From 5d5140a875ed84cebd73dc148b2c9bdb3928f6ed Mon Sep 17 00:00:00 2001 From: Aaron Manaloto Date: Mon, 22 Apr 2024 15:07:14 +0800 Subject: [PATCH 1/5] Remove datatable shared examples --- spec/factories/tags.rb | 4 + .../issue_pages/datatable_spec.rb} | 174 +++++++++--------- spec/features/issue_pages/evidence_spec.rb | 6 - spec/features/issue_pages/table_spec.rb | 42 ----- .../node_pages/evidence_table_spec.rb | 36 ---- spec/features/node_pages/notes_table_spec.rb | 30 --- 6 files changed, 89 insertions(+), 203 deletions(-) rename spec/{support/datatables_shared_examples.rb => features/issue_pages/datatable_spec.rb} (52%) delete mode 100644 spec/features/issue_pages/table_spec.rb delete mode 100644 spec/features/node_pages/evidence_table_spec.rb delete mode 100644 spec/features/node_pages/notes_table_spec.rb diff --git a/spec/factories/tags.rb b/spec/factories/tags.rb index 79cb523f9..edf76e9d1 100644 --- a/spec/factories/tags.rb +++ b/spec/factories/tags.rb @@ -1,5 +1,9 @@ FactoryBot.define do factory :tag do sequence(:name) { |n| "!#{"%06d" % n}_tag" } + + transient do + project {} + end end end diff --git a/spec/support/datatables_shared_examples.rb b/spec/features/issue_pages/datatable_spec.rb similarity index 52% rename from spec/support/datatables_shared_examples.rb rename to spec/features/issue_pages/datatable_spec.rb index 84d6cd349..df977058c 100644 --- a/spec/support/datatables_shared_examples.rb +++ b/spec/features/issue_pages/datatable_spec.rb @@ -1,8 +1,37 @@ -# let(:default_columns) { ['Title', 'Created', ...] } -# let(:hidden_columns) { ['Description', 'Extra', ...] } -# let(:filter) { { keyword:'keyword', filter_count: 1 } } -shared_examples 'a DataTable' do - describe 'column visibility', js: true do +require 'rails_helper' + +describe 'issue table', js: true do + subject { page } + + let(:issue) { issues[0] } + let(:issues) do + [ + create( + :issue, + text: "#[Title]#\nIssue1\n\n#[Risk]#\nHigh\n\n#[Description]#\nn/a", + node: current_project.issue_library + ), + create(:issue, node: current_project.issue_library) + ] + end + + let(:tags) do + Tag::DEFAULT_TAGS.map do |tag| + create(:tag, name: tag, project: current_project) + end + end + + before do + login_to_project_as_user + issues + tags + visit project_issues_path(current_project) + end + + describe 'column visibility' do + let(:default_columns) { ['Title', 'Tags'] } + let(:hidden_columns) { ['Description', 'Risk'] } + it 'displays default columns on load' do within '.dataTables_wrapper thead tr' do default_columns.each do |column| @@ -20,30 +49,21 @@ end it 'can toggle column visibility by clicking on colvis button' do - if hidden_columns.present? - within '.dt-buttons.btn-group' do - page.find('.buttons-colvis').click - - within '.dt-button-collection' do - click_link hidden_columns[0] - end - end + within '.dt-buttons.btn-group' do + page.find('.buttons-colvis').click - within '.dataTables_wrapper thead tr' do - expect(page).to have_text(hidden_columns[0]) + within '.dt-button-collection' do + click_link hidden_columns[0] end end - end - end - describe 'delete button', js: true do - before do - unless page.has_css?('[data-table-destroy-url]') - # Skip this spec if table doesn't support bulk delete - skip + within '.dataTables_wrapper thead tr' do + expect(page).to have_text(hidden_columns[0]) end end + end + describe 'delete button' do it 'is hidden by default' do within '.dt-buttons.btn-group' do expect(page).to_not have_button('Delete') @@ -84,14 +104,7 @@ end end - describe 'tagging', js: true do - before do - unless page.has_css?('[data-tags]') - # Skip this spec if table doesn't support tagging - skip - end - end - + describe 'tagging' do it 'shows the tag button when an item is selected' do within '.dataTables_wrapper' do page.find('td.select-checkbox', match: :first).click @@ -106,7 +119,7 @@ click_button('Tag') within '.dt-button-collection' do - @tags.each do |tag| + tags.each do |tag| expect(page).to have_link(tag.display_name) end end @@ -120,87 +133,70 @@ click_button('Tag') within '.dt-button-collection' do - click_link(@tags.first.display_name) + click_link(tags.first.display_name) end end # Wait for the spinner to disappear expect(page).to_not have_css('[data-behavior=spinner]') - expect(@issue.reload.tags).to include(@tags.first) + expect(issue.reload.tags).to include(tags.first) end end - it 'can filter rows', js: true do - within '.dataTables_filter' do - search_input = page.find('input[type=search]') - search_input.set(filter[:keyword]) - end + describe 'dynamic columns' do + let(:default_columns) { ['Title', 'Tags'] } - within '.dataTable' do - expect(all('tbody tr').count).to eq(filter[:filter_count]) - end - end -end - -# let(:new_content) { "#[Title]#\nTitle\n\n#[New Field]#\nNew Field Value" } -# let(:old_content) { "#[Title]#\nTitle" } -# let(:resource) { Issue.take } -# let(:update_attribute) { :text } -shared_examples 'a DataTable with Dynamic Columns' do - let(:hide_default_columns) do - within '.dt-buttons.btn-group' do - page.find('.buttons-colvis').click + let(:hide_default_columns) do + within '.dt-buttons.btn-group' do + page.find('.buttons-colvis').click - within '.dt-button-collection' do - default_columns.each do |column| - click_link column + within '.dt-button-collection' do + default_columns.each do |column| + click_link column + end end end end - end - let(:update_resource_with_new_content) do - resource.update_attribute(content_attribute, new_content) - end - - let(:update_resource_with_old_content) do - resource.update_attribute(content_attribute, old_content) - end + context 'when new fields are added' do + it 'persists column state' do + hide_default_columns + issue.update_attribute(:text, "#[Title]#\nNew Title\n\n#[Risk]#\nHigh\n\n#[Description]#\nn/a\n\n#[New Field]#\nNew Field Value") - context 'when new columns are added', js: true do - it 'persists column state' do - hide_default_columns - update_resource_with_new_content + page.refresh - # Refresh - visit current_url - - within '.dataTables_wrapper thead tr' do - expect(page).to_not have_text('Created') - expect(page).to_not have_text('Updated') - expect(page).to_not have_text('New Field') + within '.dataTables_wrapper thead tr' do + expect(page).to_not have_text('Created') + expect(page).to_not have_text('Updated') + expect(page).to_not have_text('New Field') + end end end - end - context 'when columns are removed', js: true do - it 'persists column state' do - hide_default_columns - update_resource_with_new_content + context 'when fields are removed' do + it 'persists column state' do + hide_default_columns + issue.update_attribute(:text, "#[Title]#\nIssue1") - # Refresh - visit current_url + page.refresh - update_resource_with_old_content + within '.dataTables_wrapper thead tr' do + expect(page).to_not have_text('Created') + expect(page).to_not have_text('Updated') + expect(page).to_not have_text('New Field') + end + end + end + end - # Refresh - visit current_url + it 'can filter rows' do + within '.dataTables_filter' do + search_input = page.find('input[type=search]') + search_input.set(issue.title) + end - within '.dataTables_wrapper thead tr' do - expect(page).to_not have_text('Created') - expect(page).to_not have_text('Updated') - expect(page).to_not have_text('New Field') - end + within '.dataTable' do + expect(all('tbody tr').count).to eq(1) end end end diff --git a/spec/features/issue_pages/evidence_spec.rb b/spec/features/issue_pages/evidence_spec.rb index bea1a4d5d..eb003a929 100644 --- a/spec/features/issue_pages/evidence_spec.rb +++ b/spec/features/issue_pages/evidence_spec.rb @@ -26,11 +26,5 @@ visit project_issue_path(current_project, issue) click_link("Evidence #{issue.evidence.count}") end - - let(:default_columns) { ['Label', 'Title'] } - let(:hidden_columns) { ['Created by'] } - let(:filter) { { keyword: issue.evidence.first.title, filter_count: 1 } } - - it_behaves_like 'a DataTable' end end diff --git a/spec/features/issue_pages/table_spec.rb b/spec/features/issue_pages/table_spec.rb deleted file mode 100644 index 747d7c36f..000000000 --- a/spec/features/issue_pages/table_spec.rb +++ /dev/null @@ -1,42 +0,0 @@ -require 'rails_helper' - -describe 'issue pages' do - describe '#index table', js: true do - subject { page } - - before do - login_to_project_as_user - - @issue = create( - :issue, - text: "#[Title]#\nIssue1\n\n#[Risk]#\nHigh\n\n#[Description]#\nn/a", - node: current_project.issue_library - ) - - create(:issue, node: current_project.issue_library) - - @tags = Tag::DEFAULT_TAGS.map do |tag| - if defined?(Dradis::Pro) - create(:tag, name: tag, project: current_project) - else - create(:tag, name: tag) - end - end - - visit project_issues_path(current_project) - end - - let(:default_columns) { ['Title', 'Tags'] } - let(:hidden_columns) { ['Description', 'Risk'] } - let(:filter) { { keyword: @issue.title, filter_count: 1 } } - - it_behaves_like 'a DataTable' - - let(:new_content) { "#[Title]#\nNew Title\n\n#[Risk]#\nHigh\n\n#[Description]#\nn/a\n\n#[New Field]#\nNew Field Value" } - let(:old_content) { "#[Title]#\nIssue1\n\n#[Risk]#\nHigh\n\n#[Description]#\nn/a" } - let(:resource) { @issue } - let(:content_attribute) { :text } - - it_behaves_like 'a DataTable with Dynamic Columns' - end -end diff --git a/spec/features/node_pages/evidence_table_spec.rb b/spec/features/node_pages/evidence_table_spec.rb deleted file mode 100644 index 27909eb20..000000000 --- a/spec/features/node_pages/evidence_table_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'rails_helper' - -describe 'node pages' do - describe '#show evidence table' do - subject { page } - - before do - login_to_project_as_user - - @node = create(:node, project: @project) - issue = create(:issue, node: @project.issue_library) - @evidence = create( - :evidence, - node: @node, - content: "#[Title]#\nEvidence1\n\n#[Description]#\nn/a\n#[Extra]#\nExtra field", - issue: issue, - ) - - create(:evidence, node: @node, issue: issue) - visit project_node_path(@project, @node, tab: 'evidence-tab') - end - - let(:default_columns) { ['Title', 'Label'] } - let(:hidden_columns) { ['Created', 'Created by', 'Updated'] } - let(:filter) { { keyword: @evidence.title, filter_count: 1 } } - - it_behaves_like 'a DataTable' - - let(:new_content) { "#[Title]#\nEvidence1\n\n#[Description]#\nn/a\n#[Extra]#\nExtra field\n\n#[New Field]#\nNew Field Value" } - let(:old_content) { "#[Title]#\nEvidence1\n\n#[Description]#\nn/a\n#[Extra]#\nExtra field" } - let(:resource) { @evidence } - let(:content_attribute) { :content } - - it_behaves_like 'a DataTable with Dynamic Columns' - end -end diff --git a/spec/features/node_pages/notes_table_spec.rb b/spec/features/node_pages/notes_table_spec.rb deleted file mode 100644 index 8c3692dfe..000000000 --- a/spec/features/node_pages/notes_table_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'rails_helper' - -describe 'node pages' do - describe '#show notes table' do - subject { page } - - before do - login_to_project_as_user - - node = create(:node, project: current_project) - @note = create(:note, node: node, text: "#[Title]#\nNote1\n\n#[Description]#\nn/a\n#[Extra]#\nExtra field") - create(:note, node: node) - - visit project_node_path(current_project, node, tab: 'notes-tab') - end - - let(:default_columns) { ['Title'] } - let(:hidden_columns) { ['Created', 'Created by', 'Updated'] } - let(:filter) { { keyword: @note.title, filter_count: 1 } } - - it_behaves_like 'a DataTable' - - let(:new_content) { "#[Title]#\nNote1\n\n#[Description]#\nn/a\n#[Extra]#\nExtra field\n\n#[New Field]#\nNew Field Value" } - let(:old_content) { "#[Title]#\nNote1\n\n#[Description]#\nn/a\n#[Extra]#\nExtra field" } - let(:resource) { @note } - let(:content_attribute) { :text } - - it_behaves_like 'a DataTable with Dynamic Columns' - end -end From 13dab67f53ae8a04c7c0996cb67acd06dc29f10d Mon Sep 17 00:00:00 2001 From: Aaron Manaloto Date: Mon, 22 Apr 2024 15:18:27 +0800 Subject: [PATCH 2/5] Remove textile shared examples --- spec/features/card_pages/card_pages_spec.rb | 14 -- spec/features/evidence_spec.rb | 23 --- spec/features/issue_pages/merge_spec.rb | 10 +- .../issue_pages/textile_editor_spec.rb | 109 ++++++++++++++ spec/features/issues_spec.rb | 9 -- spec/features/note_pages_spec.rb | 23 --- .../support/textile_editor_shared_examples.rb | 135 ------------------ 7 files changed, 110 insertions(+), 213 deletions(-) create mode 100644 spec/features/issue_pages/textile_editor_spec.rb delete mode 100644 spec/support/textile_editor_shared_examples.rb diff --git a/spec/features/card_pages/card_pages_spec.rb b/spec/features/card_pages/card_pages_spec.rb index ba28d983e..83aab20cc 100644 --- a/spec/features/card_pages/card_pages_spec.rb +++ b/spec/features/card_pages/card_pages_spec.rb @@ -26,13 +26,6 @@ describe 'when in new page', js: true do let(:submit_form) { click_button 'Create Card' } - describe 'textile form view' do - let(:action_path) { new_project_board_list_card_path(current_project, @board, @list) } - let(:required_form) { fill_in :card_name, with: 'New Card' } - it_behaves_like 'a textile form view', Card - it_behaves_like 'an editor that remembers what view you like' - end - describe 'submitting the form with valid information' do before do visit new_project_board_list_card_path(current_project, @board, @list) @@ -117,13 +110,6 @@ @card = create(:card, list: @list) end - describe 'textile form view' do - let(:action_path) { edit_project_board_list_card_path(current_project, @board, @list, @card) } - let(:item) { @card } - it_behaves_like 'a textile form view', Card - it_behaves_like 'an editor that remembers what view you like' - end - describe 'submitting the form with valid information' do before do visit edit_project_board_list_card_path(current_project, @board, @list, @card) diff --git a/spec/features/evidence_spec.rb b/spec/features/evidence_spec.rb index de5866929..a6861049c 100644 --- a/spec/features/evidence_spec.rb +++ b/spec/features/evidence_spec.rb @@ -109,17 +109,6 @@ end end - it 'uses the full-screen editor plugin' # TODO - - it_behaves_like 'a form with a help button' - - describe 'textile form view' do - let(:action_path) { edit_project_node_evidence_path(current_project, @node, @evidence) } - let(:item) { @evidence } - it_behaves_like 'a textile form view', Evidence - it_behaves_like 'an editor that remembers what view you like' - end - describe 'submitting the form with valid information', js: true do let(:new_content) { 'new content' } before do @@ -187,14 +176,6 @@ click_link 'Source' end - describe 'textile form view' do - let(:action_path) { new_project_node_evidence_path(current_project, @node) } - let(:params) { {} } - let(:required_form) { find('#evidence_issue_id option:nth-of-type(2)').select_option } - it_behaves_like 'a textile form view', Evidence - it_behaves_like 'an editor that remembers what view you like' - end - context 'when no template is specified' do let(:params) { {} } @@ -203,10 +184,6 @@ expect(textarea.value.strip).to eq '' end - it 'uses the textile-editor plugin' - - it_behaves_like 'a form with a help button' - describe 'submitting the form with valid information' do before do select @issue_1.title, from: :evidence_issue_id diff --git a/spec/features/issue_pages/merge_spec.rb b/spec/features/issue_pages/merge_spec.rb index 10f455fe9..3e8be5075 100644 --- a/spec/features/issue_pages/merge_spec.rb +++ b/spec/features/issue_pages/merge_spec.rb @@ -26,15 +26,7 @@ expect(page).to have_content('1 issue merged into ') end - context "merge issues into a new one", js: true do - describe 'textile form view' do - let(:action_path) { new_project_merge_path(current_project, ids: [@issue1.id, @issue2.id]) } - let(:required_form) do - choose('Merge into a new issue') - end - it_behaves_like 'a textile form view', Issue - end - + context 'merge issues into a new one', js: true do it 'creates a new issue' do expect(page).to have_content /You're merging 2 Issues into a target Issue/i diff --git a/spec/features/issue_pages/textile_editor_spec.rb b/spec/features/issue_pages/textile_editor_spec.rb new file mode 100644 index 000000000..fadf2a14e --- /dev/null +++ b/spec/features/issue_pages/textile_editor_spec.rb @@ -0,0 +1,109 @@ +require 'rails_helper' + +describe 'issue form', js: true do + before do + login_to_project_as_user + visit new_project_issue_path(current_project) + end + + let(:submit_form) { click_button 'Create Issue' } + + describe 'clicking the \'help\' button' do + before { find('form .btn-help').click } + + it 'displays Textile help' do + expect(page).to have_selector '.textile-help' + end + end + + describe 'an editor that remembers what view you like' do + it 'will load source view after using source view' do + click_link 'Source' + + page.refresh + + expect(page).to have_css('textarea.textile') + end + + it 'will load fields view after viewing source view but clicking back to fields view' do + click_link 'Source' + click_link 'Fields' + + page.refresh + + expect(page).to have_css('.textile-form') + end + end + + describe 'a textile form view' do + before { click_link 'Fields' } + + it 'add fields in the form' do + current_field_count = all('.textile-form-field').count + + within '.textile-form' do + click_link 'Add field' + end + + expect(page).to have_css('.textile-form-field', count: current_field_count + 1) + end + + it 'remove fields in the form' do + expect { + find('[data-behavior=textile-form-field]', match: :first).hover + within '[data-behavior~=textile-form-field]', match: :first do + click_link 'Delete' + end + }.to change { all('.textile-form-field').count }.by(-1) + end + + it 'saves the item when submitted' do + fill_in('item_form[field_name_0]', with: 'Title') + fill_in('item_form[field_value_0]', with: 'Test Item') + + # Wait for ajax + within '.textile-preview' do + find('h5') + find('p') + end + + within '.form-actions' do + find('[type="submit"]').click + end + + issue = Issue.last + + expect(page).to have_current_path(project_issue_path(current_project, issue), ignore_query: true) + expect(issue.content).to include("#[Title]#\r\nTest Item") + end + + it 'supports text without field headers' do + fieldless_string = "Line 1\nLine 2\n\nLine 4" + field_string = "#[Field]#\nTest Value" + + click_link 'Source' + fill_in 'issue_text', with: fieldless_string + '\n' + field_string + + click_link 'Fields' + + expect(find('#item_form_field_name_0').value).to eq ('') + expect(find('#item_form_field_value_0').value).to eq (fieldless_string) + expect(find('#item_form_field_name_1').value).to eq ('Field') + expect(find('#item_form_field_value_1').value).to eq ('Test Value') + end + + it 'supports fields with duplicated field names' do + text = "#[Field]#\nValue 1\n\n#[Field]#\nValue 2" + + click_link 'Source' + fill_in 'issue_text', with: text + + click_link 'Fields' + + expect(find('#item_form_field_name_0').value).to eq ('Field') + expect(find('#item_form_field_value_0').value).to eq ('Value 1') + expect(find('#item_form_field_name_1').value).to eq ('Field') + expect(find('#item_form_field_value_1').value).to eq ('Value 2') + end + end +end diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb index 178702dd8..3d2be6476 100644 --- a/spec/features/issues_spec.rb +++ b/spec/features/issues_spec.rb @@ -70,10 +70,6 @@ describe 'new page', js: true do let(:submit_form) { click_button 'Create Issue' } - let(:action_path) { new_project_issue_path(current_project) } - it_behaves_like 'a textile form view', Issue - it_behaves_like 'an editor that remembers what view you like' - context 'submitting the form with valid information' do before do visit new_project_issue_path(current_project) @@ -204,11 +200,6 @@ describe 'edit page', js: true do let(:submit_form) { click_button 'Update Issue' } - let(:action_path) { edit_project_issue_path(current_project, @issue) } - let(:item) { @issue } - it_behaves_like 'a textile form view', Issue - it_behaves_like 'an editor that remembers what view you like' - before do issuelib = current_project.issue_library @issue = create(:issue, node: issuelib, updated_at: 2.seconds.ago) diff --git a/spec/features/note_pages_spec.rb b/spec/features/note_pages_spec.rb index c71b53881..b0c87d766 100644 --- a/spec/features/note_pages_spec.rb +++ b/spec/features/note_pages_spec.rb @@ -97,17 +97,6 @@ should have_field :note_text end - it 'uses the full-screen editor plugin' # TODO - - it_behaves_like 'a form with a help button' - - describe 'textile form view' do - let(:action_path) { edit_project_node_note_path(current_project, @node, @note) } - let(:item) { @note } - it_behaves_like 'a textile form view', Note - it_behaves_like 'an editor that remembers what view you like' - end - # TODO handle the case where a Note has no paperclip versions (legacy data) describe 'submitting the form with valid information', js: true do @@ -191,10 +180,6 @@ expect(textarea.value.strip).to eq '' end - it 'uses the textile-editor plugin' - - it_behaves_like 'a form with a help button' - describe 'submitting the form with valid information' do let(:new_note) { @node.notes.order('created_at ASC').last } @@ -248,14 +233,6 @@ end end - describe 'textile form view' do - let(:params) { {} } - - let(:action_path) { new_project_node_note_path(current_project, @node) } - it_behaves_like 'a textile form view', Note - it_behaves_like 'an editor that remembers what view you like' - end - describe 'local caching' do let(:model_path) { new_project_node_note_path(current_project, @node) } let(:model_attributes) { [{ name: :text, value: 'New Note' }] } diff --git a/spec/support/textile_editor_shared_examples.rb b/spec/support/textile_editor_shared_examples.rb deleted file mode 100644 index b8dfa5130..000000000 --- a/spec/support/textile_editor_shared_examples.rb +++ /dev/null @@ -1,135 +0,0 @@ -shared_examples 'a form with a help button' do - describe "clicking the 'help' button", js: true do - before { find('form .btn-help').click } - it 'displays Textile help' do - expect(page).to have_selector 'h5', text: /Text styles/i - expect(page).to have_selector 'h5', text: /Block Code \(bc.\)/i - expect(page).to have_selector 'h5', text: /Lists/i - expect(page).to have_selector 'h5', text: /Miscellaneous/i - expect(page).to have_selector 'h5', text: /Further help/i - end - end -end - -shared_examples 'an editor that remembers what view you like' do - before do - visit action_path - end - - it 'will load source view after using source view' do - click_link 'Source' - - visit action_path - - expect(page).to have_css('textarea.textile') - end - - it 'will load fields view after viewing source view but clicking back to fields view' do - click_link 'Source' - click_link 'Fields' - - visit action_path - - expect(page).to have_css('.textile-form') - end -end - -shared_examples 'a textile form view' do |klass| - before do - visit action_path - - required_form if defined?(required_form) - - click_link 'Fields' - end - - it 'add fields in the form', js: true do - current_field_count = all('.textile-form-field').count - - within '.textile-form' do - click_link 'Add field' - end - - expect(page).to have_css('.textile-form-field', count: current_field_count + 1) - end - - it 'remove fields in the form', js: true do - expect { - find('[data-behavior=textile-form-field]', match: :first).hover - within '[data-behavior~=textile-form-field]', match: :first do - click_link 'Delete' - end - }.to change { all('.textile-form-field').count }.by(-1) - end - - it 'saves the item when submitted', js: true do - fill_in('item_form[field_name_0]', with: 'Title') - fill_in('item_form[field_value_0]', with: 'Test Item') - - # Wait for the source view change buffer time - find('.textile-preview', text: /Test Item/) - - within '.form-actions' do - find('[type="submit"]').click - end - - updated_item = defined?(item) ? item : klass.last - - content_attribute = get_content_attribute(klass) - show_path = get_show_path(updated_item, klass) - - expect(page).to have_current_path(polymorphic_path(show_path), ignore_query: true) - expect(updated_item.reload.send(content_attribute)).to include("#[Title]#\r\nTest Item") - end - - it 'supports text without field headers' do - content_attribute = get_content_attribute(klass) - fieldless_string = "Line 1\nLine 2\n\nLine 4" - field_string = "#[Field]#\nTest Value" - - click_link 'Source' - fill_in "#{klass.to_s.downcase}_#{content_attribute}", with: fieldless_string + "\n" + field_string - - click_link 'Fields' - - expect(find('#item_form_field_name_0').value).to eq ('') - expect(find('#item_form_field_value_0').value).to eq (fieldless_string) - expect(find('#item_form_field_name_1').value).to eq ('Field') - expect(find('#item_form_field_value_1').value).to eq ('Test Value') - end - - it 'supports fields with duplicated field names' do - content_attribute = get_content_attribute(klass) - text = "#[Field]#\nValue 1\n\n#[Field]#\nValue 2" - - click_link 'Source' - fill_in "#{klass.to_s.underscore}_#{content_attribute}", with: text - - click_link 'Fields' - - expect(find('#item_form_field_name_0').value).to eq ('Field') - expect(find('#item_form_field_value_0').value).to eq ('Value 1') - expect(find('#item_form_field_name_1').value).to eq ('Field') - expect(find('#item_form_field_value_1').value).to eq ('Value 2') - end - - def get_content_attribute(klass) - if klass == Evidence - content_attribute = :content - elsif klass == Issue || klass == Note - content_attribute = :text - elsif klass == Card - content_attribute = :description - end - end - - def get_show_path(updated_item, klass) - if klass == Evidence || klass == Note - show_path = [current_project, updated_item.node, updated_item] - elsif klass == Issue - show_path = [current_project, updated_item] - elsif klass == Card - show_path = [current_project, updated_item.list.board, updated_item.list, updated_item] - end - end -end From af1f613e2e43206b972353f1985a462d0a763ce0 Mon Sep 17 00:00:00 2001 From: Aaron Manaloto Date: Mon, 22 Apr 2024 15:21:45 +0800 Subject: [PATCH 3/5] Appease rubocop --- spec/features/card_pages/card_pages_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/card_pages/card_pages_spec.rb b/spec/features/card_pages/card_pages_spec.rb index 83aab20cc..c2f1033de 100644 --- a/spec/features/card_pages/card_pages_spec.rb +++ b/spec/features/card_pages/card_pages_spec.rb @@ -5,7 +5,7 @@ it 'should require authenticated users' do project = create(:project) - @board = create(:board, project:, node: project.methodology_library) + @board = create(:board, project: project, node: project.methodology_library) visit project_board_path(@board.project, @board) expect(current_path).to eq(login_path) expect(page).to have_content('Access denied.') From 6a295060459abfec01011c010d5617cb3992dd14 Mon Sep 17 00:00:00 2001 From: Aaron Manaloto Date: Mon, 22 Apr 2024 15:27:37 +0800 Subject: [PATCH 4/5] Remove datatable example in tags --- spec/features/tags_spec.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/spec/features/tags_spec.rb b/spec/features/tags_spec.rb index 1a4044165..7a649f336 100644 --- a/spec/features/tags_spec.rb +++ b/spec/features/tags_spec.rb @@ -16,8 +16,6 @@ let(:hidden_columns) { ['Color', 'Created', 'Updated'] } let(:filter) { { keyword: tag.name, filter_count: 1 } } - it_behaves_like 'a DataTable' - describe 'can delete tag', js: true do it 'deletes the Tag' do page.find("tr#tag-#{tag.id}").hover From 905a1082a44a17dd4b052d4a4a9606f6cf5ecaa0 Mon Sep 17 00:00:00 2001 From: Aaron Manaloto Date: Mon, 22 Apr 2024 15:50:29 +0800 Subject: [PATCH 5/5] Revert quotes change --- spec/features/issue_pages/textile_editor_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/issue_pages/textile_editor_spec.rb b/spec/features/issue_pages/textile_editor_spec.rb index fadf2a14e..4af3393bd 100644 --- a/spec/features/issue_pages/textile_editor_spec.rb +++ b/spec/features/issue_pages/textile_editor_spec.rb @@ -82,7 +82,7 @@ field_string = "#[Field]#\nTest Value" click_link 'Source' - fill_in 'issue_text', with: fieldless_string + '\n' + field_string + fill_in 'issue_text', with: fieldless_string + "\n" + field_string click_link 'Fields'