diff options
Diffstat (limited to 'spec/support/shared_examples/features')
7 files changed, 131 insertions, 7 deletions
diff --git a/spec/support/shared_examples/features/page_description_shared_examples.rb b/spec/support/shared_examples/features/page_description_shared_examples.rb index 81653220b4c..e3ea36633d1 100644 --- a/spec/support/shared_examples/features/page_description_shared_examples.rb +++ b/spec/support/shared_examples/features/page_description_shared_examples.rb @@ -7,3 +7,13 @@ RSpec.shared_examples 'page meta description' do |expected_description| end end end + +RSpec.shared_examples 'default brand title page meta description' do + include AppearancesHelper + + it 'renders the page with description, og:description, and twitter:description meta tags with the default brand title', :aggregate_failures do + %w(name='description' property='og:description' property='twitter:description').each do |selector| + expect(page).to have_selector("meta[#{selector}][content='#{default_brand_title}']", visible: false) + end + end +end diff --git a/spec/support/shared_examples/features/sidebar/sidebar_due_date_shared_examples.rb b/spec/support/shared_examples/features/sidebar/sidebar_due_date_shared_examples.rb new file mode 100644 index 00000000000..345dfbce423 --- /dev/null +++ b/spec/support/shared_examples/features/sidebar/sidebar_due_date_shared_examples.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'date sidebar widget' do + context 'editing due date' do + let(:due_date_value) { find('[data-testid="sidebar-due-date"] [data-testid="sidebar-date-value"]') } + + around do |example| + freeze_time { example.run } + end + + it 'displays "None" when there is no due date' do + expect(due_date_value.text).to have_content 'None' + end + + it 'updates due date' do + page.within('[data-testid="sidebar-due-date"]') do + today = Date.today.day + + click_button 'Edit' + + click_button today.to_s + + wait_for_requests + + expect(page).to have_content(today.to_s(:medium)) + expect(due_date_value.text).to have_content Time.current.strftime('%b %-d, %Y') + end + end + end +end diff --git a/spec/support/shared_examples/features/sidebar/sidebar_milestone_shared_examples.rb b/spec/support/shared_examples/features/sidebar/sidebar_milestone_shared_examples.rb new file mode 100644 index 00000000000..da730240e8e --- /dev/null +++ b/spec/support/shared_examples/features/sidebar/sidebar_milestone_shared_examples.rb @@ -0,0 +1,60 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'milestone sidebar widget' do + context 'editing milestone' do + let_it_be(:milestone_expired) { create(:milestone, project: project, title: 'Foo - expired', due_date: 5.days.ago) } + let_it_be(:milestone_no_duedate) { create(:milestone, project: project, title: 'Foo - No due date') } + let_it_be(:milestone1) { create(:milestone, project: project, title: 'Milestone-1', due_date: 20.days.from_now) } + let_it_be(:milestone2) { create(:milestone, project: project, title: 'Milestone-2', due_date: 15.days.from_now) } + let_it_be(:milestone3) { create(:milestone, project: project, title: 'Milestone-3', due_date: 10.days.from_now) } + + let(:milestone_widget) { find('[data-testid="sidebar-milestones"]') } + + before do + within(milestone_widget) do + click_button 'Edit' + end + + wait_for_all_requests + end + + it 'shows milestones list in the dropdown' do + # 5 milestones + "No milestone" = 6 items + expect(milestone_widget.find('.gl-new-dropdown-contents')).to have_selector('li.gl-new-dropdown-item', count: 6) + end + + it 'shows expired milestone at the bottom of the list and milestone due earliest at the top of the list', :aggregate_failures do + within(milestone_widget, '.gl-new-dropdown-contents') do + expect(page.find('li:last-child')).to have_content milestone_expired.title + + [milestone3, milestone2, milestone1, milestone_no_duedate].each_with_index do |m, i| + expect(page.all('li.gl-new-dropdown-item')[i + 1]).to have_content m.title + end + end + end + + it 'adds a milestone' do + within(milestone_widget) do + click_button milestone1.title + + wait_for_requests + + page.within('[data-testid="select-milestone"]') do + expect(page).to have_content(milestone1.title) + end + end + end + + it 'removes a milestone' do + within(milestone_widget) do + click_button "No milestone" + + wait_for_requests + + page.within('[data-testid="select-milestone"]') do + expect(page).not_to have_content(milestone1.title) + end + end + end + end +end diff --git a/spec/support/shared_examples/features/sidebar_shared_examples.rb b/spec/support/shared_examples/features/sidebar_shared_examples.rb index d509d124de0..615f568420e 100644 --- a/spec/support/shared_examples/features/sidebar_shared_examples.rb +++ b/spec/support/shared_examples/features/sidebar_shared_examples.rb @@ -5,6 +5,7 @@ RSpec.shared_examples 'issue boards sidebar' do before do first_card.click + wait_for_requests end it 'shows sidebar when clicking issue' do @@ -41,6 +42,14 @@ RSpec.shared_examples 'issue boards sidebar' do end end + context 'editing issue milestone', :js do + it_behaves_like 'milestone sidebar widget' + end + + context 'editing issue due date', :js do + it_behaves_like 'date sidebar widget' + end + context 'in notifications subscription' do it 'displays notifications toggle', :aggregate_failures do page.within('[data-testid="sidebar-notifications"]') do diff --git a/spec/support/shared_examples/features/snippets_shared_examples.rb b/spec/support/shared_examples/features/snippets_shared_examples.rb index bd1a67f3bb5..c402333107c 100644 --- a/spec/support/shared_examples/features/snippets_shared_examples.rb +++ b/spec/support/shared_examples/features/snippets_shared_examples.rb @@ -20,7 +20,7 @@ RSpec.shared_examples 'paginated snippets' do |remote: false| end RSpec.shared_examples 'tabs with counts' do - let(:tabs) { page.all('.snippet-scope-menu li') } + let(:tabs) { page.all('.js-snippets-nav-tabs li') } it 'shows a tab for All snippets and count' do tab = tabs[0] diff --git a/spec/support/shared_examples/features/wiki/user_updates_wiki_page_shared_examples.rb b/spec/support/shared_examples/features/wiki/user_updates_wiki_page_shared_examples.rb index 7ced8508a31..a456b76b324 100644 --- a/spec/support/shared_examples/features/wiki/user_updates_wiki_page_shared_examples.rb +++ b/spec/support/shared_examples/features/wiki/user_updates_wiki_page_shared_examples.rb @@ -138,11 +138,26 @@ RSpec.shared_examples 'User updates wiki page' do end context 'when using the content editor' do - before do - click_button 'Use the new editor' + context 'with feature flag on' do + before do + click_button 'Edit rich text' + end + + it_behaves_like 'edits content using the content editor' end - it_behaves_like 'edits content using the content editor' + context 'with feature flag off' do + before do + stub_feature_flags(wiki_switch_between_content_editor_raw_markdown: false) + visit(wiki_path(wiki)) + + click_link('Edit') + + click_button 'Use the new editor' + end + + it_behaves_like 'edits content using the content editor' + end end end diff --git a/spec/support/shared_examples/features/wiki/user_views_wiki_page_shared_examples.rb b/spec/support/shared_examples/features/wiki/user_views_wiki_page_shared_examples.rb index 96df5a5f972..eec911f3b6f 100644 --- a/spec/support/shared_examples/features/wiki/user_views_wiki_page_shared_examples.rb +++ b/spec/support/shared_examples/features/wiki/user_views_wiki_page_shared_examples.rb @@ -161,7 +161,7 @@ RSpec.shared_examples 'User views a wiki page' do commit = wiki.commit visit wiki_page_path(wiki, wiki_page, version_id: commit, action: :diff) - expect(page).to have_content('by John Doe') + expect(page).to have_content('by Sidney Jones') expect(page).to have_content('updated home') expect(page).to have_content('Showing 1 changed file with 1 addition and 3 deletions') expect(page).to have_content('some link') @@ -174,7 +174,7 @@ RSpec.shared_examples 'User views a wiki page' do commit = wiki.commit('HEAD^') visit wiki_page_path(wiki, wiki_page, version_id: commit, action: :diff) - expect(page).to have_content('by John Doe') + expect(page).to have_content('by Sidney Jones') expect(page).to have_content('updated home') expect(page).to have_content('Showing 1 changed file with 1 addition and 3 deletions') expect(page).to have_content('some link') @@ -188,7 +188,7 @@ RSpec.shared_examples 'User views a wiki page' do commit = wiki.commit('HEAD^') visit wiki_page_path(wiki, wiki_page, version_id: commit, action: :diff) - expect(page).to have_content('by John Doe') + expect(page).to have_content('by Sidney Jones') expect(page).to have_content('created page: home') expect(page).to have_content('Showing 1 changed file with 4 additions and 0 deletions') expect(page).to have_content('Look at this') |