Skip to content

Commit

Permalink
Merge pull request #42991 from margelo/fix/e2e-tests-loading-screen-v2
Browse files Browse the repository at this point in the history
[NoQA] fix: e2e long loading
  • Loading branch information
mountiny authored Jun 3, 2024
2 parents d7fd40a + 50ad7b8 commit fe32d94
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
6 changes: 3 additions & 3 deletions tests/e2e/compare/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function buildCompareEntry(name: string, compare: Stats, baseline: Stats): Entry
/**
* Compare results between baseline and current entries and categorize.
*/
function compareResults(compareEntries: Metric | string, baselineEntries: Metric | string) {
function compareResults(baselineEntries: Metric | string, compareEntries: Metric | string = baselineEntries) {
// Unique test scenario names
const baselineKeys = Object.keys(baselineEntries ?? {});
const names = Array.from(new Set([...baselineKeys]));
Expand Down Expand Up @@ -81,8 +81,8 @@ function compareResults(compareEntries: Metric | string, baselineEntries: Metric
}

export default (main: Metric | string, delta: Metric | string, outputFile: string, outputFormat = 'all') => {
// IMPORTANT NOTE: make sure you are passing the delta/compare results first, then the main/baseline results:
const outputData = compareResults(delta, main);
// IMPORTANT NOTE: make sure you are passing the main/baseline results first, then the delta/compare results:
const outputData = compareResults(main, delta);

if (outputFormat === 'console' || outputFormat === 'all') {
printToConsole(outputData);
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default {
TESTS_CONFIG: {
[TEST_NAMES.AppStartTime]: {
name: TEST_NAMES.AppStartTime,

warmupRuns: 1,
// ... any additional config you might need
},
[TEST_NAMES.OpenChatFinderPage]: {
Expand Down
18 changes: 14 additions & 4 deletions tests/e2e/testRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ const runTests = async (): Promise<void> => {
for (let testIndex = 0; testIndex < tests.length; testIndex++) {
const test = Object.values(config.TESTS_CONFIG)[testIndex];

// re-instal app for each new test suite
await installApp(config.MAIN_APP_PACKAGE, mainAppPath);
await installApp(config.DELTA_APP_PACKAGE, deltaAppPath);

// check if we want to skip the test
if (args.includes('--includes')) {
const includes = args[args.indexOf('--includes') + 1];
Expand All @@ -177,11 +181,17 @@ const runTests = async (): Promise<void> => {

const warmupText = `Warmup for test '${test.name}' [${testIndex + 1}/${tests.length}]`;

// Warmup the main app:
await runTestIteration(config.MAIN_APP_PACKAGE, `[MAIN] ${warmupText}`);
// by default we do 2 warmups:
// - first warmup to pass a login flow
// - second warmup to pass an actual flow and cache network requests
const iterations = test.warmupRuns ?? 2;
for (let i = 0; i < iterations; i++) {
// Warmup the main app:
await runTestIteration(config.MAIN_APP_PACKAGE, `[MAIN] ${warmupText}. Iteration ${i + 1}/${iterations}`);

// Warmup the delta app:
await runTestIteration(config.DELTA_APP_PACKAGE, `[DELTA] ${warmupText}`);
// Warmup the delta app:
await runTestIteration(config.DELTA_APP_PACKAGE, `[DELTA] ${warmupText}. Iteration ${i + 1}/${iterations}`);
}

// For each test case we allow the test to fail three times before we stop the test run:
const errorCountRef = {
Expand Down

0 comments on commit fe32d94

Please sign in to comment.