From 2b780e7f5d5e5c2f2bdbca68991575ef25dda073 Mon Sep 17 00:00:00 2001 From: Alan Greene Date: Thu, 19 Sep 2024 21:40:26 +0100 Subject: [PATCH] Reduce flakiness in create and edit E2E tests Reduce the incidents of flakiness encountered when running the E2E tests locally on some machines. We have not encountered this flakiness in CI, but the changes should have no negative impact. - Wait for new page header after navigation. This helps to reduce the likelihood of timeouts when attempting to interact with controls on the destination page - Ensure the step details are loaded before making assertions based on the log content --- .../e2e/cypress/e2e/run/pipelinerun-create.cy.js | 15 +++++++++++++++ .../e2e/cypress/e2e/run/pipelinerun-edit.cy.js | 2 ++ packages/e2e/cypress/e2e/run/taskrun-create.cy.js | 15 +++++++++++++++ packages/e2e/cypress/e2e/run/taskrun-edit.cy.js | 1 + 4 files changed, 33 insertions(+) diff --git a/packages/e2e/cypress/e2e/run/pipelinerun-create.cy.js b/packages/e2e/cypress/e2e/run/pipelinerun-create.cy.js index 6cf448163..8ff86f7e9 100644 --- a/packages/e2e/cypress/e2e/run/pipelinerun-create.cy.js +++ b/packages/e2e/cypress/e2e/run/pipelinerun-create.cy.js @@ -45,6 +45,8 @@ spec: cy.visit( `/#/pipelineruns/create?namespace=${namespace}&pipelineName=${pipelineName}` ); + cy.contains('h1', 'Create PipelineRun'); + cy.get('[id=create-pipelinerun--namespaces-dropdown]').should( 'have.value', namespace @@ -58,11 +60,14 @@ spec: cy.contains('h1', 'PipelineRuns'); cy.contains('a', `${pipelineName}-run`).click(); + cy.contains('h1', `${pipelineName}-run`); cy.get('header[class="tkn--pipeline-run-header"]') .find('span[class="tkn--status-label"]', { timeout: 15000 }) .should('have.text', 'Succeeded'); + cy.contains('[role=button]', 'echo').click(); + cy.contains('.tkn--log', 'Hello World!'); cy.contains('.tkn--log', 'Step completed successfully'); }); @@ -92,6 +97,8 @@ spec: cy.visit( `/#/pipelineruns/create?namespace=${namespace}&pipelineName=${pipelineName}` ); + cy.contains('h1', 'Create PipelineRun'); + cy.get('[id=create-pipelinerun--namespaces-dropdown]').should( 'have.value', namespace @@ -116,11 +123,14 @@ spec: cy.contains('h1', 'PipelineRuns'); cy.contains('a', pipelineRunName).click(); + cy.contains('h1', pipelineRunName); cy.get('header[class="tkn--pipeline-run-header"]') .find('span[class="tkn--status-label"]', { timeout: 15000 }) .should('have.text', 'Succeeded'); + cy.contains('[role=button]', 'echo').click(); + cy.contains('.tkn--log', 'Hello World!'); cy.contains('.tkn--log', 'Step completed successfully'); }); @@ -158,11 +168,14 @@ spec: cy.contains('h1', 'PipelineRuns'); cy.get(`[title=${pipelineRunName}]`).click(); + cy.contains('h1', pipelineRunName); cy.get('header[class="tkn--pipeline-run-header"]') .find('span[class="tkn--status-label"]', { timeout: 15000 }) .should('have.text', 'Succeeded'); + cy.contains('[role=button]', 'echo').click(); + cy.contains('.tkn--log', 'Hello World!'); cy.contains('.tkn--log', 'Step completed successfully'); }); @@ -202,6 +215,8 @@ spec: .find('span[class="tkn--status-label"]', { timeout: 15000 }) .should('have.text', 'Succeeded'); + cy.contains('[role=button]', 'echo').click(); + cy.contains('.tkn--log', 'Hello World!'); cy.contains('.tkn--log', 'Step completed successfully'); }); diff --git a/packages/e2e/cypress/e2e/run/pipelinerun-edit.cy.js b/packages/e2e/cypress/e2e/run/pipelinerun-edit.cy.js index df56961a2..c16d9f868 100644 --- a/packages/e2e/cypress/e2e/run/pipelinerun-edit.cy.js +++ b/packages/e2e/cypress/e2e/run/pipelinerun-edit.cy.js @@ -46,6 +46,8 @@ spec: cy.visit( `/#/pipelineruns/create?namespace=${namespace}&pipelineName=${pipelineName}` ); + cy.contains('h1', 'Create PipelineRun'); + cy.get('[id=create-pipelinerun--namespaces-dropdown]').should( 'have.value', namespace diff --git a/packages/e2e/cypress/e2e/run/taskrun-create.cy.js b/packages/e2e/cypress/e2e/run/taskrun-create.cy.js index 3d7252efd..2657f3b1e 100644 --- a/packages/e2e/cypress/e2e/run/taskrun-create.cy.js +++ b/packages/e2e/cypress/e2e/run/taskrun-create.cy.js @@ -40,6 +40,8 @@ spec: `; cy.applyResource(task); cy.visit(`/#/taskruns/create?namespace=${namespace}&taskName=${taskName}`); + cy.contains('h1', 'Create TaskRun'); + cy.get('[id=create-taskrun--namespaces-dropdown]').should( 'have.value', namespace @@ -53,11 +55,14 @@ spec: cy.contains('h1', 'TaskRuns'); cy.contains('a', `${taskName}-run`).click(); + cy.contains('h1', `${taskName}-run`); cy.get('header[class="tkn--pipeline-run-header"]') .find('span[class="tkn--status-label"]', { timeout: 15000 }) .should('have.text', 'Succeeded'); + cy.contains('[role=button]', 'echo').click(); + cy.contains('.tkn--log', 'Hello World!'); cy.contains('.tkn--log', 'Step completed successfully'); }); @@ -82,6 +87,7 @@ spec: `; cy.applyResource(task); cy.visit(`/#/taskruns/create?namespace=${namespace}&taskName=${taskName}`); + cy.contains('h1', 'Create TaskRun'); cy.get('[id=create-taskrun--namespaces-dropdown]').should( 'have.value', namespace @@ -106,11 +112,14 @@ spec: cy.contains('h1', 'TaskRuns'); cy.contains('a', taskRunName).click(); + cy.contains('h1', taskRunName); cy.get('header[class="tkn--pipeline-run-header"]') .find('span[class="tkn--status-label"]', { timeout: 15000 }) .should('have.text', 'Succeeded'); + cy.contains('[role=button]', 'echo').click(); + cy.contains('.tkn--log', 'Hello World!'); cy.contains('.tkn--log', 'Step completed successfully'); }); @@ -145,11 +154,14 @@ spec: cy.contains('h1', 'TaskRuns'); cy.get(`[title=${taskRunName}]`).click(); + cy.contains('h1', taskRunName); cy.get('header[class="tkn--pipeline-run-header"]') .find('span[class="tkn--status-label"]', { timeout: 15000 }) .should('have.text', 'Succeeded'); + cy.contains('[role=button]', 'echo').click(); + cy.contains('.tkn--log', 'Hello World!'); cy.contains('.tkn--log', 'Step completed successfully'); }); @@ -181,11 +193,14 @@ spec: cy.contains('h1', 'TaskRuns'); cy.get(`[title=${taskRunName}]`).click(); + cy.contains('h1', taskRunName); cy.get('header[class="tkn--pipeline-run-header"]') .find('span[class="tkn--status-label"]', { timeout: 15000 }) .should('have.text', 'Succeeded'); + cy.contains('[role=button]', 'echo').click(); + cy.contains('.tkn--log', 'Hello World!'); cy.contains('.tkn--log', 'Step completed successfully'); }); diff --git a/packages/e2e/cypress/e2e/run/taskrun-edit.cy.js b/packages/e2e/cypress/e2e/run/taskrun-edit.cy.js index f42bc0d1c..f9dc9ac33 100644 --- a/packages/e2e/cypress/e2e/run/taskrun-edit.cy.js +++ b/packages/e2e/cypress/e2e/run/taskrun-edit.cy.js @@ -41,6 +41,7 @@ spec: `; cy.applyResource(task); cy.visit(`/#/taskruns/create?namespace=${namespace}&taskName=${taskName}`); + cy.contains('h1', 'Create TaskRun'); cy.get('[id=create-taskrun--namespaces-dropdown]').should( 'have.value', namespace