diff --git a/e2e/constants/e2e.constants.ts b/e2e/constants/e2e.constants.ts new file mode 100644 index 0000000..2a14089 --- /dev/null +++ b/e2e/constants/e2e.constants.ts @@ -0,0 +1,5 @@ +const TIMEOUT_BASE = 15000; + +export const TIMEOUT_SHORT = {timeout: TIMEOUT_BASE}; +export const TIMEOUT_AVERAGE = {timeout: 2 * TIMEOUT_BASE}; +export const TIMEOUT_LONG = {timeout: 4 * TIMEOUT_BASE}; diff --git a/e2e/constants/test-ids.constants.ts b/e2e/constants/test-ids.constants.ts index 3483c19..4ee4b8a 100644 --- a/e2e/constants/test-ids.constants.ts +++ b/e2e/constants/test-ids.constants.ts @@ -4,8 +4,12 @@ export const testIds = { auth: { signInII: 'btn-sign-in-ii' }, + launchpad: { + launch: 'btn-launch-first-satellite', + launchExtraSatellite: 'btn-launch-extra-satellite', + actions: 'btn-open-actions' + }, createSatellite: { - launch: 'btn-launch-satellite', create: 'btn-create-satellite', input: 'input-satellite-name', website: 'input-radio-satellite-website', @@ -18,7 +22,8 @@ export const testIds = { }, navbar: { openWallet: 'btn-open-wallet', - getIcp: 'btn-get-icp' + getIcp: 'btn-get-icp', + getCycles: 'btn-get-cycles' }, createAnalytics: { navLink: 'link-analytics-dashboard', diff --git a/e2e/page-objects/console.page.ts b/e2e/page-objects/console.page.ts index c485d23..9ab2068 100644 --- a/e2e/page-objects/console.page.ts +++ b/e2e/page-objects/console.page.ts @@ -2,6 +2,7 @@ import {InternetIdentityPage} from '@dfinity/internet-identity-playwright'; import {notEmptyString} from '@dfinity/utils'; import {PrincipalText, PrincipalTextSchema} from '@dfinity/zod-schemas'; import {expect} from '@playwright/test'; +import {TIMEOUT_AVERAGE, TIMEOUT_SHORT} from '../constants/e2e.constants'; import {testIds} from '../constants/test-ids.constants'; import {IdentityPage, type IdentityPageParams} from './identity.page'; import {SatellitePage} from './satellite.page'; @@ -48,13 +49,31 @@ export class ConsolePage extends IdentityPage { await this.#consoleIIPage.waitReady({url: CONTAINER_URL, canisterId: INTERNET_IDENTITY_ID}); } - async createSatellite({kind}: {kind: 'website' | 'application'}): Promise { - await expect(this.page.getByTestId(testIds.createSatellite.launch)).toBeVisible({ - timeout: 20000 - }); + async createSatellite(params: {kind: 'website' | 'application'}): Promise { + await expect(this.page.getByTestId(testIds.launchpad.launch)).toBeVisible(TIMEOUT_AVERAGE); + + await this.page.getByTestId(testIds.launchpad.launch).click(); + + await this.createSatelliteWizard(params); + } + + async openCreateAdditionalSatelliteWizard(params: { + kind: 'website' | 'application'; + }): Promise { + await expect(this.page.getByTestId(testIds.launchpad.actions)).toBeVisible(TIMEOUT_AVERAGE); - await this.page.getByTestId(testIds.createSatellite.launch).click(); + await this.page.getByTestId(testIds.launchpad.actions).click(); + await expect(this.page.getByTestId(testIds.launchpad.launchExtraSatellite)).toBeVisible( + TIMEOUT_AVERAGE + ); + + await this.page.getByTestId(testIds.launchpad.launchExtraSatellite).click(); + + await this.createSatelliteWizard(params); + } + + private async createSatelliteWizard({kind}: {kind: 'website' | 'application'}): Promise { await expect(this.page.getByTestId(testIds.createSatellite.create)).toBeVisible({ timeout: 15000 }); @@ -64,9 +83,9 @@ export class ConsolePage extends IdentityPage { await this.page.getByTestId(testIds.createSatellite.create).click(); - await expect(this.page.getByTestId(testIds.createSatellite.continue)).toBeVisible({ - timeout: 20000 - }); + await expect(this.page.getByTestId(testIds.createSatellite.continue)).toBeVisible( + TIMEOUT_AVERAGE + ); await this.page.getByTestId(testIds.createSatellite.continue).click(); } @@ -74,9 +93,9 @@ export class ConsolePage extends IdentityPage { async visitSatelliteSite( {title}: {title: string} = {title: 'Juno / Satellite'} ): Promise { - await expect(this.page.getByTestId(testIds.satelliteOverview.visit)).toBeVisible({ - timeout: 20000 - }); + await expect(this.page.getByTestId(testIds.satelliteOverview.visit)).toBeVisible( + TIMEOUT_AVERAGE + ); const satellitePagePromise = this.context.waitForEvent('page'); @@ -93,16 +112,16 @@ export class ConsolePage extends IdentityPage { }); } - async getICP(): Promise { + async getCycles(): Promise { await expect(this.page.getByTestId(testIds.navbar.openWallet)).toBeVisible(); await this.page.getByTestId(testIds.navbar.openWallet).click(); - await expect(this.page.getByTestId(testIds.navbar.getIcp)).toBeVisible(); + await expect(this.page.getByTestId(testIds.navbar.getCycles)).toBeVisible(); - await this.page.getByTestId(testIds.navbar.getIcp).click(); + await this.page.getByTestId(testIds.navbar.getCycles).click(); - await expect(this.page.getByText('55.0001')).toBeVisible({timeout: 65000}); + await expect(this.page.getByText('330.010 T Cycles')).toBeVisible({timeout: 65000}); } async copySatelliteID(): Promise { @@ -128,7 +147,7 @@ export class ConsolePage extends IdentityPage { await this.goto({path: `/satellite/?s=${satelliteId}&tab=setup`}); const btnLocator = this.page.locator('button', {hasText: 'Add an access key'}); - await expect(btnLocator).toBeVisible({timeout: 10000}); + await expect(btnLocator).toBeVisible(TIMEOUT_SHORT); await btnLocator.click(); const form = this.page.locator('form'); @@ -145,6 +164,6 @@ export class ConsolePage extends IdentityPage { await expect(submitLocator).toBeEnabled(); await submitLocator.click(); - await expect(this.page.getByText('Access Key Added')).toBeVisible({timeout: 10000}); + await expect(this.page.getByText('Access Key Added')).toBeVisible(TIMEOUT_SHORT); } } diff --git a/e2e/page-objects/satellite.page.ts b/e2e/page-objects/satellite.page.ts index 679c19e..a2cfd08 100644 --- a/e2e/page-objects/satellite.page.ts +++ b/e2e/page-objects/satellite.page.ts @@ -1,4 +1,5 @@ import {expect} from '@playwright/test'; +import {TIMEOUT_AVERAGE} from '../constants/e2e.constants'; import {IdentityPage} from './identity.page'; export class SatellitePage extends IdentityPage { @@ -10,7 +11,7 @@ export class SatellitePage extends IdentityPage { return await this.page.title(); }, { - timeout: 30000, + ...TIMEOUT_AVERAGE, intervals: [1_000, 2_000, 10_000] } ) diff --git a/e2e/snapshots.spec.ts b/e2e/snapshots.spec.ts index 8216675..bd7aef5 100644 --- a/e2e/snapshots.spec.ts +++ b/e2e/snapshots.spec.ts @@ -64,11 +64,11 @@ const snapshotTests = ({satelliteKind}: {satelliteKind: 'website' | 'application const {consolePage, cliPage} = getTestPages(); - await consolePage.getICP(); + await consolePage.getCycles(); await consolePage.goto(); - await consolePage.createSatellite({kind: 'application'}); + await consolePage.openCreateAdditionalSatelliteWizard({kind: 'application'}); const satelliteId = await consolePage.copySatelliteID();