|
1 | 1 | import { describe, expect, it } from "vitest"; |
2 | 2 | import { render } from "vitest-browser-react"; |
3 | | - |
| 3 | +import { I18nProvider } from "../i18n/I18nProvider"; |
4 | 4 | import type { DocumentJson } from "../parser/document"; |
5 | 5 | import { Table } from "./Table"; |
6 | 6 | import { TagCatalogProvider } from "./TagCatalogProvider"; |
@@ -129,4 +129,59 @@ describe("Table", () => { |
129 | 129 |
|
130 | 130 | expect(screen.getByRole("paragraph")).not.toBeInTheDocument(); |
131 | 131 | }); |
| 132 | + |
| 133 | + it("should support fullscreen mode", async () => { |
| 134 | + const jsonDocument: DocumentJson = { |
| 135 | + tag: "table", |
| 136 | + attributes: { "@xml:id": "t3" }, |
| 137 | + value: [ |
| 138 | + { tag: "head", attributes: { "@type": "label" }, value: "Table 3" }, |
| 139 | + { |
| 140 | + tag: "row", |
| 141 | + attributes: { "@role": "label" }, |
| 142 | + value: [ |
| 143 | + { tag: "cell", attributes: {}, value: "H1" }, |
| 144 | + { tag: "cell", attributes: {}, value: "H2" }, |
| 145 | + ], |
| 146 | + }, |
| 147 | + { |
| 148 | + tag: "row", |
| 149 | + attributes: { "@role": "data" }, |
| 150 | + value: [ |
| 151 | + { tag: "cell", attributes: {}, value: "D1" }, |
| 152 | + { tag: "cell", attributes: {}, value: "D2" }, |
| 153 | + ], |
| 154 | + }, |
| 155 | + ], |
| 156 | + }; |
| 157 | + |
| 158 | + const screen = await render(<Table data={jsonDocument} />, { |
| 159 | + wrapper: ({ children }) => ( |
| 160 | + <I18nProvider> |
| 161 | + <TagCatalogProvider tagCatalog={tagCatalog}> |
| 162 | + {children} |
| 163 | + </TagCatalogProvider> |
| 164 | + </I18nProvider> |
| 165 | + ), |
| 166 | + }); |
| 167 | + |
| 168 | + const fullScreenButton = screen.getByRole("button", { |
| 169 | + name: "Passer en mode plein écran", |
| 170 | + }); |
| 171 | + expect(fullScreenButton).toBeVisible(); |
| 172 | + |
| 173 | + await fullScreenButton.click(); |
| 174 | + |
| 175 | + const dialog = screen.getByRole("dialog"); |
| 176 | + expect(dialog).toBeVisible(); |
| 177 | + |
| 178 | + const exitFullScreenButton = screen.getByRole("button", { |
| 179 | + name: "Quitter le mode plein écran", |
| 180 | + }); |
| 181 | + expect(exitFullScreenButton).toBeVisible(); |
| 182 | + |
| 183 | + await exitFullScreenButton.click(); |
| 184 | + |
| 185 | + expect(dialog).not.toBeInTheDocument(); |
| 186 | + }); |
132 | 187 | }); |
0 commit comments