1- import { v4 as uuidv4 } from 'uuid' ;
2- import { AuthTestUtils } from '../../support/auth-utils' ;
31import { PageSelectors , SidebarSelectors } from '../../support/selectors' ;
2+ import { logTestEnvironment } from '../../support/test-config' ;
3+ import { setupCommonExceptionHandlers } from '../../support/exception-handlers' ;
44
55describe ( 'Sidebar Components Resilience Tests' , ( ) => {
6- const generateRandomEmail = ( ) => `${ uuidv4 ( ) } @appflowy.io` ;
7- let testEmail : string ;
6+ before ( ( ) => {
7+ logTestEnvironment ( ) ;
8+ } ) ;
89
910 beforeEach ( ( ) => {
10- testEmail = generateRandomEmail ( ) ;
11-
12- // Handle uncaught exceptions that we expect during app initialization
13- cy . on ( 'uncaught:exception' , ( err : Error ) => {
14- // Ignore known non-critical errors
15- if (
16- err . message . includes ( 'No workspace or service found' ) ||
17- err . message . includes ( 'View not found' ) ||
18- err . message . includes ( 'WebSocket' ) ||
19- err . message . includes ( 'connection' ) ||
20- err . message . includes ( 'Failed to load models' ) ||
21- err . message . includes ( 'Minified React error' ) ||
22- err . message . includes ( 'ResizeObserver loop' ) ||
23- err . message . includes ( 'Non-Error promise rejection' )
24- ) {
25- return false ;
26- }
27- return true ;
28- } ) ;
11+ setupCommonExceptionHandlers ( ) ;
2912 } ) ;
3013
3114 it ( 'should load app without React error boundaries triggering for ShareWithMe and Favorite components' , ( ) => {
32- cy . visit ( '/login' , { failOnStatusCode : false } ) ;
33- cy . wait ( 2000 ) ;
34-
35- const authUtils = new AuthTestUtils ( ) ;
36- authUtils . signInWithTestUrl ( testEmail ) . then ( ( ) => {
15+ cy . loginTestUser ( ) . then ( ( ) => {
3716 cy . url ( ) . should ( 'include' , '/app' ) ;
3817 cy . task ( 'log' , 'Signed in successfully' ) ;
3918
@@ -78,13 +57,7 @@ describe('Sidebar Components Resilience Tests', () => {
7857 } ) ;
7958
8059 it ( 'should handle empty favorites gracefully' , ( ) => {
81- cy . visit ( '/login' , { failOnStatusCode : false } ) ;
82- cy . wait ( 2000 ) ;
83-
84- const authUtils = new AuthTestUtils ( ) ;
85- authUtils . signInWithTestUrl ( testEmail ) . then ( ( ) => {
86- cy . url ( ) . should ( 'include' , '/app' ) ;
87-
60+ cy . loginTestUser ( ) . then ( ( ) => {
8861 // Wait for app to fully load
8962 SidebarSelectors . pageHeader ( ) . should ( 'be.visible' , { timeout : 30000 } ) ;
9063 PageSelectors . names ( ) . should ( 'exist' , { timeout : 30000 } ) ;
@@ -107,13 +80,7 @@ describe('Sidebar Components Resilience Tests', () => {
10780 } ) ;
10881
10982 it ( 'should handle ShareWithMe with no shared content gracefully' , ( ) => {
110- cy . visit ( '/login' , { failOnStatusCode : false } ) ;
111- cy . wait ( 2000 ) ;
112-
113- const authUtils = new AuthTestUtils ( ) ;
114- authUtils . signInWithTestUrl ( testEmail ) . then ( ( ) => {
115- cy . url ( ) . should ( 'include' , '/app' ) ;
116-
83+ cy . loginTestUser ( ) . then ( ( ) => {
11784 // Wait for app to fully load
11885 SidebarSelectors . pageHeader ( ) . should ( 'be.visible' , { timeout : 30000 } ) ;
11986 PageSelectors . names ( ) . should ( 'exist' , { timeout : 30000 } ) ;
@@ -139,13 +106,7 @@ describe('Sidebar Components Resilience Tests', () => {
139106 } ) ;
140107
141108 it ( 'should handle invalid outline data gracefully' , ( ) => {
142- cy . visit ( '/login' , { failOnStatusCode : false } ) ;
143- cy . wait ( 2000 ) ;
144-
145- const authUtils = new AuthTestUtils ( ) ;
146- authUtils . signInWithTestUrl ( testEmail ) . then ( ( ) => {
147- cy . url ( ) . should ( 'include' , '/app' ) ;
148-
109+ cy . loginTestUser ( ) . then ( ( ) => {
149110 // Wait for app to fully load
150111 SidebarSelectors . pageHeader ( ) . should ( 'be.visible' , { timeout : 30000 } ) ;
151112 PageSelectors . names ( ) . should ( 'exist' , { timeout : 30000 } ) ;
@@ -173,13 +134,7 @@ describe('Sidebar Components Resilience Tests', () => {
173134 } ) ;
174135
175136 it ( 'should handle favorites with invalid favorited_at dates gracefully' , ( ) => {
176- cy . visit ( '/login' , { failOnStatusCode : false } ) ;
177- cy . wait ( 2000 ) ;
178-
179- const authUtils = new AuthTestUtils ( ) ;
180- authUtils . signInWithTestUrl ( testEmail ) . then ( ( ) => {
181- cy . url ( ) . should ( 'include' , '/app' ) ;
182-
137+ cy . loginTestUser ( ) . then ( ( ) => {
183138 // Wait for app to fully load
184139 SidebarSelectors . pageHeader ( ) . should ( 'be.visible' , { timeout : 30000 } ) ;
185140 PageSelectors . names ( ) . should ( 'exist' , { timeout : 30000 } ) ;
0 commit comments