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
15 changes: 0 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
},
"devDependencies": {
"@dfinity/eslint-config-oisy-wallet": "^0.2.3",
"@dfinity/internet-identity-playwright": "^3.0.0-next-2026-01-31",
"@dfinity/pic": "^0.17.2",
"@dfinity/response-verification": "^3.0.3",
"@icp-sdk/bindgen": "^0.2.1",
Expand Down
4 changes: 2 additions & 2 deletions src/e2e/create-analytics.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { testWithII } from '@dfinity/internet-identity-playwright';
import { test } from '@playwright/test';
import { initTestSuite } from './utils/init.utils';

const getConsolePage = initTestSuite();

testWithII('should create analytics', async () => {
test('should create analytics', async () => {
const consolePage = getConsolePage();

await consolePage.createAnalytics();
Expand Down
7 changes: 3 additions & 4 deletions src/e2e/create-application.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { testWithII } from '@dfinity/internet-identity-playwright';
import { expect } from '@playwright/test';
import { expect, test } from '@playwright/test';
import { initTestSuite } from './utils/init.utils';

const getConsolePage = initTestSuite();

testWithII('should create a satellite for an application', async () => {
test('should create a satellite for an application', async () => {
const consolePage = getConsolePage();

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

testWithII('should visit newly create satellite', async () => {
test('should visit newly create satellite', async () => {
const consolePage = getConsolePage();

const satellitePage = await consolePage.visitSatellite();
Expand Down
4 changes: 2 additions & 2 deletions src/e2e/create-second-satellite.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { testWithII } from '@dfinity/internet-identity-playwright';
import { test } from '@playwright/test';
import { initTestSuite } from './utils/init.utils';

const getConsolePage = initTestSuite();

testWithII('should not allow creating a second satellite', async () => {
test('should not allow creating a second satellite', async () => {
const consolePage = getConsolePage();

// First creation succeeds (use website by default – scenario symmetry with existing tests)
Expand Down
7 changes: 3 additions & 4 deletions src/e2e/create-website.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { testWithII } from '@dfinity/internet-identity-playwright';
import { expect } from '@playwright/test';
import { expect, test } from '@playwright/test';
import { initTestSuite } from './utils/init.utils';

const getConsolePage = initTestSuite();

testWithII('should create a satellite for a website', async () => {
test('should create a satellite for a website', async () => {
const consolePage = getConsolePage();

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

testWithII('should visit newly create satellite', async () => {
test('should visit newly create satellite', async () => {
const consolePage = getConsolePage();

const satellitePage = await consolePage.visitSatellite();
Expand Down
111 changes: 57 additions & 54 deletions src/e2e/page-objects/console.page.ts
Original file line number Diff line number Diff line change
@@ -1,68 +1,69 @@
import { testIds } from '$lib/constants/test-ids.constants';
import i18n from '$lib/i18n/en.json' with { type: 'json' };
import { InternetIdentityPage } from '@dfinity/internet-identity-playwright';
import { expect } from '@playwright/test';
import { type BrowserContext, expect } from '@playwright/test';
import { nanoid } from 'nanoid';
import type { Page } from 'playwright-core';
import { TIMEOUT_AVERAGE, TIMEOUT_LONG } from '../constants/e2e.constants';
import { IdentityPage, type IdentityPageParams } from './identity.page';

export class ConsolePage extends IdentityPage {
#consoleIIPage: InternetIdentityPage;
export interface ConsolePageParams {
page: Page;
context: BrowserContext;
}

constructor(params: IdentityPageParams) {
super(params);
export class ConsolePage {
readonly #page: Page;
readonly #context: BrowserContext;

this.#consoleIIPage = new InternetIdentityPage({
page: this.page,
context: this.context,
browser: this.browser
});
constructor({ page, context }: ConsolePageParams) {
this.#page = page;
this.#context = context;
}

async goto(): Promise<void> {
await this.page.goto('/');
await this.#page.goto('/');
}

async signInWithII(): Promise<void> {
await this.#consoleIIPage.signIn({
passkey: {
selector: `[data-tid=${testIds.auth.signInII}]`
}
});
}
async signIn(): Promise<void> {
await expect(this.#page.getByTestId(testIds.auth.switchDevAccount)).toBeVisible(
TIMEOUT_AVERAGE
);

await this.#page.getByTestId(testIds.auth.switchDevAccount).click();

async waitReady(): Promise<void> {
const CONTAINER_URL = 'http://127.0.0.1:5987';
const INTERNET_IDENTITY_ID = 'rdmx6-jaaaa-aaaaa-aaadq-cai';
await expect(this.#page.getByTestId(testIds.auth.inputDevIdentifier)).toBeVisible();

await this.#consoleIIPage.waitReady({ url: CONTAINER_URL, canisterId: INTERNET_IDENTITY_ID });
await this.#page.getByTestId(testIds.auth.inputDevIdentifier).fill(nanoid());

await expect(this.#page.getByTestId(testIds.auth.continueDevAccount)).toBeVisible();

await this.#page.getByTestId(testIds.auth.continueDevAccount).click();
}

async createSatellite({ kind }: { kind: 'website' | 'application' }): Promise<void> {
await expect(this.page.getByTestId(testIds.launchpad.launch)).toBeVisible(TIMEOUT_AVERAGE);
await expect(this.#page.getByTestId(testIds.launchpad.launch)).toBeVisible(TIMEOUT_AVERAGE);

await this.page.getByTestId(testIds.launchpad.launch).click();
await this.#page.getByTestId(testIds.launchpad.launch).click();

await expect(this.page.getByTestId(testIds.createSatellite.create)).toBeVisible();
await expect(this.#page.getByTestId(testIds.createSatellite.create)).toBeVisible();

await this.page.getByTestId(testIds.createSatellite.input).fill('Test');
await this.page.getByTestId(testIds.createSatellite[kind]).click();
await this.#page.getByTestId(testIds.createSatellite.input).fill('Test');
await this.#page.getByTestId(testIds.createSatellite[kind]).click();

await this.page.getByTestId(testIds.createSatellite.create).click();
await this.#page.getByTestId(testIds.createSatellite.create).click();

await expect(this.page.getByTestId(testIds.createSatellite.continue)).toBeVisible(
await expect(this.#page.getByTestId(testIds.createSatellite.continue)).toBeVisible(
TIMEOUT_AVERAGE
);

await this.page.getByTestId(testIds.createSatellite.continue).click();
await this.#page.getByTestId(testIds.createSatellite.continue).click();
}

async visitSatellite(): Promise<Page> {
await expect(this.page.getByTestId(testIds.satelliteOverview.visit)).toBeVisible();
await expect(this.#page.getByTestId(testIds.satelliteOverview.visit)).toBeVisible();

const satellitePagePromise = this.context.waitForEvent('page');
const satellitePagePromise = this.#context.waitForEvent('page');

await this.page.getByTestId(testIds.satelliteOverview.visit).click();
await this.#page.getByTestId(testIds.satelliteOverview.visit).click();

const satellitePage = await satellitePagePromise;

Expand All @@ -72,57 +73,59 @@ export class ConsolePage extends IdentityPage {
}

async createAnalytics(): Promise<void> {
await this.page.goto('/analytics');
await this.#page.goto('/analytics');

await expect(this.page.getByTestId(testIds.createAnalytics.launch)).toBeVisible(
await expect(this.#page.getByTestId(testIds.createAnalytics.launch)).toBeVisible(
TIMEOUT_AVERAGE
);

await this.page.getByTestId(testIds.createAnalytics.launch).click();
await this.#page.getByTestId(testIds.createAnalytics.launch).click();

await expect(this.page.getByTestId(testIds.createAnalytics.create)).toBeVisible();
await expect(this.#page.getByTestId(testIds.createAnalytics.create)).toBeVisible();

await this.page.getByTestId(testIds.createAnalytics.create).click();
await this.#page.getByTestId(testIds.createAnalytics.create).click();

await expect(this.page.getByTestId(testIds.createAnalytics.close)).toBeVisible(TIMEOUT_AVERAGE);
await expect(this.#page.getByTestId(testIds.createAnalytics.close)).toBeVisible(
TIMEOUT_AVERAGE
);

await this.page.getByTestId(testIds.createAnalytics.close).click();
await this.#page.getByTestId(testIds.createAnalytics.close).click();

await expect(this.page.getByText(i18n.analytics.unique_page_views)).toBeVisible(
await expect(this.#page.getByText(i18n.analytics.unique_page_views)).toBeVisible(
TIMEOUT_AVERAGE
);

await expect(this.page).toHaveScreenshot({ fullPage: true, maxDiffPixelRatio: 0.05 });
await expect(this.#page).toHaveScreenshot({ fullPage: true, maxDiffPixelRatio: 0.05 });
}

async getCycles(expected: { balance: string }): Promise<void> {
await this.page.getByTestId(testIds.navbar.openWallet).click();
await this.#page.getByTestId(testIds.navbar.openWallet).click();

await this.page.getByTestId(testIds.navbar.getCycles).click();
await this.#page.getByTestId(testIds.navbar.getCycles).click();

await expect(this.page.getByRole('menu')).toContainText(expected.balance, TIMEOUT_LONG);
await expect(this.#page.getByRole('menu')).toContainText(expected.balance, TIMEOUT_LONG);
}

async openCreateAdditionalSatelliteWizard(): Promise<void> {
await expect(this.page.getByTestId(testIds.launchpad.actions)).toBeVisible(TIMEOUT_AVERAGE);
await expect(this.#page.getByTestId(testIds.launchpad.actions)).toBeVisible(TIMEOUT_AVERAGE);

await this.page.getByTestId(testIds.launchpad.actions).click();
await this.#page.getByTestId(testIds.launchpad.actions).click();

await expect(this.page.getByTestId(testIds.launchpad.launchExtraSatellite)).toBeVisible(
await expect(this.#page.getByTestId(testIds.launchpad.launchExtraSatellite)).toBeVisible(
TIMEOUT_AVERAGE
);

await this.page.getByTestId(testIds.launchpad.launchExtraSatellite).click();
await this.#page.getByTestId(testIds.launchpad.launchExtraSatellite).click();
}

async failedAtCreatingSatellite(): Promise<void> {
await expect(this.page.getByTestId(testIds.wizard.closeInsufficientFunds)).toBeVisible();
await expect(this.page.getByTestId(testIds.createSatellite.create)).not.toBeVisible();
await expect(this.#page.getByTestId(testIds.wizard.closeInsufficientFunds)).toBeVisible();
await expect(this.#page.getByTestId(testIds.createSatellite.create)).not.toBeVisible();

const expectedText = i18n.satellites.create_satellite_price
.replace('{0}', '3.000 TCycles')
.replace('{1}', '0.000 TCycles');

await expect(this.page.getByText(expectedText)).toBeVisible();
await expect(this.#page.getByText(expectedText)).toBeVisible();
}
}
23 changes: 0 additions & 23 deletions src/e2e/page-objects/identity.page.ts

This file was deleted.

19 changes: 6 additions & 13 deletions src/e2e/utils/init.utils.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { testWithII } from '@dfinity/internet-identity-playwright';
import { test } from '@playwright/test';
import { ConsolePage } from '../page-objects/console.page';

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

let consolePage: ConsolePage;

testWithII.beforeAll(async ({ playwright }) => {
testWithII.setTimeout(120000);
test.beforeAll(async ({ playwright }) => {
test.setTimeout(120000);

const browser = await playwright.chromium.launch();

Expand All @@ -16,19 +16,12 @@ export const initTestSuite = (): (() => ConsolePage) => {

consolePage = new ConsolePage({
page,
context,
browser
context
});

await consolePage.waitReady();

await consolePage.goto();

await consolePage.signInWithII();
});

testWithII.afterAll(async () => {
await consolePage.close();
await consolePage.signIn();
});

return (): ConsolePage => consolePage;
Expand Down
15 changes: 6 additions & 9 deletions src/e2e/wallet.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { testWithII } from '@dfinity/internet-identity-playwright';
import { test } from '@playwright/test';
import { initTestSuite } from './utils/init.utils';

const getConsolePage = initTestSuite();

testWithII(
'should have wallet balance equal 330.010 TCycles when developer click on Get Cycles',
async () => {
testWithII.setTimeout(60_000);
test('should have wallet balance equal 330.010 TCycles when developer click on Get Cycles', async () => {
test.setTimeout(60_000);

const consolePage = getConsolePage();
const consolePage = getConsolePage();

await consolePage.getCycles({ balance: '330.010 TCycles' });
}
);
await consolePage.getCycles({ balance: '330.010 TCycles' });
});
Loading