DEV: Consistently use `response` helper (#17627)
This commit is contained in:
parent
20462cf2b5
commit
b179fb98b1
|
@ -7,15 +7,15 @@ import {
|
||||||
} from "discourse/tests/helpers/qunit-helpers";
|
} from "discourse/tests/helpers/qunit-helpers";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
import pretender from "../helpers/create-pretender";
|
import pretender, { response } from "../helpers/create-pretender";
|
||||||
|
|
||||||
acceptance("Dismiss notification confirmation", function (needs) {
|
acceptance("Dismiss notification confirmation", function (needs) {
|
||||||
needs.user();
|
needs.user();
|
||||||
|
|
||||||
test("does not show modal when no high priority notifications", async function (assert) {
|
test("does not show modal when no high priority notifications", async function (assert) {
|
||||||
pretender.put("/notifications/mark-read", () => {
|
pretender.put("/notifications/mark-read", () =>
|
||||||
return [200, { "Content-Type": "application/json" }, { success: true }];
|
response({ success: true })
|
||||||
});
|
);
|
||||||
|
|
||||||
await visit("/");
|
await visit("/");
|
||||||
await click(".current-user");
|
await click(".current-user");
|
||||||
|
@ -50,9 +50,9 @@ acceptance("Dismiss notification confirmation", function (needs) {
|
||||||
query(".dismiss-notification-confirmation-modal .btn-primary").innerText,
|
query(".dismiss-notification-confirmation-modal .btn-primary").innerText,
|
||||||
I18n.t("notifications.dismiss_confirmation.dismiss")
|
I18n.t("notifications.dismiss_confirmation.dismiss")
|
||||||
);
|
);
|
||||||
pretender.put("/notifications/mark-read", () => {
|
pretender.put("/notifications/mark-read", () =>
|
||||||
return [200, { "Content-Type": "application/json" }, { success: true }];
|
response({ success: true })
|
||||||
});
|
);
|
||||||
|
|
||||||
await click(".dismiss-notification-confirmation-modal .btn-primary");
|
await click(".dismiss-notification-confirmation-modal .btn-primary");
|
||||||
|
|
||||||
|
|
|
@ -60,48 +60,36 @@ let callbackCount = 0;
|
||||||
|
|
||||||
acceptance("Second Factor Auth Page", function (needs) {
|
acceptance("Second Factor Auth Page", function (needs) {
|
||||||
needs.user();
|
needs.user();
|
||||||
needs.pretender((server, helpers) => {
|
needs.pretender((server, { parsePostData, response }) => {
|
||||||
server.get("/session/2fa.json", (request) => {
|
server.get("/session/2fa.json", (request) => {
|
||||||
const response = { ...RESPONSES[request.queryParams.nonce] };
|
const responseBody = { ...RESPONSES[request.queryParams.nonce] };
|
||||||
const status = response.status || 200;
|
const status = responseBody.status || 200;
|
||||||
delete response.status;
|
delete responseBody.status;
|
||||||
return [status, { "Content-Type": "application/json" }, response];
|
return response(status, responseBody);
|
||||||
});
|
});
|
||||||
|
|
||||||
server.post("/session/2fa", (request) => {
|
server.post("/session/2fa", (request) => {
|
||||||
const params = helpers.parsePostData(request.requestBody);
|
const params = parsePostData(request.requestBody);
|
||||||
if (params.second_factor_token === WRONG_TOTP) {
|
if (params.second_factor_token === WRONG_TOTP) {
|
||||||
return [
|
return response(401, {
|
||||||
401,
|
|
||||||
{ "Content-Type": "application/json" },
|
|
||||||
{
|
|
||||||
error: "invalid token man",
|
error: "invalid token man",
|
||||||
ok: false,
|
ok: false,
|
||||||
},
|
});
|
||||||
];
|
|
||||||
} else {
|
} else {
|
||||||
return [
|
return response({
|
||||||
200,
|
|
||||||
{ "Content-Type": "application/json" },
|
|
||||||
{
|
|
||||||
ok: true,
|
ok: true,
|
||||||
callback_method: "PUT",
|
callback_method: "PUT",
|
||||||
callback_path: "/callback-path",
|
callback_path: "/callback-path",
|
||||||
redirect_url: "/",
|
redirect_url: "/",
|
||||||
},
|
});
|
||||||
];
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
server.put("/callback-path", () => {
|
server.put("/callback-path", () => {
|
||||||
callbackCount++;
|
callbackCount++;
|
||||||
return [
|
return response(200, {
|
||||||
200,
|
|
||||||
{ "Content-Type": "application/json" },
|
|
||||||
{
|
|
||||||
whatever: true,
|
whatever: true,
|
||||||
},
|
});
|
||||||
];
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||||
import { click, render } from "@ember/test-helpers";
|
import { click, render } from "@ember/test-helpers";
|
||||||
import { count, exists, query } from "discourse/tests/helpers/qunit-helpers";
|
import { count, exists, query } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { hbs } from "ember-cli-htmlbars";
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
import pretender from "discourse/tests/helpers/create-pretender";
|
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||||
|
|
||||||
module("Integration | Component | admin-report", function (hooks) {
|
module("Integration | Component | admin-report", function (hooks) {
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
@ -124,19 +124,15 @@ module("Integration | Component | admin-report", function (hooks) {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("rate limited", async function (assert) {
|
test("rate limited", async function (assert) {
|
||||||
pretender.get("/admin/reports/bulk", () => {
|
pretender.get("/admin/reports/bulk", () =>
|
||||||
return [
|
response(429, {
|
||||||
429,
|
|
||||||
{ "Content-Type": "application/json" },
|
|
||||||
{
|
|
||||||
errors: [
|
errors: [
|
||||||
"You’ve performed this action too many times. Please wait 10 seconds before trying again.",
|
"You’ve performed this action too many times. Please wait 10 seconds before trying again.",
|
||||||
],
|
],
|
||||||
error_type: "rate_limit",
|
error_type: "rate_limit",
|
||||||
extras: { wait_seconds: 10 },
|
extras: { wait_seconds: 10 },
|
||||||
},
|
})
|
||||||
];
|
);
|
||||||
});
|
|
||||||
|
|
||||||
await render(hbs`<AdminReport @dataSourceName="signups_rate_limited" />`);
|
await render(hbs`<AdminReport @dataSourceName="signups_rate_limited" />`);
|
||||||
|
|
||||||
|
|
|
@ -3,15 +3,13 @@ import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||||
import { render } from "@ember/test-helpers";
|
import { render } from "@ember/test-helpers";
|
||||||
import { createFile } from "discourse/tests/helpers/qunit-helpers";
|
import { createFile } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { hbs } from "ember-cli-htmlbars";
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
import pretender from "discourse/tests/helpers/create-pretender";
|
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||||
|
|
||||||
module("Integration | Component | avatar-uploader", function (hooks) {
|
module("Integration | Component | avatar-uploader", function (hooks) {
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
pretender.post("/uploads.json", () => {
|
pretender.post("/uploads.json", () => response({}));
|
||||||
return [200, { "Content-Type": "application/json" }, {}];
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("default", async function (assert) {
|
test("default", async function (assert) {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { module, test } from "qunit";
|
||||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||||
import { click, render } from "@ember/test-helpers";
|
import { click, render } from "@ember/test-helpers";
|
||||||
import { hbs } from "ember-cli-htmlbars";
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
import pretender from "discourse/tests/helpers/create-pretender";
|
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||||
import EmberObject from "@ember/object";
|
import EmberObject from "@ember/object";
|
||||||
|
|
||||||
|
@ -23,11 +23,7 @@ module("Integration | Component | badge-title", function (hooks) {
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
pretender.put("/u/eviltrout/preferences/badge_title", () => [
|
pretender.put("/u/eviltrout/preferences/badge_title", () => response({}));
|
||||||
200,
|
|
||||||
{ "Content-Type": "application/json" },
|
|
||||||
{},
|
|
||||||
]);
|
|
||||||
|
|
||||||
await render(hbs`
|
await render(hbs`
|
||||||
<BadgeTitle @selectableUserBadges={{this.selectableUserBadges}} />
|
<BadgeTitle @selectableUserBadges={{this.selectableUserBadges}} />
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||||
import { render } from "@ember/test-helpers";
|
import { render } from "@ember/test-helpers";
|
||||||
import { query } from "discourse/tests/helpers/qunit-helpers";
|
import { query } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { hbs } from "ember-cli-htmlbars";
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
import pretender from "discourse/tests/helpers/create-pretender";
|
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||||
import { resetCache } from "pretty-text/upload-short-url";
|
import { resetCache } from "pretty-text/upload-short-url";
|
||||||
|
|
||||||
module("Integration | Component | cook-text", function (hooks) {
|
module("Integration | Component | cook-text", function (hooks) {
|
||||||
|
@ -21,19 +21,15 @@ module("Integration | Component | cook-text", function (hooks) {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("resolves short URLs", async function (assert) {
|
test("resolves short URLs", async function (assert) {
|
||||||
pretender.post("/uploads/lookup-urls", () => {
|
pretender.post("/uploads/lookup-urls", () =>
|
||||||
return [
|
response([
|
||||||
200,
|
|
||||||
{ "Content-Type": "application/json" },
|
|
||||||
[
|
|
||||||
{
|
{
|
||||||
short_url: "upload://a.png",
|
short_url: "upload://a.png",
|
||||||
url: "/images/avatar.png",
|
url: "/images/avatar.png",
|
||||||
short_path: "/images/d-logo-sketch.png",
|
short_path: "/images/d-logo-sketch.png",
|
||||||
},
|
},
|
||||||
],
|
])
|
||||||
];
|
);
|
||||||
});
|
|
||||||
|
|
||||||
await render(
|
await render(
|
||||||
hbs`<CookText @rawText="![an image](upload://a.png)" @class="post-body" />`
|
hbs`<CookText @rawText="![an image](upload://a.png)" @class="post-body" />`
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||||
import { click, render } from "@ember/test-helpers";
|
import { click, render } from "@ember/test-helpers";
|
||||||
import { exists, query } from "discourse/tests/helpers/qunit-helpers";
|
import { exists, query } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { hbs } from "ember-cli-htmlbars";
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
import pretender from "discourse/tests/helpers/create-pretender";
|
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||||
import User from "discourse/models/user";
|
import User from "discourse/models/user";
|
||||||
|
|
||||||
|
@ -11,19 +11,13 @@ module("Integration | Component | invite-panel", function (hooks) {
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
test("shows the invite link after it is generated", async function (assert) {
|
test("shows the invite link after it is generated", async function (assert) {
|
||||||
pretender.get("/u/search/users", () => {
|
pretender.get("/u/search/users", () => response({ users: [] }));
|
||||||
return [200, { "Content-Type": "application/json" }, { users: [] }];
|
|
||||||
});
|
|
||||||
|
|
||||||
pretender.post("/invites", () => {
|
pretender.post("/invites", () =>
|
||||||
return [
|
response({
|
||||||
200,
|
|
||||||
{ "Content-Type": "application/json" },
|
|
||||||
{
|
|
||||||
link: "http://example.com/invites/92c297e886a0ca03089a109ccd6be155",
|
link: "http://example.com/invites/92c297e886a0ca03089a109ccd6be155",
|
||||||
},
|
})
|
||||||
];
|
);
|
||||||
});
|
|
||||||
|
|
||||||
this.currentUser.set("details", { can_invite_via_email: true });
|
this.currentUser.set("details", { can_invite_via_email: true });
|
||||||
this.set("panel", {
|
this.set("panel", {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { module, test } from "qunit";
|
||||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||||
import { click, render } from "@ember/test-helpers";
|
import { click, render } from "@ember/test-helpers";
|
||||||
import { count, exists, query } from "discourse/tests/helpers/qunit-helpers";
|
import { count, exists, query } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import pretender from "discourse/tests/helpers/create-pretender";
|
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||||
import { hbs } from "ember-cli-htmlbars";
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
|
|
||||||
module("Integration | Component | site-header", function (hooks) {
|
module("Integration | Component | site-header", function (hooks) {
|
||||||
|
@ -43,7 +43,7 @@ module("Integration | Component | site-header", function (hooks) {
|
||||||
|
|
||||||
pretender.get("/notifications", () => {
|
pretender.get("/notifications", () => {
|
||||||
assert.ok(false, "it should not try to refresh notifications");
|
assert.ok(false, "it should not try to refresh notifications");
|
||||||
return [403, { "Content-Type": "application/json" }, {}];
|
return response(403, {});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Click anywhere
|
// Click anywhere
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { render } from "@ember/test-helpers";
|
||||||
import { cloneJSON } from "discourse-common/lib/object";
|
import { cloneJSON } from "discourse-common/lib/object";
|
||||||
import NotificationFixtures from "discourse/tests/fixtures/notification-fixtures";
|
import NotificationFixtures from "discourse/tests/fixtures/notification-fixtures";
|
||||||
import { hbs } from "ember-cli-htmlbars";
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
import pretender from "discourse/tests/helpers/create-pretender";
|
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
|
|
||||||
function getNotificationsData() {
|
function getNotificationsData() {
|
||||||
|
@ -22,16 +22,12 @@ module(
|
||||||
hooks.beforeEach(() => {
|
hooks.beforeEach(() => {
|
||||||
pretender.get("/notifications", (request) => {
|
pretender.get("/notifications", (request) => {
|
||||||
queryParams = request.queryParams;
|
queryParams = request.queryParams;
|
||||||
return [
|
return response({ notifications: notificationsData });
|
||||||
200,
|
|
||||||
{ "Content-Type": "application/json" },
|
|
||||||
{ notifications: notificationsData },
|
|
||||||
];
|
|
||||||
});
|
});
|
||||||
|
|
||||||
pretender.put("/notifications/mark-read", () => {
|
pretender.put("/notifications/mark-read", () =>
|
||||||
return [200, { "Content-Type": "application/json" }, { success: true }];
|
response({ success: true })
|
||||||
});
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
hooks.afterEach(() => {
|
hooks.afterEach(() => {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import Topic from "discourse/models/topic";
|
||||||
import User from "discourse/models/user";
|
import User from "discourse/models/user";
|
||||||
import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
|
import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { next } from "@ember/runloop";
|
import { next } from "@ember/runloop";
|
||||||
import pretender from "discourse/tests/helpers/create-pretender";
|
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||||
import { settled } from "@ember/test-helpers";
|
import { settled } from "@ember/test-helpers";
|
||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
|
|
||||||
|
@ -594,13 +594,9 @@ discourseModule("Unit | Controller | topic", function (hooks) {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("selectReplies", async function (assert) {
|
test("selectReplies", async function (assert) {
|
||||||
pretender.get("/posts/1/reply-ids.json", () => {
|
pretender.get("/posts/1/reply-ids.json", () =>
|
||||||
return [
|
response([{ id: 2, level: 1 }])
|
||||||
200,
|
);
|
||||||
{ "Content-Type": "application/json" },
|
|
||||||
[{ id: 2, level: 1 }],
|
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
let model = topicWithStream({
|
let model = topicWithStream({
|
||||||
posts: [{ id: 1 }, { id: 2 }],
|
posts: [{ id: 1 }, { id: 2 }],
|
||||||
|
@ -656,9 +652,7 @@ discourseModule("Unit | Controller | topic", function (hooks) {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("deletePost - no modal is shown if post does not have replies", function (assert) {
|
test("deletePost - no modal is shown if post does not have replies", function (assert) {
|
||||||
pretender.get("/posts/2/reply-ids.json", () => {
|
pretender.get("/posts/2/reply-ids.json", () => response([]));
|
||||||
return [200, { "Content-Type": "application/json" }, []];
|
|
||||||
});
|
|
||||||
|
|
||||||
let destroyed;
|
let destroyed;
|
||||||
const post = EmberObject.create({
|
const post = EmberObject.create({
|
||||||
|
|
|
@ -3,15 +3,13 @@ import {
|
||||||
linkSeenMentions,
|
linkSeenMentions,
|
||||||
} from "discourse/lib/link-mentions";
|
} from "discourse/lib/link-mentions";
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import pretender from "discourse/tests/helpers/create-pretender";
|
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||||
import domFromString from "discourse-common/lib/dom-from-string";
|
import domFromString from "discourse-common/lib/dom-from-string";
|
||||||
|
|
||||||
module("Unit | Utility | link-mentions", function () {
|
module("Unit | Utility | link-mentions", function () {
|
||||||
test("linkSeenMentions replaces users and groups", async function (assert) {
|
test("linkSeenMentions replaces users and groups", async function (assert) {
|
||||||
pretender.get("/u/is_local_username", () => [
|
pretender.get("/u/is_local_username", () =>
|
||||||
200,
|
response({
|
||||||
{ "Content-Type": "application/json" },
|
|
||||||
{
|
|
||||||
valid: ["valid_user"],
|
valid: ["valid_user"],
|
||||||
valid_groups: ["valid_group"],
|
valid_groups: ["valid_group"],
|
||||||
mentionable_groups: [
|
mentionable_groups: [
|
||||||
|
@ -22,8 +20,8 @@ module("Unit | Utility | link-mentions", function () {
|
||||||
],
|
],
|
||||||
cannot_see: [],
|
cannot_see: [],
|
||||||
max_users_notified_per_group_mention: 100,
|
max_users_notified_per_group_mention: 100,
|
||||||
},
|
})
|
||||||
]);
|
);
|
||||||
|
|
||||||
await fetchUnseenMentions([
|
await fetchUnseenMentions([
|
||||||
"valid_user",
|
"valid_user",
|
||||||
|
|
|
@ -5,7 +5,7 @@ import Post from "discourse/models/post";
|
||||||
import { Promise } from "rsvp";
|
import { Promise } from "rsvp";
|
||||||
import User from "discourse/models/user";
|
import User from "discourse/models/user";
|
||||||
import createStore from "discourse/tests/helpers/create-store";
|
import createStore from "discourse/tests/helpers/create-store";
|
||||||
import pretender from "discourse/tests/helpers/create-pretender";
|
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||||
import sinon from "sinon";
|
import sinon from "sinon";
|
||||||
|
|
||||||
function buildStream(id, stream) {
|
function buildStream(id, stream) {
|
||||||
|
@ -873,10 +873,6 @@ module("Unit | Model | post-stream", function () {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const response = (object) => {
|
|
||||||
return [200, { "Content-Type": "application/json" }, object];
|
|
||||||
};
|
|
||||||
|
|
||||||
pretender.get("/posts/4", () => {
|
pretender.get("/posts/4", () => {
|
||||||
return response({ id: 4, post_number: 4 });
|
return response({ id: 4, post_number: 4 });
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
import pretender from "discourse/tests/helpers/create-pretender";
|
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||||
import {
|
import {
|
||||||
discourseModule,
|
discourseModule,
|
||||||
publishToMessageBus,
|
publishToMessageBus,
|
||||||
|
@ -10,10 +10,7 @@ import User from "discourse/models/user";
|
||||||
|
|
||||||
function setupPretender() {
|
function setupPretender() {
|
||||||
pretender.get(`/u/test/private-message-topic-tracking-state`, () => {
|
pretender.get(`/u/test/private-message-topic-tracking-state`, () => {
|
||||||
return [
|
return response([
|
||||||
200,
|
|
||||||
{ "Content-Type": "application/json" },
|
|
||||||
[
|
|
||||||
{
|
{
|
||||||
topic_id: 123,
|
topic_id: 123,
|
||||||
highest_post_number: 12,
|
highest_post_number: 12,
|
||||||
|
@ -21,8 +18,7 @@ function setupPretender() {
|
||||||
notification_level: 3,
|
notification_level: 3,
|
||||||
group_ids: [],
|
group_ids: [],
|
||||||
},
|
},
|
||||||
],
|
]);
|
||||||
];
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||||
import { click, render } from "@ember/test-helpers";
|
import { click, render } from "@ember/test-helpers";
|
||||||
import { count, exists, query } from "discourse/tests/helpers/qunit-helpers";
|
import { count, exists, query } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import hbs from "htmlbars-inline-precompile";
|
import hbs from "htmlbars-inline-precompile";
|
||||||
import pretender from "discourse/tests/helpers/create-pretender";
|
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||||
import EmberObject from "@ember/object";
|
import EmberObject from "@ember/object";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
|
|
||||||
|
@ -15,10 +15,7 @@ module("Integration | Component | Widget | discourse-poll", function (hooks) {
|
||||||
hooks.beforeEach(function () {
|
hooks.beforeEach(function () {
|
||||||
pretender.put("/polls/vote", () => {
|
pretender.put("/polls/vote", () => {
|
||||||
++requests;
|
++requests;
|
||||||
return [
|
return response({
|
||||||
200,
|
|
||||||
{ "Content-Type": "application/json" },
|
|
||||||
{
|
|
||||||
poll: {
|
poll: {
|
||||||
name: "poll",
|
name: "poll",
|
||||||
type: "regular",
|
type: "regular",
|
||||||
|
@ -40,8 +37,7 @@ module("Integration | Component | Widget | discourse-poll", function (hooks) {
|
||||||
chart_type: "bar",
|
chart_type: "bar",
|
||||||
},
|
},
|
||||||
vote: ["1f972d1df351de3ce35a787c89faad29"],
|
vote: ["1f972d1df351de3ce35a787c89faad29"],
|
||||||
},
|
});
|
||||||
];
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue