A platform for community discussion. Free, open, simple.
DEV: Centralise more user preferences tests into individual files (#19100)
Alan Guo Xiang Tan6d8a93ac417f
diff --git a/app/assets/javascripts/discourse/tests/acceptance/preferences-test.js b/app/assets/javascripts/discourse/tests/acceptance/preferences-test.jsindex b905a4dc630..92d6db4dd36 100644--- a/app/assets/javascripts/discourse/tests/acceptance/preferences-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/preferences-test.js@@ -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({diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-account-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-account-test.jsindex 67ddd632416..7b64c3f9562 100644--- a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-account-test.js+++ b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-account-test.js@@ -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")+ );+ });});