Make Background a native feature
- Background replaces the Background Slideshow plugin and the background image of Appearance. It shows a folder as a slideshow, or one image. - It is on by default. Its module loads at launch only when a folder or an image is chosen. - Rust keeps the one folder in background-folder.json. The interface never sends a path. Eight background_* commands replace the six deprecated backgrounds_* commands. - The first start moves the slideshow folder and settings, and keeps the saved image as the image source. - One blur worker with a cache, fewer folder reads, and a decode before each fade. The hub writes only the changed properties. - Remove the deprecated folder methods of api.backgrounds. set, get, and subscribe stay for the Project Management plugin. - Show the view buttons in the workbench test without text, after UI-056. - Update the tests, the measurement tool, the docs, and UI-057.
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
// Workarea backgrounds in both themes: splash, writer, reader, split, Source, narrow layouts, fades, reduced motion, and removal.
|
||||
// The saved image shows through the Background feature (src/lib/features/background/). The test also sets its own frames.
|
||||
import assert from 'node:assert/strict';
|
||||
import { writeFile } from 'node:fs/promises';
|
||||
import { chooseView, mockTauri, openPage, outputDir, runSmoke, smokeUrl } from '../_harness/index.mjs';
|
||||
import { chooseView, mockTauri, openPage, outputDir, runSmoke, showSavedImage, smokeUrl } from '../_harness/index.mjs';
|
||||
|
||||
const viewport = { width: 1280, height: 820 };
|
||||
|
||||
@@ -43,6 +44,7 @@ await runSmoke('appearance/backgroundFrames', async ({ browser }) => {
|
||||
const urls = [make('#bd486c', '#438f67'), make('#286f9b', '#725ea2')].map(url => URL.createObjectURL(blob(url)));
|
||||
window.backgroundTest = { hub: backgroundHub, owner: Symbol(), urls, saved, theme };
|
||||
}, theme);
|
||||
await showSavedImage(page);
|
||||
const background = page.locator('.workarea-background');
|
||||
const style = (locator, property, pseudo) => locator.evaluate((node, [property, pseudo]) => getComputedStyle(node, pseudo)[property], [property, pseudo]);
|
||||
async function openWelcome() {
|
||||
@@ -120,12 +122,14 @@ await runSmoke('appearance/backgroundFrames', async ({ browser }) => {
|
||||
await page.screenshot({ path: `${output}/${theme}-splash-narrow.png` });
|
||||
await page.emulateMedia({ reducedMotion: 'reduce' });
|
||||
await page.evaluate(() => { const { hub, owner, urls } = window.backgroundTest; hub.set(owner, 'app', { url: urls[0], overlay: 0.2, position: 'center', size: 'cover', previous: { url: urls[1], overlay: 0.2, position: 'center', size: 'cover' }, transitionMs: 2000 }); });
|
||||
assert.equal(await background.evaluate(node => node.getAnimations().length), 0);
|
||||
assert.equal(await background.evaluate(node => node.getAnimations({ subtree: true }).length), 0);
|
||||
await page.evaluate(() => { const { hub, owner, urls } = window.backgroundTest; hub.removeOwner(owner); urls.forEach(URL.revokeObjectURL); });
|
||||
assert.equal(await page.evaluate(() => document.body.style.getPropertyValue('--rs-background-previous-image')), '');
|
||||
// The frame of Background (the saved image) shows again, without a fade.
|
||||
assert.equal(await page.evaluate(() => document.body.style.getPropertyValue('--rs-background-previous-image')), 'none');
|
||||
assert.match(await style(background, 'backgroundImage'), /blob:/);
|
||||
await page.evaluate(async () => { const { saveAppearance } = await import('/src/lib/theme/appearance.ts'); saveAppearance({ theme: 'default', mode: window.backgroundTest.theme }); });
|
||||
assert.equal(await style(background, 'backgroundImage'), 'none');
|
||||
await page.waitForFunction(() => getComputedStyle(document.querySelector('.workarea-background')).backgroundImage === 'none');
|
||||
assert.equal(await page.evaluate(() => document.body.style.getPropertyValue('--rs-background-image')), '', 'Without an image, the body has no background properties');
|
||||
await openWelcome();
|
||||
await page.locator('.editor > .body').waitFor();
|
||||
assert.equal(await style(page.locator('.editor > .body'), 'backgroundColor'), await style(page.locator('.shell'), 'backgroundColor'));
|
||||
|
||||
Reference in New Issue
Block a user