From f53e821d86fc7197a0c08b72c9ed7b01d7c0538b Mon Sep 17 00:00:00 2001 From: patrycja-paczkowska Date: Mon, 8 Jul 2024 14:49:38 +0200 Subject: [PATCH 1/4] wip --- .../src/page-objects/modal-app-update.page.ts | 52 +++++++ ...home-page-mc-force-update-available.e2e.ts | 145 ++++++++++++++++++ 2 files changed, 197 insertions(+) create mode 100644 apps/mudita-center-e2e/src/page-objects/modal-app-update.page.ts create mode 100644 apps/mudita-center-e2e/src/specs/overview/home-page-mc-force-update-available.e2e.ts diff --git a/apps/mudita-center-e2e/src/page-objects/modal-app-update.page.ts b/apps/mudita-center-e2e/src/page-objects/modal-app-update.page.ts new file mode 100644 index 0000000000..d91a40c96b --- /dev/null +++ b/apps/mudita-center-e2e/src/page-objects/modal-app-update.page.ts @@ -0,0 +1,52 @@ +/** + * Copyright (c) Mudita sp. z o.o. All rights reserved. + * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md + */ + +import Page from "./page" + +class ModalAppUpdate extends Page { + get modalHeader() { + return $('[data-testid="modal-title"]') + } + + public get paragraphAvailableVersion() { + return $("h4*=Update Mudita Center to") + } + + public get paragraphCurrentVersion() { + return $("p*=Update it to use") + } + + public get paragraphPrivacyPolicy() { + return $( + "p*=Please accept the Privacy Policy to start updating Mudita Center." + ) + } + + public get linkPrivacyPolicy() { + return $("a=Privacy Policy") + } + + public get checkboxPrivacyPolicy() { + return $('[data-testid="privacy-policy-checkbox"]') + } + + public get buttonUpdate() { + return $('[data-testid="modal-action-button"]') + } + + public get paragraphUpdatingMuditaCenter() { + return $("h4*=Updating Mudita Center") + } + + public get spinnerLoader() { + return $('[data-testid="loader-spinner"]') + } + + public get paragraphPleaseWait() { + return $("p*=Please wait while Mudita Center is being updated.") + } +} + +export default new ModalAppUpdate() diff --git a/apps/mudita-center-e2e/src/specs/overview/home-page-mc-force-update-available.e2e.ts b/apps/mudita-center-e2e/src/specs/overview/home-page-mc-force-update-available.e2e.ts new file mode 100644 index 0000000000..1a64bb1d41 --- /dev/null +++ b/apps/mudita-center-e2e/src/specs/overview/home-page-mc-force-update-available.e2e.ts @@ -0,0 +1,145 @@ +import { E2EMockClient } from "../../../../../libs/e2e-mock/client/src" +import modalAppUpdatePage from "../../page-objects/modal-app-update.page" +import ModalPage from "../../page-objects/modal.page" +import packageInfo from "../../../../mudita-center/package.json" + +describe("Force Update MC - Successful Download", () => { + before(async function () { + E2EMockClient.connect() + //wait for a connection to be established + await browser.waitUntil(() => { + return E2EMockClient.checkConnection() + }) + + E2EMockClient.setMockUpdateState({ available: true, version: "999.0.0" }) + E2EMockClient.mockHttpResponse({ + url: "/v2-app-configuration", + method: "GET", + status: 200, + data: { + centerVersion: "3.0.0", + productVersions: { + MuditaHarmony: "1.0.0", + MuditaPure: "1.0.0", + APIDevice: "1.0.0", + }, + }, + }) + }) + + it("Check update modal sections ", async () => { + await console.log("PACKAGE INFO VERSION:" + packageInfo.version) + + // Header + const modalHeader = await modalAppUpdatePage.modalHeader + await expect(modalHeader).toBeDisplayed() + await expect(modalHeader).toHaveText("Mudita Center") + + // Available version + const paragraphAvailableVersion = + await modalAppUpdatePage.paragraphAvailableVersion + await expect(paragraphAvailableVersion).toBeDisplayed() + await expect(paragraphAvailableVersion).toHaveTextContaining( + "Update Mudita Center to" + ) + const textParagraphAvailableVersion = + await paragraphAvailableVersion.getText() + const availableAppVersion = textParagraphAvailableVersion.split("to ").pop() + await console.log("AVAILABLE VERSION:" + availableAppVersion) + + // Current version + const paragraphCurrentVersion = + await modalAppUpdatePage.paragraphCurrentVersion + await expect(paragraphCurrentVersion).toBeDisplayed() + await expect(paragraphCurrentVersion).toHaveTextContaining( + "Update it to use the full version of the Mudita Center. Your current version:" + ) + const textParagraphCurrentVersion = await paragraphCurrentVersion.getText() + const currentAppVersion = textParagraphCurrentVersion.split(": ").pop() + await console.log("CURRENT VERSION:" + currentAppVersion) + + // Privacy policy + const paragraphPrivacyPolicy = + await modalAppUpdatePage.paragraphPrivacyPolicy + await expect(paragraphPrivacyPolicy).toBeDisplayed() + await expect(paragraphPrivacyPolicy).toHaveText( + "Please accept the Privacy Policy to start updating Mudita Center." + ) + + const linkPrivacyPolicy = await modalAppUpdatePage.linkPrivacyPolicy + await expect(linkPrivacyPolicy).toBeDisplayed() + await expect(linkPrivacyPolicy).toHaveText("Privacy Policy") + + // TBD + // await expect(linkPrivacyPolicy).toHaveAttr("href") + const linkColor = await linkPrivacyPolicy.getCSSProperty("color") + await expect(linkColor.value).toBe("rgba(109,155,188,1)") + const linkDecoration = await linkPrivacyPolicy.getCSSProperty( + "text-decoration" + ) + await expect(linkDecoration.value).toBe( + "underline solid rgb(109, 155, 188)" + ) + + const checkboxPrivacyPolicy = await modalAppUpdatePage.checkboxPrivacyPolicy + await expect(checkboxPrivacyPolicy).toBeDisplayed() + await expect(checkboxPrivacyPolicy).not.toBeChecked() + + // Button: UPDATE + const buttonUpdate = await modalAppUpdatePage.buttonUpdate + await expect(buttonUpdate.isDisplayed()) + await expect(buttonUpdate).not.toBeClickable() + + // Close modal button + const modalCloseButton = await ModalPage.modalCloseButton + // TBD + // await expect(modalCloseButton).not.toBeDisplayed() + }) + + it("Button UPDATE is clickable after selecting the checkbox", async () => { + const checkboxPrivacyPolicy = await modalAppUpdatePage.checkboxPrivacyPolicy + await expect(checkboxPrivacyPolicy).toBeDisplayed() + + const buttonUpdate = await modalAppUpdatePage.buttonUpdate + await expect(buttonUpdate).toBeDisplayed() + await expect(buttonUpdate).not.toBeClickable() + + await checkboxPrivacyPolicy.click() + await expect(checkboxPrivacyPolicy).toBeChecked() + + await expect(buttonUpdate).toBeClickable() + }) + + it("Check Updating Mudita Center modal", async () => { + const buttonUpdate = await modalAppUpdatePage.buttonUpdate + await expect(buttonUpdate).toBeDisplayed() + await buttonUpdate.click() + + const modalHeader = await modalAppUpdatePage.modalHeader + await expect(modalHeader).toBeDisplayed() + await expect(modalHeader).toHaveText("Mudita Center") + + const paragraphUpdatingMuditaCenter = + await modalAppUpdatePage.paragraphUpdatingMuditaCenter + await expect(paragraphUpdatingMuditaCenter).toBeDisplayed() + await expect(paragraphUpdatingMuditaCenter).toHaveText( + "Updating Mudita Center" + ) + + const spinnerLoader = await modalAppUpdatePage.spinnerLoader + await expect(spinnerLoader).toBeDisplayed() + const spinnerColor = await spinnerLoader.getCSSProperty("color") + await expect(spinnerColor.value).toBe("rgba(109,155,188,1)") + + const spinnerAnimation = await spinnerLoader.getCSSProperty("animation") + await expect(spinnerAnimation.value).toBe( + "chase 2.5s linear 0s infinite normal both running" + ) + + const paragraphPleaseWait = await modalAppUpdatePage.paragraphPleaseWait + await expect(paragraphPleaseWait).toBeDisplayed() + await expect(paragraphPleaseWait).toHaveText( + "Please wait while Mudita Center is being updated." + ) + }) +}) From 1948c4320e85911b0f23b85ba7006f4843b78ef5 Mon Sep 17 00:00:00 2001 From: patrycja-paczkowska Date: Tue, 9 Jul 2024 13:02:14 +0200 Subject: [PATCH 2/4] [CP-2749] Add mock MC Force Update E2E test --- ....e2e.ts => e2e-mock-mc-force-update-available.e2e.ts} | 9 +++------ .../src/test-filenames/consts/test-filenames.const.ts | 1 + apps/mudita-center-e2e/wdio.conf.ts | 3 +++ 3 files changed, 7 insertions(+), 6 deletions(-) rename apps/mudita-center-e2e/src/specs/overview/{home-page-mc-force-update-available.e2e.ts => e2e-mock-mc-force-update-available.e2e.ts} (96%) diff --git a/apps/mudita-center-e2e/src/specs/overview/home-page-mc-force-update-available.e2e.ts b/apps/mudita-center-e2e/src/specs/overview/e2e-mock-mc-force-update-available.e2e.ts similarity index 96% rename from apps/mudita-center-e2e/src/specs/overview/home-page-mc-force-update-available.e2e.ts rename to apps/mudita-center-e2e/src/specs/overview/e2e-mock-mc-force-update-available.e2e.ts index 1a64bb1d41..f8e29592a7 100644 --- a/apps/mudita-center-e2e/src/specs/overview/home-page-mc-force-update-available.e2e.ts +++ b/apps/mudita-center-e2e/src/specs/overview/e2e-mock-mc-force-update-available.e2e.ts @@ -13,11 +13,11 @@ describe("Force Update MC - Successful Download", () => { E2EMockClient.setMockUpdateState({ available: true, version: "999.0.0" }) E2EMockClient.mockHttpResponse({ - url: "/v2-app-configuration", + url: "v2-app-configuration", method: "GET", status: 200, data: { - centerVersion: "3.0.0", + centerVersion: "999.0.0", productVersions: { MuditaHarmony: "1.0.0", MuditaPure: "1.0.0", @@ -70,8 +70,6 @@ describe("Force Update MC - Successful Download", () => { await expect(linkPrivacyPolicy).toBeDisplayed() await expect(linkPrivacyPolicy).toHaveText("Privacy Policy") - // TBD - // await expect(linkPrivacyPolicy).toHaveAttr("href") const linkColor = await linkPrivacyPolicy.getCSSProperty("color") await expect(linkColor.value).toBe("rgba(109,155,188,1)") const linkDecoration = await linkPrivacyPolicy.getCSSProperty( @@ -92,8 +90,7 @@ describe("Force Update MC - Successful Download", () => { // Close modal button const modalCloseButton = await ModalPage.modalCloseButton - // TBD - // await expect(modalCloseButton).not.toBeDisplayed() + await expect(modalCloseButton).not.toBeDisplayed() }) it("Button UPDATE is clickable after selecting the checkbox", async () => { diff --git a/apps/mudita-center-e2e/src/test-filenames/consts/test-filenames.const.ts b/apps/mudita-center-e2e/src/test-filenames/consts/test-filenames.const.ts index 10e4e12dc3..e4be541749 100644 --- a/apps/mudita-center-e2e/src/test-filenames/consts/test-filenames.const.ts +++ b/apps/mudita-center-e2e/src/test-filenames/consts/test-filenames.const.ts @@ -18,5 +18,6 @@ export enum TestFilesPaths { privacyPolicyTest = "src/specs/settings/privacy-policy.e2e.ts", licenseTest = "src/specs/settings/license.e2e.ts", helpWindowCheckOfflineTest = "src/specs/help/help-window-check-offline.e2e.ts", + mcHomePageForceUpdateTest = "src/specs/overview/e2e-mock-mc-force-update-available.e2e.ts", } export const toRelativePath = (path: string) => `./${path}` diff --git a/apps/mudita-center-e2e/wdio.conf.ts b/apps/mudita-center-e2e/wdio.conf.ts index e51198e7c5..d5c615140e 100644 --- a/apps/mudita-center-e2e/wdio.conf.ts +++ b/apps/mudita-center-e2e/wdio.conf.ts @@ -67,6 +67,7 @@ export const config: Options.Testrunner = { toRelativePath(TestFilesPaths.privacyPolicyTest), toRelativePath(TestFilesPaths.licenseTest), toRelativePath(TestFilesPaths.helpWindowCheckOfflineTest), + toRelativePath(TestFilesPaths.mcHomePageForceUpdateTest), ], suites: { standalone: [ @@ -84,6 +85,7 @@ export const config: Options.Testrunner = { toRelativePath(TestFilesPaths.privacyPolicyTest), toRelativePath(TestFilesPaths.licenseTest), toRelativePath(TestFilesPaths.helpWindowCheckOfflineTest), + toRelativePath(TestFilesPaths.mcHomePageForceUpdateTest), ], mock: [toRelativePath(TestFilesPaths.e2eMockSample)], multidevicePureHarmony: [], @@ -108,6 +110,7 @@ export const config: Options.Testrunner = { toRelativePath(TestFilesPaths.privacyPolicyTest), toRelativePath(TestFilesPaths.licenseTest), toRelativePath(TestFilesPaths.helpWindowCheckOfflineTest), + toRelativePath(TestFilesPaths.mcHomePageForceUpdateTest), ], }, // Patterns to exclude. From b1968013b5837e64c31502fc6ac7a4123ad84685 Mon Sep 17 00:00:00 2001 From: Daniel Karski Date: Tue, 9 Jul 2024 11:26:52 +0200 Subject: [PATCH 3/4] [CP-2749] Update readme.md (#1961) --- libs/e2e-mock/server/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/e2e-mock/server/README.md b/libs/e2e-mock/server/README.md index a14a2b20f9..b0e6fa1f9e 100644 --- a/libs/e2e-mock/server/README.md +++ b/libs/e2e-mock/server/README.md @@ -93,7 +93,7 @@ To set the response indicating that an update is available and a Mudita Center u ```javascript E2EMockClient.setMockUpdateState({ available: true, version: "4.0.0" }) E2EMockClient.mockHttpResponse({ - url: '/v2-app-configuration', + url: 'v2-app-configuration', method: 'GET', status: 200, data: { @@ -113,7 +113,7 @@ To set the response indicating that an update is available and the application i ```javascript E2EMockClient.setMockUpdateState({ available: true, version: "4.0.0" }) E2EMockClient.mockHttpResponse({ - url: '/v2-app-configuration', + url: 'v2-app-configuration', method: 'GET', status: 200, data: { From a0095dd4da1c99e8afed693d3ec50d21e64b933d Mon Sep 17 00:00:00 2001 From: patrycja-paczkowska Date: Tue, 23 Jul 2024 17:56:30 +0200 Subject: [PATCH 4/4] [CP-2749] After review fixes --- .../e2e-mock-mc-force-update-available.e2e.ts | 15 +++++++++++---- apps/mudita-center-e2e/wdio.conf.ts | 4 +++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/apps/mudita-center-e2e/src/specs/overview/e2e-mock-mc-force-update-available.e2e.ts b/apps/mudita-center-e2e/src/specs/overview/e2e-mock-mc-force-update-available.e2e.ts index f8e29592a7..f43688c3be 100644 --- a/apps/mudita-center-e2e/src/specs/overview/e2e-mock-mc-force-update-available.e2e.ts +++ b/apps/mudita-center-e2e/src/specs/overview/e2e-mock-mc-force-update-available.e2e.ts @@ -4,6 +4,8 @@ import ModalPage from "../../page-objects/modal.page" import packageInfo from "../../../../mudita-center/package.json" describe("Force Update MC - Successful Download", () => { + const newestAvailableVersion = "9.9.9" + before(async function () { E2EMockClient.connect() //wait for a connection to be established @@ -11,7 +13,11 @@ describe("Force Update MC - Successful Download", () => { return E2EMockClient.checkConnection() }) - E2EMockClient.setMockUpdateState({ available: true, version: "999.0.0" }) + E2EMockClient.setMockUpdateState({ + available: true, + version: newestAvailableVersion, + }) + E2EMockClient.mockHttpResponse({ url: "v2-app-configuration", method: "GET", @@ -28,7 +34,7 @@ describe("Force Update MC - Successful Download", () => { }) it("Check update modal sections ", async () => { - await console.log("PACKAGE INFO VERSION:" + packageInfo.version) + console.log("PACKAGE INFO VERSION:" + packageInfo.version) // Header const modalHeader = await modalAppUpdatePage.modalHeader @@ -45,7 +51,8 @@ describe("Force Update MC - Successful Download", () => { const textParagraphAvailableVersion = await paragraphAvailableVersion.getText() const availableAppVersion = textParagraphAvailableVersion.split("to ").pop() - await console.log("AVAILABLE VERSION:" + availableAppVersion) + console.log("AVAILABLE VERSION:" + availableAppVersion) + await expect(availableAppVersion).toBe(newestAvailableVersion) // Current version const paragraphCurrentVersion = @@ -56,7 +63,7 @@ describe("Force Update MC - Successful Download", () => { ) const textParagraphCurrentVersion = await paragraphCurrentVersion.getText() const currentAppVersion = textParagraphCurrentVersion.split(": ").pop() - await console.log("CURRENT VERSION:" + currentAppVersion) + console.log("CURRENT VERSION:" + currentAppVersion) // Privacy policy const paragraphPrivacyPolicy = diff --git a/apps/mudita-center-e2e/wdio.conf.ts b/apps/mudita-center-e2e/wdio.conf.ts index d5c615140e..396a6ce7b2 100644 --- a/apps/mudita-center-e2e/wdio.conf.ts +++ b/apps/mudita-center-e2e/wdio.conf.ts @@ -85,9 +85,11 @@ export const config: Options.Testrunner = { toRelativePath(TestFilesPaths.privacyPolicyTest), toRelativePath(TestFilesPaths.licenseTest), toRelativePath(TestFilesPaths.helpWindowCheckOfflineTest), + ], + mock: [ + toRelativePath(TestFilesPaths.e2eMockSample), toRelativePath(TestFilesPaths.mcHomePageForceUpdateTest), ], - mock: [toRelativePath(TestFilesPaths.e2eMockSample)], multidevicePureHarmony: [], multideviceSingleHarmony: [], multideviceSinglePure: [],