up
This commit is contained in:
+49
-1
@@ -35,6 +35,7 @@ async function fixture(t: TestContext, secure = true) {
|
||||
}
|
||||
const model = {
|
||||
offline: false,
|
||||
server: 'https://server.test',
|
||||
introURL: 'https://media.test/intro.wav',
|
||||
musicOverride: null as Record<string, unknown> | null,
|
||||
mediaHandler: null as ((url: string) => Promise<Response>) | null,
|
||||
@@ -82,7 +83,7 @@ async function fixture(t: TestContext, secure = true) {
|
||||
headers: { 'Content-Type': 'audio/wav' },
|
||||
})
|
||||
}
|
||||
assert.equal(url.origin, 'https://server.test')
|
||||
assert.equal(url.origin, model.server)
|
||||
if (path === '/api/auth/login')
|
||||
return json({ accessToken: 'ACCESS-SECRET', refreshToken: 'REFRESH-SECRET' })
|
||||
if (path === '/api/auth/refresh') {
|
||||
@@ -264,6 +265,44 @@ async function fixture(t: TestContext, secure = true) {
|
||||
prepare,
|
||||
}
|
||||
}
|
||||
test('чистый профиль предлагает адрес сайта по умолчанию', async (t) => {
|
||||
const f = await fixture(t)
|
||||
assert.equal(f.online.snapshot().server, 'https://evening-detective.crabs-games.art')
|
||||
})
|
||||
|
||||
for (const [input, expected] of [
|
||||
['https://evening-detective.crabs-games.art/', 'https://evening-detective-api.crabs-games.art'],
|
||||
['http://127.0.0.1:8090', 'http://127.0.0.1:8090'],
|
||||
]) {
|
||||
test(`адрес входа ${input}: API и сохранённый адрес ${expected}`, async (t) => {
|
||||
const f = await fixture(t, false)
|
||||
f.model.server = expected!
|
||||
await f.online.act({
|
||||
action: 'login',
|
||||
server: input!,
|
||||
email: 'test@example.test',
|
||||
password: 'PASSWORD-SECRET',
|
||||
})
|
||||
assert.equal(f.online.snapshot().authenticated, true)
|
||||
assert.equal(f.online.snapshot().server, expected)
|
||||
assert.ok(f.requests.some((r) => r.path === '/api/auth/login'))
|
||||
await f.online.close()
|
||||
const restored = new Online(
|
||||
join(f.directory, 'connection'),
|
||||
f.store,
|
||||
new Controller(() => {}),
|
||||
f.secrets,
|
||||
f.fetchAPI,
|
||||
)
|
||||
try {
|
||||
await restored.initialize()
|
||||
assert.equal(restored.snapshot().server, expected)
|
||||
} finally {
|
||||
await restored.close()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function objectMusic(version: number, index = 0) {
|
||||
return {
|
||||
stateVersion: String(version),
|
||||
@@ -1189,3 +1228,12 @@ test('публикация текста после смены игры не от
|
||||
assert.equal(f.controller.state.catalog.key, null)
|
||||
assert.equal(f.controller.state.scene.stepIndex, null)
|
||||
})
|
||||
|
||||
test('истёкшая авторизация при подключении игры не маскируется сетевой ошибкой', async (t) => {
|
||||
const f = await fixture(t)
|
||||
await f.login()
|
||||
f.model.accessExpired = true
|
||||
f.model.refreshExpired = true
|
||||
await assert.rejects(f.online.act({ action: 'connect', gameId: 7 }), /Сессия истекла/)
|
||||
assert.equal(f.online.snapshot().authenticated, false)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user