Skip to content

Commit f9b8e8c

Browse files
Mariovidorochdev
authored andcommitted
[test-optimization] [SDTEST-2272] Fix attempt_to_fix tagging in Playwright (#6071)
1 parent 6832c36 commit f9b8e8c

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict'
2+
3+
const { test, expect } = require('@playwright/test')
4+
5+
test.beforeEach(async ({ page }) => {
6+
await page.goto(process.env.PW_BASE_URL)
7+
})
8+
9+
test.describe('retried test', () => {
10+
test('should be retried', async ({ page }) => {
11+
await expect(page.locator('.hello-world')).toHaveText([
12+
'Hello World'
13+
])
14+
})
15+
})

integration-tests/playwright/playwright.spec.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,5 +1727,52 @@ versions.forEach((version) => {
17271727
})
17281728
})
17291729
})
1730+
1731+
contextNewVersions('check retries tagging', () => {
1732+
it('does not send attempt to fix tags if test is retried and not attempt to fix', (done) => {
1733+
const receiverPromise = receiver
1734+
.gatherPayloadsMaxTimeout(({ url }) => url === '/api/v2/citestcycle', (payloads) => {
1735+
const events = payloads.flatMap(({ payload }) => payload.events)
1736+
const tests = events.filter(event => event.type === 'test').map(event => event.content)
1737+
1738+
assert.equal(tests.length, NUM_RETRIES_EFD + 1)
1739+
for (const test of tests) {
1740+
assert.notProperty(test.meta, TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED)
1741+
assert.notProperty(test.meta, TEST_HAS_FAILED_ALL_RETRIES)
1742+
}
1743+
})
1744+
1745+
receiver.setSettings({
1746+
impacted_tests_enabled: true,
1747+
early_flake_detection: {
1748+
enabled: true,
1749+
slow_test_retries: {
1750+
'5s': NUM_RETRIES_EFD
1751+
}
1752+
},
1753+
known_tests_enabled: true,
1754+
test_management: {
1755+
attempt_to_fix_retries: NUM_RETRIES_EFD
1756+
}
1757+
})
1758+
1759+
childProcess = exec(
1760+
'./node_modules/.bin/playwright test -c playwright.config.js retried-test.js',
1761+
{
1762+
cwd,
1763+
env: {
1764+
...getCiVisAgentlessConfig(receiver.port),
1765+
PW_BASE_URL: `http://localhost:${webAppPort}`,
1766+
TEST_DIR: './ci-visibility/playwright-tests-retries-tagging',
1767+
},
1768+
stdio: 'pipe'
1769+
}
1770+
)
1771+
1772+
childProcess.on('exit', () => {
1773+
receiverPromise.then(done).catch(done)
1774+
})
1775+
})
1776+
})
17301777
})
17311778
})

packages/datadog-instrumentations/src/playwright.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,9 @@ function testEndHandler (test, annotations, testStatus, error, isTimeout, isMain
337337
testStatuses.push(testStatus)
338338
}
339339

340-
if (testStatuses.length === testManagementAttemptToFixRetries + 1) {
340+
const testProperties = getTestProperties(test)
341+
342+
if (testStatuses.length === testManagementAttemptToFixRetries + 1 && testProperties.attemptToFix) {
341343
if (testStatuses.includes('fail')) {
342344
test._ddHasFailedAttemptToFixRetries = true
343345
}

0 commit comments

Comments
 (0)