Skip to content

Commit

Permalink
Feat: Add destination check to resolver (#3345)
Browse files Browse the repository at this point in the history
* feat: improve route resolver to import/:destinations with non existing destination
* feat: add frontend test to route resolver ipdate
  • Loading branch information
edelclaux authored Feb 3, 2025
1 parent d655a53 commit 33cbc8a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
9 changes: 9 additions & 0 deletions frontend/cypress/e2e/import/navigation-module-access-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ describe(`Should be able to acces the import module`, () => {
cy.visitImport();
cy.checkCurrentPageIsImport();
});

it('Should be able to visit synthese upload', () => {
cy.visit('/#/import/synthese/process/upload');
});

it('Should not be able to visit bad-destination upload', () => {
cy.visit('/#/import/bad-destination/process/upload');
cy.checkCurrentPageIsImport();
});
});
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Cypress.Commands.add('checkCurrentPageIsImportUpload', (destination) => {
// Check the url
cy.url().should(
'be.equal',
`${Cypress.config('baseUrl')}/#/import/${destination}/process/upload`
);
// Check that the main component is there
cy.get('[data-qa="import-new-upload-file"]').should('exist');
});
1 change: 1 addition & 0 deletions frontend/cypress/support/import/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import './backToImportList';
import './checkCellValueExistsInColumn';
import './checkCurrentPageIsImport';
import './checkCurrentPageIsImportUpload';
import './checkImportListSize';
import './configureImportContentMapping';
import './configureImportFieldMapping';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ export class ImportProcessResolver implements Resolve<Import> {
let step: Step = route.data.step;
let destination: string = route.params['destination'];

// Check that import in this destination is authorized
const fetchDestination = this.ds.getDestinations('C');
fetchDestination.subscribe((destinations) => {
if(!destinations.find(item => item?.code == destination)){
this.router.navigate([this.config.IMPORT.MODULE_URL]);
return EMPTY;
}
});

this.ds.setDestination(destination);
if (step == Step.Upload && route.params.id_import === undefined) {
// creating new import
Expand Down

0 comments on commit 33cbc8a

Please sign in to comment.