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