For AC1 the proposal is to add the test case inside the bundle like this one:
it("Storage: enable and evaluate encryption", async function () {
// Open storage page
const selectorLinkStorage: string = "a[href='#/storage']";
await page.waitForSelector(selectorLinkStorage);
await page.locator(selectorLinkStorage).click();
// Open encryption page
const storage = new StoragePage(page);
await storage.openEncryption();
const storageEncryption = new StorageEncryptionPage(page);
await storageEncryption.encryptWith(agamaPassword);
// Evaluate encryption
await storage.assertEncryption();
});
and define the following POM:
storage-page.ts
import { type Locator, type Page } from "puppeteer-core";
import assert from "node:assert/strict";
export class StoragePage {
readonly page: Page;
readonly encryptionEnableButton: string = "button::-p-text(Enable)";
readonly enabledDiv: string = "div[aria-label='Encryption'] > div > div > div > div > div div::-p-text(enabled)";
constructor(page: Page) {
this.page = page;
}
async openEncryption() {
await this.page.locator(this.encryptionEnableButton).click();
}
async assertEncryption() {
const selectorTextEnabled = await this.page.waitForSelector(this.enabledDiv);
const textEnabled = await selectorTextEnabled?.evaluate(el => el.textContent);
assert.equal(textEnabled, "enabled");
}
}
and storage-encryption-page.ts
:
import { type Locator, type Page } from "puppeteer-core";
export class StorageEncryptionPage {
readonly page: Page;
readonly checkboxEncrypt: string = "label[class='pf-v5-c-switch'] > input[type='checkbox']";
readonly passworInput: string = "#password";
readonly passwordConfirmationInput: string = "#passwordConfirmation";
readonly acceptEncryptionButton: string = "button[form='encryptionSettingsForm']";
constructor(page: Page) {
this.page = page;
}
async encryptWith(password: string) {
await this.page.locator(this.checkboxEncrypt).click();
await this.page.locator(this.passworInput).fill(password);
await this.page.locator(this.passwordConfirmationInput).fill(password);
await this.page.locator(this.acceptEncryptionButton).click();
}
}
For AC2 a temporary workaround to call agama profile import
is to run the command inside NodeJs:
const urlProfile = 'https://raw.githubusercontent.com/os-autoinst/os-autoinst-distri-opensuse/master/data/yam/agama/auto/default_tumbleweed.json';
function importAgamaProfile(urlProfile: string) {
const result = execFileSync(`/usr/bin/agama`, [`profile`, `import`, `${urlProfile}`]);
console.log(result);
}
// Import profile
importAgamaProfile(urlProfile);
But the final solution will be to have a openQA Perl module that ran before the Puppeteer test