FIX: display error when moving post fails (#23860)

This fix ensures that an error modal is displayed when a post is moved to a new topic that has an invalid title.
This commit is contained in:
Krzysztof Kotlarek 2023-10-10 11:49:48 +11:00 committed by GitHub
parent b58f660cd2
commit bb342bafe9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 0 deletions

View File

@ -3,6 +3,8 @@
@title={{i18n "topic.move_to.title"}} @title={{i18n "topic.move_to.title"}}
@closeModal={{@closeModal}} @closeModal={{@closeModal}}
class="choose-topic-modal" class="choose-topic-modal"
@flash={{this.flash}}
@flashType="error"
> >
<:body> <:body>
{{#if @model.topic.isPrivateMessage}} {{#if @model.topic.isPrivateMessage}}

View File

@ -19,6 +19,7 @@ export default class MoveToTopic extends Component {
@tracked chronologicalOrder = false; @tracked chronologicalOrder = false;
@tracked selection = "new_topic"; @tracked selection = "new_topic";
@tracked selectedTopicId; @tracked selectedTopicId;
@tracked flash;
constructor() { constructor() {
super(...arguments); super(...arguments);

View File

@ -9,6 +9,13 @@ import { test } from "qunit";
acceptance("Topic move posts", function (needs) { acceptance("Topic move posts", function (needs) {
needs.user(); needs.user();
needs.pretender((server, helper) => {
server.post("/t/280/move-posts", () => {
return helper.response(404, {
errors: ["Invalid title"],
});
});
});
test("default", async function (assert) { test("default", async function (assert) {
await visit("/t/internationalization-localization"); await visit("/t/internationalization-localization");
@ -53,6 +60,20 @@ acceptance("Topic move posts", function (needs) {
); );
}); });
test("display error when new topic has invalid title", async function (assert) {
await visit("/t/internationalization-localization");
await click(".toggle-admin-menu");
await click(".topic-admin-multi-select .btn");
await click("#post_11 .select-below");
await click(".selected-posts .move-to-topic");
await fillIn(".choose-topic-modal #split-topic-name", "Existing topic");
await click(".choose-topic-modal .modal-footer .btn-primary");
assert.strictEqual(
query("#modal-alert").innerText.trim(),
I18n.t("topic.move_to.error")
);
});
test("moving all posts", async function (assert) { test("moving all posts", async function (assert) {
await visit("/t/internationalization-localization"); await visit("/t/internationalization-localization");
await click(".toggle-admin-menu"); await click(".toggle-admin-menu");