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
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-12765-tests-1756144753597.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tests
---

Fix Cypress test result summary duration accuracy ([#12765](https://github.com/linode/manager/pull/12765))
5 changes: 5 additions & 0 deletions packages/manager/cypress/support/plugins/junit-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const getCommonJunitConfig = (
testSuite: string,
config: Cypress.PluginConfigOptions
) => {
const runnerIndex = Number(config.env['CY_TEST_SPLIT_RUN_INDEX']) || 1;

if (config.env[envVarName]) {
if (!config.reporterOptions) {
config.reporterOptions = {};
Expand All @@ -38,6 +40,9 @@ const getCommonJunitConfig = (
testsuitesTitle: testSuiteName,
jenkinsMode: true,
suiteTitleSeparatedBy: 'β†’',
properties: {
runner_index: runnerIndex,
},
};
}
return config;
Expand Down
30 changes: 26 additions & 4 deletions scripts/junit-summary/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,32 @@ import type { TestResult } from '../results/test-result';
* @returns Length of time for all suites to run, in seconds.
*/
export const getTestLength = (suites: TestSuites[]): number => {
const unroundedLength = suites.reduce((acc: number, cur: TestSuites) => {
return acc + (cur.time ?? 0);
}, 0);
return Math.round(unroundedLength * 1000) / 1000;
const testDurations: {[key: number]: number} = suites.reduce((acc: {[key: number]: number}, cur: TestSuites) => {
const suite = cur.testsuite?.[0];
if (!suite) {
return acc;
}

const runnerIndex = (() => {
if (!suite.properties) {
return 1;
}
const indexProperty = suite.properties.find((property) => {
return property.name === 'runner_index';
});

if (!indexProperty) {
return 1;
}
return Number(indexProperty.value);
})();

acc[runnerIndex] = (acc[runnerIndex] || 0) + (cur.time ?? 0);
return acc;
}, {});

const highestDuration = Math.max(...Object.values(testDurations));
return Math.round(highestDuration * 1000) / 1000;
};

/**
Expand Down