chore: less 'as any' in html-reporter (#32117)
Signed-off-by: Max Schmitt <max@schmitt.mx> Co-authored-by: Simon Knott <info@simonknott.de>
This commit is contained in:
parent
effb1ae234
commit
0d575b4ef6
|
|
@ -30,10 +30,10 @@ export function bundle(): Plugin {
|
|||
if (!ctx || !ctx.bundle)
|
||||
return html;
|
||||
html = html.replace(/(?=<!--)([\s\S]*?)-->/, '');
|
||||
for (const [name, value] of Object.entries(ctx.bundle) as any) {
|
||||
for (const [name, value] of Object.entries(ctx.bundle)) {
|
||||
if (name.endsWith('.map'))
|
||||
continue;
|
||||
if (value.code)
|
||||
if ('code' in value)
|
||||
html = html.replace(/<script type="module".*<\/script>/, () => `<script type="module">${value.code}</script>`);
|
||||
else
|
||||
html = html.replace(/<link rel="stylesheet"[^>]*>/, () => `<style type='text/css'>${value.source}</style>`);
|
||||
|
|
|
|||
|
|
@ -156,8 +156,8 @@ type SearchValues = {
|
|||
|
||||
const searchValuesSymbol = Symbol('searchValues');
|
||||
|
||||
function cacheSearchValues(test: TestCaseSummary): SearchValues {
|
||||
const cached = (test as any)[searchValuesSymbol] as SearchValues | undefined;
|
||||
function cacheSearchValues(test: TestCaseSummary & { [searchValuesSymbol]?: SearchValues }): SearchValues {
|
||||
const cached = test[searchValuesSymbol];
|
||||
if (cached)
|
||||
return cached;
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ function cacheSearchValues(test: TestCaseSummary): SearchValues {
|
|||
labels: test.tags.map(tag => tag.toLowerCase()),
|
||||
annotations: test.annotations.map(a => a.type.toLowerCase() + '=' + a.description?.toLocaleLowerCase())
|
||||
};
|
||||
(test as any)[searchValuesSymbol] = searchValues;
|
||||
test[searchValuesSymbol] = searchValues;
|
||||
return searchValues;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class ZipReport implements LoadedReport {
|
|||
private _json!: HTMLReport;
|
||||
|
||||
async load() {
|
||||
const zipReader = new zipjs.ZipReader(new zipjs.Data64URIReader((window as any).playwrightReportBase64), { useWebWorkers: false });
|
||||
const zipReader = new zipjs.ZipReader(new zipjs.Data64URIReader(window.playwrightReportBase64!), { useWebWorkers: false });
|
||||
for (const entry of await zipReader.getEntries())
|
||||
this._entries.set(entry.filename, entry);
|
||||
this._json = await this.entry('report.json') as HTMLReport;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ declare global {
|
|||
playwrightSetSelector: (selector: string, focus?: boolean) => void;
|
||||
playwrightUpdateLogs: (callLogs: CallLog[]) => void;
|
||||
dispatch(data: EventData): Promise<void>;
|
||||
saveSettings(data: any): Promise<void>;
|
||||
saveSettings?(): Promise<void>;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,10 +17,16 @@
|
|||
import React from 'react';
|
||||
import { type Setting, settings } from './uiUtils';
|
||||
|
||||
declare global {
|
||||
interface Document {
|
||||
playwrightThemeInitialized?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
export function applyTheme() {
|
||||
if ((document as any).playwrightThemeInitialized)
|
||||
if (document.playwrightThemeInitialized)
|
||||
return;
|
||||
(document as any).playwrightThemeInitialized = true;
|
||||
document.playwrightThemeInitialized = true;
|
||||
document!.defaultView!.addEventListener('focus', (event: any) => {
|
||||
if (event.target.document.nodeType === Node.DOCUMENT_NODE)
|
||||
document.body.classList.remove('inactive');
|
||||
|
|
|
|||
|
|
@ -165,6 +165,12 @@ export function useSetting<S>(name: string | undefined, defaultValue: S, title?:
|
|||
return [value, setValueWrapper, setting];
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
saveSettings?(): Promise<void>;
|
||||
}
|
||||
}
|
||||
|
||||
export class Settings {
|
||||
onChangeEmitter = new EventTarget();
|
||||
|
||||
|
|
@ -175,8 +181,7 @@ export class Settings {
|
|||
setString(name: string, value: string) {
|
||||
localStorage[name] = value;
|
||||
this.onChangeEmitter.dispatchEvent(new Event(name));
|
||||
if ((window as any).saveSettings)
|
||||
(window as any).saveSettings();
|
||||
window.saveSettings?.();
|
||||
}
|
||||
|
||||
getObject<T>(name: string, defaultValue: T): T {
|
||||
|
|
@ -192,9 +197,7 @@ export class Settings {
|
|||
setObject<T>(name: string, value: T) {
|
||||
localStorage[name] = JSON.stringify(value);
|
||||
this.onChangeEmitter.dispatchEvent(new Event(name));
|
||||
|
||||
if ((window as any).saveSettings)
|
||||
(window as any).saveSettings();
|
||||
window.saveSettings?.();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue