Skip to content

Commit

Permalink
fix failing e2e tests (mattermost#3014)
Browse files Browse the repository at this point in the history
  • Loading branch information
saturninoabril committed Jun 25, 2019
1 parent 664e2b9 commit bf76389
Show file tree
Hide file tree
Showing 22 changed files with 142 additions and 87 deletions.
12 changes: 12 additions & 0 deletions components/signup/signup_email/signup_email.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,24 @@ export default class SignupEmail extends React.Component {
componentDidMount() {
trackEvent('signup', 'signup_user_01_welcome');

this.setDocumentTitle(this.props.siteName);

const {inviteId} = this.state;
if (inviteId && inviteId.length > 0) {
this.getInviteInfo(inviteId);
}
}

componentDidUpdate() {
this.setDocumentTitle(this.props.siteName);
}

setDocumentTitle = (siteName) => {
if (siteName) {
document.title = siteName;
}
}

getTokenData = (token, data) => {
const parsedData = JSON.parse(data);

Expand Down
5 changes: 0 additions & 5 deletions cypress/fixtures/markdown/markdown_block_quotes_2.html

This file was deleted.

1 change: 0 additions & 1 deletion cypress/fixtures/markdown/markdown_inline_images_1.html

This file was deleted.

1 change: 0 additions & 1 deletion cypress/fixtures/markdown/markdown_inline_images_2.html

This file was deleted.

2 changes: 0 additions & 2 deletions cypress/fixtures/markdown/markdown_inline_images_3.html

This file was deleted.

2 changes: 0 additions & 2 deletions cypress/fixtures/markdown/markdown_inline_images_4.html

This file was deleted.

2 changes: 0 additions & 2 deletions cypress/fixtures/markdown/markdown_inline_images_5.html

This file was deleted.

14 changes: 7 additions & 7 deletions cypress/integration/at_mentions/at_mentions_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ function setNotificationSettings(desiredSettings = {first: true, username: true,
}

describe('at-mention', () => {
const baseUrl = Cypress.config('baseUrl');

beforeEach(() => {
cy.fixture('users').as('usersJSON');

Expand Down Expand Up @@ -117,7 +119,7 @@ describe('at-mention', () => {
const message = `@${this.receiver.username} I'm messaging you! ${Date.now()}`;

// # Use another account to post a message @-mentioning our receiver
cy.postMessageAs(this.sender, message, this.channelId);
cy.task('postMessageAs', {sender: this.sender, message, channelId: this.channelId, baseUrl});

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

Expand All @@ -127,6 +129,7 @@ describe('at-mention', () => {
cy.get('#publicChannel').scrollIntoView();

cy.get('#sidebarItem_town-square').
scrollIntoView().
find('#unreadMentions').
should('be.visible').
and('have.text', '1');
Expand Down Expand Up @@ -158,7 +161,7 @@ describe('at-mention', () => {
const message = `Hey ${this.receiver.username}! I'm messaging you! ${Date.now()}`;

// # Use another account to post a message @-mentioning our receiver
cy.postMessageAs(this.sender, message, this.channelId);
cy.task('postMessageAs', {sender: this.sender, message, channelId: this.channelId, baseUrl});

// * Verify stub was not called
cy.get('@notifySpy').should('be.not.called');
Expand Down Expand Up @@ -194,15 +197,12 @@ describe('at-mention', () => {
setNotificationSettings({first: false, username: false, shouts: false, custom: true});

const channelMentions = ['@here', '@all', '@channel'];
const sender = this.sender;
const channelId = this.channelId;
const receiver = this.receiver;

channelMentions.forEach((mention) => {
const message = `Hey ${mention} I'm message you all! ${Date.now()}`;

// # Use another account to post a message @-mentioning our receiver
cy.postMessageAs(sender, message, channelId);
cy.task('postMessageAs', {sender: this.sender, message, channelId: this.channelId, baseUrl});

// * Verify stub was not called
cy.get('@notifySpy').should('be.not.called');
Expand All @@ -228,7 +228,7 @@ describe('at-mention', () => {

// * Verify it's not highlighted
cy.get('@postMessageText').
find(`[data-mention=${receiver.username}]`).
find(`[data-mention=${this.receiver.username}]`).
should('not.exist');

cy.get('#sidebarItem_saepe-5').click({force: true});
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/channel/message_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('Message', () => {

// # Post a message to force next user message to display a message
cy.getCurrentChannelId().then((channelId) => {
cy.postMessageAs(sysadmin, 'Hello', channelId);
cy.task('postMessageAs', {sender: sysadmin, message: 'Hello', channelId, baseUrl: Cypress.config('baseUrl')});
});

// # Post message "One"
Expand Down
8 changes: 8 additions & 0 deletions cypress/integration/login/login_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ let config;

describe('Login page', () => {
before(() => {
// Disable other auth options
const newSettings = {
Office365Settings: {Enable: false},
LdapSettings: {Enable: false},
};
cy.apiUpdateConfig(newSettings);

cy.apiGetConfig().then((response) => {
config = response.body;
});
Expand All @@ -36,6 +43,7 @@ describe('Login page', () => {
cy.get('#login_section').should('be.visible');
cy.get('#site_name').should('contain', config.TeamSettings.SiteName);
cy.get('#site_description').should('contain', 'All team communication in one place, searchable and accessible anywhere');
cy.get('#loginId').should('be.visible');
cy.get('#loginId').
should('be.visible').
and(($loginTextbox) => {
Expand Down
10 changes: 10 additions & 0 deletions cypress/integration/login/signup_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ let config;

describe('Signup Email page', () => {
before(() => {
// Disable other auth options
const newSettings = {
Office365Settings: {Enable: false},
LdapSettings: {Enable: false},
};
cy.apiUpdateConfig(newSettings);

cy.apiGetConfig().then((response) => {
config = response.body;
});
Expand All @@ -23,6 +30,9 @@ describe('Signup Email page', () => {
});

it('should render', () => {
// * check the initialUrl
cy.url().should('include', '/signup_email');

// * Check that the login section is loaded
cy.get('#signup_email_section').should('be.visible');

Expand Down
51 changes: 51 additions & 0 deletions cypress/integration/markdown/markdown_image_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

// ***************************************************************
// - [#] indicates a test step (e.g. 1. Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************

/* eslint max-nested-callbacks: ["error", 4] */

import * as TIMEOUTS from '../../fixtures/timeouts';

describe('Markdown', () => {
before(() => {
cy.apiLogin('user-1');
cy.visit('/');
});

const baseUrl = Cypress.config('baseUrl');

const inlineImage1 = `<h3 class="markdown__heading">In-line Images</h3><p>Mattermost/platform build status: <a class="theme markdown__link" href="https://travis-ci.org/mattermost/platform" rel="noreferrer" target="_blank"><img alt="Build Status" class="markdown-inline-img" src="${baseUrl}/api/v4/image?url=https%3A%2F%2Ftravis-ci.org%2Fmattermost%2Fplatform.svg%3Fbranch%3Dmaster"></a></p>`;
const inlineImage2 = `<h3 class="markdown__heading">In-line Images</h3><p>GitHub favicon: <img alt="Github" class="markdown-inline-img" src="${baseUrl}/api/v4/image?url=https%3A%2F%2Fgithub.githubassets.com%2Ffavicon.ico"></p>`;
const inlineImage3 = `<h3 class="markdown__heading">In-line Images</h3><p>GIF Image:
<img alt="gif" class="markdown-inline-img" src="${baseUrl}/api/v4/image?url=http%3A%2F%2Fi.giphy.com%2FxNrM4cGJ8u3ao.gif" style=""></p>`;
const inlineImage4 = `<h3 class="markdown__heading">In-line Images</h3><p>4K Wallpaper Image (11Mb):
<img alt="4K Image" class="markdown-inline-img" src="${baseUrl}/api/v4/image?url=https%3A%2F%2Fimages.wallpaperscraft.com%2Fimage%2Fstarry_sky_shine_glitter_118976_3840x2160.jpg" style=""></p>`;
const inlineImage5 = `<h3 class="markdown__heading">In-line Images</h3><p>Panorama Image:
<img alt="Pano" class="markdown-inline-img" src="${baseUrl}/api/v4/image?url=http%3A%2F%2Famardeepphotography.com%2Fwp-content%2Fuploads%2F2012%2F11%2FUntitled_Panorama6small.jpg" style=""></p>`;

const tests = [
{name: 'with in-line images 1', fileKey: 'markdown_inline_images_1', expected: inlineImage1},
{name: 'with in-line images 2', fileKey: 'markdown_inline_images_2', expected: inlineImage2},
{name: 'with in-line images 3 (Gif)', fileKey: 'markdown_inline_images_3', expected: inlineImage3},
{name: 'with in-line images 4 (4k)', fileKey: 'markdown_inline_images_4', expected: inlineImage4},
{name: 'with in-line images 5 (Panorama)', fileKey: 'markdown_inline_images_5', expected: inlineImage5},
];

tests.forEach((test) => {
it(test.name, () => {
// # Post markdown message
cy.postMessageFromFile(`markdown/${test.fileKey}.md`);

// * Verify that HTML Content is correct.
// Note we use the Gigantic timeout to ensure that the large images will load
cy.getLastPostId().then((postId) => {
cy.get(`#postMessageText_${postId}`, {timeout: TIMEOUTS.GIGANTIC}).should('have.html', test.expected);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ const testCases = [
{name: 'Markdown - should appear as a carriage return separating two lines of text', fileKey: 'markdown_carriage_return_two_lines'},
{name: 'Markdown - in-line code', fileKey: 'markdown_inline_code'},
{name: 'Markdown - lines', fileKey: 'markdown_lines'},
{name: 'Markdown - block quotes 1', fileKey: 'markdown_block_quotes_1'},
{name: 'Markdown - block quotes 2', fileKey: 'markdown_block_quotes_2'},
{name: 'Markdown - headings', fileKey: 'markdown_headings'},
{name: 'Markdown - escape characters', fileKey: 'markdown_escape_characters'},
{name: 'Markdown - block quotes 1', fileKey: 'markdown_block_quotes_1'},
];

describe('Markdown message', () => {
Expand Down Expand Up @@ -67,24 +66,20 @@ describe('Markdown message', () => {
});
});

describe('with images', () => {
const tests = [
{name: 'Markdown - in-line images 1', fileKey: 'markdown_inline_images_1'},
{name: 'Markdown - in-line images 2', fileKey: 'markdown_inline_images_2'},
{name: 'Markdown - in-line images 3 (Gif)', fileKey: 'markdown_inline_images_3'},
{name: 'Markdown - in-line images 4 (4k)', fileKey: 'markdown_inline_images_4'},
{name: 'Markdown - in-line images 5 (Panorama)', fileKey: 'markdown_inline_images_5'},
];
it('Markdown - block quotes 2', () => {
const baseUrl = Cypress.config('baseUrl');
const expectedHtml = `<h3 class="markdown__heading">Block Quotes</h3><p><strong>The following markdown should render within the block quote:</strong></p>
<blockquote>
<h4 class="markdown__heading">Heading 4</h4><p><em>Italics</em>, <em>Italics</em>, <strong>Bold</strong>, <strong><em>Bold-italics</em></strong>, <strong><em>Bold-italics</em></strong>, <del>Strikethrough</del>
<span data-emoticon="slightly_smiling_face"><span alt=":slightly_smiling_face:" class="emoticon" title=":slightly_smiling_face:" style="background-image: url(&quot;${baseUrl}/static/emoji/1f642.png&quot;);"></span></span> <span data-emoticon="slightly_smiling_face"><span alt=":slightly_smiling_face:" class="emoticon" title=":slightly_smiling_face:" style="background-image: url(&quot;${baseUrl}/static/emoji/1f642.png&quot;);"></span></span> <span data-emoticon="wink"><span alt=":wink:" class="emoticon" title=":wink:" style="background-image: url(&quot;${baseUrl}/static/emoji/1f609.png&quot;);"></span></span> <span data-emoticon="scream"><span alt=":scream:" class="emoticon" title=":scream:" style="background-image: url(&quot;${baseUrl}/static/emoji/1f631.png&quot;);"></span></span> <span data-emoticon="bamboo"><span alt=":bamboo:" class="emoticon" title=":bamboo:" style="background-image: url(&quot;${baseUrl}/static/emoji/1f38d.png&quot;);"></span></span> <span data-emoticon="gift_heart"><span alt=":gift_heart:" class="emoticon" title=":gift_heart:" style="background-image: url(&quot;${baseUrl}/static/emoji/1f49d.png&quot;);"></span></span> <span data-emoticon="dolls"><span alt=":dolls:" class="emoticon" title=":dolls:" style="background-image: url(&quot;${baseUrl}/static/emoji/1f38e.png&quot;);"></span></span></p>
</blockquote>`;

tests.forEach((test) => {
it(test.name, () => {
// # Post markdown message
cy.postMessageFromFile(`markdown/${test.fileKey}.md`);
// # Post markdown message
cy.postMessageFromFile('markdown/markdown_block_quotes_2.md');

// * Verify that HTML Content is correct.
// Note we use the Gigantic timeout to ensure that the large images will load
cy.compareLastPostHTMLContentFromFile(`markdown/${test.fileKey}.html`, TIMEOUTS.GIGANTIC);
});
// * Verify that HTML Content is correct
cy.getLastPostId().then((postId) => {
cy.get(`#postMessageText_${postId}`, {timeout: TIMEOUTS.MEDIUM}).should('have.html', expectedHtml);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ function signupWithEmail(name, pw) {

describe('Email Address', () => {
before(() => {
// Set EnableOpenServer to true
// Set EnableOpenServer to true and disable other auth options
const newSettings = {
TeamSettings: {EnableOpenServer: true},
Office365Settings: {Enable: false},
LdapSettings: {Enable: false},
};
cy.apiUpdateConfig(newSettings);
});
Expand Down
Loading

0 comments on commit bf76389

Please sign in to comment.