Merge branch 'dev' into refactor/common

This commit is contained in:
Tibo De Peuter 2025-04-01 21:38:50 +02:00
commit a4408b5bc0
Signed by: tdpeuter
GPG key ID: 38297DE43F75FFE2
145 changed files with 3437 additions and 2822 deletions

View file

@ -10,9 +10,12 @@ import { LearningObjectIdentifier } from '../../../src/entities/content/learning
const NEWER_TEST_SUFFIX = 'nEweR';
function createTestLearningObjects(learningObjectRepo: LearningObjectRepository): { older: LearningObject; newer: LearningObject } {
async function createTestLearningObjects(learningObjectRepo: LearningObjectRepository): Promise<{
older: LearningObject;
newer: LearningObject;
}> {
const olderExample = example.createLearningObject();
learningObjectRepo.save(olderExample);
await learningObjectRepo.save(olderExample);
const newerExample = example.createLearningObject();
newerExample.title = 'Newer example';
@ -32,23 +35,21 @@ describe('AttachmentRepository', () => {
beforeAll(async () => {
await setupTestApp();
attachmentRepo = getAttachmentRepository();
exampleLearningObjects = createTestLearningObjects(getLearningObjectRepository());
exampleLearningObjects = await createTestLearningObjects(getLearningObjectRepository());
});
it('can add attachments to learning objects without throwing an error', () => {
it('can add attachments to learning objects without throwing an error', async () => {
attachmentsOlderLearningObject = Object.values(example.createAttachment).map((fn) => fn(exampleLearningObjects.older));
for (const attachment of attachmentsOlderLearningObject) {
attachmentRepo.save(attachment);
}
await Promise.all(attachmentsOlderLearningObject.map(async (attachment) => attachmentRepo.save(attachment)));
});
let attachmentOnlyNewer: Attachment;
it('allows us to add attachments with the same name to a different learning object without throwing an error', () => {
it('allows us to add attachments with the same name to a different learning object without throwing an error', async () => {
attachmentOnlyNewer = Object.values(example.createAttachment)[0](exampleLearningObjects.newer);
attachmentOnlyNewer.content.write(NEWER_TEST_SUFFIX);
attachmentRepo.save(attachmentOnlyNewer);
await attachmentRepo.save(attachmentOnlyNewer);
});
let olderLearningObjectId: LearningObjectIdentifier;

View file

@ -10,7 +10,7 @@ import { Language } from 'dwengo-1-common/src/util/language';
function expectToHaveFoundPrecisely(expected: LearningPath, result: LearningPath[]): void {
expect(result).toHaveProperty('length');
expect(result.length).toBe(1);
expectToBeCorrectEntity({ entity: result[0]! }, { entity: expected });
expectToBeCorrectEntity({ entity: result[0] }, { entity: expected });
}
function expectToHaveFoundNothing(result: LearningPath[]): void {