Skip to content

Commit 04965f9

Browse files
committed
Merge branch 'develop'
2 parents 1a5aff6 + 519ad50 commit 04965f9

37 files changed

Lines changed: 1220 additions & 691 deletions
Lines changed: 310 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,310 @@
1+
describe('I can create a new project as a new user', () => {
2+
const projectInfo = {
3+
name: 'Test Project',
4+
location: '123 Test Street',
5+
postcode: 42424,
6+
insee: 42123,
7+
commune: 'commune de test',
8+
description: 'This is a test project description',
9+
email: `${Date.now()}@example.com`,
10+
fixedEmail: 'test2@example.com',
11+
};
12+
13+
const signupInfo = {
14+
first_name: 'Test',
15+
last_name: 'User',
16+
organization: 'Test Organization',
17+
organization_position: 'Test Position',
18+
phone_no: '0102030405',
19+
password1: 'Testpassword123',
20+
password2: 'Testpassword123',
21+
};
22+
23+
const alreadyExistingUserInfo = {
24+
email: projectInfo.email,
25+
password: 'Testpassword123',
26+
};
27+
28+
it('goes through the complete onboarding process', () => {
29+
// Visit home page and click on need help button
30+
cy.visit('/');
31+
cy.get('[data-test-id="button-need-help"]')
32+
.contains('Solliciter')
33+
.click({ force: true });
34+
35+
// Land on onboarding/project page
36+
cy.url().should('include', '/onboarding/project');
37+
38+
// Fill project form
39+
cy.get('#id_name')
40+
.should('not.have.class', 'fr-input--error')
41+
.type(projectInfo.name, { delay: 0 })
42+
.should('have.value', projectInfo.name)
43+
.should('have.class', 'fr-input--valid');
44+
45+
cy.get('#id_location')
46+
.should('not.have.class', 'fr-input--error')
47+
.type(projectInfo.location, { delay: 0 })
48+
.should('have.value', projectInfo.location)
49+
.should('have.class', 'fr-input--valid');
50+
51+
cy.get('[data-test-id="input-postcode"]')
52+
.type(projectInfo.postcode, { delay: 0 })
53+
.should('have.value', projectInfo.postcode)
54+
.parent()
55+
.should('have.class', 'fr-input-group--valid');
56+
57+
cy.get('[data-test-id="select-city"]')
58+
.should('not.have.class', 'fr-select-group--error')
59+
.focus();
60+
61+
cy.get('[data-test-id="select-city"]')
62+
.should('contain.text', projectInfo.commune)
63+
.should('have.value', projectInfo.insee)
64+
.parent()
65+
.should('have.class', 'fr-select-group--valid');
66+
67+
cy.get('#id_description')
68+
.should('not.have.class', 'fr-input--error')
69+
.type(projectInfo.description, { delay: 0 })
70+
.should('have.value', projectInfo.description)
71+
.should('have.class', 'fr-input--valid');
72+
73+
cy.get('#id_email')
74+
.should('not.have.class', 'fr-input--error')
75+
.type(projectInfo.email, { delay: 0 })
76+
.should('have.value', projectInfo.email)
77+
.should('have.class', 'fr-input--valid');
78+
79+
// Handle captcha
80+
cy.document().then((doc) => {
81+
const iframe = doc.getElementById('id_captcha').querySelector('iframe');
82+
const innerDoc = iframe.contentDocument || iframe.contentWindow.document;
83+
innerDoc.querySelector('.recaptcha-checkbox').click();
84+
cy.wait(400);
85+
});
86+
87+
// Submit project form
88+
cy.get('button[type="submit"]').click();
89+
90+
// Land on onboarding/signup page
91+
cy.url().should('include', '/onboarding/signup');
92+
93+
// Fill signup form
94+
cy.get('[name=first_name]')
95+
.type(signupInfo.first_name, { delay: 0 })
96+
.should('have.value', signupInfo.first_name);
97+
98+
cy.get('[name=last_name]')
99+
.type(signupInfo.last_name, { delay: 0 })
100+
.should('have.value', signupInfo.last_name);
101+
102+
cy.get('[name=org_name]')
103+
.type(signupInfo.organization, { delay: 0 })
104+
.should('have.value', signupInfo.organization);
105+
106+
cy.get('[name=role]')
107+
.type(signupInfo.organization_position, { delay: 0 })
108+
.should('have.value', signupInfo.organization_position);
109+
110+
cy.get('[name=phone]')
111+
.type(signupInfo.phone_no, { delay: 0 })
112+
.should('have.value', signupInfo.phone_no);
113+
114+
cy.get('[name=password]')
115+
.type(signupInfo.password1, { delay: 0 })
116+
.should('have.value', signupInfo.password1);
117+
118+
// Submit signup form
119+
cy.get('[type=submit]').click();
120+
121+
// Land on onboarding/summary page
122+
cy.url().should('include', '/onboarding/summary');
123+
});
124+
125+
it('goes through the onboarding process but stop at signup page', () => {
126+
// Visit home page and click on need help button
127+
cy.visit('/');
128+
cy.get('[data-test-id="button-need-help"]')
129+
.contains('Solliciter')
130+
.click({ force: true });
131+
132+
// Land on onboarding/project page
133+
cy.url().should('include', '/onboarding/project');
134+
135+
// Fill project form
136+
cy.get('#id_name')
137+
.should('not.have.class', 'fr-input--error')
138+
.type(projectInfo.name, { delay: 0 })
139+
.should('have.value', projectInfo.name)
140+
.should('have.class', 'fr-input--valid');
141+
142+
cy.get('#id_location')
143+
.should('not.have.class', 'fr-input--error')
144+
.type(projectInfo.location, { delay: 0 })
145+
.should('have.value', projectInfo.location)
146+
.should('have.class', 'fr-input--valid');
147+
148+
cy.get('[data-test-id="input-postcode"]')
149+
.type(projectInfo.postcode, { delay: 0 })
150+
.should('have.value', projectInfo.postcode)
151+
.parent()
152+
.should('have.class', 'fr-input-group--valid');
153+
154+
cy.get('[data-test-id="select-city"]')
155+
.should('not.have.class', 'fr-select-group--error')
156+
.focus();
157+
158+
cy.get('[data-test-id="select-city"]')
159+
.should('contain.text', projectInfo.commune)
160+
.should('have.value', projectInfo.insee)
161+
.parent()
162+
.should('have.class', 'fr-select-group--valid');
163+
164+
cy.get('#id_description')
165+
.should('not.have.class', 'fr-input--error')
166+
.type(projectInfo.description, { delay: 0 })
167+
.should('have.value', projectInfo.description)
168+
.should('have.class', 'fr-input--valid');
169+
170+
cy.get('#id_email')
171+
.should('not.have.class', 'fr-input--error')
172+
.type(projectInfo.fixedEmail, { delay: 0 })
173+
.should('have.value', projectInfo.fixedEmail)
174+
.should('have.class', 'fr-input--valid');
175+
176+
// Handle captcha
177+
cy.document().then((doc) => {
178+
const iframe = doc.getElementById('id_captcha').querySelector('iframe');
179+
const innerDoc = iframe.contentDocument || iframe.contentWindow.document;
180+
innerDoc.querySelector('.recaptcha-checkbox').click();
181+
cy.wait(400);
182+
});
183+
184+
// Submit project form
185+
cy.get('button[type="submit"]').click();
186+
187+
// Land on onboarding/signup page
188+
cy.url().should('include', '/onboarding/signup');
189+
190+
// Restart at project page
191+
cy.visit('/onboarding/project');
192+
193+
cy.get('[data-cy="found-email-onboarding"]').should(
194+
'contain.text',
195+
projectInfo.fixedEmail
196+
);
197+
198+
cy.get('[data-cy="continue-onboarding"]').click();
199+
200+
// Fill signup form
201+
cy.get('[name=first_name]')
202+
.type(signupInfo.first_name, { delay: 0 })
203+
.should('have.value', signupInfo.first_name);
204+
205+
cy.get('[name=last_name]')
206+
.type(signupInfo.last_name, { delay: 0 })
207+
.should('have.value', signupInfo.last_name);
208+
209+
cy.get('[name=org_name]')
210+
.type(signupInfo.organization, { delay: 0 })
211+
.should('have.value', signupInfo.organization);
212+
213+
cy.get('[name=role]')
214+
.type(signupInfo.organization_position, { delay: 0 })
215+
.should('have.value', signupInfo.organization_position);
216+
217+
cy.get('[name=phone]')
218+
.type(signupInfo.phone_no, { delay: 0 })
219+
.should('have.value', signupInfo.phone_no);
220+
221+
cy.get('[name=password]')
222+
.type(signupInfo.password1, { delay: 0 })
223+
.should('have.value', signupInfo.password1);
224+
225+
// Submit signup form
226+
cy.get('[type=submit]').click();
227+
228+
// Land on onboarding/summary page
229+
cy.url().should('include', '/onboarding/summary');
230+
});
231+
232+
it('goes through the complete onboarding process with already existing user', () => {
233+
// Visit home page and click on need help button
234+
cy.visit('/');
235+
cy.get('[data-test-id="button-need-help"]')
236+
.contains('Solliciter')
237+
.click({ force: true });
238+
239+
// Land on onboarding/project page
240+
cy.url().should('include', '/onboarding/project');
241+
242+
// Fill project form
243+
cy.get('#id_name')
244+
.should('not.have.class', 'fr-input--error')
245+
.type(projectInfo.name, { delay: 0 })
246+
.should('have.value', projectInfo.name)
247+
.should('have.class', 'fr-input--valid');
248+
249+
cy.get('#id_location')
250+
.should('not.have.class', 'fr-input--error')
251+
.type(projectInfo.location, { delay: 0 })
252+
.should('have.value', projectInfo.location)
253+
.should('have.class', 'fr-input--valid');
254+
255+
cy.get('[data-test-id="input-postcode"]')
256+
.type(projectInfo.postcode, { delay: 0 })
257+
.should('have.value', projectInfo.postcode)
258+
.parent()
259+
.should('have.class', 'fr-input-group--valid');
260+
261+
cy.get('[data-test-id="select-city"]')
262+
.should('not.have.class', 'fr-select-group--error')
263+
.focus();
264+
265+
cy.get('[data-test-id="select-city"]')
266+
.should('contain.text', projectInfo.commune)
267+
.should('have.value', projectInfo.insee)
268+
.parent()
269+
.should('have.class', 'fr-select-group--valid');
270+
271+
cy.get('#id_description')
272+
.should('not.have.class', 'fr-input--error')
273+
.type(projectInfo.description, { delay: 0 })
274+
.should('have.value', projectInfo.description)
275+
.should('have.class', 'fr-input--valid');
276+
277+
cy.get('#id_email')
278+
.should('not.have.class', 'fr-input--error')
279+
.type(projectInfo.email, { delay: 0 })
280+
.should('have.value', projectInfo.email)
281+
.should('have.class', 'fr-input--valid');
282+
283+
// Handle captcha
284+
cy.document().then((doc) => {
285+
const iframe = doc.getElementById('id_captcha').querySelector('iframe');
286+
const innerDoc = iframe.contentDocument || iframe.contentWindow.document;
287+
innerDoc.querySelector('.recaptcha-checkbox').click();
288+
cy.wait(400);
289+
});
290+
291+
// Submit project form
292+
cy.get('button[type="submit"]').click();
293+
294+
// Land on onboarding/signup page
295+
cy.url().should('include', '/onboarding/signin');
296+
297+
// Fill signup form
298+
cy.get('[name=login]').should('have.value', alreadyExistingUserInfo.email);
299+
300+
cy.get('[name=password]')
301+
.type(alreadyExistingUserInfo.password, { delay: 0 })
302+
.should('have.value', alreadyExistingUserInfo.password);
303+
304+
// Submit signup form
305+
cy.get('[type=submit]').click();
306+
307+
// Land on onboarding/summary page
308+
cy.url().should('include', '/onboarding/summary');
309+
});
310+
});

frontend_tests/cypress/e2e/project/onboarding/canCreateAProjectIfConnected.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
describe("I can create a project if i'm connected @critical", () => {
1+
describe("I can create a project if i'm connected @deposer-projet @critical", () => {
22
beforeEach(() => {
33
cy.login('collectivité1');
44
});

frontend_tests/cypress/support/commands.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,14 @@ Cypress.Commands.add('createProject', (label, objProject = project) => {
192192
.should('have.value', objProject.description || project.description)
193193
.should('have.class', 'fr-input--valid');
194194

195+
// Handle captcha
196+
cy.document().then((doc) => {
197+
const iframe = doc.getElementById('id_captcha').querySelector('iframe');
198+
const innerDoc = iframe.contentDocument || iframe.contentWindow.document;
199+
innerDoc.querySelector('.recaptcha-checkbox').click();
200+
cy.wait(400);
201+
});
202+
195203
cy.get('button[type="submit"]').click().should('be.disabled');
196204

197205
cy.url().should('include', '/onboarding/summary');
@@ -300,7 +308,7 @@ Cypress.Commands.add(
300308

301309
cy.url().should('include', '/actions');
302310

303-
if(!withResource) {
311+
if (!withResource) {
304312
cy.contains(`${label}`);
305313
} else {
306314
cy.contains(currentResource.fields.title);

recoco/apps/dsrc/templates/dsrc/core/blocks/buttons/button_group.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@
88
{% endif %}
99
{% if form.helper.action_button.submit %}
1010
<li class="flex-grow-1">
11-
<button type="submit"
12-
class="fr-btn dsrc-color--primary w-100"
13-
x-on:click="validate"
14-
:disabled="!isFormEdited && !canSubmit"
15-
{% if disabled %}disabled=""{% endif %}>{{ form.helper.action_button.submit.label }}</button>
11+
<button type="submit" class="fr-btn dsrc-color--primary w-100" x-on:click="validate" :disabled="!isFormEdited || !canSubmit || errors.length > 0"
12+
{% if disabled %}disabled=""{% endif %}
13+
>{{ form.helper.action_button.submit.label }}</button>
1614
</li>
1715
{% endif %}
1816
</ul>

recoco/apps/home/templates/home/home.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ <h1 class="fr-h1">{{ request.site.name }}</h1>
3333
<ul class="fr-btns-group fr-btns-group--inline" data-test-id="intro-uv">
3434
<li>
3535
{% if user.is_authenticated %}
36-
<a href="{% url 'onboarding-project' %}"
36+
<a href="{% url 'onboarding' %}?prefill=true"
3737
class="fr-btn fr-text--xl"
3838
data-test-id="button-need-help">Solliciter {{ request.site.name }}</a>
3939
{% else %}
40-
<button class="fr-btn fr-text--xl"
41-
data-fr-opened="false"
42-
aria-controls="onboarding-modal">Solliciter {{ request.site.name }}</button>
40+
<a href="{% url 'onboarding-project' %}"
41+
class="fr-btn fr-text--xl"
42+
data-test-id="button-need-help">Solliciter {{ request.site.name }}</a>
4343
{% endif %}
4444
</li>
4545
</ul>
@@ -105,7 +105,6 @@ <h4 class="imiteH6">Tous alimentent l’évolution du dossier et des besoins</h4
105105
</div>
106106
</div>
107107
<div class="border-bottom"></div>
108-
{% include "home/onboarding/onboarding-modal.html" with form=onboarding_modal_form %}
109108
{% endblock content %}
110109
{% block footer %}
111110
<div class="row justify-content-center" id="footer">{% include "footer/footer.html" %}</div>

0 commit comments

Comments
 (0)