sm-click-library-ui 0.0.450 → 0.0.452
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-DYdf7d6i.js → index-DROYAO9_.js} +2249 -2219
- package/dist/sm-click-library-ui.es.js +1 -1
- package/dist/sm-click-library-ui.umd.js +13 -13
- package/dist/style.css +1 -1
- package/dist/test-utils/setup.js +66 -65
- package/dist/{web-lZeLwlI5.js → web-Co2pOCJi.js} +2 -2
- package/dist/{web-0zMjtKAX.js → web-oovEdFqA.js} +2 -2
- package/package.json +2 -1
- package/src/test-utils/components/CRM+/manipulateProduct.test.js +85 -0
- package/src/test-utils/setup.js +66 -65
package/dist/test-utils/setup.js
CHANGED
|
@@ -1,65 +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
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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-DROYAO9_.js";
|
|
2
|
+
import { E } from "./web-oovEdFqA.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-DROYAO9_.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-Co2pOCJi.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.452",
|
|
9
9
|
"main": "dist/sm-click-library-ui.es.js",
|
|
10
10
|
"module": "dist/sm-click-library-ui.umd.js",
|
|
11
11
|
"private": false,
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"@storybook/vue3": "^8.2.3",
|
|
53
53
|
"@storybook/vue3-vite": "^8.2.3",
|
|
54
54
|
"@vitejs/plugin-vue": "^5.0.5",
|
|
55
|
+
"@vitest/ui": "3.2.4",
|
|
55
56
|
"autoprefixer": "^10.4.19",
|
|
56
57
|
"jsdom": "^26.0.0",
|
|
57
58
|
"postcss": "^8.4.39",
|
|
@@ -0,0 +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
|
+
});
|
package/src/test-utils/setup.js
CHANGED
|
@@ -1,65 +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
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
+
}));
|