1import assert from 'node:assert/strict'2import test from 'node:test'3import { workingStateIsDirty, workingStateSnapshot } from '../src/working-state.js'45const exampleStateFor = type => ({6 type,7 source: `${type} example`,8 options: {},9 meta: { title: `${type} title`, description: '' },10 presentation: { appearance: 'auto-transparent' },11})1213test('treats a pristine anonymous example as a clean baseline', () => {14 assert.equal(workingStateIsDirty(exampleStateFor('d2'), { defaultStateFor: exampleStateFor }), false)15 assert.equal(workingStateIsDirty({ ...exampleStateFor('d2'), source: 'edited' }, { defaultStateFor: exampleStateFor }), true)16})1718test('compares aliases to their saved snapshot instead of the catalog example', () => {19 const saved = { ...exampleStateFor('d2'), source: 'saved source' }20 const options = { defaultStateFor: exampleStateFor, savedSnapshot: workingStateSnapshot(saved) }21 assert.equal(workingStateIsDirty(saved, options), false)22 assert.equal(workingStateIsDirty({ ...saved, source: 'local edit' }, options), true)23})2425test('keeps encryption envelope changes dirty independently of content', () => {26 assert.equal(workingStateIsDirty(exampleStateFor('d2'), {27 defaultStateFor: exampleStateFor,28 keyEnvelopeDirty: true,29 }), true)30})