playwright: Add playwright to ESLint and fix errors
This add the `playwright` folder to the lint script and fixes errors.
This commit is contained in:
parent
88f41b0b75
commit
3a85341dbf
3 changed files with 40 additions and 38 deletions
|
|
@ -96,8 +96,8 @@
|
|||
},
|
||||
"scripts": {
|
||||
"lint": "npm-run-all lint:*",
|
||||
"lint:js": "eslint src",
|
||||
"lint:js:fix": "eslint src --fix",
|
||||
"lint:js": "eslint src playwright",
|
||||
"lint:js:fix": "eslint src playwright --fix",
|
||||
"start": "fec dev",
|
||||
"start:stage": "fec dev --clouddotEnv=stage",
|
||||
"start:prod": "fec dev --clouddotEnv=prod",
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
import { expect, type Page, type FrameLocator } from '@playwright/test';
|
||||
import { type Page, type FrameLocator } from '@playwright/test';
|
||||
|
||||
export const ibFrame = (page: Page): FrameLocator | Page => {
|
||||
if (isHosted()) {
|
||||
return page
|
||||
return page;
|
||||
}
|
||||
return page.locator('iframe[name="cockpit1\\:localhost\\/cockpit-image-builder"]').contentFrame();
|
||||
}
|
||||
return page
|
||||
.locator('iframe[name="cockpit1\\:localhost\\/cockpit-image-builder"]')
|
||||
.contentFrame();
|
||||
};
|
||||
|
||||
export const login = async (
|
||||
page: Page
|
||||
) => {
|
||||
export const login = async (page: Page) => {
|
||||
if (!process.env.USER || !process.env.PASSWORD) {
|
||||
throw new Error('user or password not set in environment');
|
||||
}
|
||||
|
|
@ -21,17 +21,13 @@ export const login = async (
|
|||
return loginConsole(page, user, password);
|
||||
}
|
||||
return loginCockpit(page, user, password);
|
||||
}
|
||||
};
|
||||
|
||||
export const isHosted = (): Boolean => {
|
||||
export const isHosted = (): boolean => {
|
||||
return process.env.BASE_URL?.includes('redhat.com') || false;
|
||||
}
|
||||
};
|
||||
|
||||
const loginCockpit = async (
|
||||
page: Page,
|
||||
user: string,
|
||||
password: string
|
||||
) => {
|
||||
const loginCockpit = async (page: Page, user: string, password: string) => {
|
||||
await page.goto('/cockpit-image-builder');
|
||||
|
||||
await page.getByRole('textbox', { name: 'User name' }).fill(user);
|
||||
|
|
@ -44,20 +40,18 @@ const loginCockpit = async (
|
|||
await page.getByRole('button', { name: 'Administrative access' });
|
||||
};
|
||||
|
||||
const loginConsole = async (
|
||||
page: Page,
|
||||
user: string,
|
||||
password: string
|
||||
) => {
|
||||
const loginConsole = async (page: Page, user: string, password: string) => {
|
||||
await page.goto('/insights/image-builder/landing');
|
||||
await page.getByRole('textbox', { name: 'Red Hat login or email' }).fill(user);
|
||||
await page
|
||||
.getByRole('textbox', { name: 'Red Hat login or email' })
|
||||
.fill(user);
|
||||
await page.getByRole('button', { name: 'Next' }).click();
|
||||
await page.getByRole('textbox', { name: 'Password' }).fill(password);
|
||||
await page.getByRole('button', { name: 'Log in' }).click();
|
||||
await closePopupsIfExist(page);
|
||||
await page.locator('#preview-toggle').check();
|
||||
await page.getByRole('heading', { name: 'All images' });
|
||||
}
|
||||
};
|
||||
|
||||
const closePopupsIfExist = async (page: Page) => {
|
||||
const locatorsToCheck = [
|
||||
|
|
|
|||
|
|
@ -1,17 +1,12 @@
|
|||
import { expect, test } from '@playwright/test';
|
||||
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
import {
|
||||
login,
|
||||
ibFrame,
|
||||
isHosted,
|
||||
} from './lib/lib';
|
||||
import { login, ibFrame, isHosted } from './lib/lib';
|
||||
|
||||
test.describe.serial('test', () => {
|
||||
let blueprintName = uuidv4();
|
||||
const blueprintName = uuidv4();
|
||||
test('create blueprint', async ({ page }) => {
|
||||
await login(page)
|
||||
await login(page);
|
||||
const frame = await ibFrame(page);
|
||||
|
||||
await frame.getByRole('heading', { name: 'Images About image builder' });
|
||||
|
|
@ -23,7 +18,9 @@ test.describe.serial('test', () => {
|
|||
await frame.getByRole('button', { name: 'Next', exact: true }).click();
|
||||
|
||||
if (isHosted()) {
|
||||
await frame.getByRole('heading', { name: 'Register systems using this image' });
|
||||
await frame.getByRole('heading', {
|
||||
name: 'Register systems using this image',
|
||||
});
|
||||
await page.getByTestId('automatically-register-checkbox').uncheck();
|
||||
await frame.getByRole('button', { name: 'Next', exact: true }).click();
|
||||
await frame.getByRole('heading', { name: 'Compliance' });
|
||||
|
|
@ -89,7 +86,9 @@ test.describe.serial('test', () => {
|
|||
|
||||
await login(page);
|
||||
const frame = await ibFrame(page);
|
||||
await frame.getByRole('textbox', { name: 'Search input' }).fill(blueprintName);
|
||||
await frame
|
||||
.getByRole('textbox', { name: 'Search input' })
|
||||
.fill(blueprintName);
|
||||
await frame.getByText(blueprintName, { exact: true }).first().click();
|
||||
|
||||
await frame.getByRole('button', { name: 'Edit blueprint' }).click();
|
||||
|
|
@ -101,7 +100,9 @@ test.describe.serial('test', () => {
|
|||
await frame.getByRole('button', { name: 'Review and finish' }).click();
|
||||
await frame.getByRole('button', { name: 'About packages' }).click();
|
||||
await frame.getByRole('gridcell', { name: 'osbuild-composer' });
|
||||
await frame.getByRole('button', { name: 'Save changes to blueprint' }).click();
|
||||
await frame
|
||||
.getByRole('button', { name: 'Save changes to blueprint' })
|
||||
.click();
|
||||
|
||||
await frame.getByRole('button', { name: 'Edit blueprint' }).click();
|
||||
await frame.getByRole('button', { name: 'About packages' }).click();
|
||||
|
|
@ -113,19 +114,26 @@ test.describe.serial('test', () => {
|
|||
test('build blueprint', async ({ page }) => {
|
||||
await login(page);
|
||||
const frame = await ibFrame(page);
|
||||
await frame.getByRole('textbox', { name: 'Search input' }).fill(blueprintName);
|
||||
await frame
|
||||
.getByRole('textbox', { name: 'Search input' })
|
||||
.fill(blueprintName);
|
||||
await frame.getByText(blueprintName, { exact: true }).first().click();
|
||||
await frame.getByTestId('blueprint-build-image-menu-option').click();
|
||||
|
||||
// make sure the image is present
|
||||
await frame.getByTestId('images-table').getByRole('button', { name: 'Details' }).click();
|
||||
await frame
|
||||
.getByTestId('images-table')
|
||||
.getByRole('button', { name: 'Details' })
|
||||
.click();
|
||||
await frame.getByText('Build Information');
|
||||
});
|
||||
|
||||
test('delete blueprint', async ({ page }) => {
|
||||
await login(page);
|
||||
const frame = await ibFrame(page);
|
||||
await frame.getByRole('textbox', { name: 'Search input' }).fill(blueprintName);
|
||||
await frame
|
||||
.getByRole('textbox', { name: 'Search input' })
|
||||
.fill(blueprintName);
|
||||
await frame.getByText(blueprintName, { exact: true }).first().click();
|
||||
await frame.getByTestId('blueprint-action-menu-toggle').click();
|
||||
await frame.getByRole('menuitem', { name: 'Delete blueprint' }).click();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue