Skip to content

Commit

Permalink
Merge pull request #1979 from Agenta-AI/test-upload-testset-file
Browse files Browse the repository at this point in the history
Test: upload testset as csv
  • Loading branch information
aakrem authored Aug 14, 2024
2 parents 8eb5d67 + 3e562d9 commit b664ac4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
31 changes: 28 additions & 3 deletions agenta-web/cypress/e2e/testset.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ describe("Testsets crud and UI functionality", () => {
cy.visit(`/apps/${app_id}/testsets/new/manual`)
})

it("navigates successfully to the new testset page", () => {
it("Should navigates successfully to the new testset page", () => {
cy.url().should("include", "/testsets/new/manual")
})

it("don't allow creation of a testset without a name", () => {
it("Should not allow creation of a testset without a name", () => {
cy.get('[data-cy="testset-save-button"]').click()
cy.get('[data-cy="testset-name-reqd-error"]').should("be.visible")
})

it("successfully creates the testset and navigates to the list", () => {
it("Should successfully creates the testset and navigates to the list", () => {
const testsetName = randString(8)
cy.get('[data-cy="testset-name-input"]').type(testsetName)
cy.get(".ag-row").should("have.length", 3)
Expand All @@ -56,6 +56,31 @@ describe("Testsets crud and UI functionality", () => {
})
})

context("When uploading testset", () => {
const testset_name = randString(8)
beforeEach(() => {
cy.visit(`/apps/${app_id}/testsets`)
})

it("Should successfully upload a testset", () => {
cy.url().should("include", "/testsets")
cy.clickLinkAndWait('[data-cy="testset-new-upload-link"]')
cy.url().should("include", "/testsets/new/upload")
cy.get('[data-cy="upload-testset-file-name"]').type(testset_name)
cy.get('[type="file"]').selectFile("cypress/data/countries-genders.csv", {force: true})
cy.wait(1000)
cy.contains("countries-genders.csv").should("be.visible")
cy.get('[data-cy="testset-upload-button"]').click()
})

it("Should check the uploaded testset is present", () => {
cy.url().should("include", "/testsets")
cy.get('[data-cy="app-testset-list"]').as("table")
cy.get("@table").get(".ant-table-pagination li a").last().click()
cy.get("@table").contains(testset_name).as("tempTestSet").should("be.visible")
})
})

after(() => {
cy.cleanupVariantAndTestset()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export default function AddANewTestset() {
<Spin spinning={uploadLoading}>
<Form onFinish={onFinish} form={form} className={classes.form} {...layout}>
<Form.Item name="testsetName" label="Test set name" rules={[{type: "string"}]}>
<Input maxLength={25} />
<Input maxLength={25} data-cy="upload-testset-file-name" />
</Form.Item>
<Form.Item
name="file"
Expand All @@ -189,7 +189,12 @@ export default function AddANewTestset() {
</Form.Item>

<Form.Item {...tailLayout}>
<Button type="primary" htmlType="submit" disabled={uploadLoading}>
<Button
type="primary"
htmlType="submit"
disabled={uploadLoading}
data-cy="testset-upload-button"
>
Add test set
</Button>
</Form.Item>
Expand Down

0 comments on commit b664ac4

Please sign in to comment.