FIX: Can't dismiss new topics for experimental new new view (#22484)
Regressed in 8b80132f88
due to a lack of
tests.
This commit is contained in:
parent
7ffe0997d7
commit
bf582290ba
|
@ -6,17 +6,17 @@
|
|||
<p>
|
||||
<PreferenceCheckbox
|
||||
@labelKey="topics.bulk.dismiss_new_modal.topics"
|
||||
@checked={{@model.dismissTopics}}
|
||||
@checked={{this.dismissTopics}}
|
||||
@class="dismiss-topics"
|
||||
/>
|
||||
<PreferenceCheckbox
|
||||
@labelKey="topics.bulk.dismiss_new_modal.posts"
|
||||
@checked={{@model.dismissPosts}}
|
||||
@checked={{this.dismissPosts}}
|
||||
@class="dismiss-posts"
|
||||
/>
|
||||
<PreferenceCheckbox
|
||||
@labelKey="topics.bulk.dismiss_new_modal.untrack"
|
||||
@checked={{@model.untrack}}
|
||||
@checked={{this.untrack}}
|
||||
@class="untrack"
|
||||
/>
|
||||
</p>
|
||||
|
|
|
@ -2,9 +2,18 @@ import Component from "@glimmer/component";
|
|||
import { action } from "@ember/object";
|
||||
|
||||
export default class DismissNew extends Component {
|
||||
dismissTopics = true;
|
||||
dismissPosts = true;
|
||||
untrack = false;
|
||||
|
||||
@action
|
||||
dismissed() {
|
||||
this.args.model.dismissCallback();
|
||||
this.args.model.dismissCallback({
|
||||
dismissTopics: this.dismissTopics,
|
||||
dismissPosts: this.dismissPosts,
|
||||
untrack: this.untrack,
|
||||
});
|
||||
|
||||
this.args.closeModal();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,23 @@
|
|||
import Mixin from "@ember/object/mixin";
|
||||
import User from "discourse/models/user";
|
||||
import { inject as service } from "@ember/service";
|
||||
import { action } from "@ember/object";
|
||||
import DismissNewModal from "discourse/components/modal/dismiss-new";
|
||||
|
||||
export default Mixin.create({
|
||||
modal: service(),
|
||||
currentUser: service(),
|
||||
|
||||
@action
|
||||
resetNew() {
|
||||
const user = User.current();
|
||||
if (!user.new_new_view_enabled) {
|
||||
if (!this.currentUser.new_new_view_enabled) {
|
||||
return this.callResetNew();
|
||||
}
|
||||
|
||||
this.modal.show(DismissNewModal, {
|
||||
model: {
|
||||
dismissTopics: true,
|
||||
dismissPosts: true,
|
||||
dismissCallback: () =>
|
||||
this.callResetNew(
|
||||
this.model.dismissPosts,
|
||||
this.model.dismissTopics,
|
||||
this.model.untrack
|
||||
),
|
||||
dismissCallback: ({ dismissPosts, dismissTopics, untrack }) => {
|
||||
this.callResetNew(dismissPosts, dismissTopics, untrack);
|
||||
},
|
||||
},
|
||||
});
|
||||
},
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
|
||||
describe "Filtering topics", type: :system, js: true do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
let(:topic_list) { PageObjects::Components::TopicList.new }
|
||||
let(:dismiss_new_modal) { PageObjects::Modals::DismissNew.new }
|
||||
fab!(:group) { Fabricate(:group).tap { |g| g.add(user) } }
|
||||
fab!(:topic) { Fabricate(:topic) }
|
||||
|
||||
let(:topic_list) { PageObjects::Components::TopicList.new }
|
||||
let(:dismiss_new_modal) { PageObjects::Modals::DismissNew.new }
|
||||
|
||||
before { SiteSetting.experimental_new_new_view_groups = group.id }
|
||||
|
||||
it "displays confirmation modal with preselected options" do
|
||||
|
@ -15,9 +16,15 @@ describe "Filtering topics", type: :system, js: true do
|
|||
visit("/new")
|
||||
|
||||
expect(topic_list).to have_topic(topic)
|
||||
|
||||
find(".dismiss-read", text: "Dismiss…").click
|
||||
|
||||
expect(dismiss_new_modal).to have_dismiss_topics_checked
|
||||
expect(dismiss_new_modal).to have_dismiss_posts_checked
|
||||
expect(dismiss_new_modal).to have_untrack_unchecked
|
||||
|
||||
dismiss_new_modal.click_dismiss
|
||||
|
||||
expect(topic_list).to have_no_topics
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,6 +14,10 @@ module PageObjects
|
|||
page.has_css?(TOPIC_LIST_ITEM_SELECTOR, count: count)
|
||||
end
|
||||
|
||||
def has_no_topics?
|
||||
page.has_no_css?(TOPIC_LIST_ITEM_SELECTOR)
|
||||
end
|
||||
|
||||
def has_topic?(topic)
|
||||
page.has_css?(topic_list_item_class(topic))
|
||||
end
|
||||
|
|
|
@ -14,6 +14,11 @@ module PageObjects
|
|||
def has_untrack_unchecked?
|
||||
find(".untrack label").has_no_checked_field?
|
||||
end
|
||||
|
||||
def click_dismiss
|
||||
click_button("dismiss-read-confirm")
|
||||
self
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue