Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"devDependencies": {
"@playwright/browser-chromium": "1.52.0",
"@types/node": "22.15.19",
"@types/node": "22.15.21",
"@typescript-eslint/eslint-plugin": "7.18.0",
"@typescript-eslint/parser": "7.18.0",
"assert-modules-support-case-insensitive-fs": "1.0.1",
Expand Down
4 changes: 2 additions & 2 deletions src/utils/events/registerEndTestRunEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {calculateTestRunStatus} from './calculateTestRunStatus';
import {getTestRunEvent} from './getTestRunEvent';
import {writeFullMocksIfNeeded} from './writeFullMocksIfNeeded';

import type {EndTestRunEvent, FullTestRun, TestRun} from '../../types/internal';
import type {EndTestRunEvent, FullTestRun, RunHash, TestRun} from '../../types/internal';

/**
* Registers end test run event (for report) after test closing.
Expand Down Expand Up @@ -74,7 +74,7 @@ export const registerEndTestRunEvent = async (endTestRunEvent: EndTestRunEvent):
const {getMainTestRunParams, getTestRunHash} = getUserlandHooks();

const mainParams = getMainTestRunParams(testRun);
const runHash = getTestRunHash(testRun);
const runHash = getTestRunHash(testRun).replaceAll('#', '') as RunHash;

const fullTestRun: FullTestRun = {mainParams, runHash, ...testRun};

Expand Down
6 changes: 5 additions & 1 deletion src/utils/expect/createExpectMethod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ export const createExpectMethod = (
}

return runAssertion(this.actualValue);
});
}).catch((error: Error) => ({
actualValue: this.actualValue,
description: this.description,
error,
}));

return assertionPromise.then(({actualValue, additionalLogFields, error}) => {
const logMessage = `Assert: ${this.description}`;
Expand Down
49 changes: 12 additions & 37 deletions src/utils/report/client/chooseTestRun.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import {assertValueIsDefined as clientAssertValueIsDefined} from './assertValueIsDefined';
import {
renderApiStatistics as clientRenderApiStatistics,
renderTestRunDetails as clientRenderTestRunDetails,
} from './render';

import type {
ApiStatisticsReportHash,
ReportClientState,
RunHash,
SafeHtml,
} from '../../../types/internal';
import {maybeRenderApiStatistics as clientMaybeRenderApiStatistics} from './maybeRenderApiStatistics';
import {renderTestRunDetails as clientRenderTestRunDetails} from './render';

import type {ReportClientState, RunHash, SafeHtml} from '../../../types/internal';

const assertValueIsDefined: typeof clientAssertValueIsDefined = clientAssertValueIsDefined;
const renderApiStatistics = clientRenderApiStatistics;
const maybeRenderApiStatistics = clientMaybeRenderApiStatistics;
const renderTestRunDetails = clientRenderTestRunDetails;

declare const reportClientState: ReportClientState;
Expand All @@ -35,7 +28,7 @@ export function chooseTestRun(runHash: RunHash): void {
return;
}

const previousHash = window.location.hash as RunHash;
const previousHash = window.location.hash.replaceAll('#', '') as RunHash;

window.location.hash = runHash;

Expand All @@ -47,7 +40,10 @@ export function chooseTestRun(runHash: RunHash): void {

const previousTestRunDetailsElement = e2edRightColumnContainer.firstElementChild as HTMLElement;

if (!(previousHash in testRunDetailsElementsByHash)) {
if (
!(previousHash in testRunDetailsElementsByHash) &&
!previousTestRunDetailsElement.classList.contains('test-details-empty')
) {
testRunDetailsElementsByHash[previousHash] = previousTestRunDetailsElement;
}

Expand All @@ -61,30 +57,9 @@ export function chooseTestRun(runHash: RunHash): void {
return;
}

const pagesHash: ApiStatisticsReportHash = 'api-statistics-pages';
const requestsHash: ApiStatisticsReportHash = 'api-statistics-requests';
const resourcesHash: ApiStatisticsReportHash = 'api-statistics-resources';

let rightColumnHtml: SafeHtml | undefined;

const hash = String(runHash);

if (hash === pagesHash || hash === requestsHash || hash === resourcesHash) {
const {reportClientData} = reportClientState;

if (reportClientData === undefined) {
// eslint-disable-next-line no-console
console.error(
`Cannot find report client data in JSON report data (tried to click "${runHash}"). Probably JSON report data not yet completely loaded. Please try click again later`,
);

return;
}

const {apiStatistics} = reportClientData;
let rightColumnHtml: SafeHtml | undefined = maybeRenderApiStatistics(runHash);

rightColumnHtml = renderApiStatistics({apiStatistics, hash});
} else {
if (rightColumnHtml === undefined) {
const {fullTestRuns} = reportClientState;
const fullTestRun = fullTestRuns.find((testRun) => testRun.runHash === runHash);

Expand Down
6 changes: 4 additions & 2 deletions src/utils/report/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ export {clickOnTestRun} from './clickOnTestRun';
/** @internal */
export {createJsxRuntime} from './createJsxRuntime';
/** @internal */
export {initialScript} from './initialScript';
/** @internal */
export {maybeRenderApiStatistics} from './maybeRenderApiStatistics';
/** @internal */
export {onDomContentLoad} from './onDomContentLoad';
/** @internal */
export {onFirstJsonReportDataLoad} from './onFirstJsonReportDataLoad';
/** @internal */
export {initialScript} from './initialScript';
/** @internal */
export {parseMarkdownLinks} from './parseMarkdownLinks';
/** @internal */
export {readJsonReportData} from './readJsonReportData';
Expand Down
45 changes: 45 additions & 0 deletions src/utils/report/client/maybeRenderApiStatistics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import {renderApiStatistics as clientRenderApiStatistics} from './render';

import type {
ApiStatisticsReportHash,
ReportClientState,
RunHash,
SafeHtml,
} from '../../../types/internal';

const renderApiStatistics = clientRenderApiStatistics;

declare const reportClientState: ReportClientState;

/**
* Renders `ApiStatistics` by `runHash`, if this is a one of kind of `ApiStatistics` hash
* (pages, requests or resources).
* This base client function should not use scope variables (except other base functions).
* @internal
*/
export function maybeRenderApiStatistics(runHash: RunHash): SafeHtml | undefined {
const hash = String(runHash);

const pagesHash: ApiStatisticsReportHash = 'api-statistics-pages';
const requestsHash: ApiStatisticsReportHash = 'api-statistics-requests';
const resourcesHash: ApiStatisticsReportHash = 'api-statistics-resources';

if (hash !== pagesHash && hash !== requestsHash && hash !== resourcesHash) {
return;
}

const {reportClientData} = reportClientState;

if (reportClientData === undefined) {
// eslint-disable-next-line no-console
console.error(
`Cannot find report client data in JSON report data (tried to click "${hash}"). Probably JSON report data not yet completely loaded. Please try click again later`,
);

return;
}

const {apiStatistics} = reportClientData;

return renderApiStatistics({apiStatistics, hash});
}