diff --git a/apps/mudita-center-e2e/src/helpers/index.ts b/apps/mudita-center-e2e/src/helpers/index.ts index 844f85e401..c4a50b30f9 100644 --- a/apps/mudita-center-e2e/src/helpers/index.ts +++ b/apps/mudita-center-e2e/src/helpers/index.ts @@ -4,3 +4,4 @@ */ export * from "./sleep.helper" +export * from "./add-device.helper" diff --git a/apps/mudita-center-e2e/src/page-objects/select-device.page.ts b/apps/mudita-center-e2e/src/page-objects/select-device.page.ts new file mode 100644 index 0000000000..6c6341126b --- /dev/null +++ b/apps/mudita-center-e2e/src/page-objects/select-device.page.ts @@ -0,0 +1,29 @@ +/** + * Copyright (c) Mudita sp. z o.o. All rights reserved. + * For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md + */ + +import { index } from "@orama/orama/dist/components" +import Page from "./page" + +class SelectDevicePage extends Page { + public get devicesList() { + return $("[data-testid='devices-list']") + } + public get availableDevices() { + return $$('[data-testid="available-device"]') + } + public get selectDeviceSerialNumber() { + return $$('[data-testid="available-device-serial-number"]') + } + public get selectDeviceName() { + return $$('[data-testid="available-device-name"]') + } + public get selectADeviceToContinueTitle() { + return $("h1*=Select a device to continue") + } + public getDeviceOnSelectModal(index: number) { + return $(`(//p[@data-testid="available-device-serial-number"])[${index}]`) + } +} +export default new SelectDevicePage() diff --git a/apps/mudita-center-e2e/src/specs/overview/e2e-mock-sample.e2e.ts b/apps/mudita-center-e2e/src/specs/overview/e2e-mock-sample.e2e.ts index e069538b85..228385d794 100644 --- a/apps/mudita-center-e2e/src/specs/overview/e2e-mock-sample.e2e.ts +++ b/apps/mudita-center-e2e/src/specs/overview/e2e-mock-sample.e2e.ts @@ -74,6 +74,54 @@ describe("E2E mock sample - overview view", () => { await expect(drawerHeader).toBeDisplayed() }) + it("Add third device", async () => { + E2EMockClient.addDevice({ + path: "path-3", + serialNumber: "third-serial-number", + }) + await browser.pause(6000) + + const drawerHeader = $(`//*[text()='Select a device']`) + await drawerHeader.waitForDisplayed() + await expect(drawerHeader).toBeDisplayed() + }) + + it("Add fourth device", async () => { + E2EMockClient.addDevice({ + path: "path-4", + serialNumber: "fourth-serial-number", + }) + await browser.pause(6000) + + const drawerHeader = $(`//*[text()='Select a device']`) + await drawerHeader.waitForDisplayed() + await expect(drawerHeader).toBeDisplayed() + }) + + it("Add fifth device", async () => { + E2EMockClient.addDevice({ + path: "path-5", + serialNumber: "fifth-serial-number", + }) + await browser.pause(6000) + + const drawerHeader = $(`//*[text()='Select a device']`) + await drawerHeader.waitForDisplayed() + await expect(drawerHeader).toBeDisplayed() + }) + + it("Add sixth device", async () => { + E2EMockClient.addDevice({ + path: "path-6", + serialNumber: "sixth-serial-number", + }) + await browser.pause(6000) + + const drawerHeader = $(`//*[text()='Select a device']`) + await drawerHeader.waitForDisplayed() + await expect(drawerHeader).toBeDisplayed() + }) + it("Remove first device", async () => { E2EMockClient.removeDevice("path-1") await browser.pause(6000) diff --git a/apps/mudita-center-e2e/src/specs/stress-tests/connected-devices-stress-test.ts b/apps/mudita-center-e2e/src/specs/stress-tests/connected-devices-stress-test.ts new file mode 100644 index 0000000000..8fdb23453c --- /dev/null +++ b/apps/mudita-center-e2e/src/specs/stress-tests/connected-devices-stress-test.ts @@ -0,0 +1,232 @@ +import { E2EMockClient } from "../../../../../libs/e2e-mock/client/src" +import { + overviewDataWithOneSimCard, + overviewDataWithOneSimCard2nd, + overviewDataWithOneSimCard3rd, + overviewDataWithOneSimCard4th, + overviewDataWithOneSimCard5th, + overviewDataWithOneSimCard6th, +} from "../../../../../libs/e2e-mock/responses/src" +import OverviewKompaktPage from "../../page-objects/overview-kompakt.page" +import HomePage from "../../page-objects/home.page" +import { kompaktImageRegex } from "../../consts/regex-const" +import selectDevicePage from "../../page-objects/select-device.page" + +describe("Kompakt switching devices", () => { + const firstSerialNumber = "KOM1234567890" + const secondSerialNumber = "KOM1234567892" + const thirdSerialNumber = "KOM1234567893" + const fourthSerialNumber = "KOM1234567894" + const fifthSerialNumber = "KOM1234567895" + const sixthSerialNumber = "KOM1234567896" + + before(async () => { + E2EMockClient.connect() + await browser.waitUntil(() => { + return E2EMockClient.checkConnection() + }) + }) + + after(() => { + E2EMockClient.stopServer() + E2EMockClient.disconnect() + }) + + it("Connect 1,2 Kompakt devices", async () => { + const devices = [ + { + path: "path-1", + body: overviewDataWithOneSimCard, + serialNumber: firstSerialNumber, + }, + { + path: "path-2", + body: overviewDataWithOneSimCard2nd, + serialNumber: secondSerialNumber, + }, + ] + + const mockResponses = devices.map((device) => { + E2EMockClient.mockResponse({ + path: device.path, + body: device.body, + endpoint: "FEATURE_DATA", + method: "GET", + status: 200, + }) + return E2EMockClient.addDevice({ + path: device.path, + serialNumber: device.serialNumber, + }) + }) + await Promise.all(mockResponses) + await browser.pause(6000) + }) + + it("Check Select Device Modal and verify Devices 1 and 2", async () => { + const selectADeviceToContinueTitle = + await selectDevicePage.selectADeviceToContinueTitle + await expect(selectADeviceToContinueTitle).toHaveText( + "Select a device to continue" + ) + + const availableDevices = selectDevicePage.availableDevices + await expect(availableDevices).toBeDisplayed() + + const firstDeviceOnSelectModal = + await selectDevicePage.getDeviceOnSelectModal(1) + const secondDeviceOnSelectModal = + await selectDevicePage.getDeviceOnSelectModal(2) + + await expect(firstDeviceOnSelectModal).toBeDisplayed() + await expect(secondDeviceOnSelectModal).toBeDisplayed() + + const selectDeviceModalSerialNumbers = + selectDevicePage.selectDeviceSerialNumber + const selectDeviceModalNames = selectDevicePage.selectDeviceName + + const firstDeviceSerialNumber = + await selectDeviceModalSerialNumbers[0].getText() + await expect(firstDeviceSerialNumber).toEqual(firstSerialNumber) + const firstDeviceName = await selectDeviceModalNames[0] + await expect(firstDeviceName).toHaveText("Kompakt") + + const secondDeviceSerialNumber = + await selectDeviceModalSerialNumbers[1].getText() + await expect(secondDeviceSerialNumber).toEqual(secondSerialNumber) + const secondDeviceName = await selectDeviceModalNames[1] + await expect(secondDeviceName).toHaveText("Kompakt") + }) + + it("Connect 3,4,5,6 Kompakt devices", async () => { + const devices = [ + { + path: "path-3", + body: overviewDataWithOneSimCard3rd, + serialNumber: thirdSerialNumber, + }, + { + path: "path-4", + body: overviewDataWithOneSimCard4th, + serialNumber: fourthSerialNumber, + }, + { + path: "path-5", + body: overviewDataWithOneSimCard5th, + serialNumber: fifthSerialNumber, + }, + { + path: "path-6", + body: overviewDataWithOneSimCard6th, + serialNumber: sixthSerialNumber, + }, + ] + + for (const device of devices) { + E2EMockClient.mockResponse({ + path: device.path, + body: device.body, + endpoint: "FEATURE_DATA", + method: "GET", + status: 200, + }) + E2EMockClient.addDevice({ + path: device.path, + serialNumber: device.serialNumber, + }) + + await browser.pause(6000) + } + }) + + it("Verify Devices 3, 4, 5, 6", async () => { + const thirdDeviceOnSelectModal = + await selectDevicePage.getDeviceOnSelectModal(1) + const fourthDeviceOnSelectModal = + await selectDevicePage.getDeviceOnSelectModal(2) + + await expect(thirdDeviceOnSelectModal).toBeDisplayed() + await expect(fourthDeviceOnSelectModal).toBeDisplayed() + + const selectDeviceModalSerialNumbers = + selectDevicePage.selectDeviceSerialNumber + const selectDeviceModalNames = selectDevicePage.selectDeviceName + + const thirdDeviceSerialNumber = + await selectDeviceModalSerialNumbers[2].getText() + await expect(thirdDeviceSerialNumber).toEqual(thirdSerialNumber) + const thirdDeviceName = await selectDeviceModalNames[2] + await expect(thirdDeviceName).toHaveText("Kompakt") + + const fourthDeviceSerialNumber = + await selectDeviceModalSerialNumbers[3].getText() + await expect(fourthDeviceSerialNumber).toEqual(fourthSerialNumber) + const fourthDeviceName = await selectDeviceModalNames[3] + await expect(fourthDeviceName).toHaveText("Kompakt") + + const fifthDeviceOnSelectModal = + await selectDevicePage.getDeviceOnSelectModal(1) + const sixthDeviceOnSelectModal = + await selectDevicePage.getDeviceOnSelectModal(2) + + await expect(fifthDeviceOnSelectModal).toBeDisplayed() + await expect(sixthDeviceOnSelectModal).toBeDisplayed() + + const fifthDeviceSerialNumber = + await selectDeviceModalSerialNumbers[4].getText() + await expect(fifthDeviceSerialNumber).toEqual(fifthSerialNumber) + const fifthDeviceName = await selectDeviceModalNames[4] + await expect(fifthDeviceName).toHaveText("Kompakt") + + const sixthDeviceSerialNumber = + await selectDeviceModalSerialNumbers[5].getText() + await expect(sixthDeviceSerialNumber).toEqual(sixthSerialNumber) + const sixthDeviceName = await selectDeviceModalNames[5] + await expect(sixthDeviceName).toHaveText("Kompakt") + }) + + it("Switch to 6th device", async () => { + const sixthDeviceOnSelectModal = + await selectDevicePage.getDeviceOnSelectModal(6) + + await expect(sixthDeviceOnSelectModal).toBeDisplayed() + await sixthDeviceOnSelectModal.waitForClickable() + await sixthDeviceOnSelectModal.click() + }) + + it("Verify Overview Page for 6th device", async () => { + const kompaktImage = await OverviewKompaktPage.kompaktImage + await expect(kompaktImage).toBeDisplayed() + await expect(kompaktImage).toHaveAttribute("src", kompaktImageRegex) + + const kompaktOsVersion = await OverviewKompaktPage.kompaktOsVersion + await expect(kompaktOsVersion).toBeDisplayed() + await expect(kompaktOsVersion).toHaveText("Mudita OS") + + const kompaktSimCard1Subtext = + await OverviewKompaktPage.kompaktSimCard1Subtext + await expect(kompaktSimCard1Subtext).toHaveText("SIM 1") + + const kompaktNetworkName = await OverviewKompaktPage.kompaktNetworkName + await expect(kompaktNetworkName).toBeDisplayed() + await expect(kompaktNetworkName).toHaveText("Telia") + + const kompaktBatteryLevelValue = + await OverviewKompaktPage.kompaktBatteryLevelValue + await expect(kompaktBatteryLevelValue).toBeDisplayed() + await expect(kompaktBatteryLevelValue).toHaveText("20%") + }) + + it("Disconnect the devices and check if News page is present", async () => { + E2EMockClient.removeDevice("path-1") + E2EMockClient.removeDevice("path-2") + E2EMockClient.removeDevice("path-3") + E2EMockClient.removeDevice("path-4") + E2EMockClient.removeDevice("path-5") + E2EMockClient.removeDevice("path-6") + + const homeHeader = await HomePage.homeHeader + await homeHeader.waitForDisplayed() + await expect(homeHeader).toHaveText("Welcome to Mudita Center") + }) +}) 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 4ca7a3f861..73a2465fe4 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 @@ -22,5 +22,6 @@ export enum TestFilesPaths { kompaktOverview = "src/specs/overview/kompakt-overview.ts", kompaktSwitchingDevices = "src/specs/overview/kompakt-switching-devices.ts", kompaktAbout = "src/specs/overview/kompakt-about.ts", + kompaktConnectedDevicesModalStressTest = "src/specs/stress-tests/connected-devices-stress-test.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 62e39e8ac7..7d3a77dd26 100644 --- a/apps/mudita-center-e2e/wdio.conf.ts +++ b/apps/mudita-center-e2e/wdio.conf.ts @@ -72,6 +72,7 @@ export const config: Options.Testrunner = { toRelativePath(TestFilesPaths.kompaktSwitchingDevices), toRelativePath(TestFilesPaths.mcHomePageForceUpdateTest), toRelativePath(TestFilesPaths.kompaktAbout), + toRelativePath(TestFilesPaths.kompaktConnectedDevicesModalStressTest), ], suites: { standalone: [ @@ -94,6 +95,7 @@ export const config: Options.Testrunner = { toRelativePath(TestFilesPaths.kompaktOverview), toRelativePath(TestFilesPaths.kompaktSwitchingDevices), toRelativePath(TestFilesPaths.kompaktAbout), + toRelativePath(TestFilesPaths.kompaktConnectedDevicesModalStressTest), ], multidevicePureHarmony: [], multideviceSingleHarmony: [], @@ -121,6 +123,7 @@ export const config: Options.Testrunner = { toRelativePath(TestFilesPaths.kompaktOverview), toRelativePath(TestFilesPaths.kompaktSwitchingDevices), toRelativePath(TestFilesPaths.kompaktAbout), + toRelativePath(TestFilesPaths.kompaktConnectedDevicesModalStressTest), ], }, // Patterns to exclude. diff --git a/libs/e2e-mock/responses/src/lib/overview-responses.ts b/libs/e2e-mock/responses/src/lib/overview-responses.ts index 0891b2b190..f9fb72dd07 100644 --- a/libs/e2e-mock/responses/src/lib/overview-responses.ts +++ b/libs/e2e-mock/responses/src/lib/overview-responses.ts @@ -46,7 +46,7 @@ export const overviewDataWithOneSimCard = { export const overviewDataWithOneSimCard2nd = { summary: { about: { - serialNumber: { text: "1123456789ABCDEF" }, + serialNumber: { text: "1123456789ABCDEG" }, imei1: { text: "064055030138811" }, imei2: { text: "064055030138829" }, sar: { @@ -68,3 +68,107 @@ export const overviewDataWithOneSimCard2nd = { }, }, } + +export const overviewDataWithOneSimCard3rd = { + summary: { + about: { + serialNumber: { text: "1123456789ABCDEH" }, + imei1: { text: "064055030138811" }, + imei2: { text: "064055030138829" }, + sar: { + text: "### SAR\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sed aliquet ligula, viverra feugiat massa. In hac habitasse platea dictumst.\n\n1. Interdum et malesuada fames ac ante ipsum primis in faucibus.\n2. Suspendisse consectetur, nibh non consequat hendrerit, nibh felis commodo lacus, id auctor ante purus vitae justo.\n3. Cras purus neque, pharetra vitae nulla ac, mollis facilisis felis. Sed sit amet ex diam.\n\n> Sed accumsan sem nec iaculis euismod.", + }, + }, + }, + sections: { + battery: { + icon: "battery-charging-3", + text: "60%", + subText: "", + }, + update: { text: "Mudita OS", version: "0.3.1" }, + "airplane-mode": { + icon: "network-signal-3", + text: "Orange", + subText: "SIM 1", + }, + }, +} + +export const overviewDataWithOneSimCard4th = { + summary: { + about: { + serialNumber: { text: "1123456789ABCDEI" }, + imei1: { text: "064055030138811" }, + imei2: { text: "064055030138829" }, + sar: { + text: "### SAR\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sed aliquet ligula, viverra feugiat massa. In hac habitasse platea dictumst.\n\n1. Interdum et malesuada fames ac ante ipsum primis in faucibus.\n2. Suspendisse consectetur, nibh non consequat hendrerit, nibh felis commodo lacus, id auctor ante purus vitae justo.\n3. Cras purus neque, pharetra vitae nulla ac, mollis facilisis felis. Sed sit amet ex diam.\n\n> Sed accumsan sem nec iaculis euismod.", + }, + }, + }, + sections: { + battery: { + icon: "battery-charging-2", + text: "80%", + subText: "", + }, + update: { text: "Mudita OS", version: "0.3.1" }, + "airplane-mode": { + icon: "network-signal-4", + text: "O2", + subText: "SIM 1", + }, + }, +} + +export const overviewDataWithOneSimCard5th = { + summary: { + about: { + serialNumber: { text: "1123456789ABCDEJ" }, + imei1: { text: "064055030138811" }, + imei2: { text: "064055030138829" }, + sar: { + text: "### SAR\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sed aliquet ligula, viverra feugiat massa. In hac habitasse platea dictumst.\n\n1. Interdum et malesuada fames ac ante ipsum primis in faucibus.\n2. Suspendisse consectetur, nibh non consequat hendrerit, nibh felis commodo lacus, id auctor ante purus vitae justo.\n3. Cras purus neque, pharetra vitae nulla ac, mollis facilisis felis. Sed sit amet ex diam.\n\n> Sed accumsan sem nec iaculis euismod.", + }, + }, + }, + sections: { + battery: { + icon: "battery-charging-2", + text: "100%", + subText: "", + }, + update: { text: "Mudita OS", version: "0.3.1" }, + "airplane-mode": { + icon: "network-signal-4", + text: "Vodafone", + subText: "SIM 1", + }, + }, +} + +export const overviewDataWithOneSimCard6th = { + summary: { + about: { + serialNumber: { text: "1123456789ABCDEK" }, + imei1: { text: "064055030138811" }, + imei2: { text: "064055030138829" }, + sar: { + text: "### SAR\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sed aliquet ligula, viverra feugiat massa. In hac habitasse platea dictumst.\n\n1. Interdum et malesuada fames ac ante ipsum primis in faucibus.\n2. Suspendisse consectetur, nibh non consequat hendrerit, nibh felis commodo lacus, id auctor ante purus vitae justo.\n3. Cras purus neque, pharetra vitae nulla ac, mollis facilisis felis. Sed sit amet ex diam.\n\n> Sed accumsan sem nec iaculis euismod.", + }, + }, + }, + sections: { + battery: { + icon: "battery-charging-2", + text: "20%", + subText: "", + }, + update: { text: "Mudita OS", version: "0.3.1" }, + "airplane-mode": { + icon: "network-signal-4", + text: "Telia", + subText: "SIM 1", + }, + }, +}