-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved the assertions to the modal pages
- Loading branch information
1 parent
f67cece
commit 693f264
Showing
4 changed files
with
139 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import { AppPage } from "tests/page/abstractClasses"; | ||
import { step } from "tests/misc/reporters/step"; | ||
import { expect } from '@playwright/test'; | ||
Check failure on line 3 in apps/ledger-live-desktop/tests/page/ledgerSync.page.ts
|
||
|
||
export class LedgerSyncPage extends AppPage { | ||
private syncAccountsButton = this.page.getByRole("button", { name: "Sync your accounts" }); | ||
private closeLedgerSyncButton = this.page.getByRole("button", { name: "Close" }); | ||
private manageInstancesButton = this.page | ||
.getByTestId("walletSync-manage-instances") | ||
.getByText("Manage"); | ||
private manageBackupButton = this.page.getByTestId("walletSync-manage-backup"); | ||
private deleteBackupButton = this.page.getByTestId("walletSync-manage-backup-delete"); | ||
private confirmBackupDeletionButton = this.page.getByRole("button", { name: "Delete" }); | ||
private successTextElement = this.page.locator("span", { hasText: "Success" }).first(); | ||
private closeLSDrawerButton = this.page.getByTestId("drawer-close-button"); | ||
private backupDeletionSuccessText = this.page.getByText( | ||
"Your devices have been unsynchronized and your key has been deleted", | ||
); | ||
|
||
async SyncAccounts() { | ||
await this.syncAccountsButton.click(); | ||
} | ||
|
||
async doesSyncAccountsButtonExist(): Promise<boolean> { | ||
return this.syncAccountsButton.isVisible(); | ||
} | ||
|
||
async closeLedgerSync() { | ||
await this.closeLedgerSyncButton.click(); | ||
} | ||
|
||
async openManageInstances() { | ||
await this.manageInstancesButton.click(); | ||
} | ||
|
||
async manageBackup() { | ||
await this.manageBackupButton.click(); | ||
} | ||
|
||
async deleteBackup() { | ||
await this.deleteBackupButton.click(); | ||
} | ||
|
||
async confirmBackupDeletion() { | ||
await this.confirmBackupDeletionButton.click(); | ||
} | ||
|
||
async destroyTrustchain() { | ||
await this.manageBackup(); | ||
await this.deleteBackup(); | ||
await this.confirmBackupDeletion(); | ||
} | ||
|
||
async checkSynchronizationSuccess(): Promise<boolean> { | ||
await this.successTextElement.waitFor({ state: "visible" }); | ||
return this.successTextElement.isVisible(); | ||
} | ||
|
||
async backupDeletionSuccess(): Promise<boolean> { | ||
await this.backupDeletionSuccessText.waitFor({ state: "visible" }); | ||
return this.backupDeletionSuccessText.isVisible(); | ||
} | ||
|
||
async countSyncedInstances(): Promise<number> { | ||
const countInstancesText = await this.page.getByText("Synchronized instance").textContent(); | ||
const instanceCount = extractNumberFromText(countInstancesText || ""); | ||
return instanceCount; | ||
} | ||
|
||
async closeLSManagerDrawer() { | ||
await this.closeLSDrawerButton.nth(0).click(); | ||
} | ||
|
||
@step("Check if sync entry point exists") | ||
async expectSyncAccountsButtonExist() { | ||
const isSyncButtonVisible = await this.doesSyncAccountsButtonExist(); | ||
expect(isSyncButtonVisible).toBe(true); | ||
} | ||
|
||
@step("Perform synchronization and validate success") | ||
async expectSynchronizationSuccess() { | ||
const success = await this.checkSynchronizationSuccess(); | ||
expect(success).toBe(true); | ||
} | ||
|
||
@step("Validate number of synchronized instances") | ||
async expectNbSyncedInstances(nb: number) { | ||
const nbInstances = await this.countSyncedInstances(); | ||
expect(nbInstances).toBe(nb); | ||
} | ||
|
||
@step("Trustchain destroyed") | ||
async expectBackupDeletion() { | ||
const deletionsuccess = await this.backupDeletionSuccess(); | ||
expect(deletionsuccess).toBe(true); | ||
} | ||
} | ||
|
||
async function extractNumberFromText(text: string): Promise<number> { | ||
const match = text.match(/\d+/); | ||
return match ? parseInt(match[0], 10) : 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 35 additions & 50 deletions
85
apps/ledger-live-desktop/tests/specs/speculos/manage.ledgersync.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,43 @@ | ||
import { test } from "../../fixtures/common"; | ||
import { addTmsLink } from "tests/utils/allureUtils"; | ||
import { getDescription } from "../../utils/customJsonReporter"; | ||
import { expect } from '@playwright/test'; | ||
import { AppInfos } from "tests/enum/AppInfos"; | ||
|
||
const apps: AppInfos[] = [AppInfos.LS]; | ||
// Use a single value instead of an array | ||
const app: AppInfos = AppInfos.LS; | ||
|
||
for (const myapp of apps) { | ||
test.describe(`[${myapp.name}] Add Accounts`, () => { | ||
test.use({ | ||
userdata: "ledgerSync", | ||
speculosApp: myapp, | ||
|
||
}); | ||
|
||
test("Synchronize one instance then delete the backup", async ({ app, page }) => { | ||
const description = getDescription(test.info().annotations).split(", "); | ||
await addTmsLink(description); | ||
|
||
// Step 1: Validate the presence of the sync entry point | ||
await test.step("Check if sync entry point exists", async () => { | ||
await app.settings.goToSettings(); | ||
await app.settings.goToGeneralSettings(); | ||
await app.settings.openManageLedgerSync(); | ||
const isSyncButtonVisible = await app.settings.doesSyncAccountsButtonExist(); | ||
expect(isSyncButtonVisible).toBe(true); | ||
}); | ||
|
||
// Step 2: Perform synchronization and validate the process | ||
await test.step("Perform synchronization and validate success", async () => { | ||
await app.settings.SyncAccounts(); | ||
await app.speculos.confirmOperationOnDevice("Log in to"); | ||
await app.speculos.confirmOperationOnDevice("Enable"); | ||
const success = await app.settings.checkSynchronizationSuccess(); | ||
expect(success).toBe(true); | ||
await app.settings.closeLedgerSync(); | ||
}); | ||
|
||
// Step 3: Validate the number of synchronized instances | ||
await test.step("Validate number of synchronized instances", async () => { | ||
await app.settings.openManageLedgerSync(); | ||
const nbInstances = await app.settings.countSyncedInstances(); | ||
expect(nbInstances).toBe(1); | ||
await app.settings.closeLSManagerDrawer(); | ||
}); | ||
test.describe(`[${app.name}] Sync Accounts`, () => { | ||
test.use({ | ||
userdata: "ledgerSync", | ||
speculosApp: app, | ||
}); | ||
|
||
// Step 4: Delete backup | ||
await test.step("Delete backup and validate", async () => { | ||
await app.settings.openManageLedgerSync(); | ||
await app.settings.destroyTrustchain(); | ||
const deletionsuccess = await app.settings.backupDeletionSuccess(); | ||
expect(deletionsuccess).toBe(true); | ||
await app.settings.closeLSManagerDrawer(); | ||
}); | ||
}); | ||
test("Synchronize one instance then delete the backup", async ({ app, page }) => { | ||
Check failure on line 15 in apps/ledger-live-desktop/tests/specs/speculos/manage.ledgersync.spec.ts
|
||
const description = getDescription(test.info().annotations).split(", "); | ||
await addTmsLink(description); | ||
|
||
// Step 1: Validate the presence of the sync entry point | ||
await app.settings.goToSettings(); | ||
await app.settings.goToGeneralSettings(); | ||
await app.settings.openManageLedgerSync(); | ||
await app.ledgerSync.expectSyncAccountsButtonExist(); | ||
|
||
// Step 2: Perform synchronization and validate the process | ||
await app.ledgerSync.SyncAccounts(); | ||
await app.speculos.confirmOperationOnDevice("Log in to"); | ||
await app.speculos.confirmOperationOnDevice("Enable"); | ||
await app.ledgerSync.expectSynchronizationSuccess(); | ||
await app.ledgerSync.closeLedgerSync(); | ||
|
||
// Step 3: Validate the number of synchronized instances | ||
await app.settings.openManageLedgerSync(); | ||
await app.ledgerSync.expectNbSyncedInstances(1); | ||
await app.ledgerSync.closeLSManagerDrawer(); | ||
|
||
// Step 4: Delete backup | ||
await app.settings.openManageLedgerSync(); | ||
await app.ledgerSync.destroyTrustchain(); | ||
await app.ledgerSync.expectBackupDeletion(); | ||
await app.ledgerSync.closeLSManagerDrawer(); | ||
}); | ||
} | ||
}); |