1
1
'use strict'
2
2
3
+ const { once } = require ( 'node:events' )
3
4
const { exec, execSync } = require ( 'child_process' )
4
5
const satisfies = require ( 'semifies' )
5
6
const path = require ( 'path' )
@@ -25,6 +26,7 @@ const {
25
26
TEST_IS_NEW ,
26
27
TEST_IS_RETRY ,
27
28
TEST_EARLY_FLAKE_ENABLED ,
29
+ TEST_EARLY_FLAKE_ABORT_REASON ,
28
30
TEST_SUITE ,
29
31
TEST_CODE_OWNERS ,
30
32
TEST_SESSION_NAME ,
@@ -537,7 +539,9 @@ versions.forEach((version) => {
537
539
} )
538
540
539
541
receiver . setKnownTestsResponseCode ( 500 )
540
- receiver . setKnownTests ( { } )
542
+ receiver . setKnownTests ( {
543
+ playwright : { }
544
+ } )
541
545
542
546
const receiverPromise = receiver
543
547
. gatherPayloadsMaxTimeout ( ( { url } ) => url === '/api/v2/citestcycle' , ( payloads ) => {
@@ -641,6 +645,61 @@ versions.forEach((version) => {
641
645
receiverPromise . then ( ( ) => done ( ) ) . catch ( done )
642
646
} )
643
647
} )
648
+
649
+ it ( 'does not run EFD if the known tests response is invalid' , async ( ) => {
650
+ receiver . setSettings ( {
651
+ early_flake_detection : {
652
+ enabled : true ,
653
+ slow_test_retries : {
654
+ '5s' : NUM_RETRIES_EFD
655
+ }
656
+ } ,
657
+ known_tests_enabled : true
658
+ } )
659
+
660
+ receiver . setKnownTests (
661
+ {
662
+ 'not-playwright' : { }
663
+ }
664
+ )
665
+
666
+ const receiverPromise = receiver
667
+ . gatherPayloadsMaxTimeout ( ( { url } ) => url === '/api/v2/citestcycle' , ( payloads ) => {
668
+ const events = payloads . flatMap ( ( { payload } ) => payload . events )
669
+
670
+ const testSession = events . find ( event => event . type === 'test_session_end' ) . content
671
+ assert . notProperty ( testSession . meta , TEST_EARLY_FLAKE_ENABLED )
672
+ assert . propertyVal ( testSession . meta , TEST_EARLY_FLAKE_ABORT_REASON , 'faulty' )
673
+
674
+ const tests = events . filter ( event => event . type === 'test' ) . map ( event => event . content )
675
+ const newTests = tests . filter ( test =>
676
+ test . resource . endsWith ( 'should work with passing tests' )
677
+ )
678
+ newTests . forEach ( test => {
679
+ assert . notProperty ( test . meta , TEST_IS_NEW )
680
+ } )
681
+
682
+ const retriedTests = tests . filter ( test => test . meta [ TEST_IS_RETRY ] === 'true' )
683
+ assert . equal ( retriedTests . length , 0 )
684
+ } )
685
+
686
+ childProcess = exec (
687
+ './node_modules/.bin/playwright test -c playwright.config.js' ,
688
+ {
689
+ cwd,
690
+ env : {
691
+ ...getCiVisAgentlessConfig ( receiver . port ) ,
692
+ PW_BASE_URL : `http://localhost:${ webAppPort } `
693
+ } ,
694
+ stdio : 'pipe'
695
+ }
696
+ )
697
+
698
+ await Promise . all ( [
699
+ once ( childProcess , 'exit' ) ,
700
+ receiverPromise ,
701
+ ] )
702
+ } )
644
703
} )
645
704
646
705
it ( 'does not crash when maxFailures=1 and there is an error' , ( done ) => {
@@ -1703,7 +1762,9 @@ versions.forEach((version) => {
1703
1762
1704
1763
context ( 'test is new' , ( ) => {
1705
1764
it ( 'should be retried and marked both as new and modified' , ( done ) => {
1706
- receiver . setKnownTests ( { } )
1765
+ receiver . setKnownTests ( {
1766
+ playwright : { }
1767
+ } )
1707
1768
receiver . setSettings ( {
1708
1769
impacted_tests_enabled : true ,
1709
1770
early_flake_detection : {
0 commit comments