From 7ea84cb422af2cd9c4ebb9626f6d8ccb7764d9e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Carden=CC=83a?= <35935591+luisecm@users.noreply.github.com> Date: Fri, 27 Oct 2023 10:27:13 -0600 Subject: [PATCH] test(update): adding cropper tool tests for banner and profile --- .../settings/SettingsProfileScreen.ts | 15 +++--- tests/specs/05-settings-profile.spec.ts | 49 +++++++++++++------ .../specs/14-create-reusable-accounts.spec.ts | 4 +- 3 files changed, 43 insertions(+), 25 deletions(-) diff --git a/tests/screenobjects/settings/SettingsProfileScreen.ts b/tests/screenobjects/settings/SettingsProfileScreen.ts index a8cd51d9dfe..1bffd9b1fd4 100644 --- a/tests/screenobjects/settings/SettingsProfileScreen.ts +++ b/tests/screenobjects/settings/SettingsProfileScreen.ts @@ -13,7 +13,6 @@ import { USER_A_INSTANCE, } from "@helpers/constants"; import SettingsBaseScreen from "@screenobjects/settings/SettingsBaseScreen"; -import { get } from "http"; const currentOS = driver[USER_A_INSTANCE].capabilities.automationName; const robot = require("robotjs"); @@ -335,7 +334,7 @@ export default class SettingsProfileScreen extends SettingsBaseScreen { ); } - async uploadBannerPicture(relativePath: string) { + async selectBannerPicture(relativePath: string) { // Invoke File Selection method depending on current OS driver // If Windows driver is running, first retrieve the current context and pass it to file selection function const currentDriver = await this.getCurrentDriver(); @@ -350,10 +349,6 @@ export default class SettingsProfileScreen extends SettingsBaseScreen { await profileBannerWindows.click(); await selectFileOnWindows(relativePath, uplinkContext, executor); } - - // Validate that profile banner is displayed on screen - const profileBannerImage = await this.profileBanner; - await profileBannerImage.waitForExist(); } async selectProfilePicture(relativePath: string) { @@ -373,8 +368,14 @@ export default class SettingsProfileScreen extends SettingsBaseScreen { } } - async validateProfilePictureIsShown() { + async validateBannerPictureIsShown() { // Validate that profile banner is displayed on screen + const bannerImage = await this.profileBanner; + await bannerImage.waitForExist(); + } + + async validateProfilePictureIsShown() { + // Validate that profile picture is displayed on screen const profilePictureImage = await this.profilePicture; await profilePictureImage.waitForExist(); } diff --git a/tests/specs/05-settings-profile.spec.ts b/tests/specs/05-settings-profile.spec.ts index cfab85006ae..124a3a96019 100644 --- a/tests/specs/05-settings-profile.spec.ts +++ b/tests/specs/05-settings-profile.spec.ts @@ -72,8 +72,7 @@ export default async function settingsProfile() { await expect(statusInput).toHaveTextContaining(""); }); - // Needs rework for adding the cropping tool on banner pictures - xit("Settings Profile - Profile picture - Display Crop Tool Modal", async () => { + it("Settings Profile - Profile picture - Display Crop Tool Modal", async () => { // Click on profile picture upload button and select the file logo.jpg await settingsProfileFirstUser.selectProfilePicture( "./tests/fixtures/logo.jpg" @@ -83,8 +82,7 @@ export default async function settingsProfile() { await cropProfileFirstUser.validateCropToolModalIsShown(); }); - // Needs rework for adding the cropping tool on banner pictures - xit("Settings Profile - Profile Picture - Crop Tool Modal elements", async () => { + it("Settings Profile - Profile Picture - Crop Tool Modal elements", async () => { // Validate Image Preview is displayed on Profile Picture Crop Tool Modal await cropProfileFirstUser.cropImagePreview.waitForExist(); @@ -107,15 +105,13 @@ export default async function settingsProfile() { await expect(rangeValueText).toHaveTextContaining("1"); }); - // Needs rework for adding the cropping tool on banner pictures - xit("Settings Profile - Profile Picture - Close Crop Tool Modal", async () => { + it("Settings Profile - Profile Picture - Close Crop Tool Modal", async () => { // Click on Cancel button and assert Crop Tool Modal is closed await cropProfileFirstUser.clickOnCancelButton(); await cropProfileFirstUser.cropImageModal.waitForExist({ reverse: true }); }); - // Needs rework for adding the cropping tool on banner pictures - xit("Settings Profile - Profile Picture - Crop Image and add profile picture", async () => { + it("Settings Profile - Profile Picture - Crop Image and add profile picture", async () => { // Click on profile picture upload button and select the file logo.jpg await settingsProfileFirstUser.selectProfilePicture( "./tests/fixtures/logo.jpg" @@ -153,15 +149,24 @@ export default async function settingsProfile() { }); // Needs visual validation steps to ensure that picture was actually loaded matches with expected image - // Needs rework for adding the cropping tool on banner pictures - xit("Settings Profile - Add banner picture", async () => { - await settingsProfileFirstUser.uploadBannerPicture( + it("Settings Profile - Crop banner and add banner picture", async () => { + // Click on banner picture upload button and select the file banner.jpg + await settingsProfileFirstUser.selectBannerPicture( "./tests/fixtures/banner.jpg" ); + + // Validate Crop Tool Modal is displayed + await cropProfileFirstUser.validateCropToolModalIsShown(); + + // Change the size of picture and click on confirm button to save + await cropProfileFirstUser.clickOnIncreaseRangeButton(); + await cropProfileFirstUser.clickOnConfirmButton(); + + // Validate new banner picture is displayed + await settingsProfileFirstUser.validateBannerPictureIsShown(); }); - // Needs rework for adding the cropping tool on banner pictures - xit("Settings Profile - Change profile picture", async () => { + it("Settings Profile - Change profile picture", async () => { // Wait for toast notification to be closed before starting test await settingsProfileFirstUser.waitUntilNotificationIsClosed(); @@ -182,20 +187,32 @@ export default async function settingsProfile() { }); // Needs visual validation steps to ensure that picture was actually loaded matches with expected image - // Needs rework for adding the cropping tool on banner pictures - xit("Settings Profile - Change banner picture", async () => { + it("Settings Profile - Change banner picture", async () => { // Wait for toast notification to be closed before starting test await settingsProfileFirstUser.waitUntilNotificationIsClosed(); - await settingsProfileFirstUser.uploadBannerPicture( + await settingsProfileFirstUser.selectBannerPicture( "./tests/fixtures/second-banner.jpg" ); + + // Validate Crop Tool Modal is displayed + await cropProfileFirstUser.validateCropToolModalIsShown(); + + // Change the size of picture and click on confirm button to save + await cropProfileFirstUser.clickOnIncreaseRangeButton(); + await cropProfileFirstUser.clickOnConfirmButton(); + + // Validate new banner picture is displayed + await settingsProfileFirstUser.validateBannerPictureIsShown(); }); it("Settings Profile - Validate Copy ID button tooltip", async () => { // Wait for toast notification to be closed before starting test await settingsProfileFirstUser.waitUntilNotificationIsClosed(); + // Wait for toast notification to be closed before starting test + await settingsProfileFirstUser.waitUntilNotificationIsClosed(); + // Validate Copy ID button tooltip await settingsProfileFirstUser.hoverOnCopyID(); diff --git a/tests/specs/14-create-reusable-accounts.spec.ts b/tests/specs/14-create-reusable-accounts.spec.ts index 8b315fcb7de..052a1fb1d4a 100644 --- a/tests/specs/14-create-reusable-accounts.spec.ts +++ b/tests/specs/14-create-reusable-accounts.spec.ts @@ -39,7 +39,7 @@ export default async function createReusableAccounts() { }); it("Add banner picture - Chat User A", async () => { - await settingsProfileFirstUser.uploadBannerPicture( + await settingsProfileFirstUser.selectBannerPicture( "./tests/fixtures/banner.jpg" ); }); @@ -91,7 +91,7 @@ export default async function createReusableAccounts() { it("Add banner picture - Chat User B", async () => { it("Settings Profile - Change banner picture", async () => { - await settingsProfileFirstUser.uploadBannerPicture( + await settingsProfileFirstUser.selectBannerPicture( "./tests/fixtures/second-banner.jpg" ); });