Skip to content

Commit 0a38e23

Browse files
committed
feat: Toska test course
1 parent 3936e68 commit 0a38e23

File tree

4 files changed

+50
-56
lines changed

4 files changed

+50
-56
lines changed

src/client/locales/Kielet.py

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/server/db/seeders/chatInstance.ts

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,28 @@ import type { CourseUnit } from '../../types'
33
import { TEST_COURSES } from '../../../shared/testData'
44
import { ChatInstance } from '../models'
55

6-
const chatInstances = [
7-
TEST_COURSES.TEST_COURSE,
8-
TEST_COURSES.EXAMPLE_COURSE,
9-
{
10-
id: TEST_COURSES.OTE_SANDBOX.id,
11-
name: TEST_COURSES.OTE_SANDBOX.name,
12-
description: '',
13-
courseId: TEST_COURSES.OTE_SANDBOX.id,
14-
activityPeriod: TEST_COURSES.OTE_SANDBOX.activityPeriod,
15-
courseUnits: [
16-
{
17-
code: TEST_COURSES.OTE_SANDBOX.code,
18-
organisations: [
19-
{
20-
code: 'ote',
21-
id: 'ote',
22-
name: { en: 'OTE', fi: 'OTE', sv: 'OTE' },
23-
},
24-
],
25-
},
26-
] as CourseUnit[],
27-
},
28-
] as InferCreationAttributes<ChatInstance>[]
6+
const chatInstances = Object.values(TEST_COURSES).map((course) => ({
7+
id: course.id,
8+
name: course.name,
9+
description: '',
10+
courseId: course.id,
11+
activityPeriod: course.activityPeriod,
12+
code: course.code,
13+
model: 'model' in course ? course.model : undefined,
14+
usageLimit: 'usageLimit' in course ? course.usageLimit : undefined,
15+
courseUnits: [
16+
{
17+
code: course.code,
18+
organisations: [
19+
{
20+
code: 'ote',
21+
id: 'ote',
22+
name: { en: 'OTE', fi: 'OTE', sv: 'OTE' },
23+
},
24+
],
25+
},
26+
] as CourseUnit[],
27+
})) as unknown as InferCreationAttributes<ChatInstance>[]
2928

3029
const seedChatInstances = async () => {
3130
const operations: any[] = []

src/server/services/chatInstances/access.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@ export const getEnrolledCourses = async (user: User) => {
2222
// @ts-expect-error
2323
{ conflictFields: ['user_id', 'chat_instance_id'] },
2424
)
25+
26+
if (user.iamGroups.includes('grp-toska')) {
27+
await Enrolment.upsert(
28+
{
29+
userId: user.id,
30+
chatInstanceId: TEST_COURSES.TOSKA.id,
31+
},
32+
// TS is wrong here. It expects fields in camelCase
33+
// while the actual fields need to be in snake_case
34+
// @ts-expect-error
35+
{ conflictFields: ['user_id', 'chat_instance_id'] },
36+
)
37+
}
2538
}
2639

2740
const enrollments = (await Enrolment.findAll({

src/shared/testData.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,21 @@ export const TEST_COURSES = {
6767
},
6868
code: 'ESI-1234',
6969
},
70+
TOSKA: {
71+
id: 'toska',
72+
courseId: 'toska',
73+
name: {
74+
en: 'Toska',
75+
sv: 'Toska',
76+
fi: 'Toska',
77+
},
78+
activityPeriod: {
79+
startDate: '2025-08-26',
80+
endDate: '2100-08-26',
81+
},
82+
code: 'TOSKA-1234',
83+
usageLimit: 2_000_000,
84+
},
7085
}
7186

7287
export const TEST_USER_IDS = [

0 commit comments

Comments
 (0)