|
9 | 9 | } from './utils/currentTimeEntry'; |
10 | 10 | import type { Page } from '@playwright/test'; |
11 | 11 | import { newTagResponse } from './utils/tags'; |
12 | | -import { updateOrganizationCurrencyViaWeb } from './utils/api'; |
| 12 | +import { createProjectViaApi, updateOrganizationCurrencyViaWeb } from './utils/api'; |
13 | 13 |
|
14 | 14 | // Date picker button name patterns for different date formats |
15 | 15 | const DATE_DISPLAY_PATTERN = /^\d{4}-\d{2}-\d{2}$|^\d{2}\/\d{2}\/\d{4}$|^\d{2}\.\d{2}\.\d{4}$/; |
@@ -368,6 +368,45 @@ test('test that timer started on dashboard is visible on time page', async ({ pa |
368 | 368 | await assertThatTimerIsStopped(page); |
369 | 369 | }); |
370 | 370 |
|
| 371 | +test('test that creating a new project from the time tracker dropdown prefills the search text', async ({ |
| 372 | + page, |
| 373 | + ctx, |
| 374 | +}) => { |
| 375 | + const existingProjectName = 'Existing Project ' + Math.floor(Math.random() * 10000); |
| 376 | + const searchText = 'PrefillProject ' + Math.floor(Math.random() * 10000); |
| 377 | + |
| 378 | + // Create a project so the dropdown renders (not the "Add new project" button) |
| 379 | + await createProjectViaApi(ctx, { name: existingProjectName }); |
| 380 | + await goToDashboard(page); |
| 381 | + |
| 382 | + // Open the project dropdown |
| 383 | + await page.getByRole('button', { name: 'No Project' }).click(); |
| 384 | + |
| 385 | + // Type a search term that won't match any existing project |
| 386 | + await page.getByTestId('client_dropdown_search').fill(searchText); |
| 387 | + |
| 388 | + // Click "Create new Project" |
| 389 | + await page.getByText('Create new Project').click(); |
| 390 | + |
| 391 | + // Verify the project name input is pre-filled with the search text |
| 392 | + await expect(page.getByLabel('Project name')).toHaveValue(searchText); |
| 393 | + |
| 394 | + // Complete project creation to verify full flow works |
| 395 | + await Promise.all([ |
| 396 | + page.waitForResponse( |
| 397 | + async (response) => |
| 398 | + response.url().includes('/projects') && |
| 399 | + response.request().method() === 'POST' && |
| 400 | + response.status() === 201 && |
| 401 | + (await response.json()).data.name === searchText |
| 402 | + ), |
| 403 | + page.getByRole('button', { name: 'Create Project' }).click(), |
| 404 | + ]); |
| 405 | + |
| 406 | + // The project dropdown should now show the newly created project |
| 407 | + await expect(page.getByRole('button', { name: searchText })).toBeVisible(); |
| 408 | +}); |
| 409 | + |
371 | 410 | test('test that adding a project and tag before starting timer works', async ({ page }) => { |
372 | 411 | const newTagName = 'TimerTag ' + Math.floor(Math.random() * 10000); |
373 | 412 | await goToDashboard(page); |
|
0 commit comments