2019-05-23 14:07:59 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-12-13 10:22:18 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-03 14:08:28 -04:00
|
|
|
RSpec.describe 'Admin Appearance' do
|
2016-12-13 10:22:18 -05:00
|
|
|
let!(:appearance) { create(:appearance) }
|
2020-11-23 10:09:37 -05:00
|
|
|
let(:admin) { create(:admin) }
|
2016-12-13 10:22:18 -05:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
flag_values = [true, false]
|
|
|
|
flag_values.each do |val|
|
|
|
|
before do
|
|
|
|
stub_feature_flags(restyle_login_page: val)
|
|
|
|
end
|
2016-12-13 10:22:18 -05:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
it 'create new appearance' do
|
|
|
|
sign_in(admin)
|
|
|
|
gitlab_enable_admin_mode_sign_in(admin)
|
|
|
|
visit admin_application_settings_appearances_path
|
2016-12-13 10:22:18 -05:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
fill_in 'appearance_title', with: 'MyCompany'
|
|
|
|
fill_in 'appearance_description', with: 'dev server'
|
|
|
|
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'
|
2016-12-13 10:22:18 -05:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
expect(page).to have_current_path admin_application_settings_appearances_path, ignore_query: true
|
|
|
|
expect(page).to have_content 'Appearance'
|
2021-09-27 02:09:35 -04:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
expect(page).to have_field('appearance_title', with: 'MyCompany')
|
|
|
|
expect(page).to have_field('appearance_description', with: 'dev server')
|
|
|
|
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
|
2017-11-22 08:48:38 -05:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
it 'preview sign-in page appearance' do
|
|
|
|
sign_in(admin)
|
|
|
|
gitlab_enable_admin_mode_sign_in(admin)
|
2017-11-22 08:48:38 -05:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
visit admin_application_settings_appearances_path
|
|
|
|
click_link "Sign-in page"
|
2017-11-22 08:48:38 -05:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
expect(find('#login')).to be_disabled
|
|
|
|
expect(find('#password')).to be_disabled
|
|
|
|
expect(find('button')).to be_disabled
|
2016-12-13 10:22:18 -05:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
expect_custom_sign_in_appearance(appearance)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'preview new project page appearance', :js do
|
2020-11-23 10:09:37 -05:00
|
|
|
sign_in(admin)
|
|
|
|
gitlab_enable_admin_mode_sign_in(admin)
|
2018-04-02 10:26:59 -04:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
visit admin_application_settings_appearances_path
|
|
|
|
click_link "New project page"
|
2018-04-02 10:26:59 -04:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
expect_custom_new_project_appearance(appearance)
|
2018-04-02 10:26:59 -04:00
|
|
|
end
|
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
context 'Custom system header and footer' do
|
2018-04-02 10:26:59 -04:00
|
|
|
before do
|
2022-08-08 17:09:31 -04:00
|
|
|
sign_in(admin)
|
|
|
|
gitlab_enable_admin_mode_sign_in(admin)
|
2018-04-02 10:26:59 -04:00
|
|
|
end
|
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
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
|
2018-04-02 10:26:59 -04:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
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
|
2018-04-02 10:26:59 -04:00
|
|
|
end
|
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
context 'when system header and footer messages are not empty' do
|
|
|
|
before do
|
|
|
|
appearance.update!(header_message: 'Foo', footer_message: 'Bar')
|
|
|
|
end
|
2017-11-22 08:48:38 -05:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
it 'shows custom system header and footer fields' do
|
|
|
|
visit admin_application_settings_appearances_path
|
2017-11-22 08:48:38 -05:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
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
|
2017-11-22 08:48:38 -05:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
it 'custom sign-in page' do
|
|
|
|
visit new_user_session_path
|
2016-12-13 10:22:18 -05:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
expect_custom_sign_in_appearance(appearance)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'custom new project page', :js do
|
2022-07-22 14:08:56 -04:00
|
|
|
sign_in(admin)
|
2020-11-23 10:09:37 -05:00
|
|
|
gitlab_enable_admin_mode_sign_in(admin)
|
2022-08-08 17:09:31 -04:00
|
|
|
visit new_project_path
|
|
|
|
click_link 'Create blank project'
|
|
|
|
|
|
|
|
expect_custom_new_project_appearance(appearance)
|
2020-04-28 11:09:29 -04:00
|
|
|
end
|
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
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
|
|
|
|
|
|
|
|
it 'renders guidelines when set' do
|
|
|
|
sign_in create(:user)
|
|
|
|
visit profile_path
|
2020-04-28 11:09:29 -04:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
expect(page).to have_content 'Custom profile image guidelines, please 😄!'
|
|
|
|
end
|
2020-04-28 11:09:29 -04:00
|
|
|
end
|
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
it 'appearance logo' do
|
|
|
|
sign_in(admin)
|
|
|
|
gitlab_enable_admin_mode_sign_in(admin)
|
|
|
|
visit admin_application_settings_appearances_path
|
2016-12-13 10:22:18 -05:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
attach_file(:appearance_logo, logo_fixture)
|
|
|
|
click_button 'Update appearance settings'
|
|
|
|
expect(page).to have_css(logo_selector)
|
2016-12-13 10:22:18 -05:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
click_link 'Remove logo'
|
|
|
|
expect(page).not_to have_css(logo_selector)
|
|
|
|
end
|
2016-12-13 10:22:18 -05:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
it 'header logos' do
|
|
|
|
sign_in(admin)
|
|
|
|
gitlab_enable_admin_mode_sign_in(admin)
|
|
|
|
visit admin_application_settings_appearances_path
|
2016-12-13 10:22:18 -05:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
attach_file(:appearance_header_logo, logo_fixture)
|
|
|
|
click_button 'Update appearance settings'
|
|
|
|
expect(page).to have_css(header_logo_selector)
|
2016-12-13 10:22:18 -05:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
click_link 'Remove header logo'
|
|
|
|
expect(page).not_to have_css(header_logo_selector)
|
|
|
|
end
|
2016-12-13 10:22:18 -05:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
it 'Favicon' do
|
|
|
|
sign_in(admin)
|
|
|
|
gitlab_enable_admin_mode_sign_in(admin)
|
|
|
|
visit admin_application_settings_appearances_path
|
2017-09-26 10:07:53 -04:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
attach_file(:appearance_favicon, logo_fixture)
|
|
|
|
click_button 'Update appearance settings'
|
2017-09-26 10:07:53 -04:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
expect(page).to have_css('.appearance-light-logo-preview')
|
2017-09-26 10:07:53 -04:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
click_link 'Remove favicon'
|
2017-09-26 10:07:53 -04:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
expect(page).not_to have_css('.appearance-light-logo-preview')
|
2017-09-27 09:03:49 -04:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
# allowed file types
|
|
|
|
attach_file(:appearance_favicon, Rails.root.join('spec', 'fixtures', 'sanitized.svg'))
|
|
|
|
click_button 'Update appearance settings'
|
2017-09-27 09:03:49 -04:00
|
|
|
|
2022-08-08 17:09:31 -04:00
|
|
|
expect(page).to have_content 'Favicon You are not allowed to upload "svg" files, allowed types: png, ico'
|
|
|
|
end
|
2017-09-26 10:07:53 -04:00
|
|
|
end
|
|
|
|
|
2017-11-22 08:48:38 -05:00
|
|
|
def expect_custom_sign_in_appearance(appearance)
|
2016-12-13 10:22:18 -05:00
|
|
|
expect(page).to have_content appearance.title
|
|
|
|
expect(page).to have_content appearance.description
|
|
|
|
end
|
|
|
|
|
2017-11-22 08:48:38 -05:00
|
|
|
def expect_custom_new_project_appearance(appearance)
|
|
|
|
expect(page).to have_content appearance.new_project_guidelines
|
|
|
|
end
|
|
|
|
|
2016-12-13 10:22:18 -05:00
|
|
|
def logo_selector
|
2017-07-24 13:36:52 -04:00
|
|
|
'//img[data-src^="/uploads/-/system/appearance/logo"]'
|
2016-12-13 10:22:18 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def header_logo_selector
|
2017-07-24 13:36:52 -04:00
|
|
|
'//img[data-src^="/uploads/-/system/appearance/header_logo"]'
|
2016-12-13 10:22:18 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def logo_fixture
|
|
|
|
Rails.root.join('spec', 'fixtures', 'dk.png')
|
|
|
|
end
|
|
|
|
end
|