Skip to content

Commit

Permalink
playwright: Fix tooltip hover check (#3824)
Browse files Browse the repository at this point in the history
* remove redundant shift creation

* add testid to all variants
  • Loading branch information
mastercactapus committed Apr 25, 2024
1 parent c6f8690 commit 23fe852
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 38 deletions.
27 changes: 1 addition & 26 deletions test/integration/schedules.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test.afterEach(async ({ page }) => {
await page.click('button:has-text("Confirm")')
})

test('local time hover', async ({ page, isMobile }) => {
test('local time hover', async ({ page }) => {
// change schedule tz to Europe/Amsterdam
await page.click('[aria-label="Edit"]')
await page.fill('input[name=time-zone]', 'Europe/Amsterdam')
Expand All @@ -37,31 +37,6 @@ test('local time hover', async ({ page, isMobile }) => {

await page.goto(`${baseURL}/schedules/${scheduleID}/shifts`)

// add user override
if (!isMobile) {
await page.click('button:has-text("Create Override")')
await page.keyboard.press('Tab')
await page.keyboard.press('ArrowDown')
await page.keyboard.press('ArrowDown')
await page.keyboard.press('Enter')
} else {
await page.click('[data-testid="AddIcon"]')
await page.keyboard.press('Tab')
await page.keyboard.press('Tab')
await page.keyboard.press('ArrowDown')
await page.keyboard.press('ArrowDown')
await page.keyboard.press('Enter')
}

// should display schedule timezone in form
await expect(page.locator('form[id=dialog-form]')).toContainText(
'Times shown in schedule timezone (Europe/Amsterdam)',
)
await page.locator('input[name=addUserID]').fill('Admin McIntegrationFace')

await page.click('li:has-text("Admin McIntegrationFace")')
await page.locator('button[type=submit]').click()

// should display schedule tz on hover
await page.hover(`[data-testid="shift-details"]`)
await expect(page.locator('[data-testid="shift-tooltip"]')).toContainText(
Expand Down
24 changes: 12 additions & 12 deletions web/src/app/schedules/ScheduleShiftList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,11 @@ function ScheduleShiftList({
const scheduleTZDetails = `From ${schedStartTime} to ${schedEndTime} ${tzAbbr}`
const localTZDetails = `From ${localStartTime} to ${localEndTime} ${localTzAbbr}`
return (
<Tooltip title={scheduleTZDetails} placement='right'>
<span data-cy='shift-details' data-testid='shift-details'>
{localTZDetails}
</span>
<Tooltip
title={<span data-testid='shift-tooltip'>{scheduleTZDetails}</span>}
placement='right'
>
<span data-testid='shift-details'>{localTZDetails}</span>
</Tooltip>
)
}
Expand All @@ -194,8 +195,11 @@ function ScheduleShiftList({
s.truncated ? ' at least' : ''
} ${localEndTime} ${localTzAbbr}`
return (
<Tooltip title={scheduleTZDetails} placement='right'>
<span>{localTZDetails}</span>
<Tooltip
title={<span data-testid='shift-tooltip'>{scheduleTZDetails}</span>}
placement='right'
>
<span data-testid='shift-details'>{localTZDetails}</span>
</Tooltip>
)
}
Expand All @@ -205,14 +209,10 @@ function ScheduleShiftList({
const localTZDetails = `Active after ${localStartTime} ${localTzAbbr}`
return (
<Tooltip
title={scheduleTZDetails}
title={<span data-testid='shift-tooltip'>{scheduleTZDetails}</span>}
placement='right'
PopperProps={{
// @ts-expect-error test id
'data-testid': 'shift-tooltip',
}}
>
<span>{localTZDetails}</span>
<span data-testid='shift-details'>{localTZDetails}</span>
</Tooltip>
)
}
Expand Down

0 comments on commit 23fe852

Please sign in to comment.