diff --git a/frontend/tests/e2e/project/project-view-gantt.spec.ts b/frontend/tests/e2e/project/project-view-gantt.spec.ts index ed1a71f8c..9b00ec8af 100644 --- a/frontend/tests/e2e/project/project-view-gantt.spec.ts +++ b/frontend/tests/e2e/project/project-view-gantt.spec.ts @@ -3,8 +3,35 @@ import dayjs from 'dayjs' import {TaskFactory} from '../../factories/task' import {ProjectFactory} from '../../factories/project' import {ProjectViewFactory} from '../../factories/project_view' +import {updateUserSettings} from '../../support/updateUserSettings' test.describe('Project View Gantt', () => { + test('Shows the correct start of the week in the date picker', async ({authenticatedPage: page, apiContext, userToken}) => { + await ProjectFactory.create(1) + await ProjectViewFactory.create(1, {id: 2, project_id: 1, view_kind: 1}) + + // Set the week start to Monday (1) + await updateUserSettings(apiContext, userToken, {week_start: 1}) + + await page.goto('/projects/1/2') + // Reload to ensure settings are loaded fresh from the API + await page.reload() + await page.waitForLoadState('networkidle') + + // Open the date range picker + const dateInput = page.locator('.project-gantt .gantt-options .field .control input.input.form-control') + await expect(dateInput).toBeVisible() + await dateInput.click() + + // Wait for the calendar to be visible and open + const calendar = page.locator('.flatpickr-calendar.open') + await expect(calendar).toBeVisible({timeout: 10000}) + + // Verify the first weekday in the calendar is Monday + const firstWeekday = calendar.locator('.flatpickr-weekday').first() + await expect(firstWeekday).toHaveText(/Mon/i) + }) + test('Hides tasks with no dates', async ({authenticatedPage: page}) => { await ProjectFactory.create(1) await ProjectViewFactory.create(1, {id: 2, project_id: 1, view_kind: 1}) diff --git a/frontend/tests/e2e/user/settings.spec.ts b/frontend/tests/e2e/user/settings.spec.ts index 44637ca86..e074896fd 100644 --- a/frontend/tests/e2e/user/settings.spec.ts +++ b/frontend/tests/e2e/user/settings.spec.ts @@ -96,17 +96,42 @@ test.describe('User Settings', () => { const nameInput = page.locator('.general-settings input.input').first() await expect(nameInput).toBeVisible({timeout: 10000}) await expect(nameInput).toBeEnabled() + }) + test('Updates the week start day', async ({authenticatedPage: page}) => { + await page.goto('/user/settings/general') + await page.waitForLoadState('networkidle') - // Clear and type to ensure Vue's reactivity is triggered - await nameInput.clear() - await nameInput.pressSequentially('Lorem Ipsum', {delay: 10}) + // Wait for the settings page to be fully loaded and find the select by its label + const weekStartSelect = page.getByLabel('Week starts on') + await weekStartSelect.scrollIntoViewIfNeeded() + await expect(weekStartSelect).toBeVisible({timeout: 10000}) + + // Select Wednesday (value 3) + await weekStartSelect.selectOption({value: '3'}) // The save button only appears when isDirty becomes true (settings changed) const saveButton = page.locator('[data-cy="saveGeneralSettings"]') await expect(saveButton).toBeVisible({timeout: 10000}) + + // Intercept the API request to verify it contains the correct setting + const settingsUpdatePromise = page.waitForResponse(response => + response.url().includes('user/settings/general') && response.request().method() === 'POST', + ) + await saveButton.click() + const response = await settingsUpdatePromise + const requestData = JSON.parse(response.request().postData() || '{}') + expect(requestData.week_start).toBe(3) + expect(response.ok()).toBe(true) + await expect(page.locator('.global-notification')).toContainText('Success') - await expect(page.locator('.navbar .username-dropdown-trigger .username')).toContainText('Lorem Ipsum') + + // Verify the setting was saved by reloading the page + await page.reload() + await page.waitForLoadState('networkidle') + const weekStartSelectAfterReload = page.getByLabel('Week starts on') + await weekStartSelectAfterReload.scrollIntoViewIfNeeded() + await expect(weekStartSelectAfterReload).toHaveValue('3') }) })