Skip to content

Commit

Permalink
Update e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hannyle committed May 24, 2022
1 parent 9730b68 commit ea97490
Show file tree
Hide file tree
Showing 24 changed files with 178 additions and 167 deletions.
44 changes: 22 additions & 22 deletions cypress/integration/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe("Basic application flow", function () {
*/

// Try to send invalid form
cy.formActions("Submit")
cy.formActions("Mark as ready")

cy.get<FormInput[]>("input[data-testid='descriptor.studyTitle']").then($input => {
expect($input[0].validationMessage).to.contain("Please fill")
Expand All @@ -38,26 +38,26 @@ describe("Basic application flow", function () {
cy.get("[data-testid='descriptor.studyTitle']").type("Test title")
cy.get("[data-testid='descriptor.studyTitle']").should("have.value", "Test title")

cy.formActions("Clear form")
cy.optionsActions("Clear form")

cy.get("[data-testid='descriptor.studyTitle']").type("New title")
cy.get("[data-testid='descriptor.studyTitle']").should("have.value", "New title")
cy.get("[data-testid='descriptor.studyType']").select("Metagenomics")
cy.get("[data-testid='descriptor.studyAbstract']").type("New abstract")

// Submit form
cy.formActions("Submit")
cy.formActions("Mark as ready")
cy.get("[data-testid='study-objects-list']").find("li").should("have.length", 1)

// DAC form
cy.clickAddObject(DisplayObjectTypes.dac)

// Try to submit empty DAC form. This should be invalid
cy.get("[data-testid=title]").type("Test title")
cy.formActions("Submit")
cy.formActions("Mark as ready")
cy.get("span").contains("must have at least 1 item")

cy.get("h5").contains("Contacts").parents().children("button").click()
cy.get("div[data-testid='contacts'] > div > button").click()
cy.get("[data-testid='contacts.0.name']").type("Test contact name")
// Test invalid email address (form array, default)
cy.get("[data-testid='contacts.0.email']").type("email")
Expand All @@ -71,11 +71,11 @@ describe("Basic application flow", function () {
cy.get("[data-testid='contacts.0.mainContact']").check()

// Submit DAC form
cy.formActions("Submit")
cy.formActions("Mark as ready")

// Test DAC form update
cy.get("[data-testid='dac-objects-list']").within(() => {
cy.get("a").contains("Test contact name").click()
cy.get("a").contains("Test title").click()
})

cy.get("[data-testid='contacts']").should("be.visible")
Expand All @@ -86,7 +86,7 @@ describe("Basic application flow", function () {
cy.formActions("Update")

cy.get("[data-testid='dac-objects-list']").within(() => {
cy.get("a").contains("Test contact name").click()
cy.contains("Test title").should("be.visible").click({ force: true })
})
cy.get("[data-testid='contacts.0.name']").should("have.value", "Test contact name edited")

Expand All @@ -101,7 +101,7 @@ describe("Basic application flow", function () {
cy.get("textarea[data-testid='policy.policyText']").type("Test policy text")

// Submit Policy form
cy.formActions("Submit")
cy.formActions("Mark as ready")

/*
* 3rd step, Describe
Expand All @@ -121,7 +121,7 @@ describe("Basic application flow", function () {
cy.get("[data-testid='title']").type("Test Sample title")
cy.get("[data-testid='sampleName.taxonId']").type("123")
// Submit Sample form
cy.formActions("Submit")
cy.formActions("Mark as ready")

// Fill a Experiment form
cy.clickAddObject(ObjectTypes.experiment)
Expand Down Expand Up @@ -155,20 +155,20 @@ describe("Basic application flow", function () {
)

// Submit Experiment form
cy.formActions("Submit")
cy.formActions("Mark as ready")

// Fill a Run form
cy.clickAddObject(ObjectTypes.run)
cy.get("[data-testid='title']").type("Test Run title")
cy.get("h5[data-testid='experimentRef']").parents().children("button").click()
cy.get("[data-testid='experimentRef'] > div > button").click()

// Select experimentAccessionId
cy.get("select[data-testid='experimentRef.0.accessionId']").select(1)

cy.get("select[data-testid='experimentRef.0.accessionId']").should("contain", " - Title:")

// Submit Run form
cy.formActions("Submit")
cy.formActions("Mark as ready")

// Fill an Analysis form
cy.clickAddObject(ObjectTypes.analysis)
Expand Down Expand Up @@ -197,31 +197,31 @@ describe("Basic application flow", function () {
cy.get("[data-testid='experimentRef.refname']").type("Experiment Test Namespace")

// Sample
cy.get("h5").contains("Sample Reference").parents().children("button").click()
cy.get("[data-testid='sampleRef'] > div > button").click()
cy.get("[data-testid='sampleRef.0.accessionId']").select(1)
cy.get("[data-testid='sampleRef.0.identifiers.submitterId.namespace']").type("Sample Test Namespace")
cy.get("[data-testid='sampleRef.0.identifiers.submitterId.value']").type("Sample Test Value")

// Run
cy.get("h5").contains("Run Reference").parents().children("button").click()
cy.get("[data-testid='runRef'] > div > button").click()
cy.get("[data-testid='runRef.0.accessionId']").select(1)
cy.get("[data-testid='runRef.0.identifiers.submitterId.namespace']").type("Run Test Namespace")
cy.get("[data-testid='runRef.0.identifiers.submitterId.value']").type("Run Test Value")

// Analysis
cy.get("div[data-testid='analysisRef'] > div").eq(1).children("button").click()
cy.get("[data-testid='analysisRef'] > div > button").click()
cy.get("[data-testid='analysisRef.0.accessionId']").type("Analysis Test Accession Id")
cy.get("[data-testid='analysisRef.0.identifiers.submitterId.namespace']").type("Analysis Test Namespace")
cy.get("[data-testid='analysisRef.0.identifiers.submitterId.value']").type("Analysis Test Value")

// Files
cy.get("div[data-testid='files'] > div").eq(1).children("button").click()
cy.get("[data-testid='files'] > div > button").click()
cy.get("[data-testid='files.0.filename']").type("filename 1")
cy.get("select[data-testid='files.0.filetype']").select("other")
cy.get("select[data-testid='files.0.checksumMethod']").select("MD5")
cy.get("[data-testid='files.0.checksum']").type("b1f4f9a523e36fd969f4573e25af4540")

cy.get("div[data-testid='files'] > div").eq(1).children("button").click()
cy.get("[data-testid='files'] > div > button").click()
cy.get("[data-testid='files.1.filename']").type("filename 2")
cy.get("select[data-testid='files.1.filetype']").select("info")
cy.get("select[data-testid='files.1.checksumMethod']").select("SHA-256")
Expand All @@ -230,7 +230,7 @@ describe("Basic application flow", function () {
)
})
// Submit Analysis form
cy.formActions("Submit")
cy.formActions("Mark as ready")

// Fill a Dataset form
cy.clickAddObject(ObjectTypes.dataset)
Expand All @@ -244,17 +244,17 @@ describe("Basic application flow", function () {
cy.get("select[data-testid='policyRef.accessionId']").should("contain", " - Title:")

// Select runAccessionId
cy.get("div").contains("Run Reference").parents().children("button").click()
cy.get("[data-testid='runRef'] > div > button").click()
cy.get("select[data-testid='runRef.0.accessionId']").select(1)
cy.get("select[data-testid='runRef.0.accessionId']").should("contain", " - Title:")

// Select analysisAccessionId
cy.get("div").contains("Analysis Reference").parents().children("button").click()
cy.get("[data-testid='analysisRef'] > div > button").click()
cy.get("select[data-testid='analysisRef.0.accessionId']").select(1)
cy.get("select[data-testid='analysisRef.0.accessionId']").should("contain", " - Title:")

// Submit Dataset form
cy.formActions("Submit")
cy.formActions("Mark as ready")

/*
* 5th step, Identifier and publish
Expand Down
18 changes: 9 additions & 9 deletions cypress/integration/doiForm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe("DOI form", function () {
}

cy.get("[data-testid='title']").type(testRunData.title)
cy.get("h5[data-testid='experimentRef']").parents().children("button").click()
cy.get("div[data-testid='experimentRef'] > div > button").click()
cy.get("[data-testid='experimentRef.0.accessionId']").select(1)

const testRunFile = {
Expand All @@ -37,7 +37,7 @@ describe("DOI form", function () {
cy.get("[data-testid='files.0.checksum']").type(testRunFile.checksum)

// Submit form
cy.formActions("Submit")
cy.formActions("Mark as ready")

// Run objects container should have contain created object
cy.get("[data-testid='run-objects-list']").find("li").should("have.length", 2)
Expand Down Expand Up @@ -73,13 +73,13 @@ describe("DOI form", function () {
cy.get("[data-testid='files.0.checksum']").type(testAnalysisFile.checksum)

// Submit form
cy.formActions("Submit")
cy.formActions("Mark as ready")

// Analysis objects container should have contain created object
cy.get("[data-testid='analysis-objects-list']").find("li").should("have.length", 2)

// Fill another Analysis form with the same fileType as Run form: "bam"
cy.formActions("New form")
cy.get("button").contains("Add analysis").click()
cy.get("[data-testid='title']").type(testAnalysisData.title2)
cy.get("[data-testid='analysisType']").select("Reference Alignment")
cy.get("[data-testid='analysisType.referenceAlignment.assembly']").select("Standard")
Expand All @@ -91,7 +91,7 @@ describe("DOI form", function () {
cy.get("[data-testid='files.0.checksum']").type(testAnalysisFile.checksum)

// Submit form
cy.formActions("Submit")
cy.formActions("Mark as ready")

// Analysis objects container should have contain both newly created objects
cy.get("[data-testid='analysis-objects-list']").find("li").should("have.length", 3)
Expand Down Expand Up @@ -265,10 +265,10 @@ describe("DOI form", function () {
cy.openDOIForm()

// Fill in required Creators field
cy.get("[data-testid='creators']").parent().children("button").click()
cy.get("div[data-testid='creators'] > div > button").click()
cy.get("[data-testid='creators.0.givenName']").type("Test given name")
cy.get("[data-testid='creators.0.familyName']").type("Test family name")
cy.get("[data-testid='creators.0.affiliation']", { timeout: 10000 }).parent().children("button").click()
cy.get("div[data-testid='creators.0.affiliation'] > div > button").click()
cy.intercept("/organizations*").as("searchOrganization")
cy.get("[data-testid='creators.0.affiliation.0.name-inputField']").type("csc")
cy.wait("@searchOrganization")
Expand All @@ -278,14 +278,14 @@ describe("DOI form", function () {
cy.get("[data-testid='creators.0.affiliation.0.schemeUri']").should("have.value", "https://ror.org")

// Fill in required Subjects field
cy.get("[data-testid='subjects']").parent().children("button").click()
cy.get("div[data-testid='subjects'] > div > button").click()
cy.get("[data-testid='subjects.0.subject']").select("FOS: Mathematics")

// Fill in required Keywords
cy.get("input[data-testid='keywords']").type("keyword-1,")

// Select Dates
cy.get("[data-testid='dates']").parent().children("button").click()
cy.get("div[data-testid='dates'] > div > button").click()

cy.get("[data-testid='dates.0.date']").scrollIntoView()
cy.get("[data-testid='dates.0.date']").should("be.visible")
Expand Down
53 changes: 20 additions & 33 deletions cypress/integration/draft.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,31 @@ describe("Draft operations", function () {
cy.get("[data-testid=title]").type("Test title")

// Save a draft
cy.formActions("Save as Draft")
cy.formActions("Save as draft")
cy.get("div[role=alert]", { timeout: 10000 }).contains("Draft saved with")
cy.get("[data-testid='policy-objects-list']").find("li").should("have.length", 1)

// Save another draft
cy.formActions("New form")
cy.get("button").contains("Add policy").click()
cy.get("[data-testid=title]").should("have.value", "")
cy.get("[data-testid=title]").type("Test title 2")
cy.formActions("Save as Draft")
cy.formActions("Save as draft")
cy.get("div[role=alert]", { timeout: 10000 }).contains("Draft saved with")
cy.get("[data-testid='policy-objects-list']").find("li").should("have.length", 2)

// Update draft, save from dialog
cy.get("[data-testid=title]").type(" second save")
cy.get("[data-testid='policy-objects-list']").find("li").first().click()
cy.get("h2").contains("Would you like to save draft version of this form")
cy.get("[data-testid='draft-policy-list-item']").first().click()
cy.contains("Would you like to save draft version of this form").should("be.visible")
cy.get("div[role=dialog]").contains("Save").click()
cy.get("div[role=dialog]", { timeout: 10000 }).should("not.exist")
cy.get("[data-testid='policy-objects-list']").find("li").should("have.length", 2)

// Delete a draft
cy.get("[data-testid='Draft-objects']")
.find("li")
.first()
.within(() => {
cy.get("[data-testid='Delete submission']").first().click()
})
cy.get("[data-testid='Draft-objects']").find("li", { timeout: 10000 }).should("have.length", 1)

// Continue draft
cy.continueLatestDraft(ObjectTypes.policy)
// Continue first draft
cy.get("[data-testid='draft-policy-list-item']", { timeout: 10000 }).first().click({ force: true })

cy.get("[data-testid=title]")
// Clear
cy.formActions("Clear form")
// Clear form
cy.optionsActions("Clear form")
// Fill
cy.get("[data-testid=title]").should("have.value", "")
cy.get("[data-testid=title]").type("New title")
Expand All @@ -62,38 +54,33 @@ describe("Draft operations", function () {
cy.get("div[role=alert]", { timeout: 10000 }).contains("Draft updated with")

// Create a new form and save as draft
cy.formActions("New form")
cy.get("button").contains("Add DAC").click()
cy.get("[data-testid=title]").should("contain.text", "")
cy.get("[data-testid=title]").type("New title 2")
cy.get("[data-testid=title]").should("have.value", "New title 2")
cy.get("select[data-testid='dacRef.accessionId']").select(1)
cy.formActions("Save as Draft")
cy.formActions("Save as draft")

cy.get("div[role=alert]", { timeout: 10000 }).contains("Draft saved with")

// Check that there are 2 drafts saved in drafts list
cy.get("ul[data-testid='Draft-objects']").find("li").should("have.length", 2)
cy.get("ul[data-testid='dac-objects-list']").find("li").should("have.length", 2)

// Submit first form draft
cy.continueLatestDraft(ObjectTypes.policy)
cy.get("select[data-testid='dacRef.accessionId']").select(1)
cy.get("select[data-testid='policy']").select("Policy Text")
cy.get("textarea[data-testid='policy.policyText']").type("Test policy text")
cy.formActions("Submit")
cy.formActions("Mark as ready")
cy.get("div[role=alert]", { timeout: 10000 }).contains("Submitted with")
cy.get("[data-testid='Form-objects']").find("li").should("have.length", 1)

// Submit second form draft
cy.get(`[data-testid='draft-${ObjectTypes.policy}-list-item']`).should("have.length", 1)
// Re-query instead of continueLatestDraft -command since original query results in detached DOM element
cy.get(`[data-testid='draft-${ObjectTypes.policy}-list-item']`).click()
cy.get("select[data-testid='policy']").select("Policy Text")
cy.get(`[data-testid='draft-${ObjectTypes.policy}-list-item']`).first().click()
cy.get("select[data-testid='policy']", { timeout: 10000 }).select("Policy Text")
cy.get("textarea[data-testid='policy.policyText']").type("Test policy text")
cy.formActions("Submit")
cy.formActions("Mark as ready")
// Check that there are 2 submitted objects
cy.get("[data-testid='Form-objects']", { timeout: 10000 }).find("li").should("have.length", 2)

// Drafts list should be unmounted
cy.get("[data-testid='Draft-objects']").should("have.length", 0)
cy.get("[data-testid='policy-objects-list']", { timeout: 10000 }).find("li").should("have.length", 2)
})
})

Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/draftTemplates.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe("draft selections and templates", function () {
cy.clickAccordionPanel("Study, DAC and policy")
cy.clickAddObject("policy")
cy.get("[data-testid=title]").type("Policy draft title")
cy.formActions("Save as Draft")
cy.formActions("Save as draft")

cy.clickAccordionPanel("publish")

Expand Down
Loading

0 comments on commit ea97490

Please sign in to comment.