diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/issuables/shortcuts_issuable_spec.rb | 46 | ||||
-rw-r--r-- | spec/features/projects/blobs/blob_show_spec.rb | 12 | ||||
-rw-r--r-- | spec/helpers/search_helper_spec.rb | 4 | ||||
-rw-r--r-- | spec/javascripts/monitoring/dashboard_spec.js | 12 | ||||
-rw-r--r-- | spec/javascripts/monitoring/mock_data.js | 15 | ||||
-rw-r--r-- | spec/spec_helper.rb | 1 | ||||
-rw-r--r-- | spec/support/selection_helper.rb | 6 |
7 files changed, 78 insertions, 18 deletions
diff --git a/spec/features/issuables/shortcuts_issuable_spec.rb b/spec/features/issuables/shortcuts_issuable_spec.rb new file mode 100644 index 00000000000..e25fd1a6249 --- /dev/null +++ b/spec/features/issuables/shortcuts_issuable_spec.rb @@ -0,0 +1,46 @@ +require 'spec_helper' + +feature 'Blob shortcuts', :js do + let(:user) { create(:user) } + let(:project) { create(:project, :public, :repository) } + let(:issue) { create(:issue, project: project, author: user) } + let(:merge_request) { create(:merge_request, source_project: project) } + let(:note_text) { 'I got this!' } + + before do + project.add_developer(user) + sign_in(user) + end + + describe 'pressing "r"' do + describe 'On an Issue' do + before do + create(:note, noteable: issue, project: project, note: note_text) + visit project_issue_path(project, issue) + wait_for_requests + end + + it 'quotes the selected text' do + select_element('.note-text') + find('body').native.send_key('r') + + expect(find('.js-main-target-form .js-vue-comment-form').value).to include(note_text) + end + end + + describe 'On a Merge Request' do + before do + create(:note, noteable: merge_request, project: project, note: note_text) + visit project_merge_request_path(project, merge_request) + wait_for_requests + end + + it 'quotes the selected text' do + select_element('.note-text') + find('body').native.send_key('r') + + expect(find('.js-main-target-form #note_note').value).to include(note_text) + end + end + end +end diff --git a/spec/features/projects/blobs/blob_show_spec.rb b/spec/features/projects/blobs/blob_show_spec.rb index 3d465e709b9..88813d9b5ff 100644 --- a/spec/features/projects/blobs/blob_show_spec.rb +++ b/spec/features/projects/blobs/blob_show_spec.rb @@ -1,6 +1,8 @@ require 'spec_helper' feature 'File blob', :js do + include MobileHelpers + let(:project) { create(:project, :public, :repository) } def visit_blob(path, anchor: nil, ref: 'master') @@ -30,6 +32,16 @@ feature 'File blob', :js do expect(page).to have_link('Open raw') end end + + it 'displays file actions on all screen sizes' do + file_actions_selector = '.file-actions' + + resize_screen_sm + expect(page).to have_selector(file_actions_selector, visible: true) + + resize_screen_xs + expect(page).to have_selector(file_actions_selector, visible: true) + end end context 'Markdown file' do diff --git a/spec/helpers/search_helper_spec.rb b/spec/helpers/search_helper_spec.rb index ab647401e14..6c9a7febf14 100644 --- a/spec/helpers/search_helper_spec.rb +++ b/spec/helpers/search_helper_spec.rb @@ -102,6 +102,10 @@ describe SearchHelper do it 'includes project base-endpoint' do expect(search_filter_input_options('')[:data]['base-endpoint']).to eq(project_path(@project)) end + + it 'includes autocomplete=off flag' do + expect(search_filter_input_options('')[:autocomplete]).to eq('off') + end end context 'group' do diff --git a/spec/javascripts/monitoring/dashboard_spec.js b/spec/javascripts/monitoring/dashboard_spec.js index 752fdfb4614..9885b8a790f 100644 --- a/spec/javascripts/monitoring/dashboard_spec.js +++ b/spec/javascripts/monitoring/dashboard_spec.js @@ -1,6 +1,8 @@ import Vue from 'vue'; +import MockAdapter from 'axios-mock-adapter'; import Dashboard from '~/monitoring/components/dashboard.vue'; -import { MonitorMockInterceptor } from './mock_data'; +import axios from '~/lib/utils/axios_utils'; +import { metricsGroupsAPIResponse, mockApiEndpoint } from './mock_data'; describe('Dashboard', () => { const fixtureName = 'environments/metrics/metrics.html.raw'; @@ -26,13 +28,17 @@ describe('Dashboard', () => { }); describe('requests information to the server', () => { + let mock; beforeEach(() => { document.querySelector('#prometheus-graphs').setAttribute('data-has-metrics', 'true'); - Vue.http.interceptors.push(MonitorMockInterceptor); + mock = new MockAdapter(axios); + mock.onGet(mockApiEndpoint).reply(200, { + metricsGroupsAPIResponse, + }); }); afterEach(() => { - Vue.http.interceptors = _.without(Vue.http.interceptors, MonitorMockInterceptor); + mock.reset(); }); it('shows up a loading state', (done) => { diff --git a/spec/javascripts/monitoring/mock_data.js b/spec/javascripts/monitoring/mock_data.js index 7ceab657464..6b34855b8b2 100644 --- a/spec/javascripts/monitoring/mock_data.js +++ b/spec/javascripts/monitoring/mock_data.js @@ -2425,13 +2425,6 @@ const metricsGroupsAPIResponse = { export default metricsGroupsAPIResponse; -const responseMockData = { - 'GET': { - '/root/hello-prometheus/environments/30/additional_metrics.json': metricsGroupsAPIResponse, - 'http://test.host/frontend-fixtures/environments-project/environments/1/additional_metrics.json': metricsGroupsAPIResponse, // TODO: MAke sure this works in the monitoring_bundle_spec - }, -}; - export const deploymentData = [ { id: 111, @@ -8320,11 +8313,3 @@ export function convertDatesMultipleSeries(multipleSeries) { }); return convertedMultiple; } - -export function MonitorMockInterceptor(request, next) { - const body = responseMockData[request.method.toUpperCase()][request.url]; - - next(request.respondWith(JSON.stringify(body), { - status: 200, - })); -} diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7c8331f6c60..6310ea1b52b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -50,6 +50,7 @@ RSpec.configure do |config| config.include SearchHelpers, type: :feature config.include CookieHelper, :js config.include InputHelper, :js + config.include SelectionHelper, :js config.include InspectRequests, :js config.include WaitForRequests, :js config.include LiveDebugger, :js diff --git a/spec/support/selection_helper.rb b/spec/support/selection_helper.rb new file mode 100644 index 00000000000..b4725b137b2 --- /dev/null +++ b/spec/support/selection_helper.rb @@ -0,0 +1,6 @@ +module SelectionHelper + def select_element(selector) + find(selector) + execute_script("let range = document.createRange(); let sel = window.getSelection(); range.selectNodeContents(document.querySelector('#{selector}')); sel.addRange(range);") + end +end |