@@ -10,6 +10,8 @@ import {
10
10
import {
11
11
EXCLUDED_DIRS ,
12
12
TEST_FILE_DETECTION ,
13
+ backendIndicators ,
14
+ strongUIIndicators ,
13
15
} from "../percy-snapshot-utils/constants.js" ;
14
16
15
17
import { DetectionConfig } from "../percy-snapshot-utils/types.js" ;
@@ -70,45 +72,9 @@ async function batchRegexCheck(
70
72
async function isLikelyUITest ( filePath : string ) : Promise < boolean > {
71
73
try {
72
74
const content = await fs . promises . readFile ( filePath , "utf8" ) ;
73
-
74
- // Quick backend test elimination
75
- const backendIndicators = [
76
- / i m p o r t \s + r e q u e s t s / ,
77
- / r e q u e s t s \. ( g e t | p o s t | p u t | d e l e t e | p a t c h ) / ,
78
- / @ p y t e s t \. m a r k \. ( a p i | b a c k e n d | i n t e g r a t i o n ) / ,
79
- / B A S E _ U R L \s * = / ,
80
- / \. s t a t u s _ c o d e / ,
81
- / \. j s o n \( \) / ,
82
- / T e s t C l i e n t / ,
83
- / B e a r e r \s + / ,
84
- / A u t h o r i z a t i o n .* B e a r e r / ,
85
- ] ;
86
-
87
75
if ( backendIndicators . some ( ( pattern ) => pattern . test ( content ) ) ) {
88
76
return false ;
89
77
}
90
-
91
- // UI-specific patterns that require context
92
- const strongUIIndicators = [
93
- // Browser automation with specific context
94
- / ( d r i v e r | b r o w s e r | p a g e ) \. ( c l i c k | t y p e | f i l l | s c r e e n s h o t | w a i t ) / ,
95
- / w e b d r i v e r \. ( C h r o m e | F i r e f o x | S a f a r i | E d g e ) / ,
96
- / ( s e l e n i u m | p l a y w r i g h t | p u p p e t e e r | c y p r e s s ) .* i m p o r t / ,
97
- // CSS/XPath selectors
98
- / B y \. ( I D | C L A S S _ N A M E | X P A T H | C S S _ S E L E C T O R ) / ,
99
- / \$ \( [ ' " # [ . ] [ ^ ' " ] * [ ' " ] \) / , // $(".class") or $("#id")
100
- // Page Object Model
101
- / c l a s s .* P a g e .* : / ,
102
- / c l a s s .* P a g e O b j e c t / ,
103
- // UI test markers
104
- / @ ( u i | w e b | e 2 e | b r o w s e r ) _ ? t e s t / ,
105
- / @ p y t e s t \. m a r k \. ( u i | w e b | e 2 e | b r o w s e r ) / ,
106
- // Browser navigation
107
- / \. g o t o \s * \( [ ' " ] h t t p s ? : / ,
108
- / \. v i s i t \s * \( [ ' " ] h t t p s ? : / ,
109
- / \. n a v i g a t e \( \) \. t o \( / ,
110
- ] ;
111
-
112
78
return strongUIIndicators . some ( ( pattern ) => pattern . test ( content ) ) ;
113
79
} catch {
114
80
return false ;
0 commit comments