From bb3cc10c87da48488413f20e5dbfd07bbbbba562 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 20 Aug 2025 13:46:08 +0000 Subject: [PATCH 1/3] Initial plan From 5d39d84a1e1488a46f91a8e815bd6aa3dfe4b9a8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 20 Aug 2025 14:04:24 +0000 Subject: [PATCH 2/3] Fix JUnit XML test case name inconsistency in scenario retries Co-authored-by: kobenguyent <7845001+kobenguyent@users.noreply.github.com> --- lib/mocha/test.js | 6 +++ .../sandbox/configs/definitions/steps.d.ts | 20 +++++++++ test/unit/mocha/test_clone_test.js | 44 +++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 test/data/sandbox/configs/definitions/steps.d.ts create mode 100644 test/unit/mocha/test_clone_test.js diff --git a/lib/mocha/test.js b/lib/mocha/test.js index 7ff53721d..702cdf571 100644 --- a/lib/mocha/test.js +++ b/lib/mocha/test.js @@ -77,6 +77,12 @@ function deserializeTest(test) { test.parent = Object.assign(new Suite(test.parent?.title || 'Suite'), test.parent) enhanceMochaSuite(test.parent) if (test.steps) test.steps = test.steps.map(step => Object.assign(new Step(step.title), step)) + + // Restore the custom fullTitle function to maintain consistency with original test + if (test.parent && test.parent.title) { + test.fullTitle = () => `${test.parent.title}: ${test.title}` + } + return test } diff --git a/test/data/sandbox/configs/definitions/steps.d.ts b/test/data/sandbox/configs/definitions/steps.d.ts new file mode 100644 index 000000000..41dc21a1e --- /dev/null +++ b/test/data/sandbox/configs/definitions/steps.d.ts @@ -0,0 +1,20 @@ +/// +type steps_file = typeof import('../../support/custom_steps.js') +type MyPage = typeof import('../../support/my_page.js') +type SecondPage = typeof import('../../support/second_page.js') +type CurrentPage = typeof import('./po/custom_steps.js') + +declare namespace CodeceptJS { + interface SupportObject { + I: I + current: any + MyPage: MyPage + SecondPage: SecondPage + CurrentPage: CurrentPage + } + interface Methods extends FileSystem {} + interface I extends ReturnType, WithTranslation {} + namespace Translation { + interface Actions {} + } +} diff --git a/test/unit/mocha/test_clone_test.js b/test/unit/mocha/test_clone_test.js new file mode 100644 index 000000000..dc5a1b1ba --- /dev/null +++ b/test/unit/mocha/test_clone_test.js @@ -0,0 +1,44 @@ +const { expect } = require('chai') +const { createTest, cloneTest } = require('../../../lib/mocha/test') +const { createSuite } = require('../../../lib/mocha/suite') +const MochaSuite = require('mocha/lib/suite') + +describe('Test cloning for retries', function () { + it('should maintain consistent fullTitle format after cloning', function () { + // Create a root suite first + const rootSuite = new MochaSuite('', null, true) + // Create a test suite as child + const suite = createSuite(rootSuite, 'JUnit reporting') + + // Create a test + const test = createTest('Test 1', () => {}) + + // Add test to suite - this sets up the custom fullTitle function + test.addToSuite(suite) + + const originalTitle = test.fullTitle() + expect(originalTitle).to.equal('JUnit reporting: Test 1') + + // Clone the test (this is what happens during retries) + const clonedTest = cloneTest(test) + const clonedTitle = clonedTest.fullTitle() + + // The cloned test should maintain the same title format with colon + expect(clonedTitle).to.equal(originalTitle) + expect(clonedTitle).to.equal('JUnit reporting: Test 1') + }) + + it('should preserve parent-child relationship after cloning', function () { + const rootSuite = new MochaSuite('', null, true) + const suite = createSuite(rootSuite, 'Feature Suite') + + const test = createTest('Scenario Test', () => {}) + test.addToSuite(suite) + + const clonedTest = cloneTest(test) + + expect(clonedTest.parent).to.exist + expect(clonedTest.parent.title).to.equal('Feature Suite') + expect(clonedTest.fullTitle()).to.equal('Feature Suite: Scenario Test') + }) +}) From 9ea58ed47df6916993ec0bafe9652e1a42b2a780 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 20 Aug 2025 14:07:10 +0000 Subject: [PATCH 3/3] Improve edge case handling for empty suite titles in cloned tests Co-authored-by: kobenguyent <7845001+kobenguyent@users.noreply.github.com> --- lib/mocha/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mocha/test.js b/lib/mocha/test.js index 702cdf571..e4a33f346 100644 --- a/lib/mocha/test.js +++ b/lib/mocha/test.js @@ -79,7 +79,7 @@ function deserializeTest(test) { if (test.steps) test.steps = test.steps.map(step => Object.assign(new Step(step.title), step)) // Restore the custom fullTitle function to maintain consistency with original test - if (test.parent && test.parent.title) { + if (test.parent) { test.fullTitle = () => `${test.parent.title}: ${test.title}` }