FIX: ensures tag notification level is changed (#21106)

Following a change in e9f7262813 which prevents the notification level to be returned from the update endpoint, the model couldn't update itself. This commit makes the update manually and adds a test to prevent future regressions.

Note we could also change the backend endpoint, but this should work correctly with minimum risk.
This commit is contained in:
Joffrey JAFFEUX 2023-04-17 10:48:41 +02:00 committed by GitHub
parent a299c61d72
commit 2535381f44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 0 deletions

View File

@ -184,6 +184,8 @@ export default DiscoverySortableController.extend(
.then((response) => {
const payload = response.responseJson;
this.tagNotification.set("notification_level", notificationLevel);
this.currentUser.setProperties({
watched_tags: payload.watched_tags,
watching_first_post_tags: payload.watching_first_post_tags,

View File

@ -37,6 +37,11 @@ module PageObjects
expand
element.find(".select-kit-row[data-value='#{value}']").click
end
def select_row_by_name(name)
expand
element.find(".select-kit-row[data-name='#{name}']").click
end
end
end
end

View File

@ -0,0 +1,24 @@
# frozen_string_literal: true
describe "Tag notification level", type: :system, js: true do
let(:tags_page) { PageObjects::Pages::Tag.new }
let(:select_kit) do
PageObjects::Components::SelectKit.new(page.find(".tag-notifications-button"))
end
fab!(:tag_1) { Fabricate(:tag) }
fab!(:current_user) { Fabricate(:admin) }
before { sign_in(current_user) }
describe "when changing a tag's notification level" do
it "should change instantly" do
tags_page.visit_tag(tag_1)
expect(select_kit).to have_selected_name("regular")
select_kit.select_row_by_name("watching")
expect(select_kit).to have_selected_name("watching")
end
end
end