Add testOptions parameter to openTerminal in TestUtils.

This is used to control whether the UnicodeGraphemesAddon is loaded.
This commit is contained in:
Per Bothner
2023-08-09 14:44:45 -07:00
parent b9a4760b44
commit 3bfe5d86c0
2 changed files with 10 additions and 10 deletions
+1 -1
View File
@@ -34,7 +34,7 @@ describe('API Integration Tests', function(): void {
// fails with the grapheme injection, not sure why...
it('Proposed API check', async () => {
await openTerminal(page, { allowProposedApi: false });
await openTerminal(page, { allowProposedApi: false }, { loadUnicodeGraphemesAddon: false });
await page.evaluate(`
try {
window.term.markers;
+9 -9
View File
@@ -43,18 +43,18 @@ export async function timeout(ms: number): Promise<void> {
return new Promise<void>(r => setTimeout(r, ms));
}
export async function openTerminal(page: playwright.Page, options: ITerminalOptions & ITerminalInitOnlyOptions = {}): Promise<void> {
export async function openTerminal(page: playwright.Page, options: ITerminalOptions & ITerminalInitOnlyOptions = {}, testOptions: any = { loadUnicodeGraphemesAddon: true}): Promise<void> {
await page.evaluate(`window.term = new Terminal(${JSON.stringify({ allowProposedApi: true, ...options })})`);
await page.evaluate(`window.term.open(document.querySelector('#terminal-container'))`);
/*
// TODO: make this injection configurable from outside
await page.evaluate(`
window.unicode = new UnicodeGraphemesAddon();
window.term.loadAddon(window.unicode);
window.term.unicode.activeVersion = '15-graphemes';
`);
*/
// See https://github.com/xtermjs/xterm.js/pull/4519#discussion_r1285234453
if (testOptions.loadUnicodeGraphemesAddon) {
await page.evaluate(`
window.unicode = new UnicodeGraphemesAddon();
window.term.loadAddon(window.unicode);
window.term.unicode.activeVersion = '15-graphemes';
`);
}
await page.waitForSelector('.xterm-rows');
}