import {test, expect} from '../../fixtures/test'
// Tab key inside a list item must indent to create a nested sub-list.
// Canvas assignments and course content rely heavily on nested lists.
test.describe('nested lists', () => {
test.beforeEach(async ({page, rcePage}) => {
await page.goto('/scenarios/basic')
await rcePage.waitForEditor()
await rcePage.contentFrame().locator('body').click()
})
test('Tab inside a list item creates a nested list', async ({page, rcePage}) => {
// Create a bulleted list with two items
await page.evaluate(() => {
// @ts-expect-error -- TinyMCE global
window.tinymce.activeEditor.setContent('
')
})
// Click the second list item
const secondItem = rcePage.contentFrame().locator('li').nth(1)
await secondItem.click()
await page.keyboard.press('Tab')
const content = await rcePage.getContent()
// Should contain a nested inside the first -
expect(content).toMatch(/
- [\s\S]*
{
await page.evaluate(() => {
// @ts-expect-error -- TinyMCE global
window.tinymce.activeEditor.setContent(
'',
)
})
const nestedItem = rcePage.contentFrame().locator('li li').first()
await nestedItem.click()
await page.keyboard.press('Shift+Tab')
const content = await rcePage.getContent()
// After outdent, "nested item" should be at the top level
const lis = content.match(/- {
await page.evaluate(() => {
// @ts-expect-error -- TinyMCE global
window.tinymce.activeEditor.setContent(
'',
)
})
const content = await rcePage.getContent()
expect(content).toMatch(/
{
await page.evaluate(() => {
// @ts-expect-error -- TinyMCE global
window.tinymce.activeEditor.setContent(
'',
)
})
const content = await rcePage.getContent()
expect(content).toContain('level 1')
expect(content).toContain('level 2')
expect(content).toContain('level 3')
// At least 3 nested or - structures
const ulCount = (content.match(/