mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Split tests for user preferences security page into individual file (#19096)
Mixing multiple acceptance tests in a single file makes the acceptance tests much harder to find.
This commit is contained in:
parent
4f63bc8ed2
commit
5e516a7d7d
@ -1,6 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
acceptance,
|
acceptance,
|
||||||
count,
|
|
||||||
exists,
|
exists,
|
||||||
query,
|
query,
|
||||||
updateCurrentUser,
|
updateCurrentUser,
|
||||||
@ -572,56 +571,6 @@ acceptance("Ignored users", function (needs) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
acceptance("User Preferences - Security", function (needs) {
|
|
||||||
needs.user();
|
|
||||||
needs.pretender(preferencesPretender);
|
|
||||||
|
|
||||||
test("recently connected devices", async function (assert) {
|
|
||||||
await visit("/u/eviltrout/preferences/security");
|
|
||||||
|
|
||||||
assert.strictEqual(
|
|
||||||
query(
|
|
||||||
".auth-tokens > .auth-token:nth-of-type(1) .auth-token-device"
|
|
||||||
).innerText.trim(),
|
|
||||||
"Linux Computer",
|
|
||||||
"it should display active token first"
|
|
||||||
);
|
|
||||||
|
|
||||||
assert.strictEqual(
|
|
||||||
query(".pref-auth-tokens > a:nth-of-type(1)").innerText.trim(),
|
|
||||||
I18n.t("user.auth_tokens.show_all", { count: 3 }),
|
|
||||||
"it should display two tokens"
|
|
||||||
);
|
|
||||||
assert.strictEqual(
|
|
||||||
count(".pref-auth-tokens .auth-token"),
|
|
||||||
2,
|
|
||||||
"it should display two tokens"
|
|
||||||
);
|
|
||||||
|
|
||||||
await click(".pref-auth-tokens > a:nth-of-type(1)");
|
|
||||||
|
|
||||||
assert.strictEqual(
|
|
||||||
count(".pref-auth-tokens .auth-token"),
|
|
||||||
3,
|
|
||||||
"it should display three tokens"
|
|
||||||
);
|
|
||||||
|
|
||||||
const authTokenDropdown = selectKit(".auth-token-dropdown");
|
|
||||||
await authTokenDropdown.expand();
|
|
||||||
await authTokenDropdown.selectRowByValue("notYou");
|
|
||||||
|
|
||||||
assert.strictEqual(count(".d-modal:visible"), 1, "modal should appear");
|
|
||||||
|
|
||||||
await click(".modal-footer .btn-primary");
|
|
||||||
|
|
||||||
assert.strictEqual(
|
|
||||||
count(".pref-password.highlighted"),
|
|
||||||
1,
|
|
||||||
"it should highlight password preferences"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
acceptance(
|
acceptance(
|
||||||
"User Preferences for staged user and don't allow tracking prefs",
|
"User Preferences for staged user and don't allow tracking prefs",
|
||||||
function (needs) {
|
function (needs) {
|
||||||
|
@ -0,0 +1,64 @@
|
|||||||
|
import I18n from "I18n";
|
||||||
|
import { test } from "qunit";
|
||||||
|
import { click, visit } from "@ember/test-helpers";
|
||||||
|
import {
|
||||||
|
acceptance,
|
||||||
|
count,
|
||||||
|
query,
|
||||||
|
} from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||||
|
|
||||||
|
acceptance("User Preferences - Security", function (needs) {
|
||||||
|
needs.user();
|
||||||
|
|
||||||
|
needs.pretender((server, helper) => {
|
||||||
|
server.get("/u/eviltrout/activity.json", () => {
|
||||||
|
return helper.response({});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test("recently connected devices", async function (assert) {
|
||||||
|
await visit("/u/eviltrout/preferences/security");
|
||||||
|
|
||||||
|
assert.strictEqual(
|
||||||
|
query(
|
||||||
|
".auth-tokens > .auth-token:nth-of-type(1) .auth-token-device"
|
||||||
|
).innerText.trim(),
|
||||||
|
"Linux Computer",
|
||||||
|
"it should display active token first"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.strictEqual(
|
||||||
|
query(".pref-auth-tokens > a:nth-of-type(1)").innerText.trim(),
|
||||||
|
I18n.t("user.auth_tokens.show_all", { count: 3 }),
|
||||||
|
"it should display two tokens"
|
||||||
|
);
|
||||||
|
assert.strictEqual(
|
||||||
|
count(".pref-auth-tokens .auth-token"),
|
||||||
|
2,
|
||||||
|
"it should display two tokens"
|
||||||
|
);
|
||||||
|
|
||||||
|
await click(".pref-auth-tokens > a:nth-of-type(1)");
|
||||||
|
|
||||||
|
assert.strictEqual(
|
||||||
|
count(".pref-auth-tokens .auth-token"),
|
||||||
|
3,
|
||||||
|
"it should display three tokens"
|
||||||
|
);
|
||||||
|
|
||||||
|
const authTokenDropdown = selectKit(".auth-token-dropdown");
|
||||||
|
await authTokenDropdown.expand();
|
||||||
|
await authTokenDropdown.selectRowByValue("notYou");
|
||||||
|
|
||||||
|
assert.strictEqual(count(".d-modal:visible"), 1, "modal should appear");
|
||||||
|
|
||||||
|
await click(".modal-footer .btn-primary");
|
||||||
|
|
||||||
|
assert.strictEqual(
|
||||||
|
count(".pref-password.highlighted"),
|
||||||
|
1,
|
||||||
|
"it should highlight password preferences"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user