@1doc/1ds-react 2.10.0 → 2.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +235 -0
- package/dist/components/Accordion/Accordion.d.ts +6 -0
- package/dist/components/Accordion/Accordion.js +17 -5
- package/dist/components/Badge/Badge.css +13 -4
- package/dist/components/Badge/Badge.d.ts +9 -2
- package/dist/components/Badge/Badge.js +3 -0
- package/dist/components/Button/Button.css +5 -0
- package/dist/components/Button/Button.d.ts +3 -0
- package/dist/components/Button/Button.js +1 -0
- package/dist/components/Calendar/Calendar.css +10 -0
- package/dist/components/Calendar/Calendar.d.ts +3 -0
- package/dist/components/Calendar/Calendar.js +6 -1
- package/dist/components/Coachmark/Coachmark.d.ts +2 -1
- package/dist/components/Coachmark/Coachmark.js +6 -1
- package/dist/components/CodeBlock/CodeBlock.css +3 -3
- package/dist/components/CodeBlock/CodeBlock.d.ts +2 -2
- package/dist/components/DataTable/DataTable.css +42 -0
- package/dist/components/DataTable/DataTable.d.ts +9 -2
- package/dist/components/DataTable/DataTable.js +15 -0
- package/dist/components/Input/Input.css +9 -0
- package/dist/components/Input/Input.d.ts +3 -0
- package/dist/components/Input/Input.js +1 -0
- package/dist/components/Kbd/Kbd.css +3 -3
- package/dist/components/Kbd/Kbd.d.ts +1 -1
- package/dist/components/Modal/Modal.css +19 -0
- package/dist/components/Modal/Modal.d.ts +7 -0
- package/dist/components/Modal/Modal.js +1 -0
- package/dist/components/RichTextEditor/RichTextEditor.d.ts +2 -2
- package/dist/components/RichTextEditor/RichTextEditor.js +0 -5
- package/dist/components/SegmentedControl/SegmentedControl.css +46 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +3 -0
- package/dist/components/SegmentedControl/SegmentedControl.js +1 -0
- package/dist/components/Select/Select.css +28 -2
- package/dist/components/Select/Select.d.ts +7 -0
- package/dist/components/Select/Select.js +55 -9
- package/dist/components/StatCard/StatCard.css +8 -0
- package/dist/components/StatCard/StatCard.d.ts +3 -0
- package/dist/components/StatCard/StatCard.js +1 -0
- package/dist/components/Tabs/Tabs.css +11 -0
- package/dist/components/Tabs/Tabs.d.ts +7 -0
- package/dist/components/Tabs/Tabs.js +7 -1
- package/dist/components/Tag/Tag.css +3 -1
- package/dist/teste/AccordionControlado.test.d.ts +1 -0
- package/dist/teste/AccordionControlado.test.js +73 -0
- package/dist/teste/BadgeAttachedTomEPadding.test.d.ts +1 -0
- package/dist/teste/BadgeAttachedTomEPadding.test.js +43 -0
- package/dist/teste/ButtonDensidade.test.d.ts +1 -0
- package/dist/teste/ButtonDensidade.test.js +28 -0
- package/dist/teste/CalendarCompacto.test.d.ts +1 -0
- package/dist/teste/CalendarCompacto.test.js +29 -0
- package/dist/teste/CoachmarkUmPasso.test.d.ts +1 -0
- package/dist/teste/CoachmarkUmPasso.test.js +34 -0
- package/dist/teste/DataTableCompactaETom.test.d.ts +1 -0
- package/dist/teste/DataTableCompactaETom.test.js +69 -0
- package/dist/teste/InputGhost.test.d.ts +1 -0
- package/dist/teste/InputGhost.test.js +32 -0
- package/dist/teste/ModalProporcoes1Doc.test.d.ts +1 -0
- package/dist/teste/ModalProporcoes1Doc.test.js +32 -0
- package/dist/teste/RichTextEditorEstiloDeTexto.test.js +7 -7
- package/dist/teste/SegmentedControlSuperficie.test.d.ts +1 -0
- package/dist/teste/SegmentedControlSuperficie.test.js +39 -0
- package/dist/teste/SelectItemComEscopo.test.d.ts +1 -0
- package/dist/teste/SelectItemComEscopo.test.js +54 -0
- package/dist/teste/SelectListaFiltro.test.d.ts +1 -0
- package/dist/teste/SelectListaFiltro.test.js +102 -0
- package/dist/teste/StatCardTamanhoSm.test.d.ts +1 -0
- package/dist/teste/StatCardTamanhoSm.test.js +32 -0
- package/dist/teste/TabsCompacta.test.d.ts +1 -0
- package/dist/teste/TabsCompacta.test.js +35 -0
- package/dist/teste/TagPositivoTingido.test.d.ts +1 -0
- package/dist/teste/TagPositivoTingido.test.js +54 -0
- package/dist/teste/lerArquivo.d.ts +1 -0
- package/dist/teste/lerArquivo.js +12 -0
- package/dist/utils/html-seguro.js +1 -1
- package/package.json +3 -3
- package/src/teste/AccordionControlado.test.tsx +87 -0
- package/src/teste/BadgeAttachedTomEPadding.test.tsx +60 -0
- package/src/teste/ButtonDensidade.test.tsx +40 -0
- package/src/teste/CalendarCompacto.test.tsx +37 -0
- package/src/teste/CoachmarkUmPasso.test.tsx +45 -0
- package/src/teste/DataTableCompactaETom.test.tsx +85 -0
- package/src/teste/InputGhost.test.tsx +42 -0
- package/src/teste/ModalProporcoes1Doc.test.tsx +36 -0
- package/src/teste/RichTextEditorEstiloDeTexto.test.tsx +8 -8
- package/src/teste/SegmentedControlSuperficie.test.tsx +52 -0
- package/src/teste/SelectItemComEscopo.test.tsx +69 -0
- package/src/teste/SelectListaFiltro.test.tsx +120 -0
- package/src/teste/StatCardTamanhoSm.test.tsx +42 -0
- package/src/teste/TabsCompacta.test.tsx +45 -0
- package/src/teste/TagPositivoTingido.test.tsx +60 -0
- package/src/teste/lerArquivo.ts +13 -0
- package/src/utils/html-seguro.ts +1 -1
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { describe, expect, it, vi } from "vitest";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
5
|
+
import Accordion from "../components/Accordion/Accordion";
|
|
6
|
+
const ITENS = [
|
|
7
|
+
{ id: "prazos", title: "Prazos", content: "Dez dias úteis.", defaultOpen: true },
|
|
8
|
+
{ id: "anexos", title: "Anexos", content: "Até 10 MB." },
|
|
9
|
+
{ id: "sigilo", title: "Sigilo", content: "Só o setor." },
|
|
10
|
+
];
|
|
11
|
+
const aberto = (nome) => screen.getByRole("button", { name: nome }).getAttribute("aria-expanded") === "true";
|
|
12
|
+
describe("Accordion · não controlado (como antes)", () => {
|
|
13
|
+
it("começa pelos defaultOpen e o clique abre e fecha; onOpenChange avisa a nova lista", () => {
|
|
14
|
+
const aoMudar = vi.fn();
|
|
15
|
+
render(_jsx(Accordion, { items: ITENS, multiple: true, onOpenChange: aoMudar }));
|
|
16
|
+
expect(aberto("Prazos")).toBe(true);
|
|
17
|
+
fireEvent.click(screen.getByRole("button", { name: "Anexos" }));
|
|
18
|
+
expect(aberto("Anexos")).toBe(true);
|
|
19
|
+
expect(aoMudar).toHaveBeenLastCalledWith(["prazos", "anexos"]);
|
|
20
|
+
fireEvent.click(screen.getByRole("button", { name: "Prazos" }));
|
|
21
|
+
expect(aberto("Prazos")).toBe(false);
|
|
22
|
+
expect(aoMudar).toHaveBeenLastCalledWith(["anexos"]);
|
|
23
|
+
});
|
|
24
|
+
it("sem multiple, abrir um fecha o outro", () => {
|
|
25
|
+
render(_jsx(Accordion, { items: ITENS }));
|
|
26
|
+
fireEvent.click(screen.getByRole("button", { name: "Anexos" }));
|
|
27
|
+
expect(aberto("Anexos")).toBe(true);
|
|
28
|
+
expect(aberto("Prazos")).toBe(false);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
describe("Accordion · controlado (open e onOpenChange)", () => {
|
|
32
|
+
it("open manda: o que está em open está aberto, ignorando defaultOpen", () => {
|
|
33
|
+
render(_jsx(Accordion, { items: ITENS, open: ["sigilo"] }));
|
|
34
|
+
expect(aberto("Sigilo")).toBe(true);
|
|
35
|
+
expect(aberto("Prazos")).toBe(false);
|
|
36
|
+
});
|
|
37
|
+
it("o clique só pede (onOpenChange); sem o app mudar open, nada abre", () => {
|
|
38
|
+
const aoMudar = vi.fn();
|
|
39
|
+
render(_jsx(Accordion, { items: ITENS, multiple: true, open: ["prazos"], onOpenChange: aoMudar }));
|
|
40
|
+
fireEvent.click(screen.getByRole("button", { name: "Anexos" }));
|
|
41
|
+
expect(aoMudar).toHaveBeenCalledWith(["prazos", "anexos"]);
|
|
42
|
+
expect(aberto("Anexos")).toBe(false);
|
|
43
|
+
});
|
|
44
|
+
it("o app guarda a escolha: com o estado dele, abre, fecha e a lista chega em ordem", () => {
|
|
45
|
+
let ultima = [];
|
|
46
|
+
function App() {
|
|
47
|
+
const [abertos, setAbertos] = useState([]);
|
|
48
|
+
return (_jsx(Accordion, { items: ITENS, multiple: true, open: abertos, onOpenChange: (ids) => {
|
|
49
|
+
ultima = ids;
|
|
50
|
+
setAbertos(ids);
|
|
51
|
+
} }));
|
|
52
|
+
}
|
|
53
|
+
render(_jsx(App, {}));
|
|
54
|
+
expect(aberto("Prazos")).toBe(false);
|
|
55
|
+
fireEvent.click(screen.getByRole("button", { name: "Sigilo" }));
|
|
56
|
+
fireEvent.click(screen.getByRole("button", { name: "Anexos" }));
|
|
57
|
+
expect(ultima).toEqual(["sigilo", "anexos"]);
|
|
58
|
+
expect(aberto("Sigilo") && aberto("Anexos")).toBe(true);
|
|
59
|
+
fireEvent.click(screen.getByRole("button", { name: "Sigilo" }));
|
|
60
|
+
expect(ultima).toEqual(["anexos"]);
|
|
61
|
+
expect(aberto("Sigilo")).toBe(false);
|
|
62
|
+
});
|
|
63
|
+
it("open vazio é controlado (tudo fechado), não ausência", () => {
|
|
64
|
+
render(_jsx(Accordion, { items: ITENS, open: [] }));
|
|
65
|
+
expect(aberto("Prazos")).toBe(false);
|
|
66
|
+
});
|
|
67
|
+
it("item desabilitado não pede nada", () => {
|
|
68
|
+
const aoMudar = vi.fn();
|
|
69
|
+
render(_jsx(Accordion, { items: [{ id: "x", title: "Bloqueado", content: "...", disabled: true }], open: [], onOpenChange: aoMudar }));
|
|
70
|
+
fireEvent.click(screen.getByRole("button", { name: "Bloqueado" }));
|
|
71
|
+
expect(aoMudar).not.toHaveBeenCalled();
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
|
+
import Badge from "../components/Badge/Badge";
|
|
5
|
+
import { lerArquivo } from "./lerArquivo";
|
|
6
|
+
const cssBadge = await lerArquivo("../core/src/components/Badge/Badge.css");
|
|
7
|
+
const css = cssBadge.replace(/\r\n/g, "\n");
|
|
8
|
+
const bloco = (seletor) => {
|
|
9
|
+
const inicio = css.indexOf(seletor + " {");
|
|
10
|
+
return css.slice(inicio, css.indexOf("}", inicio));
|
|
11
|
+
};
|
|
12
|
+
describe("Badge 2xs · padding lateral de 8px", () => {
|
|
13
|
+
it("a regra do 2xs usa o degrau nano (8px) dos lados e o micro (2px) em cima e embaixo", () => {
|
|
14
|
+
expect(bloco(".umds-badge--2xs")).toMatch(/padding:\s*var\(--umds-primitive-spacing-micro\)\s+var\(--umds-primitive-spacing-nano\)/);
|
|
15
|
+
});
|
|
16
|
+
it("os outros tamanhos não mudam de padding", () => {
|
|
17
|
+
expect(bloco(".umds-badge--xs")).toMatch(/padding:\s*var\(--umds-primitive-spacing-micro\)\s+var\(--umds-primitive-spacing-quarck\)/);
|
|
18
|
+
expect(bloco(".umds-badge--md")).toMatch(/padding:\s*var\(--umds-primitive-spacing-quarck\)\s+var\(--umds-primitive-spacing-nano\)/);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
describe("Badge attached · 22px e tom escuro", () => {
|
|
22
|
+
it("o rótulo colado tem altura mínima de 22px (24 - 2), de qualquer tamanho", () => {
|
|
23
|
+
expect(bloco(".umds-badge--attached")).toMatch(/min-height:\s*calc\(var\(--umds-primitive-spacing-xxs\)\s*-\s*var\(--umds-primitive-spacing-micro\)\)/);
|
|
24
|
+
const { container } = render(_jsx(Badge, { attached: true, size: "xs", variant: "neutral", appearance: "solid", children: "Tarefa manual" }));
|
|
25
|
+
expect(container.firstElementChild).toHaveClass("umds-badge--attached", "umds-badge--xs");
|
|
26
|
+
});
|
|
27
|
+
it("attachedTone dark escreve a classe; sem ela e com light, não", () => {
|
|
28
|
+
const { container } = render(_jsxs(_Fragment, { children: [_jsx(Badge, { attached: true, attachedTone: "dark", variant: "neutral", appearance: "solid", children: "A" }), _jsx(Badge, { attached: true, variant: "neutral", appearance: "solid", children: "B" }), _jsx(Badge, { attached: true, attachedTone: "light", variant: "neutral", appearance: "solid", children: "C" })] }));
|
|
29
|
+
expect(container.children[0]).toHaveClass("umds-badge--attached-dark");
|
|
30
|
+
expect(container.children[1]).not.toHaveClass("umds-badge--attached-dark");
|
|
31
|
+
expect(container.children[2]).not.toHaveClass("umds-badge--attached-dark");
|
|
32
|
+
});
|
|
33
|
+
it("sem attached o tom é ignorado", () => {
|
|
34
|
+
const { container } = render(_jsx(Badge, { attachedTone: "dark", variant: "neutral", appearance: "solid", children: "A" }));
|
|
35
|
+
expect(container.firstElementChild).not.toHaveClass("umds-badge--attached-dark");
|
|
36
|
+
});
|
|
37
|
+
it("CSS: o escuro é neutral-dark-down com texto branco, só no neutro sólido colado", () => {
|
|
38
|
+
const regra = bloco(".umds-badge--attached.umds-badge--neutral.umds-badge--solid.umds-badge--attached-dark");
|
|
39
|
+
expect(regra).toMatch(/background-color:\s*var\(--umds-semantic-color-neutral-dark-down\)/);
|
|
40
|
+
expect(regra).toMatch(/color:\s*var\(--umds-semantic-color-neutral-light-pure\)/);
|
|
41
|
+
expect(bloco(".umds-badge--attached.umds-badge--neutral.umds-badge--solid")).toMatch(/neutral-light-medium/);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { render, screen } from "@testing-library/react";
|
|
4
|
+
import Button from "../components/Button/Button";
|
|
5
|
+
import { lerArquivo } from "./lerArquivo";
|
|
6
|
+
const cssButton = await lerArquivo("../core/src/components/Button/Button.css");
|
|
7
|
+
const css = cssButton.replace(/\r\n/g, "\n");
|
|
8
|
+
const bloco = (seletor) => {
|
|
9
|
+
const inicio = css.indexOf(seletor + " {");
|
|
10
|
+
return css.slice(inicio, css.indexOf("}", inicio));
|
|
11
|
+
};
|
|
12
|
+
describe("Button · density", () => {
|
|
13
|
+
it("comfortable escreve a classe; sem a prop e com default o botão é o de antes", () => {
|
|
14
|
+
render(_jsxs(_Fragment, { children: [_jsx(Button, { size: "sm", density: "comfortable", children: "A" }), _jsx(Button, { size: "sm", children: "B" }), _jsx(Button, { size: "sm", density: "default", children: "C" })] }));
|
|
15
|
+
expect(screen.getByRole("button", { name: "A" })).toHaveClass("umds-button--sm", "umds-button--comfortable");
|
|
16
|
+
expect(screen.getByRole("button", { name: "B" })).not.toHaveClass("umds-button--comfortable");
|
|
17
|
+
expect(screen.getByRole("button", { name: "C" })).not.toHaveClass("umds-button--comfortable");
|
|
18
|
+
});
|
|
19
|
+
it("CSS: o sm confortável tem 12px de padding lateral; o sm de antes segue em 8px; o só-ícone fica de fora", () => {
|
|
20
|
+
expect(bloco(".umds-button--sm.umds-button--comfortable:not(.umds-button--icon)")).toMatch(/padding:\s*0\s+var\(--umds-primitive-spacing-mini\)/);
|
|
21
|
+
expect(bloco(".umds-button--sm")).toMatch(/padding:\s*0\s+var\(--umds-primitive-spacing-nano\)/);
|
|
22
|
+
});
|
|
23
|
+
it("os outros tamanhos mantêm o padding (a densidade só mexe no sm)", () => {
|
|
24
|
+
expect(bloco(".umds-button--xs")).toMatch(/padding:\s*0\s+var\(--umds-primitive-spacing-mini\)/);
|
|
25
|
+
expect(bloco(".umds-button--md")).toMatch(/padding:\s*0\s+var\(--umds-primitive-spacing-xxxs\)/);
|
|
26
|
+
expect(bloco(".umds-button--lg")).toMatch(/padding:\s*0\s+var\(--umds-primitive-spacing-xxs\)/);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import Calendar from "../components/Calendar/Calendar";
|
|
4
|
+
import { render } from "@testing-library/react";
|
|
5
|
+
import { lerArquivo } from "./lerArquivo";
|
|
6
|
+
const cssCalendar = await lerArquivo("../core/src/components/Calendar/Calendar.css");
|
|
7
|
+
const CSS = { Calendar: cssCalendar };
|
|
8
|
+
const css = (componente) => CSS[componente].replace(/\r\n/g, "\n");
|
|
9
|
+
const bloco = (texto, seletor) => {
|
|
10
|
+
const inicio = texto.indexOf(seletor + " {");
|
|
11
|
+
expect(inicio, seletor).toBeGreaterThanOrEqual(0);
|
|
12
|
+
return texto.slice(inicio, texto.indexOf("}", inicio));
|
|
13
|
+
};
|
|
14
|
+
describe("Calendar · density compact", () => {
|
|
15
|
+
it("compact escreve a classe na raiz; sem a prop, não", () => {
|
|
16
|
+
const { container } = render(_jsxs(_Fragment, { children: [_jsx(Calendar, { today: "2026-05-15", defaultDate: "2026-05-15", density: "compact" }), _jsx(Calendar, { today: "2026-05-15", defaultDate: "2026-05-15" })] }));
|
|
17
|
+
expect(container.children[0]).toHaveClass("umds-calendar--compact", "umds-calendar--month");
|
|
18
|
+
expect(container.children[1]).not.toHaveClass("umds-calendar--compact");
|
|
19
|
+
});
|
|
20
|
+
it("CSS: evento de 20px (16 + 4), 4px de padding lateral e linha de 16px; o título só é cortado quando passa da largura", () => {
|
|
21
|
+
const t = css("Calendar");
|
|
22
|
+
const compacto = bloco(t, ".umds-calendar--compact .umds-calendar__event");
|
|
23
|
+
expect(compacto).toMatch(/min-height:\s*calc\(var\(--umds-primitive-spacing-xxxs\)\s*\+\s*var\(--umds-primitive-spacing-quarck\)\)/);
|
|
24
|
+
expect(compacto).toMatch(/padding:\s*var\(--umds-primitive-spacing-micro\)\s+var\(--umds-primitive-spacing-quarck\)/);
|
|
25
|
+
expect(compacto).toMatch(/line-height:\s*var\(--umds-primitive-spacing-xxxs\)/);
|
|
26
|
+
const titulo = bloco(t, ".umds-calendar__event-title");
|
|
27
|
+
expect(titulo).toMatch(/text-overflow:\s*ellipsis/);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { render, screen } from "@testing-library/react";
|
|
4
|
+
import Coachmark from "../components/Coachmark/Coachmark";
|
|
5
|
+
const UM = [{ target: "#alvo-a", title: "Novo: arrastar", content: "Arraste a linha para trocar a ordem." }];
|
|
6
|
+
const DOIS = [...UM, { title: "Pronto", content: "Sem alvo." }];
|
|
7
|
+
function Pagina({ passos, ...resto }) {
|
|
8
|
+
return (_jsxs("div", { children: [_jsx("button", { id: "alvo-a", children: "A" }), _jsx(Coachmark, { steps: passos, open: true, ...resto })] }));
|
|
9
|
+
}
|
|
10
|
+
describe("Coachmark · contador", () => {
|
|
11
|
+
it("com um passo só não há contador, nem visível nem na região aria-live", () => {
|
|
12
|
+
const { baseElement } = render(_jsx(Pagina, { passos: UM }));
|
|
13
|
+
expect(screen.queryByText("1 de 1")).toBeNull();
|
|
14
|
+
expect(baseElement.textContent).not.toContain("1 de 1");
|
|
15
|
+
expect(baseElement.querySelector(".umds-coachmark__sr")?.textContent).toBe("Novo: arrastar");
|
|
16
|
+
});
|
|
17
|
+
it("com um passo e modal={false} também não (a dica pontual)", () => {
|
|
18
|
+
const { baseElement } = render(_jsx(Pagina, { passos: UM, modal: false }));
|
|
19
|
+
expect(baseElement.textContent).not.toContain("1 de 1");
|
|
20
|
+
});
|
|
21
|
+
it("com dois passos o contador aparece e o leitor de tela o ouve", () => {
|
|
22
|
+
const { baseElement } = render(_jsx(Pagina, { passos: DOIS }));
|
|
23
|
+
expect(screen.getByText("1 de 2")).toBeInTheDocument();
|
|
24
|
+
expect(baseElement.querySelector(".umds-coachmark__sr")?.textContent).toBe("1 de 2: Novo: arrastar");
|
|
25
|
+
});
|
|
26
|
+
it("counterLabel segue valendo com mais de um passo", () => {
|
|
27
|
+
render(_jsx(Pagina, { passos: DOIS, counterLabel: "Step {current} of {total}" }));
|
|
28
|
+
expect(screen.getByText("Step 1 of 2")).toBeInTheDocument();
|
|
29
|
+
});
|
|
30
|
+
it("o botão do último passo continua sendo Concluir", () => {
|
|
31
|
+
render(_jsx(Pagina, { passos: UM }));
|
|
32
|
+
expect(screen.getByRole("button", { name: "Concluir" })).toBeInTheDocument();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
|
+
import DataTable from "../components/DataTable/DataTable";
|
|
5
|
+
import { lerArquivo } from "./lerArquivo";
|
|
6
|
+
const cssDataTable = await lerArquivo("../core/src/components/DataTable/DataTable.css");
|
|
7
|
+
const COLUNAS = [
|
|
8
|
+
{ key: "nome", label: "Nome" },
|
|
9
|
+
{ key: "situacao", label: "Situação" },
|
|
10
|
+
];
|
|
11
|
+
const DADOS = [
|
|
12
|
+
{ nome: "Ana Souza", situacao: "Ativa", tom: "positive" },
|
|
13
|
+
{ nome: "Carlos Lima", situacao: "Bloqueado", tom: "negative" },
|
|
14
|
+
{ nome: "Marina Alves", situacao: "Licença", tom: "info" },
|
|
15
|
+
{ nome: "Rafael Pereira", situacao: "Desligado", tom: "muted" },
|
|
16
|
+
{ nome: "Beatriz Lima", situacao: "Ativa" },
|
|
17
|
+
];
|
|
18
|
+
const linhas = (c) => [...c.querySelectorAll("tbody tr")];
|
|
19
|
+
describe("DataTable · rowTone", () => {
|
|
20
|
+
it("o nome de um campo da linha traz o tom", () => {
|
|
21
|
+
const { container } = render(_jsx(DataTable, { columns: COLUNAS, data: DADOS, rowTone: "tom" }));
|
|
22
|
+
const l = linhas(container);
|
|
23
|
+
expect(l[0]).toHaveClass("umds-datatable__row--positive");
|
|
24
|
+
expect(l[1]).toHaveClass("umds-datatable__row--negative");
|
|
25
|
+
expect(l[2]).toHaveClass("umds-datatable__row--info");
|
|
26
|
+
expect(l[3]).toHaveClass("umds-datatable__row--muted");
|
|
27
|
+
expect(l[4].className).toBe("umds-datatable__row");
|
|
28
|
+
});
|
|
29
|
+
it("uma função (row, rowIndex) devolve o tom", () => {
|
|
30
|
+
const { container } = render(_jsx(DataTable, { columns: COLUNAS, data: DADOS, rowTone: (row, i) => (row.situacao === "Bloqueado" || i === 4 ? "negative" : undefined) }));
|
|
31
|
+
const l = linhas(container);
|
|
32
|
+
expect(l[1]).toHaveClass("umds-datatable__row--negative");
|
|
33
|
+
expect(l[4]).toHaveClass("umds-datatable__row--negative");
|
|
34
|
+
expect(l[0].className).toBe("umds-datatable__row");
|
|
35
|
+
});
|
|
36
|
+
it("tom desconhecido ou vazio não vira classe", () => {
|
|
37
|
+
const { container } = render(_jsx(DataTable, { columns: COLUNAS, data: [{ nome: "A", situacao: "x", tom: "rosa" }, { nome: "B", situacao: "y", tom: "" }], rowTone: "tom" }));
|
|
38
|
+
for (const l of linhas(container))
|
|
39
|
+
expect(l.className).toBe("umds-datatable__row");
|
|
40
|
+
});
|
|
41
|
+
it("sem rowTone nada muda", () => {
|
|
42
|
+
const { container } = render(_jsx(DataTable, { columns: COLUNAS, data: DADOS }));
|
|
43
|
+
for (const l of linhas(container))
|
|
44
|
+
expect(l.className).toBe("umds-datatable__row");
|
|
45
|
+
});
|
|
46
|
+
it("o tom convive com a linha selecionada e a zebra (as classes ficam; o CSS faz a selecionada vencer)", () => {
|
|
47
|
+
const { container } = render(_jsx(DataTable, { columns: COLUNAS, data: DADOS, rowTone: "tom", striped: true, rowKey: "nome", selectedRowKeys: ["Carlos Lima"] }));
|
|
48
|
+
const l = linhas(container);
|
|
49
|
+
expect(l[1]).toHaveClass("umds-datatable__row--negative", "umds-datatable__row--selected", "umds-datatable__row--striped");
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
describe("DataTable · compacta, 44px e CSS do tom", () => {
|
|
53
|
+
const css = cssDataTable.replace(/\r\n/g, "\n");
|
|
54
|
+
const bloco = (seletor) => {
|
|
55
|
+
const inicio = css.indexOf(seletor + " {");
|
|
56
|
+
return css.slice(inicio, css.indexOf("}", inicio));
|
|
57
|
+
};
|
|
58
|
+
it("a densidade compacta fixa cabeçalho e linha na altura de campo (44px); o documento fica de fora", () => {
|
|
59
|
+
expect(bloco(".umds-datatable--compact:not(.umds-datatable--document) .umds-datatable__td")).toMatch(/height:\s*var\(--umds-semantic-field-height\)/);
|
|
60
|
+
expect(css).toContain(".umds-datatable--compact:not(.umds-datatable--document) .umds-datatable__th,");
|
|
61
|
+
const { container } = render(_jsx(DataTable, { density: "compact", columns: COLUNAS, data: DADOS }));
|
|
62
|
+
expect(container.querySelector(".umds-datatable--compact")).not.toBeNull();
|
|
63
|
+
});
|
|
64
|
+
it("a linha selecionada vence o tom (o :not) e o tom vence a zebra", () => {
|
|
65
|
+
expect(css).toMatch(/\.umds-datatable__row--negative:not\(\.umds-datatable__row--selected\)/);
|
|
66
|
+
expect(css).toMatch(/\.umds-datatable__row--negative:not\(\.umds-datatable__row--selected\)\.umds-datatable__row--striped/);
|
|
67
|
+
expect(bloco(".umds-datatable__row--muted .umds-datatable__td")).toMatch(/neutral-dark-down/);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import Input from "../components/Input/Input";
|
|
4
|
+
import { render } from "@testing-library/react";
|
|
5
|
+
import { lerArquivo } from "./lerArquivo";
|
|
6
|
+
const cssInput = await lerArquivo("../core/src/components/Input/Input.css");
|
|
7
|
+
const CSS = { Input: cssInput };
|
|
8
|
+
const css = (componente) => CSS[componente].replace(/\r\n/g, "\n");
|
|
9
|
+
const bloco = (texto, seletor) => {
|
|
10
|
+
const inicio = texto.indexOf(seletor + " {");
|
|
11
|
+
expect(inicio, seletor).toBeGreaterThanOrEqual(0);
|
|
12
|
+
return texto.slice(inicio, texto.indexOf("}", inicio));
|
|
13
|
+
};
|
|
14
|
+
describe("Input · variant ghost", () => {
|
|
15
|
+
it("ghost escreve a classe; sem a prop e com default, não", () => {
|
|
16
|
+
const { container } = render(_jsxs(_Fragment, { children: [_jsx(Input, { ariaLabel: "a", variant: "ghost" }), _jsx(Input, { ariaLabel: "b" }), _jsx(Input, { ariaLabel: "c", variant: "default" })] }));
|
|
17
|
+
expect(container.children[0]).toHaveClass("umds-input--ghost");
|
|
18
|
+
expect(container.children[1]).not.toHaveClass("umds-input--ghost");
|
|
19
|
+
expect(container.children[2]).not.toHaveClass("umds-input--ghost");
|
|
20
|
+
});
|
|
21
|
+
it("CSS: só o repouso muda (fundo claro, borda clara) e com baixa especificidade, para o hover e o foco vencerem", () => {
|
|
22
|
+
const t = css("Input");
|
|
23
|
+
const ghost = bloco(t, ".umds-input--ghost:where(:not(.umds-input--error):not(.umds-input--disabled):not(.umds-input--readonly)) .umds-input__container");
|
|
24
|
+
expect(ghost).toMatch(/background-color:\s*var\(--umds-semantic-color-background-light\)/);
|
|
25
|
+
expect(ghost).toMatch(/border-color:\s*var\(--umds-semantic-color-neutral-light-medium\)/);
|
|
26
|
+
expect(t.indexOf(".umds-input__container:focus-within:not(")).toBeGreaterThanOrEqual(0);
|
|
27
|
+
});
|
|
28
|
+
it("o foco, o erro e o desabilitado do campo ghost seguem as classes do padrão", () => {
|
|
29
|
+
const { container } = render(_jsx(Input, { ariaLabel: "d", variant: "ghost", errorMessage: "Obrigat\u00F3rio" }));
|
|
30
|
+
expect(container.firstElementChild).toHaveClass("umds-input--ghost", "umds-input--error");
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import Modal from "../components/Modal/Modal";
|
|
4
|
+
import { render, screen } from "@testing-library/react";
|
|
5
|
+
import { lerArquivo } from "./lerArquivo";
|
|
6
|
+
const cssModal = await lerArquivo("../core/src/components/Modal/Modal.css");
|
|
7
|
+
const CSS = { Modal: cssModal };
|
|
8
|
+
const css = (componente) => CSS[componente].replace(/\r\n/g, "\n");
|
|
9
|
+
const bloco = (texto, seletor) => {
|
|
10
|
+
const inicio = texto.indexOf(seletor + " {");
|
|
11
|
+
expect(inicio, seletor).toBeGreaterThanOrEqual(0);
|
|
12
|
+
return texto.slice(inicio, texto.indexOf("}", inicio));
|
|
13
|
+
};
|
|
14
|
+
describe("Modal · density 1doc", () => {
|
|
15
|
+
it("escreve a classe e convive com variant primary; sem a prop, não", () => {
|
|
16
|
+
render(_jsx(Modal, { open: true, inline: true, density: "1doc", variant: "primary", title: "Resolver tarefa" }));
|
|
17
|
+
expect(screen.getByRole("dialog", { name: "Resolver tarefa" })).toHaveClass("umds-modal--1doc", "umds-modal--primary", "umds-modal--base");
|
|
18
|
+
});
|
|
19
|
+
it("sem density o modal é o de antes", () => {
|
|
20
|
+
render(_jsx(Modal, { open: true, inline: true, title: "Padr\u00E3o" }));
|
|
21
|
+
expect(screen.getByRole("dialog", { name: "Padrão" })).not.toHaveClass("umds-modal--1doc");
|
|
22
|
+
});
|
|
23
|
+
it("CSS: cabeçalho de 67px, rodapé de 65px (padding 12px 24px) e raio de 12px; o padrão (8px) não muda", () => {
|
|
24
|
+
const t = css("Modal");
|
|
25
|
+
expect(bloco(t, ".umds-modal--1doc.umds-modal--base .umds-modal__header")).toMatch(/min-height:\s*67px/);
|
|
26
|
+
const rodape = bloco(t, ".umds-modal--1doc.umds-modal--base .umds-modal__footer");
|
|
27
|
+
expect(rodape).toMatch(/min-height:\s*65px/);
|
|
28
|
+
expect(rodape).toMatch(/padding:\s*var\(--umds-primitive-spacing-mini\)\s+var\(--umds-primitive-spacing-xxs\)/);
|
|
29
|
+
expect(t).toMatch(/\.umds-modal--1doc:not\(\.umds-modal--fullscreen\):not\(\.umds-modal--janela-fullscreen\):not\(\.umds-modal--sheet\) \{\n(?:\s*\/\*.*\*\/\n)?\s*border-radius:\s*12px/);
|
|
30
|
+
expect(bloco(t, ".umds-modal")).toMatch(/border-radius:\s*var\(--umds-primitive-border-radius-sm\)/);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -25,7 +25,7 @@ describe("html-seguro: estilo de texto por token", () => {
|
|
|
25
25
|
expect(estiloDeTexto("color", "var(--umds-primitive-red-pure)")).toBe("color: var(--umds-primitive-red-pure);");
|
|
26
26
|
expect(estiloDeTexto("color", "var(--umds-semantic-color-feedback-negative-pure)")).toBe("color: var(--umds-semantic-color-feedback-negative-pure);");
|
|
27
27
|
expect(estiloDeTexto("font-size", "var(--umds-primitive-font-size-xs)")).toBe("font-size: var(--umds-primitive-font-size-xs);");
|
|
28
|
-
expect(estiloDeTexto("font-family", "var(--umds-semantic-font-family-
|
|
28
|
+
expect(estiloDeTexto("font-family", "var(--umds-semantic-font-family-base)")).toBe("font-family: var(--umds-semantic-font-family-base);");
|
|
29
29
|
for (const mau of ["red", "#ff0000", "rgb(255,0,0)", "var(--outra-coisa)", "var(--umds-primitive-red-pure); background: red", "expression(alert(1))", "url(x)"]) {
|
|
30
30
|
expect(estiloDeTexto("color", mau)).toBe("");
|
|
31
31
|
}
|
|
@@ -36,7 +36,7 @@ describe("html-seguro: estilo de texto por token", () => {
|
|
|
36
36
|
});
|
|
37
37
|
it("o span guarda só as declarações válidas; o resto do style sai", () => {
|
|
38
38
|
expect(sanitizarHtml('<span style="color: var(--umds-primitive-red-pure); background: red; font-size: 40px">a</span>')).toBe('<span style="color: var(--umds-primitive-red-pure);">a</span>');
|
|
39
|
-
expect(sanitizarHtml('<span style="font-family: var(--umds-semantic-font-family-
|
|
39
|
+
expect(sanitizarHtml('<span style="font-family: var(--umds-semantic-font-family-base); font-size: var(--umds-primitive-font-size-sm)">a</span>')).toBe('<span style="font-family: var(--umds-semantic-font-family-base); font-size: var(--umds-primitive-font-size-sm);">a</span>');
|
|
40
40
|
expect(sanitizarHtml('<span style="color: red">a</span>')).toBe("<span>a</span>");
|
|
41
41
|
});
|
|
42
42
|
it("estilo só vale em span: em outras tags sai", () => {
|
|
@@ -62,15 +62,15 @@ describe("RichTextEditor: fonte, tamanho e cor do texto", () => {
|
|
|
62
62
|
fireEvent.keyDown(screen.getByRole("group", { name: "Cor do texto" }), { key: "Escape" });
|
|
63
63
|
expect(screen.queryByRole("group", { name: "Cor do texto" })).toBeNull();
|
|
64
64
|
});
|
|
65
|
-
it("a fonte
|
|
65
|
+
it("a fonte do DS embrulha o texto selecionado num span com o token", async () => {
|
|
66
66
|
const usuario = userEvent.setup();
|
|
67
67
|
const aoMudar = vi.fn();
|
|
68
68
|
abrir(["fontFamily"], { onChange: aoMudar });
|
|
69
69
|
selecionarTexto();
|
|
70
70
|
await usuario.click(screen.getByRole("button", { name: "Fonte" }));
|
|
71
71
|
await usuario.click(screen.getByRole("combobox", { name: "Fonte" }));
|
|
72
|
-
await usuario.click(screen.getByRole("option", { name: "
|
|
73
|
-
expect(execCommand).toHaveBeenCalledWith("insertHTML", false, '<span style="font-family: var(--umds-semantic-font-family-
|
|
72
|
+
await usuario.click(screen.getByRole("option", { name: "Padrão" }));
|
|
73
|
+
expect(execCommand).toHaveBeenCalledWith("insertHTML", false, '<span style="font-family: var(--umds-semantic-font-family-base);">Parecer</span>');
|
|
74
74
|
expect(aoMudar).toHaveBeenCalled();
|
|
75
75
|
expect(screen.queryByRole("group", { name: "Fonte" })).toBeNull();
|
|
76
76
|
});
|
|
@@ -105,11 +105,11 @@ describe("RichTextEditor: fonte, tamanho e cor do texto", () => {
|
|
|
105
105
|
});
|
|
106
106
|
it("os textos vêm por labels", async () => {
|
|
107
107
|
const usuario = userEvent.setup();
|
|
108
|
-
abrir(["fontFamily", "textColor"], { labels: { fontFamily: "Font", textColor: "Text color",
|
|
108
|
+
abrir(["fontFamily", "textColor"], { labels: { fontFamily: "Font", textColor: "Text color", fontFamilyBase: "Default", styleClose: "Close" } });
|
|
109
109
|
selecionarTexto();
|
|
110
110
|
await usuario.click(screen.getByRole("button", { name: "Font" }));
|
|
111
111
|
await usuario.click(screen.getByRole("combobox", { name: "Font" }));
|
|
112
|
-
expect(screen.getByRole("option", { name: "
|
|
112
|
+
expect(screen.getByRole("option", { name: "Default" })).toBeInTheDocument();
|
|
113
113
|
await usuario.keyboard("{Escape}");
|
|
114
114
|
expect(screen.getByRole("button", { name: "Close" })).toBeInTheDocument();
|
|
115
115
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import SegmentedControl from "../components/SegmentedControl/SegmentedControl";
|
|
4
|
+
import { render } from "@testing-library/react";
|
|
5
|
+
import { lerArquivo } from "./lerArquivo";
|
|
6
|
+
const cssSegmentedControl = await lerArquivo("../core/src/components/SegmentedControl/SegmentedControl.css");
|
|
7
|
+
const CSS = { SegmentedControl: cssSegmentedControl };
|
|
8
|
+
const css = (componente) => CSS[componente].replace(/\r\n/g, "\n");
|
|
9
|
+
const bloco = (texto, seletor) => {
|
|
10
|
+
const inicio = texto.indexOf(seletor + " {");
|
|
11
|
+
expect(inicio, seletor).toBeGreaterThanOrEqual(0);
|
|
12
|
+
return texto.slice(inicio, texto.indexOf("}", inicio));
|
|
13
|
+
};
|
|
14
|
+
describe("SegmentedControl · variant surface", () => {
|
|
15
|
+
const OPCOES = [
|
|
16
|
+
{ label: "Individual", value: "individual", count: 12 },
|
|
17
|
+
{ label: "Em lote", value: "lote" },
|
|
18
|
+
];
|
|
19
|
+
it("surface escreve a classe; sem a prop e com default, não", () => {
|
|
20
|
+
const { container } = render(_jsxs(_Fragment, { children: [_jsx(SegmentedControl, { options: OPCOES, variant: "surface", defaultValue: "individual" }), _jsx(SegmentedControl, { options: OPCOES, defaultValue: "individual" }), _jsx(SegmentedControl, { options: OPCOES, variant: "default", defaultValue: "individual" })] }));
|
|
21
|
+
expect(container.children[0]).toHaveClass("umds-segmented--surface");
|
|
22
|
+
expect(container.children[1]).not.toHaveClass("umds-segmented--surface");
|
|
23
|
+
expect(container.children[2]).not.toHaveClass("umds-segmented--surface");
|
|
24
|
+
});
|
|
25
|
+
it("CSS: o escolhido é branco, em negrito e com sombra; o trilho é cinza claro; o azul cheio do padrão segue", () => {
|
|
26
|
+
const t = css("SegmentedControl");
|
|
27
|
+
const escolhido = bloco(t, ".umds-segmented--surface .umds-segmented__input:checked + .umds-segmented__item,\n.umds-segmented--surface .umds-segmented__input:checked + .umds-segmented__item:hover");
|
|
28
|
+
expect(escolhido).toMatch(/background-color:\s*var\(--umds-semantic-color-background-white\)/);
|
|
29
|
+
expect(escolhido).toMatch(/font-weight:\s*var\(--umds-primitive-font-weight-bold\)/);
|
|
30
|
+
expect(escolhido).toMatch(/box-shadow:\s*var\(--umds-semantic-shadow-md\)/);
|
|
31
|
+
expect(bloco(t, ".umds-segmented--surface .umds-segmented__track")).toMatch(/background-color:\s*var\(--umds-semantic-color-neutral-light-medium\)/);
|
|
32
|
+
expect(t).toMatch(/\.umds-segmented__input:checked \+ \.umds-segmented__item,\n\.umds-segmented__input:checked \+ \.umds-segmented__item:hover \{\n\s*background-color:\s*var\(--umds-semantic-color-primary-pure\)/);
|
|
33
|
+
});
|
|
34
|
+
it("o contador do escolhido fica cinza sobre o branco e o dos outros, branco sobre o trilho", () => {
|
|
35
|
+
const t = css("SegmentedControl");
|
|
36
|
+
expect(bloco(t, ".umds-segmented--surface .umds-segmented__count")).toMatch(/background-color:\s*var\(--umds-semantic-color-background-white\)/);
|
|
37
|
+
expect(bloco(t, ".umds-segmented--surface .umds-segmented__input:checked + .umds-segmented__item .umds-segmented__count")).toMatch(/background-color:\s*var\(--umds-semantic-color-neutral-light-medium\)/);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
4
|
+
import Select from "../components/Select/Select";
|
|
5
|
+
const OPCOES = [
|
|
6
|
+
{ label: "Urgente", value: "urgente", etiqueta: "Prazo hoje" },
|
|
7
|
+
{ label: "Rotina", value: "rotina", etiqueta: "Sem prazo" },
|
|
8
|
+
];
|
|
9
|
+
const item = ({ optionData }) => (_jsxs("span", { "data-testid": "item", children: [_jsx("b", { children: optionData.label }), " ", _jsx("i", { children: optionData.etiqueta })] }));
|
|
10
|
+
describe("Select · item com escopo da opção", () => {
|
|
11
|
+
it("a lista mostra o item de cada opção, recebendo a opção (optionData e o apelido option)", () => {
|
|
12
|
+
const vistos = [];
|
|
13
|
+
render(_jsx(Select, { ariaLabel: "Prioridade", options: OPCOES, item: (escopo) => {
|
|
14
|
+
vistos.push(escopo);
|
|
15
|
+
return _jsx("span", { "data-testid": "item", children: escopo.optionData.label });
|
|
16
|
+
} }));
|
|
17
|
+
fireEvent.click(screen.getByRole("combobox"));
|
|
18
|
+
expect(screen.getAllByTestId("item").map((n) => n.textContent)).toEqual(["Urgente", "Rotina"]);
|
|
19
|
+
expect(vistos[0].optionData).toBe(OPCOES[0]);
|
|
20
|
+
expect(vistos[0].option).toBe(OPCOES[0]);
|
|
21
|
+
});
|
|
22
|
+
it("o gatilho com a opção escolhida mostra o conteúdo do item, não o texto", () => {
|
|
23
|
+
render(_jsx(Select, { ariaLabel: "Prioridade", options: OPCOES, value: "urgente", item: item }));
|
|
24
|
+
const gatilho = screen.getByRole("combobox");
|
|
25
|
+
expect(gatilho.querySelector(".umds-select__trigger-item")).not.toBeNull();
|
|
26
|
+
expect(gatilho).toHaveTextContent("Urgente");
|
|
27
|
+
expect(gatilho).toHaveTextContent("Prazo hoje");
|
|
28
|
+
expect(gatilho.querySelector(".umds-select__placeholder")).toBeNull();
|
|
29
|
+
});
|
|
30
|
+
it("sem valor o gatilho mostra o placeholder; escolher na lista passa o item para o gatilho", () => {
|
|
31
|
+
function App() {
|
|
32
|
+
return _jsx(Select, { ariaLabel: "Prioridade", placeholder: "Escolha", options: OPCOES, item: item });
|
|
33
|
+
}
|
|
34
|
+
render(_jsx(App, {}));
|
|
35
|
+
const gatilho = screen.getByRole("combobox");
|
|
36
|
+
expect(gatilho).toHaveTextContent("Escolha");
|
|
37
|
+
expect(gatilho.querySelector(".umds-select__trigger-item")).toBeNull();
|
|
38
|
+
fireEvent.click(gatilho);
|
|
39
|
+
fireEvent.click(screen.getAllByRole("option")[1]);
|
|
40
|
+
expect(screen.getByRole("combobox").querySelector(".umds-select__trigger-item")).toHaveTextContent("Rotina");
|
|
41
|
+
});
|
|
42
|
+
it("seleção múltipla segue com o texto no gatilho", () => {
|
|
43
|
+
render(_jsx(Select, { ariaLabel: "Prioridade", multiple: true, options: OPCOES, value: ["urgente"], item: item }));
|
|
44
|
+
expect(screen.getByRole("combobox").querySelector(".umds-select__trigger-item")).toBeNull();
|
|
45
|
+
});
|
|
46
|
+
it("sem item nada muda: o gatilho mostra o rótulo; item como nó solto (legado) não vai ao gatilho", () => {
|
|
47
|
+
const { rerender } = render(_jsx(Select, { ariaLabel: "Prioridade", options: OPCOES, value: "urgente" }));
|
|
48
|
+
expect(screen.getByRole("combobox")).toHaveTextContent("Urgente");
|
|
49
|
+
expect(screen.getByRole("combobox").querySelector(".umds-select__trigger-item")).toBeNull();
|
|
50
|
+
rerender(_jsx(Select, { ariaLabel: "Prioridade", options: OPCOES, value: "urgente", item: _jsx("em", { children: "fixo" }) }));
|
|
51
|
+
expect(screen.getByRole("combobox").querySelector(".umds-select__trigger-item")).toBeNull();
|
|
52
|
+
expect(screen.getByRole("combobox")).toHaveTextContent("Urgente");
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|