-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #881 from facebookresearch/add-cypress-test-to-sim…
…ple-static-task Add cypress test to simple static task
- Loading branch information
Showing
10 changed files
with
4,675 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
mephisto/abstractions/blueprints/static_html_task/source/cypress.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
video: false, | ||
|
||
e2e: { | ||
baseUrl: "http://localhost:3000/?worker_id=x&assignment_id=1", | ||
}, | ||
}; |
53 changes: 53 additions & 0 deletions
53
...isto/abstractions/blueprints/static_html_task/source/cypress/e2e/simple_static_task.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
describe("Loads simple_static_task", () => { | ||
it("Makes request for agent", () => { | ||
cy.intercept({ pathname: "/request_agent" }).as("agentRequest"); | ||
cy.visit("/"); | ||
cy.wait("@agentRequest").then((interception) => { | ||
expect(interception.response.statusCode).to.eq(200); | ||
}); | ||
}); | ||
it("Loads correct elements", () => { | ||
cy.get('[data-cy="close-modal-button"]'); | ||
cy.get('[data-cy="instructions-panel-header"]'); | ||
cy.get('[data-cy="instructions-panel-body"]'); | ||
cy.get('[data-cy="character-name-paragraph"]'); | ||
cy.get('[data-cy="character-description-paragraph"]'); | ||
cy.get('[data-cy="character-dropdown"]'); | ||
cy.get('[data-cy="submit-button"]'); | ||
}); | ||
}); | ||
|
||
describe("Submits the html_static_task", () => { | ||
it("Closing starting modal", () => { | ||
cy.get('[data-cy="close-modal-button"]').as("modalButton").click(); | ||
cy.get("@modalButton").should("not.be.visible"); | ||
}); | ||
it("Select a character name description", () => { | ||
cy.get('[data-cy="character-dropdown"]').select("Good"); | ||
cy.get('[data-cy="character-dropdown"]').select("Bad"); | ||
}); | ||
it("Upload a file", () => { | ||
cy.fixture("bliss.png").then((fileContent) => { | ||
cy.get('[data-cy="character-file-input"]').attachFile({ | ||
fileContent: fileContent.toString(), | ||
fileName: "bliss.png", | ||
mimeType: "image/png", | ||
}); | ||
}); | ||
}); | ||
it("Submit the task", () => { | ||
cy.on("window:alert", (txt) => { | ||
expect(txt).to.contains( | ||
'The task has been submitted! Data: {"rating":"bad"' | ||
); | ||
expect(txt).to.contains('"name":"bliss.png"'); | ||
expect(txt).to.contains('"size":51824'); | ||
expect(txt).to.contains('"type":"image/png"'); | ||
}); | ||
cy.intercept({ pathname: "/submit_task" }).as("submitTask"); | ||
cy.get('[data-cy="submit-button"]').click(); | ||
cy.wait("@submitTask").then((interception) => { | ||
expect(interception.response.statusCode).to.eq(200); | ||
}); | ||
}); | ||
}); |
Binary file added
BIN
+38 KB
...isto/abstractions/blueprints/static_html_task/source/cypress/fixtures/bliss.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions
1
mephisto/abstractions/blueprints/static_html_task/source/cypress/support/commands.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import "cypress-file-upload"; |
1 change: 1 addition & 0 deletions
1
mephisto/abstractions/blueprints/static_html_task/source/cypress/support/e2e.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import "./commands"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.