Skip to content
Merged
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
123 changes: 66 additions & 57 deletions e2e/snapshots.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,94 +2,103 @@ import {testWithII} from '@dfinity/internet-identity-playwright';
import {expect} from '@playwright/test';
import {initTestSuite} from './utils/init.utils';

const getTestPages = initTestSuite();
testWithII.describe.configure({mode: 'serial'});

const SNAPSHOT_TARGET = {target: 'satellite' as const};
const snapshotTests = ({satelliteKind}: {satelliteKind: 'website' | 'application'}) => {
testWithII.describe(`satellite ${satelliteKind}`, () => {
const getTestPages = initTestSuite({satelliteKind});

testWithII('should create and restore a snapshot', async () => {
const {consolePage, cliPage} = getTestPages();
const SNAPSHOT_TARGET = {target: 'satellite' as const};

await cliPage.createSnapshot(SNAPSHOT_TARGET);
testWithII('should create and restore a snapshot', async () => {
const {consolePage, cliPage} = getTestPages();

await cliPage.clearHosting();
await cliPage.createSnapshot(SNAPSHOT_TARGET);

const satellitePage = await consolePage.visitSatelliteSite({
title: 'Internet Computer - Error: response verification error'
});
await satellitePage.assertScreenshot();
await cliPage.clearHosting();

const satellitePage = await consolePage.visitSatelliteSite({
title: 'Internet Computer - Error: response verification error'
});
await satellitePage.assertScreenshot();

await cliPage.restoreSnapshot(SNAPSHOT_TARGET);
await cliPage.restoreSnapshot(SNAPSHOT_TARGET);

await satellitePage.reload();
await satellitePage.assertScreenshot();
});
await satellitePage.reload();
await satellitePage.assertScreenshot();
});

testWithII('should create, download, delete, upload and restore a snapshot', async () => {
testWithII.setTimeout(120_000);
testWithII('should create, download, delete, upload and restore a snapshot', async () => {
testWithII.setTimeout(120_000);

const {consolePage, cliPage} = getTestPages();
const {consolePage, cliPage} = getTestPages();

await cliPage.createSnapshot(SNAPSHOT_TARGET);
await cliPage.createSnapshot(SNAPSHOT_TARGET);

const {snapshotFolder} = await cliPage.downloadSnapshot(SNAPSHOT_TARGET);
const {snapshotFolder} = await cliPage.downloadSnapshot(SNAPSHOT_TARGET);

await cliPage.deleteSnapshot(SNAPSHOT_TARGET);
await cliPage.deleteSnapshot(SNAPSHOT_TARGET);

const {snapshotId} = await cliPage.listSnapshot(SNAPSHOT_TARGET);
expect(snapshotId).toBeUndefined();
const {snapshotId} = await cliPage.listSnapshot(SNAPSHOT_TARGET);
expect(snapshotId).toBeUndefined();

await cliPage.clearHosting();
await cliPage.clearHosting();

const satellitePage = await consolePage.visitSatelliteSite({
title: 'Internet Computer - Error: response verification error'
});
await satellitePage.assertScreenshot();
const satellitePage = await consolePage.visitSatelliteSite({
title: 'Internet Computer - Error: response verification error'
});
await satellitePage.assertScreenshot();

await cliPage.uploadSnapshot({...SNAPSHOT_TARGET, folder: snapshotFolder});
await cliPage.uploadSnapshot({...SNAPSHOT_TARGET, folder: snapshotFolder});

await cliPage.restoreSnapshot(SNAPSHOT_TARGET);
await cliPage.restoreSnapshot(SNAPSHOT_TARGET);

await satellitePage.reload();
await satellitePage.assertScreenshot();
});
await satellitePage.reload();
await satellitePage.assertScreenshot();
});

testWithII(
'should create, download, delete, upload and restore a snapshot to another satellite',
async () => {
testWithII.setTimeout(120_000);
testWithII(
'should create, download, delete, upload and restore a snapshot to another satellite',
async () => {
testWithII.setTimeout(120_000);

const {consolePage, cliPage} = getTestPages();
const {consolePage, cliPage} = getTestPages();

await consolePage.getICP();
await consolePage.getICP();

await consolePage.goto();
await consolePage.goto();

await consolePage.createSatellite({kind: 'application'});
await consolePage.createSatellite({kind: 'application'});

const satelliteId = await consolePage.copySatelliteID();
const satelliteId = await consolePage.copySatelliteID();

await cliPage.toggleSatelliteId({satelliteId});
await cliPage.toggleSatelliteId({satelliteId});

const {accessKey} = await cliPage.whoami();
const {accessKey} = await cliPage.whoami();

await consolePage.addSatelliteAdminAccessKey({accessKey, satelliteId});
await consolePage.addSatelliteAdminAccessKey({accessKey, satelliteId});

await cliPage.deployHosting({clear: true});
await cliPage.deployHosting({clear: true});

await consolePage.goto({path: `/satellite/?s=${satelliteId}`});
await consolePage.goto({path: `/satellite/?s=${satelliteId}`});

const satellitePage = await consolePage.visitSatelliteSite({
title: 'Hello World'
});
await satellitePage.assertScreenshot();
const satellitePage = await consolePage.visitSatelliteSite({
title: 'Hello World'
});
await satellitePage.assertScreenshot();

const {snapshotFolder} = await cliPage.getSnapshotFsFolder();
const {snapshotFolder} = await cliPage.getSnapshotFsFolder();

await cliPage.uploadSnapshot({...SNAPSHOT_TARGET, folder: snapshotFolder});
await cliPage.uploadSnapshot({...SNAPSHOT_TARGET, folder: snapshotFolder});

await cliPage.restoreSnapshot(SNAPSHOT_TARGET);
await cliPage.restoreSnapshot(SNAPSHOT_TARGET);

await satellitePage.reload();
await satellitePage.assertScreenshot();
}
);
});
};

await satellitePage.reload();
await satellitePage.assertScreenshot();
}
);
snapshotTests({satelliteKind: 'application'});
snapshotTests({satelliteKind: 'website'});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 6 additions & 4 deletions e2e/utils/init.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ interface TestSuitePages {
cliPage: CliPage;
}

export const initTestSuite = (): (() => TestSuitePages) => {
testWithII.describe.configure({mode: 'serial'});

export const initTestSuite = ({
satelliteKind
}: {
satelliteKind: 'website' | 'application';
}): (() => TestSuitePages) => {
let consolePage: ConsolePage;
let cliPage: CliPage;

Expand All @@ -27,7 +29,7 @@ export const initTestSuite = (): (() => TestSuitePages) => {
browser
});

await consolePage.createSatellite({kind: 'website'});
await consolePage.createSatellite({kind: satelliteKind});

const satelliteId = await consolePage.copySatelliteID();

Expand Down