init commit,

This commit is contained in:
louiscklaw
2025-05-28 09:55:51 +08:00
commit efe70ceb69
8042 changed files with 951668 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
import { findAndClickLocator } from "../base.screen.js";
export class AlertModal {
async clickCancelButtonOf(parent: string) {
await findAndClickLocator(`${parent} #cancel-alert-button`);
}
async clickConfirmButtonOf(parent: string) {
await findAndClickLocator(`${parent} #confirm-alert-button`);
}
}
export default new AlertModal();

View File

@@ -0,0 +1,37 @@
import {
findAndClickLocator,
findFilterAndClickElement,
} from "../base.screen.js";
export class BaseModal {
closeButtonLocator = "[data-testid=\"close-button\"]";
async clickCloseButtonOf(parent: string) {
await findAndClickLocator(`${parent} ${this.closeButtonLocator}`);
}
async clickDoneButton() {
await findFilterAndClickElement(this.closeButtonLocator);
}
async clickDoneLabel() {
await findFilterAndClickElement("[data-testid=\"close-button-label\"]");
}
async introTitle(modalName: string) {
return $(`[data-testid="${modalName}-title"]`);
}
async introText(modalName: string) {
return $(`[data-testid="${modalName}-modal-intro-text"]`);
}
returnSectionTitleLocator = (modalName: string, sectionName: string) =>
`[data-testid="${modalName}-modal-section-${sectionName}"`;
async subsectionElement(locator: string, type: string, index: number) {
return $(`${locator.slice(0, -1)}-${type}-${index}` + "\"]");
}
}
export default new BaseModal();

View File

@@ -0,0 +1,43 @@
export class CommonIdentityModal {
get displayNameTitle() {
return $("[data-testid=\"display-name-title\"]");
}
get themeTitle() {
return $(".theme-input-title");
}
async themeItem(index: number) {
return $(`[data-testid="identifier-theme-selector-item-${index}"]`);
}
async clickChosenTheme(index: number) {
await (await this.themeItem(index)).click();
}
async displayNameInputElement(elementName: string) {
return $(`#${elementName}-name-input input`);
}
async getIdElementLocator(elementName: string) {
return `[data-testid="${elementName}-identifier-modal"]`;
}
async idElement(elementName: string) {
return $(await this.getIdElementLocator(elementName));
}
async identifierTypeItem(name: string) {
return $(`[data-testid="identifier-aidtype-${name.toLowerCase()}"]`);
}
async modalTitleElement(elementName: string) {
return $(`[data-testid="${elementName}-title"]`);
}
async clickChosenIdentifierType(identifierType: string) {
await (await this.identifierTypeItem(identifierType)).click();
}
}
export default new CommonIdentityModal();

View File

@@ -0,0 +1,13 @@
import { CommonIdentityModal } from "./common-identity.modal.js";
export class IdentifierJsonModal extends CommonIdentityModal {
get copyJsonButton() {
return $("[data-testid=\"identifier-copy-json\"]");
}
get saveToDeviceButton() {
return $("[data-testid=\"save-to-device-button\"]");
}
}
export default new IdentifierJsonModal();

View File

@@ -0,0 +1,42 @@
import { expect } from "expect-webdriverio";
import { CommonIdentityModal } from "./common-identity.modal.js";
export class IdentityAddModal extends CommonIdentityModal {
get createIdentifierButton() {
return $("[data-testid=\"primary-button-create-identifier-modal\"]");
}
get displayNameInput() {
return this.displayNameInputElement("display");
}
get identifierTypeTitle() {
return $(".type-input-title");
}
get id() {
return this.idElement("create");
}
get modalTitle() {
return this.modalTitleElement("add-an-identifier");
}
async loads() {
await expect(this.id).toBeDisplayed();
await expect(this.modalTitle).toHaveText("Add an identifier");
await expect(super.displayNameTitle).toHaveText("Display name");
await expect(this.displayNameInput).toBeDisplayed();
await expect(this.identifierTypeTitle).toHaveText("AID type");
await expect(this.identifierTypeItem("default")).toBeDisplayed();
await expect(this.identifierTypeItem("multisig")).toBeDisplayed();
await expect(this.identifierTypeItem("delegated")).toBeDisplayed();
await expect(super.themeTitle).toHaveText("Choose a theme");
for (let i = 0; i < 2; i++) {
await expect(super.themeItem(i)).toBeDisplayed();
}
await expect(this.createIdentifierButton).toBeDisplayed();
}
}
export default new IdentityAddModal();

View File

@@ -0,0 +1,40 @@
import { expect } from "expect-webdriverio";
import { CommonIdentityModal } from "./common-identity.modal.js";
export class IdentityEditModal extends CommonIdentityModal {
modalName = "edit";
get confirmChangesButton() {
return $("[data-testid=\"continue-button\"]");
}
get displayNameInput() {
return this.displayNameInputElement(this.modalName);
}
get id() {
return this.idElement(this.modalName);
}
get idLocator() {
return this.getIdElementLocator(this.modalName);
}
get modalTitle() {
return this.modalTitleElement(`${this.modalName}-identifier`);
}
async loads() {
await expect(this.id).toBeDisplayed();
await expect(this.modalTitle).toHaveText("Edit identifier");
await expect(super.displayNameTitle).toHaveText("Display name");
await expect(this.displayNameInput).toBeDisplayed();
await expect(this.themeTitle).toHaveText("Edit theme");
for (let i = 0; i < 4; i++) {
await expect(this.themeItem(i)).toBeDisplayed();
}
await expect(this.confirmChangesButton).toBeDisplayed();
}
}
export default new IdentityEditModal();

View File

@@ -0,0 +1,25 @@
import { CommonIdentityModal } from "./common-identity.modal.js";
export class IdentityOptionsModal extends CommonIdentityModal {
get deleteIdentifierOption() {
return $("[data-testid=\"delete-identifier-options\"]");
}
get editIdentifierOption() {
return $("[data-testid=\"edit-identifier-options\"]");
}
get id() {
return this.idElement("view");
}
get shareIdentifierOption() {
return $("[data-testid=\"share-identifier-options\"]");
}
get viewJsonOption() {
return $("[data-testid=\"view-json-identifier-options\"]");
}
}
export default new IdentityOptionsModal();

View File

@@ -0,0 +1,43 @@
import { expect } from "expect-webdriverio";
import { CommonIdentityModal } from "./common-identity.modal.js";
export class IdentityShareModal extends CommonIdentityModal {
get copyButton() {
return $("[data-testid=\"share-identifier-copy-button\"]");
}
get copyButton2() {
return $(".share-identifier-option");
}
get copyButtonLabel() {
return $("[data-testid=\"share-identifier-copy-label\"]");
}
get moreOptionsButton() {
return $("[data-testid=\"share-identifier-more-button\"]");
}
get moreOptionsButtonLabel() {
return $("[data-testid=\"share-identifier-more-label\"]");
}
get modalTitle() {
return this.modalTitleElement("share-connection");
}
get qrCodeColumn() {
return $("[data-testid=\"share-identifier-qr-code\"]");
}
async loads() {
await expect(this.modalTitle).toHaveText("Share connection");
await expect(this.qrCodeColumn).toBeDisplayed();
await expect(this.copyButton).toBeDisplayed();
await expect(this.copyButtonLabel).toHaveText("Copy Out-of-Band Invitation (OOBI)");
await expect(this.moreOptionsButton).toBeDisplayed();
await expect(this.moreOptionsButtonLabel).toHaveText("More share options");
}
}
export default new IdentityShareModal();

View File

@@ -0,0 +1,36 @@
import { expect } from "expect-webdriverio";
import {
findAndClickLocator,
findFilterAndClickElement,
} from "../base.screen.js";
export class MenuToolbar {
backArrowButtonLocator = "[data-testid=\"back-button\"]";
get addButton() {
return $("[data-testid=\"add-button\"]");
}
get connectionsButton() {
return $("[data-testid=\"connections-button\"]");
}
async menusButton(screenLocator: string) {
return $(`[data-testid="menu-button-${screenLocator}"]`);
}
async clickBackArrowButtonOf(parent: string) {
await findAndClickLocator(`${parent} ${this.backArrowButtonLocator}`);
}
async clickBackArrowIcon() {
await findFilterAndClickElement(this.backArrowButtonLocator);
}
async loads() {
await expect(this.addButton).toBeDisplayed();
await expect(this.connectionsButton).toBeDisplayed();
}
}
export default new MenuToolbar();

View File

@@ -0,0 +1,52 @@
import { expect } from "expect-webdriverio";
import { PrivacyPolicy } from "../../constants/text.constants.js";
import { BaseModal } from "./base.modal.js";
export class PrivacyPolicyModal extends BaseModal {
modalName = "privacy-policy";
async validateSectionContent(
sectionName: string,
sectionIndex: number,
sectionLength: number
) {
const sectionLocator = this.returnSectionTitleLocator(
this.modalName,
sectionName
);
await expect($(`${sectionLocator}`)).toHaveText(
PrivacyPolicy[`Section${sectionIndex}Title` as keyof typeof PrivacyPolicy]
);
for (let i = 1; i <= sectionLength; i++) {
await expect(
await this.subsectionElement(sectionLocator, "content", i)
).toHaveText(
PrivacyPolicy[
`Section${sectionIndex}Content${i}` as keyof typeof PrivacyPolicy
]
);
}
}
async loads() {
await expect(this.introTitle(this.modalName)).toHaveText(
PrivacyPolicy.Title
);
await expect(this.introText(this.modalName)).toHaveText(
PrivacyPolicy.Intro
);
await this.validateSectionContent("datacontrollerandcontactdetails", 1, 1);
await this.validateSectionContent("typesofdatacollected", 2, 6);
await this.validateSectionContent("howwecollectyourpersonaldata", 3, 5);
await this.validateSectionContent("useofpersonaldata", 4, 6);
await this.validateSectionContent("datasecurityandtransfer", 5, 4);
await this.validateSectionContent("retention", 6, 4);
await this.validateSectionContent("datadisclosure", 7, 11);
await this.validateSectionContent("yourrights", 8, 10);
await this.validateSectionContent("thirdpartylinks", 9, 2);
await this.validateSectionContent("changes", 10, 2);
await this.validateSectionContent("dataprivacycontact", 11, 1);
}
}
export default new PrivacyPolicyModal();

View File

@@ -0,0 +1,33 @@
import { expect } from "expect-webdriverio";
export class TabBar {
get credentialsTabButton() {
return $("#tab-button-Credentials");
}
get identityTabButton() {
return $("#tab-button-Identity");
}
get menuTabButton() {
return $("#tab-button-Menu");
}
get p2pChatTabButton() {
return $("#tab-button-P2P");
}
get scanTabButton() {
return $("#tab-button-Scan");
}
async loads() {
await expect(this.identityTabButton).toBeDisplayed();
await expect(this.credentialsTabButton).toBeDisplayed();
await expect(this.scanTabButton).toBeDisplayed();
await expect(this.p2pChatTabButton).toBeDisplayed();
await expect(this.menuTabButton).toBeDisplayed();
}
}
export default new TabBar();

View File

@@ -0,0 +1,61 @@
import { expect } from "expect-webdriverio";
import { TermsOfUse } from "../../constants/text.constants.js";
import { BaseModal } from "./base.modal.js";
export class TermsOfUseModal extends BaseModal {
modalName = "terms-of-use";
async validateSubtitlesAndContent(
sectionName: string,
sectionIndex: number,
sectionLength: number
) {
const sectionLocator = this.returnSectionTitleLocator(
this.modalName,
sectionName
);
await expect($(`${sectionLocator}`)).toHaveText(
TermsOfUse[`Section${sectionIndex}Title` as keyof typeof TermsOfUse]
);
for (let i = 1; i <= sectionLength; i++) {
await expect(
await this.subsectionElement(sectionLocator, "subtitle", i)
).toHaveText(
TermsOfUse[
`Section${sectionIndex}Subtitle${i}` as keyof typeof TermsOfUse
]
);
await expect(
await this.subsectionElement(sectionLocator, "content", i)
).toHaveText(
TermsOfUse[
`Section${sectionIndex}Content${i}` as keyof typeof TermsOfUse
]
);
}
}
async loads() {
await expect(this.introTitle(this.modalName)).toHaveText(TermsOfUse.Title);
await expect(this.introText(this.modalName)).toHaveText(TermsOfUse.Intro);
await this.validateSubtitlesAndContent("useofproducts", 1, 7);
await this.validateSubtitlesAndContent("yourcontent", 2, 5);
await this.validateSubtitlesAndContent("intellectualproperty", 3, 4);
await this.validateSubtitlesAndContent(
"disclaimerslimitationofliability",
4,
4
);
const section5Locator = this.returnSectionTitleLocator(
this.modalName,
"indemnification"
);
await expect($(`${section5Locator}`)).toHaveText(TermsOfUse.Section5Title);
await expect(
await this.subsectionElement(section5Locator, "content", 1)
).toHaveText(TermsOfUse.Section5Content1);
await this.validateSubtitlesAndContent("miscellaneous", 6, 2);
}
}
export default new TermsOfUseModal();

View File

@@ -0,0 +1,13 @@
import { BaseModal } from "./base.modal.js";
export class WelcomeModal extends BaseModal {
get confirmButton() {
return $("[data-testid=\"primary-button-set-user-name\"]");
}
get nameInput() {
return $("#set-user-name-input > label > div > input");
}
}
export default new WelcomeModal();