From 0f5a46931cb4b8919d7e1cdd64c162678a2e975d Mon Sep 17 00:00:00 2001 From: Kaosiso Ezealigo Date: Fri, 8 Dec 2023 01:19:50 +0100 Subject: [PATCH] cypress test: ab testing --- agenta-web/cypress.config.ts | 2 +- agenta-web/cypress/e2e/ab-testing-evaluation.cy.ts | 13 +++++++------ agenta-web/cypress/e2e/playground.cy.ts | 5 ++++- agenta-web/cypress/support/commands/evaluations.ts | 2 +- .../EvaluationTable/SingleModelEvaluationTable.tsx | 2 +- .../EvaluationCardView/EvaluationVotePanel.tsx | 2 ++ .../Evaluations/EvaluationCardView/index.tsx | 2 +- 7 files changed, 17 insertions(+), 11 deletions(-) diff --git a/agenta-web/cypress.config.ts b/agenta-web/cypress.config.ts index 2d69a1f196..980b98b2fd 100644 --- a/agenta-web/cypress.config.ts +++ b/agenta-web/cypress.config.ts @@ -11,7 +11,7 @@ export default defineConfig({ baseUrl: "http://localhost", defaultCommandTimeout: 30000, requestTimeout: 10000, - specPattern: ["*/e2e/playground.cy.ts"], + specPattern: ["*/e2e/ab-testing-evaluation.cy.ts"], }, env: { baseApiURL: "http://localhost/api", diff --git a/agenta-web/cypress/e2e/ab-testing-evaluation.cy.ts b/agenta-web/cypress/e2e/ab-testing-evaluation.cy.ts index a54245d469..2e58da24ab 100644 --- a/agenta-web/cypress/e2e/ab-testing-evaluation.cy.ts +++ b/agenta-web/cypress/e2e/ab-testing-evaluation.cy.ts @@ -69,15 +69,16 @@ describe("A/B Testing Evaluation workflow", () => { cy.clickLinkAndWait('[data-cy="start-new-evaluation-button"]') cy.url().should("include", "/human_a_b_testing") + cy.get('[data-cy="evalInstructionsShown-ok-btn"]').click() + + cy.get('[data-cy="abTesting-app-variant-vote-button"]').should("not.exist") + cy.get('[data-cy="abTesting-both-bad-vote-button"]').should("not.exist") cy.wait(1000) cy.get('[data-cy="abTesting-run-all-button"]').click() - cy.get('[data-cy^="abTesting-app-variant-1-vote-button"]').should("not.be.disabled") - cy.get('[data-cy^="abTesting-app-variant-2-vote-button"]').should("not.be.disabled") - cy.get('[data-cy^="abTesting-both-bad-vote-button"]').should("not.be.disabled") - cy.get('[data-cy="abTesting-app-variant-1-vote-button-0"]').click() - cy.get('[data-cy="abTesting-app-variant-2-vote-button-1"]').click() - cy.get('[data-cy="abTesting-both-bad-vote-button-2"]').click() + cy.get('[data-cy="abTesting-app-variant-vote-button"]').eq(0).click() + cy.get('[data-cy="abTesting-app-variant-vote-button"]').eq(1).click() + cy.get('[data-cy="abTesting-both-bad-vote-button"]').click() }) }) diff --git a/agenta-web/cypress/e2e/playground.cy.ts b/agenta-web/cypress/e2e/playground.cy.ts index 353cb355f0..29bf8bf079 100644 --- a/agenta-web/cypress/e2e/playground.cy.ts +++ b/agenta-web/cypress/e2e/playground.cy.ts @@ -6,7 +6,10 @@ describe("Playground Prompt Test", function () { it("Should test prompt functionality in the Playground", () => { cy.get('[data-cy^="testview-input-parameters"]').eq(0).type("Germany") cy.get('[data-cy="testview-input-parameters-run-button"]').click() - cy.get('textarea[placeholder="Results will be shown here"].ant-input').should("contain.text", "Loading...") + cy.get('textarea[placeholder="Results will be shown here"].ant-input').should( + "contain.text", + "Loading...", + ) cy.get('textarea[placeholder="Results will be shown here"].ant-input').should( "contain.text", "The capital of Germany is Berlin.", diff --git a/agenta-web/cypress/support/commands/evaluations.ts b/agenta-web/cypress/support/commands/evaluations.ts index 14c112124f..c96c984e84 100644 --- a/agenta-web/cypress/support/commands/evaluations.ts +++ b/agenta-web/cypress/support/commands/evaluations.ts @@ -91,7 +91,7 @@ Cypress.Commands.add("cleanupVariantAndTestset", () => { Cypress.Commands.add("addingOpenaiKey", () => { cy.visit("/settings") - cy.get('[data-cy="openai-api-input"]').eq(0).type("apiKey") + cy.get('[data-cy="openai-api-input"]').eq(0).type(apiKey) cy.get('[data-cy="openai-api-save"]').eq(0).click() }) diff --git a/agenta-web/src/components/EvaluationTable/SingleModelEvaluationTable.tsx b/agenta-web/src/components/EvaluationTable/SingleModelEvaluationTable.tsx index a07a948022..5f69df6787 100644 --- a/agenta-web/src/components/EvaluationTable/SingleModelEvaluationTable.tsx +++ b/agenta-web/src/components/EvaluationTable/SingleModelEvaluationTable.tsx @@ -407,7 +407,7 @@ const SingleModelEvaluationTable: React.FC = ({ type="primary" onClick={runAllEvaluations} size="large" - data-cy="abTesting-run-all-button" + data-cy="single-model-run-all-button" > Run All diff --git a/agenta-web/src/components/Evaluations/EvaluationCardView/EvaluationVotePanel.tsx b/agenta-web/src/components/Evaluations/EvaluationCardView/EvaluationVotePanel.tsx index a8ae9830d4..06875a67f1 100644 --- a/agenta-web/src/components/Evaluations/EvaluationCardView/EvaluationVotePanel.tsx +++ b/agenta-web/src/components/Evaluations/EvaluationCardView/EvaluationVotePanel.tsx @@ -92,6 +92,7 @@ const ComparisonVote: React.FC = ({variants, onChange, valu onClick={getOnClick(variant.variantId)} type={value === variant.variantId ? "primary" : undefined} danger + data-cy="abTesting-app-variant-vote-button" > {String.fromCharCode(65 + ix)}: {variant.variantName} @@ -106,6 +107,7 @@ const ComparisonVote: React.FC = ({variants, onChange, valu type={value === badId ? "primary" : undefined} key={badId} onClick={getOnClick(badId)} + data-cy="abTesting-both-bad-vote-button" > Both are bad diff --git a/agenta-web/src/components/Evaluations/EvaluationCardView/index.tsx b/agenta-web/src/components/Evaluations/EvaluationCardView/index.tsx index ed1e9476a1..21a4549439 100644 --- a/agenta-web/src/components/Evaluations/EvaluationCardView/index.tsx +++ b/agenta-web/src/components/Evaluations/EvaluationCardView/index.tsx @@ -218,7 +218,7 @@ const EvaluationCardView: React.FC = ({ ), - okText: "Ok", + okText: Ok, cancelText: null, width: 500, onCancel: () => (opened.current = false),