Skip to content

Commit

Permalink
MM-27208 MM-T1683 Add unit test for joining a public channel via a li…
Browse files Browse the repository at this point in the history
  • Loading branch information
hmhealey authored Sep 23, 2020
1 parent 88511bf commit 9a936b1
Showing 1 changed file with 60 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,19 @@
// Group: @channel

import {getAdminAccount} from '../../support/env';
import {getRandomId} from '../../utils';

describe('Archived channels', () => {
let testTeam;
let testUser;

before(() => {
cy.apiUpdateConfig({
TeamSettings: {
ExperimentalViewArchivedChannels: true,
},
});

cy.apiInitSetup().then(({team, user}) => {
testTeam = team;
testUser = user;
Expand Down Expand Up @@ -51,17 +58,62 @@ describe('Archived channels', () => {
// * Verify that we've logged in as the test user
cy.get('#headerUsername').should('contain', '@' + testUser.username);

// * Verify that we've switched to the correct channel and that the header contains the archived icon
cy.get('#channelHeaderTitle').should('contain', channel.display_name);
cy.get('#channelHeaderInfo .icon__archive').should('be.visible');
verifyViewingArchivedChannel(channel);
});
});
});

it('MM-T1683 Join an archived channel by selecting a link to channel', () => {
// # Log in as another user
cy.apiAdminLogin();

// # Create a new channel
cy.apiCreateChannel(testTeam.id, 'channel', 'channel').then(({channel}) => {
const channelLink = `/${testTeam.name}/channels/${channel.name}`;

// # Visit the channel and archive it
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
cy.uiArchiveChannel();

// * Verify that the channel is visible in the sidebar with the archived icon
cy.get(`#sidebarItem_${channel.name}`).should('be.visible');
cy.get(`#sidebarItem_${channel.name} .icon__archive`).should('be.visible');
// # Visit Town Square
cy.visit(`/${testTeam.name}/channels/town-square`);

// * Verify that the archived channel banner is visible at the bottom of the channel view
cy.get('#channelArchivedMessage').should('be.visible');
// # Make a post linking to the archived channel
const linkText = `link ${getRandomId()}`;
cy.getCurrentChannelId().then((currentChannelId) => {
cy.postMessageAs({
sender: getAdminAccount(),
message: `This is a link: [${linkText}](${channelLink})`,
channelId: currentChannelId,
});
});

// # Log out and back in as the test user
cy.apiLogin(testUser);

// # Visit Town Square
cy.visit(`/${testTeam.name}/channels/town-square`);

// * Verify that we've logged in as the test user
cy.get('#headerUsername').should('contain', '@' + testUser.username);

// * Verify that the link exists and then click on it
cy.contains('a', linkText).should('be.visible').click();

verifyViewingArchivedChannel(channel);
});
});
});

function verifyViewingArchivedChannel(channel) {
// * Verify that we've switched to the correct channel and that the header contains the archived icon
cy.get('#channelHeaderTitle').should('contain', channel.display_name);
cy.get('#channelHeaderInfo .icon__archive').should('be.visible');

// * Verify that the channel is visible in the sidebar with the archived icon
cy.get(`#sidebarItem_${channel.name}`).should('be.visible');
cy.get(`#sidebarItem_${channel.name} .icon__archive`).should('be.visible');

// * Verify that the archived channel banner is visible at the bottom of the channel view
cy.get('#channelArchivedMessage').should('be.visible');
}

0 comments on commit 9a936b1

Please sign in to comment.