mirror of
https://github.com/backnotprop/plannotator.git
synced 2026-09-14 14:17:26 +08:00
27791a6fba
* feat(editor): add compact plan navigator * feat(editor): simplify compact plan chrome * fix(editor): close compact navigator after file selection * feat(editor): add compact plan review surfaces * fix(editor): hold navigator through cold file loads * fix(editor): preserve desktop diff activation
58 lines
1.7 KiB
TypeScript
58 lines
1.7 KiB
TypeScript
import { describe, expect, test } from 'bun:test';
|
|
import React from 'react';
|
|
import { renderToStaticMarkup } from 'react-dom/server';
|
|
import { CompactEditControls } from './CompactEditControls';
|
|
|
|
describe('CompactEditControls', () => {
|
|
test('keeps source-file Save and Cancel in a normal-flow touch row', () => {
|
|
const html = renderToStaticMarkup(
|
|
<CompactEditControls
|
|
documentTitle="notes.md"
|
|
sourceBacked
|
|
saveStatus="dirty"
|
|
cancelMode
|
|
confirmDiscard={false}
|
|
onSave={() => {}}
|
|
onExit={() => {}}
|
|
/>,
|
|
);
|
|
|
|
expect(html).toContain('data-pn-compact-edit-controls="true"');
|
|
expect(html).toContain('Editing notes.md');
|
|
expect(html).toContain('>Save<');
|
|
expect(html).toContain('>Cancel<');
|
|
expect(html.match(/data-pn-touch-target/g)).toHaveLength(2);
|
|
expect(html).not.toContain('fixed');
|
|
expect(html).not.toContain('sticky');
|
|
});
|
|
|
|
test('uses Done for plan edits and a clear second-step discard label', () => {
|
|
const plan = renderToStaticMarkup(
|
|
<CompactEditControls
|
|
documentTitle="Plan"
|
|
sourceBacked={false}
|
|
saveStatus={undefined}
|
|
cancelMode={false}
|
|
confirmDiscard={false}
|
|
onSave={() => {}}
|
|
onExit={() => {}}
|
|
/>,
|
|
);
|
|
const discard = renderToStaticMarkup(
|
|
<CompactEditControls
|
|
documentTitle="notes.md"
|
|
sourceBacked
|
|
saveStatus="dirty"
|
|
cancelMode
|
|
confirmDiscard
|
|
onSave={() => {}}
|
|
onExit={() => {}}
|
|
/>,
|
|
);
|
|
|
|
expect(plan).toContain('>Done<');
|
|
expect(plan).not.toContain('>Save<');
|
|
expect(discard).toContain('>Discard changes<');
|
|
});
|
|
});
|