Skip to content

Commit 34636cf

Browse files
committed
API Entreprise start: show disclaimer if no valid editor
1 parent e4cc2f3 commit 34636cf

File tree

3 files changed

+87
-25
lines changed

3 files changed

+87
-25
lines changed

app/javascript/controllers/choose_authorization_request_form_controller.js

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Controller } from '@hotwired/stimulus'
22

33
export default class extends Controller {
4-
static targets = ['editors', 'editor', 'forms', 'form', 'noTeamDisclaimer']
4+
static targets = ['editors', 'editor', 'forms', 'form', 'noTeamDisclaimer', 'noEditorDisclaimer']
55
static values = {
66
editors: Array,
77
targetUseCase: String
@@ -35,7 +35,7 @@ export default class extends Controller {
3535
this.formTargets.forEach((form) => {
3636
const formTags = this._getFormTags(form)
3737

38-
if (formTags.includes(editor) || formTags.includes('default')) {
38+
if (formTags.includes(editor)) {
3939
form.classList.remove('fr-hidden')
4040
} else {
4141
form.classList.add('fr-hidden')
@@ -46,7 +46,11 @@ export default class extends Controller {
4646
this._hideOtherUseCaseForms()
4747
}
4848

49-
this._showFormsBlock()
49+
if (this._noForm()) {
50+
this._showNoEditorDisclaimer()
51+
} else {
52+
this._showFormsBlock()
53+
}
5054
}
5155

5256
_getFormTags (form) {
@@ -94,12 +98,24 @@ export default class extends Controller {
9498
})
9599
this.formsTarget.classList.add('fr-hidden')
96100
this.noTeamDisclaimerTarget.classList.add('fr-hidden')
101+
this.noEditorDisclaimerTarget.classList.add('fr-hidden')
97102
}
98103

99104
_showNoTeamDisclaimer () {
100105
this.noTeamDisclaimerTarget.classList.remove('fr-hidden')
101106
}
102107

108+
_showNoEditorDisclaimer () {
109+
this.noEditorDisclaimerTarget.classList.remove('fr-hidden')
110+
this.formsTarget.classList.add('fr-hidden')
111+
}
112+
113+
_noForm () {
114+
return this.formTargets.every((form) => {
115+
return form.classList.contains('fr-hidden')
116+
})
117+
}
118+
103119
_hideOtherUseCaseForms () {
104120
this.formTargets.forEach((form) => {
105121
const formTags = this._getFormTags(form)

app/views/authorization_request_forms/index/_api_entreprise.html.erb

+15-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
</div>
5757
</fieldset>
5858

59-
<div data-choose-authorization-request-form-target="editors" id="editor-list" class="fr-hidden">
59+
<div data-choose-authorization-request-form-target="editors" id="editors-list" class="fr-hidden">
6060
<h3>
6161
Quel est votre éditeur de logiciel ?
6262
</h3>
@@ -110,6 +110,20 @@
110110
<br />
111111

112112
🔎 L’API Entreprise s’utilise au travers d’un logiciel métier, comme par exemple un profil acheteur pour les marchés publics. Si vous collectez et traitez les données à la main, vous n’avez probablement pas un logiciel dédié aux démarches.
113+
114+
<br />
115+
116+
Vous pouvez utiliser l'espace agent sur l'annuaires des entreprises.
117+
</p>
118+
</div>
119+
120+
<div data-choose-authorization-request-form-target="noEditorDisclaimer" id="no-editor-disclaimer" class="fr-bg-alt-blue-france fr-hidden">
121+
<p class="center fr-px-5w fr-py-1w">
122+
Vous êtes éligible mais votre éditeur ne semble pas utiliser l'API Entreprise, ou son intégration ne nécessite aucune action de votre part.
123+
124+
<br />
125+
126+
Si votre éditeur n'intégre pas API Entreprise, vous pouvez utiliser l'espace agent sur l'annuaires des entreprises.
113127
</p>
114128
</div>
115129
</div>

spec/features/authorization_requests/api_entreprise_spec.rb

+53-21
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,75 @@
55
sign_in(user)
66
end
77

8-
describe 'when we do not have a use_case in the url' do
9-
before do
10-
visit choose_authorization_request_form_path(authorization_definition_id: 'api_entreprise')
8+
describe 'use case filtering' do
9+
describe 'when we do not have a use_case in the url' do
10+
before do
11+
visit choose_authorization_request_form_path(authorization_definition_id: 'api_entreprise')
12+
end
13+
14+
context 'when we choose internal team' do
15+
before do
16+
find('label', text: 'Vos développeurs').click
17+
end
18+
19+
it 'shows more forms with the default one' do
20+
expect(all('.authorization-request-form-card').count).to be > 2
21+
22+
expect(page).to have_css('#authorization_request_form_api-entreprise')
23+
expect(page).to have_css('#authorization_request_form_api-entreprise-marches-publics')
24+
expect(page).to have_css('#authorization_request_form_api-entreprise-aides-publiques')
25+
end
26+
end
1127
end
1228

13-
context 'when we choose internal team' do
29+
describe 'when we have a use_case in the url' do
30+
let(:use_case) { 'marches_publics' }
31+
1432
before do
15-
find('label', text: 'Vos développeurs').click
33+
visit choose_authorization_request_form_path(authorization_definition_id: 'api_entreprise', use_case:)
1634
end
1735

18-
it 'shows more forms with the default one' do
19-
expect(all('.authorization-request-form-card').count).to be > 2
36+
context 'when we choose internal team' do
37+
before do
38+
find('label', text: 'Vos développeurs').click
39+
end
40+
41+
it 'shows only this form with the default one' do
42+
expect(page).to have_css('.authorization-request-form-card', count: 2)
2043

21-
expect(page).to have_css('#authorization_request_form_api-entreprise')
22-
expect(page).to have_css('#authorization_request_form_api-entreprise-marches-publics')
23-
expect(page).to have_css('#authorization_request_form_api-entreprise-aides-publiques')
44+
expect(page).to have_css('#authorization_request_form_api-entreprise')
45+
expect(page).to have_css('#authorization_request_form_api-entreprise-marches-publics')
46+
end
2447
end
2548
end
2649
end
2750

28-
describe 'when we have a use_case in the url' do
29-
let(:use_case) { 'marches_publics' }
30-
51+
describe 'no available editor' do
3152
before do
32-
visit choose_authorization_request_form_path(authorization_definition_id: 'api_entreprise', use_case:)
53+
visit choose_authorization_request_form_path(authorization_definition_id: 'api_entreprise')
54+
55+
find('label', text: 'Votre éditeur').click
56+
57+
within('#editors-list') do
58+
find('label', text: editor).click
59+
end
3360
end
3461

35-
context 'when we choose internal team' do
36-
before do
37-
find('label', text: 'Vos développeurs').click
62+
context 'when editor has forms' do
63+
let(:editor) { 'MGDIS' }
64+
65+
it 'shows editors forms' do
66+
expect(page).to have_css('.authorization-request-form-card', count: 1)
67+
68+
expect(page).to have_css('#authorization_request_form_api-entreprise-mgdis')
3869
end
70+
end
3971

40-
it 'shows only this form with the default one' do
41-
expect(page).to have_css('.authorization-request-form-card', count: 2)
72+
context 'when editor has no forms (choose none)' do
73+
let(:editor) { 'Aucun' }
4274

43-
expect(page).to have_css('#authorization_request_form_api-entreprise')
44-
expect(page).to have_css('#authorization_request_form_api-entreprise-marches-publics')
75+
it 'shows no forms' do
76+
expect(page).to have_css('#no-editor-disclaimer')
4577
end
4678
end
4779
end

0 commit comments

Comments
 (0)