chore(html-reporter) ammend test for page title and favicon

This commit is contained in:
Ryan Rosello 2024-07-07 06:49:18 +10:00
parent 47465e2a6c
commit 5e985a664a
2 changed files with 13 additions and 7 deletions

View file

@ -77,6 +77,18 @@ test('should render test case', async ({ mount }) => {
await expect(component.getByText('My test')).toBeVisible();
});
test('should correctly set the page title and favicon', async ({ mount, page }) => {
await mount(<TestCaseView projectNames={['chromium', 'webkit']} test={testCase} run={0} anchor=''></TestCaseView>);
expect(await page.locator('link[rel="icon"]').getAttribute('href')).toEqual('../logo_expected.svg');
expect(await page.title()).toEqual(`| ${testCase.title}`);
});
test('should fallback to default title and favicon', async ({ mount, page }) => {
await mount(<TestCaseView projectNames={['chromium', 'webkit']} test={undefined} run={0} anchor=''></TestCaseView>);
expect(await page.locator('link[rel="icon"]').getAttribute('href')).toEqual('../logo_default.svg');
expect(await page.title()).toEqual('Playwright Test Report');
});
const linkRenderingTestCase: TestCase = {
testId: 'testid',
title: 'My test',
@ -95,12 +107,6 @@ const linkRenderingTestCase: TestCase = {
results: [result]
};
test('should correctly set the page title and favicon', async ({ mount, page }) => {
await mount(<TestCaseView projectNames={['chromium', 'webkit']} test={linkRenderingTestCase} run={0} anchor=''></TestCaseView>);
expect(await page.locator('link[rel="icon"]').getAttribute('href')).toEqual('../logo_expected.svg');
expect(await page.title()).toEqual(`| ${linkRenderingTestCase.title}`);
});
test('should correctly render links in annotations', async ({ mount, page }) => {
const component = await mount(<TestCaseView projectNames={['chromium', 'webkit']} test={linkRenderingTestCase} run={0} anchor=''></TestCaseView>);
// const container = await(component.getByText('Annotations'));

View file

@ -45,7 +45,7 @@ export const TestCaseView: React.FC<{
}, [test?.annotations]);
React.useEffect(() => {
document.title = `| ${test?.title}` ?? 'Playwright Test Report';
document.title = test?.title ? `| ${test.title}` : 'Playwright Test Report';
setSvgFavicon(test?.outcome);
}, [test?.outcome, test?.title]);