Skip to content

Commit

Permalink
Rename commands in accordance with comments on #265
Browse files Browse the repository at this point in the history
  • Loading branch information
Azer0s committed Oct 1, 2019
1 parent a2cb254 commit 9e46bcf
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions examples/tests/cypress/integration/channels.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('Channels', () => {
cy.subscribe('mike', 'my.public.event');
// "foo":"bar" due to way how Cypress handles escaping of curly braces
cy.sendEvent('my.public.event', '"foo":"bar"');
cy.assertReceivedEventLog('event-log', '(.*my.public.event)(.*"foo":"bar")');
cy.assertSingleNewEventContainsMessage('event-log', '(.*my.public.event)(.*"foo":"bar")');
cy.disconnect();
});

Expand All @@ -16,11 +16,11 @@ describe('Channels', () => {
cy.subscribe('mike', 'message');
// "name":"mike","foo":"bar" due to way how Cypress handles escaping of curly braces
cy.sendEvent('message', '"name":"mike","foo":"bar"');
cy.assertReceivedEventLog('event-log', '"name":"mike","foo":"bar"');
cy.assertSingleNewEventContainsMessage('event-log', '"name":"mike","foo":"bar"');
// send constrained event for different user - John
cy.sendEvent('message', '"name":"john","foo":"bar"');
// Mike shouldn't receive any new event
cy.assertReceivedEventLog(
cy.assertSingleNewEventContainsMessage(
'event-log',
'(.*message)(.*"name":"mike","foo":"bar")'
);
Expand Down
10 changes: 5 additions & 5 deletions examples/tests/cypress/integration/subscriptions-jwt.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,33 @@ describe('Subscriptions with JWT auth', () => {
cy.visit(`/${type}-3-demo-jwt.html`);
cy.setAndVerifyInput('greeting', 'hello');
cy.submit();
cy.assertReceivedEvents('eventList', 'hello');
cy.assertNewestEventContainsMessage('eventList', 'hello');
});

it(`Applies ${type} subscription constraints tied with JWT for given event type`, () => {
cy.visit(`/${type}-demo-jwt-extractors.html`);
cy.setAndVerifyInput('greeting', 'hello');
cy.setAndVerifyInput('name', 'john');
cy.submit();
cy.assertReceivedEvents('eventList', '"name":"john","greeting":"hello"');
cy.assertNewestEventContainsMessage('eventList', '"name":"john","greeting":"hello"');
// John shouldn't receive Mike's events
cy.setAndVerifyInput('greeting', 'hello');
cy.setAndVerifyInput('name', 'mike');
cy.submit();
cy.assertReceivedEvents('eventList', '"name":"john","greeting":"hello"');
cy.assertNewestEventContainsMessage('eventList', '"name":"john","greeting":"hello"');
});

it(`Creates ${type} subscriptions based on JWT in connection call and applies constraints`, () => {
cy.visit(`/${type}-demo-jwt-extractors-conn.html`);
cy.setAndVerifyInput('greeting', 'hello');
cy.setAndVerifyInput('name', 'john.doe');
cy.submit();
cy.assertReceivedEvents('eventList', '"name":"john.doe","greeting":"hello"');
cy.assertNewestEventContainsMessage('eventList', '"name":"john.doe","greeting":"hello"');
// John Doe shouldn't receive Mike's events
cy.setAndVerifyInput('greeting', 'hello');
cy.setAndVerifyInput('name', 'mike');
cy.submit();
cy.assertReceivedEvents(
cy.assertNewestEventContainsMessage(
'eventList',
'"name":"john.doe","greeting":"hello"'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@ describe('Subscriptions with no auth', () => {
cy.visit(`/${type}-1-demo.html`);
cy.setAndVerifyInput('greeting', 'hello');
cy.submit();
cy.assertReceivedEvents('eventList', 'hello');
cy.assertNewestEventContainsMessage('eventList', 'hello');
});

it(`Creates ${type} connection and subscriptions within a same call`, () => {
cy.visit(`/${type}-demo-single-call.html`);
cy.setAndVerifyInput('greeting', 'hello');
cy.submit();
cy.assertReceivedEvents('eventList', 'hello');
cy.assertNewestEventContainsMessage('eventList', 'hello');
});

it(`Applies ${type} subscription constraints for given event type`, () => {
cy.visit(`/${type}-2-demo-simple-extractors.html`);
cy.setAndVerifyInput('greeting', 'hello');
cy.setAndVerifyInput('name', 'john');
cy.submit();
cy.assertReceivedEvents('eventList', '"name":"john","greeting":"hello"');
cy.assertNewestEventContainsMessage('eventList', '"name":"john","greeting":"hello"');
// John shouldn't receive Mike's events
cy.setAndVerifyInput('greeting', 'hello');
cy.setAndVerifyInput('name', 'mike');
cy.submit();
cy.assertReceivedEvents('eventList', '"name":"john","greeting":"hello"');
cy.assertNewestEventContainsMessage('eventList', '"name":"john","greeting":"hello"');
});
});
});
4 changes: 2 additions & 2 deletions examples/tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ Cypress.Commands.add('sendEvent', (eventType, message) => {
cy.get('#send-button').click();
});

Cypress.Commands.add('assertReceivedEvents', (element, message) => {
Cypress.Commands.add('assertNewestEventContainsMessage', (element, message) => {
// assert number and content of received events
cy.get(`#${element} > li`, {timeout: 30000})
.should('be.visible')
.first()
.contains(message)
});

Cypress.Commands.add('assertReceivedEventLog', (element, message) => {
Cypress.Commands.add('assertSingleNewEventContainsMessage', (element, message) => {
// assert number and content of received events
cy.get(`#${element}`, {timeout: 30000})
.should('have.length', 1)
Expand Down

0 comments on commit 9e46bcf

Please sign in to comment.