Skip to content

Commit

Permalink
Remove textile shared examples
Browse files Browse the repository at this point in the history
  • Loading branch information
aapomm committed Apr 22, 2024
1 parent 5d5140a commit 13dab67
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 213 deletions.
14 changes: 0 additions & 14 deletions spec/features/card_pages/card_pages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
23 changes: 0 additions & 23 deletions spec/features/evidence_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) { {} }

Expand All @@ -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
Expand Down
10 changes: 1 addition & 9 deletions spec/features/issue_pages/merge_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
109 changes: 109 additions & 0 deletions spec/features/issue_pages/textile_editor_spec.rb
Original file line number Diff line number Diff line change
@@ -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
9 changes: 0 additions & 9 deletions spec/features/issues_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
23 changes: 0 additions & 23 deletions spec/features/note_pages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }

Expand Down Expand Up @@ -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' }] }
Expand Down
Loading

0 comments on commit 13dab67

Please sign in to comment.