Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add POM of product selection #15

Merged
merged 1 commit into from Aug 24, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 38 additions & 0 deletions actors/index-actor.ts
@@ -0,0 +1,38 @@
import { ProductSelectionPage } from '../pages/product-selection-opensuse-page';
import { MainPage } from '../pages/main-page';

export class IndexActor {
jknphy marked this conversation as resolved.
Show resolved Hide resolved
readonly page: Page;
readonly mainPage: MainPage;
readonly productSelectionPage: ProductSelectionPage;

constructor(page: Page, mainPage: MainPage, productSelectionPage: ProductSelectionPage) {
this.page = page;
this.mainPage = mainPage;
this.productSelectionPage = productSelectionPage;
}

async goto() {
await this.page.goto('/cockpit/@localhost/agama/index.html');
}

async handleProductSelectionIfAny() {
// possible first pages the user can find
const actions = Object.freeze({
setProduct: Symbol("product"),
setInstall: Symbol("install"),
});

// check for multiple texts in parallel, avoid waiting for timeouts
let action = await Promise.any([
this.productSelectionPage.productSelectionText.waitFor().then(() => actions.setProduct),
this.mainPage.installButton.waitFor().then(() => actions.setInstall),
]);

// optional product selection
if (action === actions.setProduct) {
await this.productSelectionPage.chooseOpensuseTumbleweed();
await this.productSelectionPage.select();
}
}
}
29 changes: 29 additions & 0 deletions pages/product-selection-opensuse-page.ts
@@ -0,0 +1,29 @@
import { test, expect } from '@playwright/test';

export class ProductSelectionOpensusePage {
readonly page: Page;
readonly productSelectionText: Locator;
readonly opensuseTumbleweedLabel: Locator;
readonly opensuseLeapLabel: Locator;
readonly selectButton: Locator;

constructor(page: Page) {
this.page = page;
this.productSelectionText = page.getByText('Product selection');
this.opensuseTumbleweedLabel = page.getByLabel('openSUSE Tumbleweed');
this.opensuseLeapLabel = page.getByLabel('openSUSE Leap 16.0');
this.selectButton = page.getByRole('button', { name: 'Select' });
}

async chooseOpensuseTumbleweed() {
await this.opensuseTumbleweedLabel.check();
}

async chooseOpensuseLeap() {
await this.opensuseLeapLabel.check();
}

async select() {
await this.selectButton.click();
}
}
65 changes: 36 additions & 29 deletions tests/encrypted_lvm.spec.ts
@@ -1,50 +1,57 @@
import { test, expect } from '@playwright/test';
import { IndexActor } from "../actors/index-actor";
import { StoragePage } from '../pages/storage-page';
import { MainPage } from '../pages/main-page';
import { ProductSelectionOpensusePage } from '../pages/product-selection-opensuse-page';
import { EncryptionPasswordPopup } from '../pages/encryption-password-popup';
import { mainPagePath } from "../lib/installer";
import { UsersPage } from '../pages/users-page';
import { DefineUserPage } from '../pages/define-user-page';
import { ConfigureRootPasswordPage } from '../pages/configure-root-password-page';

const minute = 60 * 1000;
test.describe('The main page', () => {
test.beforeEach(async ({ page }) => {
await page.goto(mainPagePath());
const productSelectionOpensusePage = new ProductSelectionOpensusePage(page);
const mainPage = new MainPage(page);
const indexActor = new IndexActor(page, mainPage, productSelectionOpensusePage);
indexActor.goto();
indexActor.handleProductSelectionIfAny();
});

test('Installation test with encrypted lvm file system', async ({ page }) => {
test('Installation test with encrypted lvm file system', async ({ page }) => {
const mainPage = new MainPage(page);
await mainPage.accessStorage();
await test.step("set encrypted lvm file system", async () => {
await mainPage.accessStorage();

const storagePage = new StoragePage(page);
await storagePage.useEncryption();
const storagePage = new StoragePage(page);
jknphy marked this conversation as resolved.
Show resolved Hide resolved
await storagePage.useEncryption();

const passwordPopup = new EncryptionPasswordPopup(page);
await passwordPopup.fillPassword('nots3cr3t');
await passwordPopup.fillPasswordConfirmation('nots3cr3t');
await passwordPopup.accept();
const passwordPopup = new EncryptionPasswordPopup(page);
await passwordPopup.fillPassword('nots3cr3t');
await passwordPopup.fillPasswordConfirmation('nots3cr3t');
await passwordPopup.accept();

await storagePage.validateEncryptionIsUsed();
await storagePage.useLVM();
await storagePage.back();
await storagePage.validateEncryptionIsUsed();
await storagePage.useLVM();
await storagePage.back();

await mainPage.accessUsers();
await mainPage.accessUsers();

const usersPage = new UsersPage(page);
await usersPage.expectNoUserDefined();
await usersPage.defineUser();
const defineUserPage = new DefineUserPage(page);
await defineUserPage.fillUserFullName('Bernhard M. Wiedemann');
await defineUserPage.fillUserName('bernhard');
await defineUserPage.fillAndConfirmPassword('nots3cr3t');
await defineUserPage.confirm();
await usersPage.expectRootPasswordNotSet();
await usersPage.configureRootPassword();
const configureRootPasswordPage = new ConfigureRootPasswordPage(page);
await configureRootPasswordPage.fillAndConfirmPassword('nots3cr3t');
await configureRootPasswordPage.confirm();
await usersPage.back();
const usersPage = new UsersPage(page);
await usersPage.expectNoUserDefined();
await usersPage.defineUser();
const defineUserPage = new DefineUserPage(page);
await defineUserPage.fillUserFullName('Bernhard M. Wiedemann');
await defineUserPage.fillUserName('bernhard');
await defineUserPage.fillAndConfirmPassword('nots3cr3t');
await defineUserPage.confirm();
await usersPage.expectRootPasswordNotSet();
await usersPage.configureRootPassword();
const configureRootPasswordPage = new ConfigureRootPasswordPage(page);
await configureRootPasswordPage.fillAndConfirmPassword('nots3cr3t');
await configureRootPasswordPage.confirm();
await usersPage.back();
});

//Installation
await test.step("Run installation", async () => {
Expand All @@ -66,6 +73,6 @@ test.describe('The main page', () => {
if (error.constructor.name !== "TimeoutError") throw (error);
}
}
});
});
});
});
62 changes: 34 additions & 28 deletions tests/full-disk-encryption.spec.ts
@@ -1,50 +1,56 @@
import { test, expect } from '@playwright/test';
import { IndexActor } from "../actors/index-actor";
import { StoragePage } from '../pages/storage-page';
import { MainPage } from '../pages/main-page';
import { ProductSelectionOpensusePage } from '../pages/product-selection-opensuse-page';
import { EncryptionPasswordPopup } from '../pages/encryption-password-popup';
import { mainPagePath } from "../lib/installer";
import { UsersPage } from '../pages/users-page';
import { DefineUserPage } from '../pages/define-user-page';
import { ConfigureRootPasswordPage } from '../pages/configure-root-password-page';

const minute = 60 * 1000;
test.describe('The main page', () => {
test.beforeEach(async ({ page }) => {
await page.goto(mainPagePath());
const productSelectionOpensusePage = new ProductSelectionOpensusePage(page);
const mainPage = new MainPage(page);
const indexActor = new IndexActor(page, mainPage, productSelectionOpensusePage);
indexActor.goto();
indexActor.handleProductSelectionIfAny();
});

test('Full-disk encryption', async ({ page }) => {
test('Full-disk encryption', async ({ page }) => {
const mainPage = new MainPage(page);
await mainPage.accessStorage();
await test.step("Set for Full-disk encryption", async () => {
await mainPage.accessStorage();

const storagePage = new StoragePage(page);
await storagePage.useEncryption();
const storagePage = new StoragePage(page);
await storagePage.useEncryption();

const passwordPopup = new EncryptionPasswordPopup(page);
await passwordPopup.fillPassword('nots3cr3t');
await passwordPopup.fillPasswordConfirmation('nots3cr3t');
await passwordPopup.accept();
const passwordPopup = new EncryptionPasswordPopup(page);
await passwordPopup.fillPassword('nots3cr3t');
await passwordPopup.fillPasswordConfirmation('nots3cr3t');
await passwordPopup.accept();

await storagePage.validateEncryptionIsUsed();
await storagePage.back();
await storagePage.validateEncryptionIsUsed();
await storagePage.back();

await expect(page.getByText(process.env.PRODUCTNAME)).toBeVisible({ timeout: 2 * minute });
await mainPage.accessUsers();
await mainPage.accessUsers();

const usersPage = new UsersPage(page);
await usersPage.expectNoUserDefined();
await usersPage.defineUser();
const defineUserPage = new DefineUserPage(page);
await defineUserPage.fillUserFullName('Bernhard M. Wiedemann');
await defineUserPage.fillUserName('bernhard');
await defineUserPage.fillAndConfirmPassword('nots3cr3t');
await defineUserPage.confirm();
await usersPage.expectRootPasswordNotSet();
await usersPage.configureRootPassword();
const configureRootPasswordPage = new ConfigureRootPasswordPage(page);
await configureRootPasswordPage.fillAndConfirmPassword('nots3cr3t');
await configureRootPasswordPage.confirm();
await usersPage.back();
const usersPage = new UsersPage(page);
await usersPage.expectNoUserDefined();
await usersPage.defineUser();
const defineUserPage = new DefineUserPage(page);
await defineUserPage.fillUserFullName('Bernhard M. Wiedemann');
await defineUserPage.fillUserName('bernhard');
await defineUserPage.fillAndConfirmPassword('nots3cr3t');
await defineUserPage.confirm();
await usersPage.expectRootPasswordNotSet();
await usersPage.configureRootPassword();
const configureRootPasswordPage = new ConfigureRootPasswordPage(page);
await configureRootPasswordPage.fillAndConfirmPassword('nots3cr3t');
await configureRootPasswordPage.confirm();
await usersPage.back();
});

//Installation
await test.step("Run installation", async () => {
Expand Down
61 changes: 36 additions & 25 deletions tests/lvm.spec.ts
@@ -1,40 +1,50 @@
import { test, expect } from '@playwright/test';
import { mainPagePath } from "../lib/installer";
import { IndexActor } from "../actors/index-actor";
import { ProductSelectionOpensusePage } from '../pages/product-selection-opensuse-page';
import { MainPage } from '../pages/main-page';
import { StoragePage } from '../pages/storage-page';
import { UsersPage } from '../pages/users-page';
import { DefineUserPage } from '../pages/define-user-page';
import { ConfigureRootPasswordPage } from '../pages/configure-root-password-page';

const minute = 60 * 1000;
test('Use logical volume management (LVM) as storage device for installation', async ({ page }) => {
await page.goto(mainPagePath());
const mainPage = new MainPage(page);
await mainPage.accessStorage();
test.describe('The main page', () => {
test.beforeEach(async ({ page }) => {
const productSelectionPage = new ProductSelectionOpensusePage(page);
const mainPage = new MainPage(page);
const indexActor = new IndexActor(page, mainPage, productSelectionPage);
indexActor.goto();
indexActor.handleProductSelectionIfAny();
});

test("Use logical volume management (LVM) as storage device for installation", async ({ page }) => {
const mainPage = new MainPage(page);
await test.step("Set LVM and Users", async () => {
await mainPage.accessStorage();

const storagePage = new StoragePage(page);
await storagePage.useLVM();
await storagePage.back();
const storagePage = new StoragePage(page);
await storagePage.useLVM();
await storagePage.back();

await expect(page.getByText(process.env.PRODUCTNAME)).toBeVisible({ timeout: 2 * minute });
await mainPage.accessUsers();
await mainPage.accessUsers();

const usersPage = new UsersPage(page);
await usersPage.expectNoUserDefined();
await usersPage.defineUser();
const defineUserPage = new DefineUserPage(page);
await defineUserPage.fillUserFullName('Bernhard M. Wiedemann');
await defineUserPage.fillUserName('bernhard');
await defineUserPage.fillAndConfirmPassword('nots3cr3t');
await defineUserPage.confirm();
await usersPage.expectRootPasswordNotSet();
await usersPage.configureRootPassword();
const configureRootPasswordPage = new ConfigureRootPasswordPage(page);
await configureRootPasswordPage.fillAndConfirmPassword('nots3cr3t');
await configureRootPasswordPage.confirm();
await usersPage.back();
const usersPage = new UsersPage(page);
await usersPage.expectNoUserDefined();
await usersPage.defineUser();
const defineUserPage = new DefineUserPage(page);
await defineUserPage.fillUserFullName('Bernhard M. Wiedemann');
await defineUserPage.fillUserName('bernhard');
await defineUserPage.fillAndConfirmPassword('nots3cr3t');
await defineUserPage.confirm();
await usersPage.expectRootPasswordNotSet();
await usersPage.configureRootPassword();
const configureRootPasswordPage = new ConfigureRootPasswordPage(page);
await configureRootPasswordPage.fillAndConfirmPassword('nots3cr3t');
await configureRootPasswordPage.confirm();
await usersPage.back();
});

await test.step("Run installation", async () => {
await test.step("Run installation", async () => {
test.setTimeout(30 * minute);
// start the installation
await expect(page.getByText("Installation will take")).toBeVisible({ timeout: 2 * minute });
Expand All @@ -53,5 +63,6 @@ test('Use logical volume management (LVM) as storage device for installation', a
if (error.constructor.name !== "TimeoutError") throw (error);
}
}
});
});
});