Skip to content

Commit

Permalink
feat: render timings of retry; render logo from file; refactor some s…
Browse files Browse the repository at this point in the history
…tyles
  • Loading branch information
uid11 committed Dec 27, 2021
1 parent 9919059 commit ebded95
Show file tree
Hide file tree
Showing 18 changed files with 230 additions and 122 deletions.
2 changes: 1 addition & 1 deletion logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"build:copy:bin": "cp bin/init.sh bin/runInDocker.sh build/node_modules/e2ed/bin",
"postbuild:copy:bin": "(cd build/node_modules/e2ed/bin && chmod +x runLocal.js && chmod +x runWithRetries.js)",
"build:copy:scripts": "cp build/scripts/*.js build",
"build:copy:meta": "cp -r LICENSE package.json README.md styles build/node_modules/e2ed",
"build:copy:meta": "cp -r LICENSE logo.svg package.json README.md styles build/node_modules/e2ed",
"prebuild:copy:example": "rm -r ./build/e2ed",
"build:copy:example": "cp -r e2ed build/node_modules/e2ed/",
"postbuild:copy:example": "rm -r ./build/node_modules/e2ed/e2ed/node_modules",
Expand Down
2 changes: 1 addition & 1 deletion src/package/bin/runWithRetries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const asyncRunTests = async (): Promise<void> => {
await registerStartE2edRunEvent(e2edRunEvent);

for (; retryIndex <= retries; retryIndex += 1) {
runLabel = `retry ${retryIndex}/${retries}`;
runLabel = `r:${retryIndex}/${retries};c:${concurrency}`;

const startRetryTimeInMs = Date.now() as UtcTimeInMs;
const printedTestsString =
Expand Down
8 changes: 5 additions & 3 deletions src/package/types/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export type RetryButtonProps = Readonly<{
* @internal
*/
export type TestRunButtonProps = Readonly<{
durationInMs: number;
endTimeInMs: UtcTimeInMs;
filePath: string;
mainParams: string;
name: string;
Expand All @@ -43,11 +43,13 @@ export type TestRunButtonProps = Readonly<{
}>;

/**
* TestRunsList component props.
* Retry component props.
* @internal
*/
export type TestRunsListProps = Readonly<{
export type RetryProps = Readonly<{
endTimeInMs: UtcTimeInMs;
hidden: boolean;
retry: number;
startTimeInMs: UtcTimeInMs;
testRunButtons: readonly TestRunButtonProps[];
}>;
8 changes: 4 additions & 4 deletions src/package/utils/report/client/e2edClickOnRetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
export function e2edClickOnRetry(element: HTMLElement): void {
const chosenRetryId = element.getAttribute('aria-controls');
const retry = Number(chosenRetryId?.match(/\d+/)?.[0]);
const allRetryElements: NodeListOf<HTMLElement> = document.querySelectorAll('[id$=nav-tablist]');
const allRetryElements: NodeListOf<HTMLElement> = document.querySelectorAll('.retry');
const allRetryButtonElements: NodeListOf<HTMLElement> =
document.querySelectorAll('.nav-tabs__button');

Expand All @@ -19,9 +19,9 @@ export function e2edClickOnRetry(element: HTMLElement): void {
retryButtonElement.setAttribute('aria-selected', String(selected));
}

const retryTitleElement = document.querySelector('.main__section-title');
const leftSection = document.querySelector('.main__section._position_left');

if (retryTitleElement) {
retryTitleElement.textContent = `Retry ${retry}`;
if (leftSection) {
leftSection.ariaLabel = `Retry ${retry}`;
}
}
12 changes: 8 additions & 4 deletions src/package/utils/report/client/e2edRenderTestRunDetails.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import type {TestRun} from '../../../types/internal';
import type {SafeHtml, TestRun} from '../../../types/internal';

import type {e2edSanitizeHtml as E2edSanitizeHtml} from './sanitizeHtml';

declare const e2edSanitizeHtml: typeof E2edSanitizeHtml;

/**
* Render tag <article class="test-detail"> with test run details.
* Render tag <article class="test-details"> with test run details.
* This global client function should not use scope variables (except other global functions).
* @internal
*/
export function e2edRenderTestRunDetails(testRun: TestRun): string {
export function e2edRenderTestRunDetails(testRun: TestRun): SafeHtml {
void testRun;

return '<article class="test-detail"></article>';
return e2edSanitizeHtml`<article class="test-details"></article>`;
}
38 changes: 24 additions & 14 deletions src/package/utils/report/getTestRunsLists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@ import {TestRunStatus} from '../../constants/internal';

import {getRunHashUnificator} from './getRunHashUnificator';

import type {ReportData, RunId, TestRunButtonProps, TestRunsListProps} from '../../types/internal';
import type {
ReportData,
RetryProps,
RunId,
TestRunButtonProps,
UtcTimeInMs,
} from '../../types/internal';

/**
* Get array of TestRunsListProps (by retries) from report data.
* Get array of RetryProps from report data.
* @internal
*/
export const getTestRunsLists = ({testRunsWithHooks}: ReportData): TestRunsListProps[] => {
export const getTestRunsLists = ({testRunsWithHooks}: ReportData): RetryProps[] => {
const runHashUnificator = getRunHashUnificator();

const internallyRetriedRunIds: RunId[] = [];
const testRunsLists: TestRunsListProps[] = [];
const retries: RetryProps[] = [];
const testRunButtonsHash: Record<number, TestRunButtonProps[]> = {};

for (const testRunWithHooks of testRunsWithHooks) {
Expand All @@ -29,13 +35,11 @@ export const getTestRunsLists = ({testRunsWithHooks}: ReportData): TestRunsListP
endTimeInMs,
} = testRunWithHooks;

const durationInMs = endTimeInMs - startTimeInMs;

if (previousRunId) {
internallyRetriedRunIds.push(previousRunId);
}

const retry = parseInt((runLabel || 'retry 1').slice(6), 10);
const retry = parseInt((runLabel || 'r:1').slice(2), 10);

const {duplicate, runHash} = runHashUnificator(maybeDuplicateRunHash);

Expand All @@ -46,7 +50,7 @@ export const getTestRunsLists = ({testRunsWithHooks}: ReportData): TestRunsListP
}

const testRunButtonProps = {
durationInMs,
endTimeInMs,
filePath,
mainParams,
name,
Expand Down Expand Up @@ -82,18 +86,24 @@ export const getTestRunsLists = ({testRunsWithHooks}: ReportData): TestRunsListP
return a.startTimeInMs - b.startTimeInMs;
});

const startTimes = testRunButtons.map((testRun) => testRun.startTimeInMs);
const startTimeInMs = Math.min(...startTimes) as UtcTimeInMs;

const endTimes = testRunButtons.map((testRun) => testRun.endTimeInMs);
const endTimeInMs = Math.max(...endTimes) as UtcTimeInMs;

const retry = Number(retryString);

const testRunsList = {hidden: true, retry, testRunButtons};
const testRunsList = {endTimeInMs, hidden: true, retry, startTimeInMs, testRunButtons};

testRunsLists.push(testRunsList);
retries.push(testRunsList);
}

testRunsLists.sort((a, b) => a.retry - b.retry);
retries.sort((a, b) => a.retry - b.retry);

if (testRunsLists[0]) {
(testRunsLists[0] as {hidden: boolean}).hidden = false;
if (retries[0]) {
(retries[0] as {hidden: boolean}).hidden = false;
}

return testRunsLists;
return retries;
};
22 changes: 0 additions & 22 deletions src/package/utils/report/render/renderListOfTestRuns.ts

This file was deleted.

Loading

0 comments on commit ebded95

Please sign in to comment.