Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions frontend/e2e/local/worldbuilding-backgrounds.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
* Worldbuilding Custom Background Tests - Local Mode
*
* Exercises the per-element background theming (Appearance panel) end to end:
* - toggles start unchecked when no region is configured
* - the demo template ships each element with themed gradient backgrounds
* - disabling both regions clears them and unchecks the toggles
* - enabling a region with a solid colour applies it to the sidenav
* - enabling a region with a gradient applies it to the content area
* - backgrounds persist across a reload
Expand Down Expand Up @@ -148,10 +149,23 @@ test.describe('Worldbuilding Custom Backgrounds', () => {
const sidenav = page.getByTestId('wb-sidenav');
const content = page.getByTestId('wb-content');

await test.step('toggles start unchecked when unconfigured', async () => {
await test.step('demo template ships themed gradient backgrounds', async () => {
await expect(menuToggle).toHaveAttribute('aria-checked', 'true');
await expect(contentToggle).toHaveAttribute('aria-checked', 'true');
await expect(sidenav).toHaveClass(/has-custom-background/);
await expect(content).toHaveClass(/has-custom-background/);
await expect
.poll(() => contentBgImage(page))
.toContain('linear-gradient');
});

await test.step('disabling both regions clears the template backgrounds', async () => {
await menuToggle.click();
await contentToggle.click();
await expect(menuToggle).toHaveAttribute('aria-checked', 'false');
await expect(contentToggle).toHaveAttribute('aria-checked', 'false');
await expect(sidenav).not.toHaveClass(/has-custom-background/);
await expect(content).not.toHaveClass(/has-custom-background/);
});

await test.step('solid colour applies to the sidenav', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,23 @@ test.describe('Worldbuilding Editor Custom Background Screenshots', () => {
}

/**
* Enable a region via its slide toggle. Material slide toggles are clicked
* rather than checked/unchecked.
* Enable a region via its slide toggle, starting from a fresh default
* setting. The demo template ships every element with themed gradients, so
* a region that is already on is switched off first; re-enabling resets it
* to the default auto-adjusted solid colour the helpers below expect.
* Material slide toggles are clicked rather than checked/unchecked.
*/
async function enableRegion(
page: Page,
region: 'menu' | 'content'
): Promise<void> {
await page.getByTestId(`appearance-${region}-toggle`).click();
const toggle = page.getByTestId(`appearance-${region}-toggle`);
if ((await toggle.getAttribute('aria-checked')) === 'true') {
await toggle.click();
await expect(toggle).toHaveAttribute('aria-checked', 'false');
}
await toggle.click();
await expect(toggle).toHaveAttribute('aria-checked', 'true');
}

/**
Expand Down
Loading