Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Cypress/E2E: Fix channel switcher spec (#6662)
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Baylon authored Oct 7, 2020
1 parent 4a4e3cf commit f8ef44e
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions e2e/cypress/integration/channel/channel_switcher_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@

describe('Channel Switcher', () => {
let testTeam;
const channelNamePrefix = 'achannel';
const channelDisplayNamePrefix = 'ASwitchChannel';

before(() => {
cy.apiInitSetup().then(({team, user}) => {
cy.apiInitSetup({channelPrefix: {name: `${channelNamePrefix}-a`, displayName: `${channelDisplayNamePrefix} A`}}).then(({team, user}) => {
testTeam = team;

// # Add some channels
cy.apiCreateChannel(testTeam.id, 'channel-a', 'SwitchChannel A', 'O');
cy.apiCreateChannel(testTeam.id, 'channel-b', 'SwitchChannel B', 'O');
cy.apiCreateChannel(testTeam.id, 'channel-c', 'SwitchChannel C', 'O');
cy.apiCreateChannel(testTeam.id, `${channelNamePrefix}-b`, `${channelDisplayNamePrefix} B`, 'O');
cy.apiCreateChannel(testTeam.id, `${channelNamePrefix}-c`, `${channelDisplayNamePrefix} C`, 'O');

// # Login as test user and go to town square
cy.apiLogin(user);
Expand All @@ -34,33 +35,33 @@ describe('Channel Switcher', () => {
// # Start typing channel name in the "Switch Channels" modal message box
// # Use up/down arrow keys to highlight second channel
// # Press ENTER
cy.get('#quickSwitchInput').type('SwitchChannel ').type('{downarrow}').type('{downarrow}').type('{enter}');
cy.get('#quickSwitchInput').type(`${channelDisplayNamePrefix} `).type('{downarrow}').type('{downarrow}').type('{enter}');

// * Expect channel title to match title
cy.get('#channelHeaderTitle').
should('be.visible').
and('contain.text', 'SwitchChannel B');
and('contain.text', `${channelDisplayNamePrefix} B`);

// * Expect url to match url
cy.url().should('contain', 'channel-b');
cy.url().should('contain', `${channelNamePrefix}-b`);
});

it('MM-T2031_2 - should switch channels by mouse', () => {
// # Press CTRL+K (Windows) or CMD+K(Mac)
cy.typeCmdOrCtrl().type('K', {release: true});

// # Start typing channel name in the "Switch Channels" modal message box
cy.get('#quickSwitchInput').type('SwitchChannel ');
cy.get('#quickSwitchInput').type(`${channelDisplayNamePrefix} `);

cy.get('[data-testid^=channel-c] > span').click();
cy.get(`[data-testid^=${channelNamePrefix}-c] > span`).click();

// * Expect channel title to match title
cy.get('#channelHeaderTitle').
should('be.visible').
and('contain.text', 'SwitchChannel C');
and('contain.text', `${channelDisplayNamePrefix} C`);

// * Expect url to match url
cy.url().should('contain', 'channel-c');
cy.url().should('contain', `${channelNamePrefix}-c`);
});

it('MM-T2031_3 - should show empty result', () => {
Expand Down

0 comments on commit f8ef44e

Please sign in to comment.