Skip to content

Commit

Permalink
Merge pull request #1017 from Agenta-AI/cypress-test/-failing-test-an…
Browse files Browse the repository at this point in the history
…d-a/b-testing-eval

Cypress test/ failing test and a/b testing eval
  • Loading branch information
aakrem authored Dec 10, 2023
2 parents 524e116 + ae238d7 commit 3ee8c90
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 47 deletions.
1 change: 0 additions & 1 deletion agenta-web/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export default defineConfig({
baseUrl: "http://localhost",
defaultCommandTimeout: 30000,
requestTimeout: 10000,
specPattern: ["*/e2e/smoke-tests.cy.ts", "*/e2e/app-navigation.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
2 changes: 1 addition & 1 deletion agenta-web/cypress/e2e/playground.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe("Playground Prompt Test", function () {
})

it("Should test prompt functionality in the Playground", () => {
cy.get('[data-cy="testview-input-parameters-0"]').type("Germany")
cy.get('[data-cy^="testview-input-parameters"]').eq(0).type("Germany")
cy.get('[data-cy="testview-input-parameters-run-button"]').click()
cy.get('[data-cy="testview-input-parameters-result"]').should("contain.text", "Loading...")
cy.get('[data-cy="testview-input-parameters-result"]').should(
Expand Down
24 changes: 6 additions & 18 deletions agenta-web/cypress/e2e/testset.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,12 @@ describe("Testsets crud and UI functionality", () => {
cy.get('[data-cy="testset-name-input"]').type(testsetName)
cy.get(".ag-row").should("have.length", 3)
countries.forEach((country, index) => {
cy.get(".ag-row")
.eq(index)
.within(() => {
cy.get("div.ag-cell")
.eq(1)
.within(() => {
cy.get("span").eq(0).dblclick()
cy.get(".ag-input-field-input").type(country.country)
})
cy.get("div.ag-cell")
.eq(2)
.within(() => {
cy.get("span").eq(0).dblclick()
cy.get(".ag-input-field-input").type(
`The capital of ${country.country} is ${country.capital}.`,
)
})
})
cy.get(`.ag-center-cols-container .ag-row[row-index="${index}"]`).within(() => {
cy.get(".ag-cell").eq(1).type(country.country)
cy.get(".ag-cell")
.eq(2)
.type(`The capital of ${country.country} is ${country.capital}.`)
})
})
cy.intercept("/api/testsets/*").as("saveTestsetRequest")
cy.get('[data-cy="testset-save-button"]').click()
Expand Down
26 changes: 7 additions & 19 deletions agenta-web/cypress/support/commands/evaluations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Cypress.Commands.add("createVariant", () => {
})
})

cy.get('[data-cy="create-app-button"]').first().click()
cy.get('[data-cy^="create-app-button"]').eq(1).click()
const appName = randString(5)

cy.get('[data-cy="enter-app-name-modal"]')
Expand Down Expand Up @@ -66,24 +66,12 @@ Cypress.Commands.add("createVariantsAndTestsets", () => {

cy.get(".ag-row").should("have.length", 3)
countries.forEach((country, index) => {
cy.get(".ag-row")
.eq(index)
.within(() => {
cy.get("div.ag-cell")
.eq(1)
.within(() => {
cy.get("span").eq(0).dblclick()
cy.get(".ag-input-field-input").type(country.country)
})
cy.get("div.ag-cell")
.eq(2)
.within(() => {
cy.get("span").eq(0).dblclick()
cy.get(".ag-input-field-input").type(
`The capital of ${country.country} is ${country.capital}.`,
)
})
})
cy.get(`.ag-center-cols-container .ag-row[row-index="${index}"]`).within(() => {
cy.get(".ag-cell").eq(1).type(country.country)
cy.get(".ag-cell")
.eq(2)
.type(`The capital of ${country.country} is ${country.capital}.`)
})
})

cy.get('[data-cy="testset-save-button"]').click()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,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 @@ -221,7 +221,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 3ee8c90

Please sign in to comment.