feat: refs #6695 implement parallel Cypress testing and enhance timeout configurations
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Alex Moreno 2025-02-26 14:54:05 +01:00
parent cd410fa7cf
commit 010313ada9
5 changed files with 71 additions and 16 deletions

10
Jenkinsfile vendored
View File

@ -116,11 +116,11 @@ pipeline {
def image = docker.build('lilium-dev', '-f docs/Dockerfile.dev docs') def image = docker.build('lilium-dev', '-f docs/Dockerfile.dev docs')
sh "docker-compose ${env.COMPOSE_PARAMS} up -d" sh "docker-compose ${env.COMPOSE_PARAMS} up -d"
image.inside("--network ${env.COMPOSE_PROJECT}_default -e CI -e TZ") { image.inside("--network ${env.COMPOSE_PROJECT}_default -e CI -e TZ") {
sh 'cypress run --browser chromium || true' // sh 'cypress run --browser chromium || true'
// sh ''' sh '''
// find test/cypress/integration -name "*.spec.js" | xargs -n 1 -P 2 -I {} sh -c "xvfb-run -a cypress run --headless --browser chromium --spec '{}'" source test/cypress/cypressParallel.sh
// wait cypressParallel 2 || true
// ''' '''
} }
} }
} }

View File

@ -1,6 +1,6 @@
import { defineConfig } from 'cypress'; import { defineConfig } from 'cypress';
let urlHost, reporter, reporterOptions, defaultCommandTimeout; let urlHost, reporter, reporterOptions, timeouts;
if (process.env.CI) { if (process.env.CI) {
urlHost = 'front'; urlHost = 'front';
@ -17,7 +17,12 @@ if (process.env.CI) {
json: false, json: false,
}, },
}; };
defaultCommandTimeout = 30000; timeouts = {
defaultCommandTimeout: 30000,
requestTimeout: 30000,
responseTimeout: 60000,
pageLoadTimeout: 60000,
};
} else { } else {
urlHost = 'localhost'; urlHost = 'localhost';
reporter = 'cypress-mochawesome-reporter'; reporter = 'cypress-mochawesome-reporter';
@ -29,18 +34,19 @@ if (process.env.CI) {
reportDir: 'test/cypress/reports', reportDir: 'test/cypress/reports',
inlineAssets: true, inlineAssets: true,
}; };
defaultCommandTimeout = 10000; timeouts = {
defaultCommandTimeout: 10000,
requestTimeout: 10000,
responseTimeout: 30000,
pageLoadTimeout: 60000,
};
} }
export default defineConfig({ export default defineConfig({
e2e: { e2e: {
baseUrl: `http://${urlHost}:9000`, baseUrl: `http://${urlHost}:9000`,
experimentalStudio: false, experimentalStudio: false,
defaultCommandTimeout,
trashAssetsBeforeRuns: false, trashAssetsBeforeRuns: false,
requestTimeout: 10000,
responseTimeout: 30000,
pageLoadTimeout: 60000,
defaultBrowser: 'chromium', defaultBrowser: 'chromium',
fixturesFolder: 'test/cypress/fixtures', fixturesFolder: 'test/cypress/fixtures',
screenshotsFolder: 'test/cypress/screenshots', screenshotsFolder: 'test/cypress/screenshots',
@ -60,7 +66,12 @@ export default defineConfig({
}, },
viewportWidth: 1280, viewportWidth: 1280,
viewportHeight: 720, viewportHeight: 720,
...timeouts,
// setupNodeEvents(on, config) {
// process.env.NODE_OPTIONS = '--loader ts-node/esm';
// return config;
// },
includeShadowDom: true,
waitForAnimations: true,
}, },
defaultCommandTimeout,
numTestsKeptInMemory: 0,
}); });

View File

@ -0,0 +1,10 @@
cypressParallel() {
TEST_PATHS=(
'test/cypress/integration/claim/claimAction.spec.js'
'test/cypress/integration/claim/claimDevelopment.spec.js'
)
# find 'test/cypress/integration' -name "*.spec.js"
printf "%s\n" "${TEST_PATHS[@]}" | xargs -P $1 -I {} sh -c 'xvfb-run -a cypress run --headless --browser chromium --spec {}'
# cypress run --headless --browser chromium --spec 'test/cypress/integration/shelving/parking/parkingBasicData.spec.js'
wait
}

View File

@ -6,13 +6,16 @@ describe('ParkingBasicData', () => {
beforeEach(() => { beforeEach(() => {
cy.login('developer'); cy.login('developer');
cy.visit(`/#/shelving/parking/1/basic-data`); cy.visit(`/#/shelving/parking/1/basic-data`);
cy.get('[data-cy="loading-spinner"]', { timeout: 10000 }).should(
'not.be.visible',
);
}); });
it('should give an error if the code aldready exists', () => { it('should give an error if the code aldready exists', () => {
cy.get(codeInput).eq(0).should('have.value', '700-01').clear(); cy.get(codeInput).eq(0).should('have.value', '700-01').clear();
cy.get(codeInput).eq(0).type('700-02'); cy.get(codeInput).eq(0).type('700-02');
cy.saveCard(); cy.saveCard();
cy.get('.q-notification__message').should('have.text', 'The code already exists'); cy.checkNotification('The code already exists');
}); });
it('should edit the code and sector', () => { it('should edit the code and sector', () => {
@ -24,7 +27,8 @@ describe('ParkingBasicData', () => {
cy.dataCy('Picking order_input').clear().type(80230); cy.dataCy('Picking order_input').clear().type(80230);
cy.saveCard(); cy.saveCard();
cy.get('.q-notification__message').should('have.text', 'Data saved'); cy.checkNotification('Data saved');
cy.get(sectorSelect).should('have.value', 'First sector'); cy.get(sectorSelect).should('have.value', 'First sector');
cy.get(codeInput).should('have.value', '700-01'); cy.get(codeInput).should('have.value', '700-01');
cy.dataCy('Picking order_input').should('have.value', 80230); cy.dataCy('Picking order_input').should('have.value', 80230);

30
test/cypress/run.sh Normal file
View File

@ -0,0 +1,30 @@
#!/bin/bash
CYPRESS_SPEC_FOLDER="test/cypress/integration"
cleanup() {
docker-compose -p e2e --project-directory . -f test/cypress/docker-compose.yml down || true
}
trap cleanup SIGINT
#CLEAN
rm -rf test/cypress/screenshots
rm -rf test/cypress/results
rm -rf junit
#RUN
CI=true TZ=Europe/Madrid docker-compose -p e2e --project-directory . -f test/cypress/docker-compose.yml up -d
sleep 20 # FIXME:
docker run -it --rm \
-v "$(pwd)":/app \
-e CI=true \
-e TZ=Europe/Madrid \
--network e2e_default \
lilium-dev \
bash -c '
source test/cypress/cypressParallel.sh
cypressParallel 4
'
cleanup
# cypress run --headless --browser chromium --spec \"test/cypress/integration\"