Skip to content

Commit

Permalink
Merge pull request #224 from CSCfi/develop
Browse files Browse the repository at this point in the history
bump to 0.9.2
  • Loading branch information
blankdots authored Apr 8, 2021
2 parents d060402 + cf4a4bd commit af6a092
Show file tree
Hide file tree
Showing 24 changed files with 625 additions and 255 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Install and run frontend either with:
- Docker by running `docker-compose up --build` (add `-d` flag to run container in the background).
- By default, frontend tries to connect to docker-container running the backend. Feel free to modify `docker-compose.yml` if you want to use some other setup.
- Local node setup by running `npm install` followed with `npm start`.
- If `npm install` leaves corrupted package-lock.json, try to fix with `npm ci`

After installing and running, frontend can be found from `http://localhost:3000`.

Expand Down
3 changes: 1 addition & 2 deletions cypress/integration/app.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe("Basic e2e", function () {
// Edit saved submission
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").blur()
cy.get("input[name='descriptor.studyTitle']", { timeout: 10000 }).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")
Expand Down Expand Up @@ -85,7 +85,6 @@ describe("Basic e2e", function () {
.then($btn => $btn.click())

cy.get("form").within(() => {

cy.get("input[name='title']").type("Test title")
// Experiment
cy.get("input[name='experimentRef.accessionId']").type("Experiment Test Accession Id")
Expand Down
45 changes: 45 additions & 0 deletions cypress/integration/errorPages.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
describe("catch error codes and display corresponding error page", function () {
const baseUrl = "http://localhost:" + Cypress.env("port") + "/"

it("should redirect to 401 page if no granted access", () => {
cy.visit(baseUrl + "home")
cy.contains(".MuiAlert-message", "401 Authorization Error")
})

it("should redirect to 403 page if response status code is 403 ", () => {
cy.intercept(
{
method: "GET",
url: "/folders",
},
{
statusCode: 403,
}
)
cy.visit(baseUrl)
cy.get('[alt="CSC Login"]').click()
cy.contains(".MuiAlert-message", "403 Forbidden Error")
})

it("should redirect to 404 page on unknown route", () => {
cy.visit(baseUrl)
cy.get('[alt="CSC Login"]').click()
cy.visit(baseUrl + "home/unknownroute")
cy.contains(".MuiAlert-message", "404 Not Found")
})

it("should redirect to 500 page if response status code is 500 ", () => {
cy.intercept(
{
method: "GET",
url: "/folders",
},
{
statusCode: 500,
}
)
cy.visit(baseUrl)
cy.get('[alt="CSC Login"]').click()
cy.contains(".MuiAlert-message", "500 Internal Server Error")
})
})
83 changes: 83 additions & 0 deletions cypress/integration/objectLinksAttributes.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
describe("render objects' links and attributes ", function () {
const baseUrl = "http://localhost:" + Cypress.env("port") + "/"

it("should render correct Study Links and Attributes", () => {
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()

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

// Add new Study Link
cy.get("div").contains("Study Links").parent().children("button").click()

// Choose XRef Link
cy.get("select[name='studyLinks[0]']").select("XRef Link")

cy.get("input[name='studyLinks[0].xrefDb']").type("Test XRef Database")
cy.get("input[name='studyLinks[0].xrefId']").type("Test XRef Database ID")
cy.get("input[name='studyLinks[0].label']").type("Test XRef Label")

// Add new URL Link
cy.get("div").contains("Study Links").parent().children("button").click()
cy.get("select[name='studyLinks[1]']").select("URL Link")

cy.get("input[name='studyLinks[1].label']").type("Test URL Label")
cy.get("input[name='studyLinks[1].url']").type("https://testlink.com")

// Add new Entrez Link
cy.get("div").contains("Study Links").parent().children("button").click()
cy.get("select[name='studyLinks[2]']").select("Entrez Link")

cy.get("select[name='studyLinks[2].entrezDb']").select("genome")
cy.get("input[name='studyLinks[2].entrezId']").type("Test Entrez Database ID")
cy.get("input[name='studyLinks[2].label']").type("Test Entrez Label")

// Choose Study Attributes
cy.get("div").contains("Study Attributes").parent().children("button").click()

cy.get("input[name='studyAttributes[0].tag']").type("Test Attributes Tag")
cy.get("textarea[name='studyAttributes[0].value']").type("Test Attributes Value")

// Submit form
cy.get("button[type=submit]").contains("Submit").click()
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()
cy.get("input[name='descriptor.studyTitle']").should("have.value", "Test title")

// Check XRef Link
cy.get("select[name='studyLinks[0]']").should("have.value", "XRef Link")
cy.get("input[name='studyLinks[0].xrefDb']").should("have.value", "Test XRef Database")
cy.get("input[name='studyLinks[0].xrefId']").should("have.value", "Test XRef Database ID")
cy.get("input[name='studyLinks[0].label']").should("have.value", "Test XRef Label")

// Check URL Link
cy.get("select[name='studyLinks[1]']").should("have.value", "URL Link")
cy.get("input[name='studyLinks[1].label']").should("have.value", "Test URL Label")
cy.get("input[name='studyLinks[1].url']").should("have.value", "https://testlink.com")

// Check Entrez Link
cy.get("select[name='studyLinks[2]']").should("have.value", "Entrez Link")
cy.get("select[name='studyLinks[2].entrezDb']").should("have.value", "genome")
cy.get("input[name='studyLinks[2].entrezId']").should("have.value", "Test Entrez Database ID")
cy.get("input[name='studyLinks[2].label']").should("have.value", "Test Entrez Label")

cy.get("input[name='studyAttributes[0].tag']").should("have.value", "Test Attributes Tag")
cy.get("textarea[name='studyAttributes[0].value']").should("have.value", "Test Attributes Value")
})
})
Loading

0 comments on commit af6a092

Please sign in to comment.