-
Notifications
You must be signed in to change notification settings - Fork 132
Expand file tree
/
Copy pathsmart-picker.spec.ts
More file actions
60 lines (50 loc) 路 2.07 KB
/
Copy pathsmart-picker.spec.ts
File metadata and controls
60 lines (50 loc) 路 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { expect, mergeTests } from '@playwright/test'
import { test as editorTest } from '../support/fixtures/editor'
import { test as uploadFileTest } from '../support/fixtures/upload-file'
const test = mergeTests(editorTest, uploadFileTest)
test.beforeEach(async ({ open }) => {
await open()
})
test('See top options', async ({ editor }) => {
await editor.type('/')
await expect(editor.getSuggestion('To-Do list')).toBeVisible()
})
test('Create heading', async ({ editor }) => {
await editor.type('/Heading')
await editor.content.press('Enter')
await editor.type('Hello world')
await editor.content.press('Enter')
await expect(editor.getHeading({ name: 'Hello world' })).toBeVisible()
})
test('Insert Link', async ({ editor }) => {
await editor.type('/Any')
await editor.getSuggestion('Any link').click()
await editor.referencePicker.fill('https://github.com')
await expect(editor.referenceWidget).toContainText('GitHub')
await editor.referencePicker.press('Enter')
await expect(editor.content.getByRole('link')).toContainText('github.com')
})
test('Files provider is renamed to "Link a file"', async ({ editor }) => {
await editor.type('/')
await expect(editor.getSuggestion('Link a file')).toBeVisible()
})
test('Important items appear before remaining items', async ({ editor }) => {
await editor.type('/')
await expect(editor.getSuggestion('To-Do list')).toBeVisible()
const allTexts = await editor.suggestions
.locator('.suggestion-list__item')
.allTextContents()
const todoIdx = allTexts.findIndex((t) => t.includes('To-Do list'))
const tableIdx = allTexts.findIndex((t) => t.includes('Table'))
const filesIdx = allTexts.findIndex((t) => t.includes('Link a file'))
const heading1Idx = allTexts.findIndex((t) => t.includes('Heading 1'))
expect(todoIdx).toBeLessThan(filesIdx)
expect(todoIdx).toBeLessThan(heading1Idx)
expect(tableIdx).toBeLessThan(filesIdx)
expect(tableIdx).toBeLessThan(heading1Idx)
expect(filesIdx).toBeLessThan(heading1Idx)
})