feat(client): Persist editor open tabs (#59103)

Co-authored-by: sembauke <semboot699@gmail.com>
This commit is contained in:
Arif Khalid
2025-04-08 21:05:19 +08:00
committed by GitHub
parent 83c686aca2
commit 25249d1654
3 changed files with 80 additions and 5 deletions

View File

@@ -1,6 +1,8 @@
import { test, expect } from '@playwright/test';
import { getEditors } from './utils/editor';
import { clearEditor, focusEditor, getEditors } from './utils/editor';
import solution from './fixtures/learn-basic-css-by-building-a-cafe-menu-15.json';
import { isMacOS } from './utils/user-agent';
test.beforeEach(async ({ page }) => {
await page.goto(
@@ -72,4 +74,54 @@ test.describe('MultifileEditor Component', () => {
expect(await editorPane.getAttribute('style')).toBe(newStyle);
});
test('Multiple open editors should remain open on moving to next challenge', async ({
page,
isMobile,
browserName,
context
}) => {
test.skip(
browserName !== 'chromium',
'Only chromium allows us to use the clipboard API.'
);
await context.grantPermissions(['clipboard-read', 'clipboard-write']);
await focusEditor({ page, isMobile });
await clearEditor({ page, browserName });
await page.evaluate(
async solution => await navigator.clipboard.writeText(solution.content),
solution
);
if (isMacOS) {
await page.keyboard.press('Meta+v');
} else {
await page.keyboard.press('Control+v');
}
const stylesEditor = page.getByRole('button', {
name: 'styles.css Editor'
});
await stylesEditor.click();
const editorsCurrentPage = getEditors(page);
await expect(editorsCurrentPage).toHaveCount(2);
await page.keyboard.press('Control+Enter');
const submitButton = page.getByRole('button', {
name: 'Submit and go to next challenge'
});
// Mobile screen shifts submit button out of view and Playwright fails at scrolling with multiple editors open
if (isMobile) {
await submitButton.dispatchEvent('click');
} else {
await submitButton.click();
}
const editorsNextPage = getEditors(page);
await expect(editorsNextPage).toHaveCount(2);
});
});