Skip to content

Commit

Permalink
CP-2930 [API Device][Kompakt] Backup - Getting Initial Information (O…
Browse files Browse the repository at this point in the history
…verview Config Check) (#2069)
  • Loading branch information
robertmudi authored Sep 30, 2024
1 parent d8a290c commit 8421d55
Show file tree
Hide file tree
Showing 6 changed files with 383 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/**
* Copyright (c) Mudita sp. z o.o. All rights reserved.
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/

import { OverviewPage } from "./overview.page"

class ModalBackupKompaktPage extends OverviewPage {
public get backupInfo() {
return $('//div[@data-testid="block-box-backup"]//p')
}
public get createBackupButton() {
return $('//button[@type="button" and .//span[text()="Create backup"]]')
}
public get createBackupProceedNext() {
return $('[data-testid="backup-features-modal-create-action"]')
}

public get contactList() {
return $$('[data-testid="backup-features-modal-element-active"]')[0]
}
public get callLog() {
return $$('[data-testid="backup-features-modal-element-active"]')[1]
}
public get backupModalTitle() {
return $('[data-testid="backup-features-modal-title"]')
}
public get backupModalDescription() {
return $('[data-testid="backup-features-modal-description"]')
}
public get backupModalCancel() {
return $('[data-testid="backup-features-modal-cancel-action"]')
}

public get backupModalClose() {
return $('[data-testid="modal-close-button-icon-button"]')
}

public get createBackupPasswordModalTitle() {
return $('[data-testid="predefined-backup-password-title"]')
}

public get createBackupPasswordOptionalText() {
return $('[data-testid="predefined-backup-password-title"] span')
}
public get createBackupPasswordModalDescription() {
return $('[data-testid="predefined-backup-password-description"]')
}

public get createBackupPasswordModalDescriptionMore() {
return $('[data-testid="predefined-backup-password-description"] span')
}

public get createBackupPasswordPlaceholder() {
return $('[data-testid="predefined-backup-password-placeholder"]')
}

public get createBackupPasswordRepeatPlaceholder() {
return $('[data-testid="predefined-backup-password-repeat-placeholder"]')
}

public get createBackupPasswordConfirm() {
return $('[data-testid="predefined-backup-password-confirm-button"]')
}

public get createBackupPasswordSkip() {
return $('[data-testid="predefined-backup-password-skip-button"]')
}

public get createBackupPasswordClose() {
return $('[data-testid="modal-close-button-icon-button"]')
}

public get inputPassword() {
return $$('[data-testid="interactive-text-input-input"]')[0]
}

public get repeatInputPassword() {
return $$('[data-testid="interactive-text-input-input"]')[1]
}

public get unhidePasswordIcon() {
return $('[data-testid="icon-password-hide"]')
}

public get hidePasswordIcon() {
return $('[data-testid="icon-password-show"]')
}

public get passwordsDoNotMatch() {
return $('[data-testid="interactive-text-input-error-text"]')
}
}
export default new ModalBackupKompaktPage()
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
import { E2EMockClient } from "../../../../../libs/e2e-mock/client/src"
import {
overviewConfigForBackup,
overviewDataWithOneSimCard,
} from "../../../../../libs/e2e-mock/responses/src"
import ModalBackupKompaktPage from "../../page-objects/modal-backup-kompakt.page"

describe("E2E mock sample - overview view", () => {
before(async () => {
E2EMockClient.connect()
//wait for a connection to be established
await browser.waitUntil(() => {
return E2EMockClient.checkConnection()
})
})

after(() => {
E2EMockClient.stopServer()
E2EMockClient.disconnect()
})

it("Connect device", async () => {
E2EMockClient.mockResponse({
path: "path-1",
body: overviewConfigForBackup,
endpoint: "FEATURE_CONFIGURATION",
method: "GET",
status: 200,
})
E2EMockClient.mockResponse({
path: "path-1",
body: overviewDataWithOneSimCard,
endpoint: "FEATURE_DATA",
method: "GET",
status: 200,
})
E2EMockClient.addDevice({
path: "path-1",
serialNumber: "first-serial-number",
})

await browser.pause(6000)
const menuItem = await $(`//a[@href="#/generic/mc-overview"]`)

await menuItem.waitForDisplayed({ timeout: 10000 })
await expect(menuItem).toBeDisplayed()
})

it("Wait for Overview Page and click Create Backup", async () => {
const createBackupButton = await ModalBackupKompaktPage.createBackupButton
await expect(createBackupButton).toBeDisplayed()
await expect(createBackupButton).toBeClickable()
await createBackupButton.click()
})

it("Verify modal in scope of available backup options, verify text and buttons", async () => {
const contactList = await ModalBackupKompaktPage.contactList
await expect(contactList).toBeDisplayed()
const contactListText = await contactList?.getProperty("textContent")
expect(contactListText).toContain("Contact list")
expect(contactListText).not.toContain("Coming soon!")

const callLog = await ModalBackupKompaktPage.callLog
await expect(callLog).toBeDisplayed()
const callLogText = await callLog?.getProperty("textContent")
expect(callLogText).toContain("Call log")
expect(callLogText).not.toContain("Coming soon!")

const backupModalTitle = ModalBackupKompaktPage.backupModalTitle
await expect(backupModalTitle).toBeDisplayed()
await expect(backupModalTitle).toHaveText("Create backup")

const backupModalDescription = ModalBackupKompaktPage.backupModalDescription
await expect(backupModalDescription).toBeDisplayed()
await expect(backupModalDescription).toHaveText(
"All backup data stays on your computer."
)

const backupModalCancel = ModalBackupKompaktPage.backupModalCancel
await expect(backupModalCancel).toBeClickable()

const backupModalClose = ModalBackupKompaktPage.backupModalClose
await expect(backupModalClose).toBeClickable()
})

it("Click Create backup - verify modal about create password for backup", async () => {
const createBackupProceedNext =
await ModalBackupKompaktPage.createBackupProceedNext
await expect(createBackupProceedNext).toBeClickable()
await createBackupProceedNext.click()

const createBackupPasswordModalTitle =
ModalBackupKompaktPage.createBackupPasswordModalTitle
await expect(createBackupPasswordModalTitle).toHaveTextContaining(
"Create password for backup"
)

const createBackupPasswordOptionalText =
ModalBackupKompaktPage.createBackupPasswordOptionalText
await expect(createBackupPasswordOptionalText).toHaveText("(optional)")

const createBackupPasswordModalDescription =
ModalBackupKompaktPage.createBackupPasswordModalDescription
await expect(createBackupPasswordModalDescription).toHaveTextContaining(
"You can protect backup with a new password."
)

const createBackupPasswordModalDescriptionMore =
ModalBackupKompaktPage.createBackupPasswordModalDescriptionMore
await expect(createBackupPasswordModalDescriptionMore).toHaveText(
"* You can't change/recover the password later."
)

const createBackupPasswordPlaceholder =
ModalBackupKompaktPage.createBackupPasswordPlaceholder
await expect(createBackupPasswordPlaceholder).toBeClickable()

const createBackupPasswordRepeatPlaceholder =
ModalBackupKompaktPage.createBackupPasswordRepeatPlaceholder
await expect(createBackupPasswordRepeatPlaceholder).toBeClickable()

const createBackupPasswordConfirm =
ModalBackupKompaktPage.createBackupPasswordConfirm
await expect(createBackupPasswordConfirm).not.toBeClickable()

const createBackupPasswordSkip =
ModalBackupKompaktPage.createBackupPasswordSkip
await expect(createBackupPasswordSkip).toBeClickable()

const createBackupPasswordClose =
ModalBackupKompaktPage.createBackupPasswordClose
await expect(createBackupPasswordClose).toBeClickable()
})

it("Fill password for a backup, unhide it and verify value and design", async () => {
const inputPassword = ModalBackupKompaktPage.inputPassword
await inputPassword.click()
const randomPassword = Math.random().toString(36).substring(2, 10)
await inputPassword.setValue(randomPassword)

const checkPassword = await inputPassword.getAttribute("type")
await expect(checkPassword).toBe("password")

const unhidePasswordIcon = ModalBackupKompaktPage.unhidePasswordIcon
await unhidePasswordIcon.click()

//Verify design, and it's value to check if user can hide password if it was displayed
const hidePasswordIcon = ModalBackupKompaktPage.hidePasswordIcon
await expect(hidePasswordIcon).toBeClickable()
})

it("Fill repeat password for a backup, unhide it and verify value and design, verify (passwords do not match)", async () => {
const repeatInputPassword = ModalBackupKompaktPage.repeatInputPassword
await repeatInputPassword.click()
const randomPassword2 = Math.random().toString(36).substring(2, 10)
await repeatInputPassword.setValue(randomPassword2)

const checkPassword = await repeatInputPassword.getAttribute("type")
await expect(checkPassword).toBe("password")

const unhidePasswordIcon = ModalBackupKompaktPage.unhidePasswordIcon
await unhidePasswordIcon.click()

//Verify design and it's value to check if user can hide password if it was displayed
const hidePasswordIcon = ModalBackupKompaktPage.hidePasswordIcon
await expect(hidePasswordIcon).toBeClickable()

const passwordsDoNotMatch = ModalBackupKompaktPage.passwordsDoNotMatch
await expect(passwordsDoNotMatch).toHaveText("Passwords do not match")
})

it("Fill repeat password with first filed password and verify if passwords do not match is gone", async () => {
const inputPassword = ModalBackupKompaktPage.inputPassword
const repeatInputPassword = ModalBackupKompaktPage.repeatInputPassword
const randomPassword = Math.random().toString(36).substring(2, 10)
await inputPassword.click()
await inputPassword.clearValue()
await inputPassword.setValue(randomPassword)

await repeatInputPassword.click()
await repeatInputPassword.clearValue()
await repeatInputPassword.setValue(randomPassword)

const passwordsDoNotMatch = ModalBackupKompaktPage.passwordsDoNotMatch
await expect(passwordsDoNotMatch).not.toBeDisplayed()

const createBackupPasswordConfirm =
ModalBackupKompaktPage.createBackupPasswordConfirm
await expect(createBackupPasswordConfirm).toBeClickable()
await createBackupPasswordConfirm.click()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ export enum TestFilesPaths {
kompaktAbout = "src/specs/overview/kompakt-about.ts",
kompaktConnectedDevicesModalStressTest = "src/specs/stress-tests/connected-devices-stress-test.ts",
kompaktDrawerStressTest = "src/specs/stress-tests/device-drawer-stress-test.ts",
kompaktBackupModalGettingInitialInfo = "src/specs/overview/kompakt-backup-getting-initial-info.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 @@ -76,6 +76,7 @@ export const config: Options.Testrunner = {
toRelativePath(TestFilesPaths.kompaktAbout),
toRelativePath(TestFilesPaths.kompaktConnectedDevicesModalStressTest),
toRelativePath(TestFilesPaths.kompaktDrawerStressTest),
toRelativePath(TestFilesPaths.kompaktBackupModalGettingInitialInfo),
],
suites: {
standalone: [
Expand All @@ -101,6 +102,7 @@ export const config: Options.Testrunner = {
toRelativePath(TestFilesPaths.kompaktAbout),
toRelativePath(TestFilesPaths.kompaktConnectedDevicesModalStressTest),
toRelativePath(TestFilesPaths.kompaktDrawerStressTest),
toRelativePath(TestFilesPaths.kompaktBackupModalGettingInitialInfo),
],
multidevicePureHarmony: [],
multideviceSingleHarmony: [],
Expand Down Expand Up @@ -133,6 +135,7 @@ export const config: Options.Testrunner = {
toRelativePath(TestFilesPaths.kompaktAbout),
toRelativePath(TestFilesPaths.kompaktConnectedDevicesModalStressTest),
toRelativePath(TestFilesPaths.kompaktDrawerStressTest),
toRelativePath(TestFilesPaths.kompaktBackupModalGettingInitialInfo),
],
},
// Patterns to exclude.
Expand Down
6 changes: 3 additions & 3 deletions libs/e2e-mock/responses/src/lib/default-responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ export const DEFAULT_RESPONSES: MockResponsesMap = {
],
restoreFeatures: [
{
label: "Contacts list",
feature: "CONTACTS_LIST",
keys: ["CONTACTS_LIST"],
label: "Contact list",
feature: "CONTACT_LIST",
keys: ["CONTACT_LIST"],
},
{ label: "Call log", feature: "CALL_LOG", keys: ["CALL_LOG"] },
{ label: "Messages", feature: "MESSAGES", keys: ["MESSAGES"] },
Expand Down
Loading

0 comments on commit 8421d55

Please sign in to comment.