Files
upstream-tldraw/apps/dotcom/client/e2e/tests/smoke/homepage.spec.ts
upstream-mirror a774ac673a
Some checks failed
Deploy analytics worker / Deploy analytics worker to ${{ (github.ref == 'refs/heads/production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Failing after 1s
i18n upload strings / Upload latest strings (push) Failing after 1s
Deploy bemo / Deploy bemo to ${{ (github.ref == 'refs/heads/bemo-production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Failing after 1s
Deploy grafana resources / ${{ github.event_name == 'push' && 'Deploy grafana resources' || 'Validate grafana resources (dry run)' }} (push) Failing after 0s
End to end tests (dotcom) / Check for relevant changes (push) Failing after 0s
End to end tests (examples) / Check for relevant changes (push) Failing after 0s
End to end tests (mermaid readability) / Check for relevant changes (push) Failing after 1s
End to end tests (perf) / Check for relevant changes (push) Failing after 0s
Publish editor extensions / Publish editor extensions (push) Failing after 1s
Publish SDK packages / Remove the publish-packages label (push) Has been skipped
Checks / Tests & checks (push) Has been cancelled
Checks / Build all projects (push) Has been cancelled
Deploy templates / Deploy templates (push) Has been cancelled
End to end tests (dotcom) / End to end tests (dotcom) (push) Has been cancelled
End to end tests (mermaid readability) / End to end tests (mermaid readability) (push) Has been cancelled
End to end tests (perf) / End to end tests (perf) (push) Has been cancelled
Deploy .com / Deploy dotcom to ${{ (github.ref == 'refs/heads/production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Has been cancelled
End to end tests (examples) / End to end tests (examples) (push) Has been cancelled
Publish SDK packages / Publish SDK packages (push) Has been cancelled
Publish SDK packages / Tell user released version (push) Has been cancelled
Publish SDK packages / Publishes code templates to separate repositories (push) Has been cancelled
Publish SDK packages / Deploys the template demos with the new SDK version (push) Has been cancelled
snapshot of https://github.com/tldraw/tldraw.git (main, 2026-09-23; blobs > 131072B omitted)
2026-09-23 16:12:52 +05:00

163 lines
5.4 KiB
TypeScript

import { expectBeforeAndAfterReload, getRandomName, sleep } from '../../fixtures/helpers'
import { expect, test } from '../../fixtures/tla-test'
test.beforeEach(async ({ editor }) => {
await editor.isLoaded()
})
test('can instantiate', async ({ page }) => {
const dialogCloseButton = page.getByTestId('dialog.close')
// expect this button not to be present; ie that the dialog is not open
await expect(dialogCloseButton).not.toBeVisible()
})
test.describe('preferences', () => {
test('can toggle dark mode', async ({ page, editor, sidebar }) => {
await test.step('is light mode by default', async () => {
await expect(page.locator('div.tla-theme__light.tl-theme__light')).toBeVisible()
await expect(page.locator('div.tla-theme__dark.tl-theme__dark')).not.toBeVisible()
await expect(page.locator('div.tl-background')).toHaveCSS(
'background-color',
'rgb(249, 250, 251)'
)
await expect(page.locator('div.tla-theme-container')).toHaveCSS(
'background-color',
'rgb(252, 252, 252)'
)
})
await test.step('can toggle dark mode', async () => {
await editor.ensureSidebarOpen()
await sidebar.setDarkMode()
})
await test.step('is dark mode', async () => {
await expectBeforeAndAfterReload(async () => {
await expect(page.locator('div.tla-theme__light.tl-theme__light')).not.toBeVisible()
await expect(page.locator('div.tla-theme__dark.tl-theme__dark')).toBeVisible()
await expect(page.locator('div.tl-background')).toHaveCSS(
'background-color',
'rgb(16, 16, 17)'
)
await expect(page.locator('div.tla-theme-container')).toHaveCSS(
'background-color',
'rgb(13, 13, 13)'
)
}, page)
})
})
test('can change language', async ({ sidebar, page, editor }) => {
await editor.ensureSidebarOpen()
await test.step('English by default', async () => {
await sidebar.expectLanguageToBe('Language', 'English')
})
await sidebar.closeAccountMenu()
await test.step('change language', async () => {
await sidebar.setLanguage('Language', 'Français')
})
await test.step('changed to French', async () => {
await sidebar.expectLanguageToBe('Langue', 'Français')
await editor.openPageMenu()
// Make sure the file / page menu is using the correct language
await expect(page.getByText('Charger un média')).toBeVisible()
})
})
})
test.describe('sidebar actions', () => {
test('can pin a file from the file menu', async ({ page, editor, sidebar }) => {
// Create two files so that there are three
await editor.ensureSidebarOpen()
await sidebar.createNewDocument()
await sleep(1000)
await sidebar.createNewDocument()
expect(await sidebar.getNumberOfFiles()).toBe(3)
// Name the files
const fileName0 = getRandomName()
await sidebar.renameFile(0, fileName0)
const fileName1 = getRandomName()
await sidebar.renameFile(1, fileName1)
const fileName2 = getRandomName()
await sidebar.renameFile(2, fileName2)
// The pinned files are also sorted by recency (though not grouped by time)
// When we pin a file, we expect that it will move to the pinned files section
// but that the order of the pinned files will be the same as the order of the files
// Pin the second-most recent file...
await sidebar.pinFromFileMenu(1)
// And expect it to the the first (and only) pinned file
await expectBeforeAndAfterReload(async () => {
await expect(async () => {
await expect(
page.getByTestId('tla-file-link-pinned-0').getByText(fileName1, { exact: true })
).toBeVisible()
await expect(
page.getByTestId('tla-file-link-today-0').getByText(fileName0, { exact: true })
).toBeVisible()
await expect(
page.getByTestId('tla-file-link-today-1').getByText(fileName2, { exact: true })
).toBeVisible()
}).toPass()
}, page)
// Now we pin the most recent file...
await sidebar.pinFromFileMenu(0)
// And expect it to the first pinned file
await expectBeforeAndAfterReload(async () => {
await expect(async () => {
await expect(
page.getByTestId('tla-file-link-pinned-0').getByText(fileName0, { exact: true })
).toBeVisible()
await expect(
page.getByTestId('tla-file-link-pinned-1').getByText(fileName1, { exact: true })
).toBeVisible()
await expect(
page.getByTestId('tla-file-link-today-0').getByText(fileName2, { exact: true })
).toBeVisible()
}).toPass()
}, page)
// Now we unpin the most recent file...
await sidebar.unpinFromFileMenu(0)
await expectBeforeAndAfterReload(async () => {
await expect(async () => {
await expect(
page.getByTestId('tla-file-link-pinned-0').getByText(fileName1, { exact: true })
).toBeVisible()
await expect(
page.getByTestId('tla-file-link-today-0').getByText(fileName0, { exact: true })
).toBeVisible()
await expect(
page.getByTestId('tla-file-link-today-1').getByText(fileName2, { exact: true })
).toBeVisible()
}).toPass()
}, page)
})
})
// Menu bar
test('can rename a file name by clicking the name', async ({ editor, sidebar, page }) => {
const originalName = await editor.getCurrentFileName()
const newName = getRandomName()
await expect(async () => {
await sidebar.expectToContainText(originalName)
await sidebar.expectNotToContainText(newName)
}).toPass()
await editor.rename(newName)
await expectBeforeAndAfterReload(async () => {
await sidebar.expectToContainText(newName)
await sidebar.expectNotToContainText(originalName)
}, page)
})