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

Cypress/E2E: Move cypress channel api commands #6441

Merged
merged 1 commit into from
Sep 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ describe('Verify Accessibility Support in different input fields', () => {
});

beforeEach(() => {
cy.apiCreateChannel(testTeam.id, 'accessibility', 'accessibility').then((response) => {
testChannel = response.body;
cy.apiCreateChannel(testTeam.id, 'accessibility', 'accessibility').then(({channel}) => {
testChannel = channel;
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
});
});
Expand Down
8 changes: 4 additions & 4 deletions e2e/cypress/integration/channel/add_users_to_channel_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ describe('CS15445 Join/leave messages', () => {

it('Single User: Usernames are links, open profile popovers', () => {
// # Create and visit new channel
cy.apiCreateChannel(testTeam.id, 'channel-test', 'Channel').then((res) => {
cy.visit(`/${testTeam.name}/channels/${res.body.name}`);
cy.apiCreateChannel(testTeam.id, 'channel-test', 'Channel').then(({channel}) => {
cy.visit(`/${testTeam.name}/channels/${channel.name}`);

// # Add users to channel
addNumberOfUsersToChannel(1);
Expand All @@ -91,8 +91,8 @@ describe('CS15445 Join/leave messages', () => {

it('Combined Users: Usernames are links, open profile popovers', () => {
// # Create and visit new channel
cy.apiCreateChannel(testTeam.id, 'channel-test', 'Channel').then((res) => {
cy.visit(`/${testTeam.name}/channels/${res.body.name}`);
cy.apiCreateChannel(testTeam.id, 'channel-test', 'Channel').then(({channel}) => {
cy.visit(`/${testTeam.name}/channels/${channel.name}`);

addNumberOfUsersToChannel(3);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ describe('Channel', () => {
ownChannel = channel;
testUser = user;

cy.apiCreateChannel(testTeam.id, 'delta-test', 'Delta Channel').then((res) => {
otherChannel = res.body;
cy.apiCreateChannel(testTeam.id, 'delta-test', 'Delta Channel').then((out) => {
otherChannel = out.channel;
});

cy.apiLogin(testUser);
Expand Down
22 changes: 10 additions & 12 deletions e2e/cypress/integration/channel/channel_name_tooltips_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ import * as TIMEOUTS from '../../fixtures/timeouts';

const timestamp = Date.now();

function verifyChannel(res, verifyExistence = true) {
const channel = res.body;

// # Wait for Channel to be c
function verifyChannel(channel, verifyExistence = true) {
// # Wait for Channel to be created
cy.wait(TIMEOUTS.HALF_SEC);

// # Hover on the channel name
Expand Down Expand Up @@ -63,8 +61,8 @@ describe('channel name tooltips', () => {
testTeam.id,
'channel-test',
`Public channel with a long name-${timestamp}`,
).then((res) => {
verifyChannel(res);
).then(({channel}) => {
verifyChannel(channel);
});
});

Expand All @@ -75,8 +73,8 @@ describe('channel name tooltips', () => {
'channel-test',
`Private channel with a long name-${timestamp}`,
'P',
).then((res) => {
verifyChannel(res);
).then(({channel}) => {
verifyChannel(channel);
});
});

Expand All @@ -86,8 +84,8 @@ describe('channel name tooltips', () => {
testTeam.id,
'channel-test',
'Public channel',
).then((res) => {
verifyChannel(res, false);
).then(({channel}) => {
verifyChannel(channel, false);
});
});

Expand All @@ -98,8 +96,8 @@ describe('channel name tooltips', () => {
'channel-test',
'Private channel',
'P',
).then((res) => {
verifyChannel(res, false);
).then(({channel}) => {
verifyChannel(channel, false);
});
});

Expand Down
18 changes: 6 additions & 12 deletions e2e/cypress/integration/channel/channel_routing_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,21 @@ describe('Channel routing', () => {

it('should go to private channel view', () => {
// # Create a private channel
cy.apiCreateChannel(testTeam.id, 'private-channel', 'Private channel', 'P').then((response) => {
cy.apiCreateChannel(testTeam.id, 'private-channel', 'Private channel', 'P').then(({channel}) => {
// # Go to the newly created channel
cy.visit(`/${testTeam.name}/channels/${response.body.name}`);
cy.visit(`/${testTeam.name}/channels/${channel.name}`);

// * Check you can go to the channel without problem
cy.get('#channelHeaderTitle').should('be.visible').should('contain', 'Private channel');

// # Remove the created channel
cy.apiDeleteChannel(response.body.id);
cy.apiDeleteChannel(channel.id);
});
});

it('should go to self direct channel using the multiple ways to go', () => {
// # Create a self direct channel
cy.apiCreateDirectChannel([testUser.id, testUser.id]).then((response) => {
const ownDMChannel = response.body;

cy.apiCreateDirectChannel([testUser.id, testUser.id]).then(({channel: ownDMChannel}) => {
// # Visit the channel using the channel name
cy.visit(`/${testTeam.name}/channels/${testUser.id}__${testUser.id}`);

Expand Down Expand Up @@ -91,9 +89,7 @@ describe('Channel routing', () => {

it('should go to other user direct channel using multiple ways to go', () => {
// # Create a direct channel between two users
cy.apiCreateDirectChannel([testUser.id, otherUser1.id]).then((response) => {
const dmChannel = response.body;

cy.apiCreateDirectChannel([testUser.id, otherUser1.id]).then(({channel: dmChannel}) => {
// # Visit the channel using the channel name
cy.visit(`/${testTeam.name}/channels/${testUser.id}__${otherUser1.id}`);

Expand Down Expand Up @@ -124,9 +120,7 @@ describe('Channel routing', () => {
const userGroupIds = [testUser.id, otherUser1.id, otherUser2.id];

// # Create a group channel for 3 users
cy.apiCreateGroupChannel(userGroupIds).then((response) => {
const gmChannel = response.body;

cy.apiCreateGroupChannel(userGroupIds).then(({channel: gmChannel}) => {
// # Visit the channel using the name using the channels route
cy.visit(`/${testTeam.name}/channels/${gmChannel.name}`);

Expand Down
4 changes: 2 additions & 2 deletions e2e/cypress/integration/channel/channel_settings_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
describe('Channel Settings', () => {
before(() => {
cy.apiInitSetup().then(({team, user}) => {
cy.apiCreateChannel(team.id, 'channel', 'Private Channel', 'P').then((res) => {
cy.apiAddUserToChannel(res.body.id, user.id);
cy.apiCreateChannel(team.id, 'channel', 'Private Channel', 'P').then(({channel}) => {
cy.apiAddUserToChannel(channel.id, user.id);
});

cy.apiLogin(user);
Expand Down
8 changes: 2 additions & 6 deletions e2e/cypress/integration/channel/close_direct_group_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,7 @@ describe('Close direct messages', () => {
});

function createAndVisitDMChannel(userIds) {
return cy.apiCreateDirectChannel(userIds).then((res) => {
const channel = res.body;

return cy.apiCreateDirectChannel(userIds).then(({channel}) => {
// # Visit the new channel
cy.visit(`/${testTeam.name}/channels/${channel.name}`);

Expand Down Expand Up @@ -124,9 +122,7 @@ describe('Close group messages', () => {

function createAndVisitGMChannel(users = []) {
const userIds = users.map((user) => user.id);
return cy.apiCreateGroupChannel(userIds).then((res) => {
const channel = res.body;

return cy.apiCreateGroupChannel(userIds).then(({channel}) => {
// # Visit the new channel
cy.visit(`/${testTeam.name}/channels/${channel.name}`);

Expand Down
16 changes: 4 additions & 12 deletions e2e/cypress/integration/channel/convert_channel_to_private_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ describe('Channels', () => {
cy.apiLogin(testUser);

// # Create new test channel
cy.apiCreateChannel(testTeam.id, 'channel-test', 'Channel').then((channelRes) => {
const channel = channelRes.body;

cy.apiCreateChannel(testTeam.id, 'channel-test', 'Channel').then(({channel}) => {
// # Go to test channel
cy.visit(`/${testTeam.name}/channels/${channel.name}`);

Expand All @@ -60,9 +58,7 @@ describe('Channels', () => {
cy.apiLogin(testUser);

// # Create new test channel
cy.apiCreateChannel(testTeam.id, 'channel-test', 'Channel').then((channelRes) => {
const channel = channelRes.body;

cy.apiCreateChannel(testTeam.id, 'channel-test', 'Channel').then(({channel}) => {
// # Go to test channel
cy.visit(`/${testTeam.name}/channels/${channel.name}`);

Expand All @@ -87,9 +83,7 @@ describe('Channels', () => {
cy.apiLogin(testUser);

// # Create new test channel
cy.apiCreateChannel(testTeam.id, 'channel-test', 'Channel').then((channelRes) => {
const channel = channelRes.body;

cy.apiCreateChannel(testTeam.id, 'channel-test', 'Channel').then(({channel}) => {
// # Go to test channel
cy.visit(`/${testTeam.name}/channels/${channel.name}`);

Expand All @@ -107,9 +101,7 @@ describe('Channels', () => {
cy.apiLogin(testUser);

// # Create new test channel
cy.apiCreateChannel(testTeam.id, 'channel-test', 'Channel').then((channelRes) => {
const channel = channelRes.body;

cy.apiCreateChannel(testTeam.id, 'channel-test', 'Channel').then(({channel}) => {
// # Go to test channel
cy.visit(`/${testTeam.name}/channels/${channel.name}`);

Expand Down
4 changes: 2 additions & 2 deletions e2e/cypress/integration/channel/more_channels_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ describe('Channels', () => {

cy.apiLogin(testUser).then(() => {
// # Create new test channel
cy.apiCreateChannel(testTeam.id, 'channel-test', 'Channel').then((channelRes) => {
testChannel = channelRes.body;
cy.apiCreateChannel(testTeam.id, 'channel-test', 'Channel').then(({channel}) => {
testChannel = channel;
});

// # Go to town square
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ describe('Channel settings', () => {
// # Create 20 channels (based on length of channelNames array) to ensure that the channels list is scrollable
cy.wrap(channelNames).each((name) => {
const displayName = `channel-${name}`;
cy.apiCreateChannel(team.id, name, displayName, 'O', '', '', false).then((response) => {
const testChannel = response.body;

cy.apiCreateChannel(team.id, name, displayName, 'O', '', '', false).then(({channel}) => {
// # Add our 2 created users to each channel so they can both post messages
cy.apiAddUserToChannel(testChannel.id, mainUser.id);
cy.apiAddUserToChannel(testChannel.id, otherUser.id);
cy.apiAddUserToChannel(channel.id, mainUser.id);
cy.apiAddUserToChannel(channel.id, otherUser.id);
});
});
});
Expand Down
4 changes: 1 addition & 3 deletions e2e/cypress/integration/channel_sidebar/dm_category_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ describe('MM-T3156 DM category', () => {
usersPrefixes.forEach((prefix) => {
// # Create users with prefixes in alphabetical order
cy.apiCreateUser({prefix}).then(({user: newUser}) => {
cy.apiCreateDirectChannel([testUser.id, newUser.id]).then((res) => {
const channel = res.body;

cy.apiCreateDirectChannel([testUser.id, newUser.id]).then(({channel}) => {
// # Post message in The DM channel
cy.postMessageAs({sender: newUser, message: 'test', channelId: channel.id});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ describe('Autocomplete with Elasticsearch - Channel', () => {
const name = 'hellothere';

// # Create a new channel
cy.apiCreateChannel(testTeam.id, name, name).then((channelResponse) => {
channelId = channelResponse.body.id;
cy.apiCreateChannel(testTeam.id, name, name).then(({channel}) => {
channelId = channel.id;
});

// * Verify channel without special characters appears normally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ describe('Autocomplete with Elasticsearch - Renaming', () => {
const newChannelName = 'updatedchannel' + Date.now();

// # Create a new channel
cy.apiCreateChannel(testTeam.id, channelName, channelName).then((channelResponse) => {
const channel = channelResponse.body;

cy.apiCreateChannel(testTeam.id, channelName, channelName).then(({channel}) => {
// # Channel should appear in search results pre-change
searchAndVerifyChannel(channel);

Expand Down Expand Up @@ -118,8 +116,8 @@ describe('Autocomplete with Elasticsearch - Renaming', () => {
const channelName = 'another-channel' + Date.now();

// # Create a new channel
cy.apiCreateChannel(testTeam.id, channelName, channelName).then((channelResponse) => {
testChannel = channelResponse.body;
cy.apiCreateChannel(testTeam.id, channelName, channelName).then(({channel}) => {
testChannel = channel;

// # Channel should appear in search results pre-change
searchAndVerifyChannel(testChannel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,7 @@ describe('Autocomplete with Elasticsearch - Users', () => {

// # Create new channel and add user to channel
const channelName = `new-channel-${timestamp}`;
cy.apiCreateChannel(testTeam.id, channelName, channelName).then((channelResponse) => {
const channel = channelResponse.body;

cy.apiCreateChannel(testTeam.id, channelName, channelName).then(({channel}) => {
cy.apiGetUserByEmail(thor.email).then(({user}) => {
cy.apiAddUserToChannel(channel.id, user.id);
});
Expand Down
16 changes: 7 additions & 9 deletions e2e/cypress/integration/enterprise/ldap/ldap_group_sync_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ context('ldap', () => {
});

// # Create a test channel
cy.apiCreateChannel(testTeam.id, 'ldap-group-sync-automated-tests', 'ldap-group-sync-automated-tests').then((response) => {
testChannel = response.body;
cy.apiCreateChannel(testTeam.id, 'ldap-group-sync-automated-tests', 'ldap-group-sync-automated-tests').then(({channel}) => {
testChannel = channel;
});
});
});
Expand Down Expand Up @@ -240,8 +240,8 @@ context('ldap', () => {
'private-channel-test',
'Private channel',
'P',
).then((res) => {
const privateChannel = res.body;
).then(({channel}) => {
const privateChannel = channel;

// # Visit channel configuration of private channel
cy.visit(`/admin_console/user_management/channels/${privateChannel.id}`);
Expand Down Expand Up @@ -389,8 +389,7 @@ context('ldap', () => {
'a-channel-im-not-apart-off',
'Public channel',
'O',
).then((res) => {
const publicChannel = res.body;
).then(({channel: publicChannel}) => {
cy.apiLogin(testUser);

cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
Expand Down Expand Up @@ -444,8 +443,7 @@ context('ldap', () => {
'a-channel-im-not-apart-off',
'Public channel',
'O',
).then((res) => {
const publicChannel = res.body;
).then(({channel: publicChannel}) => {
cy.apiLogin(testUser);

// # Click more under public channels
Expand All @@ -460,7 +458,7 @@ context('ldap', () => {
cy.apiAdminLogin();
cy.apiPatchChannelPrivacy(publicChannel.id, 'P');

// # Login as a nromal user
// # Login as a normal user
cy.apiLogin(testUser);

// # Click more under public channels
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ describe('Test channel public/private toggle', () => {
});

it('Verify that System Admin can change channel privacy using toggle', () => {
cy.apiCreateChannel(testTeam.id, 'test-channel', 'Test Channel').then((res) => {
const channel = res.body;
cy.apiCreateChannel(testTeam.id, 'test-channel', 'Test Channel').then(({channel}) => {
assert(channel.type === 'O');
cy.visit(`/admin_console/user_management/channels/${channel.id}`);
cy.get('#channel_profile').contains(channel.display_name);
Expand All @@ -62,8 +61,7 @@ describe('Test channel public/private toggle', () => {
});

it('Verify that resetting sync toggle doesn\'t alter channel privacy toggle', () => {
cy.apiCreateChannel(testTeam.id, 'test-channel', 'Test Channel').then((res) => {
const channel = res.body;
cy.apiCreateChannel(testTeam.id, 'test-channel', 'Test Channel').then(({channel}) => {
assert(channel.type === 'O');
cy.visit(`/admin_console/user_management/channels/${channel.id}`);
cy.get('#channel_profile').contains(channel.display_name);
Expand Down
Loading