Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test: automatic evaluation with different correct_answer column #1985

Merged
merged 6 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions agenta-web/cypress/e2e/eval.evaluations.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import {randString} from "../../src/lib/helpers/utils"

describe("Evaluations CRUD Operations Test", function () {
let newEvalName = randString(5)
let app_id
before(() => {
cy.createVariant()
Expand Down Expand Up @@ -38,6 +41,53 @@ describe("Evaluations CRUD Operations Test", function () {
})
})

context("Executing Evaluation with different answer column", () => {
it("Should successfully rename the testset columns", () => {
cy.visit(`/apps/${app_id}/testsets`)
cy.location("pathname").should("include", "/testsets")
cy.get(".ant-table-row").eq(0).click()
cy.wait(1000)
cy.contains(/create a new test set/i).should("be.visible")
cy.get('[data-cy="testset-header-column-edit-button"]').eq(1).click()
cy.get('[data-cy="testset-header-column-edit-input"]').clear()
cy.get('[data-cy="testset-header-column-edit-input"]').type("answer")
cy.get('[data-cy="testset-header-column-save-button"]').click()
cy.get('[data-cy="testset-save-button"]').click()
})

it("Should successfully create an Evaluator", () => {
cy.visit(`/apps/${app_id}/evaluations/new-evaluator`)
cy.location("pathname").should("include", "/evaluations/new-evaluator")
cy.get('[data-cy="evaluator-card"]').should("exist")
cy.get(".ant-space > :nth-child(2) > .ant-btn").click()
cy.get('[data-cy="new-evaluator-modal"]').should("exist")
cy.get('[data-cy^="select-new-evaluator"]').eq(0).click()
cy.get('[data-cy="configure-new-evaluator-modal"]').should("exist")
cy.get('[data-cy="configure-new-evaluator-modal-input"]').type(newEvalName, {
force: true,
})
cy.get('[data-cy="new-evaluator-advance-settings"]').click()
cy.get('[data-cy="new-evaluator-column-name"]').clear()
cy.get('[data-cy="new-evaluator-column-name"]').type("answer")
cy.get('[data-cy="configure-new-evaluator-modal-save-btn"]').click()
cy.get('[data-cy="evaluator-card"]').should("have.length", 2)
cy.wait(1000)
})

it("Should successfully create an Evaluation", () => {
cy.visit(`/apps/${app_id}/evaluations/results`)
cy.location("pathname").should("include", "/evaluations/results")
cy.createNewEvaluation(newEvalName)
})

it("Should verify the successful creation and completion of the evaluation", () => {
cy.visit(`/apps/${app_id}/evaluations/results`)
cy.location("pathname").should("include", "/evaluations/results")
cy.get('.ag-row[row-index="0"]').should("exist")
cy.get('.ag-cell[col-id="status"]').should("contain.text", "Completed")
})
})

after(() => {
cy.cleanupVariantAndTestset()
})
Expand Down
6 changes: 3 additions & 3 deletions agenta-web/cypress/support/commands/evaluations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Cypress.Commands.add("removeLlmProviderKey", () => {
removeLlmProviderKey()
})

Cypress.Commands.add("createNewEvaluation", () => {
Cypress.Commands.add("createNewEvaluation", (evaluatorName = "Exact Match") => {
cy.request({
url: `${Cypress.env().baseApiURL}/evaluations/?app_id=${app_id}`,
method: "GET",
Expand All @@ -121,8 +121,8 @@ Cypress.Commands.add("createNewEvaluation", () => {
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('[data-cy="select-evaluators-option"]').contains(evaluatorName).eq(0).click()
cy.get('[data-cy="select-evaluators-group"]').click({force: true})

cy.get(".ant-modal-footer > .ant-btn-primary > .ant-btn-icon > .anticon > svg").click()
cy.wait(1000)
Expand Down
2 changes: 1 addition & 1 deletion agenta-web/cypress/support/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ declare global {
saveOpenAiKey(): Chainable<void>
removeLlmProviderKey(): Chainable<void>
addingOpenaiKey(): Chainable<void>
createNewEvaluation(): Chainable<void>
createNewEvaluation(evaluatorName?: string): Chainable<void>
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ const TableHeaderComponent = ({
value={scopedInputValues[index]}
onChange={(event) => handleInputChange(index, event)}
size="small"
data-cy="testset-header-column-edit-input"
/>
) : (
displayName
Expand All @@ -165,12 +166,14 @@ const TableHeaderComponent = ({
onClick={handleSave}
type="default"
className={classes.saveBtn}
data-cy="testset-header-column-save-button"
/>
) : (
<Button
icon={<EditOutlined />}
onClick={() => setIsEditInputOpen(true)}
type="text"
data-cy="testset-header-column-edit-button"
/>
)}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ const AdvancedSettings: React.FC<AdvancedSettingsProps> = ({settings}) => {
expandIcon={({isActive}) => <CaretRightOutlined rotate={isActive ? 90 : 0} />}
className={"my-[10px]"}
>
<Collapse.Panel key="1" header="Advanced Settings" forceRender>
<Collapse.Panel
key="1"
header="Advanced Settings"
data-cy="new-evaluator-advance-settings"
forceRender
>
{settings.map((field) => {
const rules = [
{required: field.required ?? true, message: "This field is required"},
Expand All @@ -59,7 +64,7 @@ const AdvancedSettings: React.FC<AdvancedSettingsProps> = ({settings}) => {
rules={rules}
>
{field.type === "string" || field.type === "regex" ? (
<Input />
<Input data-cy="new-evaluator-column-name" />
) : field.type === "number" ? (
<InputNumber min={field.min} max={field.max} step={0.1} />
) : field.type === "boolean" || field.type === "bool" ? (
Expand Down