Skip to content

Fix undo-redo tests #2145

@raineorshine

Description

@raineorshine

Two undo-redo tests are currently broken and being skipped.

// TODO: Cursor is null in test, but correct when testing manually
it.skip('cursor should restore correctly after undo archive', async () => {
timer.useFakeTimer()
initialize()
await timer.runAllAsync()
appStore.dispatch([newThought({ value: 'a' }), setCursor(['a']), { type: 'archiveThought' }, undo()])
await timer.runAllAsync()
timer.useRealTimer()
const stateNew = appStore.getState()
const expectedCursor = [{ value: 'a', rank: 0 }]
const cursorThoughts = stateNew.cursor && childIdsToThoughts(stateNew, stateNew.cursor)
expect(cursorThoughts).toMatchObject(expectedCursor)
})
// TODO
it.skip('persists undo thought change', async () => {
/**
* Note: we can't use await with initialize as that results in a timeout error. It's handled using the usetestTimer from Sinon.
* More on that here - https://github.com/cybersemics/em/issues/919#issuecomment-739135971.
*/
initialize()
timer.useFakeTimer()
appStore.dispatch([
importText({
text: `
- a
- b`,
}),
setCursor(['a']),
newThought({ value: 'alpha', insertNewSubthought: true }),
undo(),
])
await timer.runAllAsync()
timer.useRealTimer()
// clear and call initialize again to reload from local db (simulating page refresh)
appStore.dispatch(clear())
timer.useFakeTimer()
initialize()
await timer.runAllAsync()
const exported = exportContext(appStore.getState(), [HOME_TOKEN], 'text/plain')
const expectedOutput = `- ${HOME_TOKEN}
- a
- b`
expect(exported).toEqual(expectedOutput)
})
})

Metadata

Metadata

Assignees

Labels

testTesting and project configuration

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions