-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RHIDP-744 [Test Automation] Automate RHDH theme customization - E2E
Refactor custom theme E2E test and update uihelper functions Signed-off-by: Gustavo Lira <guga.java@gmail.com>
- Loading branch information
1 parent
e38c2e7
commit 76e5a2a
Showing
6 changed files
with
181 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
e2e-tests/playwright/e2e/plugins/custom-theme/custom-theme.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { test, Page, TestInfo } from '@playwright/test'; | ||
import { Common, setupBrowser } from '../../../utils/Common'; | ||
import { ThemeVerifier } from './theme-verifier'; | ||
|
||
let page: Page; | ||
|
||
test.describe('CustomTheme should be applied', () => { | ||
let common: Common; | ||
let themeVerifier: ThemeVerifier; | ||
|
||
test.beforeAll(async ({ browser }, testInfo) => { | ||
page = (await setupBrowser(browser, testInfo)).page; | ||
common = new Common(page); | ||
themeVerifier = new ThemeVerifier(page); | ||
|
||
await common.loginAsGuest(); | ||
}); | ||
|
||
// eslint-disable-next-line no-empty-pattern | ||
test('Verify that theme light colors are applied and make screenshots', async ({}, testInfo: TestInfo) => { | ||
await themeVerifier | ||
.setTheme('Light') | ||
.verifyHeaderGradient( | ||
'none, linear-gradient(90deg, rgb(248, 248, 248), rgb(248, 248, 248))', | ||
) | ||
.verifyBorderLeftColor('rgb(255, 95, 21)') | ||
.takeScreenshotAndAttach( | ||
'screenshots/custom-theme-light-inspection.png', | ||
testInfo, | ||
'custom-theme-light-inspection', | ||
) | ||
// .verifyPrimaryColors('rgb(255, 95, 21)') //TODO: comment out when the primary color issue is fixed (RHIDP-3107) | ||
.execute(); | ||
}); | ||
|
||
// eslint-disable-next-line no-empty-pattern | ||
test('Verify that theme dark colors are applied and make screenshots', async ({}, testInfo: TestInfo) => { | ||
await themeVerifier | ||
.setTheme('Dark') | ||
.verifyHeaderGradient( | ||
'none, linear-gradient(90deg, rgb(0, 0, 208), rgb(255, 246, 140))', | ||
) | ||
.verifyBorderLeftColor('rgb(244, 238, 169)') | ||
.takeScreenshotAndAttach( | ||
'screenshots/custom-theme-dark-inspection.png', | ||
testInfo, | ||
'custom-theme-dark-inspection', | ||
) | ||
// .verifyPrimaryColors('#ab75cf') //TODO: comment out when the primary color issue is fixed (RHIDP-3107) | ||
.execute(); | ||
}); | ||
}); |
83 changes: 83 additions & 0 deletions
83
e2e-tests/playwright/e2e/plugins/custom-theme/theme-verifier.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { Page, expect, TestInfo } from '@playwright/test'; | ||
import { UIhelper } from '../../../utils/UIhelper'; | ||
import { UIhelperPO } from '../../../support/pageObjects/global-obj'; | ||
|
||
export class ThemeVerifier { | ||
private readonly page: Page; | ||
private uiHelper: UIhelper; | ||
private readonly tasks: Array<() => Promise<void>>; | ||
|
||
constructor(page: Page) { | ||
this.page = page; | ||
this.uiHelper = new UIhelper(page); | ||
this.tasks = []; | ||
} | ||
|
||
setTheme(theme: 'Light' | 'Dark'): this { | ||
this.tasks.push(async () => { | ||
await this.uiHelper.openSidebar('Settings'); | ||
await this.uiHelper.clickBtnByTitleIfNotPressed(`Select theme ${theme}`); | ||
}); | ||
return this; | ||
} | ||
|
||
verifyHeaderGradient(expectedGradient: string): this { | ||
this.tasks.push(async () => { | ||
const header = await this.page.locator('main header'); | ||
await expect(header).toHaveCSS('background-image', expectedGradient); | ||
}); | ||
return this; | ||
} | ||
|
||
verifyBorderLeftColor(expectedColor: string): this { | ||
this.tasks.push(async () => { | ||
const locator = await this.page.locator("a[aria-label='Settings']"); | ||
await expect(locator).toHaveCSS( | ||
'border-left', | ||
`3px solid ${expectedColor}`, | ||
); | ||
}); | ||
return this; | ||
} | ||
|
||
verifyPrimaryColors(colorPrimary: string): this { | ||
this.tasks.push(async () => { | ||
await this.uiHelper.checkCssColor( | ||
this.page, | ||
UIhelperPO.MuiTypographyColorPrimary, | ||
colorPrimary, | ||
); | ||
await this.uiHelper.checkCssColor( | ||
this.page, | ||
UIhelperPO.MuiSwitchColorPrimary, | ||
colorPrimary, | ||
); | ||
await this.uiHelper.openSidebar('Catalog'); | ||
await this.uiHelper.checkCssColor( | ||
this.page, | ||
UIhelperPO.MuiButtonTextPrimary, | ||
colorPrimary, | ||
); | ||
await this.uiHelper.openSidebar('Settings'); | ||
}); | ||
return this; | ||
} | ||
|
||
takeScreenshotAndAttach( | ||
screenshotPath: string, | ||
testInfo: TestInfo, | ||
description: string, | ||
): this { | ||
this.tasks.push(async () => { | ||
await this.page.screenshot({ path: screenshotPath, fullPage: true }); | ||
await testInfo.attach(description, { path: screenshotPath }); | ||
}); | ||
return this; | ||
} | ||
|
||
async execute(): Promise<void> { | ||
for (const task of this.tasks) { | ||
await task(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters