|
5 | 5 | sign_in(user)
|
6 | 6 | end
|
7 | 7 |
|
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 |
11 | 27 | end
|
12 | 28 |
|
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 | + |
14 | 32 | before do
|
15 |
| - find('label', text: 'Vos développeurs').click |
| 33 | + visit choose_authorization_request_form_path(authorization_definition_id: 'api_entreprise', use_case:) |
16 | 34 | end
|
17 | 35 |
|
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) |
20 | 43 |
|
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 |
24 | 47 | end
|
25 | 48 | end
|
26 | 49 | end
|
27 | 50 |
|
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 |
31 | 52 | 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 |
33 | 60 | end
|
34 | 61 |
|
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') |
38 | 69 | end
|
| 70 | + end |
39 | 71 |
|
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' } |
42 | 74 |
|
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') |
45 | 77 | end
|
46 | 78 | end
|
47 | 79 | end
|
|
0 commit comments