Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions cypress/e2e/account/avatar/avatar-api.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { avatarTestUtils } from './avatar-test-utils';
import { byTestId } from '../../../support/selectors';

const { generateRandomEmail, setupBeforeEach, imports } = avatarTestUtils;
const { updateUserMetadata, AuthTestUtils, AvatarSelectors, WorkspaceSelectors } = imports;
Expand Down Expand Up @@ -37,7 +38,7 @@ describe('Avatar API', () => {
cy.task('log', 'Step 5: Open Account Settings to verify avatar');
WorkspaceSelectors.dropdownTrigger().click();
cy.wait(1000);
cy.get('[data-testid="account-settings-button"]').click();
cy.get(byTestId('account-settings-button')).click();
AvatarSelectors.accountSettingsDialog().should('be.visible');

cy.task('log', 'Step 6: Verify avatar image is displayed in Account Settings');
Expand All @@ -48,7 +49,7 @@ describe('Avatar API', () => {

// Wait for any avatar image to be present and loaded
// The AvatarImage component loads asynchronously and sets opacity to 0 while loading
cy.get('[data-testid="avatar-image"]', { timeout: 10000 })
cy.get(byTestId('avatar-image'), { timeout: 10000 })
.should('exist')
.should(($imgs) => {
// Find the first visible avatar image (opacity not 0)
Expand All @@ -66,7 +67,7 @@ describe('Avatar API', () => {
});

// Verify that the avatar image has loaded (check for non-empty src and visible state)
cy.get('[data-testid="avatar-image"]').then(($imgs) => {
cy.get(byTestId('avatar-image')).then(($imgs) => {
let foundLoaded = false;
$imgs.each((index, img) => {
const $img = Cypress.$(img);
Expand Down Expand Up @@ -158,7 +159,7 @@ describe('Avatar API', () => {
cy.task('log', 'Step 5: Open Account Settings');
WorkspaceSelectors.dropdownTrigger().click();
cy.wait(1000);
cy.get('[data-testid="account-settings-button"]').click();
cy.get(byTestId('account-settings-button')).click();
AvatarSelectors.accountSettingsDialog().should('be.visible');

cy.task('log', 'Step 6: Verify emoji is displayed in fallback');
Expand Down Expand Up @@ -190,4 +191,3 @@ describe('Avatar API', () => {
});
});
});

14 changes: 7 additions & 7 deletions cypress/e2e/account/avatar/avatar-header.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { avatarTestUtils } from './avatar-test-utils';
import { byTestIdContains } from '../../../support/selectors';

const { generateRandomEmail, setupBeforeEach, imports } = avatarTestUtils;
const { APP_EVENTS, updateWorkspaceMemberAvatar, AuthTestUtils, AvatarSelectors, dbUtils } = imports;
Expand Down Expand Up @@ -39,8 +40,8 @@ describe('Avatar Header Display', () => {
// Click on a page to open editor
cy.get('body').then(($body) => {
// Try to find and click on a page in the sidebar
if ($body.find('[data-testid*="page"]').length > 0) {
cy.get('[data-testid*="page"]').first().click();
if ($body.find(byTestIdContains('page')).length > 0) {
cy.get(byTestIdContains('page')).first().click();
} else if ($body.text().includes('Getting started')) {
cy.contains('Getting started').click();
}
Expand Down Expand Up @@ -117,8 +118,8 @@ describe('Avatar Header Display', () => {
cy.task('log', 'Step 4: Interact with editor to trigger collaborative user awareness');
// Click on a page to open editor
cy.get('body').then(($body) => {
if ($body.find('[data-testid*="page"]').length > 0) {
cy.get('[data-testid*="page"]').first().click();
if ($body.find(byTestIdContains('page')).length > 0) {
cy.get(byTestIdContains('page')).first().click();
} else if ($body.text().includes('Getting started')) {
cy.contains('Getting started').click();
}
Expand Down Expand Up @@ -213,8 +214,8 @@ describe('Avatar Header Display', () => {
cy.task('log', 'Step 6: Interact with editor to trigger collaborative user awareness');
// Click on a page to open editor
cy.get('body').then(($body) => {
if ($body.find('[data-testid*="page"]').length > 0) {
cy.get('[data-testid*="page"]').first().click();
if ($body.find(byTestIdContains('page')).length > 0) {
cy.get(byTestIdContains('page')).first().click();
} else if ($body.text().includes('Getting started')) {
cy.contains('Getting started').click();
}
Expand Down Expand Up @@ -263,4 +264,3 @@ describe('Avatar Header Display', () => {
});
});
});

4 changes: 2 additions & 2 deletions cypress/e2e/account/avatar/avatar-notifications.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { avatarTestUtils } from './avatar-test-utils';
import { byTestId } from '../../../support/selectors';

const { generateRandomEmail, setupBeforeEach, imports } = avatarTestUtils;
const { APP_EVENTS, updateWorkspaceMemberAvatar, AuthTestUtils, AvatarSelectors, dbUtils, WorkspaceSelectors } = imports;
Expand Down Expand Up @@ -61,7 +62,7 @@ describe('Avatar Notifications', () => {
cy.task('log', 'Step 7: Open Account Settings to verify avatar');
WorkspaceSelectors.dropdownTrigger().click();
cy.wait(1000);
cy.get('[data-testid="account-settings-button"]').click();
cy.get(byTestId('account-settings-button')).click();
AvatarSelectors.accountSettingsDialog().should('be.visible');

cy.task('log', 'Step 8: Verify avatar image uses updated URL');
Expand Down Expand Up @@ -183,4 +184,3 @@ describe('Avatar Notifications', () => {
});
});
});

6 changes: 3 additions & 3 deletions cypress/e2e/account/avatar/avatar-persistence.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { avatarTestUtils } from './avatar-test-utils';
import { byTestId } from '../../../support/selectors';

const { generateRandomEmail, setupBeforeEach, imports } = avatarTestUtils;
const { updateWorkspaceMemberAvatar, AuthTestUtils, AvatarSelectors, dbUtils, WorkspaceSelectors } = imports;
Expand Down Expand Up @@ -39,7 +40,7 @@ describe('Avatar Persistence', () => {
cy.task('log', 'Step 5: Verify avatar persisted');
WorkspaceSelectors.dropdownTrigger().click();
cy.wait(1000);
cy.get('[data-testid="account-settings-button"]').click();
cy.get(byTestId('account-settings-button')).click();
AvatarSelectors.accountSettingsDialog().should('be.visible');

AvatarSelectors.avatarImage().should('exist').and('have.attr', 'src', testAvatarUrl);
Expand All @@ -50,12 +51,11 @@ describe('Avatar Persistence', () => {

WorkspaceSelectors.dropdownTrigger().click();
cy.wait(1000);
cy.get('[data-testid="account-settings-button"]').click();
cy.get(byTestId('account-settings-button')).click();
AvatarSelectors.accountSettingsDialog().should('be.visible');

AvatarSelectors.avatarImage().should('exist').and('have.attr', 'src', testAvatarUrl);
});
});
});
});

4 changes: 2 additions & 2 deletions cypress/e2e/account/avatar/avatar-priority.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { avatarTestUtils } from './avatar-test-utils';
import { byTestId } from '../../../support/selectors';

const { generateRandomEmail, setupBeforeEach, imports } = avatarTestUtils;
const { updateUserMetadata, updateWorkspaceMemberAvatar, AuthTestUtils, AvatarSelectors, dbUtils, WorkspaceSelectors } = imports;
Expand Down Expand Up @@ -45,7 +46,7 @@ describe('Avatar Priority', () => {
cy.task('log', 'Step 5: Verify workspace avatar is displayed (priority)');
WorkspaceSelectors.dropdownTrigger().click();
cy.wait(1000);
cy.get('[data-testid="account-settings-button"]').click();
cy.get(byTestId('account-settings-button')).click();
AvatarSelectors.accountSettingsDialog().should('be.visible');

// Workspace avatar should be displayed, not user metadata avatar
Expand All @@ -54,4 +55,3 @@ describe('Avatar Priority', () => {
});
});
});

10 changes: 5 additions & 5 deletions cypress/e2e/account/avatar/avatar-test-utils.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import { v4 as uuidv4 } from 'uuid';

import { APP_EVENTS } from '../../../../src/application/constants';

import { updateUserMetadata, updateWorkspaceMemberAvatar } from '../../../support/api-utils';
import { AuthTestUtils } from '../../../support/auth-utils';
import { AvatarSelectors } from '../../../support/avatar-selectors';
import { dbUtils } from '../../../support/db-utils';
import { WorkspaceSelectors } from '../../../support/selectors';
import { generateRandomEmail, getTestEnvironment } from '../../../support/test-config';

const appflowyEnv = getTestEnvironment();

/**
* Shared utilities and setup for avatar tests
*/
export const avatarTestUtils = {
generateRandomEmail: () => `${uuidv4()}@appflowy.io`,
APPFLOWY_BASE_URL: Cypress.env('APPFLOWY_BASE_URL'),
generateRandomEmail,
APPFLOWY_BASE_URL: appflowyEnv.appflowyBaseUrl,

/**
* Common beforeEach setup for avatar tests
Expand Down Expand Up @@ -47,4 +48,3 @@ export const avatarTestUtils = {
WorkspaceSelectors,
},
};

6 changes: 3 additions & 3 deletions cypress/e2e/account/avatar/avatar-types.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { avatarTestUtils } from './avatar-test-utils';
import { byTestId } from '../../../support/selectors';

const { generateRandomEmail, setupBeforeEach, imports } = avatarTestUtils;
const { updateWorkspaceMemberAvatar, AuthTestUtils, AvatarSelectors, dbUtils, WorkspaceSelectors } = imports;
Expand Down Expand Up @@ -36,7 +37,7 @@ describe('Avatar Types', () => {

WorkspaceSelectors.dropdownTrigger().click();
cy.wait(1000);
cy.get('[data-testid="account-settings-button"]').click();
cy.get(byTestId('account-settings-button')).click();
AvatarSelectors.accountSettingsDialog().should('be.visible');

AvatarSelectors.avatarImage().should('exist').and('have.attr', 'src', httpsAvatar);
Expand Down Expand Up @@ -73,7 +74,7 @@ describe('Avatar Types', () => {

WorkspaceSelectors.dropdownTrigger().click();
cy.wait(1000);
cy.get('[data-testid="account-settings-button"]').click();
cy.get(byTestId('account-settings-button')).click();
AvatarSelectors.accountSettingsDialog().should('be.visible');

// Emoji should be displayed in fallback, not as image
Expand All @@ -83,4 +84,3 @@ describe('Avatar Types', () => {
});
});
});

41 changes: 20 additions & 21 deletions cypress/e2e/account/update-user-profile.cy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { v4 as uuidv4 } from 'uuid';
import { AuthTestUtils } from '../../support/auth-utils';
import { WorkspaceSelectors, byTestId } from '../../support/selectors';
import { generateRandomEmail } from '../../support/test-config';

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

beforeEach(() => {
cy.on('uncaught:exception', (err) => {
if (err.message.includes('Minified React error') ||
Expand Down Expand Up @@ -34,70 +33,70 @@ describe('Update User Profile', () => {

// Open workspace dropdown
cy.log('Step 3: Opening workspace dropdown');
cy.get('[data-testid="workspace-dropdown-trigger"]', { timeout: 10000 }).should('be.visible').click();
WorkspaceSelectors.dropdownTrigger().should('be.visible').click();

// Wait for dropdown to open
cy.get('[data-testid="workspace-dropdown-content"]', { timeout: 5000 }).should('be.visible');
WorkspaceSelectors.dropdownContent().should('be.visible');

// Click on Account Settings
cy.log('Step 4: Opening Account Settings');
cy.get('[data-testid="account-settings-button"]').should('be.visible').click();
cy.get(byTestId('account-settings-button')).should('be.visible').click();

// Add a wait to ensure the dialog has time to open
cy.wait(1000);

// Wait for Account Settings dialog to open
cy.log('Step 5: Verifying Account Settings dialog opened');
cy.get('[data-testid="account-settings-dialog"]', { timeout: 10000 }).should('be.visible');
cy.get(byTestId('account-settings-dialog'), { timeout: 10000 }).should('be.visible');

// Check initial date format (should be Month/Day/Year)
cy.log('Step 6: Checking initial date format');
cy.get('[data-testid="date-format-dropdown"]').should('be.visible');
cy.get(byTestId('date-format-dropdown')).should('be.visible');

// Test Date Format change - select Year/Month/Day
cy.log('Step 7: Testing Date Format change to Year/Month/Day');
cy.get('[data-testid="date-format-dropdown"]').click();
cy.get(byTestId('date-format-dropdown')).click();
cy.wait(500);

// Select US format (value 1) which is Year/Month/Day
cy.get('[data-testid="date-format-1"]').should('be.visible').click();
cy.get(byTestId('date-format-1')).should('be.visible').click();
cy.wait(3000); // Wait for API call to complete

// Verify the dropdown now shows Year/Month/Day
cy.get('[data-testid="date-format-dropdown"]').should('contain.text', 'Year/Month/Day');
cy.get(byTestId('date-format-dropdown')).should('contain.text', 'Year/Month/Day');

// Test Time Format change
cy.log('Step 8: Testing Time Format change');
cy.get('[data-testid="time-format-dropdown"]').should('be.visible').click();
cy.get(byTestId('time-format-dropdown')).should('be.visible').click();
cy.wait(500);

// Select 24-hour format (value 1)
cy.get('[data-testid="time-format-1"]').should('be.visible').click();
cy.get(byTestId('time-format-1')).should('be.visible').click();
cy.wait(3000); // Wait for API call to complete

// Verify the dropdown now shows 24-hour format
cy.get('[data-testid="time-format-dropdown"]').should('contain.text', '24');
cy.get(byTestId('time-format-dropdown')).should('contain.text', '24');

// Test Start Week On change
cy.log('Step 9: Testing Start Week On change');
cy.get('[data-testid="start-week-on-dropdown"]').should('be.visible').click();
cy.get(byTestId('start-week-on-dropdown')).should('be.visible').click();
cy.wait(500);

// Select Monday (value 1)
cy.get('[data-testid="start-week-1"]').should('be.visible').click();
cy.get(byTestId('start-week-1')).should('be.visible').click();
cy.wait(3000); // Wait for API call to complete

cy.get('[data-testid="start-week-on-dropdown"]').should('contain.text', 'Monday');
cy.get(byTestId('start-week-on-dropdown')).should('contain.text', 'Monday');

// The settings should remain selected in the current session
cy.log('Step 10: Verifying all settings are showing correctly');

// Verify all dropdowns still show the selected values
cy.get('[data-testid="date-format-dropdown"]').should('contain.text', 'Year/Month/Day');
cy.get('[data-testid="time-format-dropdown"]').should('contain.text', '24');
cy.get('[data-testid="start-week-on-dropdown"]').should('contain.text', 'Monday');
cy.get(byTestId('date-format-dropdown')).should('contain.text', 'Year/Month/Day');
cy.get(byTestId('time-format-dropdown')).should('contain.text', '24');
cy.get(byTestId('start-week-on-dropdown')).should('contain.text', 'Monday');

cy.log('Test completed: User profile settings updated successfully');
});
});
});
});
4 changes: 1 addition & 3 deletions cypress/e2e/app/sidebar-components.cy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { v4 as uuidv4 } from 'uuid';
import { AuthTestUtils } from '../../support/auth-utils';
import { PageSelectors, SidebarSelectors } from '../../support/selectors';
import { generateRandomEmail } from '../../support/test-config';

describe('Sidebar Components Resilience Tests', () => {
const generateRandomEmail = () => `${uuidv4()}@appflowy.io`;
let testEmail: string;

beforeEach(() => {
Expand Down Expand Up @@ -206,4 +205,3 @@ describe('Sidebar Components Resilience Tests', () => {
});
});
});

14 changes: 6 additions & 8 deletions cypress/e2e/auth/login-logout.cy.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { v4 as uuidv4 } from 'uuid';
import { AuthTestUtils } from '../../support/auth-utils';
import { TestTool } from '../../support/page-utils';
import {
WorkspaceSelectors,
AuthSelectors,
waitForReactUpdate
} from '../../support/selectors';
import { TestConfig, generateRandomEmail } from '../../support/test-config';

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

beforeEach(() => {
// Handle uncaught exceptions
Expand All @@ -27,7 +25,7 @@ describe('Login and Logout Flow', () => {

describe('Test Case 1: Complete Login and Logout Flow', () => {
it('should login and successfully logout with detailed verification', () => {
const testEmail = `test-${uuidv4()}@appflowy.io`;
const testEmail = generateRandomEmail();

cy.log(`[TEST START] Complete Login and Logout Flow - Email: ${testEmail}`);

Expand Down Expand Up @@ -103,7 +101,7 @@ describe('Login and Logout Flow', () => {

describe('Test Case 2: Quick Login and Logout using Test URL', () => {
it('should login with test URL and successfully logout', () => {
const testEmail = `test-${uuidv4()}@appflowy.io`;
const testEmail = generateRandomEmail();

cy.log(`[TEST START] Quick Login and Logout using Test URL - Email: ${testEmail}`);

Expand Down Expand Up @@ -167,7 +165,7 @@ describe('Login and Logout Flow', () => {

describe('Test Case 3: Cancel Logout Confirmation', () => {
it('should cancel logout when clicking cancel button', () => {
const testEmail = `test-${uuidv4()}@appflowy.io`;
const testEmail = generateRandomEmail();

cy.log(`[TEST START] Cancel Logout Confirmation - Email: ${testEmail}`);

Expand Down Expand Up @@ -238,4 +236,4 @@ describe('Login and Logout Flow', () => {
});
});
});
});
});
Loading