@@ -11,75 +11,98 @@ import {
1111 goToIngestionPage ,
1212} from "./utils" ;
1313
14+ const testId = Math . floor ( Math . random ( ) * 100000 ) ;
15+
1416describe ( "run history tab in manage data sources" , ( ) => {
17+ const createdSources = [ ] ;
18+
1519 beforeEach ( ( ) => {
1620 setIngestionRedesignFlags ( true ) ;
1721 cy . login ( ) ;
1822 goToIngestionPage ( ) ;
1923 } ) ;
2024
21- Cypress . on ( "uncaught:exception" , ( err , runnable ) => false ) ;
25+ afterEach ( ( ) => {
26+ // Guarantee cleanup even if a test fails mid-way
27+ if ( createdSources . length > 0 ) {
28+ // Use goToIngestionPage() rather than navigateToTab("Sources") so that
29+ // cleanup always starts from a known page state. Tests that navigate to
30+ // the Run History tab leave the Sources tab out of view, causing
31+ // navigateToTab to time out waiting for the tab element.
32+ goToIngestionPage ( ) ;
33+ createdSources . forEach ( ( name ) => {
34+ deleteIngestionSource ( name ) ;
35+ } ) ;
36+ createdSources . length = 0 ;
37+ }
38+ } ) ;
39+
40+ Cypress . on ( "uncaught:exception" , ( err ) => {
41+ if ( err . message . includes ( "ResizeObserver" ) ) return false ;
42+ // Suppress null focus errors from the app (pre-existing React bug where
43+ // .focus() is called on an unmounted element) to prevent flaky test aborts.
44+ if (
45+ err . message . includes ( "Cannot read properties of null (reading 'focus')" )
46+ )
47+ return false ;
48+ return true ;
49+ } ) ;
2250
2351 it ( "navigate to run history tab from last run column of sources tab" , ( ) => {
24- const sourceName = "test ingestion source history" ;
52+ const sourceName = `test ingestion source history ${ testId } ` ;
53+ createdSources . push ( sourceName ) ;
2554 createAndRunIngestionSource ( sourceName ) ;
26- cy . wait ( 2000 ) ;
27- cy . contains ( "td" , sourceName )
55+ cy . contains ( "td" , sourceName , { timeout : 10000 } )
2856 . siblings ( "td" )
2957 . find ( '[data-testid="ingestion-source-last-run"]' )
3058 . click ( ) ;
3159 shouldNavigateToRunHistoryTab ( ) ;
32- navigateToTab ( "Sources" ) ;
33- deleteIngestionSource ( sourceName ) ;
3460 } ) ;
3561
3662 it ( "navigate to run history tab from View run history option in dropdown of sources" , ( ) => {
37- const sourceName = "ingestion source history" ;
63+ const sourceName = `ingestion source history ${ testId } ` ;
64+ createdSources . push ( sourceName ) ;
3865 createAndRunIngestionSource ( sourceName ) ;
39- cy . wait ( 2000 ) ;
40- cy . contains ( "td" , sourceName )
66+ cy . contains ( "td" , sourceName , { timeout : 10000 } )
4167 . siblings ( "td" )
4268 . find ( '[data-testid="ingestion-more-options"]' )
4369 . click ( ) ;
4470 cy . get ( "body .ant-dropdown-menu" ) . contains ( "View Run History" ) . click ( ) ;
4571 shouldNavigateToRunHistoryTab ( ) ;
46- navigateToTab ( "Sources" ) ;
47- deleteIngestionSource ( sourceName ) ;
4872 } ) ;
4973
5074 it ( "view past executions in run history tab" , ( ) => {
51- const sourceName = "source for past executions" ;
75+ const sourceName = `source for past executions ${ testId } ` ;
76+ createdSources . push ( sourceName ) ;
5277 createAndRunIngestionSource ( sourceName ) ;
53- cy . wait ( 2000 ) ;
5478 navigateToTab ( "RunHistory" ) ;
5579 cy . get ( '[data-testid="executions-table"]' ) . within ( ( ) => {
56- cy . contains ( '[data-testid="ingestion-source-name"]' , sourceName ) . should (
57- "be.visible" ,
58- ) ;
80+ cy . contains ( '[data-testid="ingestion-source-name"]' , sourceName , {
81+ timeout : 10000 ,
82+ } ) . should ( "be.visible" ) ;
5983 } ) ;
60- navigateToTab ( "Sources" ) ;
61- deleteIngestionSource ( sourceName ) ;
6284 } ) ;
6385
6486 it ( "navigate to sources tab from source name in run history tab" , ( ) => {
65- const sourceName = "source for tab navigation" ;
87+ const sourceName = `source for tab navigation ${ testId } ` ;
88+ createdSources . push ( sourceName ) ;
6689 createAndRunIngestionSource ( sourceName ) ;
67- cy . wait ( 2000 ) ;
6890 navigateToTab ( "RunHistory" ) ;
6991 cy . get ( '[data-testid="executions-table"]' ) . within ( ( ) => {
70- cy . contains ( '[data-testid="ingestion-source-name"]' , sourceName )
92+ cy . contains ( '[data-testid="ingestion-source-name"]' , sourceName , {
93+ timeout : 10000 ,
94+ } )
7195 . should ( "be.visible" )
7296 . first ( )
7397 . click ( { force : true } ) ;
7498 } ) ;
7599 shouldNavigateToSourcesTab ( ) ;
76- cy . wait ( 2000 ) ;
77- deleteIngestionSource ( sourceName ) ;
78100 } ) ;
79101
80102 it ( "filter execution requests by source name" , ( ) => {
81- const sourceName1 = "Source1" ;
82- const sourceName2 = "Source2" ;
103+ const sourceName1 = `Source1 ${ testId } ` ;
104+ const sourceName2 = `Source2 ${ testId } ` ;
105+ createdSources . push ( sourceName1 , sourceName2 ) ;
83106
84107 createIngestionSource ( sourceName1 ) ;
85108 createIngestionSource ( sourceName2 ) ;
@@ -91,9 +114,5 @@ describe("run history tab in manage data sources", () => {
91114 cy . contains ( "td" , sourceName1 ) . should ( "be.visible" ) ;
92115 cy . contains ( "td" , sourceName2 ) . should ( "not.exist" ) ;
93116 } ) ;
94-
95- navigateToTab ( "Sources" ) ;
96- deleteIngestionSource ( sourceName1 ) ;
97- deleteIngestionSource ( sourceName2 ) ;
98117 } ) ;
99118} ) ;
0 commit comments