1
0
Fork 0

DEV: Add created and read custom fields tests

Dieser Commit ist enthalten in:
jumagura 2023-05-09 03:17:22 -04:00
Ursprung d0459575e0
Commit 1a84acec21
2 geänderte Dateien mit 105 neuen und 36 gelöschten Zeilen

Datei anzeigen

@ -29,12 +29,45 @@ acceptance("Admin | Custom Fields Unsuscribed", function (needs) {
server.get("/admin/wizards/custom-fields", () => { server.get("/admin/wizards/custom-fields", () => {
return helper.response(getCustomFields); return helper.response(getCustomFields);
}); });
server.put("/admin/wizards/custom-fields", () => {
return helper.response({ success: "OK" });
});
}); });
async function selectTypeAndSerializerAndFillInName(
type,
serializer,
name,
summaryName
) {
const typeDropdown = selectKit(
`.admin-wizard-container details:has(summary[name="${summaryName}"])`
);
await typeDropdown.expand();
await click(
`.select-kit-collection li[data-value="${type.toLowerCase()}"]`
);
const serializerDropdown = selectKit(
".admin-wizard-container details.multi-select"
);
await serializerDropdown.expand();
await click(
`.select-kit-collection li[data-value="${serializer
.toLowerCase()
.replace(/ /g, "_")}"]`
);
await fillIn(".admin-wizard-container input", name);
}
test("Navigate to custom fields tab", async (assert) => { test("Navigate to custom fields tab", async (assert) => {
await visit("/admin/wizards/custom-fields"); await visit("/admin/wizards/custom-fields");
assert.ok(find("table")); assert.ok(find("table"));
assert.ok(findAll("table tbody tr").length === 9); assert.ok(
findAll("table tbody tr").length === 4,
"Display loaded custom fields"
);
assert.ok( assert.ok(
query(".message-content").innerText.includes( query(".message-content").innerText.includes(
"View, create, edit and destroy custom fields" "View, create, edit and destroy custom fields"
@ -135,4 +168,75 @@ acceptance("Admin | Custom Fields Unsuscribed", function (needs) {
"There is one enabled option in the serializer dropdown for Post" "There is one enabled option in the serializer dropdown for Post"
); );
}); });
test("Create Topic and Post custom fields", async (assert) => {
await visit("/admin/wizards/custom-fields");
assert.ok(
findAll("table tbody tr").length === 4,
"Display loaded custom fields"
);
await click(".admin-wizard-controls .btn-icon-text");
const dropdownTopic = selectKit(
'.admin-wizard-container details:has(summary[name="Filter by: Select a class"])'
);
await dropdownTopic.expand();
await click('.select-kit-collection li[data-value="topic"]');
await selectTypeAndSerializerAndFillInName(
"String",
"Topic View",
"Topic Custom Field",
"Filter by: Select a type"
);
await click(".actions .save");
assert.ok(
query(
".admin-wizard-container tbody tr:first-child td:nth-child(1) label"
).innerText.includes("topic"),
"Topic custom field is displayed"
);
assert.ok(
query(
".admin-wizard-container tbody tr:first-child td:nth-child(3) label"
).innerText.includes("Topic Custom Field"),
"Topic custom field name is displayed"
);
await click(".admin-wizard-controls .btn-icon-text");
const dropdownPost = selectKit(
'.admin-wizard-container details:has(summary[name="Filter by: Select a class"])'
);
await dropdownPost.expand();
await click('.select-kit-collection li[data-value="post"]');
await selectTypeAndSerializerAndFillInName(
"Boolean",
"Post",
"Post Custom Field",
"Filter by: Select a type"
);
await click(".actions .save");
assert.ok(
query(
".admin-wizard-container tbody tr:first-child td:nth-child(1) label"
).innerText.includes("post"),
"Post custom field is displayed"
);
assert.ok(
query(
".admin-wizard-container tbody tr:first-child td:nth-child(3) label"
).innerText.includes("Post Custom Field"),
"Post custom field name is displayed"
);
assert.ok(
findAll("table tbody tr").length === 6,
"Display added custom fields"
);
});
}); });

Datei anzeigen

@ -254,41 +254,6 @@ const getCustomFields = {
type: "boolean", type: "boolean",
serializers: null, serializers: null,
}, },
{
id: "external",
klass: "post",
name: "missing uploads",
type: "json",
serializers: null,
},
{
id: "external",
klass: "post",
name: "missing uploads ignored",
type: "boolean",
serializers: null,
},
{
id: "external",
klass: "post",
name: "notice",
type: "json",
serializers: null,
},
{
id: "external",
klass: "post",
name: "local_dates",
type: "json",
serializers: null,
},
{
id: "external",
klass: "post",
name: "has_polls",
type: "boolean",
serializers: null,
},
], ],
}; };
const getWizardTestingLog = { const getWizardTestingLog = {