Skip to content

Commit

Permalink
Merge pull request #715 from CSCfi/feature/keywords
Browse files Browse the repository at this point in the history
Feature/DOI-keywords-and-integration-tests
  • Loading branch information
hannyle authored Apr 7, 2022
2 parents 3d4f8a1 + 3da88f7 commit 5749d44
Show file tree
Hide file tree
Showing 15 changed files with 269 additions and 153 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Field Keywords in DOI form #715
- Option to filter by submission's name in Home page #685
- New navigation bar and new home page #669

Expand Down
56 changes: 4 additions & 52 deletions cypress/integration/app.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { FormInput } from "../support/types"

describe("Basic e2e", function () {
beforeEach(() => {
cy.task("resetDb")
Expand All @@ -9,7 +7,7 @@ describe("Basic e2e", function () {
cy.login()
})

it("should create new folder, add Study form, upload Study XML file, add Analysis form, add DAC form, and publish folder", () => {
it("should create new folder, add Study form, add Analysis form, add DAC form, and publish folder", () => {
cy.login()

cy.get("button", { timeout: 10000 }).contains("Create submission").click()
Expand All @@ -20,31 +18,6 @@ describe("Basic e2e", function () {
// Skip-link
cy.clickFillForm("Study")

cy.get("div[role=button]").contains("Fill Form").should("be.visible").type("{enter}")

cy.get("div[role=button]").contains("Skip to form").should("be.visible")

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

cy.get<FormInput[]>("input[data-testid='descriptor.studyTitle']").then($input => {
expect($input[0].validationMessage).to.contain("Please fill")
})

// Fill a Study form and submit object
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.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")

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

// Upload a Study xml file.
cy.get("div[role=button]")
.contains("Upload XML File")
Expand All @@ -64,28 +37,7 @@ describe("Basic e2e", function () {
cy.get("form").submit()

// Saved objects list should have newly added item from Study object
cy.get(".MuiListItem-container", { timeout: 10000 }).should("have.length", 2)

// Replace the same XML to see error message
cy.get("button[type=button]")
.contains("Replace")
.should("be.visible")
.then($el => $el.click())
cy.get(".MuiCardHeader-action").contains("Replace")
cy.fixture("study_test.xml").then(fileContent => {
cy.get("[data-testid='xml-upload']").attachFile(
{
fileContent: fileContent.toString(),
fileName: "testFile.xml",
mimeType: "text/xml",
},
{ force: true }
)
})
cy.get("form").submit()
cy.contains(".MuiAlert-message", " Some items (e.g: accessionId, publishDate, dateCreated) cannot be changed.", {
timeout: 10000,
})
cy.get(".MuiListItem-container", { timeout: 10000 }).should("have.length", 1)

// Replace the modified XML file
cy.get("button[type=button]")
Expand All @@ -104,7 +56,7 @@ describe("Basic e2e", function () {
)
})
cy.get("form").submit()
cy.get(".MuiListItem-container", { timeout: 10000 }).should("have.length", 2)
cy.get(".MuiListItem-container", { timeout: 10000 }).should("have.length", 1)
cy.contains(".MuiAlert-message", "Object replaced")

// Fill an Analysis form and submit object
Expand Down Expand Up @@ -212,7 +164,7 @@ describe("Basic e2e", function () {
cy.get("button[type=button]").contains("Next").click()

// Check the amount of submitted objects in each object type
cy.get("h6").contains("Study").parents("div").children().eq(1).should("have.text", 2)
cy.get("h6").contains("Study").parents("div").children().eq(1).should("have.text", 1)
cy.get("h6").contains("Analysis").parents("div").children().eq(1).should("have.text", 1)

// Navigate to publish
Expand Down
28 changes: 25 additions & 3 deletions cypress/integration/doiForm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,19 +192,37 @@ describe("DOI form", function () {

// Fill in required Creators field
cy.get("[data-testid='creators']").parent().children("button").click()
cy.get("[data-testid='creators.0.givenName']").type("John Smith")

cy.get("[data-testid='creators.0.givenName']").type("Test given name")
cy.get("[data-testid='creators.0.familyName']").type("Test family name")
// Fill in required Subjects field
cy.get("[data-testid='subjects']").parent().children("button").click()
cy.get("select[data-testid='subjects.0.subject']").select("FOS: Mathematics")

// Fill in required Keywords
cy.get("input[data-testid='keywords']").type("keyword-1,")
cy.get("input[data-testid='keywords']").type("keyword-2{enter}")
cy.get("input[data-testid='keywords']").type("keyword-3{enter}")
// Try typing the same keyword and check that we don't show repeated keyword
cy.get("input[data-testid='keywords']").type("keyword-2{enter}")

cy.get("div[data-testid='keyword-1']").scrollIntoView().should("be.visible")
cy.get("div[data-testid='keyword-2']").should("be.visible")
cy.get("div[data-testid='keyword-3']").should("be.visible")

// Try deleting a tag and check that it shouldn't exist anymore
cy.get("div[data-testid='keyword-2'] > [data-testid='ClearIcon']").click()
cy.get("div[data-testid='keyword-2']").should("not.exist")

cy.get("button[type='submit']").click()
cy.contains(".MuiAlert-message", "DOI form has been saved successfully")

// Open the DOI form again and check the fields render correctly
cy.get("button").contains("Add DOI information (optional)", { timeout: 10000 }).click()
cy.get("[data-testid='creators.0.givenName']").should("have.value", "John Smith")
cy.get("[data-testid='creators.0.givenName']").should("have.value", "Test given name")
cy.get("[data-testid='creators.0.familyName']").should("have.value", "Test family name")
cy.get("select[data-testid='subjects.0.subject']").should("have.value", "FOS: Mathematics")
cy.get("div[data-testid='keyword-1']").scrollIntoView().should("be.visible")
cy.get("div[data-testid='keyword-3']").scrollIntoView().should("be.visible")
}),
it("should autofill full name based on family and given name", () => {
// Go to DOI form
Expand Down Expand Up @@ -233,11 +251,15 @@ describe("DOI form", function () {
// Fill in required Creators field
cy.get("[data-testid='creators']").parent().children("button").click()
cy.get("[data-testid='creators.0.givenName']").type("Test given name")
cy.get("[data-testid='creators.0.familyName']").type("Test family name")

// Fill in required Subjects field
cy.get("[data-testid='subjects']").parent().children("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()

Expand Down
12 changes: 3 additions & 9 deletions cypress/integration/draft.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ describe("Draft operations", function () {

cy.get("[data-testid='descriptor.studyTitle']", { timeout: 10000 }).should("have.value", "New title")
cy.get("[data-testid='descriptor.studyType']").select("Metagenomics")
cy.get("[data-testid='descriptor.studyAbstract']").type("New abstract")
cy.get("button[type=button]").contains("Update draft").click()
cy.get("div[role=alert]", { timeout: 10000 }).contains("Draft updated with")

Expand All @@ -63,6 +64,7 @@ describe("Draft operations", function () {
cy.get("[data-testid='descriptor.studyTitle']").type("New title 2")
cy.get("[data-testid='descriptor.studyTitle']").should("have.value", "New title 2")
cy.get("[data-testid='descriptor.studyType']").select("Resequencing")
cy.get("[data-testid='descriptor.studyAbstract']").type("New abstract 2")
cy.formActions("Save as Draft")

cy.get("div[role=alert]", { timeout: 10000 }).contains("Draft saved with")
Expand All @@ -76,16 +78,8 @@ describe("Draft operations", function () {
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-objects']").find("li").should("have.length", 1)

cy.continueFirstDraft()
cy.formActions("Submit")
// 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("not.exist")
cy.get("[data-testid='Draft-objects']").should("have.length", 1)
})
})

Expand Down
12 changes: 11 additions & 1 deletion cypress/integration/draftTemplates.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe("draft selections and templates", function () {
cy.get("[data-testid='descriptor.studyTitle']").type("Study test title")
cy.get("[data-testid='descriptor.studyTitle']").should("have.value", "Study test title")
cy.get("[data-testid='descriptor.studyType']").select("Metagenomics")

cy.get("[data-testid='descriptor.studyAbstract']").type("Study test abstract")
// Submit Study form
cy.formActions("Submit")
cy.get(".MuiListItem-container", { timeout: 10000 }).should("have.length", 1)
Expand All @@ -38,9 +38,19 @@ describe("draft selections and templates", function () {
cy.get("div[role=alert]", { timeout: 10000 }).contains("Draft saved with")
cy.get("[data-testid='Draft-objects']").find("li").should("have.length", 1)

// Fill Dataset form
cy.clickFillForm("Dataset")
cy.get("[data-testid='title']").type("Test Dataset title")
cy.get("[data-testid='description']").type("Dataset description")
cy.get("[data-testid='datasetType']").first().check()
cy.formActions("Submit")

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

// Fill and save DOI form
cy.saveDoiForm()

// Navigate to publish button at the bottom
cy.get("button[type=button]").contains("Publish").click()
cy.get("[data-testid='alert-dialog-content']").should(
Expand Down
14 changes: 13 additions & 1 deletion cypress/integration/home.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe("Home e2e", function () {
cy.clickFillForm("Study")
cy.get("input[data-testid='descriptor.studyTitle']").type("Test title")
cy.get("select[data-testid='descriptor.studyType']").select("Resequencing")

cy.get("[data-testid='descriptor.studyAbstract']").type("Test abstract")
// Save draft
cy.formActions("Save as Draft")
cy.get("div[role=alert]", { timeout: 10000 }).contains("Draft saved with")
Expand Down Expand Up @@ -80,17 +80,29 @@ describe("Home e2e", function () {
cy.get("div[role=button]").contains("Fill Form").click()
cy.get("input[data-testid='descriptor.studyTitle']").type("Test title")
cy.get("select[data-testid='descriptor.studyType']").select("Resequencing")
cy.get("[data-testid='descriptor.studyAbstract']").type("Test abstract")

// Submit form
cy.formActions("Submit")
cy.get(".MuiListItem-container", { timeout: 10000 }).should("have.length", 1)

// Fill Dataset form
cy.clickFillForm("Dataset")
cy.get("[data-testid='title']").type("Test Dataset title")
cy.get("[data-testid='description']").type("Dataset description")
cy.get("[data-testid='datasetType']").first().check()
cy.formActions("Submit")
cy.get(".MuiListItem-container", { timeout: 10000 }).should("have.length", 1)

// Navigate to summary
cy.get("button[type=button]").contains("Next").click()
cy.get("h1", { timeout: 10000 }).contains("Summary").should("be.visible")
// Check the amount of submitted objects in Study
cy.get("h6").contains("Study").parent("div").children().eq(1).should("have.text", 1)

// Fill and save DOI form
cy.saveDoiForm()

// 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()
Expand Down
11 changes: 6 additions & 5 deletions cypress/integration/objectLinksAttributes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe("render objects' links and attributes ", function () {
cy.get("[data-testid='descriptor.studyTitle']").type("Test title")
cy.get("[data-testid='descriptor.studyTitle']").should("have.value", "Test title")
cy.get("select[data-testid='descriptor.studyType']").select("Metagenomics")
cy.get("[data-testid='descriptor.studyAbstract']").type("Test abstract")

// Add new Study Link
cy.get("div").contains("Study Links").parents().children("button").click()
Expand Down Expand Up @@ -57,12 +58,12 @@ describe("render objects' links and attributes ", function () {
cy.get("[data-testid='studyAttributes.0.tag']").type("Test Attributes Tag")
cy.get("[data-testid='studyAttributes.0.value']").type("Test Attributes Value")

// Submit form
cy.formActions("Submit")
// Save as draft
cy.formActions("Save as Draft")
cy.get(".MuiListItem-container", { timeout: 10000 }).should("have.length", 1)

// Check submitted object has correnct rendering data
cy.get("button[type=button]").contains("Edit").click()
// Check saved object has correnct rendering data
cy.get("button[type=button]").contains("Continue").click()
cy.get("[data-testid='descriptor.studyTitle']").should("have.value", "Test title")

// Check XRef Link
Expand Down Expand Up @@ -97,7 +98,7 @@ describe("render objects' links and attributes ", function () {

// Test that removed link item is removed also from backend
cy.formActions("Update")
cy.get("button[type=button]").contains("Edit").click()
cy.get("button[type=button]").contains("Continue").click()
cy.get("div[data-testid='studyLinks'] > div", { timeout: 30000 }).should("have.length", 2)
})
})
Expand Down
33 changes: 12 additions & 21 deletions cypress/integration/objectTitles.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,39 @@ describe("draft and submitted objects' titles", function () {

it("should show correct Submitted object's displayTitle", () => {
// Focus on the Study title input in the Study form (not type anything)
cy.get("div[role=button]")
.contains("Study")
.should("be.visible")
.then($el => $el.click())
cy.get("div[role=button]").contains("Fill Form").click()

// Variables
cy.get("[data-testid='descriptor.studyTitle']").as("studyTitle")

// Fill a Study form and submit object
cy.get("@studyTitle").type("Test title")
cy.get("@studyTitle").should("have.value", "Test title")
cy.get("select[data-testid='descriptor.studyType']").select("Metagenomics")
cy.clickFillForm("Sample")

cy.get("[data-testid='title']").type("Sample test title").as("sampleTitle")
cy.get("[data-testid='sampleName.taxonId']").type("123")
// Submit form
cy.formActions("Submit")
cy.get(".MuiListItem-container", { timeout: 10000 }).should("have.length", 1)

// Check the submitted object has correct displayTitle
cy.get("div[data-schema='study']", { timeout: 10000 }).should("contain.text", "Test title")
cy.get("div[data-schema='sample']", { timeout: 10000 }).should("contain.text", "Sample test title")

// Edit submitted object
cy.get("button[type=button]").contains("Edit").click()

cy.scrollTo("top")
cy.contains("Update Study", { timeout: 10000 }).should("be.visible")
cy.get("@studyTitle", { timeout: 10000 }).should("have.value", "Test title")
cy.get("@studyTitle", { timeout: 10000 }).type(" 2")
cy.contains("Update Sample", { timeout: 10000 }).should("be.visible")
cy.get("@sampleTitle", { timeout: 10000 }).should("have.value", "Sample test title")
cy.get("@sampleTitle", { timeout: 10000 }).type(" 2")

cy.get("@studyTitle", { timeout: 30000 }).should("have.value", "Test title 2")
cy.get("@sampleTitle", { timeout: 30000 }).should("have.value", "Sample test title 2")
cy.get("button[type=submit]").contains("Update", { timeout: 10000 }).click()
cy.get("div[role=alert]").contains("Object updated")

// Check the submitted object has correctly updated displayTitle
cy.get("div[data-schema='study']", { timeout: 10000 }).should("contain.text", "Test title 2")
cy.get("div[data-schema='sample']", { timeout: 10000 }).should("contain.text", "Sample test title 2")

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

cy.get("h1", { timeout: 10000 }).contains("Summary").should("be.visible")
// Check the submitted object has correct displayTitle
cy.get("h6").contains("Study").parent("div").children().eq(1).should("have.text", 1)
cy.get("div[data-schema='study']", { timeout: 10000 }).should("contain.text", "Test title 2")
cy.get("h6").contains("Sample").parent("div").children().eq(1).should("have.text", 1)
cy.get("div[data-schema='sample']", { timeout: 10000 }).should("contain.text", "Sample test title 2")
})

it("should show correct Draft object's displayTitle", () => {
Expand All @@ -64,6 +54,7 @@ describe("draft and submitted objects' titles", function () {
cy.get("[data-testid='descriptor.studyTitle']").type("Draft title")
cy.get("[data-testid='descriptor.studyTitle']").should("have.value", "Draft title")
cy.get("select[data-testid='descriptor.studyType']").select("Metagenomics")
cy.get("[data-testid='descriptor.studyAbstract']").type("Draft abstract")

// Save a draft
cy.formActions("Save as Draft")
Expand Down
9 changes: 4 additions & 5 deletions cypress/integration/pagination.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,10 @@ describe("unpublished folders, published folders, and user's draft templates pag
cy.get("[data-testid='page info']").contains("2 of 10 pages", { timeout: 10000 }).should("be.visible")
// Check "Items per page" options
cy.wait(0)
cy.get("@button")
.then($el => {
expect(Cypress.dom.isAttached($el).valueOf()).to.be.true
})
.click()
cy.get("@button").then($el => {
expect(Cypress.dom.isAttached($el).valueOf()).to.be.true
})
cy.get("@button").click()

cy.get("li[data-value='5']", { timeout: 10000 }).should("be.visible")
cy.get("li[data-value='15']").should("be.visible")
Expand Down
Loading

0 comments on commit 5749d44

Please sign in to comment.