diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..58835b53a --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "msedge", + "request": "launch", + "name": "Launch Chrome against localhost", + "url": "http://localhost:5000", + "webRoot": "${workspaceFolder}" + } + ] +} diff --git a/cypress.config.js b/cypress.config.js index 1221dcc63..c8c62c8fa 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -22,6 +22,8 @@ module.exports = defineConfig({ }, component: { + indexHtmlFile: 'test/cypress/support/component-index.html', + supportFile: 'test/cypress/support/component.js', specPattern: 'test/cypress/components/**/*.spec.js', devServer: { framework: 'vue', diff --git a/cypress/support/commands.js b/cypress/support/commands.js deleted file mode 100644 index d5040ee1b..000000000 --- a/cypress/support/commands.js +++ /dev/null @@ -1,57 +0,0 @@ -import { mount } from 'cypress/vue'; -import { Quasar } from 'quasar'; -import { i18n } from 'src/boot/i18n'; -// *********************************************** -// This example commands.js shows you how to -// create various custom commands and overwrite -// existing commands. -// -// For more comprehensive examples of custom -// commands please read more here: -// https://on.cypress.io/custom-commands -// *********************************************** -// -// -// -- This is a parent command -- -// Cypress.Commands.add('login', (email, password) => { ... }) -// -// -// -- This is a child command -- -// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) -// -// -// -- This is a dual command -- -// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) -// -// -// -- This will overwrite an existing command -- -// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) -import { createTestingPinia } from '@pinia/testing'; -import { shallowMount } from '@vue/test-utils'; -const pinia = createTestingPinia({ createSpy: () => {}, stubActions: false }); - -Cypress.Commands.add('vnMount', (component, options = {}) => { - const globalConfig = { - global: { - stubs: ['router-view', 'vue-i18n'], - plugins: [Quasar, i18n, pinia], - mocks: { t: (key) => key }, - }, - }; - // options.global = options.global || {}; - // options.global.stubs = options.global.stubs || {}; - // options.global.stubs.transition = false; - // options.global.components = options.global.components || {}; - // options.global.plugins = options.global.plugins || []; - - // Use store passed in from options, or initialize a new one - // const { /* store = getStore(), */ ...mountOptions } = options; - - // Add plugins here - // options.global.plugins.push({ - // install(app) { - // app.use(i18n); - // }, - // }); - return shallowMount(component, { ...globalConfig, ...options }); -}); diff --git a/cypress/support/component-index.html b/cypress/support/component-index.html deleted file mode 100644 index ac6e79fd8..000000000 --- a/cypress/support/component-index.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - Components App - - -
- - \ No newline at end of file diff --git a/cypress/support/component.js b/cypress/support/component.js deleted file mode 100644 index b091808fa..000000000 --- a/cypress/support/component.js +++ /dev/null @@ -1,27 +0,0 @@ -// *********************************************************** -// This example support/component.js is processed and -// loaded automatically before your test files. -// -// This is a great place to put global configuration and -// behavior that modifies Cypress. -// -// You can change the location of this file or turn off -// automatically serving support files with the -// 'supportFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/configuration -// *********************************************************** - -// Import commands.js using ES2015 syntax: -import './commands' - -// Alternatively you can use CommonJS syntax: -// require('./commands') - -import { mount } from 'cypress/vue' - -Cypress.Commands.add('mount', mount) - -// Example use: -// cy.mount(MyComponent) \ No newline at end of file diff --git a/generate-tests.js b/generate-tests.js index 17218a3da..046081f6d 100644 --- a/generate-tests.js +++ b/generate-tests.js @@ -3,12 +3,12 @@ const path = require('path'); // Ruta de la carpeta de componentes // Ruta de la carpeta de pruebas -['common', 'ui'].forEach((folder) => { - generateTest(folder); -}); +// ['common', 'ui'].forEach((folder) => { +generateTest('folder'); +// }); function generateTest(type) { - const componentsDir = path.join(__dirname, `src/components/${type}`); - const testDir = path.join(__dirname, `test/cypress/components/${type}`); + const componentsDir = path.join(__dirname, `src/components`); + const testDir = path.join(__dirname, `test/cypress/components`); // Leer todos los archivos en la carpeta de componentes fs.readdir(componentsDir, (err, files) => { if (err) return console.error('Error leyendo la carpeta de componentes:', err); @@ -23,7 +23,7 @@ function generateTest(type) { // Contenido del archivo de prueba const testFileContent = ` -import ${componentName} from 'src/components/${type}/${file}'; +import ${componentName} from 'src/components/${file}'; describe('<${componentName} />', () => { it('TODO: boilerplate', () => { diff --git a/src/components/NavBar.vue b/src/components/NavBar.vue index ace1e7311..085c2a8d0 100644 --- a/src/components/NavBar.vue +++ b/src/components/NavBar.vue @@ -2,7 +2,7 @@ import { onMounted, ref } from 'vue'; import { useI18n } from 'vue-i18n'; import { useState } from 'src/composables/useState'; -import { useStateStore } from 'stores/useStateStore'; +import { useStateStore } from 'src/stores/useStateStore'; import { useQuasar } from 'quasar'; import PinnedModules from './PinnedModules.vue'; import UserPanel from 'src/components/UserPanel.vue'; @@ -98,6 +98,8 @@ const pinnedModulesRef = ref();
\ No newline at end of file diff --git a/test/cypress/support/component-index.html b/test/cypress/support/component-index.html new file mode 100644 index 000000000..3d489995f --- /dev/null +++ b/test/cypress/support/component-index.html @@ -0,0 +1,12 @@ + + + + + + + Components App + + +
+ + diff --git a/test/cypress/support/component.js b/test/cypress/support/component.js index 0cd10edb8..32c008206 100644 --- a/test/cypress/support/component.js +++ b/test/cypress/support/component.js @@ -49,3 +49,31 @@ function createWrapper(component, options) { Cypress.Commands.add('createWrapper', createWrapper); // Cypress.Commands.add('mount', mount); +import { shallowMount } from '@vue/test-utils'; +import { Quasar } from 'quasar'; + +Cypress.Commands.add('vnMount', (component, options = {}) => { + const globalConfig = { + global: { + stubs: ['router-view', 'vue-i18n'], + plugins: [Quasar, i18n, pinia], + mocks: { t: (key) => key }, + }, + }; + // options.global = options.global || {}; + // options.global.stubs = options.global.stubs || {}; + // options.global.stubs.transition = false; + // options.global.components = options.global.components || {}; + // options.global.plugins = options.global.plugins || []; + + // Use store passed in from options, or initialize a new one + // const { /* store = getStore(), */ ...mountOptions } = options; + + // Add plugins here + // options.global.plugins.push({ + // install(app) { + // app.use(i18n); + // }, + // }); + return shallowMount(component, { ...globalConfig, ...options }); +});