{{ item.code }}
+ {{ item.code }}
+ Cargando pedido...
+{{ code }}
+ {{ publicLink }}
+ + Ingresa el código de tu pedido o abre el link que recibiste para revisar su estado. +
+ y vuelve a consultar', async () => {
+ const api = { getPublicOrderSummary: vi.fn().mockResolvedValue(saleData) }
+ const { router, wrapper } = await mountPage(api, '/pedido/abc123')
+ await flushPromises()
+ api.getPublicOrderSummary.mockClear()
+
+ await wrapper.find('input').setValue('newcode')
+ await wrapper.find('form').trigger('submit')
+ await waitForRouteParam(router, 'code', 'newcode')
+
+ expect(router.currentRoute.value.params.code).toBe('newcode')
+ expect(api.getPublicOrderSummary).toHaveBeenCalledWith('newcode')
+ })
+})
diff --git a/tests/unit/services/django-api.spec.js b/tests/unit/services/django-api.spec.js
new file mode 100644
index 0000000..b916d12
--- /dev/null
+++ b/tests/unit/services/django-api.spec.js
@@ -0,0 +1,34 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest'
+
+import http from '@/services/http'
+import DjangoApi from '@/services/django-api'
+
+vi.mock('@/services/http', () => ({
+ default: {
+ get: vi.fn(),
+ post: vi.fn(),
+ patch: vi.fn(),
+ put: vi.fn(),
+ delete: vi.fn(),
+ },
+}))
+
+describe('DjangoApi.getPublicOrderSummary', () => {
+ beforeEach(() => {
+ vi.stubEnv('VITE_DJANGO_BASE_URL', 'http://backend.test')
+ http.get.mockReset()
+ http.get.mockResolvedValue({ data: { code: 'abc123', type: 'sale' } })
+ })
+
+ it('consulta el resumen público por código en la ruta resumen_publico', async () => {
+ const api = new DjangoApi()
+
+ const result = await api.getPublicOrderSummary('abc123')
+
+ expect(http.get).toHaveBeenCalledTimes(1)
+ expect(http.get).toHaveBeenCalledWith(
+ 'http://backend.test/don_confiao/api/resumen_publico/abc123'
+ )
+ expect(result).toEqual({ code: 'abc123', type: 'sale' })
+ })
+})
diff --git a/vitest.config.mjs b/vitest.config.mjs
new file mode 100644
index 0000000..1a2d6ee
--- /dev/null
+++ b/vitest.config.mjs
@@ -0,0 +1,34 @@
+import { fileURLToPath } from 'node:url'
+import { defineConfig } from 'vitest/config'
+import Vue from '@vitejs/plugin-vue'
+import Vuetify, { transformAssetUrls } from 'vite-plugin-vuetify'
+
+export default defineConfig({
+ plugins: [
+ Vue({
+ template: { transformAssetUrls },
+ }),
+ Vuetify({
+ autoImport: true,
+ styles: {
+ configFile: 'src/styles/settings.scss',
+ },
+ }),
+ ],
+ resolve: {
+ alias: {
+ '@': fileURLToPath(new URL('./src', import.meta.url)),
+ },
+ },
+ test: {
+ environment: 'jsdom',
+ globals: false,
+ setupFiles: ['./tests/setup.js'],
+ include: ['tests/**/*.spec.js'],
+ server: {
+ deps: {
+ inline: ['vuetify'],
+ },
+ },
+ },
+})