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

Evan updated cypress tests #68

Merged
merged 20 commits into from
Jul 15, 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
8 changes: 7 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
{}
{
"semi": false,
"singleQuote": true,
"trailingComma": "es5",
"tabWidth": 2,
"useTabs": false
}
2 changes: 1 addition & 1 deletion @empirica-mocks/core/mocks.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export function usePlayer() {
// This is a mock function that returns a mock player object
console.log("loaded usePlayer() from react-mocks.js");
// console.log("loaded usePlayer() from react-mocks.js");
const player = {
isMock: true,
introDone: true,
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

## To Run the App
## To Run the App

```bash
npm install next@13 react@latest react-dom@latest
npm install
git submodule update --init --recursive
npm run dev
```
*(Next 14 currently does not support Cypress testing.)*

_(Next 14 currently does not support Cypress testing.)_

Navigate to `localhost:3000/editor` to use the treatment editor.

Expand Down
74 changes: 39 additions & 35 deletions cypress/e2e/test.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,78 @@

describe('test spec', () => {
it('passes', () => {

// TO ADD: check for warning messages when invalid input is entered

// initial yaml code for treatment
let yamltreatment = "name: cypress3_load_test\nplayerCount: 8\ngameStages:\n[]"
let yamltreatment = "name: cypress3_load_test\nplayerCount: 1\ngameStages: []"

cy.viewport(2000, 1000, { log: false });

cy.visit('http://localhost:3000/editor')
cy.get('[data-cy="code-editor"]').type(yamltreatment)
cy.get('[data-cy="code-editor"]').clear().type(yamltreatment)
cy.get('[data-cy="yaml-save"]').click()

// create first stage
cy.get('[data-cy="add-stage-button"]').click()
cy.get('[data-cy="add-popup-name-addStage--"]').type("Stage 1")
cy.get('[data-cy="add-popup-duration-addStage--"]').type("300")
cy.get('[data-cy="add-popup-save-addStage--"]').click()
cy.get('[data-cy="edit-stage-name-new"]').type("Stage 1")
cy.get('[data-cy="edit-stage-duration-new"]').type("{backspace}300")
cy.get('[data-cy="edit-stage-save-new"]').click()

cy.get('[data-cy="stage-0"]').contains("Stage 1").should("be.visible")

// add first element to stage 1
cy.get('[data-cy="add-element-button-0"]').click()
cy.get('[data-cy="add-popup-name-addElement-0-"]').type("Element 1")
cy.get('[data-cy="add-popup-type-addElement-0-"]').select("prompt")
cy.get('[data-cy="add-popup-save-addElement-0-"]').click()
cy.get('[data-cy="edit-element-name-0-new"]').type("Element 1")
cy.get('[data-cy="edit-element-type-0-new"]').select("Prompt")
cy.get('[data-cy="edit-element-file-0-new"]').type("file/address")
cy.get('[data-cy="edit-element-save-0-new"]').click()

cy.get('[data-cy="element-0-0"]').contains("Prompt").should("be.visible")
cy.get('[data-cy="element-0-0"]').contains("prompt").should("be.visible")
cy.get('[data-cy="element-0-0"]').contains("Element 1").should("be.visible")

// add second element to stage 1
cy.get('[data-cy="add-element-button-0"]').click()
cy.get('[data-cy="add-popup-name-addElement-0-"]').type("Element 2")
cy.get('[data-cy="add-popup-type-addElement-0-"]').select("prompt")
cy.get('[data-cy="add-popup-fileAddress-addElement-0-"]').type("file/address")
cy.get('[data-cy="add-popup-save-addElement-0-"]').click()
cy.get('[data-cy="edit-element-name-0-new"]').type("Element 2")
cy.get('[data-cy="edit-element-type-0-new"]').select("Survey")
cy.get('[data-cy="edit-element-surveyName-0-new"]').select("TIPI")
cy.get('[data-cy="edit-element-save-0-new"]').click()

cy.get('[data-cy="element-0-0"]').contains("Prompt").should("be.visible")
cy.get('[data-cy="element-0-1"]').contains("Prompt").should("be.visible")
cy.get('[data-cy="element-0-1"]').contains("file/address").should("be.visible")
cy.get('[data-cy="element-0-0"]').contains("prompt").should("be.visible")
cy.get('[data-cy="element-0-1"]').contains("survey").should("be.visible")
cy.get('[data-cy="element-0-1"]').contains("TIPI").should("be.visible")

// create second stage
cy.get('[data-cy="add-stage-button"]').click()
cy.get('[data-cy="add-popup-name-addStage--"]').type("Stage 2")
cy.get('[data-cy="add-popup-duration-addStage--"]').type("200")
cy.get('[data-cy="add-popup-save-addStage--"]').click()
cy.get('[data-cy="edit-stage-name-new"]').type("Stage 2")
cy.get('[data-cy="edit-stage-duration-new"]').type("{backspace}200")
cy.get('[data-cy="edit-stage-save-new"]').click()

cy.get('[data-cy="stage-0"]').contains("Stage 1").should("be.visible")
cy.get('[data-cy="stage-1"]').contains("Stage 2").should("be.visible")

// add third element to stage 2
cy.get('[data-cy="add-element-button-1"]').click()
cy.get('[data-cy="add-popup-name-addElement-1-"]').type("Element 3")
cy.get('[data-cy="add-popup-type-addElement-1-"]').select("trainingVideo")
cy.get('[data-cy="add-popup-URL-addElement-1-"]').type("youtube.com")
cy.get('[data-cy="add-popup-save-addElement-1-"]').click()
cy.get('[data-cy="edit-element-name-1-new"]').type("Element 3")
cy.get('[data-cy="edit-element-type-1-new"]').select("Training Video")
cy.get('[data-cy="edit-element-url-1-new"]').type("https://www.youtube.com/")
cy.get('[data-cy="edit-element-save-1-new"]').click()

cy.get('[data-cy="element-1-0"]').contains("Training Video").should("be.visible")
cy.get('[data-cy="element-1-0"]').contains("url").should("be.visible")
cy.get('[data-cy="element-1-0"]').contains("video").should("be.visible")
cy.get('[data-cy="element-1-0"]').contains("https://www.youtube.com/").should("be.visible")

// edit first element
cy.get('[data-cy="edit-element-button-0-0"]').click()
cy.get('[data-cy="add-popup-name-editElement-0-0"]').type(" Edited")
// cy.get('[data-cy="add-popup-onSubmit-editElement-0-0"]').clear().type("Thanks!")
cy.get('[data-cy="add-popup-save-editElement-0-0"]').click()
cy.get('[data-cy="edit-element-name-0-0"]').should("have.value", "Element 1").should("be.visible").type(" Edited")
cy.get('[data-cy="edit-element-file-0-0"]').type("edited/file/address")
cy.get('[data-cy="edit-element-save-0-0"]').click()

cy.get('[data-cy="element-0-0"]').contains("Prompt").should("be.visible")
cy.get('[data-cy="element-0-0"]').contains("prompt").should("be.visible")
cy.get('[data-cy="element-0-0"]').contains("Element 1 Edited").should("be.visible")

// delete second element
cy.get('[data-cy="edit-element-button-0-1"]').click()
cy.get('[data-cy="add-popup-delete-editElement-0-1"]').click()
cy.get('[data-cy="edit-element-delete-0-1"]').click()

cy.get('[data-cy="stage-0"]').should("not.contain", "Element 2")

Expand All @@ -78,7 +82,7 @@ describe('test spec', () => {
cy.get('[data-cy="yaml-save"]').click()

cy.get('[data-cy="code-editor"]').contains("- name: Element 4").should("be.visible")
cy.get('[data-cy="element-1-1"]').contains("Prompt").should("be.visible")
cy.get('[data-cy="element-1-1"]').contains("prompt").should("be.visible")
cy.get('[data-cy="element-1-1"]').contains("Element 4").should("be.visible")

// add third stage via code editor
Expand All @@ -90,15 +94,15 @@ describe('test spec', () => {

// edit first stage
cy.get('[data-cy="edit-stage-button-0"]').click()
cy.get('[data-cy="add-popup-name-editStage-0-"]').type(" Edited")
cy.get('[data-cy="add-popup-duration-editStage-0-"]').clear().type("400")
cy.get('[data-cy="add-popup-save-editStage-0-"]').click()
cy.get('[data-cy="edit-stage-name-0"]').type(" Edited")
cy.get('[data-cy="edit-stage-duration-0"]').clear().type("400")
cy.get('[data-cy="edit-stage-save-0"]').click()

cy.get('[data-cy="stage-0"]').contains("Stage 1 Edited").should("be.visible")

// delete second stage
cy.get('[data-cy="edit-stage-button-2"]').click()
cy.get('[data-cy="add-popup-delete-editStage-2-"]').click()
cy.get('[data-cy="edit-stage-delete-2"]').click()

cy.get('[data-cy="timeline"]').should("not.contain", "Stage 3")
})
Expand Down
Loading
Loading