chore: fix test

This commit is contained in:
annie
2025-09-03 15:50:57 +08:00
parent d989edac40
commit 24d46493a4
5 changed files with 18 additions and 20 deletions

View File

@@ -1,7 +1,7 @@
import { v4 as uuidv4 } from 'uuid';
import { AuthTestUtils } from '../../support/auth-utils';
import { TestTool } from '../../support/page-utils';
import { PageSelectors, ModalSelectors, waitForReactUpdate } from '../../support/selectors';
import { PageSelectors, ModalSelectors, SidebarSelectors, waitForReactUpdate } from '../../support/selectors';
describe('Page Create and Delete Tests', () => {
const APPFLOWY_BASE_URL = Cypress.env('APPFLOWY_BASE_URL');
@@ -48,10 +48,10 @@ describe('Page Create and Delete Tests', () => {
cy.get('body', { timeout: 30000 }).should('not.contain', 'Welcome!');
// Wait for the sidebar to be visible (indicates app is loaded)
cy.get('[data-testid="sidebar-page-header"]', { timeout: 30000 }).should('be.visible');
SidebarSelectors.pageHeader().should('be.visible', { timeout: 30000 });
// Wait for at least one page to exist in the sidebar
cy.get('[data-testid="page-name"]', { timeout: 30000 }).should('exist');
PageSelectors.names().should('exist', { timeout: 30000 });
// Additional wait for stability
cy.wait(2000);

View File

@@ -54,8 +54,8 @@ describe('More Page Actions', () => {
cy.wait(1000);
// Look for any three-dot menu or more actions button
cy.get('[data-testid*="more"]').first().click({ force: true });
// Look for the more actions button - using PageSelectors
PageSelectors.moreActionsButton().first().click({ force: true });
cy.task('log', 'Clicked more actions button');
@@ -108,8 +108,8 @@ describe('More Page Actions', () => {
cy.wait(1000);
// Look for any three-dot menu or more actions button
cy.get('[data-testid*="more"]').first().click({ force: true });
// Look for the more actions button - using PageSelectors
PageSelectors.moreActionsButton().first().click({ force: true });
cy.task('log', 'Clicked more actions button');
@@ -127,7 +127,7 @@ describe('More Page Actions', () => {
cy.contains('Getting started').should('exist');
// Check if there's a duplicated page (might have a suffix like "(1)" or "(copy)")
cy.get('[data-testid="page-name"]').then($pages => {
PageSelectors.names().then($pages => {
const pageCount = $pages.filter((index, el) =>
el.textContent?.includes('Getting started')).length;
expect(pageCount).to.be.at.least(1);

View File

@@ -1,6 +1,7 @@
import { v4 as uuidv4 } from 'uuid';
import { AuthTestUtils } from '../../support/auth-utils';
import { TestTool } from '../../support/page-utils';
import { SidebarSelectors, PageSelectors, ModalSelectors, SpaceSelectors } from '../../support/selectors';
describe('Publish Page Test', () => {
const APPFLOWY_BASE_URL = Cypress.env('APPFLOWY_BASE_URL');
@@ -37,8 +38,8 @@ describe('Publish Page Test', () => {
// Wait for app to fully load
cy.task('log', 'Waiting for app to fully load...');
cy.get('[data-testid="sidebar-page-header"]', { timeout: 30000 }).should('be.visible');
cy.get('[data-testid="page-name"]', { timeout: 30000 }).should('exist');
SidebarSelectors.pageHeader().should('be.visible', { timeout: 30000 });
PageSelectors.names().should('exist', { timeout: 30000 });
cy.wait(2000);
// 2. create a new page called publish page
@@ -47,13 +48,13 @@ describe('Publish Page Test', () => {
cy.task('log', 'Creating page without content (template issue workaround)');
// Click new page button
cy.get('[data-testid="new-page-button"]').should('be.visible').click();
PageSelectors.newPageButton().should('be.visible').click();
cy.wait(1000);
// Handle the new page modal
cy.get('[data-testid="new-page-modal"]').should('be.visible').within(() => {
ModalSelectors.newPageModal().should('be.visible').within(() => {
// Select the first available space
cy.get('[data-testid="space-item"]').first().click();
SpaceSelectors.items().first().click();
cy.wait(500);
// Click Add button
cy.contains('button', 'Add').click();

View File

@@ -1,7 +1,7 @@
import { v4 as uuidv4 } from 'uuid';
import { AuthTestUtils } from '../../support/auth-utils';
import { TestTool } from '../../support/page-utils';
import { WorkspaceSelectors } from '../../support/selectors';
import { WorkspaceSelectors, SidebarSelectors, PageSelectors } from '../../support/selectors';
describe('User Feature Tests', () => {
const APPFLOWY_BASE_URL = Cypress.env('APPFLOWY_BASE_URL');
@@ -59,13 +59,13 @@ describe('User Feature Tests', () => {
cy.get('body', { timeout: 30000 }).should('not.contain', 'Welcome!');
// Wait for the sidebar to be visible (indicates app is loaded)
cy.get('[data-testid="sidebar-page-header"]', { timeout: 30000 }).should('be.visible');
SidebarSelectors.pageHeader().should('be.visible', { timeout: 30000 });
// Wait for at least one page to exist in the sidebar
cy.get('[data-testid="page-name"]', { timeout: 30000 }).should('exist');
PageSelectors.names().should('exist', { timeout: 30000 });
// Wait for workspace dropdown to be available
cy.get('[data-testid="workspace-dropdown-trigger"]', { timeout: 30000 }).should('be.visible');
WorkspaceSelectors.dropdownTrigger().should('be.visible', { timeout: 30000 });
cy.task('log', 'App fully loaded');

View File

@@ -22,9 +22,6 @@
"test:cy": "cypress run",
"test:integration": "cypress run --spec 'cypress/e2e/**/*.cy.ts'",
"test:integration:user": "cypress run --spec 'cypress/e2e/user/**/*.cy.ts' --headed --browser chrome",
"test:integration:page:create-delete": "cypress run --spec 'cypress/e2e/page/create-delete-page.cy.ts'",
"test:integration:page:edit": "cypress run --spec 'cypress/e2e/page/edit-page.cy.ts' --headed --browser chrome",
"test:integration:publish": "cypress run --spec 'cypress/e2e/publish/**/*.cy.ts'",
"wait:backend": "APPFLOWY_BASE_URL=${APPFLOWY_BASE_URL:-http://localhost} node scripts/wait-for-backend.js",
"coverage": "cross-env COVERAGE=true pnpm run test:unit && cross-env COVERAGE=true pnpm run test:components",
"generate-tokens": "node scripts/system-token/convert-tokens.cjs",