FIX: Assign topic button not working (#164)

Since this commit
195dcc92cb
the updateUsername function was missing an @action decorator. This adds
it back and extends the assign acceptance tests to click the
mobile/desktop assign buttons and open the modal and click the
suggestion to save the assignment.
This commit is contained in:
Martin Brennan 2021-06-29 10:12:19 +10:00 committed by GitHub
parent 195dcc92cb
commit 8b0596fc87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 66 additions and 2 deletions

View File

@ -79,6 +79,7 @@ export default Controller.extend({
.catch(popupAjaxError);
},
@action
updateUsername(selected) {
this.set("model.username", selected.firstObject);
},

View File

@ -11,13 +11,76 @@ acceptance("Assign mobile", function (needs) {
needs.settings({ assign_enabled: true });
needs.hooks.beforeEach(() => clearTopicFooterButtons());
needs.pretender((server, helper) => {
server.get("/assign/suggestions", () => {
return helper.response({
success: true,
assign_allowed_groups: false,
suggestions: [
{
id: 19,
username: "eviltrout",
name: "Robin Ward",
avatar_template:
"/user_avatar/meta.discourse.org/eviltrout/{size}/5275_2.png",
},
],
});
});
server.put("/assign/assign", () => {
return helper.response({ success: true });
});
});
test("Footer dropdown contains button", async (assert) => {
updateCurrentUser({ can_assign: true });
const menu = selectKit(".topic-footer-mobile-dropdown");
await visit("/t/internationalization-localization/280");
const menu = selectKit(".topic-footer-mobile-dropdown");
await menu.expand();
assert.ok(menu.rowByValue("assign").exists());
await menu.selectRowByValue("assign");
assert.ok(exists(".assign.modal-body"), "assign modal opens");
await click(".assign-suggestions .avatar");
});
});
acceptance("Assign desktop", function (needs) {
needs.user();
needs.settings({ assign_enabled: true });
needs.hooks.beforeEach(() => clearTopicFooterButtons());
needs.pretender((server, helper) => {
server.get("/assign/suggestions", () => {
return helper.response({
success: true,
assign_allowed_groups: false,
suggestions: [
{
id: 19,
username: "eviltrout",
name: "Robin Ward",
avatar_template:
"/user_avatar/meta.discourse.org/eviltrout/{size}/5275_2.png",
},
],
});
});
server.put("/assign/assign", () => {
return helper.response({ success: true });
});
});
test("Footer dropdown contains button", async (assert) => {
updateCurrentUser({ can_assign: true });
await visit("/t/internationalization-localization/280");
await click("#topic-footer-button-assign");
assert.ok(exists(".assign.modal-body"), "assign modal opens");
await click(".assign-suggestions .avatar");
});
});