chore: fix test

This commit is contained in:
nathan
2025-09-10 20:49:41 +08:00
parent 33c9d76425
commit ca30221a29
2 changed files with 67 additions and 10 deletions

View File

@@ -40,12 +40,46 @@ describe('Single Select Column Type', () => {
authUtils.signInWithTestUrl(testEmail).then(() => { authUtils.signInWithTestUrl(testEmail).then(() => {
cy.log('[STEP 3] Authentication successful'); cy.log('[STEP 3] Authentication successful');
cy.url({ timeout: 30000 }).should('include', '/app'); cy.url({ timeout: 30000 }).should('include', '/app');
cy.wait(3000); cy.wait(5000); // Increased wait for CI environment
// Ensure we're on the right page before proceeding
cy.log('[STEP 3.1] Verifying workspace loaded');
cy.get('body').should('exist');
cy.wait(2000);
// Create a new grid // Create a new grid
cy.log('[STEP 4] Creating new grid'); cy.log('[STEP 4] Creating new grid');
AddPageSelectors.inlineAddButton().first().click({ force: true }); cy.log('[STEP 4.1] Waiting for inline add button or new page button');
// Try to find either inline add button or new page button
cy.get('body').then($body => {
const inlineAddExists = $body.find('[data-testid="inline-add-page"]').length > 0;
const newPageExists = $body.find('[data-testid="new-page-button"]').length > 0;
if (inlineAddExists) {
cy.log('[STEP 4.2] Using inline add button');
return cy.wrap(null).then(() => {
AddPageSelectors.inlineAddButton().first().click({ force: true });
});
} else if (newPageExists) {
cy.log('[STEP 4.2] Using new page button instead');
return cy.wrap(null).then(() => {
cy.get('[data-testid="new-page-button"]').first().click({ force: true });
});
} else {
// Wait a bit more and try inline add button
cy.log('[STEP 4.2] Waiting for UI to stabilize');
return cy.wrap(null).then(() => {
cy.wait(3000);
AddPageSelectors.inlineAddButton().should('exist', { timeout: 15000 });
AddPageSelectors.inlineAddButton().first().click({ force: true });
});
}
});
waitForReactUpdate(1000); waitForReactUpdate(1000);
cy.log('[STEP 4.3] Clicking add grid button');
AddPageSelectors.addGridButton().should('exist', { timeout: 10000 });
AddPageSelectors.addGridButton().click({ force: true }); AddPageSelectors.addGridButton().click({ force: true });
cy.wait(8000); cy.wait(8000);
@@ -97,12 +131,21 @@ describe('Single Select Column Type', () => {
authUtils.signInWithTestUrl(testEmail).then(() => { authUtils.signInWithTestUrl(testEmail).then(() => {
cy.log('[STEP 3] Authentication successful'); cy.log('[STEP 3] Authentication successful');
cy.url({ timeout: 30000 }).should('include', '/app'); cy.url({ timeout: 30000 }).should('include', '/app');
cy.wait(3000); cy.wait(5000); // Increased wait for CI environment
// Ensure we're on the right page before proceeding
cy.log('[STEP 3.1] Verifying workspace loaded');
cy.get('body').should('exist');
cy.wait(2000);
// Create a new grid // Create a new grid
cy.log('[STEP 4] Creating new grid'); cy.log('[STEP 4] Creating new grid');
cy.log('[STEP 4.1] Waiting for inline add button');
AddPageSelectors.inlineAddButton().should('exist', { timeout: 15000 });
AddPageSelectors.inlineAddButton().first().scrollIntoView().click({ force: true }); AddPageSelectors.inlineAddButton().first().scrollIntoView().click({ force: true });
waitForReactUpdate(1000); waitForReactUpdate(1000);
cy.log('[STEP 4.2] Clicking add grid button');
AddPageSelectors.addGridButton().should('exist', { timeout: 10000 });
AddPageSelectors.addGridButton().click({ force: true }); AddPageSelectors.addGridButton().click({ force: true });
cy.wait(8000); cy.wait(8000);

View File

@@ -170,13 +170,27 @@ export class AuthTestUtils {
// This endpoint creates the user in the AppFlowy backend // This endpoint creates the user in the AppFlowy backend
cy.task('log', 'Calling verify endpoint to create user profile'); cy.task('log', 'Calling verify endpoint to create user profile');
// Make the verify call - this creates the user profile in AppFlowy backend // Make the verify call with retry logic for CI environment
return cy.request({ const verifyWithRetry = (retries = 3): Cypress.Chainable<any> => {
method: 'GET', return cy.request({
url: `${this.config.baseUrl}/api/user/verify/${accessToken}`, method: 'GET',
failOnStatusCode: false, url: `${this.config.baseUrl}/api/user/verify/${accessToken}`,
}).then((verifyResponse) => { failOnStatusCode: false,
cy.task('log', `Verify response status: ${verifyResponse.status}`); timeout: 30000,
}).then((verifyResponse) => {
cy.task('log', `Verify response status: ${verifyResponse.status}`);
// If we get a 502 or 503 error, retry
if ((verifyResponse.status === 502 || verifyResponse.status === 503) && retries > 0) {
cy.task('log', `Retrying verify endpoint, ${retries} attempts remaining`);
return cy.wait(2000).then(() => verifyWithRetry(retries - 1));
}
return cy.wrap(verifyResponse);
});
};
return verifyWithRetry().then((verifyResponse) => {
// Now refresh the token to get session data // Now refresh the token to get session data
return cy.request({ return cy.request({