Skip to content

Commit 1eb066f

Browse files
committed
Add E2E test for project name prefill
1 parent b1287c6 commit 1eb066f

2 files changed

Lines changed: 43 additions & 1 deletion

File tree

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ TELESCOPE_ENABLED=false
7777
# Services
7878
GOTENBERG_URL=http://gotenberg:3000
7979

80+
# Octane
81+
OCTANE_SERVER=frankenphp
82+
8083
# Local setup
8184
NGINX_HOST_NAME=solidtime.test
8285
NETWORK_NAME=reverse-proxy-docker-traefik_routing

e2e/timetracker.spec.ts

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
} from './utils/currentTimeEntry';
1010
import type { Page } from '@playwright/test';
1111
import { newTagResponse } from './utils/tags';
12-
import { updateOrganizationCurrencyViaWeb } from './utils/api';
12+
import { createProjectViaApi, updateOrganizationCurrencyViaWeb } from './utils/api';
1313

1414
// Date picker button name patterns for different date formats
1515
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
368368
await assertThatTimerIsStopped(page);
369369
});
370370

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+
371410
test('test that adding a project and tag before starting timer works', async ({ page }) => {
372411
const newTagName = 'TimerTag ' + Math.floor(Math.random() * 10000);
373412
await goToDashboard(page);

0 commit comments

Comments
 (0)