DEV: Centralise more user preferences tests into individual files (#19100)

Makes it easier to associate the route with the tests
This commit is contained in:
Alan Guo Xiang Tan 2022-11-21 10:16:47 +08:00 committed by GitHub
parent 3846b6248f
commit 6d8a93ac41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 53 deletions

View File

@ -29,12 +29,6 @@ function preferencesPretender(server, helper) {
});
});
server.post("/u/eviltrout/preferences/revoke-account", () => {
return helper.response({
success: true,
});
});
server.post("/user_avatar/eviltrout/refresh_gravatar.json", () => {
return helper.response({
gravatar_upload_id: 6543,
@ -131,31 +125,6 @@ acceptance("User Preferences", function (needs) {
assert.ok(exists("#change_username"), "it has the input element");
});
test("connected accounts", async function (assert) {
await visit("/u/eviltrout/preferences/account");
assert.ok(
exists(".pref-associated-accounts"),
"it has the connected accounts section"
);
assert.ok(
query(
".pref-associated-accounts table tr:nth-of-type(1) td:nth-of-type(1)"
).innerHTML.includes("Facebook"),
"it lists facebook"
);
await click(
".pref-associated-accounts table tr:nth-of-type(1) td:last-child button"
);
assert.ok(
query(
".pref-associated-accounts table tr:nth-of-type(1) td:last-of-type"
).innerHTML.includes("Connect")
);
});
test("default avatar selector", async function (assert) {
await visit("/u/eviltrout/preferences");
@ -328,26 +297,6 @@ acceptance(
}
);
acceptance("User Preferences when badges are disabled", function (needs) {
needs.user();
needs.settings({ enable_badges: false });
needs.pretender(preferencesPretender);
test("visit my preferences", async function (assert) {
await visit("/u/eviltrout/preferences");
assert.ok(
document.body.classList.contains("user-preferences-page"),
"has the body class"
);
assert.strictEqual(
currentURL(),
"/u/eviltrout/preferences/account",
"defaults to account tab"
);
assert.ok(exists(".user-preferences"), "it shows the preferences");
});
});
acceptance("Custom User Fields", function (needs) {
needs.user();
needs.site({

View File

@ -1,17 +1,27 @@
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
import {
acceptance,
exists,
query,
} from "discourse/tests/helpers/qunit-helpers";
import { click, visit } from "@ember/test-helpers";
import { test } from "qunit";
import DiscourseURL from "discourse/lib/url";
import I18n from "I18n";
import sinon from "sinon";
acceptance("User Profile - Account - Self Delete", function (needs) {
acceptance("User Preferences - Account", function (needs) {
needs.user({
username: "charlie",
});
needs.pretender((server, helper) => {
server.delete("/u/charlie.json", () => helper.response({ success: true }));
server.post("/u/eviltrout/preferences/revoke-account", () => {
return helper.response({
success: true,
});
});
});
test("Delete dialog", async function (assert) {
@ -35,4 +45,30 @@ acceptance("User Profile - Account - Self Delete", function (needs) {
"redirects to home after deleting"
);
});
test("connected accounts", async function (assert) {
await visit("/u/eviltrout/preferences/account");
assert.ok(
exists(".pref-associated-accounts"),
"it has the connected accounts section"
);
assert.ok(
query(
".pref-associated-accounts table tr:nth-of-type(1) td:nth-of-type(1)"
).innerHTML.includes("Facebook"),
"it lists facebook"
);
await click(
".pref-associated-accounts table tr:nth-of-type(1) td:last-child button"
);
assert.ok(
query(
".pref-associated-accounts table tr:nth-of-type(1) td:last-of-type"
).innerHTML.includes("Connect")
);
});
});