Skip to content

Commit 758d302

Browse files
committed
chore: organize test
1 parent d3eb7cf commit 758d302

37 files changed

+943
-3280
lines changed

cypress/e2e/account/avatar/avatar-test-utils.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,21 @@ import { AuthTestUtils } from '../../../support/auth-utils';
77
import { AvatarSelectors } from '../../../support/avatar-selectors';
88
import { dbUtils } from '../../../support/db-utils';
99
import { WorkspaceSelectors } from '../../../support/selectors';
10+
import { TestConfig } from '../../../support/test-config';
11+
import { setupCommonExceptionHandlers } from '../../../support/exception-handlers';
1012

1113
/**
1214
* Shared utilities and setup for avatar tests
1315
*/
1416
export const avatarTestUtils = {
1517
generateRandomEmail: () => `${uuidv4()}@appflowy.io`,
16-
APPFLOWY_BASE_URL: Cypress.env('APPFLOWY_BASE_URL'),
18+
APPFLOWY_BASE_URL: TestConfig.apiUrl,
1719

1820
/**
1921
* Common beforeEach setup for avatar tests
2022
*/
2123
setupBeforeEach: () => {
22-
// Suppress known transient errors
23-
cy.on('uncaught:exception', (err) => {
24-
if (
25-
err.message.includes('Minified React error') ||
26-
err.message.includes('View not found') ||
27-
err.message.includes('No workspace or service found')
28-
) {
29-
return false;
30-
}
31-
32-
return true;
33-
});
24+
setupCommonExceptionHandlers();
3425
cy.viewport(1280, 720);
3526
},
3627

cypress/e2e/account/update-user-profile.cy.ts

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,26 @@
11
import { v4 as uuidv4 } from 'uuid';
2-
import { AuthTestUtils } from '../../support/auth-utils';
2+
import { TestConfig, logTestEnvironment } from '../../support/test-config';
3+
import { setupCommonExceptionHandlers } from '../../support/exception-handlers';
34

45
describe('Update User Profile', () => {
56
const generateRandomEmail = () => `${uuidv4()}@appflowy.io`;
67

7-
beforeEach(() => {
8-
cy.on('uncaught:exception', (err) => {
9-
if (err.message.includes('Minified React error') ||
10-
err.message.includes('View not found') ||
11-
err.message.includes('No workspace or service found')) {
12-
return false;
13-
}
14-
return true;
15-
});
8+
before(() => {
9+
logTestEnvironment();
10+
});
1611

12+
beforeEach(() => {
13+
setupCommonExceptionHandlers();
1714
cy.viewport(1280, 720);
1815
});
1916

2017
it('should update user profile settings through Account Settings', () => {
21-
const testEmail = generateRandomEmail();
18+
let testEmail: string;
2219

2320
// Login
2421
cy.log('Step 1: Logging in to the application');
25-
cy.visit('/login', { failOnStatusCode: false });
26-
cy.wait(2000);
27-
28-
const authUtils = new AuthTestUtils();
29-
authUtils.signInWithTestUrl(testEmail).then(() => {
22+
cy.loginTestUser().then((email) => {
23+
testEmail = email;
3024
// Wait for app to load
3125
cy.log('Step 2: Waiting for application to load');
3226
cy.url({ timeout: 30000 }).should('include', '/app');

cypress/e2e/app/sidebar-components.cy.ts

Lines changed: 11 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,18 @@
1-
import { v4 as uuidv4 } from 'uuid';
2-
import { AuthTestUtils } from '../../support/auth-utils';
31
import { PageSelectors, SidebarSelectors } from '../../support/selectors';
2+
import { logTestEnvironment } from '../../support/test-config';
3+
import { setupCommonExceptionHandlers } from '../../support/exception-handlers';
44

55
describe('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 });

cypress/e2e/auth/login-logout.cy.ts

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,14 @@ import {
66
AuthSelectors,
77
waitForReactUpdate
88
} from '../../support/selectors';
9+
import { TestConfig } from '../../support/test-config';
10+
import { setupCommonExceptionHandlers } from '../../support/exception-handlers';
911

1012
describe('Login and Logout Flow', () => {
11-
const baseUrl = Cypress.config('baseUrl') || 'http://localhost:3000';
12-
const gotrueUrl = Cypress.env('APPFLOWY_GOTRUE_BASE_URL') || 'http://localhost/gotrue';
13-
const apiUrl = Cypress.env('APPFLOWY_BASE_URL') || 'http://localhost';
13+
const { baseUrl, gotrueUrl, apiUrl } = TestConfig;
1414

1515
beforeEach(() => {
16-
// Handle uncaught exceptions
17-
cy.on('uncaught:exception', (err) => {
18-
if (err.message.includes('Minified React error') ||
19-
err.message.includes('View not found') ||
20-
err.message.includes('No workspace or service found')) {
21-
return false;
22-
}
23-
return true;
24-
});
16+
setupCommonExceptionHandlers();
2517
cy.viewport(1280, 720);
2618
});
2719

@@ -54,8 +46,8 @@ describe('Login and Logout Flow', () => {
5446

5547
// Step 5: Verify workspace is loaded by checking dropdown trigger
5648
cy.log('[STEP 5] Verifying workspace loaded');
57-
WorkspaceSelectors.dropdownTrigger({ timeout: 15000 })
58-
.should('be.visible');
49+
WorkspaceSelectors.dropdownTrigger()
50+
.should('be.visible', { timeout: 15000 });
5951

6052
// Step 6: Open workspace dropdown
6153
cy.log('[STEP 6] Opening workspace dropdown');
@@ -124,8 +116,8 @@ describe('Login and Logout Flow', () => {
124116

125117
// Step 4: Verify user is logged in
126118
cy.log('[STEP 4] Verifying user is logged in');
127-
WorkspaceSelectors.dropdownTrigger({ timeout: 15000 })
128-
.should('be.visible');
119+
WorkspaceSelectors.dropdownTrigger()
120+
.should('be.visible', { timeout: 15000 });
129121

130122
// Step 5: Open workspace dropdown
131123
cy.log('[STEP 5] Opening workspace dropdown');
@@ -188,8 +180,8 @@ describe('Login and Logout Flow', () => {
188180

189181
// Step 4: Open workspace dropdown
190182
cy.log('[STEP 4] Opening workspace dropdown');
191-
WorkspaceSelectors.dropdownTrigger({ timeout: 15000 })
192-
.should('be.visible');
183+
WorkspaceSelectors.dropdownTrigger()
184+
.should('be.visible', { timeout: 15000 });
193185
TestTool.openWorkspaceDropdown();
194186

195187
// Verify dropdown is open

cypress/e2e/auth/oauth-login.cy.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { v4 as uuidv4 } from 'uuid';
2+
import { TestConfig, logTestEnvironment } from '../../support/test-config';
3+
import { setupCommonExceptionHandlers } from '../../support/exception-handlers';
24

35
/**
46
* OAuth Login Flow Tests
@@ -19,23 +21,14 @@ import { v4 as uuidv4 } from 'uuid';
1921
* - Context initialization timing
2022
*/
2123
describe('OAuth Login Flow', () => {
22-
const baseUrl = Cypress.config('baseUrl') || 'http://localhost:3000';
23-
const gotrueUrl = Cypress.env('APPFLOWY_GOTRUE_BASE_URL') || 'http://localhost/gotrue';
24-
const apiUrl = Cypress.env('APPFLOWY_BASE_URL') || 'http://localhost';
24+
const { baseUrl, gotrueUrl, apiUrl } = TestConfig;
25+
26+
before(() => {
27+
logTestEnvironment();
28+
});
2529

2630
beforeEach(() => {
27-
// Handle uncaught exceptions
28-
cy.on('uncaught:exception', (err) => {
29-
if (
30-
err.message.includes('Minified React error') ||
31-
err.message.includes('View not found') ||
32-
err.message.includes('No workspace or service found') ||
33-
err.message.includes('Cannot read properties of undefined')
34-
) {
35-
return false;
36-
}
37-
return true;
38-
});
31+
setupCommonExceptionHandlers();
3932
cy.viewport(1280, 720);
4033

4134
// Clear localStorage before each test

cypress/e2e/auth/otp-login.cy.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { v4 as uuidv4 } from 'uuid';
2+
import { TestConfig, logTestEnvironment } from '../../support/test-config';
3+
import { setupCommonExceptionHandlers } from '../../support/exception-handlers';
24

35
/**
46
* OTP Login Flow Tests
@@ -20,13 +22,14 @@ import { v4 as uuidv4 } from 'uuid';
2022
* - localStorage cleanup for new users
2123
*/
2224
describe('OTP Login Flow', () => {
23-
const baseUrl = Cypress.config('baseUrl') || 'http://localhost:3000';
24-
const gotrueUrl = Cypress.env('APPFLOWY_GOTRUE_BASE_URL') || 'http://localhost/gotrue';
25-
const apiUrl = Cypress.env('APPFLOWY_BASE_URL') || 'http://localhost';
25+
const { baseUrl, gotrueUrl, apiUrl } = TestConfig;
26+
27+
before(() => {
28+
logTestEnvironment();
29+
});
2630

2731
beforeEach(() => {
28-
// Handle uncaught exceptions
29-
cy.on('uncaught:exception', () => false);
32+
setupCommonExceptionHandlers();
3033
cy.viewport(1280, 720);
3134
});
3235

cypress/e2e/auth/password-login.cy.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import { v4 as uuidv4 } from 'uuid';
2+
import { TestConfig, logTestEnvironment } from '../../support/test-config';
3+
import { setupCommonExceptionHandlers } from '../../support/exception-handlers';
24

35
describe('Password Login Flow', () => {
4-
const baseUrl = Cypress.config('baseUrl') || 'http://localhost:3000';
5-
const gotrueUrl = Cypress.env('APPFLOWY_GOTRUE_BASE_URL') || 'http://localhost/gotrue';
6-
const apiUrl = Cypress.env('APPFLOWY_BASE_URL') || 'http://localhost';
6+
const { baseUrl, gotrueUrl, apiUrl } = TestConfig;
7+
8+
before(() => {
9+
logTestEnvironment();
10+
});
711

812
beforeEach(() => {
9-
// Handle uncaught exceptions
10-
cy.on('uncaught:exception', () => false);
13+
setupCommonExceptionHandlers();
1114
cy.viewport(1280, 720);
1215
});
1316

0 commit comments

Comments
 (0)