Verify V1 scheduling and static boundaries; record Terra workflow and visual QA
This commit is contained in:
parent
ffaa1f6afa
commit
4bf121728b
4 changed files with 36 additions and 13 deletions
|
|
@ -4,6 +4,7 @@ import path from 'node:path';
|
|||
import { unzipSync } from 'fflate';
|
||||
import { afterEach, describe, expect, it } from 'vitest';
|
||||
import { loadConfig } from '../server/config.ts';
|
||||
import { createApp } from '../server/app.ts';
|
||||
import { encryptSecret, decryptSecret } from '../server/crypto.ts';
|
||||
import { openDatabase } from '../server/db.ts';
|
||||
import { TINY_PNG } from '../server/documents/testFixtures.ts';
|
||||
|
|
@ -48,6 +49,22 @@ describe('private image authorization', () => {
|
|||
});
|
||||
|
||||
describe('key durability and restore', () => {
|
||||
it('does not serve a sibling directory through an encoded static path', async () => {
|
||||
app = await createTestApp();
|
||||
const dir = temporary();
|
||||
const web = path.join(dir, 'web');
|
||||
fs.mkdirSync(web);
|
||||
fs.mkdirSync(path.join(dir, 'web-private'));
|
||||
fs.writeFileSync(path.join(web, 'index.html'), '<html>Study Desk</html>');
|
||||
fs.writeFileSync(path.join(dir, 'web-private', 'secret.txt'), 'private fixture');
|
||||
const hono = createApp({ ...app.ctx, config: { ...app.ctx.config, webDir: web } });
|
||||
const result = await hono.request('/..%2fweb-private%2fsecret.txt');
|
||||
expect(result.status).toBe(404);
|
||||
expect(await result.text()).not.toContain('private fixture');
|
||||
expect((await hono.request('/%ZZ')).status).toBe(400);
|
||||
expect((await hono.request('/classes/example')).status).toBe(200);
|
||||
});
|
||||
|
||||
it('refuses a damaged encryption key without replacing it', () => {
|
||||
const dir = temporary();
|
||||
const config = loadConfig({ dataDir: dir }, {});
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ describe('safe migration paths', () => {
|
|||
CREATE TABLE Question (id TEXT, quizSetId TEXT, type TEXT, prompt TEXT, rationale TEXT, category TEXT, sortOrder INTEGER);
|
||||
CREATE TABLE AnswerOption (id TEXT, questionId TEXT, text TEXT, isCorrect INTEGER, sortOrder INTEGER);
|
||||
CREATE TABLE QuizAttempt (id TEXT, quizSetId TEXT, score REAL, maxScore INTEGER, answersJson TEXT, isPartialRetake INTEGER, completedAt INTEGER);
|
||||
CREATE TABLE SpacedRepetitionCardState (flashcardId TEXT, state INTEGER, reps INTEGER, due INTEGER, stability REAL, difficulty REAL, scheduledDays INTEGER, learningSteps INTEGER, lapses INTEGER, lastReview INTEGER, firstReviewedAt INTEGER);
|
||||
CREATE TABLE SpacedRepetitionCardState (flashcardId TEXT, state INTEGER, reps INTEGER, due INTEGER, stability REAL, difficulty REAL, scheduledDays INTEGER, learningSteps INTEGER, lapses INTEGER, lastReview INTEGER, firstReviewedAt INTEGER, elapsedDays INTEGER);
|
||||
INSERT INTO Class VALUES ('c','Legacy class',0,1700000000000);
|
||||
INSERT INTO MaterialGroup VALUES ('g','c','Legacy group',0,1700000000000);
|
||||
INSERT INTO Deck VALUES ('d','c','g','Legacy deck','',0,1700000000000);
|
||||
|
|
@ -32,7 +32,7 @@ describe('safe migration paths', () => {
|
|||
INSERT INTO Question VALUES ('q','z','MULTIPLE_CHOICE','Pick A','Reason','Topic',0);
|
||||
INSERT INTO AnswerOption VALUES ('a','q','A',1,0),('b','q','B',0,1);
|
||||
INSERT INTO QuizAttempt VALUES ('attempt','z',1,1,'{"q":["a"]}',0,1700000000000);
|
||||
INSERT INTO SpacedRepetitionCardState VALUES ('f',2,7,1800000000000,15,5,14,0,1,1700000000000,1600000000000);
|
||||
INSERT INTO SpacedRepetitionCardState VALUES ('f',2,7,1800000000000,15,5,14,0,1,1700000000000,1600000000000,12);
|
||||
`);
|
||||
old.close();
|
||||
const digest = () => crypto.createHash('sha256').update(fs.readFileSync(file)).digest('hex');
|
||||
|
|
@ -44,8 +44,8 @@ describe('safe migration paths', () => {
|
|||
expect(digest()).toBe(before);
|
||||
const classes = (await app.api('GET', '/api/classes')).body.classes;
|
||||
expect(classes[0].name).toBe('Legacy class');
|
||||
const card = app.ctx.db.get<{ reps: number; due: number }>('SELECT reps, due FROM cards');
|
||||
expect(card).toMatchObject({ reps: 7, due: 1800000000000 });
|
||||
const card = app.ctx.db.get<{ reps: number; due: number; elapsed_days: number }>('SELECT reps, due, elapsed_days FROM cards');
|
||||
expect(card).toMatchObject({ reps: 7, due: 1800000000000, elapsed_days: 12 });
|
||||
const attempt = app.ctx.db.get<{ id: string }>('SELECT id FROM attempts')!;
|
||||
const result = (await app.api('GET', `/api/attempts/${attempt.id}`)).body;
|
||||
expect(JSON.stringify(result)).toContain('Pick A');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue