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

Commit

Permalink
Cypress/E2E: Move more channels API commands (#6472)
Browse files Browse the repository at this point in the history
* cypress move channels api

* fix channel modes
  • Loading branch information
saturninoabril authored and calebroseland committed Oct 27, 2020
1 parent 9a2cd1b commit 8591c3d
Show file tree
Hide file tree
Showing 26 changed files with 254 additions and 293 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ describe('Channel settings', () => {
cy.visit(`/${myTeam.name}/channels/off-topic`);

// # Post message as the second user, in a channel near the top of the list
cy.apiGetChannelByName(myTeam.name, channelNames[firstChannelIndex]).then((response) => {
const channel = response.body;
cy.apiGetChannelByName(myTeam.name, channelNames[firstChannelIndex]).then(({channel}) => {
cy.postMessageAs({
sender: otherUser,
message: 'Bleep bloop I am a robot',
Expand All @@ -72,8 +71,7 @@ describe('Channel settings', () => {
cy.get('#unreadIndicatorTop').should('be.visible').click();

// # Post as another user in a channel near the bottom of the list, scroll channels list to view it (should be in bold)
cy.apiGetChannelByName(myTeam.name, channelNames[lastChannelIndex]).then((response) => {
const channel = response.body;
cy.apiGetChannelByName(myTeam.name, channelNames[lastChannelIndex]).then(({channel}) => {
cy.postMessageAs({
sender: otherUser,
message: 'Bleep bloop I am a robot',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ describe('Channel sidebar', () => {
cy.get('.SidebarChannel:not(.unread):contains(Town Square)').should('be.visible');

// # Have another user post in the Off Topic channel
cy.apiGetChannelByName(teamName, 'off-topic').then((response) => {
expect(response.status).to.equal(200);

const channel = response.body;
cy.apiGetChannelByName(teamName, 'off-topic').then(({channel}) => {
cy.postMessageAs({sender: sysadmin, message: 'Test', channelId: channel.id});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ describe('Keyboard shortcut for adding reactions to last message in channel or t
cy.apiCreateUser({prefix: 'other'}).then(({user: user1}) => {
otherUser = user1;

cy.apiGetChannelByName(testTeam.name, 'town-square').then((res) => {
townsquareChannel = res.body;
cy.apiGetChannelByName(testTeam.name, 'town-square').then((out) => {
townsquareChannel = out.channel;
});

cy.apiAddUserToTeam(testTeam.id, otherUser.id).then(() => {
Expand Down
5 changes: 2 additions & 3 deletions e2e/cypress/integration/enterprise/ldap/ldap_login_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,10 @@ context('ldap', () => {
cy.apiAdminLogin();

cy.apiGetTeamByName(testSettings.teamName).then(({team}) => {
cy.apiGetChannelByName(testSettings.teamName, 'town-square').then((r2) => {
const channelId = r2.body.id;
cy.apiGetChannelByName(testSettings.teamName, 'town-square').then(({channel}) => {
cy.apiGetUserByEmail(guest1.email).then(({user}) => {
cy.apiAddUserToTeam(team.id, user.id).then(() => {
cy.apiAddUserToChannel(channelId, user.id);
cy.apiAddUserToChannel(channel.id, user.id);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,15 @@ describe('Test channel public/private toggle', () => {
cy.get('#saveSetting').click();
cy.get('#confirmModalButton').click();
return cy.apiGetChannel(channel.id);
}).then((res) => {
const channel = res.body;
}).then(({channel}) => {
assert(channel.type === 'P');
cy.visit(`/admin_console/user_management/channels/${channel.id}`);
cy.get('#channel_profile').contains(channel.display_name);
cy.get('#channel_manage .group-teams-and-channels--body').find('button').eq(1).click();
cy.get('#saveSetting').click();
cy.get('#confirmModalButton').click();
return cy.apiGetChannel(channel.id);
}).then((res) => {
const channel = res.body;
}).then(({channel}) => {
assert(channel.type === 'O');
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,9 @@ describe('System Console', () => {

// # Add board user to test team to ensure that it exists in the team and set its preferences to skip tutorial step
cy.apiGetUserByEmail(boardUser.email).then(({user}) => {
cy.apiGetChannelByName(testTeam.name, 'town-square').then((channelRes) => {
const channelId = channelRes.body.id;
cy.apiGetChannelByName(testTeam.name, 'town-square').then(({channel}) => {
cy.apiAddUserToTeam(testTeam.id, user.id).then(() => {
cy.apiAddUserToChannel(channelId, user.id);
cy.apiAddUserToChannel(channel.id, user.id);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ describe('Archived channels', () => {
cy.get('.DataGrid', {timeout: TIMEOUTS.TWO_SEC}).scrollIntoView().should('be.visible');

// * Verify via the API that the channel is unarchived
cy.apiGetChannel(testChannel.id).then((response) => {
expect(response.body.delete_at).to.eq(0);
cy.apiGetChannel(testChannel.id).then(({channel}) => {
expect(channel.delete_at).to.eq(0);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ describe('Integrations', () => {
cy.apiInitSetup().then(({team}) => {
testTeam = team;

cy.apiGetChannelByName(team.name, 'off-topic').then((res) => {
offTopicChannel = res.body;
cy.apiGetChannelByName(team.name, 'off-topic').then(({channel}) => {
offTopicChannel = channel;
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ describe('Keyboard Shortcuts', () => {
dmWithSysadmin.name = sysadmin.username;
dmWithSysadmin.display_name = sysadmin.username;
});
cy.apiGetChannelByName(testTeam.name, 'town-square').then((response) => {
townSquare = response.body;
cy.apiGetChannelByName(testTeam.name, 'town-square').then((out) => {
townSquare = out.channel;
});
cy.apiGetChannelByName(testTeam.name, 'off-topic').then((response) => {
offTopic = response.body;
cy.apiGetChannelByName(testTeam.name, 'off-topic').then((out) => {
offTopic = out.channel;
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ describe('Verify unread toast appears after repeated manual marking post as unre
cy.apiInitSetup().then(({team, user}) => {
otherUser = user;

cy.apiGetChannelByName(team.name, 'town-square').then((res) => {
townSquareChannel = res.body;
cy.apiGetChannelByName(team.name, 'town-square').then(({channel}) => {
townSquareChannel = channel;

cy.apiGetChannelByName(team.name, 'off-topic').then((res2) => {
offTopicChannel = res2.body;
cy.apiGetChannelByName(team.name, 'off-topic').then((out) => {
offTopicChannel = out.channel;

// Toast only seems to appear after first visiting the channel
// So we need to visit the channel then navigate away
Expand Down
8 changes: 4 additions & 4 deletions e2e/cypress/integration/messaging/at_mentions_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ describe('at-mention', () => {
cy.apiAddUserToTeam(testTeam.id, sender.id);
});

cy.apiGetChannelByName(testTeam.name, 'town-square').then((res) => {
townsquareChannelId = res.body.id;
cy.apiGetChannelByName(testTeam.name, 'town-square').then((out) => {
townsquareChannelId = out.channel.id;
});

cy.apiGetChannelByName(testTeam.name, 'off-topic').then((res) => {
offTopicChannelId = res.body.id;
cy.apiGetChannelByName(testTeam.name, 'off-topic').then((out) => {
offTopicChannelId = out.channel.id;
});

// # Login as receiver and visit off-topic channel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ describe('Channel user count', () => {
cy.apiAddUserToTeam(testTeam.id, secondUser.id);
});

cy.apiGetChannelByName(testTeam.name, 'off-topic').then((response) => {
const channel = response.body;

cy.apiGetChannelByName(testTeam.name, 'off-topic').then(({channel}) => {
// # Add secondUser to 'off-topic' channel
cy.apiAddUserToChannel(channel.id, secondUser.id);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ const sendDirectMessageToUser = (user, message) => {

const closeDirectMessageViaXButton = (sender, recipient, team) => {
// # Find the username in the 'Direct Messages' list and trigger the 'x' button to appear (hover over the username)
cy.apiGetChannelsForUser(sender.id, team.id).then((response) => {
const channels = response.body;

cy.apiGetChannelsForUser(sender.id, team.id).then(({channels}) => {
// Get the name of the channel to build the CSS selector for that specific DM link in the sidebar
const channelDmWithFirstUser = channels.find((channel) =>
channel.type === 'D' && channel.name.includes(recipient.id),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ describe('Desktop notifications', () => {
// # Ensure notifications are set up to fire a desktop notification if are mentioned.
changeDesktopNotificationSettingsAs('#desktopNotificationMentions');

cy.apiGetChannelByName(testTeam.name, 'Off-Topic').then((res) => {
const channel = res.body;

cy.apiGetChannelByName(testTeam.name, 'Off-Topic').then(({channel}) => {
// # Logout the user.
cy.apiLogout().wait(TIMEOUTS.TEN_SEC);

Expand Down Expand Up @@ -145,10 +143,8 @@ describe('Desktop notifications', () => {
// # Ensure notifications are set up to fire a desktop notification if are mentioned.
changeDesktopNotificationSettingsAs('#desktopNotificationAllActivity');

cy.apiGetChannelByName(testTeam.name, 'Off-Topic').then((res) => {
const channel = res.body;

// Have another user send a post.
cy.apiGetChannelByName(testTeam.name, 'Off-Topic').then(({channel}) => {
// # Have another user send a post.
cy.postMessageAs({sender: testUser, message: actualMsg, channelId: channel.id});

// * Desktop notification should be received with expected body.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ describe('Notifications', () => {
cy.apiAddUserToTeam(testTeam.id, otherUser.id);
});

cy.apiGetChannelByName(testTeam.name, 'town-square').then((res) => {
townsquareChannelId = res.body.id;
cy.apiGetChannelByName(testTeam.name, 'town-square').then(({channel}) => {
townsquareChannelId = channel.id;
});

cy.visit(`/${testTeam.name}/channels/town-square`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ describe('Notifications', () => {
cy.apiAddUserToTeam(testTeam.id, otherUser.id);
});

cy.apiGetChannelByName(testTeam.name, 'town-square').then((res) => {
townsquareChannelId = res.body.id;
cy.apiGetChannelByName(testTeam.name, 'town-square').then(({channel}) => {
townsquareChannelId = channel.id;
});

cy.visit(`/${testTeam.name}/channels/town-square`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ describe('reply-notifications', () => {
cy.apiAddUserToTeam(testTeam.id, sender.id);
});

cy.apiGetChannelByName(testTeam.name, 'town-square').then((res) => {
townsquareChannelId = res.body.id;
cy.apiGetChannelByName(testTeam.name, 'town-square').then((out) => {
townsquareChannelId = out.channel.id;
});

// # Login as receiver and visit town-square channel
Expand Down
8 changes: 2 additions & 6 deletions e2e/cypress/integration/search_filter/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,14 @@ export function setupTestData(data, {team, admin, anotherAdmin}) {
cy.get('#postListContent', {timeout: TIMEOUTS.HALF_MIN}).should('be.visible');
cy.postMessage(todayMessage).wait(TIMEOUTS.ONE_SEC);

cy.apiGetChannelByName(team.name, 'town-square').then((townSquareRes) => {
const townSquareChannel = townSquareRes.body;

cy.apiGetChannelByName(team.name, 'town-square').then(({channel: townSquareChannel}) => {
// # Post message as new admin to Town Square
cy.postMessageAs({sender: anotherAdmin, message: firstMessage, channelId: townSquareChannel.id, createAt: firstDateEarly.ms});

// # Post message as sysadmin to Town Square
cy.postMessageAs({sender: admin, message: secondMessage, channelId: townSquareChannel.id, createAt: secondDateEarly.ms});

cy.apiGetChannelByName(team.name, 'off-topic').then((offTopicRes) => {
const offTopicChannel = offTopicRes.body;

cy.apiGetChannelByName(team.name, 'off-topic').then(({channel: offTopicChannel}) => {
// # Post message as sysadmin to off topic
cy.postMessageAs({sender: admin, message: firstOffTopicMessage, channelId: offTopicChannel.id, createAt: firstDateLater.ms});

Expand Down
4 changes: 2 additions & 2 deletions e2e/cypress/integration/toast/new_messages_toast_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ describe('Toast', () => {
cy.apiInitSetup().then(({team, user}) => {
testTeam = team;

cy.apiGetChannelByName(testTeam.name, 'town-square').then((res) => {
townsquareChannelId = res.body.id;
cy.apiGetChannelByName(testTeam.name, 'town-square').then(({channel}) => {
townsquareChannelId = channel.id;
});

cy.apiCreateUser().then(({user: user1}) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ describe('Toast', () => {
cy.apiAddUserToTeam(testTeam.id, otherUser.id);
});

cy.apiGetChannelByName(testTeam.name, 'town-square').then((res) => {
townsquareChannelId = res.body.id;
cy.apiGetChannelByName(testTeam.name, 'town-square').then(({channel}) => {
townsquareChannelId = channel.id;
});

cy.visit(`/${testTeam.name}/channels/town-square`);
Expand Down
4 changes: 2 additions & 2 deletions e2e/cypress/integration/toast/toast_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ describe('toasts', () => {
testTeam = team;
otherChannel = channel;

cy.apiGetChannelByName(testTeam.name, 'town-square').then((res) => {
townsquareChannelId = res.body.id;
cy.apiGetChannelByName(testTeam.name, 'town-square').then((out) => {
townsquareChannelId = out.channel.id;
});

cy.apiCreateUser().then(({user: user1}) => {
Expand Down
Loading

0 comments on commit 8591c3d

Please sign in to comment.