test(user): add tests for updating week start day and verifying date picker behavior

This commit is contained in:
Xela 2026-04-21 23:13:46 +00:00 committed by kolaente
parent 4add8abaa1
commit d2cac283c7
2 changed files with 56 additions and 4 deletions

View File

@ -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})

View File

@ -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')
})
})