diff --git a/actors/index-actor.ts b/actors/index-actor.ts new file mode 100644 index 0000000..b8a78e1 --- /dev/null +++ b/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 { + 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(); + } + } +} diff --git a/pages/product-selection-opensuse-page.ts b/pages/product-selection-opensuse-page.ts new file mode 100644 index 0000000..7cfa75a --- /dev/null +++ b/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(); + } +} diff --git a/tests/encrypted_lvm.spec.ts b/tests/encrypted_lvm.spec.ts index a69ce60..91d2e4d 100644 --- a/tests/encrypted_lvm.spec.ts +++ b/tests/encrypted_lvm.spec.ts @@ -1,8 +1,9 @@ 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'; @@ -10,41 +11,47 @@ 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); + 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 () => { @@ -66,6 +73,6 @@ test.describe('The main page', () => { if (error.constructor.name !== "TimeoutError") throw (error); } } - }); + }); }); }); diff --git a/tests/full-disk-encryption.spec.ts b/tests/full-disk-encryption.spec.ts index 7b224bd..e8b8dfb 100644 --- a/tests/full-disk-encryption.spec.ts +++ b/tests/full-disk-encryption.spec.ts @@ -1,8 +1,9 @@ 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'; @@ -10,41 +11,46 @@ 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 () => { diff --git a/tests/lvm.spec.ts b/tests/lvm.spec.ts index d7ccda7..7577a06 100644 --- a/tests/lvm.spec.ts +++ b/tests/lvm.spec.ts @@ -1,5 +1,6 @@ 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'; @@ -7,34 +8,43 @@ 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 }); @@ -53,5 +63,6 @@ test('Use logical volume management (LVM) as storage device for installation', a if (error.constructor.name !== "TimeoutError") throw (error); } } + }); }); });