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

Commit

Permalink
MM-T2369 : Aspect Ratio is preserved in RHS (#8165)
Browse files Browse the repository at this point in the history
* test

* Update e2e/cypress/integration/scroll/image_aspect_ratio_spec.js

Co-authored-by: Saturnino Abril <saturnino.abril@gmail.com>
  • Loading branch information
M-ZubairAhmed and saturninoabril authored Jun 1, 2021
1 parent 713e2e7 commit fbb9716
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions e2e/cypress/integration/scroll/image_aspect_ratio_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

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

describe('Scroll', () => {
let testTeam;

beforeEach(() => {
// # Create new team and new user and visit Town Square channel
cy.apiInitSetup().then(({team, channel}) => {
testTeam = team;

cy.visit(`/${testTeam.name}/channels/${channel.name}`);
});
});

it('MM-T2369 Aspect Ratio is preserved in RHS', () => {
const uploadedImages = [
{
alt: 'Wide image',
width: 960,
height: 246,
src:
'https://cdn.pixabay.com/photo/2017/10/10/22/24/wide-format-2839089_960_720.jpg',
},
{
alt: 'Tall image',
width: 400,
height: 950,
src:
'https://media.npr.org/programs/atc/features/2009/may/short/abetall3-0483922b5fb40887fc9fbe20a606e256cbbd10ee-s800-c85.jpg',
},
];

uploadedImages.forEach((uploadedImage) => {
// # Post the image as markdown image in the center
cy.uiPostMessageQuickly(`![${uploadedImage.alt}](${uploadedImage.src})`);

// # Get uploaded image in the center
cy.getLastPost().within(() => {
// * Verify image was uploaded and its aspect ratio is unchanged
verifyImageAspectRatioCorrectness(uploadedImage);
});

// # Open the message with image in RHS
cy.clickPostCommentIcon();

// # Go to RHS where image is now opened
cy.get('#rhsContainer').within(() => {
// * Verify image in the RHS has correct aspect ratio
verifyImageAspectRatioCorrectness(uploadedImage);
});
});
});
});

function verifyImageAspectRatioCorrectness(originalImage) {
cy.findByAltText(originalImage.alt).
should('exist').
and((img) => {
expect(img.width() / img.height()).to.be.closeTo(
originalImage.width / originalImage.height,
0.01,
);
});
}

0 comments on commit fbb9716

Please sign in to comment.