Skip to content

Commit 14f60c8

Browse files
committed
test: add test to check atf takes precedence over efd for impacted tests
1 parent a7b9016 commit 14f60c8

File tree

1 file changed

+70
-1
lines changed

1 file changed

+70
-1
lines changed

integration-tests/jest/jest.spec.js

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4167,7 +4167,7 @@ describe(`jest@${JEST_VERSION} commonJS`, () => {
41674167
])
41684168
})
41694169

4170-
it('attempt to fix takes precedence over EFD', async () => {
4170+
it('attempt to fix takes precedence over EFD for new tests', async () => {
41714171
const NUM_RETRIES_EFD = 2
41724172
receiver.setKnownTests({ jest: {} })
41734173
receiver.setSettings({
@@ -5080,6 +5080,75 @@ describe(`jest@${JEST_VERSION} commonJS`, () => {
50805080
runImpactedTest(done, { isModified: true })
50815081
})
50825082

5083+
it('attempt to fix takes precedence over EFD for impacted tests', async () => {
5084+
const NUM_RETRIES_EFD = 2
5085+
receiver.setSettings({
5086+
impacted_tests_enabled: true,
5087+
test_management: { enabled: true, attempt_to_fix_retries: 2 },
5088+
early_flake_detection: {
5089+
enabled: true,
5090+
slow_test_retries: {
5091+
'5s': NUM_RETRIES_EFD
5092+
},
5093+
faulty_session_threshold: 100
5094+
},
5095+
known_tests_enabled: true
5096+
})
5097+
receiver.setTestManagementTests({
5098+
jest: {
5099+
suites: {
5100+
'ci-visibility/test-impacted-test/test-impacted-1.js': {
5101+
tests: {
5102+
'impacted tests can pass normally': {
5103+
properties: {
5104+
attempt_to_fix: true
5105+
}
5106+
}
5107+
}
5108+
}
5109+
}
5110+
}
5111+
})
5112+
5113+
const eventsPromise = receiver
5114+
.gatherPayloadsMaxTimeout(({ url }) => url.endsWith('/api/v2/citestcycle'), (payloads) => {
5115+
const events = payloads.flatMap(({ payload }) => payload.events)
5116+
const tests = events.filter(event => event.type === 'test').map(event => event.content)
5117+
const impactedAtfTests = tests.filter(test =>
5118+
test.meta[TEST_SOURCE_FILE] === 'ci-visibility/test-impacted-test/test-impacted-1.js' &&
5119+
test.meta[TEST_NAME] === 'impacted tests can pass normally'
5120+
)
5121+
5122+
assert.strictEqual(impactedAtfTests.length, 3)
5123+
const atfRetries = impactedAtfTests.filter(
5124+
test => test.meta[TEST_RETRY_REASON] === TEST_RETRY_REASON_TYPES.atf
5125+
)
5126+
const efdRetries = impactedAtfTests.filter(
5127+
test => test.meta[TEST_RETRY_REASON] === TEST_RETRY_REASON_TYPES.efd
5128+
)
5129+
assert.strictEqual(atfRetries.length, 2)
5130+
assert.strictEqual(efdRetries.length, 0)
5131+
})
5132+
5133+
childProcess = exec(
5134+
runTestsCommand,
5135+
{
5136+
cwd,
5137+
env: {
5138+
...getCiVisAgentlessConfig(receiver.port),
5139+
TESTS_TO_RUN: 'test-impacted-test/test-impacted-1',
5140+
GITHUB_BASE_REF: ''
5141+
},
5142+
stdio: 'inherit'
5143+
}
5144+
)
5145+
5146+
await Promise.all([
5147+
once(childProcess, 'exit'),
5148+
eventsPromise
5149+
])
5150+
})
5151+
50835152
it('should not be detected as impacted if disabled', (done) => {
50845153
receiver.setSettings({ impacted_tests_enabled: false })
50855154

0 commit comments

Comments
 (0)