Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 21 additions & 13 deletions tests/e2e/disaster-recovery.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ test('can recover uninstalled station', async ({ page }) => {
);

await page.goto(walletUrl);
await page.getByText(/disaster recovery/i).click();

// The entry point only appears once the wallet has noticed the station is uninstalled, so it is
// waited for rather than clicked straight away.
const disasterRecoveryLink = page.getByText(/disaster recovery/i).first();
await disasterRecoveryLink.waitFor({ state: 'visible', timeout: 60_000 });
await disasterRecoveryLink.click();

const disasterRecoveryPage = new DisasterRecoveryPage(page);
await disasterRecoveryPage.assertIsOn();
Expand All @@ -64,17 +69,20 @@ test('can recover uninstalled station', async ({ page }) => {
await accountsPage.openByName('Main');

await accountPage.pickByAsset('ICP');
await accountAssetPage.getBalance();

while (true) {
// refresh the page
await page.reload();
const balance = await accountAssetPage.getBalance();

if (balance!.includes('5.0')) {
break;
}

await page.waitForTimeout(5000);
}
// Bounded so that a balance that never returns fails here reporting what it actually read,
// instead of spinning until the shared test budget runs out somewhere unrelated.
await expect
.poll(
async () => {
await page.reload();
return (await accountAssetPage.getBalance()) ?? '';
},
{
message: 'the ICP balance should be restored after disaster recovery',
timeout: 180_000,
intervals: [5_000],
},
)
.toContain('5.0');
});
18 changes: 11 additions & 7 deletions tests/e2e/page-objects/settings.page.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Page } from '@playwright/test';
import { expect, Page } from '@playwright/test';
import { getWalletPath } from '../config';
import { getCanisterInfo } from '../utils/dfx.utils';

Expand All @@ -25,12 +25,16 @@ export class SettingsPage {
await this.page.getByTestId('continue-action-btn').click();
await this.page.getByTestId('submit-action-btn').click();

while (checkForNewModuleHash) {
const newModuleHash = getCanisterInfo(stationId).moduleHash;
if (newModuleHash !== originalModuleHash) {
break;
}
await this.page.waitForTimeout(1000);
if (checkForNewModuleHash) {
// Bounded so a wasm that never installs fails here rather than consuming the whole test
// budget and surfacing as a timeout in a later, unrelated step.
await expect
.poll(() => getCanisterInfo(stationId).moduleHash, {
message: 'the station module hash should change after installing the custom wasm',
timeout: 120_000,
intervals: [2_000],
})
.not.toBe(originalModuleHash);
}

// wait till the canister starts again
Expand Down
Loading