Cypress subpath testing (#11589)

* Update config

* Update files for subpath baseurl

* update config

* skip npm ci

* add subpath config

* Update github-ation version

* Update package

* Update the config

* update commands

* Update config

* update workflow
This commit is contained in:
Ajith KV 2024-12-12 14:34:33 +05:30 committed by GitHub
parent 1042dcdace
commit 214dc1e0ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 119 additions and 49 deletions

View file

@ -75,7 +75,6 @@ jobs:
run: |
npm run --prefix server db:create
npm run --prefix server db:reset
npm run --prefix server db:seed
- name: sleep 5
run: sleep 5
@ -114,7 +113,7 @@ jobs:
dir: "./cypress-tests"
- name: Platform
uses: cypress-io/github-action@v5
uses: cypress-io/github-action@v6
with:
working-directory: ./cypress-tests
config: "baseUrl=http://localhost:8082"
@ -232,9 +231,6 @@ jobs:
sleep 5
done'
- name: Seeding
run: docker exec Tooljet-app npm run db:seed:prod
- name: Create Cypress environment file
id: create-json
uses: jsdaniell/create-json@1.1.2
@ -244,11 +240,11 @@ jobs:
dir: "./cypress-tests"
- name: Platform-subpath
uses: cypress-io/github-action@v5
uses: cypress-io/github-action@v6
with:
working-directory: ./cypress-tests
config: "baseUrl=http://localhost:3000/apps/"
config-file: cypress-workspace.config.js
config: "baseUrl=http://localhost:3000/apps"
config-file: cypress-platform-subpath.js
- name: Capture Screenshots
uses: actions/upload-artifact@v3

View file

@ -0,0 +1,94 @@
const { defineConfig } = require("cypress");
const { rmdir } = require("fs");
const fs = require("fs");
const XLSX = require("node-xlsx");
const pg = require("pg");
const path = require("path");
const pdf = require("pdf-parse");
module.exports = defineConfig({
execTimeout: 1800000,
defaultCommandTimeout: 30000,
requestTimeout: 10000,
pageLoadTimeout: 20000,
responseTimeout: 10000,
viewportWidth: 1440,
viewportHeight: 960,
chromeWebSecurity: false,
trashAssetsBeforeRuns: true,
e2e: {
setupNodeEvents (on, config) {
on("task", {
readPdf (pathToPdf) {
return new Promise((resolve) => {
const pdfPath = path.resolve(pathToPdf);
let dataBuffer = fs.readFileSync(pdfPath);
pdf(dataBuffer).then(function ({ text }) {
resolve(text);
});
});
},
});
on("task", {
readXlsx (filePath) {
return new Promise((resolve, reject) => {
try {
let dataBuffer = fs.readFileSync(filePath);
const jsonData = XLSX.parse(dataBuffer);
// jsonData= jsonData[0].data
resolve(jsonData[0]["data"].toString());
} catch (e) {
reject(e);
}
});
},
});
on("task", {
deleteFolder (folderName) {
return new Promise((resolve, reject) => {
rmdir(folderName, { maxRetries: 10, recursive: true }, (err) => {
if (err) {
console.error(err);
return reject(err);
}
resolve(null);
});
});
},
});
on("task", {
updateId ({ dbconfig, sql }) {
const client = new pg.Pool(dbconfig);
return client.query(sql);
},
});
return require("./cypress/plugins/index.js")(on, config);
},
downloadsFolder: "cypress/downloads",
experimentalRunAllSpecs: true,
experimentalModfyObstructiveThirdPartyCode: true,
experimentalRunAllSpecs: true,
baseUrl: "http://localhost:3000/apps",
specPattern: [
"cypress/e2e/happyPath/platform/ceTestcases/userFlow/firstUserOnboarding.cy.js",
"cypress/e2e/happyPath/platform/ceTestcases/!(userFlow)/**/*.cy.js",
"cypress/e2e/happyPath/platform/commonTestcases/**/*.cy.js",
],
numTestsKeptInMemory: 1,
redirectionLimit: 15,
experimentalRunAllSpecs: true,
experimentalMemoryManagement: true,
video: false,
videoUploadOnPasses: false,
retries: {
runMode: 2,
openMode: 0,
},
},
});

View file

@ -76,10 +76,9 @@ module.exports = defineConfig({
experimentalRunAllSpecs: true,
baseUrl: "http://localhost:8082",
specPattern: [
"cypress/e2e/happyPath/platform/ceTestcases/editor/appSlug.cy.js",
"cypress/e2e/happyPath/platform/ceTestcases/editor/privateAndPublicApp.cy.js",
"cypress/e2e/happyPath/platform/ceTestcases/userFlow/firstUserOnboarding.cy.js",
"cypress/e2e/happyPath/platform/ceTestcases/!(userFlow)/**/*.cy.js",
"cypress/e2e/happyPath/platform/commonTestcases/**/*.cy.js",
"cypress/e2e/happyPath/platform/ceTestcases/**/!(*appSlug|privateAndPublicApp).cy.js"
],
numTestsKeptInMemory: 1,
redirectionLimit: 15,

View file

@ -471,11 +471,12 @@ Cypress.Commands.add("appPrivacy", (appName, isPublic) => {
});
});
Cypress.Commands.overwrite('intercept', (originalFn, method, endpoint, mockData) => {
const isSubpath = Cypress.config('baseUrl')?.includes('/apps/tooljet');
const cleanEndpoint = endpoint.replace('/apps/tooljet', '');
const fullUrl = isSubpath ? `/apps/tooljet${cleanEndpoint}` : cleanEndpoint;
Cypress.Commands.overwrite('intercept', (originalFn, method, endpoint, ...rest) => {
const isSubpath = Cypress.config('baseUrl')?.includes('/apps');
const cleanEndpoint = endpoint.startsWith('/apps') ? endpoint.replace('/apps', '') : endpoint;
const fullUrl = isSubpath ? `/apps${cleanEndpoint}` : cleanEndpoint;
return originalFn(method, fullUrl, mockData);
return originalFn(method, fullUrl, ...rest);
});

View file

@ -2766,9 +2766,9 @@
}
},
"node_modules/cypress": {
"version": "13.16.0",
"resolved": "https://registry.npmjs.org/cypress/-/cypress-13.16.0.tgz",
"integrity": "sha512-g6XcwqnvzXrqiBQR/5gN+QsyRmKRhls1y5E42fyOvsmU7JuY+wM6uHJWj4ZPttjabzbnRvxcik2WemR8+xT6FA==",
"version": "13.16.1",
"resolved": "https://registry.npmjs.org/cypress/-/cypress-13.16.1.tgz",
"integrity": "sha512-17FtCaz0cx7ssWYKXzGB0Vub8xHwpVPr+iPt2fHhLMDhVAPVrplD+rTQsZUsfb19LVBn5iwkEUFjQ1yVVJXsLA==",
"hasInstallScript": true,
"dependencies": {
"@cypress/request": "^3.0.6",
@ -3556,14 +3556,11 @@
}
},
"node_modules/gopd": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.1.0.tgz",
"integrity": "sha512-FQoVQnqcdk4hVM4JN1eromaun4iuS34oStkdlLENLdpULsuQcTyXj8w7ayhuUfPwEYZ1ZOooOTT6fdA9Vmx/RA==",
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz",
"integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==",
"dependencies": {
"get-intrinsic": "^1.2.4"
},
"engines": {
"node": ">= 0.4"
"get-intrinsic": "^1.1.3"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
@ -3594,12 +3591,9 @@
}
},
"node_modules/has-proto": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.1.0.tgz",
"integrity": "sha512-QLdzI9IIO1Jg7f9GT1gXpPpXArAn6cS31R1eEZqz08Gc+uQ8/XiqHWt17Fiw+2p6oTTIq5GXEpQkAlA88YRl/Q==",
"dependencies": {
"call-bind": "^1.0.7"
},
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz",
"integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==",
"engines": {
"node": ">= 0.4"
},
@ -3608,9 +3602,9 @@
}
},
"node_modules/has-symbols": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
"integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==",
"engines": {
"node": ">= 0.4"
},
@ -5702,34 +5696,20 @@
"integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg=="
},
"node_modules/tldts": {
<<<<<<< Updated upstream
"version": "6.1.64",
"resolved": "https://registry.npmjs.org/tldts/-/tldts-6.1.64.tgz",
"integrity": "sha512-ph4AE5BXWIOsSy9stpoeo7bYe/Cy7VfpciIH4RhVZUPItCJmhqWCN0EVzxd8BOHiyNb42vuJc6NWTjJkg91Tuw==",
"dependencies": {
"tldts-core": "^6.1.64"
=======
"version": "6.1.65",
"resolved": "https://registry.npmjs.org/tldts/-/tldts-6.1.65.tgz",
"integrity": "sha512-xU9gLTfAGsADQ2PcWee6Hg8RFAv0DnjMGVJmDnUmI8a9+nYmapMQix4afwrdaCtT+AqP4MaxEzu7cCrYmBPbzQ==",
"dependencies": {
"tldts-core": "^6.1.65"
>>>>>>> Stashed changes
},
"bin": {
"tldts": "bin/cli.js"
}
},
"node_modules/tldts-core": {
<<<<<<< Updated upstream
"version": "6.1.64",
"resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-6.1.64.tgz",
"integrity": "sha512-uqnl8vGV16KsyflHOzqrYjjArjfXaU6rMPXYy2/ZWoRKCkXtghgB4VwTDXUG+t0OTGeSewNAG31/x1gCTfLt+Q=="
=======
"version": "6.1.65",
"resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-6.1.65.tgz",
"integrity": "sha512-Uq5t0N0Oj4nQSbU8wFN1YYENvMthvwU13MQrMJRspYCGLSAZjAfoBOJki5IQpnBM/WFskxxC/gIOTwaedmHaSg=="
>>>>>>> Stashed changes
},
"node_modules/tmp": {
"version": "0.2.3",