2024-01-31 14:35:41 +03:00
|
|
|
/** @file Test the labels sidebar panel. */
|
|
|
|
import * as test from '@playwright/test'
|
|
|
|
|
2024-08-29 08:54:21 +03:00
|
|
|
import {
|
|
|
|
locateCreateButton,
|
|
|
|
locateLabelsPanel,
|
|
|
|
locateLabelsPanelLabels,
|
|
|
|
locateModalBackground,
|
|
|
|
locateNewLabelButton,
|
|
|
|
locateNewLabelModal,
|
|
|
|
locateNewLabelModalColorButtons,
|
|
|
|
locateNewLabelModalNameInput,
|
|
|
|
mockAllAndLogin,
|
|
|
|
TEXT,
|
|
|
|
} from './actions'
|
2024-01-31 14:35:41 +03:00
|
|
|
|
2024-08-29 08:54:21 +03:00
|
|
|
test.test.beforeEach(({ page }) => mockAllAndLogin({ page }))
|
2024-01-31 14:35:41 +03:00
|
|
|
|
|
|
|
test.test('labels', async ({ page }) => {
|
|
|
|
// Empty labels panel
|
2024-08-29 08:54:21 +03:00
|
|
|
await test.expect(locateLabelsPanel(page)).toBeVisible()
|
2024-01-31 14:35:41 +03:00
|
|
|
|
|
|
|
// "Create label" modal
|
2024-08-29 08:54:21 +03:00
|
|
|
await locateNewLabelButton(page).click()
|
|
|
|
await test.expect(locateNewLabelModal(page)).toBeVisible()
|
2024-01-31 14:35:41 +03:00
|
|
|
await page.press('body', 'Escape')
|
2024-08-29 08:54:21 +03:00
|
|
|
await test.expect(locateNewLabelModal(page)).not.toBeVisible()
|
|
|
|
await locateNewLabelButton(page).click()
|
|
|
|
await locateModalBackground(page).click()
|
|
|
|
await test.expect(locateNewLabelModal(page)).not.toBeVisible()
|
|
|
|
await locateNewLabelButton(page).click()
|
2024-01-31 14:35:41 +03:00
|
|
|
|
|
|
|
// "Create label" modal with name set
|
2024-08-29 08:54:21 +03:00
|
|
|
await locateNewLabelModalNameInput(page).fill('New Label')
|
|
|
|
await test.expect(locateNewLabelModal(page)).toHaveText(/^New Label/)
|
2024-01-31 14:35:41 +03:00
|
|
|
|
|
|
|
await page.press('body', 'Escape')
|
|
|
|
|
|
|
|
// "Create label" modal with color set
|
|
|
|
// The exact number is allowed to vary; but to click the fourth color, there must be at least
|
|
|
|
// four colors.
|
2024-08-29 08:54:21 +03:00
|
|
|
await locateNewLabelButton(page).click()
|
|
|
|
test.expect(await locateNewLabelModalColorButtons(page).count()).toBeGreaterThanOrEqual(4)
|
2024-01-31 14:35:41 +03:00
|
|
|
// `force: true` is required because the `label` needs to handle the click event, not the
|
|
|
|
// `button`.
|
2024-08-29 08:54:21 +03:00
|
|
|
await locateNewLabelModalColorButtons(page).nth(4).click({ force: true })
|
|
|
|
await test.expect(locateNewLabelModal(page)).toBeVisible()
|
2024-01-31 14:35:41 +03:00
|
|
|
|
|
|
|
// "Create label" modal with name and color set
|
2024-08-29 08:54:21 +03:00
|
|
|
await locateNewLabelModalNameInput(page).fill('New Label')
|
|
|
|
await test.expect(locateNewLabelModal(page)).toHaveText(/^New Label/)
|
2024-01-31 14:35:41 +03:00
|
|
|
|
|
|
|
// Labels panel with one entry
|
2024-08-29 08:54:21 +03:00
|
|
|
await locateCreateButton(locateNewLabelModal(page)).click()
|
|
|
|
await test.expect(locateLabelsPanel(page)).toBeVisible()
|
2024-01-31 14:35:41 +03:00
|
|
|
|
|
|
|
// Empty labels panel again, after deleting the only entry
|
2024-08-29 08:54:21 +03:00
|
|
|
await locateLabelsPanelLabels(page).first().hover()
|
|
|
|
|
|
|
|
const labelsPanel = locateLabelsPanel(page)
|
|
|
|
await labelsPanel.getByRole('button').and(labelsPanel.getByLabel(TEXT.delete)).click()
|
2024-09-16 12:03:49 +03:00
|
|
|
await page.getByRole('button', { name: TEXT.delete }).getByText(TEXT.delete).click()
|
2024-08-29 08:54:21 +03:00
|
|
|
test.expect(await locateLabelsPanelLabels(page).count()).toBeGreaterThanOrEqual(1)
|
2024-01-31 14:35:41 +03:00
|
|
|
})
|