Skip to content

Commit

Permalink
Fixed issue Rabab found in review; where the store was not switching …
Browse files Browse the repository at this point in the history
…to representing a different analysis when loading a different analysis.
  • Loading branch information
SeriousHorncat committed Dec 2, 2024
1 parent 8dfffa0 commit c5ef145
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
9 changes: 9 additions & 0 deletions frontend/src/stores/analysisStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ export const analysisStore = reactive({
Analyses.downloadSupportingEvidence(attachmentToDownload.attachment_id, attachmentToDownload.name);
},

clear() {
this.analysis = {
name: '',
sections: [],
};

this.updatedContent = {};
},

// -----------------------------------
// Edit Operations
// -----------------------------------
Expand Down
5 changes: 4 additions & 1 deletion frontend/src/views/AnalysisView.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
54<template>
<template>
<div>
<app-header>
<AnalysisViewHeader
Expand Down Expand Up @@ -593,6 +593,9 @@ function copyToClipboard(copiedText) {
* When view is mounted, queries the analysis' state.
*/
onMounted(async () => {
if ( analysisStore.analysis.name !== props.analysis_name) {
analysisStore.clear();
}
await analysisStore.getAnalysis(props.analysis_name);
toast = toastRef.value;
});
Expand Down
32 changes: 20 additions & 12 deletions system-tests/e2e/edit_case_analysis.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,30 @@ describe('edit_case_analysis.cy.js', () => {

cy.get('[href="#Brief"]').click();
cy.get('#Brief > div > [data-test="Phenotype"] > .section-content > [data-test="editable-value"]')
.as('editablePhenotype')
.click();
cy.get('#Brief > div > [data-test="Phenotype"] > .section-content > [data-test="editable-value"]')
.type('test');
cy.get('#Brief > div > [data-test="Phenotype"] > .section-content > [data-test="editable-value"]')
.should('contain', 'test');
cy.get('@editablePhenotype').type('test');
cy.get('@editablePhenotype').should('contain', 'test');

// Save the changes to persist the analysis
cy.get('[data-test="save-edit-button"]').should('exist');
cy.get('[data-test="save-edit-button"]').click();
cy.get('[data-test="save-edit-button"]').should('not.exist');

// Verify that the changes persist once the save is complete
cy.get('[href="#Brief"]').click();
cy.get('#Brief > div > [data-test="Phenotype"] > .section-content').as('phenotypeField').should('contain', 'test');

// Visit CPAM0046 analysis to verify the updated field in CPAM0002 does not appear
cy.visit('analysis/CPAM0046');
cy.wait('@analysisLoad');
cy.get('[href="#Brief"]').click();
cy.get('@phenotypeField').contains('test').should('not.exist');

// Return to CPAM0002 analysis and verify the updated field is persisted
cy.visit('analysis/CPAM0002');
cy.wait('@analysisLoad');
cy.get('[href="#Brief"]').click();
cy.get('#Brief > div > [data-test="Phenotype"] > .section-content > [data-test="value-row"]')
.should('contain', 'test');
cy.get('.rosalution-logo').click();
cy.get('.analysis-card').first().click();
cy.get('#Brief > div > [data-test="Phenotype"] > .section-content > [data-test="value-row"]')
.should('contain', 'test');
cy.get('#Brief > div > [data-test="Nominator"] > .section-content > [data-test="value-row"]')
.should('contain', 'Dr. Person One');
cy.get('@phenotypeField').contains('test').should('exist');
});
});

0 comments on commit c5ef145

Please sign in to comment.