2020-04-08 14:13:33 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
RSpec.describe 'Admin Mode Logout', :js, feature_category: :system_access do
|
2020-04-08 14:13:33 +05:30
|
|
|
include TermsHelper
|
|
|
|
include UserLoginHelper
|
2023-06-20 00:43:36 +05:30
|
|
|
include Features::TopNavSpecHelpers
|
2020-04-08 14:13:33 +05:30
|
|
|
|
|
|
|
let(:user) { create(:admin) }
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
before do
|
|
|
|
# TODO: This used to use gitlab_sign_in, instead of sign_in, but that is buggy. See
|
|
|
|
# this issue to look into why: https://gitlab.com/gitlab-org/gitlab/-/issues/331851
|
|
|
|
sign_in(user)
|
|
|
|
gitlab_enable_admin_mode_sign_in(user)
|
|
|
|
visit admin_root_path
|
|
|
|
end
|
2021-04-29 21:17:54 +05:30
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
it 'disable removes admin mode and redirects to root page' do
|
|
|
|
gitlab_disable_admin_mode
|
2020-04-08 14:13:33 +05:30
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
expect(page).to have_current_path root_path, ignore_query: true
|
2021-09-04 01:27:46 +05:30
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
open_top_nav
|
2021-09-04 01:27:46 +05:30
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
within_top_nav do
|
|
|
|
expect(page).to have_link(href: new_admin_session_path)
|
2021-06-08 01:23:25 +05:30
|
|
|
end
|
2021-10-27 15:23:28 +05:30
|
|
|
end
|
2020-04-08 14:13:33 +05:30
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
it 'disable shows flash notice' do
|
|
|
|
gitlab_disable_admin_mode
|
2021-09-04 01:27:46 +05:30
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
expect(page).to have_selector('[data-testid="alert-info"]')
|
2020-04-08 14:13:33 +05:30
|
|
|
end
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
context 'on a read-only instance' do
|
2020-04-08 14:13:33 +05:30
|
|
|
before do
|
2021-10-27 15:23:28 +05:30
|
|
|
allow(Gitlab::Database).to receive(:read_only?).and_return(true)
|
2020-04-08 14:13:33 +05:30
|
|
|
end
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
it 'disable removes admin mode and redirects to root page' do
|
|
|
|
gitlab_disable_admin_mode
|
2020-04-08 14:13:33 +05:30
|
|
|
|
2022-05-07 20:08:51 +05:30
|
|
|
expect(page).to have_current_path root_path, ignore_query: true
|
2021-06-08 01:23:25 +05:30
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
open_top_nav
|
2021-06-08 01:23:25 +05:30
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
within_top_nav do
|
|
|
|
expect(page).to have_link(href: new_admin_session_path)
|
|
|
|
end
|
|
|
|
end
|
2021-06-08 01:23:25 +05:30
|
|
|
end
|
2020-04-08 14:13:33 +05:30
|
|
|
end
|