sm-click-library-ui 0.0.452 → 0.0.454
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/dist/{index-DROYAO9_.js → index-DzpZLR5L.js} +6121 -5966
- package/dist/sm-click-library-ui.es.js +9 -6
- package/dist/sm-click-library-ui.umd.js +15 -15
- package/dist/style.css +1 -1
- package/dist/tailwind.css +24 -3
- package/dist/test-utils/setup.js +66 -66
- package/dist/{web-Co2pOCJi.js → web-Bjna1Dgm.js} +2 -2
- package/dist/{web-oovEdFqA.js → web-Bn6o0tXI.js} +2 -2
- package/package.json +2 -1
- package/src/test-utils/components/CRM+/manipulateProduct.test.js +85 -85
- package/src/test-utils/setup.js +66 -66
package/dist/tailwind.css
CHANGED
|
@@ -967,6 +967,11 @@ video {
|
|
|
967
967
|
.list-none {
|
|
968
968
|
list-style-type: none;
|
|
969
969
|
}
|
|
970
|
+
.appearance-none {
|
|
971
|
+
-webkit-appearance: none;
|
|
972
|
+
-moz-appearance: none;
|
|
973
|
+
appearance: none;
|
|
974
|
+
}
|
|
970
975
|
.grid-cols-2 {
|
|
971
976
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
972
977
|
}
|
|
@@ -1090,9 +1095,6 @@ video {
|
|
|
1090
1095
|
.rounded-none {
|
|
1091
1096
|
border-radius: 0px;
|
|
1092
1097
|
}
|
|
1093
|
-
.rounded-sm {
|
|
1094
|
-
border-radius: 0.125rem;
|
|
1095
|
-
}
|
|
1096
1098
|
.rounded-xl {
|
|
1097
1099
|
border-radius: 0.75rem;
|
|
1098
1100
|
}
|
|
@@ -1217,6 +1219,10 @@ video {
|
|
|
1217
1219
|
.bg-emerald-500\/90 {
|
|
1218
1220
|
background-color: rgb(16 185 129 / 0.9);
|
|
1219
1221
|
}
|
|
1222
|
+
.bg-gray-400 {
|
|
1223
|
+
--tw-bg-opacity: 1;
|
|
1224
|
+
background-color: rgb(156 163 175 / var(--tw-bg-opacity, 1));
|
|
1225
|
+
}
|
|
1220
1226
|
.bg-gray-500 {
|
|
1221
1227
|
--tw-bg-opacity: 1;
|
|
1222
1228
|
background-color: rgb(107 114 128 / var(--tw-bg-opacity, 1));
|
|
@@ -1608,6 +1614,10 @@ video {
|
|
|
1608
1614
|
--tw-blur: blur(8px);
|
|
1609
1615
|
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
|
1610
1616
|
}
|
|
1617
|
+
.blur-sm {
|
|
1618
|
+
--tw-blur: blur(4px);
|
|
1619
|
+
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
|
1620
|
+
}
|
|
1611
1621
|
.drop-shadow-md {
|
|
1612
1622
|
--tw-drop-shadow: drop-shadow(0 4px 3px rgb(0 0 0 / 0.07)) drop-shadow(0 2px 2px rgb(0 0 0 / 0.06));
|
|
1613
1623
|
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
|
@@ -1764,6 +1774,17 @@ video {
|
|
|
1764
1774
|
background-color: rgb(17 27 33 / var(--tw-bg-opacity, 1));
|
|
1765
1775
|
}
|
|
1766
1776
|
|
|
1777
|
+
.checked\:scale-75:checked {
|
|
1778
|
+
--tw-scale-x: .75;
|
|
1779
|
+
--tw-scale-y: .75;
|
|
1780
|
+
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
.checked\:bg-teal-400:checked {
|
|
1784
|
+
--tw-bg-opacity: 1;
|
|
1785
|
+
background-color: rgb(45 212 191 / var(--tw-bg-opacity, 1));
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1767
1788
|
.group:hover .group-hover\:inline-block {
|
|
1768
1789
|
display: inline-block;
|
|
1769
1790
|
}
|
package/dist/test-utils/setup.js
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import { JSDOM } from "jsdom";
|
|
2
|
-
import { config } from "@vue/test-utils";
|
|
3
|
-
import { setActivePinia, createPinia } from "pinia";
|
|
4
|
-
|
|
5
|
-
// Cria um DOM simulado
|
|
6
|
-
const dom = new JSDOM(`<!DOCTYPE html><html><body></body></html>`, {
|
|
7
|
-
url: "http://localhost",
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
// Configura `window` e `document`
|
|
11
|
-
global.window = dom.window;
|
|
12
|
-
global.document = dom.window.document;
|
|
13
|
-
global.navigator = dom.window.navigator;
|
|
14
|
-
|
|
15
|
-
// Mock de métodos do DOM que podem ser necessários
|
|
16
|
-
global.window.HTMLElement = dom.window.HTMLElement;
|
|
17
|
-
global.window.requestAnimationFrame = (cb) => setTimeout(cb, 0);
|
|
18
|
-
global.window.cancelAnimationFrame = (id) => clearTimeout(id);
|
|
19
|
-
|
|
20
|
-
global.ResizeObserver = vi.fn().mockImplementation(() => ({
|
|
21
|
-
observe: vi.fn(),
|
|
22
|
-
unobserve: vi.fn(),
|
|
23
|
-
disconnect: vi.fn(),
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
global.window.matchMedia = vi.fn().mockImplementation(() => ({
|
|
27
|
-
matches: false,
|
|
28
|
-
addListener: vi.fn(),
|
|
29
|
-
removeListener: vi.fn(),
|
|
30
|
-
}));
|
|
31
|
-
|
|
32
|
-
// Configuração global do Vue Test Utils
|
|
33
|
-
config.global.stubs = {
|
|
34
|
-
Popper: true, // Evita erro de componente não encontrado
|
|
35
|
-
VueAwesomePaginate: true, // Stub para VueAwesomePaginate
|
|
36
|
-
SimpleModal: true, // Stub para SimpleModal
|
|
37
|
-
datepicker: true, // Stub para datepicker,
|
|
38
|
-
Svg: { template: "<svg></svg>" },
|
|
39
|
-
Popper: { template: "<div><slot /></div>" },
|
|
40
|
-
putVideo: { template: "<div></div>" },
|
|
41
|
-
VueAwesomePaginate: { template: "<div></div>" },
|
|
42
|
-
SimpleLoader: { template: "<div></div>" },
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
config.global.directives = {
|
|
46
|
-
lazy: () => {},
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// Ativando Pinia para os testes
|
|
50
|
-
setActivePinia(createPinia()); // Certifica que Pinia está disponível nos testes
|
|
51
|
-
|
|
52
|
-
// Mock de axios para evitar chamadas reais de API
|
|
53
|
-
import { vi } from "vitest";
|
|
54
|
-
|
|
55
|
-
vi.mock("@/router/axios", () => ({
|
|
56
|
-
default: {
|
|
57
|
-
get: vi.fn().mockResolvedValue({ data: [] }), // Return an empty array (or any default data)
|
|
58
|
-
post: vi.fn(),
|
|
59
|
-
delete: vi.fn(),
|
|
60
|
-
patch: vi.fn(),
|
|
61
|
-
},
|
|
62
|
-
}));
|
|
63
|
-
// Mock de notiwind para evitar notificações em testes
|
|
64
|
-
vi.mock("notiwind", () => ({
|
|
65
|
-
notify: vi.fn(),
|
|
66
|
-
}));
|
|
1
|
+
import { JSDOM } from "jsdom";
|
|
2
|
+
import { config } from "@vue/test-utils";
|
|
3
|
+
import { setActivePinia, createPinia } from "pinia";
|
|
4
|
+
|
|
5
|
+
// Cria um DOM simulado
|
|
6
|
+
const dom = new JSDOM(`<!DOCTYPE html><html><body></body></html>`, {
|
|
7
|
+
url: "http://localhost",
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
// Configura `window` e `document`
|
|
11
|
+
global.window = dom.window;
|
|
12
|
+
global.document = dom.window.document;
|
|
13
|
+
global.navigator = dom.window.navigator;
|
|
14
|
+
|
|
15
|
+
// Mock de métodos do DOM que podem ser necessários
|
|
16
|
+
global.window.HTMLElement = dom.window.HTMLElement;
|
|
17
|
+
global.window.requestAnimationFrame = (cb) => setTimeout(cb, 0);
|
|
18
|
+
global.window.cancelAnimationFrame = (id) => clearTimeout(id);
|
|
19
|
+
|
|
20
|
+
global.ResizeObserver = vi.fn().mockImplementation(() => ({
|
|
21
|
+
observe: vi.fn(),
|
|
22
|
+
unobserve: vi.fn(),
|
|
23
|
+
disconnect: vi.fn(),
|
|
24
|
+
}));
|
|
25
|
+
|
|
26
|
+
global.window.matchMedia = vi.fn().mockImplementation(() => ({
|
|
27
|
+
matches: false,
|
|
28
|
+
addListener: vi.fn(),
|
|
29
|
+
removeListener: vi.fn(),
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
// Configuração global do Vue Test Utils
|
|
33
|
+
config.global.stubs = {
|
|
34
|
+
Popper: true, // Evita erro de componente não encontrado
|
|
35
|
+
VueAwesomePaginate: true, // Stub para VueAwesomePaginate
|
|
36
|
+
SimpleModal: true, // Stub para SimpleModal
|
|
37
|
+
datepicker: true, // Stub para datepicker,
|
|
38
|
+
Svg: { template: "<svg></svg>" },
|
|
39
|
+
Popper: { template: "<div><slot /></div>" },
|
|
40
|
+
putVideo: { template: "<div></div>" },
|
|
41
|
+
VueAwesomePaginate: { template: "<div></div>" },
|
|
42
|
+
SimpleLoader: { template: "<div></div>" },
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
config.global.directives = {
|
|
46
|
+
lazy: () => {},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Ativando Pinia para os testes
|
|
50
|
+
setActivePinia(createPinia()); // Certifica que Pinia está disponível nos testes
|
|
51
|
+
|
|
52
|
+
// Mock de axios para evitar chamadas reais de API
|
|
53
|
+
import { vi } from "vitest";
|
|
54
|
+
|
|
55
|
+
vi.mock("@/router/axios", () => ({
|
|
56
|
+
default: {
|
|
57
|
+
get: vi.fn().mockResolvedValue({ data: [] }), // Return an empty array (or any default data)
|
|
58
|
+
post: vi.fn(),
|
|
59
|
+
delete: vi.fn(),
|
|
60
|
+
patch: vi.fn(),
|
|
61
|
+
},
|
|
62
|
+
}));
|
|
63
|
+
// Mock de notiwind para evitar notificações em testes
|
|
64
|
+
vi.mock("notiwind", () => ({
|
|
65
|
+
notify: vi.fn(),
|
|
66
|
+
}));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { W as P, b as x } from "./index-
|
|
2
|
-
import { E } from "./web-
|
|
1
|
+
import { W as P, b as x } from "./index-DzpZLR5L.js";
|
|
2
|
+
import { E } from "./web-Bn6o0tXI.js";
|
|
3
3
|
function m(w) {
|
|
4
4
|
const e = w.split("/").filter((t) => t !== "."), r = [];
|
|
5
5
|
return e.forEach((t) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as le, C as ge, W as me } from "./index-
|
|
1
|
+
import { r as le, C as ge, W as me } from "./index-DzpZLR5L.js";
|
|
2
2
|
const F = {
|
|
3
3
|
RECORDING: "RECORDING",
|
|
4
4
|
PAUSED: "PAUSED",
|
|
@@ -58,7 +58,7 @@ var te;
|
|
|
58
58
|
n.UTF8 = "utf8", n.ASCII = "ascii", n.UTF16 = "utf16";
|
|
59
59
|
})(te || (te = {}));
|
|
60
60
|
const k = le("Filesystem", {
|
|
61
|
-
web: () => import("./web-
|
|
61
|
+
web: () => import("./web-Bjna1Dgm.js").then((n) => new n.FilesystemWeb())
|
|
62
62
|
});
|
|
63
63
|
ye();
|
|
64
64
|
const Ee = le("BlobWriter");
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"dist",
|
|
6
6
|
"src/test-utils"
|
|
7
7
|
],
|
|
8
|
-
"version": "0.0.
|
|
8
|
+
"version": "0.0.454",
|
|
9
9
|
"main": "dist/sm-click-library-ui.es.js",
|
|
10
10
|
"module": "dist/sm-click-library-ui.umd.js",
|
|
11
11
|
"private": false,
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"vite-plugin-static-copy": "^2.2.0",
|
|
35
35
|
"vue": "^3.4.29",
|
|
36
36
|
"vue-debounce": "^5.0.1",
|
|
37
|
+
"vue-tel-input": "^9.5.0",
|
|
37
38
|
"vue3-avataaars": "^1.0.15",
|
|
38
39
|
"vue3-carousel": "^0.16.0",
|
|
39
40
|
"vue3-lottie": "^3.3.1",
|
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
import { mount } from "@vue/test-utils";
|
|
2
|
-
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
3
|
-
import listProducts from "../../../components/CRM+/clientsComponents/listProducts.vue";
|
|
4
|
-
|
|
5
|
-
describe("Listagem de produtos - incrementação e decrementação", () => {
|
|
6
|
-
let wrapper;
|
|
7
|
-
|
|
8
|
-
const sampleProducts = {
|
|
9
|
-
results: [
|
|
10
|
-
{ id: 1, name: "Produto A", price: 10, recurrence: "unique" },
|
|
11
|
-
{ id: 2, name: "Produto B", price: 5, recurrence: "monthly" },
|
|
12
|
-
],
|
|
13
|
-
next: null,
|
|
14
|
-
previous: null,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
wrapper = mount(listProducts, {
|
|
19
|
-
props: {
|
|
20
|
-
// começa sem selecionados
|
|
21
|
-
modelValue: [],
|
|
22
|
-
// injeta produtos locais para evitar chamada à API
|
|
23
|
-
allProducts: sampleProducts,
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("Incrementa a quantidade ao clicar em '+'", async () => {
|
|
29
|
-
const items = wrapper.findAll("li");
|
|
30
|
-
expect(items.length).toBeGreaterThan(0);
|
|
31
|
-
|
|
32
|
-
// Primeiro produto da lista
|
|
33
|
-
const firstItem = items[0];
|
|
34
|
-
const plusBtn = firstItem.findAll("button").at(1); // ordem: '-' , qty , '+'
|
|
35
|
-
const qtyDisplay = firstItem.find("p.w-5");
|
|
36
|
-
|
|
37
|
-
expect(qtyDisplay.text()).toBe("0");
|
|
38
|
-
|
|
39
|
-
await plusBtn.trigger("click");
|
|
40
|
-
await wrapper.vm.$nextTick();
|
|
41
|
-
|
|
42
|
-
// quantidade deve ser 1
|
|
43
|
-
expect(qtyDisplay.text()).toBe("1");
|
|
44
|
-
|
|
45
|
-
// evento emitido com modelo atualizado
|
|
46
|
-
const emits = wrapper.emitted("update:modelValue");
|
|
47
|
-
expect(emits).toBeTruthy();
|
|
48
|
-
const lastEmit = emits[emits.length - 1][0];
|
|
49
|
-
expect(Array.isArray(lastEmit)).toBe(true);
|
|
50
|
-
expect(lastEmit[0]).toMatchObject({
|
|
51
|
-
product: expect.objectContaining({ id: 1 }),
|
|
52
|
-
quantity: 1,
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it("Decrementa a quantidade ao clicar em '-' sem ir abaixo de 0", async () => {
|
|
57
|
-
const items = wrapper.findAll("li");
|
|
58
|
-
const firstItem = items[0];
|
|
59
|
-
const minusBtn = firstItem.findAll("button").at(0); // '-'
|
|
60
|
-
const plusBtn = firstItem.findAll("button").at(1); // '+'
|
|
61
|
-
// console.log("minusBtn:", minusBtn.html());
|
|
62
|
-
const qtyDisplay = firstItem.find("p.w-5");
|
|
63
|
-
|
|
64
|
-
// Sobe para 2
|
|
65
|
-
await plusBtn.trigger("click");
|
|
66
|
-
await plusBtn.trigger("click");
|
|
67
|
-
await wrapper.vm.$nextTick();
|
|
68
|
-
expect(qtyDisplay.text()).toBe("2");
|
|
69
|
-
|
|
70
|
-
// Desce para 1
|
|
71
|
-
await minusBtn.trigger("click");
|
|
72
|
-
await wrapper.vm.$nextTick();
|
|
73
|
-
expect(qtyDisplay.text()).toBe("1");
|
|
74
|
-
|
|
75
|
-
// Desce para 0
|
|
76
|
-
await minusBtn.trigger("click");
|
|
77
|
-
await wrapper.vm.$nextTick();
|
|
78
|
-
expect(qtyDisplay.text()).toBe("0");
|
|
79
|
-
|
|
80
|
-
// Tenta descer abaixo de 0 (deve continuar 0)
|
|
81
|
-
await minusBtn.trigger("click");
|
|
82
|
-
await wrapper.vm.$nextTick();
|
|
83
|
-
expect(qtyDisplay.text()).toBe("0");
|
|
84
|
-
});
|
|
85
|
-
});
|
|
1
|
+
import { mount } from "@vue/test-utils";
|
|
2
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
3
|
+
import listProducts from "../../../components/CRM+/clientsComponents/listProducts.vue";
|
|
4
|
+
|
|
5
|
+
describe("Listagem de produtos - incrementação e decrementação", () => {
|
|
6
|
+
let wrapper;
|
|
7
|
+
|
|
8
|
+
const sampleProducts = {
|
|
9
|
+
results: [
|
|
10
|
+
{ id: 1, name: "Produto A", price: 10, recurrence: "unique" },
|
|
11
|
+
{ id: 2, name: "Produto B", price: 5, recurrence: "monthly" },
|
|
12
|
+
],
|
|
13
|
+
next: null,
|
|
14
|
+
previous: null,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
wrapper = mount(listProducts, {
|
|
19
|
+
props: {
|
|
20
|
+
// começa sem selecionados
|
|
21
|
+
modelValue: [],
|
|
22
|
+
// injeta produtos locais para evitar chamada à API
|
|
23
|
+
allProducts: sampleProducts,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("Incrementa a quantidade ao clicar em '+'", async () => {
|
|
29
|
+
const items = wrapper.findAll("li");
|
|
30
|
+
expect(items.length).toBeGreaterThan(0);
|
|
31
|
+
|
|
32
|
+
// Primeiro produto da lista
|
|
33
|
+
const firstItem = items[0];
|
|
34
|
+
const plusBtn = firstItem.findAll("button").at(1); // ordem: '-' , qty , '+'
|
|
35
|
+
const qtyDisplay = firstItem.find("p.w-5");
|
|
36
|
+
|
|
37
|
+
expect(qtyDisplay.text()).toBe("0");
|
|
38
|
+
|
|
39
|
+
await plusBtn.trigger("click");
|
|
40
|
+
await wrapper.vm.$nextTick();
|
|
41
|
+
|
|
42
|
+
// quantidade deve ser 1
|
|
43
|
+
expect(qtyDisplay.text()).toBe("1");
|
|
44
|
+
|
|
45
|
+
// evento emitido com modelo atualizado
|
|
46
|
+
const emits = wrapper.emitted("update:modelValue");
|
|
47
|
+
expect(emits).toBeTruthy();
|
|
48
|
+
const lastEmit = emits[emits.length - 1][0];
|
|
49
|
+
expect(Array.isArray(lastEmit)).toBe(true);
|
|
50
|
+
expect(lastEmit[0]).toMatchObject({
|
|
51
|
+
product: expect.objectContaining({ id: 1 }),
|
|
52
|
+
quantity: 1,
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("Decrementa a quantidade ao clicar em '-' sem ir abaixo de 0", async () => {
|
|
57
|
+
const items = wrapper.findAll("li");
|
|
58
|
+
const firstItem = items[0];
|
|
59
|
+
const minusBtn = firstItem.findAll("button").at(0); // '-'
|
|
60
|
+
const plusBtn = firstItem.findAll("button").at(1); // '+'
|
|
61
|
+
// console.log("minusBtn:", minusBtn.html());
|
|
62
|
+
const qtyDisplay = firstItem.find("p.w-5");
|
|
63
|
+
|
|
64
|
+
// Sobe para 2
|
|
65
|
+
await plusBtn.trigger("click");
|
|
66
|
+
await plusBtn.trigger("click");
|
|
67
|
+
await wrapper.vm.$nextTick();
|
|
68
|
+
expect(qtyDisplay.text()).toBe("2");
|
|
69
|
+
|
|
70
|
+
// Desce para 1
|
|
71
|
+
await minusBtn.trigger("click");
|
|
72
|
+
await wrapper.vm.$nextTick();
|
|
73
|
+
expect(qtyDisplay.text()).toBe("1");
|
|
74
|
+
|
|
75
|
+
// Desce para 0
|
|
76
|
+
await minusBtn.trigger("click");
|
|
77
|
+
await wrapper.vm.$nextTick();
|
|
78
|
+
expect(qtyDisplay.text()).toBe("0");
|
|
79
|
+
|
|
80
|
+
// Tenta descer abaixo de 0 (deve continuar 0)
|
|
81
|
+
await minusBtn.trigger("click");
|
|
82
|
+
await wrapper.vm.$nextTick();
|
|
83
|
+
expect(qtyDisplay.text()).toBe("0");
|
|
84
|
+
});
|
|
85
|
+
});
|
package/src/test-utils/setup.js
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import { JSDOM } from "jsdom";
|
|
2
|
-
import { config } from "@vue/test-utils";
|
|
3
|
-
import { setActivePinia, createPinia } from "pinia";
|
|
4
|
-
|
|
5
|
-
// Cria um DOM simulado
|
|
6
|
-
const dom = new JSDOM(`<!DOCTYPE html><html><body></body></html>`, {
|
|
7
|
-
url: "http://localhost",
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
// Configura `window` e `document`
|
|
11
|
-
global.window = dom.window;
|
|
12
|
-
global.document = dom.window.document;
|
|
13
|
-
global.navigator = dom.window.navigator;
|
|
14
|
-
|
|
15
|
-
// Mock de métodos do DOM que podem ser necessários
|
|
16
|
-
global.window.HTMLElement = dom.window.HTMLElement;
|
|
17
|
-
global.window.requestAnimationFrame = (cb) => setTimeout(cb, 0);
|
|
18
|
-
global.window.cancelAnimationFrame = (id) => clearTimeout(id);
|
|
19
|
-
|
|
20
|
-
global.ResizeObserver = vi.fn().mockImplementation(() => ({
|
|
21
|
-
observe: vi.fn(),
|
|
22
|
-
unobserve: vi.fn(),
|
|
23
|
-
disconnect: vi.fn(),
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
global.window.matchMedia = vi.fn().mockImplementation(() => ({
|
|
27
|
-
matches: false,
|
|
28
|
-
addListener: vi.fn(),
|
|
29
|
-
removeListener: vi.fn(),
|
|
30
|
-
}));
|
|
31
|
-
|
|
32
|
-
// Configuração global do Vue Test Utils
|
|
33
|
-
config.global.stubs = {
|
|
34
|
-
Popper: true, // Evita erro de componente não encontrado
|
|
35
|
-
VueAwesomePaginate: true, // Stub para VueAwesomePaginate
|
|
36
|
-
SimpleModal: true, // Stub para SimpleModal
|
|
37
|
-
datepicker: true, // Stub para datepicker,
|
|
38
|
-
Svg: { template: "<svg></svg>" },
|
|
39
|
-
Popper: { template: "<div><slot /></div>" },
|
|
40
|
-
putVideo: { template: "<div></div>" },
|
|
41
|
-
VueAwesomePaginate: { template: "<div></div>" },
|
|
42
|
-
SimpleLoader: { template: "<div></div>" },
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
config.global.directives = {
|
|
46
|
-
lazy: () => {},
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// Ativando Pinia para os testes
|
|
50
|
-
setActivePinia(createPinia()); // Certifica que Pinia está disponível nos testes
|
|
51
|
-
|
|
52
|
-
// Mock de axios para evitar chamadas reais de API
|
|
53
|
-
import { vi } from "vitest";
|
|
54
|
-
|
|
55
|
-
vi.mock("@/router/axios", () => ({
|
|
56
|
-
default: {
|
|
57
|
-
get: vi.fn().mockResolvedValue({ data: [] }), // Return an empty array (or any default data)
|
|
58
|
-
post: vi.fn(),
|
|
59
|
-
delete: vi.fn(),
|
|
60
|
-
patch: vi.fn(),
|
|
61
|
-
},
|
|
62
|
-
}));
|
|
63
|
-
// Mock de notiwind para evitar notificações em testes
|
|
64
|
-
vi.mock("notiwind", () => ({
|
|
65
|
-
notify: vi.fn(),
|
|
66
|
-
}));
|
|
1
|
+
import { JSDOM } from "jsdom";
|
|
2
|
+
import { config } from "@vue/test-utils";
|
|
3
|
+
import { setActivePinia, createPinia } from "pinia";
|
|
4
|
+
|
|
5
|
+
// Cria um DOM simulado
|
|
6
|
+
const dom = new JSDOM(`<!DOCTYPE html><html><body></body></html>`, {
|
|
7
|
+
url: "http://localhost",
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
// Configura `window` e `document`
|
|
11
|
+
global.window = dom.window;
|
|
12
|
+
global.document = dom.window.document;
|
|
13
|
+
global.navigator = dom.window.navigator;
|
|
14
|
+
|
|
15
|
+
// Mock de métodos do DOM que podem ser necessários
|
|
16
|
+
global.window.HTMLElement = dom.window.HTMLElement;
|
|
17
|
+
global.window.requestAnimationFrame = (cb) => setTimeout(cb, 0);
|
|
18
|
+
global.window.cancelAnimationFrame = (id) => clearTimeout(id);
|
|
19
|
+
|
|
20
|
+
global.ResizeObserver = vi.fn().mockImplementation(() => ({
|
|
21
|
+
observe: vi.fn(),
|
|
22
|
+
unobserve: vi.fn(),
|
|
23
|
+
disconnect: vi.fn(),
|
|
24
|
+
}));
|
|
25
|
+
|
|
26
|
+
global.window.matchMedia = vi.fn().mockImplementation(() => ({
|
|
27
|
+
matches: false,
|
|
28
|
+
addListener: vi.fn(),
|
|
29
|
+
removeListener: vi.fn(),
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
// Configuração global do Vue Test Utils
|
|
33
|
+
config.global.stubs = {
|
|
34
|
+
Popper: true, // Evita erro de componente não encontrado
|
|
35
|
+
VueAwesomePaginate: true, // Stub para VueAwesomePaginate
|
|
36
|
+
SimpleModal: true, // Stub para SimpleModal
|
|
37
|
+
datepicker: true, // Stub para datepicker,
|
|
38
|
+
Svg: { template: "<svg></svg>" },
|
|
39
|
+
Popper: { template: "<div><slot /></div>" },
|
|
40
|
+
putVideo: { template: "<div></div>" },
|
|
41
|
+
VueAwesomePaginate: { template: "<div></div>" },
|
|
42
|
+
SimpleLoader: { template: "<div></div>" },
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
config.global.directives = {
|
|
46
|
+
lazy: () => {},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Ativando Pinia para os testes
|
|
50
|
+
setActivePinia(createPinia()); // Certifica que Pinia está disponível nos testes
|
|
51
|
+
|
|
52
|
+
// Mock de axios para evitar chamadas reais de API
|
|
53
|
+
import { vi } from "vitest";
|
|
54
|
+
|
|
55
|
+
vi.mock("@/router/axios", () => ({
|
|
56
|
+
default: {
|
|
57
|
+
get: vi.fn().mockResolvedValue({ data: [] }), // Return an empty array (or any default data)
|
|
58
|
+
post: vi.fn(),
|
|
59
|
+
delete: vi.fn(),
|
|
60
|
+
patch: vi.fn(),
|
|
61
|
+
},
|
|
62
|
+
}));
|
|
63
|
+
// Mock de notiwind para evitar notificações em testes
|
|
64
|
+
vi.mock("notiwind", () => ({
|
|
65
|
+
notify: vi.fn(),
|
|
66
|
+
}));
|