feat: complete the thirteen-stage learning experience and E2E journey
Play levels 7-13 in the app and pin E2E to the local thirteen-stage backend commit. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
import { ApiNetworkError, StaleSessionError } from '../src/api/errors'
|
||||
import { invalidateSession } from '../src/api/authSession'
|
||||
import { bindMeMutationApply, resetMeMutationQueueForTests, runMeMutation } from '../src/api/meMutationQueue'
|
||||
import { clonePlan, initialPlan, revisedPlan } from '../src/modules/gold-land/financial-goal/goalMath'
|
||||
|
||||
test('changing the later rate does not change the initial snapshot', () => {
|
||||
const initial = initialPlan(30, 120, 15, 30, 10)
|
||||
assert.equal(initial.weeks, 6)
|
||||
assert.equal(initial.remaining, 90)
|
||||
const snapshot = clonePlan(15)
|
||||
const later = revisedPlan(30, 120, snapshot, 5, 20)
|
||||
assert.equal(snapshot, 15)
|
||||
assert.equal(later.balanceAfterTwo, 50)
|
||||
assert.equal(later.totalWeeks, 2 + Math.ceil(70 / 20))
|
||||
const paused = revisedPlan(30, 120, snapshot, 0, 15)
|
||||
assert.equal(paused.balanceAfterTwo, 45)
|
||||
assert.equal(snapshot, 15)
|
||||
})
|
||||
|
||||
test('review and a failed submit keep the chosen plan', async () => {
|
||||
let answers = { 'q-left': '120' }
|
||||
answers = { ...answers, 'q-left': '90' }
|
||||
const plan = clonePlan({ initialWeekly: 15, exceptionWeekly: 5, continueWeekly: 15 })
|
||||
resetMeMutationQueueForTests()
|
||||
let applied = 0
|
||||
bindMeMutationApply(() => {
|
||||
applied += 1
|
||||
return true
|
||||
})
|
||||
await assert.rejects(() => runMeMutation(async () => { throw new ApiNetworkError() }), ApiNetworkError)
|
||||
await assert.rejects(() => runMeMutation(async () => {
|
||||
invalidateSession()
|
||||
return { me: { user: { coins: 1 } } }
|
||||
}), StaleSessionError)
|
||||
assert.equal(applied, 0)
|
||||
assert.equal(answers['q-left'], '90')
|
||||
assert.equal(plan.exceptionWeekly, 5)
|
||||
})
|
||||
Reference in New Issue
Block a user