Clean up share link tests (#7372)
* pierremtb/adhoc/clean-up-share-link-tests * Lint * WIP labels * Trigger CI * Change to skips
This commit is contained in:
@ -1,28 +1,10 @@
|
|||||||
import { expect, test } from '@e2e/playwright/zoo-test'
|
import { expect, test } from '@e2e/playwright/zoo-test'
|
||||||
|
import type { Page } from '@playwright/test'
|
||||||
|
|
||||||
const isWindows =
|
async function navigateAndClickOpenInDesktopApp(
|
||||||
navigator.platform === 'Windows' || navigator.platform === 'Win32'
|
page: Page,
|
||||||
test.describe('Share link tests', () => {
|
codeLength: number
|
||||||
;[
|
) {
|
||||||
{
|
|
||||||
codeLength: 1000,
|
|
||||||
showsErrorOnWindows: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
codeLength: 2000,
|
|
||||||
showsErrorOnWindows: true,
|
|
||||||
},
|
|
||||||
].forEach(({ codeLength, showsErrorOnWindows }) => {
|
|
||||||
test(
|
|
||||||
`Open in desktop app with ${codeLength}-long code ${isWindows && showsErrorOnWindows ? 'shows error' : "doesn't show error"}`,
|
|
||||||
{ tag: ['@web'] },
|
|
||||||
async ({ page }) => {
|
|
||||||
if (process.env.TARGET !== 'web') {
|
|
||||||
// This test is web-only
|
|
||||||
// TODO: re-enable on CI as part of a new @web test suite
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const code = Array(codeLength).fill('0').join('')
|
const code = Array(codeLength).fill('0').join('')
|
||||||
const targetURL = `?create-file=true&browser=test&code=${code}&ask-open-desktop=true`
|
const targetURL = `?create-file=true&browser=test&code=${code}&ask-open-desktop=true`
|
||||||
expect(targetURL.length).toEqual(codeLength + 58)
|
expect(targetURL.length).toEqual(codeLength + 58)
|
||||||
@ -30,16 +12,36 @@ test.describe('Share link tests', () => {
|
|||||||
expect(page.url()).toContain(targetURL)
|
expect(page.url()).toContain(targetURL)
|
||||||
const button = page.getByRole('button', { name: 'Open in desktop app' })
|
const button = page.getByRole('button', { name: 'Open in desktop app' })
|
||||||
await button.click()
|
await button.click()
|
||||||
const toastError = page.getByText(
|
|
||||||
'The URL is too long to open in the desktop app on Windows'
|
|
||||||
)
|
|
||||||
if (isWindows && showsErrorOnWindows) {
|
|
||||||
await expect(toastError).toBeVisible()
|
|
||||||
} else {
|
|
||||||
await expect(toastError).not.toBeVisible()
|
|
||||||
// TODO: check if we could verify the deep link dialog shows up
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getToastError(page: Page) {
|
||||||
|
return page.getByText('The URL is too long to open in the desktop app')
|
||||||
|
}
|
||||||
|
|
||||||
|
test.describe('Share link tests', () => {
|
||||||
|
test(
|
||||||
|
`Open in desktop app with 2000-long code doesn't show error on non-Windows`,
|
||||||
|
{ tag: ['@web', '@macos', '@linux'] },
|
||||||
|
async ({ page }) => {
|
||||||
|
test.skip(process.platform === 'win32')
|
||||||
|
const codeLength = 1000
|
||||||
|
await navigateAndClickOpenInDesktopApp(page, codeLength)
|
||||||
|
await expect(getToastError(page)).not.toBeVisible()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
test(
|
||||||
|
`Open in desktop app with 1000-long code works on Windows but not with 2000`,
|
||||||
|
{ tag: ['@web', '@windows'] },
|
||||||
|
async ({ page }) => {
|
||||||
|
test.skip(process.platform !== 'win32')
|
||||||
|
let codeLength = 1000
|
||||||
|
await navigateAndClickOpenInDesktopApp(page, codeLength)
|
||||||
|
await expect(getToastError(page)).not.toBeVisible()
|
||||||
|
|
||||||
|
codeLength = 2000
|
||||||
|
await navigateAndClickOpenInDesktopApp(page, codeLength)
|
||||||
|
await expect(getToastError(page)).toBeVisible()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
Reference in New Issue
Block a user