Merge pull request #649 from LAION-AI/623-fix-e2e-tests

Semi-comprehensive fix to the web end to end tests
This commit is contained in:
AbdBarho
2023-01-12 17:57:55 +01:00
committed by GitHub
7 changed files with 61 additions and 168 deletions
@@ -1,26 +0,0 @@
import { faker } from "@faker-js/faker";
describe("replying as the assistant", () => {
it("completes the current task on submit and on request shows a new task", () => {
cy.signInWithEmail("cypress@example.com");
cy.visit("/create/assistant_reply");
cy.get('[data-cy="task-id"').then((taskIdElement) => {
const taskId = taskIdElement.text();
const reply = faker.lorem.sentence();
cy.log("reply", reply);
cy.get('[data-cy="reply"').type(reply);
cy.get('[data-cy="submit"]').click();
cy.get('[data-cy="next-task"]').click();
cy.get('[data-cy="task-id"').should((taskIdElement) => {
expect(taskIdElement.text()).not.to.eq(taskId);
});
});
});
});
export {};
@@ -1,26 +0,0 @@
import { faker } from "@faker-js/faker";
describe("creating initial prompts", () => {
it("completes the current task on submit and on request shows a new task", () => {
cy.signInWithEmail("cypress@example.com");
cy.visit("/create/initial_prompt");
cy.get('[data-cy="task-id"').then((taskIdElement) => {
const taskId = taskIdElement.text();
const prompt = faker.lorem.sentence();
cy.log("prompt", prompt);
cy.get('[data-cy="reply"').type(prompt);
cy.get('[data-cy="submit"]').click();
cy.get('[data-cy="next-task"]').click();
cy.get('[data-cy="task-id"').should((taskIdElement) => {
expect(taskIdElement.text()).not.to.eq(taskId);
});
});
});
});
export {};
@@ -1,26 +0,0 @@
import { faker } from "@faker-js/faker";
describe("replying as the prompter", () => {
it("completes the current task on submit and on request shows a new task", () => {
cy.signInWithEmail("cypress@example.com");
cy.visit("/create/user_reply");
cy.get('[data-cy="task-id"').then((taskIdElement) => {
const taskId = taskIdElement.text();
const reply = faker.lorem.sentence();
cy.log("reply", reply);
cy.get('[data-cy="reply"').type(reply);
cy.get('[data-cy="submit"]').click();
cy.get('[data-cy="next-task"]').click();
cy.get('[data-cy="task-id"').should((taskIdElement) => {
expect(taskIdElement.text()).not.to.eq(taskId);
});
});
});
});
export {};
@@ -1,30 +0,0 @@
describe("ranking prompter replies", () => {
it("completes the current task on submit and on request shows a new task", () => {
cy.signInWithEmail("cypress@example.com");
cy.visit("/evaluate/rank_assistant_replies");
cy.get('[data-cy="task-id"').then((taskIdElement) => {
const taskId = taskIdElement.text();
// Rank an item using the keyboard so that the submit button is enabled
cy.get('button[aria-roledescription="sortable"]')
.first()
.click()
.type("{enter}")
.wait(100)
.type("{downArrow}")
.wait(100)
.type("{enter}");
cy.get('[data-cy="submit"]').click();
cy.get('[data-cy="next-task"]').click();
cy.get('[data-cy="task-id"').should((taskIdElement) => {
expect(taskIdElement.text()).not.to.eq(taskId);
});
});
});
});
export {};
@@ -1,30 +0,0 @@
describe("ranking initial prompts", () => {
it("completes the current task on submit and on request shows a new task", () => {
cy.signInWithEmail("cypress@example.com");
cy.visit("/evaluate/rank_initial_prompts");
cy.get('[data-cy="task-id"').then((taskIdElement) => {
const taskId = taskIdElement.text();
// Rank an item using the keyboard so that the submit button is enabled
cy.get('button[aria-roledescription="sortable"]')
.first()
.click()
.type("{enter}")
.wait(100)
.type("{downArrow}")
.wait(100)
.type("{enter}");
cy.get('[data-cy="submit"]').click();
cy.get('[data-cy="next-task"]').click();
cy.get('[data-cy="task-id"').should((taskIdElement) => {
expect(taskIdElement.text()).not.to.eq(taskId);
});
});
});
});
export {};
@@ -1,30 +0,0 @@
describe("ranking assistant replies", () => {
it("completes the current task on submit and on request shows a new task", () => {
cy.signInWithEmail("cypress@example.com");
cy.visit("/evaluate/rank_user_replies");
cy.get('[data-cy="task-id"').then((taskIdElement) => {
const taskId = taskIdElement.text();
// Rank an item using the keyboard so that the submit button is enabled
cy.get('button[aria-roledescription="sortable"]')
.first()
.click()
.type("{enter}")
.wait(100)
.type("{downArrow}")
.wait(100)
.type("{enter}");
cy.get('[data-cy="submit"]').click();
cy.get('[data-cy="next-task"]').click();
cy.get('[data-cy="task-id"').should((taskIdElement) => {
expect(taskIdElement.text()).not.to.eq(taskId);
});
});
});
});
export {};
+61
View File
@@ -0,0 +1,61 @@
import { faker } from "@faker-js/faker";
describe("handles random tasks", () => {
it("completes the current task on submit and on request shows a new task", () => {
cy.signInWithEmail("cypress@example.com");
cy.visit("/tasks/random");
// Check all create tasks.
cy.get('[data-cy="task"]').then((createTaskElement) => {
if (createTaskElement.find('[data-task-type="create-task"]').length) {
cy.get('[data-cy="task-id"]').then((taskIdElement) => {
const taskId = taskIdElement.text();
const reply = faker.lorem.sentence();
cy.log("reply", reply);
cy.get('[data-cy="reply"]').type(reply);
cy.get('[data-cy="submit"]').click();
cy.get('[data-cy="next-task"]').click();
cy.get('[data-cy="task-id]"').should((taskIdElement) => {
expect(taskIdElement.text()).not.to.eq(taskId);
});
});
}
// Check all Evaluate tasks.
if (createTaskElement.find('[data-task-type="evaluate-task"]').length) {
cy.get('[data-cy="task-id"]').then((taskIdElement) => {
const taskId = taskIdElement.text();
// Rank an item using the keyboard so that the submit button is enabled
cy.get('button[aria-roledescription="sortable"]')
.first()
.click()
.type("{enter}")
.wait(100)
.type("{downArrow}")
.wait(100)
.type("{enter}");
cy.get('[data-cy="submit"]').click();
cy.get('[data-cy="next-task"]').click();
cy.get('[data-cy="task-id"]').should((taskIdElement) => {
expect(taskIdElement.text()).not.to.eq(taskId);
});
});
}
if (createTaskElement.find('[data-task-type="label-task"]').length) {
}
// TODO(#623): Figure out how to fail the test if none of the checks above pass.
});
});
});
export {};