Commit 9aef2bca authored by Terri Chu's avatar Terri Chu

Merge branch 'cngo-improve-issues-feature-specs' into 'master'

Improve issues feature specs

See merge request gitlab-org/gitlab!70529
parents 44cf50ef 65a9fda2
......@@ -17,7 +17,7 @@ RSpec.describe 'Group issues page' do
end
it 'shows sidebar when clicked on "Edit issues"' do
find('.js-bulk-update-toggle').click
click_button 'Edit issues'
page.within('.js-right-sidebar') do
expect(page).to have_selector('.issuable-sidebar', visible: true)
......@@ -25,15 +25,13 @@ RSpec.describe 'Group issues page' do
end
it 'shows group milestones within "Milestone" dropdown' do
find('.js-bulk-update-toggle').click
click_button 'Edit issues'
page.within('.js-right-sidebar') do
find('button.js-milestone-select').click
wait_for_requests
click_button 'Select milestone'
wait_for_requests
page.within('.dropdown-menu-milestone .dropdown-content') do
expect(page).to have_content(milestone.title)
end
page.within('.dropdown-menu-milestone .dropdown-content') do
expect(page).to have_content(milestone.title)
end
end
end
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Dropdown epic', :js do
include FilteredSearchHelpers
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, group: group) }
let_it_be(:user) { create(:user) }
let_it_be(:epic) { create(:epic, group: group) }
let_it_be(:epic2) { create(:epic, group: group) }
let_it_be(:issue) { create(:issue, project: project) }
let(:filtered_search) { find('.filtered-search') }
let(:js_dropdown_epic) { '#js-dropdown-epic' }
let(:filter_dropdown) { find("#{js_dropdown_epic} .filter-dropdown") }
before do
stub_licensed_features(epics: true)
group.add_maintainer(user)
sign_in(user)
visit issues_group_path(group)
end
describe 'behavior' do
it 'loads all the epics when opened' do
input_filtered_search('epic:=', submit: false, extra_space: false)
expect_filtered_search_dropdown_results(filter_dropdown, 2)
end
it 'selects epic and correct title is loaded' do
input_filtered_search('epic:=', submit: false, extra_space: false)
wait_for_requests
find('li', text: epic.title).click
expect(find('.filtered-search-token .value').text).to eq("\"#{epic.title}\"::&#{epic.id}")
end
it 'filters issues by epic' do
input_filtered_search('epic:=', submit: false, extra_space: false)
wait_for_requests
find('li', text: epic2.title).click
expect(find('.issue-title-text').text).to eq("#{issue.title}")
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Dropdown weight', :js do
include FilteredSearchHelpers
let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user) }
let_it_be(:issue) { create(:issue, project: project) }
let(:filtered_search) { find('.filtered-search') }
let(:js_dropdown_weight) { '#js-dropdown-weight' }
let(:filter_dropdown) { find("#{js_dropdown_weight} .filter-dropdown") }
before do
project.add_maintainer(user)
sign_in(user)
visit project_issues_path(project)
end
describe 'behavior' do
it 'loads all the weights when opened' do
input_filtered_search('weight:=', submit: false, extra_space: false)
expect_filtered_search_dropdown_results(filter_dropdown, 21)
end
end
end
......@@ -11,33 +11,62 @@ RSpec.describe 'Filter issues by epic', :js do
let_it_be(:issue1) { create(:issue, project: project) }
let_it_be(:issue2) { create(:issue, project: project) }
let_it_be(:issue3) { create(:issue, project: project) }
let_it_be(:issue4) { create(:issue, project: project) }
let_it_be(:epic1) { create(:epic) }
let_it_be(:epic2) { create(:epic) }
let_it_be(:epic1) { create(:epic, group: group) }
let_it_be(:epic2) { create(:epic, group: group) }
let_it_be(:epic_issue1) { create(:epic_issue, issue: issue1, epic: epic1) }
let_it_be(:epic_issue2) { create(:epic_issue, issue: issue2, epic: epic2) }
let_it_be(:epic_issue3) { create(:epic_issue, issue: issue3, epic: epic2) }
let(:js_dropdown) { '#js-dropdown-epic' }
let(:filter_dropdown) { find("#js-dropdown-epic .filter-dropdown") }
before do
stub_licensed_features(epics: true)
stub_feature_flags(vue_issuables_list: false)
project.add_developer(user)
group.add_maintainer(user)
sign_in(user)
visit project_issues_path(project)
end
it 'filter issues by epic' do
input_filtered_search("epic:=&#{epic1.id}")
shared_examples 'filter issues by epic' do
it 'filters issues by epic' do
input_filtered_search("epic:=&#{epic1.id}")
expect_issues_list_count(1)
expect_issues_list_count(1)
end
it 'filters issues by negated epic' do
input_filtered_search("epic:!=&#{epic1.id}")
expect_issues_list_count(2)
end
it 'shows epics in the filtered search dropdown' do
input_filtered_search('epic:=', submit: false, extra_space: false)
expect_filtered_search_dropdown_results(filter_dropdown, 2)
end
it 'shows correct filtered search epic token value' do
input_filtered_search('epic:=', submit: false, extra_space: false)
click_on epic1.title
expect(find('.filtered-search-token .value').text).to eq("\"#{epic1.title}\"::&#{epic1.id}")
end
end
context 'when group issues list page' do
before do
visit issues_group_path(group)
end
it_behaves_like 'filter issues by epic'
end
it 'filter issues not in the epic' do
input_filtered_search("epic:!=&#{epic1.id}")
context 'when project issues list page' do
before do
visit project_issues_path(project)
end
expect_issues_list_count(3)
it_behaves_like 'filter issues by epic'
end
end
......@@ -12,7 +12,7 @@ RSpec.describe 'Filter issues weight', :js do
let_it_be(:issue1) { create(:issue, project: project, weight: 1) }
let_it_be(:issue2) { create(:issue, project: project, weight: 2, title: 'Bug report 1', milestone: milestone, author: user, assignees: [user], labels: [label]) }
let(:js_dropdown_weight) { '#js-dropdown-weight' }
let(:filter_dropdown) { find("#js-dropdown-weight .filter-dropdown") }
shared_examples 'filters by negated weight' do
it 'excludes issues with specified weight' do
......@@ -38,6 +38,14 @@ RSpec.describe 'Filter issues weight', :js do
visit project_issues_path(project)
end
describe 'behavior' do
it 'loads all the weights when opened' do
input_filtered_search('weight:=', submit: false, extra_space: false)
expect_filtered_search_dropdown_results(filter_dropdown, 21)
end
end
describe 'only weight' do
it 'filter issues by searched weight' do
input_filtered_search('weight:=1')
......
......@@ -33,7 +33,7 @@ RSpec.describe 'Group issues page' do
# However,`:js` option forces Capybara to use Selenium that doesn't support`:has`
context "it has an RSS button with current_user's feed token" do
it "shows the RSS button with current_user's feed token" do
expect(find('[data-testid="rss-feed-link"]')['href']).to have_content(user.feed_token)
expect(page).to have_link 'Subscribe to RSS feed', href: /feed_token=#{user.feed_token}/
end
end
end
......@@ -46,7 +46,7 @@ RSpec.describe 'Group issues page' do
# Note: please see the above
context "it has an RSS button without a feed token" do
it "shows the RSS button without a feed token" do
expect(find('[data-testid="rss-feed-link"]')['href']).not_to have_content('feed_token')
expect(page).not_to have_link 'Subscribe to RSS feed', href: /feed_token/
end
end
end
......
......@@ -565,21 +565,18 @@ RSpec.describe 'Filter issues', :js do
end
it 'maintains filter' do
# Closed
find('.issues-state-filters [data-state="closed"]').click
click_link 'Closed'
wait_for_requests
expect(page).to have_selector('.issues-list .issue', count: 1)
expect(page).to have_link(closed_issue.title)
# Opened
find('.issues-state-filters [data-state="opened"]').click
click_link 'Open'
wait_for_requests
expect(page).to have_selector('.issues-list .issue', count: 4)
# All
find('.issues-state-filters [data-state="all"]').click
click_link 'All'
wait_for_requests
expect(page).to have_selector('.issues-list .issue', count: 5)
......
......@@ -16,9 +16,6 @@ RSpec.describe 'Visual tokens', :js do
let(:filtered_search) { find('.filtered-search') }
let(:filter_author_dropdown) { find("#js-dropdown-author .filter-dropdown") }
let(:filter_assignee_dropdown) { find("#js-dropdown-assignee .filter-dropdown") }
let(:filter_milestone_dropdown) { find("#js-dropdown-milestone .filter-dropdown") }
let(:filter_label_dropdown) { find("#js-dropdown-label .filter-dropdown") }
def is_input_focused
page.evaluate_script("document.activeElement.classList.contains('filtered-search')")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment