Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-02-18 09:14:34 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-02-18 09:14:34 +0300
commitc8512eb431a82f6de7c3d6e5114d280f2d36df99 (patch)
treed4071aef8c829ed4d69cd72eacc1e6f5f7ea9323 /spec
parent20b517258a70b3bd1cb0d17cb77565a82ce098b5 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/features/boards/board_filters_spec.rb2
-rw-r--r--spec/features/boards/boards_spec.rb89
-rw-r--r--spec/features/labels_hierarchy_spec.rb56
-rw-r--r--spec/frontend/protected_branches/protected_branch_edit_spec.js77
-rw-r--r--spec/lib/gitlab/ci/parsers/security/validators/schema_validator_spec.rb44
-rw-r--r--spec/presenters/blob_presenter_spec.rb2
-rw-r--r--spec/spec_helper.rb2
7 files changed, 145 insertions, 127 deletions
diff --git a/spec/features/boards/board_filters_spec.rb b/spec/features/boards/board_filters_spec.rb
index e37bf515088..537b677cbd0 100644
--- a/spec/features/boards/board_filters_spec.rb
+++ b/spec/features/boards/board_filters_spec.rb
@@ -22,8 +22,6 @@ RSpec.describe 'Issue board filters', :js do
let(:filter_submit) { find('.gl-search-box-by-click-search-button') }
before do
- stub_feature_flags(issue_boards_filtered_search: true)
-
project.add_maintainer(user)
sign_in(user)
diff --git a/spec/features/boards/boards_spec.rb b/spec/features/boards/boards_spec.rb
index 2ca4ff94911..fa01304ffe0 100644
--- a/spec/features/boards/boards_spec.rb
+++ b/spec/features/boards/boards_spec.rb
@@ -13,6 +13,10 @@ RSpec.describe 'Project issue boards', :js do
let_it_be(:user) { create(:user) }
let_it_be(:user2) { create(:user) }
+ let(:filtered_search) { find('[data-testid="issue-board-filtered-search"]') }
+ let(:filter_input) { find('.gl-filtered-search-term-input') }
+ let(:filter_submit) { find('.gl-search-box-by-click-search-button') }
+
context 'signed in user' do
before do
project.add_maintainer(user)
@@ -90,8 +94,7 @@ RSpec.describe 'Project issue boards', :js do
end
it 'search closed list' do
- find('.filtered-search').set(issue8.title)
- find('.filtered-search').native.send_keys(:enter)
+ set_filter_and_search_by_token_value(issue8.title)
wait_for_requests
@@ -101,8 +104,7 @@ RSpec.describe 'Project issue boards', :js do
end
it 'search list' do
- find('.filtered-search').set(issue5.title)
- find('.filtered-search').native.send_keys(:enter)
+ set_filter_and_search_by_token_value(issue5.title)
wait_for_requests
@@ -111,26 +113,6 @@ RSpec.describe 'Project issue boards', :js do
expect(find('.board:nth-child(4)')).to have_selector('.board-card', count: 0)
end
- context 'search list negation queries' do
- before do
- visit_project_board_path_without_query_limit(project, board)
- end
-
- it 'does not have the != option' do
- find('.filtered-search').set('label:')
-
- wait_for_requests
- within('#js-dropdown-operator') do
- tokens = all(:css, 'li.filter-dropdown-item')
- expect(tokens.count).to eq(2)
- button = tokens[0].find('button')
- expect(button).to have_content('=')
- button = tokens[1].find('button')
- expect(button).to have_content('!=')
- end
- end
- end
-
it 'allows user to delete board' do
remove_list
@@ -309,8 +291,8 @@ RSpec.describe 'Project issue boards', :js do
context 'filtering' do
it 'filters by author' do
set_filter("author", user2.username)
- click_filter_link(user2.username)
- submit_filter
+ click_on user2.username
+ filter_submit.click
wait_for_requests
wait_for_board_cards(2, 1)
@@ -319,8 +301,8 @@ RSpec.describe 'Project issue boards', :js do
it 'filters by assignee' do
set_filter("assignee", user.username)
- click_filter_link(user.username)
- submit_filter
+ click_on user.username
+ filter_submit.click
wait_for_requests
@@ -330,8 +312,8 @@ RSpec.describe 'Project issue boards', :js do
it 'filters by milestone' do
set_filter("milestone", "\"#{milestone.title}")
- click_filter_link(milestone.title)
- submit_filter
+ click_on milestone.title
+ filter_submit.click
wait_for_requests
wait_for_board_cards(2, 1)
@@ -341,8 +323,8 @@ RSpec.describe 'Project issue boards', :js do
it 'filters by label' do
set_filter("label", testing.title)
- click_filter_link(testing.title)
- submit_filter
+ click_on testing.title
+ filter_submit.click
wait_for_requests
wait_for_board_cards(2, 1)
@@ -351,8 +333,10 @@ RSpec.describe 'Project issue boards', :js do
it 'filters by label with encoded character' do
set_filter("label", a_plus.title)
- click_filter_link(a_plus.title)
- submit_filter
+ # This one is a char encoding issue like the & issue
+ click_on a_plus.title
+ filter_submit.click
+ wait_for_requests
wait_for_board_cards(1, 1)
wait_for_empty_boards((2..4))
@@ -360,8 +344,8 @@ RSpec.describe 'Project issue boards', :js do
it 'filters by label with space after reload', :quarantine do
set_filter("label", "\"#{accepting.title}")
- click_filter_link(accepting.title)
- submit_filter
+ click_on accepting.title
+ filter_submit.click
# Test after reload
page.evaluate_script 'window.location.reload()'
@@ -384,13 +368,13 @@ RSpec.describe 'Project issue boards', :js do
it 'removes filtered labels' do
inspect_requests(inject_headers: { 'X-GITLAB-DISABLE-SQL-QUERY-LIMIT' => 'https://gitlab.com/gitlab-org/gitlab/-/issues/323426' }) do
set_filter("label", testing.title)
- click_filter_link(testing.title)
- submit_filter
+ click_on testing.title
+ filter_submit.click
wait_for_board_cards(2, 1)
- find('.clear-search').click
- submit_filter
+ find('[data-testid="filtered-search-clear-button"]').click
+ filter_submit.click
end
wait_for_board_cards(2, 8)
@@ -400,9 +384,9 @@ RSpec.describe 'Project issue boards', :js do
create_list(:labeled_issue, 30, project: project, labels: [planning, testing])
set_filter("label", testing.title)
- click_filter_link(testing.title)
+ click_on testing.title
inspect_requests(inject_headers: { 'X-GITLAB-DISABLE-SQL-QUERY-LIMIT' => 'https://gitlab.com/gitlab-org/gitlab/-/issues/323426' }) do
- submit_filter
+ filter_submit.click
end
wait_for_requests
@@ -442,10 +426,10 @@ RSpec.describe 'Project issue boards', :js do
it 'filters by multiple labels', :quarantine do
set_filter("label", testing.title)
- click_filter_link(testing.title)
+ click_on testing.title
set_filter("label", bug.title)
- click_filter_link(bug.title)
+ click_on bug.title
submit_filter
@@ -463,7 +447,7 @@ RSpec.describe 'Project issue boards', :js do
wait_for_requests
end
- page.within('.tokens-container') do
+ page.within('.gl-filtered-search-token') do
expect(page).to have_content(bug.title)
end
@@ -561,19 +545,26 @@ RSpec.describe 'Project issue boards', :js do
end
end
+ def set_filter_and_search_by_token_value(value)
+ filter_input.click
+ filter_input.set(value)
+ filter_submit.click
+ end
+
def set_filter(type, text)
- find('.filtered-search').native.send_keys("#{type}:=#{text}")
+ filter_input.click
+ filter_input.native.send_keys("#{type}:=#{text}")
end
def submit_filter
- find('.filtered-search').native.send_keys(:enter)
+ filter_input.native.send_keys(:enter)
end
def click_filter_link(link_text)
- page.within('.filtered-search-box') do
+ page.within(filtered_search) do
expect(page).to have_button(link_text)
- click_button(link_text)
+ click_on link_text
end
end
diff --git a/spec/features/labels_hierarchy_spec.rb b/spec/features/labels_hierarchy_spec.rb
index 6c8d41fd96f..a064eef5cc8 100644
--- a/spec/features/labels_hierarchy_spec.rb
+++ b/spec/features/labels_hierarchy_spec.rb
@@ -179,38 +179,6 @@ RSpec.describe 'Labels Hierarchy', :js do
it_behaves_like 'assigning labels from sidebar'
end
-
- context 'on project board issue sidebar' do
- let(:board) { create(:board, project: project_1) }
-
- before do
- project_1.add_developer(user)
-
- visit project_board_path(project_1, board)
-
- wait_for_requests
-
- find('.board-card').click
- end
-
- it_behaves_like 'assigning labels from sidebar'
- end
-
- context 'on group board issue sidebar' do
- let(:board) { create(:board, group: parent) }
-
- before do
- parent.add_developer(user)
-
- visit group_board_path(parent, board)
-
- wait_for_requests
-
- find('.board-card').click
- end
-
- it_behaves_like 'assigning labels from sidebar'
- end
end
context 'issuable filtering' do
@@ -242,29 +210,5 @@ RSpec.describe 'Labels Hierarchy', :js do
it_behaves_like 'filtering by ancestor labels for groups'
end
-
- context 'on project boards filter' do
- let(:board) { create(:board, project: project_1) }
-
- before do
- project_1.add_developer(user)
-
- visit project_board_path(project_1, board)
- end
-
- it_behaves_like 'filtering by ancestor labels for projects', true
- end
-
- context 'on group boards filter' do
- let(:board) { create(:board, group: parent) }
-
- before do
- parent.add_developer(user)
-
- visit group_board_path(parent, board)
- end
-
- it_behaves_like 'filtering by ancestor labels for groups', true
- end
end
end
diff --git a/spec/frontend/protected_branches/protected_branch_edit_spec.js b/spec/frontend/protected_branches/protected_branch_edit_spec.js
index b41b5028736..13e0388979d 100644
--- a/spec/frontend/protected_branches/protected_branch_edit_spec.js
+++ b/spec/frontend/protected_branches/protected_branch_edit_spec.js
@@ -8,59 +8,101 @@ import ProtectedBranchEdit from '~/protected_branches/protected_branch_edit';
jest.mock('~/flash');
const TEST_URL = `${TEST_HOST}/url`;
+const FORCE_PUSH_TOGGLE_TESTID = 'force-push-toggle';
+const CODE_OWNER_TOGGLE_TESTID = 'code-owner-toggle';
const IS_CHECKED_CLASS = 'is-checked';
+const IS_DISABLED_CLASS = 'is-disabled';
+const IS_LOADING_SELECTOR = '.toggle-loading';
describe('ProtectedBranchEdit', () => {
let mock;
beforeEach(() => {
- setFixtures(`<div id="wrap" data-url="${TEST_URL}">
- <button class="js-force-push-toggle">Toggle</button>
- </div>`);
-
jest.spyOn(ProtectedBranchEdit.prototype, 'buildDropdowns').mockImplementation();
mock = new MockAdapter(axios);
});
- const findForcePushesToggle = () => document.querySelector('.js-force-push-toggle');
+ const findForcePushToggle = () =>
+ document.querySelector(`div[data-testid="${FORCE_PUSH_TOGGLE_TESTID}"] button`);
+ const findCodeOwnerToggle = () =>
+ document.querySelector(`div[data-testid="${CODE_OWNER_TOGGLE_TESTID}"] button`);
- const create = ({ isChecked = false }) => {
- if (isChecked) {
- findForcePushesToggle().classList.add(IS_CHECKED_CLASS);
- }
+ const create = ({
+ forcePushToggleChecked = false,
+ codeOwnerToggleChecked = false,
+ hasLicense = true,
+ } = {}) => {
+ setFixtures(`<div id="wrap" data-url="${TEST_URL}">
+ <span
+ class="js-force-push-toggle"
+ data-label="Toggle allowed to force push"
+ data-is-checked="${forcePushToggleChecked}"
+ data-testid="${FORCE_PUSH_TOGGLE_TESTID}"></span>
+ <span
+ class="js-code-owner-toggle"
+ data-label="Toggle code owner approval"
+ data-is-checked="${codeOwnerToggleChecked}"
+ data-testid="${CODE_OWNER_TOGGLE_TESTID}"></span>
+ </div>`);
- return new ProtectedBranchEdit({ $wrap: $('#wrap'), hasLicense: false });
+ return new ProtectedBranchEdit({ $wrap: $('#wrap'), hasLicense });
};
afterEach(() => {
mock.restore();
});
- describe('when unchecked toggle button', () => {
+ describe('when license supports code owner approvals', () => {
+ beforeEach(() => {
+ create();
+ });
+
+ it('instantiates the code owner toggle', () => {
+ expect(findCodeOwnerToggle()).not.toBe(null);
+ });
+ });
+
+ describe('when license does not support code owner approvals', () => {
+ beforeEach(() => {
+ create({ hasLicense: false });
+ });
+
+ it('does not instantiate the code owner toggle', () => {
+ expect(findCodeOwnerToggle()).toBe(null);
+ });
+ });
+
+ describe.each`
+ description | checkedOption | patchParam | finder
+ ${'force push'} | ${'forcePushToggleChecked'} | ${'allow_force_push'} | ${findForcePushToggle}
+ ${'code owner'} | ${'codeOwnerToggleChecked'} | ${'code_owner_approval_required'} | ${findCodeOwnerToggle}
+ `('when unchecked $description toggle button', ({ checkedOption, patchParam, finder }) => {
let toggle;
beforeEach(() => {
- create({ isChecked: false });
+ create({ [checkedOption]: false });
- toggle = findForcePushesToggle();
+ toggle = finder();
});
it('is not changed', () => {
expect(toggle).not.toHaveClass(IS_CHECKED_CLASS);
- expect(toggle).not.toBeDisabled();
+ expect(toggle.querySelector(IS_LOADING_SELECTOR)).toBe(null);
+ expect(toggle).not.toHaveClass(IS_DISABLED_CLASS);
});
describe('when clicked', () => {
beforeEach(() => {
- mock.onPatch(TEST_URL, { protected_branch: { allow_force_push: true } }).replyOnce(200, {});
+ mock.onPatch(TEST_URL, { protected_branch: { [patchParam]: true } }).replyOnce(200, {});
toggle.click();
});
it('checks and disables button', () => {
expect(toggle).toHaveClass(IS_CHECKED_CLASS);
- expect(toggle).toBeDisabled();
+ expect(toggle.querySelector(IS_LOADING_SELECTOR)).not.toBe(null);
+ expect(toggle).toHaveClass(IS_DISABLED_CLASS);
});
it('sends update to BE', () =>
@@ -68,7 +110,8 @@ describe('ProtectedBranchEdit', () => {
// Args are asserted in the `.onPatch` call
expect(mock.history.patch).toHaveLength(1);
- expect(toggle).not.toBeDisabled();
+ expect(toggle).not.toHaveClass(IS_DISABLED_CLASS);
+ expect(toggle.querySelector(IS_LOADING_SELECTOR)).toBe(null);
expect(createFlash).not.toHaveBeenCalled();
}));
});
diff --git a/spec/lib/gitlab/ci/parsers/security/validators/schema_validator_spec.rb b/spec/lib/gitlab/ci/parsers/security/validators/schema_validator_spec.rb
index 951e0576a58..070b65c7808 100644
--- a/spec/lib/gitlab/ci/parsers/security/validators/schema_validator_spec.rb
+++ b/spec/lib/gitlab/ci/parsers/security/validators/schema_validator_spec.rb
@@ -3,6 +3,50 @@
require 'spec_helper'
RSpec.describe Gitlab::Ci::Parsers::Security::Validators::SchemaValidator do
+ describe 'SUPPORTED_VERSIONS' do
+ schema_path = Rails.root.join("lib", "gitlab", "ci", "parsers", "security", "validators", "schemas")
+
+ it 'matches DEPRECATED_VERSIONS keys' do
+ expect(described_class::SUPPORTED_VERSIONS.keys).to eq(described_class::DEPRECATED_VERSIONS.keys)
+ end
+
+ context 'files under schema path are explicitly listed' do
+ # We only care about the part that comes before report-format.json
+ # https://rubular.com/r/N8Juz7r8hYDYgD
+ filename_regex = /(?<report_type>[-\w]*)\-report-format.json/
+
+ versions = Dir.glob(File.join(schema_path, "*", File::SEPARATOR)).map { |path| path.split("/").last }
+
+ versions.each do |version|
+ files = Dir[schema_path.join(version, "*.json")]
+
+ files.each do |file|
+ matches = filename_regex.match(file)
+ report_type = matches[:report_type].tr("-", "_").to_sym
+
+ it "#{report_type} #{version}" do
+ expect(described_class::SUPPORTED_VERSIONS[report_type]).to include(version)
+ end
+ end
+ end
+ end
+
+ context 'every SUPPORTED_VERSION has a corresponding JSON file' do
+ described_class::SUPPORTED_VERSIONS.each_key do |report_type|
+ # api_fuzzing is covered by DAST schema
+ next if report_type == :api_fuzzing
+
+ described_class::SUPPORTED_VERSIONS[report_type].each do |version|
+ it "#{report_type} #{version} schema file is present" do
+ filename = "#{report_type.to_s.tr("_", "-")}-report-format.json"
+ full_path = schema_path.join(version, filename)
+ expect(File.file?(full_path)).to be true
+ end
+ end
+ end
+ end
+ end
+
using RSpec::Parameterized::TableSyntax
where(:report_type, :expected_errors, :valid_data) do
diff --git a/spec/presenters/blob_presenter_spec.rb b/spec/presenters/blob_presenter_spec.rb
index 225386d9596..847668ffc52 100644
--- a/spec/presenters/blob_presenter_spec.rb
+++ b/spec/presenters/blob_presenter_spec.rb
@@ -28,7 +28,7 @@ RSpec.describe BlobPresenter do
end
describe '#replace_path' do
- it { expect(presenter.replace_path).to eq("/#{project.full_path}/-/create/#{blob.commit_id}/#{blob.path}") }
+ it { expect(presenter.replace_path).to eq("/#{project.full_path}/-/update/#{blob.commit_id}/#{blob.path}") }
end
describe '#can_current_user_push_to_branch' do
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 37e9ef1d994..42163584870 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -304,8 +304,6 @@ RSpec.configure do |config|
# As we're ready to change `master` usages to `main`, let's enable it
stub_feature_flags(main_branch_over_master: false)
- stub_feature_flags(issue_boards_filtered_search: false)
-
# Disable issue respositioning to avoid heavy load on database when importing big projects.
# This is only turned on when app is handling heavy project imports.
# Can be removed when we find a better way to deal with the problem.