Skip to content

Commit

Permalink
fix e2e tests for channel at-mentions and tooltips (mattermost#5058)
Browse files Browse the repository at this point in the history
  • Loading branch information
saturninoabril authored Mar 16, 2020
1 parent d91c851 commit 850bc1e
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 76 deletions.
6 changes: 6 additions & 0 deletions e2e/cypress/integration/at_mentions/at_mentions_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ describe('at-mention', () => {

const body = `@${sender.username}: ${message}`;

cy.get('@notifySpy').should('have.been.calledWithMatch', 'Town Square', (args) => {
expect(args.body, `Notification body: "${args.body}" should match: "${body}"`).to.equal(body);
expect(args.tag, `Notification tag: "${args.tag}" should match: "${body}"`).to.equal(body);
return true;
});

cy.get('@notifySpy').should('have.been.calledWithMatch',
'Town Square', {body, tag: body, requireInteraction: false, silent: false});

Expand Down
149 changes: 73 additions & 76 deletions e2e/cypress/integration/channel/channel_name_tooltips_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,105 +35,102 @@ function verifyChannel(res, verifyExistence = true) {

describe('channel name tooltips', () => {
let loggedUser;
let team;

before(() => {
cy.loginAsNewUser().then((user) => {
loggedUser = user;
// # Login and go to /
cy.apiLogin('sysadmin');

// # Go to "/"
cy.visit('/ad-1/channels/town-square');
// # Create new test team
cy.apiCreateTeam('test-team', 'Test Team').then((response) => {
team = response.body;
cy.loginAsNewUser({}, [team.id]).then((user) => {
loggedUser = user;

// # Go to "/"
cy.visit(`/${response.body.name}/town-square`);
});
});
});

it('Should show tooltip on hover - open/public channel with long name', () => {
cy.getCurrentTeamId().then((teamId) => {
// # Create new test channel
cy.apiCreateChannel(
teamId,
'channel-test',
`Public channel with a long name-${timestamp}`
).then((res) => {
verifyChannel(res);
});
// # Create new test channel
cy.apiCreateChannel(
team.id,
'channel-test',
`Public channel with a long name-${timestamp}`
).then((res) => {
verifyChannel(res);
});
});

it('Should show tooltip on hover - private channel with long name', () => {
cy.getCurrentTeamId().then((teamId) => {
// # Create new test channel
cy.apiCreateChannel(
teamId,
'channel-test',
`Private channel with a long name-${timestamp}`,
'P'
).then((res) => {
verifyChannel(res);
});
// # Create new test channel
cy.apiCreateChannel(
team.id,
'channel-test',
`Private channel with a long name-${timestamp}`,
'P'
).then((res) => {
verifyChannel(res);
});
});

it('Should not show tooltip on hover - open/public channel with short name', () => {
cy.getCurrentTeamId().then((teamId) => {
// # Create new test channel
cy.apiCreateChannel(
teamId,
'channel-test',
'Public channel',
).then((res) => {
verifyChannel(res, false);
});
// # Create new test channel
cy.apiCreateChannel(
team.id,
'channel-test',
'Public channel',
).then((res) => {
verifyChannel(res, false);
});
});

it('Should not show tooltip on hover - private channel with short name', () => {
cy.getCurrentTeamId().then((teamId) => {
// # Create new test channel
cy.apiCreateChannel(
teamId,
'channel-test',
'Private channel',
'P'
).then((res) => {
verifyChannel(res, false);
});
// # Create new test channel
cy.apiCreateChannel(
team.id,
'channel-test',
'Private channel',
'P'
).then((res) => {
verifyChannel(res, false);
});
});

it('Should show tooltip on hover - user with a long username', () => {
cy.getCurrentTeamId().then((teamId) => {
// # Create new user
cy.createNewUser({
email: `longUser${timestamp}@sample.mattermost.com`,
username: `thisIsALongUsername${timestamp}`,
firstName: `thisIsALongFirst${timestamp}`,
lastName: `thisIsALongLast${timestamp}`,
nickname: `thisIsALongNickname${timestamp}`,
password: 'password123',
}, [teamId]).then((user) => {
// # Open a DM with the user
cy.get('#addDirectChannel').should('be.visible').click();
cy.focused().as('searchBox').type(user.username, {force: true});

// * Verify that the user is selected in the results list before typing enter
cy.get('div.more-modal__row').
should('have.length', 1).
and('have.class', 'clickable').
and('have.class', 'more-modal__row--selected').
and('contain.text', user.username.toLowerCase());

cy.get('@searchBox').type('{enter}', {force: true});
cy.get('#saveItems').should('be.visible').click();

// # Hover on the channel name
// cy.get(`#sidebarItem_${loggedUser.id}__${user.id}`).should('be.visible').trigger('mouseover');
cy.get(`#sidebarItem_${Cypress._.sortBy([loggedUser.id, user.id]).join('__')}`).should('be.visible').trigger('mouseover');

// * Verify that the tooltip is displayed
cy.get('div.tooltip-inner').should('be.visible');

// # Move cursor away from channel
cy.get(`#sidebarItem_${Cypress._.sortBy([loggedUser.id, user.id]).join('__')}`).should('be.visible').trigger('mouseout');
});
// # Create new user
cy.createNewUser({
email: `longUser${timestamp}@sample.mattermost.com`,
username: `thisIsALongUsername${timestamp}`,
firstName: `thisIsALongFirst${timestamp}`,
lastName: `thisIsALongLast${timestamp}`,
nickname: `thisIsALongNickname${timestamp}`,
password: 'password123',
}, [team.id]).then((user) => {
// # Open a DM with the user
cy.get('#addDirectChannel').should('be.visible').click();
cy.focused().as('searchBox').type(user.username, {force: true});

// * Verify that the user is selected in the results list before typing enter
cy.get('div.more-modal__row').
should('have.length', 1).
and('have.class', 'clickable').
and('have.class', 'more-modal__row--selected').
and('contain.text', user.username.toLowerCase());

cy.get('@searchBox').type('{enter}', {force: true});
cy.get('#saveItems').should('be.visible').click();

// # Hover on the channel name
cy.get(`#sidebarItem_${Cypress._.sortBy([loggedUser.id, user.id]).join('__')}`).scrollIntoView().should('be.visible').trigger('mouseover');

// * Verify that the tooltip is displayed
cy.get('div.tooltip-inner').should('be.visible');

// # Move cursor away from channel
cy.get(`#sidebarItem_${Cypress._.sortBy([loggedUser.id, user.id]).join('__')}`).scrollIntoView().should('be.visible').trigger('mouseout');
});
});
});

0 comments on commit 850bc1e

Please sign in to comment.