Files
Jarek RadoszandGitHub c5eb96b01b DEV: Migrate create-account to the new modal API (#24098)
plugin/theme-breaking changes:

1. `controller:create-account` is gone (use `component:modal/create-account` in modifyClass, **if** absolutely necessary)
2. `create-account-body` css class is gone (target `.d-modal.create-account` or any of the inner classes: `.modal-outer-container`, `.modal-middle-container`, `.modal-inner-container`, or `.modal-body`)
2023-10-30 11:01:09 +01:00

76 lines
2.1 KiB
JavaScript

import { visit } from "@ember/test-helpers";
import { test } from "qunit";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
function setupAuthData(data) {
data = {
auth_provider: "test",
email: "[email protected]",
can_edit_username: true,
can_edit_name: true,
...data,
};
const node = document.createElement("meta");
node.dataset.authenticationData = JSON.stringify(data);
node.id = "data-authentication";
document.querySelector("head").appendChild(node);
}
acceptance("Create Account - external auth", function (needs) {
needs.hooks.beforeEach(function () {
setupAuthData();
});
needs.hooks.afterEach(function () {
document.getElementById("data-authentication").remove();
});
test("when skip is disabled (default)", async function (assert) {
await visit("/");
assert
.dom(".d-modal.create-account")
.exists("it shows the registration modal");
assert.dom("#new-account-username").exists("it shows the fields");
assert
.dom(".create-account-associate-link")
.doesNotExist("it does not show the associate link");
});
test("when skip is enabled", async function (assert) {
this.siteSettings.auth_skip_create_confirm = true;
await visit("/");
assert
.dom(".d-modal.create-account")
.exists("it shows the registration modal");
assert
.dom("#new-account-username")
.doesNotExist("it does not show the fields");
});
});
acceptance("Create account - with associate link", function (needs) {
needs.hooks.beforeEach(function () {
setupAuthData({ associate_url: "/associate/abcde" });
});
needs.hooks.afterEach(function () {
document.getElementById("data-authentication").remove();
});
test("displays associate link when allowed", async function (assert) {
await visit("/");
assert
.dom(".d-modal.create-account")
.exists("it shows the registration modal");
assert.dom("#new-account-username").exists("it shows the fields");
assert
.dom(".create-account-associate-link")
.exists("it shows the associate link");
});
});