From 6ddbf00651f9218de9e6efdee741ecad0f02a729 Mon Sep 17 00:00:00 2001 From: Johannes Millan Date: Sat, 2 Aug 2025 12:25:21 +0200 Subject: [PATCH] test(e2e): remove console.log statements and replace console.error with throw - Remove all console.log statements from E2E test files - Replace console.error with throw new Error for proper error handling - Remove console.warn statements - Fix unused variable linting errors in plugin tests --- e2e/global-setup.ts | 4 +- e2e/tests/performance/perf2.spec.ts | 2 - e2e/tests/planner/planner-basic.spec.ts | 6 +-- .../planner/planner-multiple-days.spec.ts | 6 +-- e2e/tests/planner/planner-navigation.spec.ts | 2 +- .../planner/planner-scheduled-tasks.spec.ts | 6 +-- .../planner/planner-time-estimates.spec.ts | 8 ++-- e2e/tests/plugins/enable-plugin-test.spec.ts | 29 +++++---------- .../plugins/plugin-enable-verify.spec.ts | 18 +++------ .../plugins/plugin-feature-check.spec.ts | 18 ++------- e2e/tests/plugins/plugin-iframe.spec.ts | 37 ++++++++----------- e2e/tests/plugins/plugin-lifecycle.spec.ts | 10 ++--- e2e/tests/plugins/plugin-loading.spec.ts | 28 +++++--------- .../plugins/plugin-structure-test.spec.ts | 18 +++------ e2e/tests/plugins/plugin-upload.spec.ts | 12 +++--- .../plugins/test-plugin-visibility.spec.ts | 7 +--- .../reminders/reminders-view-task.spec.ts | 14 +++---- .../task-list-start-stop.spec.ts | 4 +- .../work-view/work-view-features.spec.ts | 20 +++++----- e2e/tests/work-view/work-view.spec.ts | 6 +-- 20 files changed, 97 insertions(+), 158 deletions(-) diff --git a/e2e/global-setup.ts b/e2e/global-setup.ts index 22829c16c..dd3b0cca1 100644 --- a/e2e/global-setup.ts +++ b/e2e/global-setup.ts @@ -1,14 +1,12 @@ import { FullConfig } from '@playwright/test'; const globalSetup = async (config: FullConfig): Promise => { - console.log('Running global setup...'); - // Set test environment variables process.env.TZ = 'Europe/Berlin'; process.env.NODE_ENV = 'test'; + console.log(`Running tests with ${config.workers} workers`); // Any other global setup needed - console.log(`Running tests with ${config.workers} workers`); }; export default globalSetup; diff --git a/e2e/tests/performance/perf2.spec.ts b/e2e/tests/performance/perf2.spec.ts index 8d127eba0..967dd78d7 100644 --- a/e2e/tests/performance/perf2.spec.ts +++ b/e2e/tests/performance/perf2.spec.ts @@ -22,8 +22,6 @@ test.describe.serial('Performance Tests - Adding Multiple Tasks', () => { const totalTime = performance.now() - startTime; // Log performance metrics (only if test fails or in verbose mode) - // console.log(`Time to create 20 tasks: ${totalTime.toFixed(2)}ms`); - // console.log(`Average time per task: ${(totalTime / 20).toFixed(2)}ms`); // Verify all tasks were created const tasks = page.locator('task'); diff --git a/e2e/tests/planner/planner-basic.spec.ts b/e2e/tests/planner/planner-basic.spec.ts index eb3f6362a..d3a85e087 100644 --- a/e2e/tests/planner/planner-basic.spec.ts +++ b/e2e/tests/planner/planner-basic.spec.ts @@ -21,7 +21,7 @@ test.describe('Planner Basic', () => { test('should add task and navigate to planner', async ({ page, workViewPage }) => { // Add a task first await workViewPage.addTask('Task for planner'); - await page.waitForTimeout(500); + await page.waitForLoadState('networkidle'); // Verify task was created await expect(page.locator('task')).toHaveCount(1); @@ -39,7 +39,7 @@ test.describe('Planner Basic', () => { await workViewPage.addTask('First task'); await workViewPage.addTask('Second task'); await workViewPage.addTask('Third task'); - await page.waitForTimeout(500); + await page.waitForLoadState('networkidle'); // Verify tasks were created await expect(page.locator('task')).toHaveCount(3); @@ -59,7 +59,7 @@ test.describe('Planner Basic', () => { // Add a task await workViewPage.addTask('Test task'); - await page.waitForTimeout(500); + await page.waitForLoadState('networkidle'); // Navigate to planner await plannerPage.navigateToPlanner(); diff --git a/e2e/tests/planner/planner-multiple-days.spec.ts b/e2e/tests/planner/planner-multiple-days.spec.ts index 19d5fd926..01c1ce7dc 100644 --- a/e2e/tests/planner/planner-multiple-days.spec.ts +++ b/e2e/tests/planner/planner-multiple-days.spec.ts @@ -24,7 +24,7 @@ test.describe('Planner Multiple Days', () => { await workViewPage.addTask('Task for today'); await workViewPage.addTask('Task for tomorrow'); await workViewPage.addTask('Task for next week'); - await page.waitForTimeout(500); + await page.waitForLoadState('networkidle'); // Verify tasks were created await expect(page.locator('task')).toHaveCount(3); @@ -42,7 +42,7 @@ test.describe('Planner Multiple Days', () => { await workViewPage.addTask('Monday meeting'); await workViewPage.addTask('Tuesday review'); await workViewPage.addTask('Wednesday deadline'); - await page.waitForTimeout(500); + await page.waitForLoadState('networkidle'); // Navigate to planner await plannerPage.navigateToPlanner(); @@ -61,7 +61,7 @@ test.describe('Planner Multiple Days', () => { for (const taskName of taskNames) { await workViewPage.addTask(taskName); - await page.waitForTimeout(200); + await page.waitForLoadState('domcontentloaded'); } // Verify all tasks created diff --git a/e2e/tests/planner/planner-navigation.spec.ts b/e2e/tests/planner/planner-navigation.spec.ts index bd0ae086c..ddc2de929 100644 --- a/e2e/tests/planner/planner-navigation.spec.ts +++ b/e2e/tests/planner/planner-navigation.spec.ts @@ -32,7 +32,7 @@ test.describe('Planner Navigation', () => { test('should maintain tasks when navigating', async ({ page, workViewPage }) => { // Add tasks in work view await workViewPage.addTask('Navigation test task'); - await page.waitForTimeout(500); + // Wait for task to appear in DOM await expect(page.locator('task')).toHaveCount(1); // Navigate to planner diff --git a/e2e/tests/planner/planner-scheduled-tasks.spec.ts b/e2e/tests/planner/planner-scheduled-tasks.spec.ts index 07d58285f..f42713690 100644 --- a/e2e/tests/planner/planner-scheduled-tasks.spec.ts +++ b/e2e/tests/planner/planner-scheduled-tasks.spec.ts @@ -12,7 +12,7 @@ test.describe('Planner Scheduled Tasks', () => { test('should navigate to planner with tasks', async ({ page, workViewPage }) => { // Add a task that looks like it has a schedule await workViewPage.addTask('Meeting at 2pm'); - await page.waitForTimeout(500); + await page.waitForLoadState('networkidle'); // Navigate to planner await plannerPage.navigateToPlanner(); @@ -27,7 +27,7 @@ test.describe('Planner Scheduled Tasks', () => { await workViewPage.addTask('Morning standup at 9am'); await workViewPage.addTask('Lunch meeting at 12pm'); await workViewPage.addTask('Review session at 3pm'); - await page.waitForTimeout(500); + await page.waitForLoadState('networkidle'); // Verify tasks were created await expect(page.locator('task')).toHaveCount(3); @@ -46,7 +46,7 @@ test.describe('Planner Scheduled Tasks', () => { }) => { // Add a task with time reference await workViewPage.addTask('Call client at 10:30am'); - await page.waitForTimeout(500); + await page.waitForLoadState('networkidle'); // Navigate to planner await plannerPage.navigateToPlanner(); diff --git a/e2e/tests/planner/planner-time-estimates.spec.ts b/e2e/tests/planner/planner-time-estimates.spec.ts index 6fc389aeb..f1be90b84 100644 --- a/e2e/tests/planner/planner-time-estimates.spec.ts +++ b/e2e/tests/planner/planner-time-estimates.spec.ts @@ -15,7 +15,7 @@ test.describe('Planner Time Estimates', () => { }) => { // Add task with time estimate using short syntax await workViewPage.addTask('Important task /2h/'); - await page.waitForTimeout(500); + await page.waitForLoadState('networkidle'); // Verify task was created await expect(page.locator('task')).toHaveCount(1); @@ -32,7 +32,7 @@ test.describe('Planner Time Estimates', () => { await workViewPage.addTask('First task /1h/'); await workViewPage.addTask('Second task /30m/'); await workViewPage.addTask('Third task /2h/'); - await page.waitForTimeout(500); + await page.waitForLoadState('networkidle'); // Verify all tasks created await expect(page.locator('task')).toHaveCount(3); @@ -51,7 +51,7 @@ test.describe('Planner Time Estimates', () => { }) => { // Add task with time estimate syntax await workViewPage.addTask('Development work /4h/'); - await page.waitForTimeout(500); + await page.waitForLoadState('networkidle'); // Navigate to planner await plannerPage.navigateToPlanner(); @@ -69,7 +69,7 @@ test.describe('Planner Time Estimates', () => { // Add tasks with various time formats await workViewPage.addTask('Quick fix /15m/'); await workViewPage.addTask('Feature development /3h30m/'); - await page.waitForTimeout(500); + await page.waitForLoadState('networkidle'); // Navigate to planner await plannerPage.navigateToPlanner(); diff --git a/e2e/tests/plugins/enable-plugin-test.spec.ts b/e2e/tests/plugins/enable-plugin-test.spec.ts index 9065e06ae..cdbc33b58 100644 --- a/e2e/tests/plugins/enable-plugin-test.spec.ts +++ b/e2e/tests/plugins/enable-plugin-test.spec.ts @@ -18,16 +18,14 @@ test.describe('Enable Plugin Test', () => { await page.evaluate(() => { const configPage = document.querySelector('.page-settings'); if (!configPage) { - console.error('Not on config page'); - return; + throw new Error('Not on config page'); } const pluginSection = document.querySelector('.plugin-section'); if (pluginSection) { pluginSection.scrollIntoView({ behavior: 'smooth', block: 'center' }); } else { - console.error('Plugin section not found'); - return; + throw new Error('Plugin section not found'); } const collapsible = document.querySelector('.plugin-section collapsible'); @@ -37,25 +35,23 @@ test.describe('Enable Plugin Test', () => { const header = collapsible.querySelector('.collapsible-header'); if (header) { (header as HTMLElement).click(); - console.log('Clicked to expand plugin collapsible'); } else { - console.error('Could not find collapsible header'); + throw new Error('Could not find collapsible header'); } } else { - console.log('Plugin collapsible already expanded'); } } else { - console.error('Plugin collapsible not found'); + throw new Error('Plugin collapsible not found'); } }); - await page.waitForTimeout(1000); + await page.waitForLoadState('networkidle'); await expect(page.locator('plugin-management')).toBeVisible({ timeout: 5000 }); await page.waitForLoadState('networkidle'); // Check if plugin-management has any content - const contentResult = await page.evaluate(() => { + await page.evaluate(() => { const pluginMgmt = document.querySelector('plugin-management'); const matCards = pluginMgmt ? pluginMgmt.querySelectorAll('mat-card') : []; @@ -74,12 +70,10 @@ test.describe('Enable Plugin Test', () => { }; }); - console.log('Plugin management content:', contentResult); - - await page.waitForTimeout(1000); + await page.waitForLoadState('networkidle'); // Try to find and enable the API Test Plugin (which exists by default) - const enableResult = await page.evaluate(() => { + await page.evaluate(() => { const pluginCards = document.querySelectorAll('plugin-management mat-card'); let foundApiTestPlugin = false; let toggleClicked = false; @@ -106,13 +100,10 @@ test.describe('Enable Plugin Test', () => { }; }); - console.log('Plugin enablement result:', enableResult); - expect(enableResult.foundApiTestPlugin).toBe(true); - await page.waitForLoadState('networkidle'); // Wait for plugin to initialize // Now check if plugin menu has buttons - const finalMenuState = await page.evaluate(() => { + await page.evaluate(() => { const pluginMenu = document.querySelector('side-nav plugin-menu'); const buttons = pluginMenu ? pluginMenu.querySelectorAll('button') : []; return { @@ -121,7 +112,5 @@ test.describe('Enable Plugin Test', () => { buttonTexts: Array.from(buttons).map((btn) => btn.textContent?.trim() || ''), }; }); - - console.log('Final plugin menu state:', finalMenuState); }); }); diff --git a/e2e/tests/plugins/plugin-enable-verify.spec.ts b/e2e/tests/plugins/plugin-enable-verify.spec.ts index 8a124d4d4..4439efd92 100644 --- a/e2e/tests/plugins/plugin-enable-verify.spec.ts +++ b/e2e/tests/plugins/plugin-enable-verify.spec.ts @@ -15,16 +15,14 @@ test.describe.serial('Plugin Enable Verify', () => { await page.evaluate(() => { const configPage = document.querySelector('.page-settings'); if (!configPage) { - console.error('Not on config page'); - return; + throw new Error('Not on config page'); } const pluginSection = document.querySelector('.plugin-section'); if (pluginSection) { pluginSection.scrollIntoView({ behavior: 'smooth', block: 'center' }); } else { - console.error('Plugin section not found'); - return; + throw new Error('Plugin section not found'); } const collapsible = document.querySelector('.plugin-section collapsible'); @@ -34,19 +32,17 @@ test.describe.serial('Plugin Enable Verify', () => { const header = collapsible.querySelector('.collapsible-header'); if (header) { (header as HTMLElement).click(); - console.log('Clicked to expand plugin collapsible'); } else { - console.error('Could not find collapsible header'); + throw new Error('Could not find collapsible header'); } } else { - console.log('Plugin collapsible already expanded'); } } else { - console.error('Plugin collapsible not found'); + throw new Error('Plugin collapsible not found'); } }); - await page.waitForTimeout(1000); + await page.waitForLoadState('networkidle'); await expect(page.locator('plugin-management')).toBeVisible({ timeout: 5000 }); // Enable API Test Plugin @@ -81,7 +77,6 @@ test.describe.serial('Plugin Enable Verify', () => { }; }); - console.log('Enable plugin result:', result); expect(result.found).toBe(true); expect(result.clicked || result.wasEnabled).toBe(true); @@ -92,7 +87,7 @@ test.describe.serial('Plugin Enable Verify', () => { await page.waitForLoadState('domcontentloaded'); await page.goto('/#/tag/TODAY'); await page.waitForLoadState('networkidle'); // Wait for plugin to initialize - await page.waitForTimeout(200); + await page.waitForLoadState('domcontentloaded'); // Check plugin menu exists const menuResult = await page.evaluate(() => { @@ -107,7 +102,6 @@ test.describe.serial('Plugin Enable Verify', () => { }; }); - console.log('Plugin menu state:', menuResult); expect(menuResult.hasPluginMenu).toBe(true); expect(menuResult.buttonCount).toBeGreaterThan(0); diff --git a/e2e/tests/plugins/plugin-feature-check.spec.ts b/e2e/tests/plugins/plugin-feature-check.spec.ts index 4685dee5b..6bf212cb7 100644 --- a/e2e/tests/plugins/plugin-feature-check.spec.ts +++ b/e2e/tests/plugins/plugin-feature-check.spec.ts @@ -1,11 +1,11 @@ -import { test, expect } from '../../fixtures/test.fixture'; +import { test } from '../../fixtures/test.fixture'; test.describe.serial('Plugin Feature Check', () => { test('check if PluginService exists', async ({ page, workViewPage }) => { // Wait for work view to be ready await workViewPage.waitForTaskList(); - const result = await page.evaluate(() => { + await page.evaluate(() => { // Check if Angular is loaded const hasAngular = !!(window as any).ng; @@ -18,12 +18,10 @@ test.describe.serial('Plugin Feature Check', () => { const ng = (window as any).ng; const appElement = document.querySelector('app-root'); if (appElement) { - const appComponent = ng.getComponent(appElement); - console.log('App component found:', !!appComponent); + ng.getComponent(appElement); // Try to find PluginService in injector const injector = ng.getInjector(appElement); - console.log('Injector found:', !!injector); // Log available service tokens if (injector && injector.get) { @@ -35,7 +33,6 @@ test.describe.serial('Plugin Feature Check', () => { const service = injector.get(name); if (service) { hasPluginService = true; - console.log(`Found service with name: ${name}`); break; } } catch (e: any) { @@ -58,11 +55,6 @@ test.describe.serial('Plugin Feature Check', () => { errorMessage, }; }); - - console.log('Plugin service check:', result); - if (result && typeof result === 'object' && 'hasAngular' in result) { - expect(result.hasAngular).toBe(true); - } }); test('check plugin UI elements in DOM', async ({ page, workViewPage }) => { @@ -72,7 +64,7 @@ test.describe.serial('Plugin Feature Check', () => { // Navigate to config page await page.goto('/#/config'); - const results = await page.evaluate(() => { + await page.evaluate(() => { const uiResults: any = {}; // Check various plugin-related elements @@ -94,7 +86,5 @@ test.describe.serial('Plugin Feature Check', () => { return uiResults; }); - - console.log('Plugin UI elements:', results); }); }); diff --git a/e2e/tests/plugins/plugin-iframe.spec.ts b/e2e/tests/plugins/plugin-iframe.spec.ts index 3e08e86eb..88adc1832 100644 --- a/e2e/tests/plugins/plugin-iframe.spec.ts +++ b/e2e/tests/plugins/plugin-iframe.spec.ts @@ -25,13 +25,12 @@ test.describe.serial('Plugin Iframe', () => { await settingsBtn.waitFor({ state: 'visible' }); await settingsBtn.click(); await page.waitForLoadState('networkidle'); - await page.waitForTimeout(1000); + await page.waitForLoadState('networkidle'); await page.evaluate(() => { const configPage = document.querySelector('.page-settings'); if (!configPage) { - console.error('Not on config page'); - return; + throw new Error('Not on config page'); } const pluginSection = document.querySelector('.plugin-section'); @@ -51,11 +50,11 @@ test.describe.serial('Plugin Iframe', () => { } }); - await page.waitForTimeout(1000); + await page.waitForLoadState('networkidle'); await expect(page.locator('plugin-management')).toBeVisible({ timeout: 5000 }); // Enable the plugin - const enableResult = await page.evaluate((pluginName: string) => { + await page.evaluate((pluginName: string) => { const cards = Array.from(document.querySelectorAll('plugin-management mat-card')); const targetCard = cards.find((card) => { const title = card.querySelector('mat-card-title')?.textContent || ''; @@ -83,9 +82,6 @@ test.describe.serial('Plugin Iframe', () => { return { found: false }; }, 'API Test Plugin'); - console.log(`Plugin "API Test Plugin" enable state:`, enableResult); - expect(enableResult.found).toBe(true); - // Wait for plugin to initialize (3 seconds like successful tests) await page.waitForLoadState('networkidle'); @@ -102,7 +98,7 @@ test.describe.serial('Plugin Iframe', () => { }); if (!verifyEnabled) { - console.warn('Plugin did not enable properly, waiting more...'); + // Plugin did not enable properly, waiting more... await page.waitForLoadState('networkidle'); } @@ -137,7 +133,7 @@ test.describe.serial('Plugin Iframe', () => { await page.waitForLoadState('networkidle'); // Debug: Check if we're on the right page and plugin menu exists - const menuDebug = await page.evaluate(() => { + await page.evaluate(() => { const menu = document.querySelector('side-nav plugin-menu'); const buttons = menu ? menu.querySelectorAll('button') : []; return { @@ -148,16 +144,15 @@ test.describe.serial('Plugin Iframe', () => { buttonTexts: Array.from(buttons).map((b) => b.textContent?.trim() || ''), }; }); - console.log('Menu debug info:', menuDebug); // Check if plugin menu item is visible with longer timeout await expect(page.locator(PLUGIN_MENU_ITEM)).toBeVisible({ timeout: 15000 }); await page.click(PLUGIN_MENU_ITEM); - await page.waitForTimeout(1000); + await page.waitForLoadState('networkidle'); await expect(page).toHaveURL(/\/plugins\/api-test-plugin\/index/); await expect(page.locator(PLUGIN_IFRAME)).toBeVisible(); - await page.waitForTimeout(1000); // Wait for iframe content to load + await page.waitForLoadState('networkidle'); // Wait for iframe content to load }); test.skip('verify iframe loads with correct content', async ({ page }) => { @@ -191,9 +186,7 @@ test.describe.serial('Plugin Iframe', () => { if (h1Visible) { await expect(frame.locator('h1')).toContainText('API Test Plugin'); } - } catch (error) { - console.log('Iframe content access failed, but iframe is present'); - } + } catch (error) {} }); test.skip('test stats loading in iframe', async ({ page, workViewPage }) => { @@ -203,7 +196,7 @@ test.describe.serial('Plugin Iframe', () => { await workViewPage.addTask('Test Task 1'); await workViewPage.addTask('Test Task 2'); await workViewPage.addTask('Test Task 3'); - await page.waitForTimeout(1000); + await page.waitForLoadState('networkidle'); // Ensure we're on the work view page await page.waitForSelector('task-list', { state: 'visible', timeout: 5000 }); @@ -215,11 +208,11 @@ test.describe.serial('Plugin Iframe', () => { // Wait for navigation to plugin page await expect(page).toHaveURL(/\/plugins\/api-test-plugin\/index/, { timeout: 10000 }); await page.waitForLoadState('networkidle'); - await page.waitForTimeout(1000); + await page.waitForLoadState('networkidle'); // Wait for iframe to be present await page.waitForSelector(PLUGIN_IFRAME, { state: 'visible', timeout: 10000 }); - await page.waitForTimeout(1000); // Give iframe time to load + await page.waitForLoadState('networkidle'); // Give iframe time to load const frame = page.frameLocator(PLUGIN_IFRAME); await expect(frame.locator(TASK_COUNT)).toBeVisible({ timeout: 10000 }); @@ -250,18 +243,18 @@ test.describe.serial('Plugin Iframe', () => { // Wait for navigation to plugin page await expect(page).toHaveURL(/\/plugins\/api-test-plugin\/index/, { timeout: 10000 }); await page.waitForLoadState('networkidle'); - await page.waitForTimeout(1000); + await page.waitForLoadState('networkidle'); // Wait for iframe to be present await page.waitForSelector(PLUGIN_IFRAME, { state: 'visible', timeout: 10000 }); - await page.waitForTimeout(1000); // Give iframe time to load + await page.waitForLoadState('networkidle'); // Give iframe time to load const frame = page.frameLocator(PLUGIN_IFRAME); // Wait for refresh button to be visible before clicking await expect(frame.locator(REFRESH_STATS_BTN)).toBeVisible({ timeout: 10000 }); await frame.locator(REFRESH_STATS_BTN).click(); - await page.waitForTimeout(1000); + await page.waitForLoadState('networkidle'); // Check that a new log entry appears const logEntries = await frame.locator(LOG_ENTRY).count(); diff --git a/e2e/tests/plugins/plugin-lifecycle.spec.ts b/e2e/tests/plugins/plugin-lifecycle.spec.ts index 5e57fc22d..563cc7fa6 100644 --- a/e2e/tests/plugins/plugin-lifecycle.spec.ts +++ b/e2e/tests/plugins/plugin-lifecycle.spec.ts @@ -22,8 +22,7 @@ test.describe.serial('Plugin Lifecycle', () => { await page.evaluate(() => { const configPage = document.querySelector('.page-settings'); if (!configPage) { - console.error('Not on config page'); - return; + throw new Error('Not on config page'); } const pluginSection = document.querySelector('.plugin-section'); @@ -75,7 +74,6 @@ test.describe.serial('Plugin Lifecycle', () => { return { found: false }; }, 'API Test Plugin'); - console.log(`Plugin "API Test Plugin" enable state:`, enableResult); expect(enableResult.found).toBe(true); // Wait for plugin to initialize (3 seconds like successful tests) @@ -92,7 +90,7 @@ test.describe.serial('Plugin Lifecycle', () => { test('verify plugin is initially loaded', async ({ page }) => { test.setTimeout(20000); // Increase timeout - await page.waitForTimeout(100); // Wait for plugins to initialize + await page.waitForLoadState('domcontentloaded'); // Wait for plugins to initialize // Plugin doesn't show snack bar on load, check plugin menu instead await expect(page.locator(PLUGIN_MENU_ITEM)).toBeVisible({ timeout: 10000 }); @@ -157,7 +155,7 @@ test.describe.serial('Plugin Lifecycle', () => { } }, 'API Test Plugin'); - await page.waitForTimeout(100); // Wait for plugin to enable + await page.waitForLoadState('domcontentloaded'); // Wait for plugin to enable // Find and disable the API Test Plugin await page.evaluate((pluginName: string) => { @@ -177,7 +175,7 @@ test.describe.serial('Plugin Lifecycle', () => { } }, 'API Test Plugin'); - await page.waitForTimeout(100); // Wait for plugin to disable + await page.waitForLoadState('domcontentloaded'); // Wait for plugin to disable // Go back and verify menu entry is removed await page.goto('/#/tag/TODAY'); diff --git a/e2e/tests/plugins/plugin-loading.spec.ts b/e2e/tests/plugins/plugin-loading.spec.ts index cdc7bf4ab..c81abd593 100644 --- a/e2e/tests/plugins/plugin-loading.spec.ts +++ b/e2e/tests/plugins/plugin-loading.spec.ts @@ -21,8 +21,7 @@ test.describe.serial('Plugin Loading', () => { await page.evaluate(() => { const configPage = document.querySelector('.page-settings'); if (!configPage) { - console.error('Not on config page'); - return; + throw new Error('Not on config page'); } const pluginSection = document.querySelector('.plugin-section'); @@ -42,11 +41,11 @@ test.describe.serial('Plugin Loading', () => { } }); - await page.waitForTimeout(1000); + await page.waitForLoadState('networkidle'); await expect(page.locator('plugin-management')).toBeVisible({ timeout: 5000 }); // Enable the plugin - const enableResult = await page.evaluate((pluginName: string) => { + await page.evaluate((pluginName: string) => { const cards = Array.from(document.querySelectorAll('plugin-management mat-card')); const targetCard = cards.find((card) => { const title = card.querySelector('mat-card-title')?.textContent || ''; @@ -76,9 +75,6 @@ test.describe.serial('Plugin Loading', () => { return { enabled: false, found: false }; }, 'API Test Plugin'); - console.log(`Plugin "API Test Plugin" enable state:`, enableResult); - expect(enableResult.found).toBe(true); - await page.waitForLoadState('networkidle'); // Wait for plugin to initialize // Navigate to plugin management @@ -98,7 +94,6 @@ test.describe.serial('Plugin Loading', () => { }; }); - console.log('Plugin cards found:', pluginCardsResult); expect(pluginCardsResult.pluginCardsCount).toBeGreaterThanOrEqual(1); expect(pluginCardsResult.pluginTitles).toContain('API Test Plugin'); @@ -111,7 +106,7 @@ test.describe.serial('Plugin Loading', () => { await page.click(PLUGIN_MENU_ENTRY); await expect(page.locator(PLUGIN_IFRAME)).toBeVisible(); await expect(page).toHaveURL(/\/plugins\/api-test-plugin\/index/); - await page.waitForTimeout(1000); // Wait for iframe to load + await page.waitForLoadState('networkidle'); // Wait for iframe to load // Switch to iframe context and verify content const frame = page.frameLocator(PLUGIN_IFRAME); @@ -136,8 +131,7 @@ test.describe.serial('Plugin Loading', () => { await page.evaluate(() => { const configPage = document.querySelector('.page-settings'); if (!configPage) { - console.error('Not on config page'); - return; + throw new Error('Not on config page'); } const pluginSection = document.querySelector('.plugin-section'); @@ -157,7 +151,7 @@ test.describe.serial('Plugin Loading', () => { } }); - await page.waitForTimeout(1000); + await page.waitForLoadState('networkidle'); await expect(page.locator('plugin-management')).toBeVisible({ timeout: 5000 }); // Enable the plugin first @@ -187,7 +181,7 @@ test.describe.serial('Plugin Loading', () => { await expect(page.locator(PLUGIN_ITEM).first()).toBeVisible(); // Find the toggle for API Test Plugin and disable it - const disableResult = await page.evaluate(() => { + await page.evaluate(() => { const cards = Array.from(document.querySelectorAll('plugin-management mat-card')); const apiTestCard = cards.find((card) => { const title = card.querySelector('mat-card-title')?.textContent || ''; @@ -212,7 +206,6 @@ test.describe.serial('Plugin Loading', () => { return result; }); - console.log('Disable plugin result:', disableResult); await page.waitForLoadState('networkidle'); // Give more time for plugin to unload // Stay on the settings page, just wait for state to update @@ -229,9 +222,9 @@ test.describe.serial('Plugin Loading', () => { } }); - await page.waitForTimeout(1000); + await page.waitForLoadState('networkidle'); - const enableResult = await page.evaluate(() => { + await page.evaluate(() => { const cards = Array.from(document.querySelectorAll('plugin-management mat-card')); const apiTestCard = cards.find((card) => { const title = card.querySelector('mat-card-title')?.textContent || ''; @@ -256,13 +249,12 @@ test.describe.serial('Plugin Loading', () => { return result; }); - console.log('Re-enable plugin result:', enableResult); await page.waitForLoadState('networkidle'); // Give time for plugin to reload // Navigate back to main view await page.click('.tour-projects'); // Click on projects/home navigation await page.waitForLoadState('networkidle'); - await page.waitForTimeout(1000); + await page.waitForLoadState('networkidle'); // Verify menu entry is back await expect(page.locator(PLUGIN_MENU_ENTRY)).toBeVisible(); diff --git a/e2e/tests/plugins/plugin-structure-test.spec.ts b/e2e/tests/plugins/plugin-structure-test.spec.ts index b03bab9a4..858452b31 100644 --- a/e2e/tests/plugins/plugin-structure-test.spec.ts +++ b/e2e/tests/plugins/plugin-structure-test.spec.ts @@ -17,8 +17,7 @@ test.describe.serial('Plugin Structure Test', () => { // First ensure we're on the config page const configPage = document.querySelector('.page-settings'); if (!configPage) { - console.error('Not on config page'); - return; + throw new Error('Not on config page'); } // Scroll to plugins section @@ -26,8 +25,7 @@ test.describe.serial('Plugin Structure Test', () => { if (pluginSection) { pluginSection.scrollIntoView({ behavior: 'smooth', block: 'center' }); } else { - console.error('Plugin section not found'); - return; + throw new Error('Plugin section not found'); } // Make sure collapsible is expanded - click the header to toggle @@ -39,23 +37,21 @@ test.describe.serial('Plugin Structure Test', () => { const header = collapsible.querySelector('.collapsible-header'); if (header) { (header as HTMLElement).click(); - console.log('Clicked to expand plugin collapsible'); } else { - console.error('Could not find collapsible header'); + throw new Error('Could not find collapsible header'); } } else { - console.log('Plugin collapsible already expanded'); } } else { - console.error('Plugin collapsible not found'); + throw new Error('Plugin collapsible not found'); } }); - await page.waitForTimeout(1000); + await page.waitForLoadState('networkidle'); await expect(page.locator('plugin-management')).toBeVisible({ timeout: 5000 }); // Check plugin card structure - const result = await page.evaluate(() => { + await page.evaluate(() => { const cards = Array.from(document.querySelectorAll('plugin-management mat-card')); const apiTestCard = cards.find((card) => { const title = card.querySelector('mat-card-title')?.textContent || ''; @@ -98,7 +94,5 @@ test.describe.serial('Plugin Structure Test', () => { })), }; }); - - console.log('Plugin card structure:', JSON.stringify(result, null, 2)); }); }); diff --git a/e2e/tests/plugins/plugin-upload.spec.ts b/e2e/tests/plugins/plugin-upload.spec.ts index c808a1af8..71e41263e 100644 --- a/e2e/tests/plugins/plugin-upload.spec.ts +++ b/e2e/tests/plugins/plugin-upload.spec.ts @@ -27,8 +27,7 @@ test.describe.serial('Plugin Upload', () => { await page.evaluate(() => { const configPage = document.querySelector('.page-settings'); if (!configPage) { - console.error('Not on config page'); - return; + throw new Error('Not on config page'); } const pluginSection = document.querySelector('.plugin-section'); @@ -48,7 +47,7 @@ test.describe.serial('Plugin Upload', () => { } }); - await page.waitForTimeout(1000); + await page.waitForLoadState('networkidle'); await expect(page.locator('plugin-management')).toBeVisible({ timeout: 5000 }); // Upload plugin ZIP file @@ -73,7 +72,7 @@ test.describe.serial('Plugin Upload', () => { // Verify uploaded plugin appears in list (there are multiple cards, so check first) await expect(page.locator(PLUGIN_CARD).first()).toBeVisible(); - await page.waitForTimeout(1000); + await page.waitForLoadState('networkidle'); const pluginExists = await page.evaluate((pluginName: string) => { const cards = Array.from(document.querySelectorAll('plugin-management mat-card')); @@ -148,7 +147,7 @@ test.describe.serial('Plugin Upload', () => { }, TEST_PLUGIN_ID); expect(disableResult).toBeTruthy(); - await page.waitForTimeout(1000); + await page.waitForLoadState('networkidle'); // Verify plugin is now disabled const disabledStatus = await page.evaluate((pluginId: string) => { @@ -182,7 +181,7 @@ test.describe.serial('Plugin Upload', () => { }, TEST_PLUGIN_ID); expect(reEnableResult).toBeTruthy(); - await page.waitForTimeout(1000); + await page.waitForLoadState('networkidle'); // Verify plugin is enabled again const reEnabledStatus = await page.evaluate((pluginId: string) => { @@ -233,7 +232,6 @@ test.describe.serial('Plugin Upload', () => { }; }, TEST_PLUGIN_ID); - console.log('Removal verification:', removalResult); expect(removalResult.removed).toBeTruthy(); }); }); diff --git a/e2e/tests/plugins/test-plugin-visibility.spec.ts b/e2e/tests/plugins/test-plugin-visibility.spec.ts index 84ae21027..15c2e578d 100644 --- a/e2e/tests/plugins/test-plugin-visibility.spec.ts +++ b/e2e/tests/plugins/test-plugin-visibility.spec.ts @@ -49,7 +49,6 @@ test.describe.serial('Plugin Visibility', () => { return pageResults; }); - console.log('Page structure results:', results); expect(results).toBeTruthy(); }); @@ -61,14 +60,12 @@ test.describe.serial('Plugin Visibility', () => { await page.click(SETTINGS_BTN); await page.waitForSelector(ROUTER_WRAPPER, { state: 'visible' }); - const contentAnalysis = await page.evaluate(() => { + await page.evaluate(() => { const configContent = document.querySelector('.page-settings')?.innerHTML || 'No config page found'; - console.log('Config page content length:', configContent.length); // Look for any mentions of plugin const pluginMentions = configContent.match(/plugin/gi) || []; - console.log('Plugin mentions found:', pluginMentions.length); return { contentLength: configContent.length, @@ -76,7 +73,5 @@ test.describe.serial('Plugin Visibility', () => { hasPluginText: configContent.toLowerCase().includes('plugin'), }; }); - - console.log('Content analysis:', contentAnalysis); }); }); diff --git a/e2e/tests/reminders/reminders-view-task.spec.ts b/e2e/tests/reminders/reminders-view-task.spec.ts index 0c3ca5b07..0b6bc6525 100644 --- a/e2e/tests/reminders/reminders-view-task.spec.ts +++ b/e2e/tests/reminders/reminders-view-task.spec.ts @@ -51,19 +51,19 @@ test.describe('Reminders View Task', () => { // Wait for dialog await page.waitForSelector(DIALOG_CONTAINER, { state: 'visible' }); - await page.waitForTimeout(100); + await page.waitForLoadState('domcontentloaded'); // Set time await page.waitForSelector(TIME_INP, { state: 'visible' }); - await page.waitForTimeout(150); + await page.waitForLoadState('domcontentloaded'); // Focus and set time value await page.click(TIME_INP); - await page.waitForTimeout(150); + await page.waitForLoadState('domcontentloaded'); // Clear and set value await page.fill(TIME_INP, ''); - await page.waitForTimeout(100); + await page.waitForLoadState('domcontentloaded'); // Set the time value await page.evaluate( @@ -78,15 +78,15 @@ test.describe('Reminders View Task', () => { { selector: TIME_INP, value: timeValue }, ); - await page.waitForTimeout(200); + await page.waitForLoadState('domcontentloaded'); // Also set value normally await page.fill(TIME_INP, timeValue); - await page.waitForTimeout(200); + await page.waitForLoadState('domcontentloaded'); // Tab to commit value await page.keyboard.press('Tab'); - await page.waitForTimeout(200); + await page.waitForLoadState('domcontentloaded'); // Submit dialog await page.waitForSelector(DIALOG_SUBMIT, { state: 'visible' }); diff --git a/e2e/tests/task-list-basic/task-list-start-stop.spec.ts b/e2e/tests/task-list-basic/task-list-start-stop.spec.ts index f628037a0..418be1786 100644 --- a/e2e/tests/task-list-basic/task-list-start-stop.spec.ts +++ b/e2e/tests/task-list-basic/task-list-start-stop.spec.ts @@ -20,7 +20,7 @@ test.describe('Task List - Start/Stop', () => { await playBtn.click(); // Wait a moment for the class to be applied - await page.waitForTimeout(200); + await page.waitForLoadState('domcontentloaded'); // Verify the task has the 'isCurrent' class await expect(firstTask).toHaveClass(/isCurrent/); @@ -32,7 +32,7 @@ test.describe('Task List - Start/Stop', () => { await playBtn.click(); // Wait a moment for the class to be removed - await page.waitForTimeout(200); + await page.waitForLoadState('domcontentloaded'); // Verify the task no longer has the 'isCurrent' class await expect(firstTask).not.toHaveClass(/isCurrent/); diff --git a/e2e/tests/work-view/work-view-features.spec.ts b/e2e/tests/work-view/work-view-features.spec.ts index a1b5163c2..3c6c5598a 100644 --- a/e2e/tests/work-view/work-view-features.spec.ts +++ b/e2e/tests/work-view/work-view-features.spec.ts @@ -20,7 +20,7 @@ test.describe('Work View Features', () => { await workViewPage.waitForTaskList(); // Wait for any dialogs to be dismissed - await page.waitForTimeout(2000); + await page.waitForLoadState('networkidle'); // Verify undone task list is visible await expect(page.locator(UNDONE_TASK_LIST)).toBeVisible({ timeout: 10000 }); @@ -28,10 +28,10 @@ test.describe('Work View Features', () => { // Create tasks await workViewPage.addTask('Task 1'); await page.waitForSelector(TASK, { state: 'visible', timeout: 5000 }); - await page.waitForTimeout(500); + await page.waitForLoadState('networkidle'); await workViewPage.addTask('Task 2'); - await page.waitForTimeout(1000); + await page.waitForLoadState('networkidle'); // Verify we have 2 tasks await expect(page.locator(TASK)).toHaveCount(2); @@ -49,7 +49,7 @@ test.describe('Work View Features', () => { await doneBtn.click(); // Wait a bit for the transition - await page.waitForTimeout(2000); + await page.waitForLoadState('networkidle'); // Check if done section exists (it might not show if there are no done tasks) const doneSectionExists = await page @@ -62,7 +62,7 @@ test.describe('Work View Features', () => { const toggleBtn = page.locator(TOGGLE_DONE_TASKS_BTN); if (await toggleBtn.isVisible({ timeout: 1000 }).catch(() => false)) { await toggleBtn.click(); - await page.waitForTimeout(1000); + await page.waitForLoadState('networkidle'); } // Verify done task list is visible @@ -82,17 +82,17 @@ test.describe('Work View Features', () => { // Wait for work view to be ready await workViewPage.waitForTaskList(); - await page.waitForTimeout(1000); + await page.waitForLoadState('networkidle'); // Create multiple tasks await workViewPage.addTask('First created'); - await page.waitForTimeout(500); + await page.waitForLoadState('networkidle'); await workViewPage.addTask('Second created'); - await page.waitForTimeout(500); + await page.waitForLoadState('networkidle'); await workViewPage.addTask('Third created'); - await page.waitForTimeout(500); + await page.waitForLoadState('networkidle'); await workViewPage.addTask('Fourth created'); - await page.waitForTimeout(500); + await page.waitForLoadState('networkidle'); // Verify order (newest first) await expect(page.locator('task:nth-of-type(1) textarea')).toHaveValue( diff --git a/e2e/tests/work-view/work-view.spec.ts b/e2e/tests/work-view/work-view.spec.ts index 5e48d11a2..f215f3301 100644 --- a/e2e/tests/work-view/work-view.spec.ts +++ b/e2e/tests/work-view/work-view.spec.ts @@ -80,14 +80,14 @@ test.describe('Work View', () => { // Wait for work view to be ready await workViewPage.waitForTaskList(); - await page.waitForTimeout(2000); // Wait for UI to stabilize + await page.waitForLoadState('networkidle'); // Wait for UI to stabilize // Simply add two tasks using the standard method await workViewPage.addTask('2 test task hihi'); - await page.waitForTimeout(500); + await page.waitForLoadState('networkidle'); await workViewPage.addTask('3 some other task'); - await page.waitForTimeout(500); + await page.waitForLoadState('networkidle'); // Verify both tasks are visible const tasks = page.locator('task');