Skip to content

Commit

Permalink
Merge pull request #559 from CSCfi/feature/date-picker
Browse files Browse the repository at this point in the history
Feature/date picker
  • Loading branch information
hannyle authored Dec 30, 2021
2 parents 7af42d9 + fb1e5c4 commit b4668df
Show file tree
Hide file tree
Showing 4 changed files with 330 additions and 3 deletions.
54 changes: 54 additions & 0 deletions cypress/integration/doiForm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,60 @@ describe("DOI form", function () {
"Contributor's family name,Contributor's given name"
)
})
it("should fill in the required fields, Dates fields and save DOI form successfully", () => {
// Go to DOI form
cy.openDOIForm()

// Fill in required Creators field
cy.get("h2[data-testid='creators']").parent().children("button").click()
cy.get("input[data-testid='creators.0.givenName']").type("Test given name")

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

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

cy.get("input[data-testid='dates.0.date']").scrollIntoView()
cy.get("input[data-testid='dates.0.date']").should("be.visible")
// Set a constant Date in advance so the calendar will open to certain date
cy.clock(new Date(2021, 9, 1), ["Date"])

cy.get("div[data-testid='Start']")
.scrollIntoView({ offset: { left: 0, top: -100 } })
.should("be.visible")

cy.wait(500)
cy.get("div[data-testid='Start'] > div")
.should("be.visible")
.then(() => cy.get("div[data-testid='Start'] > div > button").click({ force: true }))
cy.get("div").contains("4", { timeout: 10000 }).click()
cy.get("input[data-testid='dates.0.date']").should("have.value", "2021-10-04/")

cy.get("div[data-testid='End'] > div > button").click()
cy.get("div").contains("23", { timeout: 10000 }).click()
cy.get("input[data-testid='dates.0.date']").should("have.value", "2021-10-04/2021-10-23")

cy.get("input[name='checkedStartDate']").check()
cy.get("input[data-testid='dates.0.date']").should("have.value", "/2021-10-23")
cy.get("div[data-testid='Start'] > div > button").should("be.disabled")

cy.get("input[name='checkedStartDate']").uncheck()
cy.get("div[data-testid='Start'] > div > button").click()
cy.get("div").contains("10", { timeout: 10000 }).click()
cy.get("input[data-testid='dates.0.date']").should("have.value", "2021-10-10/2021-10-23")

cy.get("input[name='checkedEndDate']").check()
cy.get("input[data-testid='dates.0.date']").should("have.value", "2021-10-10/")
cy.get("div[data-testid='End'] > div > button").should("be.disabled")

// Select Date Type
cy.get("select[name='dates.0.dateType']").select("Valid")

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

export {}
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"i18next": "^21.6.3",
"jest": "26.6.0",
"lodash": "^4.17.21",
"moment": "^2.29.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-hook-form": "^7.19.4",
Expand Down
Loading

0 comments on commit b4668df

Please sign in to comment.