Merge branch 'dev' into 7937-claimAgile

This commit is contained in:
Javi Gallego 2025-02-21 14:59:32 +01:00
commit a7b202527f
41 changed files with 422 additions and 98 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
node_modules

90
Jenkinsfile vendored
View File

@ -1,6 +1,7 @@
#!/usr/bin/env groovy #!/usr/bin/env groovy
def PROTECTED_BRANCH def PROTECTED_BRANCH
def IS_LATEST
def BRANCH_ENV = [ def BRANCH_ENV = [
test: 'test', test: 'test',
@ -10,16 +11,18 @@ def BRANCH_ENV = [
node { node {
stage('Setup') { stage('Setup') {
env.FRONT_REPLICAS = 1
env.NODE_ENV = BRANCH_ENV[env.BRANCH_NAME] ?: 'dev' env.NODE_ENV = BRANCH_ENV[env.BRANCH_NAME] ?: 'dev'
PROTECTED_BRANCH = [ PROTECTED_BRANCH = [
'dev', 'dev',
'test', 'test',
'master', 'master',
'main',
'beta' 'beta'
].contains(env.BRANCH_NAME) ].contains(env.BRANCH_NAME)
IS_LATEST = ['master', 'main'].contains(env.BRANCH_NAME)
// https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables // https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#using-environment-variables
echo "NODE_NAME: ${env.NODE_NAME}" echo "NODE_NAME: ${env.NODE_NAME}"
echo "WORKSPACE: ${env.WORKSPACE}" echo "WORKSPACE: ${env.WORKSPACE}"
@ -58,6 +61,19 @@ pipeline {
PROJECT_NAME = 'lilium' PROJECT_NAME = 'lilium'
} }
stages { stages {
stage('Version') {
when {
expression { PROTECTED_BRANCH }
}
steps {
script {
def packageJson = readJSON file: 'package.json'
def version = "${packageJson.version}-build${env.BUILD_ID}"
writeFile(file: 'VERSION.txt', text: version)
echo "VERSION: ${version}"
}
}
}
stage('Install') { stage('Install') {
environment { environment {
NODE_ENV = "" NODE_ENV = ""
@ -71,17 +87,48 @@ pipeline {
expression { !PROTECTED_BRANCH } expression { !PROTECTED_BRANCH }
} }
environment { environment {
NODE_ENV = "" NODE_ENV = ''
CI = 'true'
TZ = 'Europe/Madrid'
} }
steps { parallel {
sh 'pnpm run test:unit:ci' stage('Unit') {
} steps {
post { sh 'pnpm run test:unit:ci'
always { }
junit( post {
testResults: 'junitresults.xml', always {
allowEmptyResults: true junit(
) testResults: 'junit/vitest.xml',
allowEmptyResults: true
)
}
}
}
stage('E2E') {
environment {
CREDENTIALS = credentials('docker-registry')
COMPOSE_PROJECT = "${PROJECT_NAME}-${env.BUILD_ID}"
COMPOSE_PARAMS = "-p ${env.COMPOSE_PROJECT} -f test/cypress/docker-compose.yml --project-directory ."
}
steps {
script {
def image = docker.build('lilium-dev', '-f docs/Dockerfile.dev docs')
sh "docker-compose ${env.COMPOSE_PARAMS} up -d"
image.inside("--network ${env.COMPOSE_PROJECT}_default -e CI -e TZ") {
sh 'cypress run --browser chromium'
}
}
}
post {
always {
sh "docker-compose ${env.COMPOSE_PARAMS} down"
junit(
testResults: 'junit/e2e.xml',
allowEmptyResults: true
)
}
}
} }
} }
} }
@ -91,25 +138,30 @@ pipeline {
} }
environment { environment {
CREDENTIALS = credentials('docker-registry') CREDENTIALS = credentials('docker-registry')
VERSION = readFile 'VERSION.txt'
} }
steps { steps {
sh 'quasar build'
script { script {
def packageJson = readJSON file: 'package.json' sh 'quasar build'
env.VERSION = "${packageJson.version}-build${env.BUILD_ID}"
def baseImage = "salix-frontend:${env.VERSION}"
def image = docker.build(baseImage, ".")
docker.withRegistry("https://${env.REGISTRY}", 'docker-registry') {
image.push()
image.push(env.BRANCH_NAME)
if (IS_LATEST) image.push('latest')
}
} }
dockerBuild()
} }
} }
stage('Deploy') { stage('Deploy') {
when { when {
expression { PROTECTED_BRANCH } expression { PROTECTED_BRANCH }
} }
environment {
VERSION = readFile 'VERSION.txt'
}
steps { steps {
script {
def packageJson = readJSON file: 'package.json'
env.VERSION = "${packageJson.version}-build${env.BUILD_ID}"
}
withKubeConfig([ withKubeConfig([
serverUrl: "$KUBERNETES_API", serverUrl: "$KUBERNETES_API",
credentialsId: 'kubernetes', credentialsId: 'kubernetes',

View File

@ -3,10 +3,39 @@ import { defineConfig } from 'cypress';
// https://docs.cypress.io/app/references/configuration // https://docs.cypress.io/app/references/configuration
// https://www.npmjs.com/package/cypress-mochawesome-reporter // https://www.npmjs.com/package/cypress-mochawesome-reporter
let urlHost,
reporter,
reporterOptions;
if (process.env.CI) {
urlHost = 'front';
reporter = 'junit';
reporterOptions = {
mochaFile: 'junit/e2e.xml',
toConsole: false,
};
} else {
urlHost = 'localhost';
reporter = 'cypress-mochawesome-reporter';
reporterOptions = {
charts: true,
reportPageTitle: 'Cypress Inline Reporter',
reportFilename: '[status]_[datetime]-report',
embeddedScreenshots: true,
reportDir: 'test/cypress/reports',
inlineAssets: true,
};
}
export default defineConfig({ export default defineConfig({
e2e: { e2e: {
baseUrl: 'http://localhost:9000/', baseUrl: `http://${urlHost}:9000`,
experimentalStudio: true, experimentalStudio: false, // Desactivado para evitar tiempos de espera innecesarios
defaultCommandTimeout: 10000,
trashAssetsBeforeRuns: false,
requestTimeout: 10000,
responseTimeout: 30000,
pageLoadTimeout: 60000,
fixturesFolder: 'test/cypress/fixtures', fixturesFolder: 'test/cypress/fixtures',
screenshotsFolder: 'test/cypress/screenshots', screenshotsFolder: 'test/cypress/screenshots',
supportFile: 'test/cypress/support/index.js', supportFile: 'test/cypress/support/index.js',
@ -14,26 +43,18 @@ export default defineConfig({
downloadsFolder: 'test/cypress/downloads', downloadsFolder: 'test/cypress/downloads',
video: false, video: false,
specPattern: 'test/cypress/integration/**/*.spec.js', specPattern: 'test/cypress/integration/**/*.spec.js',
experimentalRunAllSpecs: false, experimentalRunAllSpecs: true,
watchForFileChanges: false, watchForFileChanges: true,
reporter: 'cypress-mochawesome-reporter', reporter,
reporterOptions: { reporterOptions,
charts: true,
reportPageTitle: 'Cypress Inline Reporter',
reportFilename: '[status]_[datetime]-report',
embeddedScreenshots: true,
reportDir: 'test/cypress/reports',
inlineAssets: true,
},
component: { component: {
componentFolder: 'src', componentFolder: 'src',
testFiles: '**/*.spec.js', testFiles: '**/*.spec.js',
supportFile: 'test/cypress/support/unit.js', supportFile: 'test/cypress/support/unit.js',
}, },/*
setupNodeEvents: async (on, config) => { setupNodeEvents: async (on, config) => {
const plugin = await import('cypress-mochawesome-reporter/plugin'); const plugin = await import('cypress-mochawesome-reporter/plugin');
plugin.default(on); plugin.default(on);
const fs = await import('fs'); const fs = await import('fs');
on('task', { on('task', {
deleteFile(filePath) { deleteFile(filePath) {
@ -46,8 +67,11 @@ export default defineConfig({
}); });
return config; return config;
}, },*/
viewportWidth: 1280, viewportWidth: 1280,
viewportHeight: 720, viewportHeight: 720,
}, },
experimentalMemoryManagement: true,
defaultCommandTimeout: 10000,
numTestsKeptInMemory: 2,
}); });

View File

@ -1,7 +0,0 @@
version: '3.7'
services:
main:
image: registry.verdnatura.es/salix-frontend:${VERSION:?}
build:
context: .
dockerfile: ./Dockerfile

45
docs/Dockerfile.dev Normal file
View File

@ -0,0 +1,45 @@
FROM debian:12.9-slim
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
curl \
gnupg2 \
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y --no-install-recommends nodejs \
&& npm install -g corepack@0.31.0 \
&& corepack enable pnpm \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update \
&& apt-get -y --no-install-recommends install \
apt-utils \
chromium \
libasound2 \
libgbm-dev \
libgtk-3-0 \
libgtk2.0-0 \
libnotify-dev \
libnss3 \
libxss1 \
libxtst6 \
xauth \
xvfb \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN groupadd -r -g 1000 app \
&& useradd -r -u 1000 -g app -m -d /home/app app
USER app
ENV SHELL=bash
ENV PNPM_HOME="/home/app/.local/share/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN pnpm setup \
&& pnpm install --global cypress@13.6.6 \
&& cypress install
WORKDIR /app

View File

@ -1,6 +1,6 @@
export default [ export default [
{ {
path: '/api', path: '/api',
rule: { target: 'http://0.0.0.0:3000' }, rule: { target: 'http://127.0.0.1:3000' },
}, },
]; ];

View File

@ -11,6 +11,7 @@
import { configure } from 'quasar/wrappers'; import { configure } from 'quasar/wrappers';
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'; import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
import path from 'path'; import path from 'path';
const target = `http://${process.env.CI ? 'back' : 'localhost'}:3000`;
export default configure(function (/* ctx */) { export default configure(function (/* ctx */) {
return { return {
@ -108,13 +109,17 @@ export default configure(function (/* ctx */) {
}, },
proxy: { proxy: {
'/api': { '/api': {
target: 'http://0.0.0.0:3000', target: target,
logLevel: 'debug', logLevel: 'debug',
changeOrigin: true, changeOrigin: true,
secure: false, secure: false,
}, },
}, },
open: false, open: false,
allowedHosts: [
'front', // Agrega este nombre de host
'localhost', // Opcional, para pruebas locales
],
}, },
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#framework // https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#framework

View File

@ -12,6 +12,7 @@ import SkeletonForm from 'components/ui/SkeletonForm.vue';
import VnConfirm from './ui/VnConfirm.vue'; import VnConfirm from './ui/VnConfirm.vue';
import { tMobile } from 'src/composables/tMobile'; import { tMobile } from 'src/composables/tMobile';
import { useArrayData } from 'src/composables/useArrayData'; import { useArrayData } from 'src/composables/useArrayData';
import { getDifferences, getUpdatedValues } from 'src/filters';
const { push } = useRouter(); const { push } = useRouter();
const quasar = useQuasar(); const quasar = useQuasar();
@ -284,7 +285,12 @@ function trimData(data) {
} }
return data; return data;
} }
function onBeforeSave(formData, originalData) {
return getUpdatedValues(
Object.keys(getDifferences(formData, originalData)),
formData,
);
}
async function onKeyup(evt) { async function onKeyup(evt) {
if (evt.key === 'Enter' && !('prevent-submit' in attrs)) { if (evt.key === 'Enter' && !('prevent-submit' in attrs)) {
const input = evt.target; const input = evt.target;
@ -321,6 +327,7 @@ defineExpose({
class="q-pa-md" class="q-pa-md"
:style="maxWidth ? 'max-width: ' + maxWidth : ''" :style="maxWidth ? 'max-width: ' + maxWidth : ''"
id="formModel" id="formModel"
:mapper="onBeforeSave"
> >
<QCard> <QCard>
<slot <slot

View File

@ -85,7 +85,15 @@ const refresh = () => window.location.reload();
</QTooltip> </QTooltip>
<PinnedModules ref="pinnedModulesRef" /> <PinnedModules ref="pinnedModulesRef" />
</QBtn> </QBtn>
<QBtn class="q-pa-none" rounded dense flat no-wrap id="user"> <QBtn
class="q-pa-none"
rounded
dense
flat
no-wrap
id="user"
data-cy="userPanel_btn"
>
<VnAvatar <VnAvatar
:worker-id="user.id" :worker-id="user.id"
:title="user.name" :title="user.name"

View File

@ -21,7 +21,6 @@ import VnSection from 'src/components/common/VnSection.vue';
const { t } = useI18n(); const { t } = useI18n();
const { viewSummary } = useSummaryDialog(); const { viewSummary } = useSummaryDialog();
const tableRef = ref(); const tableRef = ref();
const invoiceOutSerialsOptions = ref([]);
const customerOptions = ref([]); const customerOptions = ref([]);
const selectedRows = ref([]); const selectedRows = ref([]);
const hasSelectedCards = computed(() => selectedRows.value.length > 0); const hasSelectedCards = computed(() => selectedRows.value.length > 0);
@ -368,7 +367,6 @@ watchEffect(selectedRows);
url="InvoiceOutSerials" url="InvoiceOutSerials"
v-model="data.serial" v-model="data.serial"
:label="t('invoiceOutModule.serial')" :label="t('invoiceOutModule.serial')"
:options="invoiceOutSerialsOptions"
option-label="description" option-label="description"
option-value="code" option-value="code"
option-filter option-filter

View File

@ -1,3 +1,7 @@
reports/* reports/*
videos/*
screenshots/* screenshots/*
downloads/* downloads/*
storage/*
reports/*
docker/logs/*

View File

@ -0,0 +1,149 @@
{
"db": {
"connector": "memory",
"timezone": "local"
},
"vn": {
"connector": "vn-mysql",
"database": "vn",
"debug": false,
"host": "db",
"port": "3306",
"username": "root",
"password": "root",
"connectionLimit": 100,
"queueLimit": 100,
"multipleStatements": true,
"legacyUtcDateProcessing": false,
"timezone": "local",
"connectTimeout": 40000,
"acquireTimeout": 90000,
"waitForConnections": true,
"maxIdleTime": 60000,
"idleTimeout": 60000
},
"osticket": {
"connector": "memory",
"timezone": "local"
},
"tempStorage": {
"name": "tempStorage",
"connector": "loopback-component-storage",
"provider": "filesystem",
"root": "./storage/tmp",
"maxFileSize": "262144000",
"allowedContentTypes": [
"application/x-7z-compressed",
"application/x-zip-compressed",
"application/x-rar-compressed",
"application/octet-stream",
"application/pdf",
"application/zip",
"application/rar",
"multipart/x-zip",
"image/png",
"image/jpeg",
"image/jpg",
"image/webp",
"video/mp4"
]
},
"dmsStorage": {
"name": "dmsStorage",
"connector": "loopback-component-storage",
"provider": "filesystem",
"root": "./storage/dms",
"maxFileSize": "262144000",
"allowedContentTypes": [
"application/x-7z-compressed",
"application/x-zip-compressed",
"application/x-rar-compressed",
"application/octet-stream",
"application/pdf",
"application/zip",
"application/rar",
"multipart/x-zip",
"image/png",
"image/jpeg",
"image/jpg",
"image/webp"
]
},
"imageStorage": {
"name": "imageStorage",
"connector": "loopback-component-storage",
"provider": "filesystem",
"root": "./storage/image",
"maxFileSize": "52428800",
"allowedContentTypes": [
"image/png",
"image/jpeg",
"image/jpg",
"image/webp"
]
},
"invoiceStorage": {
"name": "invoiceStorage",
"connector": "loopback-component-storage",
"provider": "filesystem",
"root": "./storage/pdfs/invoice",
"maxFileSize": "52428800",
"allowedContentTypes": [
"application/octet-stream",
"application/pdf"
]
},
"claimStorage": {
"name": "claimStorage",
"connector": "loopback-component-storage",
"provider": "filesystem",
"root": "./storage/dms",
"maxFileSize": "31457280",
"allowedContentTypes": [
"image/png",
"image/jpeg",
"image/jpg",
"image/webp",
"video/mp4"
]
},
"entryStorage": {
"name": "entryStorage",
"connector": "loopback-component-storage",
"provider": "filesystem",
"root": "./storage/dms",
"maxFileSize": "31457280",
"allowedContentTypes": [
"image/png",
"image/jpeg",
"image/jpg",
"image/webp",
"video/mp4"
]
},
"supplierStorage": {
"name": "supplierStorage",
"connector": "loopback-component-storage",
"provider": "filesystem",
"root": "./storage/dms",
"maxFileSize": "31457280",
"allowedContentTypes": [
"image/png",
"image/jpeg",
"image/jpg",
"image/webp",
"video/mp4",
"application/pdf"
]
},
"accessStorage": {
"name": "accessStorage",
"connector": "loopback-component-storage",
"provider": "filesystem",
"root": "./storage/access",
"maxFileSize": "524288000",
"allowedContentTypes": [
"application/x-7z-compressed"
]
}
}

View File

@ -0,0 +1,21 @@
version: '3.7'
services:
back:
image: registry.verdnatura.es/salix-back:dev
volumes:
- ./test/cypress/storage:/salix/storage
- ./test/cypress/back/datasources.json:/salix/loopback/server/datasources.json
depends_on:
- db
dns_search: .
front:
image: lilium-dev:latest
command: pnpm exec quasar dev
volumes:
- .:/app
environment:
- CI
- TZ
dns_search: .
db:
image: registry.verdnatura.es/salix-db:dev

View File

View File

@ -41,7 +41,7 @@ describe('OrderCatalog', () => {
} }
}); });
cy.get( cy.get(
'[data-cy="vn-searchbar"] > .q-field > .q-field__inner > .q-field__control' '[data-cy="vn-searchbar"] > .q-field > .q-field__inner > .q-field__control',
).type('{enter}'); ).type('{enter}');
cy.get(':nth-child(1) > [data-cy="catalogFilterCategory"]').click(); cy.get(':nth-child(1) > [data-cy="catalogFilterCategory"]').click();
cy.dataCy('catalogFilterValueDialogBtn').last().click(); cy.dataCy('catalogFilterValueDialogBtn').last().click();

View File

@ -24,9 +24,9 @@ describe('ClaimAction', () => {
const rowData = [true]; const rowData = [true];
cy.fillRow(firstRow, rowData); cy.fillRow(firstRow, rowData);
cy.get('[title="Change destination"]').click(); cy.get('[title="Change destination"]').click({ force: true });
cy.selectOption(destinationRow, 'Confeccion'); cy.selectOption(destinationRow, 'Confeccion');
cy.get('.q-card > .q-card__actions > .q-btn--standard').click(); cy.get('.q-card > .q-card__actions > .q-btn--standard').click({ force: true });
}); });
it('should regularize', () => { it('should regularize', () => {

View File

@ -8,7 +8,11 @@ describe('ClaimNotes', () => {
it('should add a new note', () => { it('should add a new note', () => {
const message = 'This is a new message.'; const message = 'This is a new message.';
cy.get('.q-textarea').type(message); cy.get('.q-textarea')
.should('be.visible')
.should('not.be.disabled')
.type(message);
cy.get(saveBtn).click(); cy.get(saveBtn).click();
cy.get(firstNote).should('have.text', message); cy.get(firstNote).should('have.text', message);
}); });

View File

@ -23,14 +23,12 @@ describe.skip('ClaimPhoto', () => {
}); });
it('should open first image dialog change to second and close', () => { it('should open first image dialog change to second and close', () => {
cy.get( cy.get(':nth-last-child(1) > .q-card').click();
':nth-child(1) > .q-card > .q-img > .q-img__container > .q-img__image'
).click();
cy.get('.q-carousel__slide > .q-img > .q-img__container > .q-img__image').should( cy.get('.q-carousel__slide > .q-img > .q-img__container > .q-img__image').should(
'be.visible' 'be.visible'
); );
cy.get('.q-carousel__control > .q-btn > .q-btn__content > .q-icon').click(); cy.get('.q-carousel__control > button').click();
cy.get( cy.get(
'.q-dialog__inner > .q-toolbar > .q-btn > .q-btn__content > .q-icon' '.q-dialog__inner > .q-toolbar > .q-btn > .q-btn__content > .q-icon'
@ -42,7 +40,7 @@ describe.skip('ClaimPhoto', () => {
it('should remove third and fourth file', () => { it('should remove third and fourth file', () => {
cy.get( cy.get(
'.multimediaParent > :nth-child(3) > .q-btn > .q-btn__content > .q-icon' '.multimediaParent > :nth-last-child(1) > .q-btn > .q-btn__content > .q-icon'
).click(); ).click();
cy.get( cy.get(
'.q-card__actions > .q-btn--unelevated > .q-btn__content > .block' '.q-card__actions > .q-btn--unelevated > .q-btn__content > .block'
@ -50,7 +48,7 @@ describe.skip('ClaimPhoto', () => {
cy.get('.q-notification__message').should('have.text', 'Data deleted'); cy.get('.q-notification__message').should('have.text', 'Data deleted');
cy.get( cy.get(
'.multimediaParent > :nth-child(3) > .q-btn > .q-btn__content > .q-icon' '.multimediaParent > :nth-last-child(1) > .q-btn > .q-btn__content > .q-icon'
).click(); ).click();
cy.get( cy.get(
'.q-card__actions > .q-btn--unelevated > .q-btn__content > .block' '.q-card__actions > .q-btn--unelevated > .q-btn__content > .block'

View File

@ -8,7 +8,7 @@ describe('Client basic data', () => {
it('Should load layout', () => { it('Should load layout', () => {
cy.get('.q-card').should('be.visible'); cy.get('.q-card').should('be.visible');
cy.dataCy('customerPhone').find('input').should('be.visible'); cy.dataCy('customerPhone').find('input').should('be.visible');
cy.dataCy('customerPhone').find('input').type('123456789'); cy.dataCy('customerPhone').find('input').clear().type('123456789');
cy.get('.q-btn-group > .q-btn--standard').click(); cy.get('.q-btn-group > .q-btn--standard').click();
cy.intercept('PATCH', '/api/Clients/1102', (req) => { cy.intercept('PATCH', '/api/Clients/1102', (req) => {
const { body } = req; const { body } = req;

View File

@ -20,7 +20,7 @@ describe('Entry', () => {
); );
}); });
it('Create entry, modify travel and add buys', () => { it.skip('Create entry, modify travel and add buys', () => {
createEntryAndBuy(); createEntryAndBuy();
cy.get('a[data-cy="EntryBasicData-menu-item"]').click(); cy.get('a[data-cy="EntryBasicData-menu-item"]').click();
selectTravel('two'); selectTravel('two');

View File

@ -9,7 +9,7 @@ describe('EntryStockBought', () => {
cy.get('[data-col-field="reserve"][data-row-index="0"]').click(); cy.get('[data-col-field="reserve"][data-row-index="0"]').click();
cy.get('input[name="reserve"]').type('10{enter}'); cy.get('input[name="reserve"]').type('10{enter}');
cy.get('button[title="Save"]').click(); cy.get('button[title="Save"]').click();
cy.get('.q-notification__message').should('have.text', 'Data saved'); cy.checkNotification('Data saved');
}); });
it('Should add a new reserved space for buyerBoss', () => { it('Should add a new reserved space for buyerBoss', () => {
cy.addBtnClick(); cy.addBtnClick();

View File

@ -1,5 +1,5 @@
/// <reference types="cypress" /> /// <reference types="cypress" />
describe('InvoiceOut summary', () => { describe.skip('InvoiceOut summary', () => {
const transferInvoice = { const transferInvoice = {
Client: { val: 'employee', type: 'select' }, Client: { val: 'employee', type: 'select' },
Type: { val: 'Error in customer data', type: 'select' }, Type: { val: 'Error in customer data', type: 'select' },

View File

@ -4,25 +4,21 @@ describe('Item tag', () => {
cy.viewport(1920, 1080); cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');
cy.visit(`/#/item/1/tags`); cy.visit(`/#/item/1/tags`);
cy.get('.q-page').should('be.visible');
cy.waitForElement('[data-cy="itemTags"]');
}); });
it('should throw an error adding an existent tag', () => { it('should throw an error adding an existent tag', () => {
cy.get('.q-page').should('be.visible');
cy.get('.q-page-sticky > div').click(); cy.get('.q-page-sticky > div').click();
cy.get('.q-page-sticky > div').click(); cy.selectOption(':nth-child(8) > .q-select', 'Tallos');
cy.dataCy('Tag_select').eq(7).type('Tallos');
cy.get('.q-menu .q-item').contains('Tallos').click();
cy.get(':nth-child(8) > [label="Value"]').type('1'); cy.get(':nth-child(8) > [label="Value"]').type('1');
cy.dataCy('crudModelDefaultSaveBtn').click(); cy.dataCy('crudModelDefaultSaveBtn').click();
cy.checkNotification("The tag or priority can't be repeated for an item"); cy.checkNotification("The tag or priority can't be repeated for an item");
}); });
it('should add a new tag', () => { it('should add a new tag', () => {
cy.get('.q-page').should('be.visible');
cy.get('.q-page-sticky > div').click(); cy.get('.q-page-sticky > div').click();
cy.get('.q-page-sticky > div').click(); cy.selectOption(':nth-child(8) > .q-select', 'Ancho de la base');
cy.dataCy('Tag_select').eq(7).click();
cy.get('.q-menu .q-item').contains('Ancho de la base').type('{enter}');
cy.get(':nth-child(8) > [label="Value"]').type('50'); cy.get(':nth-child(8) > [label="Value"]').type('50');
cy.dataCy('crudModelDefaultSaveBtn').click(); cy.dataCy('crudModelDefaultSaveBtn').click();
cy.checkNotification('Data saved'); cy.checkNotification('Data saved');

View File

@ -24,7 +24,7 @@ describe('Recover Password', () => {
it('should change password to user', () => { it('should change password to user', () => {
// Get token from mail // Get token from mail
cy.request( cy.request(
`http://localhost:3000/api/Mails?filter=%7B%22where%22%3A%20%7B%22receiver%22%3A%20%22${username}%40mydomain.com%22%7D%2C%20%22order%22%3A%20%5B%22id%20DESC%22%5D%7D&access_token=DEFAULT_TOKEN` `/api/Mails?filter=%7B%22where%22%3A%20%7B%22receiver%22%3A%20%22${username}%40mydomain.com%22%7D%2C%20%22order%22%3A%20%5B%22id%20DESC%22%5D%7D&access_token=DEFAULT_TOKEN`
).then((response) => { ).then((response) => {
const regex = /access_token=([a-zA-Z0-9]+)/; const regex = /access_token=([a-zA-Z0-9]+)/;
const [match] = response.body[0].body.match(regex); const [match] = response.body[0].body.match(regex);

View File

@ -11,7 +11,7 @@ describe('Two Factor', () => {
it('should enable two factor to sysadmin', () => { it('should enable two factor to sysadmin', () => {
cy.request( cy.request(
'PATCH', 'PATCH',
`http://localhost:3000/api/VnUsers/${userId}/update-user?access_token=DEFAULT_TOKEN`, `/api/VnUsers/${userId}/update-user?access_token=DEFAULT_TOKEN`,
{ twoFactor: 'email' } { twoFactor: 'email' }
); );
}); });
@ -41,7 +41,7 @@ describe('Two Factor', () => {
// Get code from mail // Get code from mail
cy.request( cy.request(
`http://localhost:3000/api/Mails?filter=%7B%22where%22%3A%20%7B%22receiver%22%3A%20%22${username}%40mydomain.com%22%7D%2C%20%22order%22%3A%20%5B%22id%20DESC%22%5D%7D&access_token=DEFAULT_TOKEN` `/api/Mails?filter=%7B%22where%22%3A%20%7B%22receiver%22%3A%20%22${username}%40mydomain.com%22%7D%2C%20%22order%22%3A%20%5B%22id%20DESC%22%5D%7D&access_token=DEFAULT_TOKEN`
).then((response) => { ).then((response) => {
const tempDiv = document.createElement('div'); const tempDiv = document.createElement('div');
tempDiv.innerHTML = response.body[0].body; tempDiv.innerHTML = response.body[0].body;

View File

@ -1,4 +1,4 @@
describe('AgencyWorkCenter', () => { describe.skip('AgencyWorkCenter', () => {
beforeEach(() => { beforeEach(() => {
cy.viewport(1920, 1080); cy.viewport(1920, 1080);
cy.login('developer'); cy.login('developer');

View File

@ -1,4 +1,4 @@
describe('Route extended list', () => { describe.skip('Route extended list', () => {
const getSelector = (colField) => `tr:last-child > [data-col-field="${colField}"]`; const getSelector = (colField) => `tr:last-child > [data-col-field="${colField}"]`;
const selectors = { const selectors = {

View File

@ -7,7 +7,7 @@ describe('Route', () => {
it('Route list create route', () => { it('Route list create route', () => {
cy.addBtnClick(); cy.addBtnClick();
cy.get('input[name="description"]').type('routeTestOne{enter}'); cy.get('.q-card input[name="description"]').type('routeTestOne{enter}');
cy.get('.q-notification__message').should('have.text', 'Data created'); cy.get('.q-notification__message').should('have.text', 'Data created');
cy.url().should('include', '/summary'); cy.url().should('include', '/summary');
}); });

View File

@ -1,7 +1,7 @@
/// <reference types="cypress" /> /// <reference types="cypress" />
describe('TicketSale', () => { describe('TicketSale', () => {
describe('Free ticket #31', () => { describe.skip('Free ticket #31', () => {
beforeEach(() => { beforeEach(() => {
cy.login('developer'); cy.login('developer');
cy.viewport(1920, 1080); cy.viewport(1920, 1080);
@ -121,7 +121,7 @@ describe('TicketSale', () => {
cy.url().should('match', /\/ticket\/31\/log/); cy.url().should('match', /\/ticket\/31\/log/);
}); });
}); });
describe('Ticket prepared #23', () => { describe.skip('Ticket prepared #23', () => {
beforeEach(() => { beforeEach(() => {
cy.login('developer'); cy.login('developer');
cy.viewport(1920, 1080); cy.viewport(1920, 1080);

View File

@ -40,7 +40,7 @@ describe('VnLocation', () => {
cy.selectOption(countrySelector, country); cy.selectOption(countrySelector, country);
cy.dataCy('locationProvince').type(`${province}{enter}`); cy.dataCy('locationProvince').type(`${province}{enter}`);
cy.get( cy.get(
`${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(3) ` `${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix} > :nth-child(3) `,
).click(); ).click();
cy.dataCy('locationProvince').should('have.value', province); cy.dataCy('locationProvince').should('have.value', province);
}); });
@ -87,7 +87,7 @@ describe('VnLocation', () => {
.get(':nth-child(1)') .get(':nth-child(1)')
.should('have.length.at.least', 2); .should('have.length.at.least', 2);
cy.get( cy.get(
firstOption.concat(' > .q-item__section > .q-item__label--caption') firstOption.concat(' > .q-item__section > .q-item__label--caption'),
).should('have.text', postCodeLabel); ).should('have.text', postCodeLabel);
cy.get(firstOption).click(); cy.get(firstOption).click();
cy.get('.q-btn-group > .q-btn--standard > .q-btn__content > .q-icon').click(); cy.get('.q-btn-group > .q-btn--standard > .q-btn__content > .q-icon').click();
@ -103,7 +103,7 @@ describe('VnLocation', () => {
cy.get('.q-card > h1').should('have.text', 'New postcode'); cy.get('.q-card > h1').should('have.text', 'New postcode');
cy.selectOption( cy.selectOption(
`${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix}`, `${createForm.prefix} > :nth-child(4) > .q-select > ${createForm.sufix}`,
province province,
); );
cy.get(dialogInputs).eq(0).clear(); cy.get(dialogInputs).eq(0).clear();
cy.get(dialogInputs).eq(0).type(postCode); cy.get(dialogInputs).eq(0).type(postCode);
@ -156,7 +156,7 @@ describe('VnLocation', () => {
cy.get(createLocationButton).click(); cy.get(createLocationButton).click();
cy.selectOption( cy.selectOption(
`${createForm.prefix} > :nth-child(5) > :nth-child(3) `, `${createForm.prefix} > :nth-child(5) > :nth-child(3) `,
'España' 'España',
); );
cy.dataCy('Province_icon').click(); cy.dataCy('Province_icon').click();

View File

@ -22,7 +22,7 @@ describe('WorkerNotificationsManager', () => {
); );
}); });
it('should active a notification that is yours', () => { it.skip('should active a notification that is yours', () => {
cy.login('developer'); cy.login('developer');
cy.visit(`/#/worker/${developerId}/notifications`); cy.visit(`/#/worker/${developerId}/notifications`);
cy.waitForElement(activeList); cy.waitForElement(activeList);

View File

@ -3,7 +3,7 @@ describe('ZoneWarehouse', () => {
Warehouse: { val: 'Warehouse One', type: 'select' }, Warehouse: { val: 'Warehouse One', type: 'select' },
}; };
const dataError = 'ER_DUP_ENTRY: Duplicate entry'; const dataError = 'The introduced warehouse already exists';
const saveBtn = '.q-btn--standard > .q-btn__content > .block'; const saveBtn = '.q-btn--standard > .q-btn__content > .block';
beforeEach(() => { beforeEach(() => {

View File

View File

View File

View File

View File

View File

View File

@ -27,7 +27,9 @@
// DO NOT REMOVE // DO NOT REMOVE
// Imports Quasar Cypress AE predefined commands // Imports Quasar Cypress AE predefined commands
// import { registerCommands } from '@quasar/quasar-app-extension-testing-e2e-cypress'; // import { registerCommands } from '@quasar/quasar-app-extension-testing-e2e-cypress';
Cypress.Commands.add('waitUntil', { prevSubject: 'optional' }, require('./waitUntil')); import waitUntil from './waitUntil';
Cypress.Commands.add('waitUntil', { prevSubject: 'optional' }, waitUntil);
Cypress.Commands.add('resetDB', () => { Cypress.Commands.add('resetDB', () => {
cy.exec('pnpm run resetDatabase'); cy.exec('pnpm run resetDatabase');
}); });
@ -57,7 +59,7 @@ Cypress.Commands.add('login', (user) => {
Cypress.Commands.add('domContentLoad', (element, timeout = 5000) => { Cypress.Commands.add('domContentLoad', (element, timeout = 5000) => {
cy.waitUntil(() => cy.document().then((doc) => doc.readyState === 'complete')); cy.waitUntil(() => cy.document().then((doc) => doc.readyState === 'complete'));
}); });
Cypress.Commands.add('waitForElement', (element, timeout = 5000) => { Cypress.Commands.add('waitForElement', (element, timeout = 10000) => {
cy.get(element, { timeout }).should('be.visible').and('not.be.disabled'); cy.get(element, { timeout }).should('be.visible').and('not.be.disabled');
}); });
@ -321,19 +323,14 @@ Cypress.Commands.add('clickButtonDescriptor', (id) => {
}); });
Cypress.Commands.add('openUserPanel', () => { Cypress.Commands.add('openUserPanel', () => {
cy.get( cy.dataCy('userPanel_btn').click();
'.column > .q-avatar > .q-avatar__content > .q-img > .q-img__container > .q-img__image',
).click();
}); });
Cypress.Commands.add('checkNotification', (text) => { Cypress.Commands.add('checkNotification', (text) => {
cy.get('.q-notification') cy.get('.q-notification', { timeout: 10000 })
.should('be.visible') .should('be.visible')
.last() .filter((_, el) => Cypress.$(el).text().includes(text))
.then(($lastNotification) => { .should('have.length.greaterThan', 0);
if (!Cypress.$($lastNotification).text().includes(text))
throw new Error(`Notification not found: "${text}"`);
});
}); });
Cypress.Commands.add('openActions', (row) => { Cypress.Commands.add('openActions', (row) => {

View File

@ -27,7 +27,17 @@ function randomNumber(options = { length: 10 }) {
function randomizeValue(characterSet, options) { function randomizeValue(characterSet, options) {
return Array.from({ length: options.length }, () => return Array.from({ length: options.length }, () =>
characterSet.charAt(Math.floor(Math.random() * characterSet.length)) characterSet.charAt(Math.floor(Math.random() * characterSet.length)),
).join(''); ).join('');
} }
const style = document.createElement('style');
style.innerHTML = `
* {
transition: none !important;
animation: none !important;
}
`;
document.head.appendChild(style);
export { randomString, randomNumber, randomizeValue }; export { randomString, randomNumber, randomizeValue };

View File

@ -5,9 +5,21 @@ import jsconfigPaths from 'vite-jsconfig-paths';
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'; import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
import path from 'path'; import path from 'path';
let reporters,
outputFile;
if (process.env.CI) {
reporters = ['junit', 'default'];
outputFile = {junit: './junit/vitest.xml'};
} else {
reporters = 'default';
}
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
test: { test: {
reporters,
outputFile,
environment: 'happy-dom', environment: 'happy-dom',
setupFiles: 'test/vitest/setup-file.js', setupFiles: 'test/vitest/setup-file.js',
include: [ include: [