Skip to content

Commit

Permalink
Create POMs for installation process
Browse files Browse the repository at this point in the history
  • Loading branch information
rakoenig committed Aug 31, 2023
1 parent a491039 commit 3dfb91b
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 50 deletions.
32 changes: 32 additions & 0 deletions actors/install-actor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { expect, type Page } from '@playwright/test';
import { MainPage } from '../pages/main-page';
import { ConfirmInstallationPage } from '../pages/confirm-installation-page';
import { InstallationProgressPage } from '../pages/installing-page';
import { CongratulationsPage } from '../pages/installation-finished-page';

export class InstallActor {
readonly page: Page;
readonly mainPage: MainPage;
readonly confirmInstallationPage: ConfirmInstallationPage;
readonly installationProgressPage: InstallationProgressPage;
readonly congratulationsPage: CongratulationsPage;

constructor(page: Page,
mainPage: MainPage,
confirmInstallationPage: ConfirmInstallationPage,
installationProgressPage: InstallationProgressPage,
congratulationsPage: CongratulationsPage) {
this.page = page;
this.mainPage = mainPage;
this.confirmInstallationPage = confirmInstallationPage;
this.installationProgressPage = installationProgressPage;
this.congratulationsPage = congratulationsPage;
}

async handleInstallation() {
await this.mainPage.install();
await this.confirmInstallationPage.confirm();
await this.installationProgressPage.expectProgress();
await this.congratulationsPage.expectCongratulations();
}
}
22 changes: 22 additions & 0 deletions pages/confirm-installation-page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { expect, type Locator, type Page } from '@playwright/test';

export class ConfirmInstallationPage {
readonly page: Page;
readonly confirmButton: Locator;
readonly cancelButton: Locator;

constructor(page: Page) {
this.page = page;
this.confirmButton = page.getByRole('button', { name: 'Continue' });
this.cancelButton = page.getByRole('button', { name: 'Cancel' });
}

async confirm() {
await this.confirmButton.click();
}

async cancel() {
await this.cancelButton.click();
}

}
25 changes: 25 additions & 0 deletions pages/installation-finished-page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { expect, type Locator, type Page } from '@playwright/test';

export class CongratulationsPage {
readonly page: Page;
readonly heading: Locator;

constructor(page: Page) {
this.page = page;
this.heading = page.getByRole("heading", { name: 'Congratulations!' });
}

async expectCongratulations() {
while (true) {
try {
await this.heading.waitFor({ timeout: 30 * 1000 });
break;
}
catch (error) {
// do not ignore other errors
if (error.constructor.name !== 'TimeoutError') throw (error);
}
}
}

}
16 changes: 16 additions & 0 deletions pages/installing-page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { expect, type Locator, type Page } from '@playwright/test';

export class InstallationProgressPage {
readonly page: Page;
readonly progressText: Locator;

constructor(page: Page) {
this.page = page;
this.progressText = page.getByText('Installing packages');
}

async expectProgress() {
await expect(this.progressText).toBeVisible({ timeout: 8 * 60 * 1000 });
}

}
33 changes: 0 additions & 33 deletions storageState.json

This file was deleted.

27 changes: 10 additions & 17 deletions tests/full-disk-encryption.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import { EncryptionPasswordPopup } from '../pages/encryption-password-popup';
import { UsersPage } from '../pages/users-page';
import { DefineUserPage } from '../pages/define-user-page';
import { ConfigureRootPasswordPage } from '../pages/configure-root-password-page';
import { ConfirmInstallationPage } from '../pages/confirm-installation-page';
import { InstallationProgressPage } from '../pages/installing-page';
import { CongratulationsPage } from '../pages/installation-finished-page';
import { InstallActor } from '../actors/install-actor';

const minute = 60 * 1000;
test.describe('The main page', () => {
Expand All @@ -18,7 +22,7 @@ test.describe('The main page', () => {
indexActor.handleProductSelectionIfAny();
});

test('Full-disk encryption', async ({ page }) => {
test('Full-disk encryption', async ({ page }) => {
const mainPage = new MainPage(page);
await test.step("Set for Full-disk encryption", async () => {
await mainPage.accessStorage();
Expand Down Expand Up @@ -54,24 +58,13 @@ test.describe('The main page', () => {

//Installation
await test.step("Run installation", async () => {
const confirmInstallationPage = new ConfirmInstallationPage(page);
const installationProgressPage = new InstallationProgressPage(page);
const congratulationsPage = new CongratulationsPage(page);
test.setTimeout(30 * minute);
// start the installation
await expect(page.getByText("Installation will take")).toBeVisible({ timeout: 2 * minute });
await mainPage.install();
await expect(page.getByText("Confirm Installation")).toBeVisible({ timeout: 2 * minute });
await page.getByRole("button", { name: "Continue" }).click();
// wait for the package installation progress
await expect(page.getByText("Installing packages")).toBeVisible({ timeout: 8 * minute });
while (true) {
try {
await page.getByRole("heading", { name: "Congratulations!" }).waitFor({ timeout: minute / 2 });
break;
}
catch (error) {
// do not ignore other errors
if (error.constructor.name !== "TimeoutError") throw (error);
}
}
const installActor = new InstallActor(page, mainPage, confirmInstallationPage, installationProgressPage, congratulationsPage);
await installActor.handleInstallation();
})
})
})

0 comments on commit 3dfb91b

Please sign in to comment.