From 2c4457fccc2c3dc4f28674234a8e0e7dceacccc0 Mon Sep 17 00:00:00 2001 From: Bernardo Anderson Date: Mon, 28 Jul 2025 13:19:49 -0500 Subject: [PATCH] CP-9771 - Update specs --- spec/factories/templates.rb | 2 +- spec/system/signing_form_spec.rb | 207 +------------------------------ 2 files changed, 3 insertions(+), 206 deletions(-) diff --git a/spec/factories/templates.rb b/spec/factories/templates.rb index 2091821c..eb0ea8ba 100644 --- a/spec/factories/templates.rb +++ b/spec/factories/templates.rb @@ -11,7 +11,7 @@ FactoryBot.define do submitter_count { 1 } attachment_count { 1 } only_field_types do - %w[text date checkbox radio signature number multiple select initials image file stamp cells phone payment] + %w[text date checkbox radio signature multiple select phone payment] end except_field_types { [] } private_access_user { nil } diff --git a/spec/system/signing_form_spec.rb b/spec/system/signing_form_spec.rb index 83c1b30b..6dd72138 100644 --- a/spec/system/signing_form_spec.rb +++ b/spec/system/signing_form_spec.rb @@ -6,7 +6,7 @@ RSpec.describe 'Signing Form' do context 'when the template form link is opened' do let(:template) do - create(:template, shared_link: true, account:, author:, except_field_types: %w[phone payment stamp]) + create(:template, shared_link: true, account:, author:, except_field_types: %w[phone payment]) end before do @@ -45,9 +45,6 @@ RSpec.describe 'Signing Form' do draw_canvas click_button 'next' - # Number step - fill_in 'House number', with: '123' - click_button 'next' # Multiple choice step %w[Red Blue].each { |color| check color } @@ -57,22 +54,6 @@ RSpec.describe 'Signing Form' do select 'Male', from: 'Gender' click_button 'next' - # Initials step - draw_canvas - click_button 'next' - - # Image step - find('#dropzone').click - find('input[type="file"]', visible: false).attach_file(Rails.root.join('spec/fixtures/sample-image.png')) - click_button 'next' - - # File step - find('#dropzone').click - find('input[type="file"]', visible: false).attach_file(Rails.root.join('spec/fixtures/sample-document.pdf')) - click_button 'next' - - # Cell step - fill_in 'Cell code', with: '123' click_on 'Complete' expect(page).to have_button('Download') @@ -92,18 +73,13 @@ RSpec.describe 'Signing Form' do expect(field_value(submitter, 'Do you agree?')).to be_truthy expect(field_value(submitter, 'First child')).to eq 'Boy' expect(field_value(submitter, 'Signature')).to be_present - expect(field_value(submitter, 'House number')).to eq 123 expect(field_value(submitter, 'Colors')).to contain_exactly('Red', 'Blue') expect(field_value(submitter, 'Gender')).to eq 'Male' - expect(field_value(submitter, 'Initials')).to be_present - expect(field_value(submitter, 'Avatar')).to be_present - expect(field_value(submitter, 'Attachment')).to be_present - expect(field_value(submitter, 'Cell code')).to eq '123' end end context 'when the submitter form link is opened' do - let(:template) { create(:template, account:, author:, except_field_types: %w[phone payment stamp]) } + let(:template) { create(:template, account:, author:, except_field_types: %w[phone payment]) } let(:submission) { create(:submission, template:) } let(:submitter) do create(:submitter, submission:, uuid: template.submitters.first['uuid'], account:, email: 'robin@example.com') @@ -134,9 +110,6 @@ RSpec.describe 'Signing Form' do draw_canvas click_button 'next' - # Number step - fill_in 'House number', with: '123' - click_button 'next' # Multiple choice step %w[Red Blue].each { |color| check color } @@ -146,22 +119,6 @@ RSpec.describe 'Signing Form' do select 'Male', from: 'Gender' click_button 'next' - # Initials step - draw_canvas - click_button 'next' - - # Image step - find('#dropzone').click - find('input[type="file"]', visible: false).attach_file(Rails.root.join('spec/fixtures/sample-image.png')) - click_button 'next' - - # File step - find('#dropzone').click - find('input[type="file"]', visible: false).attach_file(Rails.root.join('spec/fixtures/sample-document.pdf')) - click_button 'next' - - # Cell step - fill_in 'Cell code', with: '123' click_on 'Complete' expect(page).to have_button('Download') @@ -181,13 +138,8 @@ RSpec.describe 'Signing Form' do expect(field_value(submitter, 'Do you agree?')).to be_truthy expect(field_value(submitter, 'First child')).to eq 'Boy' expect(field_value(submitter, 'Signature')).to be_present - expect(field_value(submitter, 'House number')).to eq 123 expect(field_value(submitter, 'Colors')).to contain_exactly('Red', 'Blue') expect(field_value(submitter, 'Gender')).to eq 'Male' - expect(field_value(submitter, 'Initials')).to be_present - expect(field_value(submitter, 'Avatar')).to be_present - expect(field_value(submitter, 'Attachment')).to be_present - expect(field_value(submitter, 'Cell code')).to eq '123' end end @@ -390,32 +342,6 @@ RSpec.describe 'Signing Form' do end end - context 'when the number step' do - let(:template) { create(:template, account:, author:, only_field_types: %w[number]) } - let(:submission) { create(:submission, template:) } - let(:submitter) do - create(:submitter, submission:, uuid: template.submitters.first['uuid'], account:) - end - - it 'completes the form if the field is filled' do - visit submit_form_path(slug: submitter.slug) - - input = find_field('House number') - - expect(input[:required]).to be_truthy - expect(input[:placeholder]).to eq 'Type here...' - - fill_in 'House number', with: '4' - click_button 'Complete' - - expect(page).to have_content('Form has been completed!') - - submitter.reload - - expect(submitter.completed_at).to be_present - expect(field_value(submitter, 'House number')).to eq 4 - end - end context 'when the multiple choice step' do let(:template) { create(:template, account:, author:, only_field_types: %w[multiple]) } @@ -462,138 +388,9 @@ RSpec.describe 'Signing Form' do end end - context 'when the initials step' do - let(:template) { create(:template, account:, author:, only_field_types: %w[initials]) } - let(:submission) { create(:submission, template:) } - let(:submitter) do - create(:submitter, submission:, uuid: template.submitters.first['uuid'], account:) - end - - it 'completes the form if the canvas is typed' do - visit submit_form_path(slug: submitter.slug) - - find('#expand_form_button').click - fill_in 'initials_text_input', with: 'John Doe' - click_button 'Complete' - - expect(page).to have_content('Document has been signed!') - - submitter.reload - - expect(submitter.completed_at).to be_present - expect(field_value(submitter, 'Initials')).to be_present - end - - it 'completes the form if the canvas is drawn' do - visit submit_form_path(slug: submitter.slug) - - find('#expand_form_button').click - click_link 'Draw' - draw_canvas - click_button 'Complete' - - expect(page).to have_content('Document has been signed!') - - submitter.reload - - expect(submitter.completed_at).to be_present - expect(field_value(submitter, 'Initials')).to be_present - end - - it 'completes the form if the initials is uploaded' do - visit submit_form_path(slug: submitter.slug) - - find('#expand_form_button').click - find('span[data-tip="Click to upload"]').click - find('input[type="file"]', visible: false).attach_file(Rails.root.join('spec/fixtures/sample-image.png')) - - sleep 0.1 - - click_button 'Complete' - - expect(page).to have_content('Document has been signed!') - - submitter.reload - - expect(submitter.completed_at).to be_present - expect(field_value(submitter, 'Initials')).to be_present - end - end - - context 'when the image step' do - let(:template) { create(:template, account:, author:, only_field_types: %w[image]) } - let(:submission) { create(:submission, template:) } - let(:submitter) do - create(:submitter, submission:, uuid: template.submitters.first['uuid'], account:) - end - - it 'completes the form if the image is uploaded' do - visit submit_form_path(slug: submitter.slug) - find('#expand_form_button').click - find('#dropzone').click - find('input[type="file"]', visible: false).attach_file(Rails.root.join('spec/fixtures/sample-image.png')) - click_button 'Complete' - - expect(page).to have_content('Form has been completed!') - - submitter.reload - expect(submitter.completed_at).to be_present - expect(field_value(submitter, 'Avatar')).to be_present - end - end - - context 'when the file step' do - let(:template) { create(:template, account:, author:, only_field_types: %w[file]) } - let(:submission) { create(:submission, template:) } - let(:submitter) do - create(:submitter, submission:, uuid: template.submitters.first['uuid'], account:) - end - it 'completes the form if the file is uploaded' do - visit submit_form_path(slug: submitter.slug) - - find('#expand_form_button').click - find('#dropzone').click - find('input[type="file"]', visible: false).attach_file(Rails.root.join('spec/fixtures/sample-document.pdf')) - click_button 'Complete' - - expect(page).to have_content('Form has been completed!') - - submitter.reload - - expect(submitter.completed_at).to be_present - expect(field_value(submitter, 'Attachment')).to be_present - end - end - - context 'when the cells step' do - let(:template) { create(:template, account:, author:, only_field_types: %w[cells]) } - let(:submission) { create(:submission, template:) } - let(:submitter) do - create(:submitter, submission:, uuid: template.submitters.first['uuid'], account:) - end - - it 'completes the form if the field is filled' do - visit submit_form_path(slug: submitter.slug) - - input = find_field('Cell code') - - expect(input[:required]).to be_truthy - expect(input[:placeholder]).to eq 'Type here...' - - fill_in 'Cell code', with: '456' - click_button 'Complete' - - expect(page).to have_content('Form has been completed!') - - submitter.reload - - expect(submitter.completed_at).to be_present - expect(field_value(submitter, 'Cell code')).to eq '456' - end - end context 'when the field with conditions' do let(:template) { create(:template, account:, author:, only_field_types: ['text']) }