Commit 865ab9d7 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'qa/e2e-test-custom-email' into 'master'

Add end-to-end test for custom email

Closes gitlab-org/quality/testcases#84

See merge request gitlab-org/gitlab-ee!15857
parents b2b49576 f771211f
......@@ -25,4 +25,4 @@
= render_if_exists 'admin/application_settings/email_additional_text_setting', form: f
= f.submit _('Save changes'), class: "btn btn-success"
= f.submit _('Save changes'), class: "btn btn-success", data: { qa_selector: 'save_changes_button' }
......@@ -2,7 +2,7 @@
- page_title _("Preferences")
- @content_class = "limit-container-width" unless fluid_layout
%section.settings.as-email.no-animate#js-email-settings{ class: ('expanded' if expanded_by_default?) }
%section.settings.as-email.no-animate#js-email-settings{ class: ('expanded' if expanded_by_default?), data: { qa_selector: 'email_section' } }
.settings-header
%h4
= _('Email')
......
......@@ -270,7 +270,7 @@
%span
= _('Geo')
= nav_link(path: 'application_settings#preferences') do
= link_to preferences_admin_application_settings_path, title: _('Preferences') do
= link_to preferences_admin_application_settings_path, title: _('Preferences'), data: { qa_selector: 'admin_settings_preferences_link' } do
%span
= _('Preferences')
......
......@@ -4,6 +4,6 @@
.form-group
= form.label :email_additional_text, _('Additional text'), class: 'label-bold'
= form.text_area :email_additional_text, class: 'form-control', maxlength: Gitlab::CurrentSettings.email_additional_text_character_limit, rows: 4
= form.text_area :email_additional_text, class: 'form-control', maxlength: Gitlab::CurrentSettings.email_additional_text_character_limit, rows: 4, data: { qa_selector: 'additional_text_textarea_field' }
.form-text.text-muted
= _('Add additional text to appear in all email communications. %{character_limit} character limit') % { character_limit: number_with_delimiter(Gitlab::CurrentSettings.email_additional_text_character_limit) }
......@@ -56,8 +56,10 @@ module QA
module Settings
autoload :Templates, 'qa/ee/page/admin/settings/templates'
autoload :Integration, 'qa/ee/page/admin/settings/integration'
autoload :Preferences, 'qa/ee/page/admin/settings/preferences'
module Component
autoload :Email, 'qa/ee/page/admin/settings/component/email'
autoload :Elasticsearch, 'qa/ee/page/admin/settings/component/elasticsearch'
end
end
......
# frozen_string_literal: true
module QA
module EE
module Page
module Admin
module Settings
module Component
class Email < QA::Page::Base
view 'app/views/admin/application_settings/_email.html.haml' do
element :save_changes_button
end
view 'ee/app/views/admin/application_settings/_email_additional_text_setting.html.haml' do
element :additional_text_textarea_field
end
def additional_text_textarea_text
find_element(:additional_text_textarea_field).text
end
def fill_additional_text(text)
fill_element(:additional_text_textarea_field, text)
end
def save_changes
click_element(:save_changes_button)
end
end
end
end
end
end
end
end
# frozen_string_literal: true
module QA
module EE
module Page
module Admin
module Settings
class Preferences < QA::Page::Base
include QA::Page::Settings::Common
view 'app/views/admin/application_settings/preferences.html.haml' do
element :email_section
end
def expand_email_settings(&block)
expand_section(:email_section) do
Component::Email.perform(&block)
end
end
end
end
end
end
end
end
......@@ -11,12 +11,21 @@ module QA
element :admin_settings_repository_item
element :admin_settings_general_item
element :admin_settings_metrics_and_profiling_item
element :admin_settings_preferences_link
end
view 'app/views/layouts/nav/sidebar/_admin.html.haml' do
element :integration_settings_link
end
def go_to_preferences_settings
hover_settings do
within_submenu do
click_element :admin_settings_preferences_link
end
end
end
def go_to_repository_settings
hover_settings do
within_submenu do
......
......@@ -11,7 +11,7 @@ module QA
within_element(element_name) do
# Because it is possible to click the button before the JS toggle code is bound
wait(reload: false) do
click_button 'Expand' unless has_css?('button', text: 'Collapse')
click_button 'Expand' unless has_css?('button', text: 'Collapse', wait: 1)
has_content?('Collapse')
end
......
# frozen_string_literal: true
require 'securerandom'
module QA
context 'Plan' do
describe 'Custom email' do
before do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Page::Main::Menu.perform(&:click_admin_area)
Page::Admin::Menu.perform(&:go_to_preferences_settings)
end
it 'customizes email with additional text' do
random_custom_text = "Testing custom email - #{SecureRandom.hex(8)}"
EE::Page::Admin::Settings::Preferences.perform do |preferences|
preferences.expand_email_settings do |email_settings|
email_settings.fill_additional_text(random_custom_text)
email_settings.save_changes
expect(email_settings.additional_text_textarea_text).to have_content(random_custom_text)
end
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment