Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-03-01 12:11:01 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-03-01 12:11:01 +0300
commitc7cb37255796023730d0e31324a533e55e25bc46 (patch)
tree5140bef8ec205dd79b71066aa3ed3a3e4cb00be0 /spec
parent21543f57d625a70c3884d1915fa14ad340d01edc (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/notification_settings_controller_spec.rb202
-rw-r--r--spec/features/groups/show_spec.rb5
-rw-r--r--spec/features/profiles/user_visits_notifications_tab_spec.rb9
-rw-r--r--spec/features/projects/show/user_manages_notifications_spec.rb34
-rw-r--r--spec/frontend/notifications/components/notifications_dropdown_spec.js2
-rw-r--r--spec/support/helpers/cycle_analytics_helpers.rb4
-rw-r--r--spec/views/projects/_home_panel.html.haml_spec.rb10
7 files changed, 30 insertions, 236 deletions
diff --git a/spec/controllers/notification_settings_controller_spec.rb b/spec/controllers/notification_settings_controller_spec.rb
deleted file mode 100644
index c4d67df15f7..00000000000
--- a/spec/controllers/notification_settings_controller_spec.rb
+++ /dev/null
@@ -1,202 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe NotificationSettingsController do
- let(:project) { create(:project) }
- let(:group) { create(:group, :internal) }
- let(:user) { create(:user) }
-
- before do
- project.add_developer(user)
- end
-
- describe '#create' do
- context 'when not authorized' do
- it 'redirects to sign in page' do
- post :create,
- params: {
- project_id: project.id,
- notification_setting: { level: :participating }
- }
-
- expect(response).to redirect_to(new_user_session_path)
- end
- end
-
- context 'when authorized' do
- let(:notification_setting) { user.notification_settings_for(source) }
- let(:custom_events) do
- events = {}
-
- NotificationSetting.email_events(source).each do |event|
- events[event.to_s] = true
- end
-
- events
- end
-
- before do
- sign_in(user)
- end
-
- context 'for projects' do
- let(:source) { project }
-
- it 'creates notification setting' do
- post :create,
- params: {
- project_id: project.id,
- notification_setting: { level: :participating }
- }
-
- expect(response).to have_gitlab_http_status(:ok)
- expect(notification_setting.level).to eq("participating")
- expect(notification_setting.user_id).to eq(user.id)
- expect(notification_setting.source_id).to eq(project.id)
- expect(notification_setting.source_type).to eq("Project")
- end
-
- context 'with custom settings' do
- it 'creates notification setting' do
- post :create,
- params: {
- project_id: project.id,
- notification_setting: { level: :custom }.merge(custom_events)
- }
-
- expect(response).to have_gitlab_http_status(:ok)
- expect(notification_setting.level).to eq("custom")
-
- custom_events.each do |event, value|
- expect(notification_setting.event_enabled?(event)).to eq(value)
- end
- end
- end
- end
-
- context 'for groups' do
- let(:source) { group }
-
- it 'creates notification setting' do
- post :create,
- params: {
- namespace_id: group.id,
- notification_setting: { level: :watch }
- }
-
- expect(response).to have_gitlab_http_status(:ok)
- expect(notification_setting.level).to eq("watch")
- expect(notification_setting.user_id).to eq(user.id)
- expect(notification_setting.source_id).to eq(group.id)
- expect(notification_setting.source_type).to eq("Namespace")
- end
-
- context 'with custom settings' do
- it 'creates notification setting' do
- post :create,
- params: {
- namespace_id: group.id,
- notification_setting: { level: :custom }.merge(custom_events)
- }
-
- expect(response).to have_gitlab_http_status(:ok)
- expect(notification_setting.level).to eq("custom")
-
- custom_events.each do |event, value|
- expect(notification_setting.event_enabled?(event)).to eq(value)
- end
- end
- end
- end
- end
-
- context 'not authorized' do
- let(:private_project) { create(:project, :private) }
-
- before do
- sign_in(user)
- end
-
- it 'returns 404' do
- post :create,
- params: {
- project_id: private_project.id,
- notification_setting: { level: :participating }
- }
-
- expect(response).to have_gitlab_http_status(:not_found)
- end
- end
- end
-
- describe '#update' do
- let(:notification_setting) { user.global_notification_setting }
-
- context 'when not authorized' do
- it 'redirects to sign in page' do
- put :update,
- params: {
- id: notification_setting,
- notification_setting: { level: :participating }
- }
-
- expect(response).to redirect_to(new_user_session_path)
- end
- end
-
- context 'when authorized' do
- before do
- sign_in(user)
- end
-
- it 'returns success' do
- put :update,
- params: {
- id: notification_setting,
- notification_setting: { level: :participating }
- }
-
- expect(response).to have_gitlab_http_status(:ok)
- end
-
- context 'and setting custom notification setting' do
- let(:custom_events) do
- events = {}
-
- notification_setting.email_events.each do |event|
- events[event] = "true"
- end
- end
-
- it 'returns success' do
- put :update,
- params: {
- id: notification_setting,
- notification_setting: { level: :participating, events: custom_events }
- }
-
- expect(response).to have_gitlab_http_status(:ok)
- end
- end
- end
-
- context 'not authorized' do
- let(:other_user) { create(:user) }
-
- before do
- sign_in(other_user)
- end
-
- it 'returns 404' do
- put :update,
- params: {
- id: notification_setting,
- notification_setting: { level: :participating }
- }
-
- expect(response).to have_gitlab_http_status(:not_found)
- end
- end
- end
-end
diff --git a/spec/features/groups/show_spec.rb b/spec/features/groups/show_spec.rb
index 5067f11be67..4e213f65108 100644
--- a/spec/features/groups/show_spec.rb
+++ b/spec/features/groups/show_spec.rb
@@ -163,7 +163,6 @@ RSpec.describe 'Group show page' do
let!(:project) { create(:project, namespace: group) }
before do
- stub_feature_flags(vue_notification_dropdown: false)
group.add_maintainer(maintainer)
sign_in(maintainer)
end
@@ -171,14 +170,14 @@ RSpec.describe 'Group show page' do
it 'is enabled by default' do
visit path
- expect(page).to have_selector('.notifications-btn:not(.disabled)', visible: true)
+ expect(page).to have_selector('[data-testid="notification-button"]:not(.disabled)')
end
it 'is disabled if emails are disabled' do
group.update_attribute(:emails_disabled, true)
visit path
- expect(page).to have_selector('.notifications-btn.disabled', visible: true)
+ expect(page).to have_selector('[data-testid="notification-button"].disabled')
end
end
diff --git a/spec/features/profiles/user_visits_notifications_tab_spec.rb b/spec/features/profiles/user_visits_notifications_tab_spec.rb
index 289fbff0404..fb133071e7b 100644
--- a/spec/features/profiles/user_visits_notifications_tab_spec.rb
+++ b/spec/features/profiles/user_visits_notifications_tab_spec.rb
@@ -7,7 +7,6 @@ RSpec.describe 'User visits the notifications tab', :js do
let(:user) { create(:user) }
before do
- stub_feature_flags(vue_notification_dropdown: false)
project.add_maintainer(user)
sign_in(user)
visit(profile_notifications_path)
@@ -16,17 +15,17 @@ RSpec.describe 'User visits the notifications tab', :js do
it 'changes the project notifications setting' do
expect(page).to have_content('Notifications')
- first('#notifications-button').click
- click_link('On mention')
+ first('[data-testid="notification-button"]').click
+ click_button('On mention')
- expect(page).to have_selector('#notifications-button', text: 'On mention')
+ expect(page).to have_selector('[data-testid="notification-button"]', text: 'On mention')
end
context 'when project emails are disabled' do
let(:project) { create(:project, emails_disabled: true) }
it 'notification button is disabled' do
- expect(page).to have_selector('.notifications-btn.disabled', visible: true)
+ expect(page).to have_selector('[data-testid="notification-button"].disabled')
end
end
end
diff --git a/spec/features/projects/show/user_manages_notifications_spec.rb b/spec/features/projects/show/user_manages_notifications_spec.rb
index 5f7d9b0963b..9fe8dc920a9 100644
--- a/spec/features/projects/show/user_manages_notifications_spec.rb
+++ b/spec/features/projects/show/user_manages_notifications_spec.rb
@@ -6,38 +6,36 @@ RSpec.describe 'Projects > Show > User manages notifications', :js do
let(:project) { create(:project, :public, :repository) }
before do
- stub_feature_flags(vue_notification_dropdown: false)
sign_in(project.owner)
end
def click_notifications_button
- first('.notifications-btn').click
+ first('[data-testid="notification-button"]').click
end
it 'changes the notification setting' do
visit project_path(project)
click_notifications_button
- click_link 'On mention'
+ click_button 'On mention'
- page.within('.notification-dropdown') do
- expect(page).not_to have_css('.gl-spinner')
- end
+ wait_for_requests
click_notifications_button
- expect(find('.update-notification.is-active')).to have_content('On mention')
- expect(page).to have_css('.notifications-icon[data-testid="notifications-icon"]')
+
+ page.within first('[data-testid="notification-button"]') do
+ expect(page.find('.gl-new-dropdown-item.is-active')).to have_content('On mention')
+ expect(page).to have_css('[data-testid="notifications-icon"]')
+ end
end
it 'changes the notification setting to disabled' do
visit project_path(project)
click_notifications_button
- click_link 'Disabled'
+ click_button 'Disabled'
- page.within('.notification-dropdown') do
- expect(page).not_to have_css('.gl-spinner')
+ page.within first('[data-testid="notification-button"]') do
+ expect(page).to have_css('[data-testid="notifications-off-icon"]')
end
-
- expect(page).to have_css('.notifications-icon[data-testid="notifications-off-icon"]')
end
context 'custom notification settings' do
@@ -65,11 +63,13 @@ RSpec.describe 'Projects > Show > User manages notifications', :js do
it 'shows notification settings checkbox' do
visit project_path(project)
click_notifications_button
- page.find('a[data-notification-level="custom"]').click
+ click_button 'Custom'
+
+ wait_for_requests
- page.within('.custom-notifications-form') do
+ page.within('#custom-notifications-modal') do
email_events.each do |event_name|
- expect(page).to have_selector("input[name='notification_setting[#{event_name}]']")
+ expect(page).to have_selector("[data-testid='notification-setting-#{event_name}']")
end
end
end
@@ -80,7 +80,7 @@ RSpec.describe 'Projects > Show > User manages notifications', :js do
it 'is disabled' do
visit project_path(project)
- expect(page).to have_selector('.notifications-btn.disabled', visible: true)
+ expect(page).to have_selector('[data-testid="notification-button"].disabled', visible: true)
end
end
end
diff --git a/spec/frontend/notifications/components/notifications_dropdown_spec.js b/spec/frontend/notifications/components/notifications_dropdown_spec.js
index 88534a6d690..bc5c977d3e0 100644
--- a/spec/frontend/notifications/components/notifications_dropdown_spec.js
+++ b/spec/frontend/notifications/components/notifications_dropdown_spec.js
@@ -162,7 +162,7 @@ describe('NotificationsDropdown', () => {
initialNotificationLevel: level,
});
- const tooltipElement = findByTestId('notificationButton');
+ const tooltipElement = findByTestId('notification-button');
const tooltip = getBinding(tooltipElement.element, 'gl-tooltip');
expect(tooltip.value.title).toBe(`${tooltipTitlePrefix} - ${title}`);
diff --git a/spec/support/helpers/cycle_analytics_helpers.rb b/spec/support/helpers/cycle_analytics_helpers.rb
index a90cbbf3bd3..14041ad0ac6 100644
--- a/spec/support/helpers/cycle_analytics_helpers.rb
+++ b/spec/support/helpers/cycle_analytics_helpers.rb
@@ -15,7 +15,7 @@ module CycleAnalyticsHelpers
end
def toggle_dropdown(field)
- page.within("[data-testid='#{field}']") do
+ page.within("[data-testid*='#{field}']") do
find('.dropdown-toggle').click
wait_for_requests
@@ -26,7 +26,7 @@ module CycleAnalyticsHelpers
def select_dropdown_option_by_value(name, value, elem = '.dropdown-item')
toggle_dropdown name
- page.find("[data-testid='#{name}'] .dropdown-menu").find("#{elem}[value='#{value}']").click
+ page.find("[data-testid*='#{name}'] .dropdown-menu").find("#{elem}[value='#{value}']").click
end
def create_commit_referencing_issue(issue, branch_name: generate(:branch))
diff --git a/spec/views/projects/_home_panel.html.haml_spec.rb b/spec/views/projects/_home_panel.html.haml_spec.rb
index cc0eb9919da..d329c57af00 100644
--- a/spec/views/projects/_home_panel.html.haml_spec.rb
+++ b/spec/views/projects/_home_panel.html.haml_spec.rb
@@ -9,7 +9,6 @@ RSpec.describe 'projects/_home_panel' do
let(:project) { create(:project) }
before do
- stub_feature_flags(vue_notification_dropdown: false)
assign(:project, project)
allow(view).to receive(:current_user).and_return(user)
@@ -25,11 +24,10 @@ RSpec.describe 'projects/_home_panel' do
assign(:notification_setting, notification_settings)
end
- it 'makes it possible to set notification level' do
+ it 'renders Vue app root' do
render
- expect(view).to render_template('shared/notifications/_new_button')
- expect(rendered).to have_selector('.notification-dropdown')
+ expect(rendered).to have_selector('.js-vue-notification-dropdown')
end
end
@@ -40,10 +38,10 @@ RSpec.describe 'projects/_home_panel' do
assign(:notification_setting, nil)
end
- it 'is not possible to set notification level' do
+ it 'does not render Vue app root' do
render
- expect(rendered).not_to have_selector('.notification_dropdown')
+ expect(rendered).not_to have_selector('.js-vue-notification-dropdown')
end
end
end