Skip to content

Commit fab89c5

Browse files
Fix(unitex): Updat group checkbox label and use expect.element in tests
1 parent 62155b4 commit fab89c5

19 files changed

Lines changed: 152 additions & 117 deletions

packages/demo/src/App.spec.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, expect, it, vi } from "vitest";
1+
import { describe, expect, it } from "vitest";
22
import { userEvent } from "vitest/browser";
33
import { render } from "vitest-browser-react";
44
import App from "./App";
@@ -7,11 +7,13 @@ describe("App", () => {
77
it("should render the upload button", async () => {
88
const screen = await render(<App />);
99

10-
expect(
11-
screen.getByRole("button", {
12-
name: "Document TEI",
13-
}),
14-
).toBeInTheDocument();
10+
await expect
11+
.element(
12+
screen.getByRole("button", {
13+
name: "Document TEI",
14+
}),
15+
)
16+
.toBeInTheDocument();
1517
});
1618

1719
it("should render the XML document when a tei file is uploaded", async () => {
@@ -49,8 +51,8 @@ describe("App", () => {
4951

5052
await screen.getByRole("button", { name: "Lancer la visionneuse" }).click();
5153

52-
await vi.waitFor(() => {
53-
expect(screen.getByText("TEI Test Title")).toBeInTheDocument();
54-
});
54+
await expect
55+
.element(screen.getByText("TEI Test Title"))
56+
.toBeInTheDocument();
5557
});
5658
});

packages/demo/src/i18n/I18NProvider.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ describe("I18NProvider", () => {
1818
</I18nProvider>,
1919
);
2020

21-
expect(screen.getByText("Viewer")).toBeDefined();
21+
await expect.element(screen.getByText("Viewer")).toBeDefined();
2222
});
2323
});

packages/demo/src/viewer/ViewerPage.spec.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ describe("ViewerPage", () => {
3333
it("should render Viewer when document is provided and viewerLaunched is true", async () => {
3434
const screen = await render(<ViewerPage />);
3535

36-
expect(screen.getByText("TEI Test Title")).toBeInTheDocument();
36+
await expect
37+
.element(screen.getByText("TEI Test Title"))
38+
.toBeInTheDocument();
3739
});
3840

3941
it("should not render Viewer when document is not provided", async () => {
@@ -45,7 +47,9 @@ describe("ViewerPage", () => {
4547

4648
const screen = await render(<ViewerPage />);
4749

48-
expect(screen.getByText("TEI Test Title")).not.toBeInTheDocument();
50+
await expect
51+
.element(screen.getByText("TEI Test Title"))
52+
.not.toBeInTheDocument();
4953
});
5054

5155
it("should not render Viewer when viewerLaunched is false", async () => {
@@ -68,6 +72,8 @@ describe("ViewerPage", () => {
6872

6973
const screen = await render(<ViewerPage />);
7074

71-
expect(screen.getByText("TEI Test Title")).not.toBeInTheDocument();
75+
await expect
76+
.element(screen.getByText("TEI Test Title"))
77+
.not.toBeInTheDocument();
7278
});
7379
});

packages/react-tei/src/DocumentTitle.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,6 @@ describe("DocumentTitle", () => {
111111
),
112112
});
113113

114-
expect(screen.container).toBeEmptyDOMElement();
114+
await expect.element(screen.container).toBeEmptyDOMElement();
115115
});
116116
});

packages/react-tei/src/SidePanel/enrichmentTerm/EnrichmentTermAnnotationBlocks.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ export function EnrichmentTermAnnotationBlock({
2323
useListEnrichmentTermAnnotationByBlockType(block);
2424

2525
const toggleContext = displayStatus === "all" ? "hide" : "show";
26-
const sectionlabel = t(`termEnrichment.${block}`, {
27-
count: annotations.length,
28-
});
2926
const checkboxLabel = t("termEnrichment.toggleBlock", {
3027
context: toggleContext,
3128
});
@@ -47,7 +44,7 @@ export function EnrichmentTermAnnotationBlock({
4744
}}
4845
>
4946
<FormControlLabel
50-
label={sectionlabel}
47+
label={t("termEnrichment.underlineWordsInText")}
5148
control={
5249
<Tooltip title={checkboxLabel} placement="left">
5350
<Checkbox

packages/react-tei/src/Viewer.spec.tsx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,12 @@ describe("Viewer", () => {
5353
screen.getByRole("heading", { level: 3, name: "Section 1" }),
5454
).toBeInTheDocument();
5555

56-
expect(screen.getByText("This is a test document.")).toBeInTheDocument();
57-
expect(screen.getByText("Content of section 1.")).toBeInTheDocument();
56+
await expect
57+
.element(screen.getByText("This is a test document."))
58+
.toBeInTheDocument();
59+
await expect
60+
.element(screen.getByText("Content of section 1."))
61+
.toBeInTheDocument();
5862
});
5963

6064
it("should render a table", async () => {
@@ -98,10 +102,10 @@ describe("Viewer", () => {
98102
}),
99103
).toBeVisible();
100104

101-
expect(screen.getByRole("caption")).toBeVisible();
102-
expect(screen.getByRole("caption")).toHaveTextContent(
103-
"Table 1 Sample Table",
104-
);
105+
await expect.element(screen.getByRole("caption")).toBeVisible();
106+
await expect
107+
.element(screen.getByRole("caption"))
108+
.toHaveTextContent("Table 1 Sample Table");
105109

106110
expect(
107111
screen.getByRole("columnheader", { name: "Header 1" }),
@@ -110,8 +114,12 @@ describe("Viewer", () => {
110114
screen.getByRole("columnheader", { name: "Header 2" }),
111115
).toBeVisible();
112116

113-
expect(screen.getByRole("cell", { name: "Data 1" })).toBeVisible();
114-
expect(screen.getByRole("cell", { name: "Data 2" })).toBeVisible();
117+
await expect
118+
.element(screen.getByRole("cell", { name: "Data 1" }))
119+
.toBeVisible();
120+
await expect
121+
.element(screen.getByRole("cell", { name: "Data 2" }))
122+
.toBeVisible();
115123
expect(
116124
screen.getByRole("note").filter({
117125
hasText: "This is a table note.",

packages/react-tei/src/abstract/MultilingualAbstract.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ describe("MultilingualAbstract", () => {
228228
wrapper: I18nProvider,
229229
});
230230

231-
expect(screen.getByRole("region")).not.toBeInTheDocument();
231+
await expect.element(screen.getByRole("region")).not.toBeInTheDocument();
232232
});
233233

234234
it("should not render anything if no language attribute is present", async () => {

packages/react-tei/src/i18n/I18NProvider.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ describe("I18NProvider", () => {
1818
</I18nProvider>,
1919
);
2020

21-
expect(screen.getByText("Résumé")).toBeDefined();
21+
await expect.element(screen.getByText("Résumé")).toBeDefined();
2222
});
2323
});

packages/react-tei/src/tags/DateTag.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ describe("DateTag", () => {
6565
</TagCatalogProvider>
6666
),
6767
});
68-
expect(screen.container).toBeEmptyDOMElement();
68+
await expect.element(screen.container).toBeEmptyDOMElement();
6969
});
7070
});

packages/react-tei/src/tags/Head.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,6 @@ describe("Head", () => {
102102
</TagCatalogProvider>
103103
),
104104
});
105-
expect(screen.container).toBeEmptyDOMElement();
105+
await expect.element(screen.container).toBeEmptyDOMElement();
106106
});
107107
});

0 commit comments

Comments
 (0)