Skip to content

Commit

Permalink
CP-2920 [API Device][Multidevice] Connected Devices - stress test - a…
Browse files Browse the repository at this point in the history
…fter rebase (#2013)
  • Loading branch information
robertmudi authored Aug 14, 2024
2 parents f9ca04a + 3cc5467 commit 469c28e
Show file tree
Hide file tree
Showing 7 changed files with 419 additions and 1 deletion.
1 change: 1 addition & 0 deletions apps/mudita-center-e2e/src/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
*/

export * from "./sleep.helper"
export * from "./add-device.helper"
29 changes: 29 additions & 0 deletions apps/mudita-center-e2e/src/page-objects/select-device.page.ts
Original file line number Diff line number Diff line change
@@ -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()
48 changes: 48 additions & 0 deletions apps/mudita-center-e2e/src/specs/overview/e2e-mock-sample.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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")
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -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}`
3 changes: 3 additions & 0 deletions apps/mudita-center-e2e/wdio.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const config: Options.Testrunner = {
toRelativePath(TestFilesPaths.kompaktSwitchingDevices),
toRelativePath(TestFilesPaths.mcHomePageForceUpdateTest),
toRelativePath(TestFilesPaths.kompaktAbout),
toRelativePath(TestFilesPaths.kompaktConnectedDevicesModalStressTest),
],
suites: {
standalone: [
Expand All @@ -94,6 +95,7 @@ export const config: Options.Testrunner = {
toRelativePath(TestFilesPaths.kompaktOverview),
toRelativePath(TestFilesPaths.kompaktSwitchingDevices),
toRelativePath(TestFilesPaths.kompaktAbout),
toRelativePath(TestFilesPaths.kompaktConnectedDevicesModalStressTest),
],
multidevicePureHarmony: [],
multideviceSingleHarmony: [],
Expand Down Expand Up @@ -121,6 +123,7 @@ export const config: Options.Testrunner = {
toRelativePath(TestFilesPaths.kompaktOverview),
toRelativePath(TestFilesPaths.kompaktSwitchingDevices),
toRelativePath(TestFilesPaths.kompaktAbout),
toRelativePath(TestFilesPaths.kompaktConnectedDevicesModalStressTest),
],
},
// Patterns to exclude.
Expand Down
Loading

0 comments on commit 469c28e

Please sign in to comment.