forked from mattermost/mattermost-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mattermostGH-12286] UI Automation: Write an automated test using Cyp…
…ress for "Markdown preview: inline image" (mattermost#4233) * Write an automated test using Cypress for "Markdown preview: inline image" * Fix lint * Correct comment and add tests for markdown images not overlapping among them * Clarify comments and make more specific gets for images * Fix lint errors * Fix lint errors * Remove unneeded test on overlapping
- Loading branch information
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
e2e/cypress/integration/messaging/markdown_preview_inline_image_spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
// *************************************************************** | ||
// - [number] 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. | ||
// *************************************************************** | ||
|
||
describe('Messaging', () => { | ||
before(() => { | ||
// # Login, set the Show Markdown Preview preference, then go to / | ||
cy.apiLogin('user-1'); | ||
cy.apiSaveShowMarkdownPreviewPreference(); | ||
cy.visit('/'); | ||
}); | ||
|
||
it('M18714-Markdown preview: inline image', () => { | ||
const message = '![make it so](https://i.stack.imgur.com/MNeE7.jpg)'; | ||
|
||
cy.visit('/ad-1/channels/town-square'); | ||
|
||
// # Get the height before starting to write | ||
cy.get('#post_textbox').should('be.visible').clear().then(() => { | ||
cy.get('#post-create').then((postArea) => { | ||
cy.wrap(parseInt(postArea[0].clientHeight, 10)).as('initialHeight'); | ||
}); | ||
}); | ||
|
||
// # Post first line to use | ||
cy.get('#post_textbox').type(message).type('{shift}{enter}').type(message); | ||
|
||
// # Click on Preview button | ||
cy.get('#previewLink').click({force: true}); | ||
|
||
cy.get('#post-list').then((postList) => { | ||
cy.get('#create_post').within(() => { | ||
cy.get('.markdown-inline-img').then((img) => { | ||
// * Images do not overlap Post List | ||
expect(postList[0].getBoundingClientRect().bottom).lessThan(img[0].getBoundingClientRect().top); | ||
expect(postList[0].getBoundingClientRect().bottom).lessThan(img[1].getBoundingClientRect().top); | ||
|
||
// * Images do not overlap among themselves | ||
expect(img[0].getBoundingClientRect().bottom <= img[1].getBoundingClientRect().top).equals(true); | ||
}); | ||
}); | ||
}); | ||
|
||
// * Post Create area should be higher than before | ||
cy.get('#post-create').then((postArea) => { | ||
cy.get('@initialHeight').should('be.lessThan', parseInt(postArea[0].clientHeight, 10)); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters