Skip to content

Commit

Permalink
Merge pull request #165 from CSCfi/develop
Browse files Browse the repository at this point in the history
bump to 0.8.0
  • Loading branch information
blankdots authored Feb 12, 2021
2 parents 6eb7a5d + b3f5d92 commit 4cd13d4
Show file tree
Hide file tree
Showing 39 changed files with 26,104 additions and 549 deletions.
34 changes: 34 additions & 0 deletions cypress/fixtures/study_test_modified.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<STUDY_SET>
<STUDY alias="GSE10966" center_name="GEO">
<IDENTIFIERS>
<PRIMARY_ID>SRP000539</PRIMARY_ID>
<EXTERNAL_ID label="primary" namespace="BioProject">PRJNA108793</EXTERNAL_ID>
<EXTERNAL_ID namespace="GEO">GSE10966</EXTERNAL_ID>
</IDENTIFIERS>
<DESCRIPTOR>
<STUDY_TITLE>Different title for testing purposes
</STUDY_TITLE>
<STUDY_TYPE existing_study_type="Other" />
<STUDY_ABSTRACT>Part of a set of highly integrated epigenome maps for Arabidopsis thaliana. Keywords:
Illumina high-throughput bisulfite sequencing Overall design: Whole genome shotgun bisulfite sequencing
of wildtype Arabidopsis plants (Columbia-0), and met1, drm1 drm2 cmt3, and ros1 dml2 dml3 null mutants
using the Illumina Genetic Analyzer.
</STUDY_ABSTRACT>
<CENTER_PROJECT_NAME>GSE10966</CENTER_PROJECT_NAME>
</DESCRIPTOR>
<STUDY_LINKS>
<STUDY_LINK>
<XREF_LINK>
<DB>pubmed</DB>
<ID>18423832</ID>
</XREF_LINK>
</STUDY_LINK>
</STUDY_LINKS>
<STUDY_ATTRIBUTES>
<STUDY_ATTRIBUTE>
<TAG>parent_bioproject</TAG>
<VALUE>PRJNA107265</VALUE>
</STUDY_ATTRIBUTE>
</STUDY_ATTRIBUTES>
</STUDY>
</STUDY_SET>
43 changes: 38 additions & 5 deletions cypress/integration/app.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe("Basic e2e", function () {
cy.get('[alt="CSC Login"]').click()
})

it("should create new folder, add Study form, upload Study XML file, add Analysis form and publish folder", () => {
it("should create new folder, add Study form, upload Study XML file, add Analysis form, and publish folder", () => {
cy.visit(baseUrl)
cy.get('[alt="CSC Login"]').click()
cy.visit(baseUrl + "newdraft")
Expand All @@ -19,16 +19,34 @@ describe("Basic e2e", function () {
cy.get("textarea[name='description']").type("Test description")
cy.get("button[type=button]").contains("Next").click()

// Fill a Study form and submit object
// Skip-link
cy.get("div[role=button]").contains("Study").click()
cy.get("div[role=button]").contains("Fill Form").click()
cy.get("div[role=button]").contains("Fill Form").type("{enter}")
cy.get("div[role=button]").contains("Skip to form")

// Fill a Study form and submit object
cy.get("input[name='descriptor.studyTitle']").type("Test title")
cy.get("button[type=button]").contains("Clear form").click()
cy.get("input[name='descriptor.studyTitle']").type("New title")
cy.get("input[name='descriptor.studyTitle']").should("have.value", "New title")
cy.get("select[name='descriptor.studyType']").select("Metagenomics")

// Submit form
cy.get("button[type=submit]").contains("Submit").click()
cy.get(".MuiListItem-container", { timeout: 10000 }).should("have.length", 1)

// Edit saved submission
cy.get("button[type=button]").contains("New form").click()
cy.get("button[type=button]").contains("Edit").click()
cy.get("input[name='descriptor.studyTitle']").should("have.value", "New title")
cy.get("input[name='descriptor.studyTitle']").type(" edited")
cy.get("input[name='descriptor.studyTitle']").should("have.value", "New title edited")
cy.get("button[type=button]").contains("Update").click()
cy.get("div[role=alert]").contains("Object updated")
cy.get("button[type=button]").contains("New form").click()
cy.get("button[type=button]").contains("Edit").click()
cy.get("input[name='descriptor.studyTitle']").should("have.value", "New title edited")

// Upload a Study xml file.
cy.get("div[role=button]").contains("Upload XML File").click()
cy.fixture("study_test.xml").then(fileContent => {
Expand All @@ -45,6 +63,21 @@ describe("Basic e2e", function () {
// Saved objects list should have newly added item from Study object
cy.get(".MuiListItem-container", { timeout: 10000 }).should("have.length", 2)

// Replace XML
cy.get("button[type=button]").contains("Replace").click()
cy.get(".MuiCardHeader-action").contains("Replace")
cy.fixture("study_test_modified.xml").then(fileContent => {
cy.get('input[type="file"]').attachFile({
fileContent: fileContent.toString(),
fileName: "testFile_replace.xml",
mimeType: "text/xml",
force: true,
})
})
cy.get("form").submit()
cy.get(".MuiListItem-container", { timeout: 10000 }).should("have.length", 2)
cy.contains(".MuiAlert-message", "Object replaced")

// Fill an Analysis form and submit object
cy.get("div[role=button]").contains("Analysis").click()
cy.get("div[role=button]")
Expand Down Expand Up @@ -112,9 +145,9 @@ describe("Basic e2e", function () {
"Processed Sequence Accession Id"
)
})
cy.root().submit()
})

// Submit form
cy.get("button[type=submit]").contains("Submit").click()
// Saved objects list should have newly added item from Analysis object
cy.get(".MuiListItem-container", { timeout: 10000 }).should("have.length", 1)

Expand Down
39 changes: 35 additions & 4 deletions cypress/integration/draft.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,50 @@ describe("Draft operations", function () {

// Delete a draft
cy.get("button[aria-label='Delete draft']").first().click()
cy.get("div[data-testid='existing']").find("li").should("have.length", 1)
cy.get("div[data-testid='existing']").find("li", { timeout: 10000 }).should("have.length", 1)

// Continue draft
// Clear
cy.get("button[aria-label='Continue draft']").first().click()
cy.get("input[name='descriptor.studyTitle']").should("have.value", "Test title 2 second save")
cy.get("input[name='descriptor.studyTitle']")
cy.get("button[type=button]", { timeout: 10000 }).contains("Clear form").click()

// Fill
cy.get("input[name='descriptor.studyTitle']").type("New title")
cy.get("input[name='descriptor.studyTitle']").should("have.value", "New title")
cy.get("select[name='descriptor.studyType']").select("Metagenomics")
cy.get("button[type=button]").contains("Save as Draft").click()

// Create a new form and save as draft
cy.get("button").contains("New form").click()
cy.get("input[name='descriptor.studyTitle']").should("contain.text", "")
cy.get("input[name='descriptor.studyTitle']").type("New title 2")
cy.get("input[name='descriptor.studyTitle']").should("have.value", "New title 2")
cy.get("select[name='descriptor.studyType']").select("Resequencing")
cy.get("button[type=button]").contains("Save as Draft").click()

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

// Check that there are 2 drafts saved in "Choose from drafts"
cy.get("div[role=button]").contains("Choose from drafts").click()
cy.get("div[data-testid='existing']").find("li").should("have.length", 2)

// Submit first form draft
cy.get("button[aria-label='Continue draft']").first().click()
cy.get("button[type=submit]").contains("Submit").click()
cy.get(".MuiListItem-container", { timeout: 10000 }).should("have.length", 1)

// Submit second form draft
cy.get("div[role=button]").contains("Choose from drafts").click()
cy.get("div[data-testid='existing']").find("li").should("have.length", 1)
cy.get("button[aria-label='Continue draft']").first().click()
cy.get("button[type=submit]").contains("Submit").click()

// Check that there are 2 submitted objects
cy.get(".MuiListItem-container", { timeout: 10000 }).should("have.length", 2)

// Drafts should be empty
cy.get("div[role=button]").contains("Choose from drafts").click()
cy.get("h3").contains("No study drafts.")
cy.get("div").contains("No study drafts.")
})
})
56 changes: 56 additions & 0 deletions cypress/integration/emptyForm.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
describe("empty form should not be alerted or saved", function () {
const baseUrl = "http://localhost:" + Cypress.env("port") + "/"

it("should not show draft saving alert when form is empty, should not save an empty form", () => {
cy.visit(baseUrl)
cy.get('[alt="CSC Login"]').click()
cy.visit(baseUrl + "newdraft")

// Navigate to folder creation
cy.get("button[type=button]").contains("New folder").click()

// Add folder name & description, navigate to submissions
cy.get("input[name='name']").type("Test name")
cy.get("textarea[name='description']").type("Test description")
cy.get("button[type=button]").contains("Next").click()

// Focus on the Study title input in the Study form (not type anything)
cy.get("div[role=button]").contains("Study").click()
cy.get("div[role=button]").contains("Fill Form").click()
cy.get("input[name='descriptor.studyTitle']").focus()

// Switch to "Upload XML File" and Alert window should not pop up
cy.get("div[role=button]").contains("Upload XML File").click()
cy.get("form", { timeout: 10000 }).should("be.visible")
cy.get("form").within(() => {
cy.get("input[placeholder='Name']").should("be.visible")
})

// Switch back to "Fill form" and fill it
cy.get("div[role=button]").contains("Fill Form").click()
cy.get("input[name='descriptor.studyTitle']").type("Test study")
cy.get("input[name='descriptor.studyTitle']").should("have.value", "Test study")

// Clear form and Save
cy.get("button[type=button]").contains("Clear form").click()
cy.get("input[name='descriptor.studyTitle']", { timeout: 10000 }).should("be.empty")
cy.get("button[type=button]").contains("Save as Draft").click()

// Expect Info window should pop up
cy.get("div[role=alert]", { timeout: 10000 }).contains("An empty form cannot be saved.").should("be.visible")

// Fill in Form and Save
cy.get("input[name='descriptor.studyTitle']").type("Test study")
cy.get("input[name='descriptor.studyTitle']").should("have.value", "Test study")
cy.get("button[type=button]").contains("Save as Draft").click()

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

// Clear Study title input and Save
cy.get("input[name='descriptor.studyTitle']").clear()
cy.get("button[type=button]").contains("Save as Draft").click()

// Expect Info window should pop up
cy.get("div[role=alert]", { timeout: 10000 }).contains("An empty form cannot be saved.").should("be.visible")
})
})
171 changes: 171 additions & 0 deletions cypress/integration/home.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
describe("Home e2e", function () {
const baseUrl = "http://localhost:" + Cypress.env("port") + "/"

beforeEach(() => {
cy.visit(baseUrl)
cy.get('[alt="CSC Login"]').click()
})

it("show Overview submissions in Home page, create a draft folder, navigate to see folder details, delete object inside folder, navigate back to Overview submissions", () => {
// Overview submissions should have 2 different list and max. 5 items each list
cy.contains("Your Draft Submissions", { timeout: 10000 }).should("be.visible")
cy.contains("Your Published Submissions").should("be.visible")

cy.get("ul.MuiList-root").eq(0).children().should("have.length.at.most", 5)
cy.get("ul.MuiList-root").eq(1).children().should("have.length.at.most", 5)

// Create a new Unpublished folder
cy.get("button").contains("Create Submission").click()

// Navigate to folder creation
cy.get("button[type=button]").contains("New folder").click()

// Add folder name & description, navigate to editing folder
cy.get("input[name='name']").type("Test unpublished folder")
cy.get("textarea[name='description']").type("Test description")
cy.get("button[type=button]").contains("Next").click()

// Fill a Study form
cy.get("div[role=button]", { timeout: 10000 }).contains("Study").click()
cy.get("div[role=button]").contains("Fill Form").click()
cy.get("input[name='descriptor.studyTitle']").type("Test title")
cy.get("select[name='descriptor.studyType']").select("Resequencing")

// Submit form
cy.get("button[type=submit]").contains("Submit").click()
cy.get(".MuiListItem-container", { timeout: 10000 }).should("have.length", 1)

// Navigate to summary
cy.get("button[type=button]").contains("Next").click()

// Check the amount of submitted objects in Study
cy.get("h6").contains("Study").parent("div").children().eq(1).should("have.text", 1)

// Save folder and navigate to Home page
cy.get("button[type=button]").contains("Save and Exit").click()
cy.get('button[aria-label="Save a new folder and move to frontpage"]').contains("Return to homepage").click()

cy.reload()
// Click "See all" button to navigate to all unpublished folders list
cy.get("div.MuiCardActions-root", { timeout: 30000 })
.first()
.should("be.visible")
.find("button")
.contains("See all")
.should("be.visible")
.then($btn => $btn.click())

// Check the created folder existing in the list and navigate to see its details
cy.get("ul.MuiList-root", { timeout: 10000 })
.should("be.visible")
.within(() =>
cy
.get("div.MuiButtonBase-root")
.filter(':contains("Test unpublished folder")', { timeout: 30000 })
.should("be.visible")
.then($el => $el.last().click())
)

// Check the selected folder has the correct amount of objects
cy.get("table", { timeout: 10000 }).should("be.visible")

cy.get("tbody").should("be.visible")
cy.get("tbody>tr").should("have.length", 1)

// Delete an object inside the folder
cy.get("button[aria-label='Delete this object']")
.should("be.visible")
.then($btn => $btn.click())
cy.get("tbody>tr", { timeout: 10000 }).should("have.length", 0)

// Navigate back to unpublished folders list
cy.contains("Your draft submissions")
.should("be.visible")
.then($el => $el.click())

// Close unpublished folders list
cy.get("div.MuiCardActions-root")
.contains("Close")
.should("be.visible")
.then($btn => $btn.click())

// Check Overview submissions page is shown
cy.contains("Your Draft Submissions").should("be.visible")
cy.contains("Your Published Submissions").should("be.visible")
})

it("create a published folder, navigate to see folder details, delete object inside folder, navigate back to Overview submissions", () => {
// Create a new Published folder
cy.get("button").contains("Create Submission").click()

// Navigate to folder creation
cy.get("button[type=button]").contains("New folder").click()

// Add folder name & description, navigate to editing folder
cy.get("input[name='name']").type("Test published folder")
cy.get("textarea[name='description']").type("Test description")
cy.get("button[type=button]").contains("Next").click()

// Fill a Study form
cy.get("div[role=button]").contains("Study").click()
cy.get("div[role=button]").contains("Fill Form").click()
cy.get("input[name='descriptor.studyTitle']").type("Test title")
cy.get("select[name='descriptor.studyType']").select("Resequencing")

// Submit form
cy.get("button[type=submit]").contains("Submit").click()
cy.get(".MuiListItem-container", { timeout: 10000 }).should("have.length", 1)

// Navigate to summary
cy.get("button[type=button]").contains("Next").click()

// Check the amount of submitted objects in Study
cy.get("h6").contains("Study").parent("div").children().eq(1).should("have.text", 1)

// Navigate to publish
cy.get("button[type=button]").contains("Publish").click()
cy.get('button[aria-label="Publish folder contents and move to frontpage"]').contains("Publish").click()

cy.get("div", { timeout: 10000 }).contains("Logged in as:")
// Click "See all" button to navigate to all published folders list
cy.get("div.MuiCardActions-root", { timeout: 30000 })
.last()
.should("be.visible")
.find("button")
.contains("See all")
.should("be.visible")
.then($btn => $btn.click())

// Check the created folder existing in the list and navigate to see its details
cy.get("ul.MuiList-root", { timeout: 10000 })
.should("be.visible")
.within(() =>
cy
.get("div.MuiButtonBase-root")
.filter(':contains("Test published folder")', { timeout: 30000 })
.should("be.visible")
.then($el => $el.last().click())
)

// Check the selected folder has the correct amount of objects
cy.get("table", { timeout: 10000 }).should("be.visible")

cy.get("tbody").should("be.visible")
cy.get("tbody>tr").should("have.length", 1)

// Navigate back to published folders list
cy.contains("Your published submissions")
.should("be.visible")
.then($el => $el.click())

// Close published folders list
cy.get("div.MuiCardActions-root")
.contains("Close")
.should("be.visible")
.then($btn => $btn.click())

// Check Overview submissions page is shown
cy.contains("Your Draft Submissions").should("be.visible")
cy.contains("Your Published Submissions").should("be.visible")
})
})
Loading

0 comments on commit 4cd13d4

Please sign in to comment.