2019-09-04 21:01:54 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
RSpec.describe 'Admin Appearance', feature_category: :shared do
|
2017-08-17 22:00:37 +05:30
|
|
|
let!(:appearance) { create(:appearance) }
|
2021-02-22 17:27:13 +05:30
|
|
|
let(:admin) { create(:admin) }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
flag_values = [true, false]
|
|
|
|
flag_values.each do |val|
|
|
|
|
before do
|
|
|
|
stub_feature_flags(restyle_login_page: val)
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
it 'create new appearance' do
|
|
|
|
sign_in(admin)
|
|
|
|
gitlab_enable_admin_mode_sign_in(admin)
|
|
|
|
visit admin_application_settings_appearances_path
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
fill_in 'appearance_title', with: 'MyCompany'
|
|
|
|
fill_in 'appearance_description', with: 'dev server'
|
2023-04-23 21:23:45 +05:30
|
|
|
fill_in 'appearance_pwa_name', with: 'GitLab PWA'
|
|
|
|
fill_in 'appearance_pwa_short_name', with: 'GitLab'
|
|
|
|
fill_in 'appearance_pwa_description', with: 'GitLab as PWA'
|
2022-08-27 11:52:29 +05:30
|
|
|
fill_in 'appearance_new_project_guidelines', with: 'Custom project guidelines'
|
|
|
|
fill_in 'appearance_profile_image_guidelines', with: 'Custom profile image guidelines'
|
|
|
|
click_button 'Update appearance settings'
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
expect(page).to have_current_path admin_application_settings_appearances_path, ignore_query: true
|
|
|
|
expect(page).to have_content 'Appearance'
|
2021-11-18 22:05:49 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
expect(page).to have_field('appearance_title', with: 'MyCompany')
|
|
|
|
expect(page).to have_field('appearance_description', with: 'dev server')
|
2023-04-23 21:23:45 +05:30
|
|
|
expect(page).to have_field('appearance_pwa_name', with: 'GitLab PWA')
|
|
|
|
expect(page).to have_field('appearance_pwa_short_name', with: 'GitLab')
|
|
|
|
expect(page).to have_field('appearance_pwa_description', with: 'GitLab as PWA')
|
2022-08-27 11:52:29 +05:30
|
|
|
expect(page).to have_field('appearance_new_project_guidelines', with: 'Custom project guidelines')
|
|
|
|
expect(page).to have_field('appearance_profile_image_guidelines', with: 'Custom profile image guidelines')
|
|
|
|
expect(page).to have_content 'Last edit'
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
it 'preview sign-in page appearance' do
|
|
|
|
sign_in(admin)
|
|
|
|
gitlab_enable_admin_mode_sign_in(admin)
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
visit admin_application_settings_appearances_path
|
|
|
|
click_link "Sign-in page"
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
expect(find('#login')).to be_disabled
|
|
|
|
expect(find('#password')).to be_disabled
|
|
|
|
expect(find('button')).to be_disabled
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
expect_custom_sign_in_appearance(appearance)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'preview new project page appearance', :js do
|
2021-02-22 17:27:13 +05:30
|
|
|
sign_in(admin)
|
|
|
|
gitlab_enable_admin_mode_sign_in(admin)
|
2019-07-07 11:18:12 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
visit admin_application_settings_appearances_path
|
|
|
|
click_link "New project page"
|
2019-07-07 11:18:12 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
expect_custom_new_project_appearance(appearance)
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
context 'Custom system header and footer' do
|
2019-07-07 11:18:12 +05:30
|
|
|
before do
|
2022-08-27 11:52:29 +05:30
|
|
|
sign_in(admin)
|
|
|
|
gitlab_enable_admin_mode_sign_in(admin)
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
context 'when system header and footer messages are empty' do
|
|
|
|
it 'shows custom system header and footer fields' do
|
|
|
|
visit admin_application_settings_appearances_path
|
2019-07-07 11:18:12 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
expect(page).to have_field('appearance_header_message', with: '')
|
|
|
|
expect(page).to have_field('appearance_footer_message', with: '')
|
|
|
|
expect(page).to have_field('appearance_message_background_color')
|
|
|
|
expect(page).to have_field('appearance_message_font_color')
|
|
|
|
end
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
context 'when system header and footer messages are not empty' do
|
|
|
|
before do
|
|
|
|
appearance.update!(header_message: 'Foo', footer_message: 'Bar')
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
it 'shows custom system header and footer fields' do
|
|
|
|
visit admin_application_settings_appearances_path
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
expect(page).to have_field('appearance_header_message', with: appearance.header_message)
|
|
|
|
expect(page).to have_field('appearance_footer_message', with: appearance.footer_message)
|
|
|
|
expect(page).to have_field('appearance_message_background_color')
|
|
|
|
expect(page).to have_field('appearance_message_font_color')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
it 'custom sign-in page' do
|
|
|
|
visit new_user_session_path
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
expect_custom_sign_in_appearance(appearance)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'custom new project page', :js do
|
|
|
|
sign_in(admin)
|
2021-02-22 17:27:13 +05:30
|
|
|
gitlab_enable_admin_mode_sign_in(admin)
|
2022-08-27 11:52:29 +05:30
|
|
|
visit new_project_path
|
|
|
|
click_link 'Create blank project'
|
|
|
|
|
|
|
|
expect_custom_new_project_appearance(appearance)
|
2020-05-24 23:13:21 +05:30
|
|
|
end
|
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
context 'Profile page with custom profile image guidelines' do
|
|
|
|
before do
|
|
|
|
sign_in(admin)
|
|
|
|
gitlab_enable_admin_mode_sign_in(admin)
|
|
|
|
visit admin_application_settings_appearances_path
|
|
|
|
fill_in 'appearance_profile_image_guidelines', with: 'Custom profile image guidelines, please :smile:!'
|
|
|
|
click_button 'Update appearance settings'
|
|
|
|
end
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
it 'renders guidelines when set' do
|
|
|
|
sign_in create(:user)
|
|
|
|
visit profile_path
|
|
|
|
|
|
|
|
expect(page).to have_content 'Custom profile image guidelines, please 😄!'
|
|
|
|
end
|
2020-05-24 23:13:21 +05:30
|
|
|
end
|
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
it 'appearance logo' do
|
|
|
|
sign_in(admin)
|
|
|
|
gitlab_enable_admin_mode_sign_in(admin)
|
|
|
|
visit admin_application_settings_appearances_path
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
attach_file(:appearance_logo, logo_fixture)
|
|
|
|
click_button 'Update appearance settings'
|
|
|
|
expect(page).to have_css(logo_selector)
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
click_link 'Remove logo'
|
|
|
|
expect(page).not_to have_css(logo_selector)
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
it 'appearance pwa icon' do
|
|
|
|
sign_in(admin)
|
|
|
|
gitlab_enable_admin_mode_sign_in(admin)
|
|
|
|
visit admin_application_settings_appearances_path
|
|
|
|
|
|
|
|
attach_file(:appearance_pwa_icon, logo_fixture)
|
|
|
|
click_button 'Update appearance settings'
|
|
|
|
expect(page).to have_css(pwa_icon_selector)
|
|
|
|
|
|
|
|
click_link 'Remove icon'
|
|
|
|
expect(page).not_to have_css(pwa_icon_selector)
|
|
|
|
end
|
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
it 'header logos' do
|
|
|
|
sign_in(admin)
|
|
|
|
gitlab_enable_admin_mode_sign_in(admin)
|
|
|
|
visit admin_application_settings_appearances_path
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
attach_file(:appearance_header_logo, logo_fixture)
|
|
|
|
click_button 'Update appearance settings'
|
|
|
|
expect(page).to have_css(header_logo_selector)
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
click_link 'Remove header logo'
|
|
|
|
expect(page).not_to have_css(header_logo_selector)
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
it 'Favicon' do
|
|
|
|
sign_in(admin)
|
|
|
|
gitlab_enable_admin_mode_sign_in(admin)
|
|
|
|
visit admin_application_settings_appearances_path
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
attach_file(:appearance_favicon, logo_fixture)
|
|
|
|
click_button 'Update appearance settings'
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
expect(page).to have_css('.appearance-light-logo-preview')
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
click_link 'Remove favicon'
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
expect(page).not_to have_css('.appearance-light-logo-preview')
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
# allowed file types
|
|
|
|
attach_file(:appearance_favicon, Rails.root.join('spec', 'fixtures', 'sanitized.svg'))
|
|
|
|
click_button 'Update appearance settings'
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2022-08-27 11:52:29 +05:30
|
|
|
expect(page).to have_content 'Favicon You are not allowed to upload "svg" files, allowed types: png, ico'
|
|
|
|
end
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
def expect_custom_sign_in_appearance(appearance)
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(page).to have_content appearance.title
|
|
|
|
expect(page).to have_content appearance.description
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
def expect_custom_new_project_appearance(appearance)
|
|
|
|
expect(page).to have_content appearance.new_project_guidelines
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def logo_selector
|
2017-09-10 17:25:29 +05:30
|
|
|
'//img[data-src^="/uploads/-/system/appearance/logo"]'
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
def pwa_icon_selector
|
|
|
|
'//img[data-src^="/uploads/-/system/appearance/pwa_icon"]'
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
def header_logo_selector
|
2017-09-10 17:25:29 +05:30
|
|
|
'//img[data-src^="/uploads/-/system/appearance/header_logo"]'
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def logo_fixture
|
|
|
|
Rails.root.join('spec', 'fixtures', 'dk.png')
|
|
|
|
end
|
|
|
|
end
|