Skip to content

Commit

Permalink
Merge pull request #882 from Louifine/feat/add-tests
Browse files Browse the repository at this point in the history
[feat] enhance project tutorial tests and add observer role functiona…
  • Loading branch information
glibersat authored Jan 9, 2025
2 parents b4b9cca + decbf81 commit f31ee5e
Show file tree
Hide file tree
Showing 9 changed files with 399 additions and 219 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import projects from '../../../fixtures/projects/projects.json';

const currentProject = projects[1];
const currentProject2 = projects[25];

describe('I can follow the project tutorial', () => {
it('displays the launcher tutorial on the overview window', () => {
it('displays the launcher tutorial on the overview window as regional advisor', () => {
cy.login('conseiller1');
cy.visit(`/project/${currentProject.pk}`);
cy.get('[data-test-id="tutorial-project-launcher"]').should.exist;
Expand All @@ -19,7 +20,7 @@ describe('I can follow the project tutorial', () => {
});

it('fills up the tutorial and tutorial disappear', () => {
cy.login('jeannot');
cy.login('conseiller2');
cy.visit(`/project/2`);

cy.get('[data-test-id="button-join-as-advisor"]').click();
Expand All @@ -31,4 +32,31 @@ describe('I can follow the project tutorial', () => {
cy.get('.introjs-skipbutton').click();
cy.get('[data-test-id="project-overview-tutorial"]').should('not.exist');
});


it('displays the launcher tutorial on the overview window as advisor', () => {
cy.login('conseiller3');
cy.visit(`/project/${currentProject.pk}`);
cy.becomeAdvisor(currentProject.pk);
cy.get('[data-test-id="tutorial-project-launcher"]').should.exist;
});

it('displays the launcher tutorial on the overview window as observer', () => {
cy.login('staff');
cy.visit(`/project/${currentProject.pk}`);
cy.becomeObserver(currentProject.pk);
cy.get('[data-test-id="tutorial-project-launcher"]').should.exist;
});

it('displays the launcher tutorial on the overview window as regional advisor not on the right region ', () => {
cy.login('conseiller4');
cy.visit(`/project/${currentProject2.pk}`);
cy.get('[data-test-id="tutorial-project-launcher"]').should('not.exist');
});

it('displays the launcher tutorial on the overview window as regional advisor not on the right region but with an invite accepted', () => {
cy.login('conseiller5');
cy.visit(`/project/${currentProject2.pk}`);
cy.get('[data-test-id="tutorial-project-launcher"]').should.exist;
});
});
30 changes: 30 additions & 0 deletions frontend_tests/cypress/fixtures/profiles/profiles.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,35 @@
],
"sites" : [1]
}
},
{
"model": "home.userprofile",
"pk": 12,
"fields": {
"user": 12,
"organization": 2,
"phone_no": "",
"organization_position": null,
"deleted": null,
"departments": [
42
],
"sites" : [1]
}
},
{
"model": "home.userprofile",
"pk": 13,
"fields": {
"user": 13,
"organization": 2,
"phone_no": "",
"organization_position": null,
"deleted": null,
"departments": [
42
],
"sites" : [1]
}
}
]
16 changes: 16 additions & 0 deletions frontend_tests/cypress/fixtures/projects/invites.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[
{
"model": "invites.invite",
"pk": "774e9444-ff9b-43e3-b26f-c91421c5ddc7",
"fields": {
"created_on": "2022-09-01T08:58:56.513Z",
"accepted_on": "2022-09-01T08:58:56.513Z",
"email": "[email protected]",
"message": "viens donc adviser ce projet",
"role": "OBSERVER",
"inviter_id": 1,
"project_id": 26,
"site_id": 1
}
}
]
28 changes: 28 additions & 0 deletions frontend_tests/cypress/fixtures/projects/projects.json
Original file line number Diff line number Diff line change
Expand Up @@ -688,5 +688,33 @@
"impediments": "",
"deleted": null
}
},
{
"model": "projects.project",
"pk": 26,
"fields": {
"submitted_by": 5,
"ro_key": "af8facec96f14d0fbcf854cc26c37caa",
"last_name": "John",
"first_name": "Doe",
"publish_to_cartofriches": false,
"exclude_stats": true,
"muted": false,
"org_name": "Frichti",
"created_on": "2022-03-29T14:31:39Z",
"updated_on": "2022-09-19T13:08:07.795Z",
"tags": "",
"name": "test region",
"phone": "01 01 01 01 01",
"description": "projet sur une commune d'un autre département que le 42, à savoir celui des conseillers",
"advisors_note": "Quels financements existent pour ouvrir une friterie traditionnelle mais dans un food truck, le tout sur une ancienne usine de draperie ?\r\nedit de PR@beta",
"advisors_note_on": "2022-08-29T14:51:12Z",
"advisors_note_by": 1,
"location": "861 chemin rural 53",
"commune": 3,
"impediments": "",
"deleted": null,
"sites": [1]
}
}
]
10 changes: 10 additions & 0 deletions frontend_tests/cypress/fixtures/projects/projectsMembers.json
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,14 @@
"site": 1
}
}
,
{
"model": "projects.projectswitchtender",
"pk": 23,
"fields": {
"switchtender": 13,
"project": 26,
"site": 1
}
}
]
10 changes: 10 additions & 0 deletions frontend_tests/cypress/fixtures/projects/projectsSites.json
Original file line number Diff line number Diff line change
Expand Up @@ -278,5 +278,15 @@
"project_id": 25,
"site_id": 1
}
},
{
"pk": 29,
"model": "projects.projectsite",
"fields": {
"status": "TO_PROCESS",
"is_origin": true,
"project_id": 26,
"site_id": 1
}
}
]
Loading

0 comments on commit f31ee5e

Please sign in to comment.