fix: refs #6695 update Cypress configuration and Docker setup for improved testing
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Alex Moreno 2025-02-20 14:06:37 +01:00
parent 50637e8415
commit b5342cc130
6 changed files with 47 additions and 59 deletions

79
Jenkinsfile vendored
View File

@ -64,58 +64,53 @@ pipeline {
}
steps {
sh 'pnpm install --prefer-offline'
sh 'pnpm exec cypress install'
}
}
// stage('Test: Unit') {
// when {
// expression { !PROTECTED_BRANCH }
// }
// environment {
// NODE_ENV = ""
// }
// steps {
// sh 'pnpm run test:unit:ci'
// }
// post {
// always {
// junit(
// testResults: 'junitresults.xml',
// allowEmptyResults: true
// )
// }
// }
// }
stage('Test: E2E') {
stage('Test') {
when {
expression { !PROTECTED_BRANCH }
}
environment {
NODE_ENV = ""
CREDENTIALS = credentials('docker-registry')
}
steps {
script {
def packageJson = readJSON file: 'package.json'
env.NETWORK = "${PROJECT_NAME}-${env.BRANCH_NAME}-${env.BUILD_ID}"
sh "docker-compose -p ${env.NETWORK} -f docker-compose.e2e.yml up -d"
def networkLowerCase = env.NETWORK.toLowerCase()
def image = docker.build('cypress-setup:latest', '-f ./test/cypress/Dockerfile .')
image.inside("""
--network ${networkLowerCase}_default
-e TZ=Europe/Madrid
-e DOCKER=true
-e CI=true
""".stripIndent()) {
sh 'pnpm exec cypress install'
sh 'pnpm exec cypress run --browser chromium'
parallel {
stage('Unit') {
steps {
sh 'pnpm run test:unit:ci'
}
post {
always {
junit(
testResults: 'junitresults.xml',
allowEmptyResults: true
)
}
}
}
}
post {
always {
sh "docker-compose -p ${env.NETWORK} -f docker-compose.e2e.yml down"
stage('E2E') {
environment {
CREDENTIALS = credentials('docker-registry')
CI = "true"
TZ = 'Europe/Madrid'
COMPOSE_PROJECT = "${PROJECT_NAME}-${env.BRANCH_NAME}-${env.BUILD_ID}".toLowerCase()
COMPOSE_PARAMS = "--project-name ${env.COMPOSE_PROJECT} --project-directory . --file test/cypress/docker-compose.yml"
}
steps {
script {
sh "docker-compose ${env.COMPOSE_PARAMS} up -d"
def image = docker.build('cypress-setup', '-f ./test/cypress/Dockerfile .')
image.inside("--network ${env.COMPOSE_PROJECT}_default -e TZ -e CI") {
sh 'cypress run --browser chromium --spec test/cypress/integration/claim/claimAction.spec.js'
}
}
}
post {
always {
sh "docker-compose ${env.COMPOSE_PARAMS} down"
}
}
}
}
}

View File

@ -2,7 +2,7 @@ import { defineConfig } from 'cypress';
// https://docs.cypress.io/app/tooling/reporters
// https://docs.cypress.io/app/references/configuration
// https://www.npmjs.com/package/cypress-mochawesome-reporter
const baseUrl = `http://${process.env.DOCKER ? 'front' : 'localhost'}:9000`;
const baseUrl = `http://${process.env.CI ? 'front' : 'localhost'}:9000`;
export default defineConfig({
e2e: {

View File

@ -11,7 +11,7 @@
import { configure } from 'quasar/wrappers';
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite';
import path from 'path';
const target = `http://${process.env.DOCKER ? 'back' : 'localhost'}:3000`;
const target = `http://${process.env.CI ? 'back' : 'localhost'}:3000`;
export default configure(function (/* ctx */) {
return {

View File

@ -1,12 +1,5 @@
FROM alexmorenovn/vndev:latest
WORKDIR /app
# Copiar los archivos de package.json y pnpm-lock.yaml para evitar reinstalar dependencias innecesariamente
COPY package.json pnpm-lock.yaml ./
# Instalar solo Cypress sin instalar todas las dependencias del proyecto
RUN pnpm install --frozen-lockfile && pnpm exec cypress install
# Definir el directorio de trabajo por defecto
RUN pnpm install --global cypress@13.6.6 && cypress install
WORKDIR /app

View File

@ -7,7 +7,7 @@
"connector": "vn-mysql",
"database": "vn",
"debug": false,
"host": "vn-database",
"host": "db",
"port": "3306",
"username": "root",
"password": "root",

View File

@ -6,7 +6,7 @@ services:
- ./test/cypress/storage:/salix/storage
- ./test/cypress/back/datasources.json:/salix/loopback/server/datasources.json
depends_on:
- vn-database
- db
front:
image: alexmorenovn/vndev:latest
command: quasar dev
@ -14,7 +14,7 @@ services:
- .:/app
working_dir: /app
environment:
- TZ=Europe/Madrid
- DOCKER=true
vn-database:
image: registry.verdnatura.es/salix-db:dev
- TZ
- CI
db:
image: registry.verdnatura.es/salix-db:25.10.0-build1343