-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #323 from CSCfi/bugfix/edit-does-not-work-for-all-…
…fields Bugfix/edit does not work for all fields
- Loading branch information
Showing
11 changed files
with
382 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
describe("Populate form and render form elements by object data", function () { | ||
beforeEach(() => { | ||
cy.login() | ||
|
||
cy.get("button", { timeout: 10000 }).contains("Create Submission").click() | ||
// Navigate to folder creation | ||
cy.get("button[type=button]", { timeout: 10000 }).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() | ||
}) | ||
|
||
it("should submit Sample form and display all form values when editing the form", () => { | ||
const testData = { | ||
title: "Sample test title", | ||
taxonId: "123456", | ||
sampleData: "Human Sample", | ||
gender: "unknown", | ||
} | ||
|
||
cy.clickFillForm("Sample") | ||
|
||
cy.get("input[name='title']").type(testData.title) | ||
cy.get("input[name='sampleName.taxonId']").type(testData.taxonId) | ||
cy.get("select[name='sampleData']").select(testData.sampleData) | ||
cy.get("select[name='sampleData.gender']").select(testData.gender) | ||
|
||
// Submit form | ||
cy.get("button[type=submit]").contains("Submit").click() | ||
cy.get(".MuiListItem-container", { timeout: 10000 }).should("have.length", 1) | ||
|
||
// Clear form | ||
cy.get("button[type=button]").contains("Clear").click() | ||
|
||
// Edit saved submission | ||
cy.get("button[type=button]").contains("Edit").click() | ||
cy.get("input[name='title']").should("have.value", testData.title) | ||
cy.get("input[name='title']", { timeout: 10000 }).focus().type(" edited").blur() | ||
cy.get("input[name='title']").should("have.value", `${testData.title} edited`) | ||
cy.get("input[name='sampleName.taxonId']").should("have.value", testData.taxonId) | ||
cy.get("select[name='sampleData']").should("have.value", testData.sampleData) | ||
cy.get("select[name='sampleData.gender']").should("have.value", testData.gender) | ||
cy.get("button[type=button]").contains("Update").click() | ||
cy.get("div[role=alert]").contains("Object updated") | ||
|
||
// Clear object in state | ||
cy.get("button[type=button]").contains("New form").click() | ||
|
||
// Test updated title | ||
cy.get(".MuiListItem-container", { timeout: 10000 }).should("have.length", 1) | ||
cy.get("button[type=button]").contains("Edit").click() | ||
cy.get("input[name='title']").should("have.value", `${testData.title} edited`) | ||
}) | ||
|
||
it("should render Experiment form correctly when editing", () => { | ||
const testData = { | ||
title: "Test experiment", | ||
description: "Test experiment description", | ||
designDescription: "Test design description", | ||
sampleReference: "Individual Sample", | ||
individualSampleLabel: "Individual Sample test label", | ||
singleProcessing: "Single Processing", | ||
singleProcessingLabel: "Single Processing label", | ||
complexProcessing: "Complex Processing", | ||
stepIndex: "Step Index", | ||
stringValue: "String value", | ||
nullValue: "Null value", | ||
prevStepIndexValue: "Test prev index", | ||
} | ||
|
||
cy.clickFillForm("Experiment") | ||
|
||
cy.get("input[data-testid='title']").type(testData.title) | ||
cy.get("textarea[data-testid='description']").type(testData.description) | ||
cy.get("textarea[name='design.designDescription']").type(testData.designDescription) | ||
cy.get("select[name='design.sampleDescriptor']").select(testData.sampleReference) | ||
cy.get("input[data-testid='design.sampleDescriptor.label']").type(testData.individualSampleLabel) | ||
// Expected Base Call Table | ||
cy.get("div").contains("Expected Base Call Table").parent().children("button").click() | ||
cy.get("input[name='design.spotDescriptor.readSpec.expectedBaseCallTable[0].baseCall']").type("Test base call") | ||
cy.get("input[name='design.spotDescriptor.readSpec.expectedBaseCallTable[0].readGroupTag']").type( | ||
"Test read group tag" | ||
) | ||
// Select and fill complex processing | ||
cy.get("select[name='processing']").select(testData.complexProcessing) | ||
cy.get(":nth-child(7) > .array > .MuiButtonBase-root > .MuiButton-label").click() | ||
cy.get(".MuiPaper-root > :nth-child(1) > .formSection > .array > .MuiButtonBase-root > .MuiButton-label").click() | ||
cy.get("input[data-testid='processing[0].pipeline.pipeSection[0].stepIndex']").type(testData.stepIndex) | ||
cy.get("select[name='processing[0].pipeline.pipeSection[0].prevStepIndex']").select(testData.stringValue) | ||
cy.get("input[data-testid='processing[0].pipeline.pipeSection[0].prevStepIndex']").type(testData.prevStepIndexValue) | ||
|
||
// Save Experiment form | ||
cy.get("button[type='button']").contains("Save as Draft").click() | ||
cy.get("div[role=alert]", { timeout: 10000 }).contains("Draft saved with") | ||
|
||
cy.chooseFromDrafts() | ||
cy.get("button[aria-label='Continue draft']").first().click() | ||
|
||
// Test that values exist | ||
cy.get("input[data-testid='title']").should("have.value", testData.title) | ||
cy.get("textarea[data-testid='description']").should("have.value", testData.description) | ||
cy.get("textarea[name='design.designDescription']").should("have.value", testData.designDescription) | ||
cy.get("select[name='design.sampleDescriptor']").should("have.value", testData.sampleReference) | ||
cy.get("input[data-testid='design.sampleDescriptor.label']").should("have.value", testData.individualSampleLabel) | ||
cy.get("input[name='design.spotDescriptor.readSpec.expectedBaseCallTable[0].baseCall']").should( | ||
"have.value", | ||
"Test base call" | ||
) | ||
cy.get("input[name='design.spotDescriptor.readSpec.expectedBaseCallTable[0].readGroupTag']").should( | ||
"have.value", | ||
"Test read group tag" | ||
) | ||
cy.get("input[data-testid='processing[0].pipeline.pipeSection[0].stepIndex']").should( | ||
"have.value", | ||
testData.stepIndex | ||
) | ||
cy.get("input[data-testid='processing[0].pipeline.pipeSection[0].prevStepIndex']").should( | ||
"have.value", | ||
testData.prevStepIndexValue | ||
) | ||
|
||
// Change Prev Step Index from string value to null | ||
cy.get("select[name='processing[0].pipeline.pipeSection[0].prevStepIndex']").select(testData.nullValue) | ||
|
||
// Save Experiment form 2nd time | ||
cy.get("button[type='button']").contains("Update draft").click() | ||
cy.get("div[role=alert]", { timeout: 10000 }).contains("Draft updated with") | ||
|
||
cy.chooseFromDrafts() | ||
cy.get("button[aria-label='Continue draft']").first().click() | ||
|
||
// Test that Prev Step Index is nulled | ||
cy.get("input[data-testid='processing[0].pipeline.pipeSection[0].stepIndex']").should("not.exist") | ||
}) | ||
|
||
it("should render Run form correctly when editing", () => { | ||
const testData = { | ||
title: "Test Run", | ||
referenceAlignment: "Standard", | ||
accessionId: "123456", | ||
} | ||
|
||
cy.clickFillForm("Run") | ||
|
||
cy.get("input[data-testid='title']").type(testData.title) | ||
cy.get("select[name='runType.referenceAlignment.assembly']").select(testData.referenceAlignment) | ||
cy.get("input[data-testid='runType.referenceAlignment.assembly.accessionId']").type(testData.accessionId) | ||
|
||
// Save draft | ||
cy.get("button[type='button']").contains("Save as Draft").click() | ||
cy.get("div[role=alert]", { timeout: 10000 }).contains("Draft saved with") | ||
|
||
// Select newly saved draft | ||
cy.chooseFromDrafts() | ||
cy.get("button[aria-label='Continue draft']").first().click() | ||
|
||
cy.get("select[name='runType.referenceAlignment.assembly']").should("have.value", testData.referenceAlignment) | ||
cy.get("input[data-testid='runType.referenceAlignment.assembly.accessionId']").should( | ||
"have.value", | ||
testData.accessionId | ||
) | ||
}) | ||
|
||
it("should render form with checkboxes correctly", () => { | ||
const testData = { | ||
title: "Test Dataset", | ||
} | ||
|
||
cy.clickFillForm("Dataset") | ||
|
||
cy.get("input[data-testid='title']").type(testData.title) | ||
cy.get("[type='checkbox']").first().check() | ||
|
||
// Save draft | ||
cy.get("button[type='button']").contains("Save as Draft").click() | ||
cy.get("div[role=alert]", { timeout: 10000 }).contains("Draft saved with") | ||
|
||
// Select newly saved draft | ||
cy.chooseFromDrafts() | ||
cy.get("button[aria-label='Continue draft']").first().click() | ||
|
||
cy.get("[type='checkbox']").first().should("be.checked") | ||
|
||
// Test that checkbox clears with form clear -button | ||
cy.get("button[type=button]", { timeout: 10000 }).contains("Clear form").click() | ||
cy.get("[type='checkbox']").first().should("not.be.checked") | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.