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,45 @@
|
||||
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 { formatCoinTenths, nextShown, previousShown, revealPeriods } from '../src/modules/gold-land/lesson/growthTable'
|
||||
|
||||
const periods = [1000, 1100, 1210, 1331]
|
||||
|
||||
test('period reveal can move forward and back without changing amounts', () => {
|
||||
const snapshot = periods.join(',')
|
||||
let shown = 1
|
||||
assert.deepEqual(revealPeriods(periods, shown), [1000])
|
||||
shown = nextShown(shown, periods.length)
|
||||
shown = nextShown(shown, periods.length)
|
||||
shown = nextShown(shown, periods.length)
|
||||
assert.deepEqual(revealPeriods(periods, shown), periods)
|
||||
shown = previousShown(shown)
|
||||
assert.equal(revealPeriods(periods, shown).at(-1), 1210)
|
||||
assert.equal(periods.join(','), snapshot)
|
||||
assert.equal(formatCoinTenths(1331), '۱۳۳٫۱')
|
||||
assert.equal(formatCoinTenths(1210), '۱۲۱')
|
||||
assert.equal(formatCoinTenths(1300), '۱۳۰')
|
||||
})
|
||||
|
||||
test('review keeps the chosen answer and a failed submit does not apply me', async () => {
|
||||
let answer = '120'
|
||||
answer = '121'
|
||||
resetMeMutationQueueForTests()
|
||||
let applied = 0
|
||||
bindMeMutationApply(() => {
|
||||
applied += 1
|
||||
return true
|
||||
})
|
||||
await assert.rejects(() => runMeMutation(async () => {
|
||||
throw new ApiNetworkError()
|
||||
}), ApiNetworkError)
|
||||
assert.equal(answer, '121')
|
||||
await assert.rejects(() => runMeMutation(async () => {
|
||||
invalidateSession()
|
||||
return { me: { user: { coins: 9 } } }
|
||||
}), StaleSessionError)
|
||||
assert.equal(applied, 0)
|
||||
assert.equal(answer, '121')
|
||||
})
|
||||
Reference in New Issue
Block a user