fix(app): annotations tab split, editor-wide undo keys, keyboard point fits, typed radius message
This commit is contained in:
1 parent
447d0a4272
commit
3f15762d95
25 files changed
+1398
-653
No files matched your search
@@ -147,24 +147,27 @@ describe('correctionFor', () => {
|
||||
it('offers C for a refused B or an A refused out_of_frame, never for A too_small', () => {
|
||||
const reduced = { cx: 13.19, cy: 15, r: 13.19 }
|
||||
expect(
|
||||
correctionFor(frame, reduced, ['annotation.geometry.too_small']),
|
||||
correctionFor(frame, reduced, ['annotation.geometry.too_small'], 13.19),
|
||||
).not.toBeNull()
|
||||
const edge = { cx: 5, cy: 15, r: 13.2 }
|
||||
expect(
|
||||
correctionFor(frame, edge, ['annotation.geometry.out_of_frame'])?.circle
|
||||
.cx,
|
||||
correctionFor(frame, edge, ['annotation.geometry.out_of_frame'], 13.2)
|
||||
?.circle.cx,
|
||||
).toBe(13.2)
|
||||
expect(
|
||||
correctionFor(frame, { cx: 20, cy: 15, r: 13.2 }, [
|
||||
'annotation.geometry.too_small',
|
||||
]),
|
||||
correctionFor(
|
||||
frame,
|
||||
{ cx: 20, cy: 15, r: 13.2 },
|
||||
['annotation.geometry.too_small'],
|
||||
13.2,
|
||||
),
|
||||
).toBeNull()
|
||||
})
|
||||
|
||||
it('offers nothing when C is the circle that was just refused', () => {
|
||||
const circle = { cx: 13.2, cy: 13.2, r: 13.2 }
|
||||
expect(
|
||||
correctionFor(frame, circle, ['annotation.geometry.out_of_frame']),
|
||||
correctionFor(frame, circle, ['annotation.geometry.out_of_frame'], 13.2),
|
||||
).toBeNull()
|
||||
})
|
||||
})
|
||||
@@ -211,7 +214,12 @@ describe.each(FRAMES)('a point placed in the frame %s', (viewBox) => {
|
||||
expect(proposal.kind).not.toBe('outside')
|
||||
if (proposal.kind === 'outside') continue
|
||||
const insert = circleInserter(b)
|
||||
const attempt = attemptPoint(frame, proposal.circle, insert)
|
||||
const attempt = attemptPoint(
|
||||
frame,
|
||||
proposal.circle,
|
||||
insert,
|
||||
proposal.circle.r,
|
||||
)
|
||||
expect(attempt).toMatchObject({ status: 'created' })
|
||||
expect(currentErrors(b).size).toBe(0)
|
||||
}
|
||||
@@ -247,7 +255,12 @@ describe('a very elongated frame', () => {
|
||||
const frame = frameOf(b)!
|
||||
const proposal = proposePoint(frame, { x: 500, y: 15 })
|
||||
if (proposal.kind !== 'circle') throw new Error('proposal')
|
||||
const attempt = attemptPoint(frame, proposal.circle, circleInserter(b))
|
||||
const attempt = attemptPoint(
|
||||
frame,
|
||||
proposal.circle,
|
||||
circleInserter(b),
|
||||
proposal.circle.r,
|
||||
)
|
||||
expect(attempt.status).toBe('refused')
|
||||
expect(b.preview.document).toBe(b.text)
|
||||
})
|
||||
@@ -267,7 +280,9 @@ describe('a detail crop', () => {
|
||||
const inside = proposePoint(frame, { x: 150, y: 350 })
|
||||
if (inside.kind !== 'circle') throw new Error('proposal')
|
||||
const insert = circleInserter(b, 'view-det')
|
||||
expect(attemptPoint(frame, inside.circle, insert)).toMatchObject({
|
||||
expect(
|
||||
attemptPoint(frame, inside.circle, insert, inside.circle.r),
|
||||
).toMatchObject({
|
||||
status: 'created',
|
||||
})
|
||||
expect(proposePoint(frame, { x: 99, y: 350 })).toEqual({ kind: 'outside' })
|
||||
@@ -276,3 +291,73 @@ describe('a detail crop', () => {
|
||||
expect(currentErrors(b).size).toBe(0)
|
||||
})
|
||||
})
|
||||
|
||||
describe('a radius the user typed (H5)', () => {
|
||||
const frame = f(0, 0, 40, 30)
|
||||
|
||||
it('is never replaced by a corrected position: the core issue is shown', () => {
|
||||
const typed = { cx: 20, cy: 15, r: 1 }
|
||||
const codes = ['annotation.geometry.too_small']
|
||||
expect(correctionFor(frame, typed, codes, 13.2)).toBeNull()
|
||||
expect(correctionFor(frame, typed, codes, undefined)).toBeNull()
|
||||
})
|
||||
|
||||
it('on the core: a typed too-small radius creates nothing and keeps the message', () => {
|
||||
const b = bed('0 0 5000 5000')
|
||||
const big = frameOf(b)!
|
||||
const attempt = attemptPoint(
|
||||
big,
|
||||
{ cx: 2500, cy: 2500, r: 1 },
|
||||
circleInserter(b),
|
||||
defaultRadius(big),
|
||||
)
|
||||
expect(attempt).toMatchObject({ status: 'refused' })
|
||||
expect(b.preview.document).toBe(b.text)
|
||||
})
|
||||
})
|
||||
|
||||
describe('the keyboard point (H4)', () => {
|
||||
it.each([
|
||||
'0.003 0.004 20 20',
|
||||
'0 0 20 20',
|
||||
'-50 20 40 30',
|
||||
'0.003 0.004 1000 30',
|
||||
])('fits the frame %s by construction, with no correction', (viewBox) => {
|
||||
const b = bed(viewBox)
|
||||
const frame = frameOf(b)!
|
||||
const circle = centreCircle(frame)
|
||||
const slack = 1e-9 // float noise of x + w / 2 − r only; the core decides below
|
||||
expect(circle.cx - circle.r).toBeGreaterThanOrEqual(frame.x - slack)
|
||||
expect(circle.cy - circle.r).toBeGreaterThanOrEqual(frame.y - slack)
|
||||
expect(circle.cx + circle.r).toBeLessThanOrEqual(frame.x + frame.w + slack)
|
||||
expect(circle.cy + circle.r).toBeLessThanOrEqual(frame.y + frame.h + slack)
|
||||
const attempt = attemptPoint(frame, circle, circleInserter(b), circle.r)
|
||||
expect(attempt.status).not.toBe('correction')
|
||||
if (viewBox.endsWith('1000 30')) return
|
||||
expect(attempt).toMatchObject({ status: 'created' })
|
||||
})
|
||||
})
|
||||
|
||||
describe.each(['0 0 1000 30', '0 0 4000 200'])(
|
||||
'the elongated frame %s (H8)',
|
||||
(viewBox) => {
|
||||
it('gives the core the verdict on every edge and corner click, keeping nothing invalid', () => {
|
||||
const frame = frameOf(bed(viewBox))!
|
||||
for (const click of clicksOf(frame)) {
|
||||
const b = bed(viewBox)
|
||||
const proposal = proposePoint(frame, click)
|
||||
if (proposal.kind === 'outside') continue
|
||||
const attempt = attemptPoint(
|
||||
frame,
|
||||
proposal.circle,
|
||||
circleInserter(b),
|
||||
proposal.circle.r,
|
||||
)
|
||||
expect(['created', 'refused', 'correction']).toContain(attempt.status)
|
||||
expect(currentErrors(b).size).toBe(0)
|
||||
if (attempt.status !== 'created')
|
||||
expect(b.preview.document).toBe(b.text)
|
||||
}
|
||||
})
|
||||
},
|
||||
)
|
||||
Reference in new issue
Block a user