@@ -1350,5 +1350,73 @@ versions.forEach((version) => {
13501350 } )
13511351 } )
13521352 } )
1353+
1354+ if ( version === 'latest' ) {
1355+ context ( 'active test span' , ( ) => {
1356+ it ( 'can grab the test span and add tags' , ( done ) => {
1357+ const receiverPromise = receiver
1358+ . gatherPayloadsMaxTimeout ( ( { url } ) => url === '/api/v2/citestcycle' , ( payloads ) => {
1359+ const events = payloads . flatMap ( ( { payload } ) => payload . events )
1360+
1361+ const test = events . find ( event => event . type === 'test' ) . content
1362+
1363+ assert . equal ( test . meta [ 'test.custom_tag' ] , 'this is custom' )
1364+ } )
1365+
1366+ childProcess = exec (
1367+ './node_modules/.bin/playwright test -c playwright.config.js active-test-span-tags-test.js' ,
1368+ {
1369+ cwd,
1370+ env : {
1371+ ...getCiVisAgentlessConfig ( receiver . port ) ,
1372+ PW_BASE_URL : `http://localhost:${ webAppPort } ` ,
1373+ TEST_DIR : './ci-visibility/playwright-tests-active-test-span'
1374+ } ,
1375+ stdio : 'pipe'
1376+ }
1377+ )
1378+
1379+ childProcess . on ( 'exit' , ( ) => {
1380+ receiverPromise . then ( ( ) => done ( ) ) . catch ( done )
1381+ } )
1382+ } )
1383+
1384+ it ( 'can grab the test span and add spans' , ( done ) => {
1385+ const receiverPromise = receiver
1386+ . gatherPayloadsMaxTimeout ( ( { url } ) => url === '/api/v2/citestcycle' , ( payloads ) => {
1387+ const events = payloads . flatMap ( ( { payload } ) => payload . events )
1388+
1389+ const test = events . find ( event => event . type === 'test' ) . content
1390+ const spans = events . filter ( event => event . type === 'span' ) . map ( event => event . content )
1391+
1392+ const customSpan = spans . find ( span => span . name === 'my custom span' )
1393+
1394+ assert . exists ( customSpan )
1395+ assert . equal ( customSpan . meta [ 'test.really_custom_tag' ] , 'this is really custom' )
1396+
1397+ // custom span is children of active test span
1398+ assert . equal ( customSpan . trace_id . toString ( ) , test . trace_id . toString ( ) )
1399+ assert . equal ( customSpan . parent_id . toString ( ) , test . span_id . toString ( ) )
1400+ } )
1401+
1402+ childProcess = exec (
1403+ './node_modules/.bin/playwright test -c playwright.config.js active-test-span-custom-span-test.js' ,
1404+ {
1405+ cwd,
1406+ env : {
1407+ ...getCiVisAgentlessConfig ( receiver . port ) ,
1408+ PW_BASE_URL : `http://localhost:${ webAppPort } ` ,
1409+ TEST_DIR : './ci-visibility/playwright-tests-active-test-span'
1410+ } ,
1411+ stdio : 'pipe'
1412+ }
1413+ )
1414+
1415+ childProcess . on ( 'exit' , ( ) => {
1416+ receiverPromise . then ( ( ) => done ( ) ) . catch ( done )
1417+ } )
1418+ } )
1419+ } )
1420+ }
13531421 } )
13541422} )
0 commit comments