Commit ae3826b4 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'cngo-use-let_it_be-in-filter-search-specs' into 'master'

Use `let_it_be` in filtered search feature specs

See merge request gitlab-org/gitlab!65976
parents 3ee41a90 a0498ad0
......@@ -5,15 +5,16 @@ require 'spec_helper'
RSpec.describe 'Dropdown epic', :js do
include FilteredSearchHelpers
let(:group) { create(:group) }
let(:project) { create(:project, group: group) }
let(:user) { create(:user) }
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") }
let!(:epic) { create(:epic, group: group) }
let!(:epic2) { create(:epic, group: group) }
let!(:issue) { create(:issue, project: project) }
before do
stub_licensed_features(epics: true)
......
......@@ -5,8 +5,10 @@ require 'spec_helper'
RSpec.describe 'Dropdown weight', :js do
include FilteredSearchHelpers
let!(:project) { create(:project) }
let!(:user) { create(:user) }
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") }
......@@ -14,7 +16,6 @@ RSpec.describe 'Dropdown weight', :js do
before do
project.add_maintainer(user)
sign_in(user)
create(:issue, project: project)
visit project_issues_path(project)
end
......
......@@ -5,8 +5,13 @@ require 'spec_helper'
RSpec.describe 'Filter issues weight', :js do
include FilteredSearchHelpers
let!(:project) { create(:project) }
let!(:user) { create(:user, name: 'administrator', username: 'root') }
let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user, name: 'administrator', username: 'root') }
let_it_be(:label) { create(:label, project: project, title: 'urgent') }
let_it_be(:milestone) { create(:milestone, title: 'version1', project: project) }
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' }
shared_examples 'filters by negated weight' do
......@@ -30,19 +35,6 @@ RSpec.describe 'Filter issues weight', :js do
project.add_maintainer(user)
sign_in(user)
label = create(:label, project: project, title: 'urgent')
milestone = create(:milestone, title: 'version1', project: project)
create(:issue, project: project, weight: 1)
issue = create(:issue,
project: project,
weight: 2,
title: 'Bug report 1',
milestone: milestone,
author: user,
assignees: [user])
issue.labels << label
visit project_issues_path(project)
end
......
......@@ -5,15 +5,16 @@ require 'spec_helper'
RSpec.describe 'Dropdown assignee', :js do
include FilteredSearchHelpers
let!(:project) { create(:project) }
let!(:user) { create(:user, name: 'administrator', username: 'root') }
let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user, name: 'administrator', username: 'root') }
let_it_be(:issue) { create(:issue, project: project) }
let(:js_dropdown_assignee) { '#js-dropdown-assignee' }
let(:filter_dropdown) { find("#{js_dropdown_assignee} .filter-dropdown") }
before do
project.add_maintainer(user)
sign_in(user)
create(:issue, project: project)
visit project_issues_path(project)
end
......
......@@ -5,15 +5,16 @@ require 'spec_helper'
RSpec.describe 'Dropdown author', :js do
include FilteredSearchHelpers
let!(:project) { create(:project) }
let!(:user) { create(:user, name: 'administrator', username: 'root') }
let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user, name: 'administrator', username: 'root') }
let_it_be(:issue) { create(:issue, project: project) }
let(:js_dropdown_author) { '#js-dropdown-author' }
let(:filter_dropdown) { find("#{js_dropdown_author} .filter-dropdown") }
before do
project.add_maintainer(user)
sign_in(user)
create(:issue, project: project)
visit project_issues_path(project)
end
......
......@@ -5,8 +5,10 @@ require 'spec_helper'
RSpec.describe 'Dropdown base', :js do
include FilteredSearchHelpers
let!(:project) { create(:project) }
let!(:user) { create(:user, name: 'administrator', username: 'root') }
let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user, name: 'administrator', username: 'root') }
let_it_be(:issue) { create(:issue, project: project) }
let(:filtered_search) { find('.filtered-search') }
let(:js_dropdown_assignee) { '#js-dropdown-assignee' }
let(:filter_dropdown) { find("#{js_dropdown_assignee} .filter-dropdown") }
......@@ -18,7 +20,6 @@ RSpec.describe 'Dropdown base', :js do
before do
project.add_maintainer(user)
sign_in(user)
create(:issue, project: project)
visit project_issues_path(project)
end
......
......@@ -5,10 +5,11 @@ require 'spec_helper'
RSpec.describe 'Dropdown emoji', :js do
include FilteredSearchHelpers
let!(:project) { create(:project, :public) }
let!(:user) { create(:user, name: 'administrator', username: 'root') }
let!(:issue) { create(:issue, project: project) }
let!(:award_emoji_star) { create(:award_emoji, name: 'star', user: user, awardable: issue) }
let_it_be(:project) { create(:project, :public) }
let_it_be(:user) { create(:user, name: 'administrator', username: 'root') }
let_it_be(:issue) { create(:issue, project: project) }
let_it_be(:award_emoji_star) { create(:award_emoji, name: 'star', user: user, awardable: issue) }
let(:filtered_search) { find('.filtered-search') }
let(:js_dropdown_emoji) { '#js-dropdown-my-reaction' }
let(:filter_dropdown) { find("#{js_dropdown_emoji} .filter-dropdown") }
......
......@@ -5,8 +5,10 @@ require 'spec_helper'
RSpec.describe 'Dropdown hint', :js do
include FilteredSearchHelpers
let!(:project) { create(:project, :public) }
let!(:user) { create(:user) }
let_it_be(:project) { create(:project, :public) }
let_it_be(:user) { create(:user) }
let_it_be(:issue) { create(:issue, project: project) }
let(:filtered_search) { find('.filtered-search') }
let(:js_dropdown_hint) { '#js-dropdown-hint' }
let(:js_dropdown_operator) { '#js-dropdown-operator' }
......@@ -21,8 +23,6 @@ RSpec.describe 'Dropdown hint', :js do
before do
project.add_maintainer(user)
create(:issue, project: project)
create(:merge_request, source_project: project, target_project: project)
end
context 'when user not logged in' do
......
......@@ -5,22 +5,23 @@ require 'spec_helper'
RSpec.describe 'Dropdown label', :js do
include FilteredSearchHelpers
let(:project) { create(:project) }
let(:user) { create(:user) }
let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user) }
let_it_be(:issue) { create(:issue, project: project) }
let_it_be(:label) { create(:label, project: project, title: 'bug-label') }
let(:filtered_search) { find('.filtered-search') }
let(:filter_dropdown) { find('#js-dropdown-label .filter-dropdown') }
before do
project.add_maintainer(user)
sign_in(user)
create(:issue, project: project)
visit project_issues_path(project)
end
describe 'behavior' do
it 'loads all the labels when opened' do
create(:label, project: project, title: 'bug-label')
filtered_search.set('label:=')
expect_filtered_search_dropdown_results(filter_dropdown, 1)
......
......@@ -5,10 +5,11 @@ require 'spec_helper'
RSpec.describe 'Dropdown milestone', :js do
include FilteredSearchHelpers
let!(:project) { create(:project) }
let!(:user) { create(:user) }
let!(:milestone) { create(:milestone, title: 'v1.0', project: project) }
let!(:uppercase_milestone) { create(:milestone, title: 'CAP_MILESTONE', project: project) }
let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user) }
let_it_be(:milestone) { create(:milestone, title: 'v1.0', project: project) }
let_it_be(:uppercase_milestone) { create(:milestone, title: 'CAP_MILESTONE', project: project) }
let_it_be(:issue) { create(:issue, project: project) }
let(:filtered_search) { find('.filtered-search') }
let(:filter_dropdown) { find('#js-dropdown-milestone .filter-dropdown') }
......@@ -16,7 +17,6 @@ RSpec.describe 'Dropdown milestone', :js do
before do
project.add_maintainer(user)
sign_in(user)
create(:issue, project: project)
visit project_issues_path(project)
end
......
......@@ -5,10 +5,11 @@ require 'spec_helper'
RSpec.describe 'Dropdown release', :js do
include FilteredSearchHelpers
let!(:project) { create(:project, :repository) }
let!(:user) { create(:user) }
let!(:release) { create(:release, tag: 'v1.0', project: project) }
let!(:crazy_release) { create(:release, tag: '☺!/"#%&\'{}+,-.<>;=@]_`{|}🚀', project: project) }
let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { create(:user) }
let_it_be(:release) { create(:release, tag: 'v1.0', project: project) }
let_it_be(:crazy_release) { create(:release, tag: '☺!/"#%&\'{}+,-.<>;=@]_`{|}🚀', project: project) }
let_it_be(:issue) { create(:issue, project: project) }
let(:filtered_search) { find('.filtered-search') }
let(:filter_dropdown) { find('#js-dropdown-release .filter-dropdown') }
......@@ -16,7 +17,6 @@ RSpec.describe 'Dropdown release', :js do
before do
project.add_maintainer(user)
sign_in(user)
create(:issue, project: project)
visit project_issues_path(project)
end
......
......@@ -6,14 +6,15 @@ RSpec.describe 'Recent searches', :js do
include FilteredSearchHelpers
include MobileHelpers
let(:project_1) { create(:project, :public) }
let(:project_2) { create(:project, :public) }
let_it_be(:project_1) { create(:project, :public) }
let_it_be(:project_2) { create(:project, :public) }
let_it_be(:issue_1) { create(:issue, project: project_1) }
let_it_be(:issue_2) { create(:issue, project: project_2) }
let(:project_1_local_storage_key) { "#{project_1.full_path}-issue-recent-searches" }
before do
Capybara.ignore_hidden_elements = false
create(:issue, project: project_1)
create(:issue, project: project_2)
# Visit any fast-loading page so we can clear local storage without a DOM exception
visit '/404'
......
......@@ -5,14 +5,15 @@ require 'spec_helper'
RSpec.describe 'Search bar', :js do
include FilteredSearchHelpers
let!(:project) { create(:project) }
let!(:user) { create(:user) }
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') }
before do
project.add_maintainer(user)
sign_in(user)
create(:issue, project: project)
visit project_issues_path(project)
end
......
......@@ -5,13 +5,14 @@ require 'spec_helper'
RSpec.describe 'Visual tokens', :js do
include FilteredSearchHelpers
let!(:project) { create(:project) }
let!(:user) { create(:user, name: 'administrator', username: 'root') }
let!(:user_rock) { create(:user, name: 'The Rock', username: 'rock') }
let!(:milestone_nine) { create(:milestone, title: '9.0', project: project) }
let!(:milestone_ten) { create(:milestone, title: '10.0', project: project) }
let!(:label) { create(:label, project: project, title: 'abc') }
let!(:cc_label) { create(:label, project: project, title: 'Community Contribution') }
let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user, name: 'administrator', username: 'root') }
let_it_be(:user_rock) { create(:user, name: 'The Rock', username: 'rock') }
let_it_be(:milestone_nine) { create(:milestone, title: '9.0', project: project) }
let_it_be(:milestone_ten) { create(:milestone, title: '10.0', project: project) }
let_it_be(:label) { create(:label, project: project, title: 'abc') }
let_it_be(:cc_label) { create(:label, project: project, title: 'Community Contribution') }
let_it_be(:issue) { create(:issue, project: project) }
let(:filtered_search) { find('.filtered-search') }
let(:filter_author_dropdown) { find("#js-dropdown-author .filter-dropdown") }
......@@ -27,7 +28,6 @@ RSpec.describe 'Visual tokens', :js do
project.add_user(user, :maintainer)
project.add_user(user_rock, :maintainer)
sign_in(user)
create(:issue, project: project)
set_cookie('sidebar_collapsed', 'true')
......
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