chore(html-reporter) update type used by the setFavicon function
This commit is contained in:
parent
d167c5b928
commit
28b7ed10e1
|
|
@ -14,7 +14,7 @@
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { TestCase, TestCaseAnnotation } from './types';
|
import type { TestCase, TestCaseAnnotation, TestCaseSummary } from './types';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { TabbedPane } from './tabbedPane';
|
import { TabbedPane } from './tabbedPane';
|
||||||
import { AutoChip } from './chip';
|
import { AutoChip } from './chip';
|
||||||
|
|
@ -46,7 +46,7 @@ export const TestCaseView: React.FC<{
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
document.title = test?.title ? `| ${test.title}` : 'Playwright Test Report';
|
document.title = test?.title ? `| ${test.title}` : 'Playwright Test Report';
|
||||||
setSvgFavicon(test?.outcome);
|
test?.outcome ? setFavicon({ outcome: test.outcome }) : setFavicon('default');
|
||||||
}, [test?.outcome, test?.title]);
|
}, [test?.outcome, test?.title]);
|
||||||
|
|
||||||
return <div className='test-case-column vbox'>
|
return <div className='test-case-column vbox'>
|
||||||
|
|
@ -136,17 +136,13 @@ const LabelsLinkView: React.FC<React.PropsWithChildren<{
|
||||||
) : null;
|
) : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
function setSvgFavicon(outcome: 'skipped' | 'expected' | 'unexpected' | 'flaky'| undefined) {
|
function setFavicon(outcome: Pick<TestCaseSummary, 'outcome'> | 'default') {
|
||||||
// Find or create a link element for the favicon
|
|
||||||
let link: HTMLLinkElement | null = document.querySelector("link[rel*='icon']");
|
let link: HTMLLinkElement | null = document.querySelector("link[rel*='icon']");
|
||||||
if (!link) {
|
if (!link) {
|
||||||
link = document.createElement('link');
|
link = document.createElement('link');
|
||||||
link.rel = 'icon';
|
link.rel = 'icon';
|
||||||
document.getElementsByTagName('head')[0].appendChild(link);
|
document.getElementsByTagName('head')[0].appendChild(link);
|
||||||
}
|
}
|
||||||
|
const outcomeValue = outcome instanceof Object ? outcome.outcome : outcome;
|
||||||
if (!outcome)
|
link.href = `../logo_${outcomeValue}.svg`;
|
||||||
link.href = '../logo_default.svg';
|
|
||||||
else
|
|
||||||
link.href = `../logo_${outcome}.svg`;
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue