|
|
@@ -28,9 +28,9 @@ test('完课确认:学生与老师依次确认,重复确认幂等,越权
|
|
|
});
|
|
|
test('学习记录:仅关联已经提交答题记录的历史阅读',async()=>{
|
|
|
const db=new PGlite();try{
|
|
|
- await db.exec('CREATE TABLE "SurveyItem"("objectId" text primary key,"createdAt" timestamptz,"updatedAt" timestamptz,"user" text,"type" text,"title" text,"createOptions" jsonb,"isDeleted" boolean);CREATE TABLE "SurveyLog"("objectId" text primary key,"createdAt" timestamptz,"updatedAt" timestamptz,"user" text,"surveyItem" text,"isDeleted" boolean);');
|
|
|
+ await db.exec('CREATE TABLE "SurveyItem"("objectId" text primary key,"createdAt" timestamptz,"updatedAt" timestamptz,"user" text,"type" text,"title" text,"createOptions" jsonb,"isDeleted" boolean);CREATE TABLE "SurveyLog"("objectId" text primary key,"createdAt" timestamptz,"updatedAt" timestamptz,"user" text,"surveyItem" text);');
|
|
|
await db.query('INSERT INTO "SurveyItem" VALUES($1,now(),now(),$2,$3,$4,$5::jsonb,false),($6,now(),now(),$2,$3,$7,$8::jsonb,false)', ['article201','_User$learner','reading','已完成文章',JSON.stringify({params:{sourceStudyId:'201'}}),'article202','未完成文章',JSON.stringify({params:{sourceStudyId:'202'}})]);
|
|
|
- await db.query('INSERT INTO "SurveyLog" VALUES($1,now(),now(),$2,$3,false)', ['log201','_User$learner','SurveyItem$article201']);
|
|
|
+ await db.query('INSERT INTO "SurveyLog" VALUES($1,now(),now(),$2,$3)', ['log201','_User$learner','SurveyItem$article201']);
|
|
|
const source=gatewaySource.match(/async function appOverviewCompletedReadingMap[\s\S]*?\n}\nasync function appLearningTarget/)?.[0].replace(/\nasync function appLearningTarget[\s\S]*$/,'');assert.ok(source);
|
|
|
const context={Psql:{query:async(statement,args)=>(await db.query(statement,args)).rows},legacyUserObject:async()=>({id:'learner'})};vm.runInNewContext(source+';this.readingMap=appOverviewCompletedReadingMap',context);
|
|
|
const map=await context.readingMap([{GeneralID:201},{GeneralID:202}],100);assert.equal(map.get('201').readingArticleId,'article201');assert.equal(map.get('201').readingTitle,'已完成文章');assert.equal(map.has('202'),false);
|