Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/distinguish linking accession ids #449

Merged
merged 4 commits into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions cypress/integration/linkingAccessionIds.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ describe("Linking Accession Ids", function () {
.should("be.visible")
.then($btn => $btn.click())
)
cy.get("input[name='sampleName.taxonId']").type(123)
cy.get("[data-testid='title']").type("Test Sample title")
cy.get("[data-testid='sampleName.taxonId']").type(123)
// Submit Sample form
cy.get("button[type=submit]").contains("Submit").click()
cy.get(".MuiListItem-container", { timeout: 10000 }).should("have.length", 1)
Expand All @@ -66,13 +67,16 @@ describe("Linking Accession Ids", function () {
.should("be.visible")
.then($btn => $btn.click())
)
cy.get("[data-testid='title']").type("Test Experiment title")
cy.get("input[name='studyRef.label']").type("Study Label")

// Select studyAccessionId
cy.get("select[name='studyRef.accessionId']").then($el => {
const studyAccessionId = cy.get("@studyAccessionId")
$el.click()
$el.select(studyAccessionId)
})
cy.get("select[name='studyRef.accessionId']").should("contain", " - Title:")

cy.get("textarea[name='design.designDescription']").type("Design description")
cy.get("select[name='design.sampleDescriptor']").select("Individual Sample")
Expand All @@ -82,6 +86,7 @@ describe("Linking Accession Ids", function () {
const sampleAccessionId = cy.get("@sampleAccessionId")
$el.select(sampleAccessionId)
})
cy.get("select[name='design.sampleDescriptor.accessionId']").should("contain", " - Title:")

cy.get("select[name='design.libraryDescriptor.libraryStrategy']").select("AMPLICON")
cy.get("select[name='design.libraryDescriptor.librarySource']").select("GENOMIC")
Expand All @@ -107,13 +112,15 @@ describe("Linking Accession Ids", function () {
.should("be.visible")
.then($btn => $btn.click())
)
cy.get("[data-testid='title']").type("Test Run title")
cy.get("h2[data-testid='experimentRef']").parent().children("button").click()
cy.get("[data-testid='experimentRef[0].label']").type("Test experiment label ref")
// Select experimentAccessionId
cy.get("select[name='experimentRef[0].accessionId']").then($el => {
const experimentAccessionId = cy.get("@experimentAccessionId")
$el.select(experimentAccessionId)
})
cy.get("select[name='experimentRef[0].accessionId']").should("contain", " - Title:")

// Submit Run form
cy.get("button[type=submit]").contains("Submit").click()
Expand All @@ -136,6 +143,7 @@ describe("Linking Accession Ids", function () {
.should("be.visible")
.then($btn => $btn.click())
)
cy.get("[data-testid='title']").type("Test Analysis title")
cy.get("select[name='analysisType']").select("Reference Alignment")
cy.get("select[name='analysisType.referenceAlignment.assembly']").select("Standard")
cy.get("input[name='analysisType.referenceAlignment.assembly.accessionId']").type("Standard accessionId")
Expand All @@ -144,24 +152,32 @@ describe("Linking Accession Ids", function () {
const studyAccessionId = cy.get("@studyAccessionId")
$el.select(studyAccessionId)
})
cy.get("select[name='studyRef.accessionId']").should("contain", " - Title:")

// Select experimentAccessionId
cy.get("div").contains("Experiment Reference").parent().children("button").click()
cy.get("select[name='experimentRef[0].accessionId']").then($el => {
const experimentAccessionId = cy.get("@experimentAccessionId")
$el.select(experimentAccessionId)
})
cy.get("select[name='experimentRef[0].accessionId']").should("contain", " - Title:")

// Select sampleAccessionId
cy.get("div").contains("Sample Reference").parent().children("button").click()
cy.get("select[name='sampleRef[0].accessionId']").then($el => {
const sampleAccessionId = cy.get("@sampleAccessionId")
$el.select(sampleAccessionId)
})
cy.get("select[name='sampleRef[0].accessionId']").should("contain", " - Title:")

// Select runAccessionId
cy.get("div").contains("Run Reference").parent().children("button").click()
cy.get("select[name='runRef[0].accessionId']").then($el => {
const runAccessionId = cy.get("@runAccessionId")
$el.select(runAccessionId)
})
cy.get("select[name='runRef[0].accessionId']").should("contain", " - Title:")

// Submit Analysis form
cy.get("button[type=submit]").contains("Submit").click()
cy.get(".MuiListItem-container", { timeout: 10000 }).should("have.length", 1)
Expand All @@ -173,6 +189,7 @@ describe("Linking Accession Ids", function () {

// Another Analysis form
cy.get("button[type=button]").contains("New form").click()
cy.get("[data-testid='title']").type("Test Analysis title 2")
cy.get("select[name='analysisType']").select("Reference Alignment")
cy.get("select[name='analysisType.referenceAlignment.assembly']").select("Standard")
cy.get("input[name='analysisType.referenceAlignment.assembly.accessionId']").type("Standard accessionId 2")
Expand All @@ -183,6 +200,7 @@ describe("Linking Accession Ids", function () {
const analysisAccessionId = cy.get("@analysisAccessionId")
$el.select(analysisAccessionId)
})
cy.get("select[name='analysisRef[0].accessionId']").should("contain", " - Title:")

// Submit Analysis form
cy.get("button[type=submit]").contains("Submit").click()
Expand Down Expand Up @@ -229,11 +247,14 @@ describe("Linking Accession Ids", function () {
.should("be.visible")
.then($btn => $btn.click())
)
cy.get("[data-testid='title']").type("Test Policy title")
cy.get("input[name='dacRef.label']").type("Test DAC")
cy.get("select[name='dacRef.accessionId']").then($el => {
const dacAccessionId = cy.get("@dacAccessionId")
$el.select(dacAccessionId)
})
cy.get("select[name='dacRef.accessionId']").should("contain", " - Main Contact:")

cy.get("select[name='policy']").select("Policy Text")
cy.get("textarea[name='policy.policyText']").type("Test policy text")
// Submit Policy form
Expand All @@ -257,7 +278,7 @@ describe("Linking Accession Ids", function () {
.then($btn => $btn.click())
)

cy.get("input[name='title']").type("Dataset title")
cy.get("[data-testid='title']").type("Test Dataset title")
cy.get("textarea[name='description']").type("Dataset description")
cy.get("input[name='datasetType']").first().check()

Expand All @@ -266,20 +287,24 @@ describe("Linking Accession Ids", function () {
const policyAccessionId = cy.get("@policyAccessionId")
$el.select(policyAccessionId)
})
cy.get("select[name='policyRef.accessionId']").should("contain", " - Title:")

// Select runAccessionId
cy.get("div").contains("Run Reference").parent().children("button").click()
cy.get("select[name='runRef[0].accessionId']").then($el => {
const runAccessionId = cy.get("@runAccessionId")
$el.select(runAccessionId)
})
cy.get("select[name='runRef[0].accessionId']").should("contain", " - Title:")

// Select analysisAccessionId
cy.get("div").contains("Analysis Reference").parent().children("button").click()
cy.get("select[name='analysisRef[0].accessionId']").then($el => {
const analysisAccessionId = cy.get("@analysisAccessionId")
$el.select(analysisAccessionId)
})
cy.get("select[name='analysisRef[0].accessionId']").should("contain", " - Title:")

// Submit Dataset form
cy.get("button[type=submit]").contains("Submit").click()
cy.get(".MuiListItem-container", { timeout: 10000 }).should("have.length", 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,12 @@ const WizardFillObjectDetailsForm = (): React$Element<typeof Container> => {

const getAccessionIds = (objectType: string) => {
const submissions = metadataObjects?.filter(obj => obj.schema.toLowerCase() === objectType)
const accessionIds = submissions?.map(obj => obj.accessionId)
// Add "- Title: " to accessionId, special case DAC form: add "- Main Contact:"
const accessionIds = submissions?.map(obj =>
obj.schema === ObjectTypes.dac
? `${obj.accessionId} - Main Contact: ${obj.tags?.displayTitle}`
: `${obj.accessionId} - Title: ${obj.tags?.displayTitle}`
)
return accessionIds
}

Expand Down
68 changes: 42 additions & 26 deletions src/components/NewDraftWizard/WizardForms/WizardJSONSchemaParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ const traverseFields = (
let required = object?.else?.required ?? object.required
let requireFirstItem = false

if (path.length === 0 && propertyKey === "title" && !object.title.includes("DAC - Data Access Committee")) {
requireFirstItem = true
}
// Require first field of section if parent section is a required property
if (
requireFirst ||
Expand Down Expand Up @@ -816,32 +819,45 @@ const FormSelectField = ({
<Controller
name={name}
control={control}
render={({ field, fieldState: { error } }) => (
<div className={classes.divBaseline}>
<ValidationSelectField
{...field}
label={label}
value={field.value || ""}
error={!!error}
helperText={error?.message}
required={required}
select
SelectProps={{ native: true }}
>
<option aria-label="None" value="" disabled />
{options.map(option => (
<option key={`${name}-${option}`} value={option}>
{option}
</option>
))}
</ValidationSelectField>
{description && (
<FieldTooltip title={description} placement="top" arrow>
<HelpOutlineIcon className={classes.fieldTip} />
</FieldTooltip>
)}
</div>
)}
render={({ field, fieldState: { error } }) => {
return (
<div className={classes.divBaseline}>
<ValidationSelectField
{...field}
label={label}
value={field.value || ""}
error={!!error}
helperText={error?.message}
required={required}
select
SelectProps={{ native: true }}
onChange={e =>
field.onChange(() => {
const val = e.target.value
// Case: linkingAccessionIds which include "AccessionId + Form's title", we need to return only accessionId as value
if (val?.includes("Title")) {
const hyphenIndex = val.indexOf("-")
return val.slice(0, hyphenIndex - 1)
}
return val
})
}
>
<option aria-label="None" value="" disabled />
{options.map(option => (
<option key={`${name}-${option}`} value={option}>
{option}
</option>
))}
</ValidationSelectField>
{description && (
<FieldTooltip title={description} placement="top" arrow>
<HelpOutlineIcon className={classes.fieldTip} />
</FieldTooltip>
)}
</div>
)
}}
/>
)
}}
Expand Down