Skip to content

Commit 41a3176

Browse files
feat: assert snapshot deleted
1 parent adb8c4c commit 41a3176

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

e2e/page-objects/cli.page.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import {assertNonNullish} from '@dfinity/utils';
1+
import {assertNonNullish, notEmptyString} from '@dfinity/utils';
22
import type {PrincipalText} from '@dfinity/zod-schemas';
3-
import {execute} from '@junobuild/cli-tools';
3+
import {execute, spawn} from '@junobuild/cli-tools';
44
import {readdirSync, statSync} from 'node:fs';
55
import {readFile, writeFile} from 'node:fs/promises';
66
import {join} from 'node:path';
@@ -155,6 +155,24 @@ export class CliPage extends TestPage {
155155
});
156156
}
157157

158+
async listSnapshot({
159+
target
160+
}: {
161+
target: 'satellite' | 'orbiter' | 'mission-control';
162+
}): Promise<{snapshotId: string | undefined}> {
163+
let output = '';
164+
165+
await spawn({
166+
command: JUNO_CMD,
167+
args: buildArgs(['snapshot', 'list', '--target', target]),
168+
stdout: (o) => (output += o),
169+
silentErrors: true
170+
});
171+
172+
const [_, snapshotId] = output.split('Snapshot found:');
173+
return {snapshotId: notEmptyString(snapshotId) ? snapshotId.trim() : undefined};
174+
}
175+
158176
/**
159177
* @override
160178
*/

e2e/snapshots.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {testWithII} from '@dfinity/internet-identity-playwright';
2+
import {expect} from '@playwright/test';
23
import {initTestSuite} from './utils/init.utils';
34

45
const getTestPages = initTestSuite();
@@ -34,7 +35,8 @@ testWithII('should create, download, delete, upload and restore a snapshot', asy
3435

3536
await cliPage.deleteSnapshot(SNAPSHOT_TARGET);
3637

37-
// TODO: assert no snapshot
38+
const {snapshotId} = await cliPage.listSnapshot(SNAPSHOT_TARGET);
39+
expect(snapshotId).toBeUndefined();
3840

3941
await cliPage.clearHosting();
4042

0 commit comments

Comments
 (0)