-
Notifications
You must be signed in to change notification settings - Fork 143
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
8ff97cd
commit 513f985
Showing
5 changed files
with
133 additions
and
32 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 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 |
---|---|---|
@@ -1,50 +1,48 @@ | ||
import { test, Page, expect } from '@playwright/test'; | ||
import { UIhelper } from '../utils/UIhelper'; | ||
import { test, Page, TestInfo } from '@playwright/test'; | ||
import { Common, setupBrowser } from '../utils/Common'; | ||
import { ThemeVerifier } from '../utils/custom-theme/theme-verifier'; | ||
|
||
let page: Page; | ||
|
||
test.describe('CustomTheme should be applied', () => { | ||
let common: Common; | ||
let uiHelper: UIhelper; | ||
let themeVerifier: ThemeVerifier; | ||
|
||
test.beforeAll(async ({ browser }, testInfo) => { | ||
page = (await setupBrowser(browser, testInfo)).page; | ||
common = new Common(page); | ||
uiHelper = new UIhelper(page); | ||
themeVerifier = new ThemeVerifier(page); | ||
|
||
await common.loginAsGuest(); | ||
}); | ||
|
||
/* eslint-disable-next-line no-empty-pattern */ | ||
test('Verify that theme colors are applied and make screenshots', async ({} /* NOSONAR */, testInfo) => { | ||
await uiHelper.openSidebar('Settings'); | ||
|
||
const header = await page.locator('header').first(); | ||
await expect(header).toHaveCSS( | ||
'background-image', | ||
// 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'); | ||
await themeVerifier.verifyHeaderGradient( | ||
'none, linear-gradient(90deg, rgb(248, 248, 248), rgb(248, 248, 248))', | ||
); | ||
await themeVerifier.verifyBorderLeftColor('rgb(255, 95, 21)'); | ||
await themeVerifier.takeScreenshotAndAttach( | ||
'screenshots/custom-theme-light-inspection.png', | ||
testInfo, | ||
'custom-theme-light-inspection', | ||
); | ||
//await themeVerifier.verifyPrimaryColors('rgb(255, 95, 21)') //TODO: comment out when the primary color issue is fixed (RHIDP-3107) | ||
}); | ||
|
||
await page.screenshot({ | ||
path: 'screenshots/cusotm-theme-inspection.png', | ||
fullPage: true, | ||
}); | ||
|
||
await testInfo.attach('cusotm-theme-inspection', { | ||
path: 'screenshots/cusotm-theme-inspection.png', | ||
}); | ||
|
||
await page.locator('[name=pin]').click(); | ||
|
||
await page.screenshot({ | ||
path: 'screenshots/cusotm-theme-inspection-collapsed.png', | ||
fullPage: true, | ||
}); | ||
await testInfo.attach('cusotm-theme-inspection-collapsed', { | ||
path: 'screenshots/cusotm-theme-inspection-collapsed.png', | ||
}); | ||
|
||
await common.signOut(); | ||
// 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'); | ||
await themeVerifier.verifyHeaderGradient( | ||
'none, linear-gradient(90deg, rgb(0, 0, 208), rgb(255, 246, 140))', | ||
); | ||
await themeVerifier.verifyBorderLeftColor('rgb(244, 238, 169)'); | ||
await themeVerifier.takeScreenshotAndAttach( | ||
'screenshots/custom-theme-dark-inspection.png', | ||
testInfo, | ||
'custom-theme-dark-inspection', | ||
); | ||
// await themeVerifier.verifyPrimaryColors('#ab75cf') //TODO: comment out when the primary color issue is fixed (RHIDP-3107) | ||
}); | ||
}); |
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
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,60 @@ | ||
import { Page, expect, TestInfo } from '@playwright/test'; | ||
import { UIhelper } from '../UIhelper'; | ||
import { UIhelperPO } from '../../support/pageObjects/global-obj'; | ||
|
||
export class ThemeVerifier { | ||
private readonly page: Page; | ||
private uiHelper: UIhelper; | ||
|
||
constructor(page: Page) { | ||
this.page = page; | ||
this.uiHelper = new UIhelper(page); | ||
} | ||
|
||
async setTheme(theme: 'Light' | 'Dark') { | ||
await this.uiHelper.openSidebar('Settings'); | ||
await this.uiHelper.clickBtnByTitleIfNotPressed(`Select theme ${theme}`); | ||
} | ||
|
||
async verifyHeaderGradient(expectedGradient: string) { | ||
const header = await this.page.locator('main header'); | ||
await expect(header).toHaveCSS('background-image', expectedGradient); | ||
} | ||
|
||
async verifyBorderLeftColor(expectedColor: string) { | ||
const locator = await this.page.locator("a[aria-label='Settings']"); | ||
await expect(locator).toHaveCSS( | ||
'border-left', | ||
`3px solid ${expectedColor}`, | ||
); | ||
} | ||
|
||
async verifyPrimaryColors(colorPrimary: string) { | ||
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'); | ||
} | ||
|
||
async takeScreenshotAndAttach( | ||
screenshotPath: string, | ||
testInfo: TestInfo, | ||
description: string, | ||
) { | ||
await this.page.screenshot({ path: screenshotPath, fullPage: true }); | ||
await testInfo.attach(description, { path: screenshotPath }); | ||
} | ||
} |