import {test, expect} from '../../fixtures/test'
//
is a semantic element for contact information related to the
// nearest article or the whole document. In course content it marks
// instructor contact info, institution addresses, or course correspondence.
// canvas-rce must preserve its text through round-trips.
test.describe(' element for contact information', () => {
test.beforeEach(async ({page, rcePage}) => {
await page.goto('/scenarios/basic')
await rcePage.waitForEditor()
})
async function setAndGet(page: any, html: string): Promise {
return page.evaluate((content: string) => {
// @ts-expect-error -- TinyMCE global
window.tinymce.activeEditor.setContent(content)
// @ts-expect-error -- TinyMCE global
return window.tinymce.activeEditor.getContent()
}, html)
}
test(' text is preserved', async ({page}) => {
const content = await setAndGet(
page,
'Professor Jane Smith
Department of Computer Science
office@university.edu',
)
expect(content).toContain('Professor Jane Smith')
expect(content).toContain('office@university.edu')
})
test(' with a mailto link is preserved', async ({page}) => {
const content = await setAndGet(
page,
'Contact: instructor@example.edu',
)
expect(content).toContain('Contact')
expect(content).toContain('instructor@example.edu')
})
test(' inside an article element — text preserved', async ({page}) => {
const content = await setAndGet(
page,
'Course description here.
Written by Dr. Adams',
)
expect(content).toContain('Course description here')
expect(content).toContain('Written by Dr. Adams')
})
test(' with formatted content — text preserved', async ({page}) => {
const content = await setAndGet(
page,
'Office Hours: Mon/Wed 2-4pm
Room 204',
)
expect(content).toContain('Office Hours')
expect(content).toContain('Mon/Wed 2-4pm')
expect(content).toContain('Room 204')
})
test('multiple blocks all preserved', async ({page}) => {
const content = await setAndGet(
page,
'Main campus: 100 University AveSatellite: 200 College Rd',
)
expect(content).toContain('100 University Ave')
expect(content).toContain('200 College Rd')
})
})