diff --git a/ee/packages/federation-matrix/.gitignore b/ee/packages/federation-matrix/.gitignore index 996e8eedb9a25..fb265e444c343 100644 --- a/ee/packages/federation-matrix/.gitignore +++ b/ee/packages/federation-matrix/.gitignore @@ -1 +1,2 @@ .nyc_output +logs/ diff --git a/ee/packages/federation-matrix/jest.config.federation.ts b/ee/packages/federation-matrix/jest.config.federation.ts index 91d6355341a40..7e90526c90470 100644 --- a/ee/packages/federation-matrix/jest.config.federation.ts +++ b/ee/packages/federation-matrix/jest.config.federation.ts @@ -37,8 +37,6 @@ export default { forceExit: true, // Force Jest to exit after tests complete detectOpenHandles: true, // Detect open handles that prevent Jest from exiting globalTeardown: '/tests/teardown.ts', - // To disable Qase integration, remove this line or comment it out - setupFilesAfterEnv: ['/tests/setup-qase.ts'], verbose: false, silent: false, reporters: [ diff --git a/ee/packages/federation-matrix/package.json b/ee/packages/federation-matrix/package.json index 6b9a5ca9eac4b..ed8f0cd2043f4 100644 --- a/ee/packages/federation-matrix/package.json +++ b/ee/packages/federation-matrix/package.json @@ -50,6 +50,7 @@ "babel-jest": "~30.2.0", "eslint": "~8.45.0", "jest": "~30.2.0", + "jest-qase-reporter": "^2.1.4", "matrix-js-sdk": "^38.4.0", "pino-pretty": "^7.6.1", "typescript": "~5.9.3" diff --git a/ee/packages/federation-matrix/tests/setup-qase.ts b/ee/packages/federation-matrix/tests/setup-qase.ts deleted file mode 100644 index 029863d9eb7e0..0000000000000 --- a/ee/packages/federation-matrix/tests/setup-qase.ts +++ /dev/null @@ -1,181 +0,0 @@ -/** - * Jest setup file that automatically wraps describe and it/test functions - * to register suites and tests with Qase. - * - * The Qase Jest reporter reports the directory structure up from the tests directory, - * making it not consistent with the test suite structure we currently follow in Qase. - * The solution is to wrap describe and it/test functions to automatically set the suite - * at the very start of the test to what we really want the reporting structure to be. - * - * This file is loaded via setupFilesAfterEnv in jest.config.federation.ts. - * Qase integration is only enabled when QASE_TESTOPS_JEST_API_TOKEN is set. - */ - -import { qase } from 'jest-qase-reporter/jest'; - -const ROOT_SUITE = 'Rocket.Chat Federation Automation'; - -/** - * Stack to track the current suite path hierarchy - */ -const suitePathStack: string[] = []; - -/** - * Store the original Jest describe function before we replace it - */ -const originalDescribe = global.describe; - -/** - * Gets the full suite path including root - */ -function getFullSuitePath(): string { - return [ROOT_SUITE, ...suitePathStack].join('\t'); -} - -/** - * Wraps describe to automatically track suite hierarchy and set suite for tests - */ -function describeImpl(name: string, fn: () => void): void { - suitePathStack.push(name); - const currentPath = getFullSuitePath(); - - originalDescribe(name, () => { - // Add beforeEach to set suite for all tests in this describe block - // This must be called before the test runs so the reporter picks it up - global.beforeEach(() => { - qase.suite(currentPath); - }); - - // Store current it and test wrappers (they might be wrapped by parent describe) - const currentIt = global.it; - const currentTest = global.test; - - // Wrap it() to automatically set suite at the very start - global.it = Object.assign( - (testName: any, fn?: any, timeout?: number) => { - // Handle qase-wrapped test names (qase returns a string) - if (typeof testName === 'string' && fn) { - return currentIt( - testName, - async () => { - // Set suite immediately at the start of the test - qase.suite(currentPath); - // Call the original test function and return the result - return fn(); - }, - timeout, - ); - } - // Handle cases where testName might be a number or other type - return currentIt(testName, fn, timeout); - }, - { - skip: (name: string, fn: () => void) => { - suitePathStack.push(name); - try { - currentIt.skip(name, fn); - } finally { - suitePathStack.pop(); - } - }, - only: (name: string, fn: () => void) => { - suitePathStack.push(name); - try { - currentIt.only(name, fn); - } finally { - suitePathStack.pop(); - } - }, - todo: (name: string) => { - suitePathStack.push(name); - try { - currentIt.todo(name); - } finally { - suitePathStack.pop(); - } - }, - }, - ) as typeof global.it; - - // Wrap test() to automatically set suite at the very start - global.test = Object.assign( - (testName: any, fn?: any, timeout?: number) => { - if (typeof testName === 'string' && fn) { - return currentTest( - testName, - async () => { - // Set suite immediately at the start of the test - qase.suite(currentPath); - // Call the original test function and return the result - return fn(); - }, - timeout, - ); - } - return currentTest(testName, fn, timeout); - }, - { - skip: (name: string, fn: () => void) => { - suitePathStack.push(name); - try { - currentTest.skip(name, fn); - } finally { - suitePathStack.pop(); - } - }, - only: (name: string, fn: () => void) => { - suitePathStack.push(name); - try { - currentTest.only(name, fn); - } finally { - suitePathStack.pop(); - } - }, - todo: (name: string) => { - suitePathStack.push(name); - try { - currentTest.todo(name); - } finally { - suitePathStack.pop(); - } - }, - }, - ) as typeof global.test; - - // Execute the describe block - try { - fn(); - } catch (error) { - console.error('Error in describe block:', error); - } - - // Restore previous wrappers - global.it = currentIt; - global.test = currentTest; - }); - - suitePathStack.pop(); -} - -// Only apply qase wrapping if the environment variable is set -if (process.env.QASE_TESTOPS_JEST_API_TOKEN) { - // Replace global describe with our wrapper - (global as any).describe = Object.assign(describeImpl, { - skip: (name: string, fn: () => void) => { - suitePathStack.push(name); - try { - originalDescribe.skip(name, fn); - } finally { - suitePathStack.pop(); - } - }, - only: (name: string, fn: () => void) => { - suitePathStack.push(name); - try { - originalDescribe.only(name, fn); - } finally { - suitePathStack.pop(); - } - }, - }) as typeof global.describe; -} diff --git a/package.json b/package.json index 847f0a2dfee8a..caa3703c24224 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,6 @@ "@types/chart.js": "^2.9.41", "@types/js-yaml": "^4.0.9", "@types/node": "~22.16.5", - "jest-qase-reporter": "^2.1.3", "ts-node": "^10.9.2", "turbo": "~2.6.1", "typescript": "~5.9.3" diff --git a/yarn.lock b/yarn.lock index 9296fc08d10b8..53a3c7889437e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8508,6 +8508,7 @@ __metadata: emojione: "npm:^4.5.0" eslint: "npm:~8.45.0" jest: "npm:~30.2.0" + jest-qase-reporter: "npm:^2.1.4" marked: "npm:^16.1.2" matrix-js-sdk: "npm:^38.4.0" mongodb: "npm:6.16.0" @@ -16341,6 +16342,17 @@ __metadata: languageName: node linkType: hard +"axios@npm:^1.13.2": + version: 1.13.2 + resolution: "axios@npm:1.13.2" + dependencies: + follow-redirects: "npm:^1.15.6" + form-data: "npm:^4.0.4" + proxy-from-env: "npm:^1.1.0" + checksum: 10/ae4e06dcd18289f2fd18179256d550d27f9a53ecb2f9c59f2ccc4efd1d7151839ba8c3e0fb533dac793e4a59a576ca8689a19244dce5c396680837674a47a867 + languageName: node + linkType: hard + "axios@npm:^1.6.1, axios@npm:^1.7.4, axios@npm:^1.8.2": version: 1.10.0 resolution: "axios@npm:1.10.0" @@ -20491,7 +20503,7 @@ __metadata: languageName: node linkType: hard -"env-schema@npm:^5.2.0": +"env-schema@npm:^5.2.0, env-schema@npm:^5.2.1": version: 5.2.1 resolution: "env-schema@npm:5.2.1" dependencies: @@ -22372,6 +22384,19 @@ __metadata: languageName: node linkType: hard +"form-data@npm:^4.0.5": + version: 4.0.5 + resolution: "form-data@npm:4.0.5" + dependencies: + asynckit: "npm:^0.4.0" + combined-stream: "npm:^1.0.8" + es-set-tostringtag: "npm:^2.1.0" + hasown: "npm:^2.0.2" + mime-types: "npm:^2.1.12" + checksum: 10/52ecd6e927c8c4e215e68a7ad5e0f7c1031397439672fd9741654b4a94722c4182e74cc815b225dcb5be3f4180f36428f67c6dd39eaa98af0dcfdd26c00c19cd + languageName: node + linkType: hard + "form-data@npm:~2.3.2": version: 2.3.3 resolution: "form-data@npm:2.3.3" @@ -25583,17 +25608,17 @@ __metadata: languageName: node linkType: hard -"jest-qase-reporter@npm:^2.1.3": - version: 2.1.3 - resolution: "jest-qase-reporter@npm:2.1.3" +"jest-qase-reporter@npm:^2.1.4": + version: 2.1.4 + resolution: "jest-qase-reporter@npm:2.1.4" dependencies: lodash.get: "npm:^4.4.2" lodash.has: "npm:^4.5.2" - qase-javascript-commons: "npm:~2.4.2" - uuid: "npm:^9.0.0" + qase-javascript-commons: "npm:~2.4.16" + uuid: "npm:^9.0.1" peerDependencies: jest: ">=28.0.0" - checksum: 10/1c19643adaffd514674d1dbdc92d6377beb859d4036228133a8ad2dadadbc879bc65b74df5f14ad371b5e269976720da3b787afbfba034ff8be0f1a1792324c7 + checksum: 10/45c9e3606205786f014523e77a6f0818906b2d953da92fda86396486c1ce836ca6a99d29993b1e8d631ce16eb9ebc0e9094f29ad099d1c35d917c3a9d21e41e1 languageName: node linkType: hard @@ -27716,7 +27741,7 @@ __metadata: languageName: node linkType: hard -"mime-types@npm:^2.1.12, mime-types@npm:^2.1.27, mime-types@npm:^2.1.31, mime-types@npm:^2.1.33, mime-types@npm:~2.1.17, mime-types@npm:~2.1.19, mime-types@npm:~2.1.24, mime-types@npm:~2.1.34": +"mime-types@npm:^2.1.12, mime-types@npm:^2.1.27, mime-types@npm:^2.1.31, mime-types@npm:^2.1.33, mime-types@npm:^2.1.35, mime-types@npm:~2.1.17, mime-types@npm:~2.1.19, mime-types@npm:~2.1.24, mime-types@npm:~2.1.34": version: 2.1.35 resolution: "mime-types@npm:2.1.35" dependencies: @@ -31256,6 +31281,16 @@ __metadata: languageName: node linkType: hard +"qase-api-client@npm:~1.1.1": + version: 1.1.1 + resolution: "qase-api-client@npm:1.1.1" + dependencies: + axios: "npm:^1.13.2" + axios-retry: "npm:^4.5.0" + checksum: 10/885ee6cc6d11a197e23335fabe5e20d34f2ce498cbefca9cf25f3fc911af487daf5fbb96771ae97dfc169b4dac4cd8a3f8767c0768bb2512112294ca15f864b2 + languageName: node + linkType: hard + "qase-api-v2-client@npm:~1.0.1": version: 1.0.2 resolution: "qase-api-v2-client@npm:1.0.2" @@ -31266,6 +31301,37 @@ __metadata: languageName: node linkType: hard +"qase-api-v2-client@npm:~1.0.4": + version: 1.0.4 + resolution: "qase-api-v2-client@npm:1.0.4" + dependencies: + axios: "npm:^1.13.2" + axios-retry: "npm:^4.5.0" + checksum: 10/6ee58fadd3bc6bb7774e17623ad98ef3f6d2634c90179fde0dfede80951bd808ee2e510bd258835704d65f7dc17f456acc2ecee1c84a6ff41b5abfaf61bb6139 + languageName: node + linkType: hard + +"qase-javascript-commons@npm:~2.4.16": + version: 2.4.16 + resolution: "qase-javascript-commons@npm:2.4.16" + dependencies: + ajv: "npm:^8.17.1" + async-mutex: "npm:~0.5.0" + chalk: "npm:^4.1.2" + env-schema: "npm:^5.2.1" + form-data: "npm:^4.0.5" + lodash.get: "npm:^4.4.2" + lodash.merge: "npm:^4.6.2" + lodash.mergewith: "npm:^4.6.2" + mime-types: "npm:^2.1.35" + qase-api-client: "npm:~1.1.1" + qase-api-v2-client: "npm:~1.0.4" + strip-ansi: "npm:^6.0.1" + uuid: "npm:^9.0.1" + checksum: 10/28881ec2909cf29d6d365e3a96a08061eb183b3492ee7529f66a07ef466347025bba91f8f70233c0b38cca95362c142f3e2b498efce76469799ab244784b894e + languageName: node + linkType: hard + "qase-javascript-commons@npm:~2.4.2": version: 2.4.2 resolution: "qase-javascript-commons@npm:2.4.2" @@ -32750,7 +32816,6 @@ __metadata: "@types/js-yaml": "npm:^4.0.9" "@types/node": "npm:~22.16.5" "@types/stream-buffers": "npm:^3.0.8" - jest-qase-reporter: "npm:^2.1.3" node-gyp: "npm:^10.2.0" ts-node: "npm:^10.9.2" turbo: "npm:~2.6.1"