@1doc/1ds-vue 2.8.0 → 2.9.0
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 +1115 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1016 -28
- package/dist/index.mjs +10524 -7523
- package/dist/index.umd.js +4 -4
- package/package.json +5 -4
- package/src/index.ts +26 -0
- package/src/teste/accordion-conteudo-livre.test.mjs +44 -0
- package/src/teste/atributos.test.mjs +91 -0
- package/src/teste/attachmentcard-ia.test.mjs +48 -0
- package/src/teste/avatargroup-overlap.test.mjs +45 -0
- package/src/teste/badge-tag.test.mjs +45 -0
- package/src/teste/box-item-flex.test.mjs +84 -0
- package/src/teste/box-layout.test.mjs +57 -0
- package/src/teste/button.test.mjs +34 -0
- package/src/teste/calendar.test.mjs +179 -0
- package/src/teste/chips-xs.test.mjs +33 -0
- package/src/teste/coachmark.test.mjs +119 -0
- package/src/teste/color-picker.test.mjs +79 -0
- package/src/teste/datatable-documento.test.mjs +106 -0
- package/src/teste/datatable-slots.test.mjs +105 -0
- package/src/teste/dom.mjs +168 -0
- package/src/teste/fileinput-trigger.test.mjs +36 -0
- package/src/teste/icon-picker.test.mjs +98 -0
- package/src/teste/input-mascara-afins.test.mjs +64 -0
- package/src/teste/kbd-code-block.test.mjs +76 -0
- package/src/teste/list.test.mjs +162 -0
- package/src/teste/modal-variantes.test.mjs +79 -0
- package/src/teste/org-chart.test.mjs +131 -0
- package/src/teste/otp-input.test.mjs +130 -0
- package/src/teste/popover-maxheight.test.mjs +26 -0
- package/src/teste/renderizar.mjs +64 -0
- package/src/teste/rich-text-editor.test.mjs +210 -0
- package/src/teste/select-placement-filtro.test.mjs +49 -0
- package/src/teste/stack-box-raiz-unica.test.mjs +134 -0
- package/src/teste/stack.test.mjs +80 -0
- package/src/teste/statcard-rotulo-topo.test.mjs +34 -0
- package/src/teste/tabs-contador-fechavel.test.mjs +60 -0
- package/src/teste/tooltip-dark.test.mjs +28 -0
- package/src/utils/calendario.ts +78 -0
- package/src/utils/html-seguro.ts +94 -0
- package/src/utils/paleta-de-cores.ts +34 -0
- package/src/utils/texto.ts +5 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calendar no Vue, montado num DOM (jsdom): grade, eventos, +N, teclado e visões.
|
|
3
|
+
*/
|
|
4
|
+
import { test, after } from "node:test";
|
|
5
|
+
import assert from "node:assert/strict";
|
|
6
|
+
import { montar, documento, teclar, clicar, proximoTick } from "./dom.mjs";
|
|
7
|
+
|
|
8
|
+
const HOJE = "2026-05-15";
|
|
9
|
+
const EVENTOS = [
|
|
10
|
+
{ id: "a", date: "2026-05-04", title: "Proc. Administrativo 002/2020", color: "--umds-primitive-blue-pure" },
|
|
11
|
+
{ id: "b", date: "2026-05-11", title: "Protocolo 005/2020", color: "--umds-primitive-green-pure", time: "09:00" },
|
|
12
|
+
{ id: "c", date: "2026-05-11", title: "Ofício 001/2020", color: "--umds-primitive-red-pure", time: "08:00" },
|
|
13
|
+
...[1, 2, 3, 4, 5].map((n) => ({ id: "d" + n, date: "2026-05-20", title: "Reunião " + n })),
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
const montados = [];
|
|
17
|
+
const abrir = async (props = {}, slots = {}) => {
|
|
18
|
+
const m = await montar("Calendar/Calendar.vue", { today: HOJE, defaultDate: HOJE, ...props }, slots);
|
|
19
|
+
montados.push(m);
|
|
20
|
+
return m;
|
|
21
|
+
};
|
|
22
|
+
after(() => montados.forEach((m) => m.desmontar()));
|
|
23
|
+
|
|
24
|
+
const celula = (m, iso) => m.raiz.querySelector(`[data-date="${iso}"]`);
|
|
25
|
+
const titulo = (m) => m.raiz.querySelector(".umds-calendar__title").textContent.trim();
|
|
26
|
+
const botao = (m, nome) => [...m.raiz.querySelectorAll("button")].find((b) => (b.getAttribute("aria-label") || b.textContent.trim()) === nome);
|
|
27
|
+
|
|
28
|
+
test("é uma grade nomeada pelo mês, com sete cabeçalhos; maio de 2026 tem seis semanas", async () => {
|
|
29
|
+
const m = await abrir();
|
|
30
|
+
const grade = m.raiz.querySelector('[role="grid"]');
|
|
31
|
+
assert.equal(grade.getAttribute("aria-label"), "Maio 2026");
|
|
32
|
+
assert.equal(m.raiz.querySelectorAll('[role="columnheader"]').length, 7);
|
|
33
|
+
assert.equal(m.raiz.querySelectorAll('[role="columnheader"]')[0].getAttribute("aria-label"), "Domingo");
|
|
34
|
+
assert.equal(m.raiz.querySelectorAll('[role="gridcell"]').length, 42);
|
|
35
|
+
assert.equal(titulo(m), "Maio 2026");
|
|
36
|
+
assert.ok(celula(m, "2026-04-26").classList.contains("umds-calendar__cell--outside"));
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test("hoje tem aria-current; cada dia tem nome com a contagem de eventos", async () => {
|
|
40
|
+
const m = await abrir({ events: EVENTOS });
|
|
41
|
+
assert.equal(celula(m, HOJE).getAttribute("aria-current"), "date");
|
|
42
|
+
assert.equal(celula(m, "2026-05-11").getAttribute("aria-label"), "segunda-feira, 11 de maio de 2026, 2 eventos");
|
|
43
|
+
assert.equal(celula(m, "2026-05-12").getAttribute("aria-label"), "terça-feira, 12 de maio de 2026, sem eventos");
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test("os eventos caem no dia, em ordem de horário, com a cor do dado", async () => {
|
|
47
|
+
const m = await abrir({ events: EVENTOS });
|
|
48
|
+
const chips = celula(m, "2026-05-11").querySelectorAll(".umds-calendar__event");
|
|
49
|
+
assert.equal(chips.length, 2);
|
|
50
|
+
assert.ok(chips[0].textContent.includes("08:00") && chips[0].textContent.includes("Ofício 001/2020"));
|
|
51
|
+
assert.match(chips[0].getAttribute("style"), /border-left-color:\s*var\(--umds-primitive-red-pure\)/);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test("passou de maxVisible: três eventos e um +N que avisa com os escondidos", async () => {
|
|
55
|
+
const vistos = [];
|
|
56
|
+
const m = await abrir({ events: EVENTOS, onMoreClick: (iso, escondidos) => vistos.push([iso, escondidos.map((e) => e.id)]) });
|
|
57
|
+
const dia = celula(m, "2026-05-20");
|
|
58
|
+
assert.equal(dia.querySelectorAll(".umds-calendar__event").length, 3);
|
|
59
|
+
const mais = dia.querySelector(".umds-calendar__more");
|
|
60
|
+
assert.equal(mais.textContent.trim(), "+2");
|
|
61
|
+
assert.equal(mais.getAttribute("aria-label"), "2 eventos a mais em 20 de maio");
|
|
62
|
+
await clicar(mais);
|
|
63
|
+
assert.deepEqual(vistos, [["2026-05-20", ["d4", "d5"]]]);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test("clicar no evento avisa com o evento e não clica no dia; clicar no dia avisa com o ISO", async () => {
|
|
67
|
+
const eventos = [];
|
|
68
|
+
const dias = [];
|
|
69
|
+
const m = await abrir({ events: EVENTOS, onEventClick: (e) => eventos.push(e.id), onDayClick: (d) => dias.push(d) });
|
|
70
|
+
await clicar(celula(m, "2026-05-04").querySelector(".umds-calendar__event"));
|
|
71
|
+
assert.deepEqual(eventos, ["a"]);
|
|
72
|
+
assert.deepEqual(dias, []);
|
|
73
|
+
await clicar(celula(m, "2026-05-12"));
|
|
74
|
+
assert.deepEqual(dias, ["2026-05-12"]);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test("anterior, próximo e hoje navegam e avisam em onDateChange", async () => {
|
|
78
|
+
const datas = [];
|
|
79
|
+
const m = await abrir({ onDateChange: (d) => datas.push(d) });
|
|
80
|
+
await clicar(botao(m, "Próximo"));
|
|
81
|
+
assert.equal(titulo(m), "Junho 2026");
|
|
82
|
+
await clicar(botao(m, "Anterior"));
|
|
83
|
+
await clicar(botao(m, "Anterior"));
|
|
84
|
+
assert.equal(titulo(m), "Abril 2026");
|
|
85
|
+
await clicar(botao(m, "Hoje"));
|
|
86
|
+
assert.equal(titulo(m), "Maio 2026");
|
|
87
|
+
assert.deepEqual(datas, ["2026-06-15", "2026-05-15", "2026-04-15", HOJE]);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test("só o dia de hoje entra na ordem de Tab, com os eventos dele", async () => {
|
|
91
|
+
const m = await abrir({ today: "2026-05-11", defaultDate: "2026-05-11", events: EVENTOS });
|
|
92
|
+
const comTab = [...m.raiz.querySelectorAll('[role="gridcell"]')].filter((c) => c.getAttribute("tabindex") === "0");
|
|
93
|
+
assert.equal(comTab.length, 1);
|
|
94
|
+
assert.equal(comTab[0].getAttribute("data-date"), "2026-05-11");
|
|
95
|
+
const chips = [...m.raiz.querySelectorAll(".umds-calendar__event")].filter((c) => c.getAttribute("tabindex") === "0");
|
|
96
|
+
assert.equal(chips.length, 2);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test("setas movem o foco; Home, End e Enter", async () => {
|
|
100
|
+
const dias = [];
|
|
101
|
+
const m = await abrir({ onDayClick: (d) => dias.push(d) });
|
|
102
|
+
celula(m, HOJE).focus();
|
|
103
|
+
await teclar(celula(m, HOJE), "ArrowRight");
|
|
104
|
+
assert.equal(documento.activeElement, celula(m, "2026-05-16"));
|
|
105
|
+
await teclar(documento.activeElement, "ArrowDown");
|
|
106
|
+
assert.equal(documento.activeElement, celula(m, "2026-05-23"));
|
|
107
|
+
await teclar(documento.activeElement, "ArrowLeft");
|
|
108
|
+
await teclar(documento.activeElement, "ArrowUp");
|
|
109
|
+
assert.equal(documento.activeElement, celula(m, "2026-05-15"));
|
|
110
|
+
await teclar(documento.activeElement, "Home");
|
|
111
|
+
assert.equal(documento.activeElement, celula(m, "2026-05-10"));
|
|
112
|
+
await teclar(documento.activeElement, "End");
|
|
113
|
+
assert.equal(documento.activeElement, celula(m, "2026-05-16"));
|
|
114
|
+
await teclar(documento.activeElement, "Enter");
|
|
115
|
+
assert.deepEqual(dias, ["2026-05-16"]);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test("a seta que sai do mês troca de mês e leva o foco; PageDown troca de mês", async () => {
|
|
119
|
+
const m = await abrir({ defaultDate: "2026-05-30" });
|
|
120
|
+
celula(m, "2026-05-30").focus();
|
|
121
|
+
await teclar(celula(m, "2026-05-30"), "ArrowRight");
|
|
122
|
+
await teclar(documento.activeElement, "ArrowRight");
|
|
123
|
+
assert.equal(titulo(m), "Junho 2026");
|
|
124
|
+
assert.equal(documento.activeElement, celula(m, "2026-06-01"));
|
|
125
|
+
await teclar(documento.activeElement, "PageDown");
|
|
126
|
+
assert.equal(titulo(m), "Julho 2026");
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test("a visão de semana: sete dias, todos os eventos; onViewChange avisa", async () => {
|
|
130
|
+
const visoes = [];
|
|
131
|
+
const m = await abrir({ today: "2026-05-20", defaultDate: "2026-05-20", events: EVENTOS, onViewChange: (v) => visoes.push(v) });
|
|
132
|
+
const semana = [...m.raiz.querySelectorAll('input[type="radio"]')].find((r) => r.value === "week");
|
|
133
|
+
semana.click();
|
|
134
|
+
await proximoTick();
|
|
135
|
+
assert.deepEqual(visoes, ["week"]);
|
|
136
|
+
assert.equal(m.raiz.querySelectorAll('[role="gridcell"]').length, 7);
|
|
137
|
+
assert.equal(celula(m, "2026-05-20").querySelectorAll(".umds-calendar__event").length, 5);
|
|
138
|
+
assert.equal(m.raiz.querySelector(".umds-calendar__more"), null);
|
|
139
|
+
assert.ok(m.raiz.querySelector(".umds-calendar--week"));
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
test("weekStartsOn=1 e locale en-US com textos por prop", async () => {
|
|
143
|
+
const m = await abrir({
|
|
144
|
+
weekStartsOn: 1,
|
|
145
|
+
locale: "en-US",
|
|
146
|
+
previousLabel: "Previous",
|
|
147
|
+
nextLabel: "Next",
|
|
148
|
+
todayLabel: "Today",
|
|
149
|
+
viewLabel: "View",
|
|
150
|
+
});
|
|
151
|
+
assert.equal(m.raiz.querySelectorAll('[role="columnheader"]')[0].getAttribute("aria-label"), "Monday");
|
|
152
|
+
assert.equal(titulo(m), "May 2026");
|
|
153
|
+
assert.ok(botao(m, "Previous") && botao(m, "Next") && botao(m, "Today"));
|
|
154
|
+
assert.equal(m.raiz.querySelector('[role="group"]').getAttribute("aria-label"), "View");
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test("os slots header-start e header-end entram no cabeçalho; hideViewSwitcher esconde o seletor", async () => {
|
|
158
|
+
const m = await abrir(
|
|
159
|
+
{ hideViewSwitcher: true },
|
|
160
|
+
{ "header-start": () => "Filtro de escopo", "header-end": () => "Legenda" },
|
|
161
|
+
);
|
|
162
|
+
const start = m.raiz.querySelector(".umds-calendar__toolbar-start").textContent;
|
|
163
|
+
const end = m.raiz.querySelector(".umds-calendar__toolbar-end").textContent;
|
|
164
|
+
assert.ok(start.includes("Filtro de escopo"));
|
|
165
|
+
assert.ok(end.includes("Legenda"));
|
|
166
|
+
assert.equal(m.raiz.querySelectorAll('input[type="radio"]').length, 0);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test("controlado: date de fora manda; selectedDate marca o dia", async () => {
|
|
170
|
+
const { ref } = await import("vue");
|
|
171
|
+
const data = ref("2026-08-10");
|
|
172
|
+
const m = await montar("Calendar/Calendar.vue", () => ({ today: HOJE, date: data.value, selectedDate: "2026-08-12" }));
|
|
173
|
+
montados.push(m);
|
|
174
|
+
assert.equal(titulo(m), "Agosto 2026");
|
|
175
|
+
assert.equal(celula(m, "2026-08-12").getAttribute("aria-selected"), "true");
|
|
176
|
+
data.value = "2026-09-01";
|
|
177
|
+
await proximoTick();
|
|
178
|
+
assert.equal(titulo(m), "Setembro 2026");
|
|
179
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Chips: size xs e circularRemove, conferidos no HTML que o Vue GERADO escreve. */
|
|
2
|
+
import { test, before, after } from "node:test";
|
|
3
|
+
import assert from "node:assert/strict";
|
|
4
|
+
import { abrir, fechar, carregar, renderizar } from "./renderizar.mjs";
|
|
5
|
+
|
|
6
|
+
let Chips;
|
|
7
|
+
|
|
8
|
+
before(async () => {
|
|
9
|
+
await abrir();
|
|
10
|
+
Chips = await carregar("Chips/Chips.vue");
|
|
11
|
+
});
|
|
12
|
+
after(fechar);
|
|
13
|
+
|
|
14
|
+
test("size xs escreve a classe; sem size continua md", async () => {
|
|
15
|
+
assert.match(await renderizar(Chips, { label: "a", size: "xs" }), /umds-chip--xs/);
|
|
16
|
+
assert.match(await renderizar(Chips, { label: "b" }), /umds-chip--md/);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("circularRemove com removable escreve a classe do círculo", async () => {
|
|
20
|
+
const html = await renderizar(Chips, { label: "Marcador", removable: true, circularRemove: true });
|
|
21
|
+
assert.match(html, /umds-chip--remove-circle/);
|
|
22
|
+
assert.match(html, /aria-label="Remover Marcador"/);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("circularRemove sem removable não escreve a classe", async () => {
|
|
26
|
+
const html = await renderizar(Chips, { label: "Marcador", circularRemove: true });
|
|
27
|
+
assert.doesNotMatch(html, /umds-chip--remove-circle/);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test("sem circularRemove o chip removível é o de antes", async () => {
|
|
31
|
+
const html = await renderizar(Chips, { label: "x", removable: true });
|
|
32
|
+
assert.doesNotMatch(html, /umds-chip--remove-circle/);
|
|
33
|
+
});
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coachmark no Vue, montado num DOM (jsdom): o cartão vai por Teleport para o
|
|
3
|
+
* body, o foco entra nele e as teclas e os botões movem o tour.
|
|
4
|
+
*/
|
|
5
|
+
import { test, after, beforeEach } from "node:test";
|
|
6
|
+
import assert from "node:assert/strict";
|
|
7
|
+
import { montar, documento, teclar, clicar, proximoTick } from "./dom.mjs";
|
|
8
|
+
|
|
9
|
+
const PASSOS = [
|
|
10
|
+
{ target: "#alvo-a", title: "Cada item é uma aba", content: "Fluxos e formulários abrem em abas." },
|
|
11
|
+
{ target: "#alvo-b", title: "Salvo sozinho", content: "Tudo fica neste navegador." },
|
|
12
|
+
{ title: "Pronto", content: "Sem alvo: o cartão fica no centro." },
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
const montados = [];
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
documento.body.innerHTML = '<button id="alvo-a">A</button><button id="alvo-b">B</button>';
|
|
18
|
+
});
|
|
19
|
+
after(() => montados.forEach((m) => m.desmontar()));
|
|
20
|
+
|
|
21
|
+
const abrir = async (props = {}) => {
|
|
22
|
+
const m = await montar("Coachmark/Coachmark.vue", { open: true, steps: PASSOS, ...props });
|
|
23
|
+
montados.push(m);
|
|
24
|
+
// O Teleport e o primeiro posicionamento acontecem em ticks seguintes.
|
|
25
|
+
await proximoTick();
|
|
26
|
+
await new Promise((r) => setTimeout(r, 30));
|
|
27
|
+
return m;
|
|
28
|
+
};
|
|
29
|
+
const cartao = () => documento.querySelector('[role="dialog"]');
|
|
30
|
+
const botao = (nome) => [...documento.querySelectorAll("button")].find((b) => b.textContent.trim() === nome);
|
|
31
|
+
|
|
32
|
+
test("aberto é um diálogo modal nomeado pelo título, com contador", async () => {
|
|
33
|
+
await abrir();
|
|
34
|
+
const c = cartao();
|
|
35
|
+
assert.ok(c);
|
|
36
|
+
assert.equal(c.getAttribute("aria-modal"), "true");
|
|
37
|
+
const titulo = documento.getElementById(c.getAttribute("aria-labelledby"));
|
|
38
|
+
assert.equal(titulo.textContent.trim(), "Cada item é uma aba");
|
|
39
|
+
assert.ok(c.textContent.includes("1 de 3"));
|
|
40
|
+
assert.ok(botao("Próximo"));
|
|
41
|
+
assert.equal(botao("Anterior"), undefined);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test("fechado não desenha nada", async () => {
|
|
45
|
+
const m = await abrir({ open: false });
|
|
46
|
+
assert.equal(cartao(), null);
|
|
47
|
+
m.desmontar();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test("o foco entra no cartão", async () => {
|
|
51
|
+
await abrir();
|
|
52
|
+
assert.equal(documento.activeElement, cartao());
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("Próximo e Anterior trocam de passo e avisam em onStepChange", async () => {
|
|
56
|
+
const vistos = [];
|
|
57
|
+
await abrir({ onStepChange: (i) => vistos.push(i) });
|
|
58
|
+
await clicar(botao("Próximo"));
|
|
59
|
+
assert.deepEqual(vistos, [1]);
|
|
60
|
+
assert.ok(cartao().textContent.includes("Salvo sozinho"));
|
|
61
|
+
await clicar(botao("Anterior"));
|
|
62
|
+
assert.deepEqual(vistos, [1, 0]);
|
|
63
|
+
assert.ok(cartao().textContent.includes("Cada item é uma aba"));
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test("setas avançam e voltam; Esc sai com 'escape'", async () => {
|
|
67
|
+
const motivos = [];
|
|
68
|
+
await abrir({ onClose: (m) => motivos.push(m) });
|
|
69
|
+
await teclar(cartao(), "ArrowRight");
|
|
70
|
+
assert.ok(cartao().textContent.includes("Salvo sozinho"));
|
|
71
|
+
await teclar(cartao(), "ArrowLeft");
|
|
72
|
+
assert.ok(cartao().textContent.includes("Cada item é uma aba"));
|
|
73
|
+
await teclar(cartao(), "Escape");
|
|
74
|
+
assert.deepEqual(motivos, ["escape"]);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test("último passo: Concluir fecha com 'finish'; Sair do tour fecha com 'skip'", async () => {
|
|
78
|
+
const motivos = [];
|
|
79
|
+
await abrir({ step: 2, onClose: (m) => motivos.push(m) });
|
|
80
|
+
assert.equal(botao("Próximo"), undefined);
|
|
81
|
+
await clicar(botao("Concluir"));
|
|
82
|
+
await clicar(botao("Sair do tour"));
|
|
83
|
+
assert.deepEqual(motivos, ["finish", "skip"]);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test("hideSkip esconde o Sair do tour", async () => {
|
|
87
|
+
await abrir({ hideSkip: true });
|
|
88
|
+
assert.equal(botao("Sair do tour"), undefined);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test("os textos vêm por prop", async () => {
|
|
92
|
+
await abrir({ step: 1, nextLabel: "Next", previousLabel: "Back", skipLabel: "Skip tour", counterLabel: "{current} of {total}" });
|
|
93
|
+
assert.ok(botao("Next") && botao("Back") && botao("Skip tour"));
|
|
94
|
+
assert.ok(cartao().textContent.includes("2 of 3"));
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test("o foco fica preso no cartão: Tab no último vai ao primeiro", async () => {
|
|
98
|
+
await abrir();
|
|
99
|
+
const sair = botao("Sair do tour");
|
|
100
|
+
const proximo = botao("Próximo");
|
|
101
|
+
proximo.focus();
|
|
102
|
+
const evento = await teclar(proximo, "Tab");
|
|
103
|
+
assert.equal(evento.defaultPrevented, true);
|
|
104
|
+
assert.equal(documento.activeElement, sair);
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test("com alvo desenha o recorte; passo sem alvo, não", async () => {
|
|
108
|
+
await abrir();
|
|
109
|
+
assert.ok(documento.querySelector(".umds-coachmark__cutout"));
|
|
110
|
+
await abrir({ step: 2 });
|
|
111
|
+
assert.equal(documento.querySelector(".umds-coachmark--no-target") !== null, true);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test("o alvo pode ser um elemento ou um ref do Vue", async () => {
|
|
115
|
+
const { ref } = await import("vue");
|
|
116
|
+
const el = ref(documento.getElementById("alvo-b"));
|
|
117
|
+
await abrir({ steps: [{ target: el, title: "Por ref" }] });
|
|
118
|
+
assert.ok(documento.querySelector(".umds-coachmark__cutout"));
|
|
119
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ColorPicker no Vue: o HTML que o componente GERADO escreve.
|
|
3
|
+
*/
|
|
4
|
+
import { test, before, after } from "node:test";
|
|
5
|
+
import assert from "node:assert/strict";
|
|
6
|
+
import { abrir, fechar, carregar, renderizar } from "./renderizar.mjs";
|
|
7
|
+
|
|
8
|
+
let ColorPicker;
|
|
9
|
+
|
|
10
|
+
before(async () => {
|
|
11
|
+
await abrir();
|
|
12
|
+
ColorPicker = await carregar("ColorPicker/ColorPicker.vue");
|
|
13
|
+
});
|
|
14
|
+
after(fechar);
|
|
15
|
+
|
|
16
|
+
test("é um radiogroup com 31 amostras, cada uma com nome acessível", async () => {
|
|
17
|
+
const html = await renderizar(ColorPicker, { ariaLabel: "Cor do marcador" });
|
|
18
|
+
assert.match(html, /role="radiogroup"[^>]*aria-label="Cor do marcador"|aria-label="Cor do marcador"[^>]*role="radiogroup"/);
|
|
19
|
+
assert.equal((html.match(/role="radio"/g) || []).length, 31);
|
|
20
|
+
assert.match(html, /aria-label="Azul escuro"/);
|
|
21
|
+
assert.match(html, /aria-label="Cinza muito claro"/);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test("pinta a amostra com a variável do token", async () => {
|
|
25
|
+
const html = await renderizar(ColorPicker, { ariaLabel: "Cor" });
|
|
26
|
+
assert.match(html, /background-color:\s*var\(--umds-primitive-blue-pure\)/);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("a escolhida tem aria-checked true, tabindex 0 e a marcação; só ela", async () => {
|
|
30
|
+
const html = await renderizar(ColorPicker, { ariaLabel: "Cor", value: "--umds-primitive-red-pure" });
|
|
31
|
+
assert.equal((html.match(/aria-checked="true"/g) || []).length, 1);
|
|
32
|
+
assert.equal((html.match(/tabindex="0"/gi) || []).length, 1);
|
|
33
|
+
assert.match(html, /umds-color-picker__swatch--selected/);
|
|
34
|
+
assert.match(html, /<button[^>]*aria-label="Vermelho"[^>]*>/);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test("sem valor, só a primeira amostra entra na ordem de Tab", async () => {
|
|
38
|
+
const html = await renderizar(ColorPicker, { ariaLabel: "Cor" });
|
|
39
|
+
assert.equal((html.match(/tabindex="0"/gi) || []).length, 1);
|
|
40
|
+
assert.match(html, /<button[^>]*aria-label="Azul escuro"[^>]*tabindex="0"|<button[^>]*tabindex="0"[^>]*aria-label="Azul escuro"/i);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("a paleta do DS abre uma linha por família (nova-linha na primeira de cada uma)", async () => {
|
|
44
|
+
const html = await renderizar(ColorPicker, { ariaLabel: "Cor" });
|
|
45
|
+
assert.equal((html.match(/umds-color-picker__swatch--nova-linha/g) || []).length, 7);
|
|
46
|
+
assert.match(html, /umds-color-picker__swatches--familias/);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("families recorta e swatches substitui", async () => {
|
|
50
|
+
const recorte = await renderizar(ColorPicker, { ariaLabel: "Cor", families: ["blue", "gray"] });
|
|
51
|
+
assert.equal((recorte.match(/role="radio"/g) || []).length, 11);
|
|
52
|
+
const propria = await renderizar(ColorPicker, {
|
|
53
|
+
ariaLabel: "Color",
|
|
54
|
+
swatches: [{ value: "--umds-primitive-blue-pure", label: "Blue" }],
|
|
55
|
+
});
|
|
56
|
+
assert.equal((propria.match(/role="radio"/g) || []).length, 1);
|
|
57
|
+
assert.match(propria, /aria-label="Blue"/);
|
|
58
|
+
assert.doesNotMatch(propria, /nova-linha/);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test("disabled desabilita as amostras", async () => {
|
|
62
|
+
const html = await renderizar(ColorPicker, { ariaLabel: "Cor", disabled: true });
|
|
63
|
+
assert.equal((html.match(/<button[^>]*disabled/g) || []).length, 31);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test("a cor livre vem desligada e allowCustom liga o campo hexadecimal", async () => {
|
|
67
|
+
const sem = await renderizar(ColorPicker, { ariaLabel: "Cor" });
|
|
68
|
+
assert.doesNotMatch(sem, /hexadecimal/);
|
|
69
|
+
const com = await renderizar(ColorPicker, { ariaLabel: "Cor", allowCustom: true, value: "#336699" });
|
|
70
|
+
assert.match(com, /Cor livre \(hexadecimal\)/);
|
|
71
|
+
assert.match(com, /value="#336699"/);
|
|
72
|
+
assert.match(com, /umds-color-picker__custom-preview/);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test("label visível nomeia o grupo", async () => {
|
|
76
|
+
const html = await renderizar(ColorPicker, { label: "Cor de fundo", id: "cp" });
|
|
77
|
+
assert.match(html, /id="cp-label"[^>]*>Cor de fundo|>Cor de fundo<\/span>/);
|
|
78
|
+
assert.match(html, /aria-labelledby="cp-label"/);
|
|
79
|
+
});
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DataTable variant="document" e DescriptionList no Vue (DOM do jsdom).
|
|
3
|
+
*/
|
|
4
|
+
import { test, after } from "node:test";
|
|
5
|
+
import assert from "node:assert/strict";
|
|
6
|
+
import { montar } from "./dom.mjs";
|
|
7
|
+
|
|
8
|
+
const montados = [];
|
|
9
|
+
const abrir = async (caminho, props, slots) => {
|
|
10
|
+
const m = await montar(caminho, props, slots);
|
|
11
|
+
montados.push(m);
|
|
12
|
+
return m;
|
|
13
|
+
};
|
|
14
|
+
after(() => montados.forEach((m) => m.desmontar()));
|
|
15
|
+
|
|
16
|
+
const COLUNAS = [
|
|
17
|
+
{ key: "descricao", label: "Descrição", sortable: true },
|
|
18
|
+
{ key: "quantidade", label: "Quantidade", align: "right" },
|
|
19
|
+
];
|
|
20
|
+
const DADOS = [
|
|
21
|
+
{ descricao: "Diesel S10", quantidade: "5.760" },
|
|
22
|
+
{ descricao: "Gasolina comum", quantidade: "1.200" },
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
test("DataTable document: classe própria, cabeçalho e linhas", async () => {
|
|
26
|
+
const m = await abrir("DataTable/DataTable.vue", { variant: "document", columns: COLUNAS, data: DADOS });
|
|
27
|
+
assert.ok(m.raiz.querySelector(".umds-datatable--document"));
|
|
28
|
+
assert.equal(m.raiz.querySelectorAll("thead th").length, 2);
|
|
29
|
+
assert.ok(m.raiz.textContent.includes("Diesel S10"));
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test("DataTable document: sem botão de ordenar, sem aria-sort, sem checkbox", async () => {
|
|
33
|
+
const m = await abrir("DataTable/DataTable.vue", {
|
|
34
|
+
variant: "document",
|
|
35
|
+
selectable: true,
|
|
36
|
+
columns: COLUNAS,
|
|
37
|
+
data: DADOS,
|
|
38
|
+
sortKey: "descricao",
|
|
39
|
+
sortDirection: "asc",
|
|
40
|
+
});
|
|
41
|
+
assert.equal(m.raiz.querySelectorAll("button").length, 0);
|
|
42
|
+
assert.equal(m.raiz.querySelectorAll('input[type="checkbox"], [role="checkbox"]').length, 0);
|
|
43
|
+
for (const th of m.raiz.querySelectorAll("thead th")) assert.equal(th.getAttribute("aria-sort"), null);
|
|
44
|
+
assert.equal(m.raiz.querySelectorAll("thead th").length, 2);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("DataTable document: a linha não é clicável nem entra no Tab", async () => {
|
|
48
|
+
let cliques = 0;
|
|
49
|
+
const m = await abrir("DataTable/DataTable.vue", {
|
|
50
|
+
variant: "document",
|
|
51
|
+
columns: COLUNAS,
|
|
52
|
+
data: DADOS,
|
|
53
|
+
onRowClick: () => cliques++,
|
|
54
|
+
});
|
|
55
|
+
const linha = m.raiz.querySelector("tbody tr");
|
|
56
|
+
assert.equal(linha.getAttribute("tabindex"), null);
|
|
57
|
+
linha.click();
|
|
58
|
+
assert.equal(cliques, 0);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test("DataTable sem variant continua igual: ordena e seleciona", async () => {
|
|
62
|
+
const ordens = [];
|
|
63
|
+
const m = await abrir("DataTable/DataTable.vue", {
|
|
64
|
+
columns: COLUNAS,
|
|
65
|
+
data: DADOS,
|
|
66
|
+
selectable: true,
|
|
67
|
+
onSort: (k, d) => ordens.push([k, d]),
|
|
68
|
+
});
|
|
69
|
+
assert.ok(m.raiz.querySelector('[role="checkbox"], input[type="checkbox"]'));
|
|
70
|
+
m.raiz.querySelector("thead button").click();
|
|
71
|
+
assert.deepEqual(ordens, [["descricao", "asc"]]);
|
|
72
|
+
assert.ok(!m.raiz.querySelector(".umds-datatable--document"));
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test("DescriptionList: dl com um dt e um dd por par; vazio vira traço", async () => {
|
|
76
|
+
const m = await abrir("DescriptionList/DescriptionList.vue", {
|
|
77
|
+
ariaLabel: "Dados de empenho",
|
|
78
|
+
items: [
|
|
79
|
+
{ label: "Dotação", value: "02.031.0001" },
|
|
80
|
+
{ label: "Fonte", value: "" },
|
|
81
|
+
],
|
|
82
|
+
});
|
|
83
|
+
const dl = m.raiz.querySelector("dl");
|
|
84
|
+
assert.equal(dl.getAttribute("aria-label"), "Dados de empenho");
|
|
85
|
+
assert.equal(dl.querySelectorAll("dt").length, 2);
|
|
86
|
+
assert.equal(dl.querySelectorAll("dd")[0].textContent.trim(), "02.031.0001");
|
|
87
|
+
assert.equal(dl.querySelectorAll("dd")[1].textContent.trim(), "—");
|
|
88
|
+
assert.ok(dl.classList.contains("umds-description-list--inline"));
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test("DescriptionList stacked ganha colunas e a caixa do valor; style e data-* chegam ao dl", async () => {
|
|
92
|
+
const m = await abrir("DescriptionList/DescriptionList.vue", {
|
|
93
|
+
layout: "stacked",
|
|
94
|
+
columns: 3,
|
|
95
|
+
bordered: true,
|
|
96
|
+
items: [{ label: "Memorando", value: "058/2025" }],
|
|
97
|
+
"data-x": "1",
|
|
98
|
+
style: "margin-top: 4px",
|
|
99
|
+
});
|
|
100
|
+
const dl = m.raiz.querySelector("dl");
|
|
101
|
+
for (const c of ["umds-description-list--stacked", "umds-description-list--cols-3", "umds-description-list--bordered"]) {
|
|
102
|
+
assert.ok(dl.classList.contains(c), c);
|
|
103
|
+
}
|
|
104
|
+
assert.equal(dl.getAttribute("data-x"), "1");
|
|
105
|
+
assert.match(dl.getAttribute("style"), /margin-top:\s*4px/);
|
|
106
|
+
});
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DataTable no Vue: slot de célula por coluna (`#cell-<key>`), slot da linha
|
|
3
|
+
* de grupo (`#row-group`) e `rowGroup`, conferidos no HTML que o Vue GERADO
|
|
4
|
+
* escreve. O `render` devolve TEXTO no Vue; o markup vem do slot.
|
|
5
|
+
*/
|
|
6
|
+
import { test, before, after } from "node:test";
|
|
7
|
+
import assert from "node:assert/strict";
|
|
8
|
+
import { h } from "vue";
|
|
9
|
+
import { abrir, fechar, carregar, renderizar } from "./renderizar.mjs";
|
|
10
|
+
|
|
11
|
+
let DataTable;
|
|
12
|
+
|
|
13
|
+
before(async () => {
|
|
14
|
+
await abrir();
|
|
15
|
+
DataTable = await carregar("DataTable/DataTable.vue");
|
|
16
|
+
});
|
|
17
|
+
after(fechar);
|
|
18
|
+
|
|
19
|
+
const COLUNAS = [
|
|
20
|
+
{ key: "nome", label: "Usuário" },
|
|
21
|
+
{ key: "perfil", label: "Perfil" },
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
const USUARIOS = [
|
|
25
|
+
{ id: 1, nome: "Lucas Andrade", setor: "SADM", perfil: "Administrador" },
|
|
26
|
+
{ id: 2, nome: "Marina Souza", setor: "SADM", perfil: "Nível 1" },
|
|
27
|
+
{ id: 3, nome: "Rafael Pereira", setor: "SOBR", perfil: "Nível 2" },
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
test("sem slot, a célula mostra row[key]", async () => {
|
|
31
|
+
const html = await renderizar(DataTable, { columns: COLUNAS, data: USUARIOS });
|
|
32
|
+
assert.match(html, />\s*Lucas Andrade\s*</);
|
|
33
|
+
assert.doesNotMatch(html, /<strong/);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("#cell-<key> desenha markup na coluna certa e recebe row, value e rowIndex", async () => {
|
|
37
|
+
const html = await renderizar(
|
|
38
|
+
DataTable,
|
|
39
|
+
{ columns: COLUNAS, data: USUARIOS },
|
|
40
|
+
{
|
|
41
|
+
"cell-nome": ({ row, value, rowIndex }) =>
|
|
42
|
+
h("strong", { class: "nome", "data-i": rowIndex }, `${value} (#${row.id})`),
|
|
43
|
+
},
|
|
44
|
+
);
|
|
45
|
+
assert.equal((html.match(/<strong class="nome"/g) || []).length, 3);
|
|
46
|
+
assert.match(html, /<strong class="nome" data-i="0">Lucas Andrade \(#1\)<\/strong>/);
|
|
47
|
+
assert.match(html, /<strong class="nome" data-i="2">Rafael Pereira \(#3\)<\/strong>/);
|
|
48
|
+
// a outra coluna segue com o valor cru
|
|
49
|
+
assert.match(html, />\s*Administrador\s*</);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("o slot vale sobre o render da coluna", async () => {
|
|
53
|
+
const colunas = [{ key: "nome", label: "Usuário", render: (row) => `render:${row.nome}` }];
|
|
54
|
+
const html = await renderizar(
|
|
55
|
+
DataTable,
|
|
56
|
+
{ columns: colunas, data: USUARIOS },
|
|
57
|
+
{ "cell-nome": ({ value }) => h("em", value) },
|
|
58
|
+
);
|
|
59
|
+
assert.match(html, /<em>Lucas Andrade<\/em>/);
|
|
60
|
+
assert.doesNotMatch(html, /render:/);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test("sem slot, o render continua formatando texto", async () => {
|
|
64
|
+
const colunas = [{ key: "nome", label: "Usuário", render: (row, i) => `${i + 1}. ${row.nome}` }];
|
|
65
|
+
const html = await renderizar(DataTable, { columns: colunas, data: USUARIOS });
|
|
66
|
+
assert.match(html, /2\. Marina Souza/);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test("rowGroup por campo abre um grupo por valor consecutivo, atravessando as colunas", async () => {
|
|
70
|
+
const html = await renderizar(DataTable, { columns: COLUNAS, data: USUARIOS, rowGroup: "setor" });
|
|
71
|
+
const grupos = [...html.matchAll(/<th[^>]*scope="rowgroup"[^>]*>([\s\S]*?)<\/th>/g)];
|
|
72
|
+
assert.deepEqual(
|
|
73
|
+
grupos.map((g) => g[1].replace(/<!--.*?-->/g, "").trim()),
|
|
74
|
+
["SADM", "SOBR"],
|
|
75
|
+
);
|
|
76
|
+
assert.match(html, /<th[^>]*scope="rowgroup"[^>]*colspan="2"/i);
|
|
77
|
+
assert.match(html, /umds-datatable__row--group/);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test("rowGroup por função e colspan com selectable", async () => {
|
|
81
|
+
const html = await renderizar(DataTable, {
|
|
82
|
+
columns: COLUNAS,
|
|
83
|
+
data: USUARIOS,
|
|
84
|
+
selectable: true,
|
|
85
|
+
rowGroup: (row) => (row.id === 3 ? undefined : "Equipe A"),
|
|
86
|
+
});
|
|
87
|
+
assert.equal((html.match(/scope="rowgroup"/g) || []).length, 1);
|
|
88
|
+
assert.match(html, /colspan="3"/i);
|
|
89
|
+
assert.match(html, /Equipe A/);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test("#row-group desenha o conteúdo do grupo e recebe label, row e rowIndex", async () => {
|
|
93
|
+
const html = await renderizar(
|
|
94
|
+
DataTable,
|
|
95
|
+
{ columns: COLUNAS, data: USUARIOS, rowGroup: "setor" },
|
|
96
|
+
{ "row-group": ({ label, row, rowIndex }) => h("em", { class: "g" }, `${label}/${row.id}/${rowIndex}`) },
|
|
97
|
+
);
|
|
98
|
+
assert.match(html, /<em class="g">SADM\/1\/0<\/em>/);
|
|
99
|
+
assert.match(html, /<em class="g">SOBR\/3\/2<\/em>/);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test("sem rowGroup não há linha de grupo", async () => {
|
|
103
|
+
const html = await renderizar(DataTable, { columns: COLUNAS, data: USUARIOS });
|
|
104
|
+
assert.doesNotMatch(html, /rowgroup/);
|
|
105
|
+
});
|