From 6246514f6a04e04a28060dc165a8623e52fad296 Mon Sep 17 00:00:00 2001 From: ashrafchowdury Date: Fri, 6 Dec 2024 20:05:43 +0600 Subject: [PATCH] fix(frontend): cypress tests --- agenta-web/cypress/e2e/eval.comparison.cy.ts | 23 +------------------ .../cypress/support/commands/evaluations.ts | 16 ++++++------- .../NewEvaluation/SelectEvaluatorSection.tsx | 2 ++ .../NewEvaluation/SelectTestsetSection.tsx | 2 +- .../NewEvaluation/SelectVariantSection.tsx | 1 + 5 files changed, 12 insertions(+), 32 deletions(-) diff --git a/agenta-web/cypress/e2e/eval.comparison.cy.ts b/agenta-web/cypress/e2e/eval.comparison.cy.ts index dac81fd172..6fcf92e7da 100644 --- a/agenta-web/cypress/e2e/eval.comparison.cy.ts +++ b/agenta-web/cypress/e2e/eval.comparison.cy.ts @@ -44,28 +44,7 @@ describe("Evaluation Comparison Test", function () { }) it("Should create 2 new Evaluations", () => { - cy.request({ - url: `${Cypress.env().baseApiURL}/evaluations?app_id=${app_id}`, - method: "GET", - }).then((resp) => { - cy.get('[data-cy="new-evaluation-button"]').click() - }) - cy.get(".ant-modal-content").should("exist") - - cy.get('[data-cy="select-testset-group"]').click() - cy.get('[data-cy="select-testset-option"]').eq(0).click() - - cy.get('[data-cy="select-variant-group"]').click() - cy.get('[data-cy="select-variant-option"]').eq(0).click() - cy.get('[data-cy="select-variant-option"]').eq(1).click() - cy.get('[data-cy="select-variant-group"]').click() - - cy.get('[data-cy="select-evaluators-group"]').click() - cy.get('[data-cy="select-evaluators-option"]').eq(0).click() - cy.get('[data-cy="select-evaluators-group"]').click() - - cy.get(".ant-modal-footer > .ant-btn-primary > .ant-btn-icon > .anticon > svg").click() - cy.wait(1000) + cy.createNewEvaluation() }) it("Should verify that there are completed evaluations in the list", () => { diff --git a/agenta-web/cypress/support/commands/evaluations.ts b/agenta-web/cypress/support/commands/evaluations.ts index a1294709eb..28cba95328 100644 --- a/agenta-web/cypress/support/commands/evaluations.ts +++ b/agenta-web/cypress/support/commands/evaluations.ts @@ -113,17 +113,15 @@ Cypress.Commands.add("createNewEvaluation", (evaluatorName = "Exact Match") => { }) cy.get(".ant-modal-content").should("exist") - cy.get('[data-cy="select-testset-group"]').click() - cy.get('[data-cy="select-testset-option"]').eq(0).click() + cy.get('[data-cy="evaluation-testset-table"]').find('input[type="radio"]').eq(0).check() - cy.get('[data-cy="select-variant-group"]').click() - cy.get('[data-cy="select-variant-option"]').eq(0).click() - cy.get('[data-cy="select-variant-group"]').click() + cy.get('[data-cy="evaluation-variant-table"]').find('input[type="checkbox"]').eq(0).check() - cy.get('[data-cy="select-evaluators-group"]').click() - cy.get('[data-cy="select-evaluators-option"]').contains(evaluatorName).eq(0).click() - cy.get('[data-cy="select-evaluators-group"]').click({force: true}) + cy.get('[data-cy="evaluation-search-evaluator"]') + .type(evaluatorName) + .should("have.value", evaluatorName) + cy.get('[data-cy="evaluation-evaluator-table"]').find('input[type="checkbox"]').eq(1).check() - cy.get(".ant-modal-footer > .ant-btn-primary > .ant-btn-icon > .anticon > svg").click() + cy.get(".ant-modal-footer > .ant-btn-primary").click() cy.wait(1000) }) diff --git a/agenta-web/src/components/pages/evaluations/NewEvaluation/SelectEvaluatorSection.tsx b/agenta-web/src/components/pages/evaluations/NewEvaluation/SelectEvaluatorSection.tsx index 9e505f439f..70bbe77f5f 100644 --- a/agenta-web/src/components/pages/evaluations/NewEvaluation/SelectEvaluatorSection.tsx +++ b/agenta-web/src/components/pages/evaluations/NewEvaluation/SelectEvaluatorSection.tsx @@ -130,6 +130,7 @@ const SelectEvaluatorSection = ({ { event.stopPropagation() }} @@ -158,6 +159,7 @@ const SelectEvaluatorSection = ({ }, }} className="ph-no-capture" + data-cy="evaluation-evaluator-table" columns={columns} rowKey={"id"} dataSource={filteredEvalConfigs} diff --git a/agenta-web/src/components/pages/evaluations/NewEvaluation/SelectTestsetSection.tsx b/agenta-web/src/components/pages/evaluations/NewEvaluation/SelectTestsetSection.tsx index b29a2cd9f0..84093eeed5 100644 --- a/agenta-web/src/components/pages/evaluations/NewEvaluation/SelectTestsetSection.tsx +++ b/agenta-web/src/components/pages/evaluations/NewEvaluation/SelectTestsetSection.tsx @@ -117,7 +117,7 @@ const SelectTestsetSection = ({ setSelectedTestsetId(selectedRowKeys[0] as string) }, }} - data-cy="app-testset-list" + data-cy="evaluation-testset-table" className={`ph-no-capture`} columns={columns} dataSource={filteredTestset} diff --git a/agenta-web/src/components/pages/evaluations/NewEvaluation/SelectVariantSection.tsx b/agenta-web/src/components/pages/evaluations/NewEvaluation/SelectVariantSection.tsx index 62e7df2e75..3d53b47526 100644 --- a/agenta-web/src/components/pages/evaluations/NewEvaluation/SelectVariantSection.tsx +++ b/agenta-web/src/components/pages/evaluations/NewEvaluation/SelectVariantSection.tsx @@ -171,6 +171,7 @@ const SelectVariantSection = ({ }} className="ph-no-capture" rowKey={"variantId"} + data-cy="evaluation-variant-table" columns={columns} dataSource={filteredVariant} scroll={{x: true}}