2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-12-04 20:38:33 +05:30
|
|
|
require 'spec_helper'
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
RSpec.describe 'Admin uses repository checks', :request_store do
|
2017-08-17 22:00:37 +05:30
|
|
|
include StubENV
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
let(:admin) { create(:admin) }
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
before do
|
2021-12-11 22:18:48 +05:30
|
|
|
stub_feature_flags(bootstrap_confirmation_modals: false)
|
2017-08-17 22:00:37 +05:30
|
|
|
stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
|
2020-03-13 15:44:24 +05:30
|
|
|
sign_in(admin)
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
context 'when admin mode is disabled' do
|
|
|
|
it 'admin project page requires admin mode' do
|
|
|
|
project = create(:project)
|
|
|
|
visit_admin_project_page(project)
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(page).not_to have_css('.repository-check')
|
|
|
|
expect(page).to have_content('Enter Admin Mode')
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
context 'when admin mode is enabled' do
|
|
|
|
before do
|
|
|
|
gitlab_enable_admin_mode_sign_in(admin)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'to trigger a single check', :js do
|
|
|
|
project = create(:project)
|
|
|
|
visit_admin_project_page(project)
|
|
|
|
|
|
|
|
page.within('.repository-check') do
|
|
|
|
click_button 'Trigger repository check'
|
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(page).to have_content('Repository check was triggered')
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
it 'to see a single failed repository check', :js do
|
|
|
|
project = create(:project)
|
|
|
|
project.update_columns(
|
|
|
|
last_repository_check_failed: true,
|
|
|
|
last_repository_check_at: Time.now
|
|
|
|
)
|
|
|
|
visit_admin_project_page(project)
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
page.within('[data-testid="last-repository-check-failed-alert"]') do
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(page.text).to match(/Last repository check \(just now\) failed/)
|
|
|
|
end
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
it 'to clear all repository checks', :js do
|
|
|
|
visit repository_admin_application_settings_path
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(RepositoryCheck::ClearWorker).to receive(:perform_async)
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
accept_confirm { find(:link, 'Clear all repository checks').send_keys(:return) }
|
|
|
|
|
|
|
|
expect(page).to have_content('Started asynchronous removal of all repository check states.')
|
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def visit_admin_project_page(project)
|
2017-09-10 17:25:29 +05:30
|
|
|
visit admin_project_path(project)
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
end
|