Skip to content

Commit

Permalink
cypress test: ab testing
Browse files Browse the repository at this point in the history
  • Loading branch information
bekossy committed Dec 8, 2023
1 parent 8b7eb0c commit 0f5a469
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion agenta-web/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 7 additions & 6 deletions agenta-web/cypress/e2e/ab-testing-evaluation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
})

Expand Down
5 changes: 4 additions & 1 deletion agenta-web/cypress/e2e/playground.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
2 changes: 1 addition & 1 deletion agenta-web/cypress/support/commands/evaluations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ const SingleModelEvaluationTable: React.FC<EvaluationTableProps> = ({
type="primary"
onClick={runAllEvaluations}
size="large"
data-cy="abTesting-run-all-button"
data-cy="single-model-run-all-button"
>
Run All
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const ComparisonVote: React.FC<ComparisonVoteProps> = ({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}
</Button>
Expand All @@ -106,6 +107,7 @@ const ComparisonVote: React.FC<ComparisonVoteProps> = ({variants, onChange, valu
type={value === badId ? "primary" : undefined}
key={badId}
onClick={getOnClick(badId)}
data-cy="abTesting-both-bad-vote-button"
>
Both are bad
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ const EvaluationCardView: React.FC<Props> = ({
</li>
</ol>
),
okText: "Ok",
okText: <span data-cy="evalInstructionsShown-ok-btn">Ok</span>,
cancelText: null,
width: 500,
onCancel: () => (opened.current = false),
Expand Down

0 comments on commit 0f5a469

Please sign in to comment.