Skip to content

Commit 10c37a7

Browse files
authored
test(form): cover markdown descriptions (#1446)
1 parent c25dbb2 commit 10c37a7

2 files changed

Lines changed: 70 additions & 0 deletions

File tree

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
-- Exercise every form layout that renders a field description:
2+
-- standard controls, the legacy checkbox/radio controls, and switches.
3+
SELECT
4+
'form' AS component,
5+
'Form description markdown' AS title,
6+
'' AS validate;
7+
8+
SELECT
9+
'modern_text' AS name,
10+
'Modern text field' AS label,
11+
'**Bold text** and *italic text*.' AS description_md;
12+
13+
SELECT
14+
'modern_textarea' AS name,
15+
'Modern textarea' AS label,
16+
'textarea' AS type,
17+
'**Bold textarea** and *italic textarea*.' AS description_md;
18+
19+
SELECT
20+
'modern_select' AS name,
21+
'Modern select' AS label,
22+
'select' AS type,
23+
'[{"label":"Option","value":"option"}]' AS options,
24+
'**Bold select** and *italic select*.' AS description_md;
25+
26+
SELECT
27+
'legacy_radio' AS name,
28+
'Legacy radio' AS label,
29+
'radio' AS type,
30+
'radio' AS value,
31+
'**Bold radio** and *italic radio*.' AS description_md;
32+
33+
SELECT
34+
'legacy_checkbox' AS name,
35+
'Legacy checkbox' AS label,
36+
'checkbox' AS type,
37+
'checkbox' AS value,
38+
'**Bold checkbox** and *italic checkbox*.' AS description_md;
39+
40+
SELECT
41+
'modern_switch' AS name,
42+
'Modern switch' AS label,
43+
'switch' AS type,
44+
'switch' AS value,
45+
'**Bold switch** and *italic switch*.' AS description_md;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { expect, test } from "../../fixture";
2+
3+
const fields = [
4+
{ selector: 'input[name="modern_text"]', name: "text" },
5+
{ selector: 'textarea[name="modern_textarea"]', name: "textarea" },
6+
{ selector: 'select[name="modern_select"]', name: "select" },
7+
{ selector: 'input[name="legacy_radio"]', name: "radio" },
8+
{ selector: 'input[name="legacy_checkbox"]', name: "checkbox" },
9+
{ selector: 'input[name="modern_switch"]', name: "switch" },
10+
];
11+
12+
test("renders markdown descriptions for every form field layout (#808)", async ({
13+
page,
14+
}) => {
15+
for (const { selector, name } of fields) {
16+
const field = page.locator(selector);
17+
const hint = field
18+
.locator("xpath=ancestor::label[1]")
19+
.locator(".form-hint");
20+
21+
await expect(field).toBeVisible();
22+
await expect(hint.locator("strong")).toHaveText(`Bold ${name}`);
23+
await expect(hint.locator("em")).toHaveText(`italic ${name}`);
24+
}
25+
});

0 commit comments

Comments
 (0)