diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-07 21:16:03 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-07 21:16:03 +0300 |
commit | 6a7fcb14aaff70d8438167b652b365406b37613c (patch) | |
tree | fd1b65c5e60e32c02a102158ef0bd9bad412e5d1 /spec | |
parent | 468bcfb9c6d04b0244c349eda62cd7ed1496cca3 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/frontend/authentication/webauthn/util_spec.js | 19 | ||||
-rw-r--r-- | spec/frontend/environments/deployment_spec.js | 6 | ||||
-rw-r--r-- | spec/frontend/runner/components/runner_list_spec.js | 4 | ||||
-rw-r--r-- | spec/graphql/types/project_type_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/integration_spec.rb | 19 | ||||
-rw-r--r-- | spec/services/merge_requests/after_create_service_spec.rb | 22 | ||||
-rw-r--r-- | spec/services/quick_actions/interpret_service_spec.rb | 63 |
7 files changed, 80 insertions, 55 deletions
diff --git a/spec/frontend/authentication/webauthn/util_spec.js b/spec/frontend/authentication/webauthn/util_spec.js new file mode 100644 index 00000000000..c9b8bfd8679 --- /dev/null +++ b/spec/frontend/authentication/webauthn/util_spec.js @@ -0,0 +1,19 @@ +import { base64ToBuffer, bufferToBase64 } from '~/authentication/webauthn/util'; + +const encodedString = 'SGVsbG8gd29ybGQh'; +const stringBytes = [72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 33]; + +describe('Webauthn utils', () => { + it('base64ToBuffer', () => { + const toArray = (val) => new Uint8Array(val); + + expect(base64ToBuffer(encodedString)).toBeInstanceOf(ArrayBuffer); + + expect(toArray(base64ToBuffer(encodedString))).toEqual(toArray(stringBytes)); + }); + + it('bufferToBase64', () => { + const buffer = base64ToBuffer(encodedString); + expect(bufferToBase64(buffer)).toBe(encodedString); + }); +}); diff --git a/spec/frontend/environments/deployment_spec.js b/spec/frontend/environments/deployment_spec.js index 992bffd6e3f..6ce0b76d98e 100644 --- a/spec/frontend/environments/deployment_spec.js +++ b/spec/frontend/environments/deployment_spec.js @@ -149,7 +149,7 @@ describe('~/environments/components/deployment.vue', () => { }); describe('is not present', () => { it('does not show the timestamp', () => { - wrapper = createWrapper({ propsData: { deployment: { createdAt: null } } }); + wrapper = createWrapper({ propsData: { deployment: { ...deployment, createdAt: null } } }); const date = wrapper.findByTitle(formatDate(deployment.createdAt)); expect(date.exists()).toBe(false); @@ -205,6 +205,10 @@ describe('~/environments/components/deployment.vue', () => { expect(button.text()).toBe(__('Hide details')); expect(button.props('icon')).toBe('expand-up'); expect(collapse.attributes('visible')).toBe('visible'); + + const username = wrapper.findByRole('link', { name: `@${deployment.user.username}` }); + + expect(username.attributes('href')).toBe(deployment.user.path); }); }); }); diff --git a/spec/frontend/runner/components/runner_list_spec.js b/spec/frontend/runner/components/runner_list_spec.js index c50486b6f7b..42d6ecca09e 100644 --- a/spec/frontend/runner/components/runner_list_spec.js +++ b/spec/frontend/runner/components/runner_list_spec.js @@ -46,9 +46,9 @@ describe('RunnerList', () => { expect(headerLabels).toEqual([ 'Status', - 'Runner ID', + 'Runner', 'Version', - 'IP Address', + 'IP', 'Jobs', 'Tags', 'Last contact', diff --git a/spec/graphql/types/project_type_spec.rb b/spec/graphql/types/project_type_spec.rb index 6ade44b54d1..7433d465b38 100644 --- a/spec/graphql/types/project_type_spec.rb +++ b/spec/graphql/types/project_type_spec.rb @@ -35,7 +35,7 @@ RSpec.describe GitlabSchema.types['Project'] do pipeline_analytics squash_read_only sast_ci_configuration cluster_agent cluster_agents agent_configurations ci_template timelogs merge_commit_template squash_commit_template work_item_types - recent_issue_boards + recent_issue_boards ci_config_path_or_default ] expect(described_class).to include_graphql_fields(*expected_fields) diff --git a/spec/models/integration_spec.rb b/spec/models/integration_spec.rb index 7bc670302f1..e822620ab80 100644 --- a/spec/models/integration_spec.rb +++ b/spec/models/integration_spec.rb @@ -710,30 +710,21 @@ RSpec.describe Integration do [ { name: 'token' }, { name: 'api_token' }, + { name: 'token_api' }, + { name: 'safe_token' }, { name: 'key' }, { name: 'api_key' }, { name: 'password' }, { name: 'password_field' }, + { name: 'some_safe_field' }, { name: 'safe_field' } - ] + ].shuffle end end end - let(:integration) do - fake_integration.new(properties: [ - { token: 'token-value' }, - { api_token: 'api_token-value' }, - { key: 'key-value' }, - { api_key: 'api_key-value' }, - { password: 'password-value' }, - { password_field: 'password_field-value' }, - { safe_field: 'safe_field-value' } - ]) - end - it 'filters out sensitive fields' do - expect(integration.api_field_names).to eq(['safe_field']) + expect(fake_integration.new).to have_attributes(api_field_names: match_array(%w[some_safe_field safe_field])) end end diff --git a/spec/services/merge_requests/after_create_service_spec.rb b/spec/services/merge_requests/after_create_service_spec.rb index ff6ccc75244..2155b4ffad1 100644 --- a/spec/services/merge_requests/after_create_service_spec.rb +++ b/spec/services/merge_requests/after_create_service_spec.rb @@ -108,17 +108,6 @@ RSpec.describe MergeRequests::AfterCreateService do expect { execute_service }.to raise_error(StandardError) expect(merge_request.reload).to be_preparing end - - context 'when early_prepare_for_mergeability feature flag is disabled' do - before do - stub_feature_flags(early_prepare_for_mergeability: false) - end - - it 'does not mark the merge request as unchecked' do - expect { execute_service }.to raise_error(StandardError) - expect(merge_request.reload).to be_preparing - end - end end context 'when preparing merge request fails' do @@ -134,17 +123,6 @@ RSpec.describe MergeRequests::AfterCreateService do expect(merge_request).to receive(:check_mergeability).with(async: true) expect { execute_service }.to raise_error(StandardError) end - - context 'when early_prepare_for_mergeability feature flag is disabled' do - before do - stub_feature_flags(early_prepare_for_mergeability: false) - end - - it 'does not mark the merge request as unchecked' do - expect { execute_service }.to raise_error(StandardError) - expect(merge_request.reload).to be_preparing - end - end end end diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb index 2c84702a526..e3a6a60393d 100644 --- a/spec/services/quick_actions/interpret_service_spec.rb +++ b/spec/services/quick_actions/interpret_service_spec.rb @@ -485,6 +485,8 @@ RSpec.describe QuickActions::InterpretService do end shared_examples 'failed command' do |error_msg| + let(:match_msg) { error_msg ? eq(error_msg) : be_empty } + it 'populates {} if content contains an unsupported command' do _, updates, _ = service.execute(content, issuable) @@ -494,11 +496,7 @@ RSpec.describe QuickActions::InterpretService do it "returns #{error_msg || 'an empty'} message" do _, _, message = service.execute(content, issuable) - if error_msg - expect(message).to eq(error_msg) - else - expect(message).to be_empty - end + expect(message).to match_msg end end @@ -887,9 +885,10 @@ RSpec.describe QuickActions::InterpretService do end end - it_behaves_like 'failed command', "Failed to assign a user because no user was found." do + it_behaves_like 'failed command', 'a parse error' do let(:content) { '/assign @abcd1234' } let(:issuable) { issue } + let(:match_msg) { eq "Could not apply assign command. Failed to find users for '@abcd1234'." } end it_behaves_like 'failed command', "Failed to assign a user because no user was found." do @@ -953,7 +952,9 @@ RSpec.describe QuickActions::InterpretService do context 'with an incorrect user' do let(:content) { '/assign_reviewer @abcd1234' } - it_behaves_like 'failed command', "Failed to assign a reviewer because no user was found." + it_behaves_like 'failed command', 'a parse error' do + let(:match_msg) { eq "Could not apply assign_reviewer command. Failed to find users for '@abcd1234'." } + end end context 'with the "reviewer" alias' do @@ -971,13 +972,16 @@ RSpec.describe QuickActions::InterpretService do context 'with no user' do let(:content) { '/assign_reviewer' } - it_behaves_like 'failed command', "Failed to assign a reviewer because no user was found." + it_behaves_like 'failed command', "Failed to assign a reviewer because no user was specified." end - context 'includes only the user reference with extra text' do - let(:content) { "/assign_reviewer @#{developer.username} do it!" } + context 'with extra text' do + let(:arg) { "@#{developer.username} do it!" } + let(:content) { "/assign_reviewer #{arg}" } - it_behaves_like 'assign_reviewer command' + it_behaves_like 'failed command', 'a parse error' do + let(:match_msg) { eq "Could not apply assign_reviewer command. Failed to find users for '#{arg}'." } + end end end @@ -2317,12 +2321,41 @@ RSpec.describe QuickActions::InterpretService do end describe 'assign command' do - let(:content) { "/assign @#{developer.username} do it!" } + shared_examples 'assigns developer' do + it 'tells us we will assign the developer' do + _, explanations = service.explain(content, merge_request) - it 'includes only the user reference' do - _, explanations = service.explain(content, merge_request) + expect(explanations).to eq(["Assigns @#{developer.username}."]) + end + end + + context 'when using a reference' do + let(:content) { "/assign @#{developer.username}" } + + include_examples 'assigns developer' + end + + context 'when using a bare username' do + let(:content) { "/assign #{developer.username}" } + + include_examples 'assigns developer' + end - expect(explanations).to eq(["Assigns @#{developer.username}."]) + context 'when using me' do + let(:content) { "/assign me" } + + include_examples 'assigns developer' + end + + context 'when there are unparseable arguments' do + let(:arg) { "#{developer.username} to this issue" } + let(:content) { "/assign #{arg}" } + + it 'tells us why we cannot do that' do + _, explanations = service.explain(content, merge_request) + + expect(explanations).to eq ["Problem with assign command: Failed to find users for '#{arg}'."] + end end end |