Skip to content

Commit

Permalink
Merge branch 'development' into 3437-snippets-search-id
Browse files Browse the repository at this point in the history
  • Loading branch information
fnocetti authored Jan 29, 2021
2 parents 6590dee + 3b3c1b8 commit b670661
Show file tree
Hide file tree
Showing 18 changed files with 658 additions and 258 deletions.
2 changes: 1 addition & 1 deletion app/api/files/filesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const appendFile = promisify(fs.appendFile);

const fileExists = async (filePath: FilePath): Promise<boolean> =>
new Promise((resolve, reject) => {
fs.stat(filePath, err => {
fs.access(filePath, err => {
if (err === null) {
resolve(true);
}
Expand Down
5 changes: 5 additions & 0 deletions app/api/files/specs/filesystem.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ describe('files', () => {
fs.writeFileSync(`${__dirname}/file2`, '');
});

afterAll(() => {
fs.unlinkSync(`${__dirname}/file1`);
fs.unlinkSync(`${__dirname}/file2`);
});

describe('deleteFiles', () => {
it('should delete all files passed', async () => {
await deleteFiles([`${__dirname}/file1`, `${__dirname}/file2`]);
Expand Down
6 changes: 3 additions & 3 deletions app/api/files/specs/publicRoutes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('public routes', () => {
beforeEach(async () => {
spyOn(search, 'indexEntities').and.returnValue(Promise.resolve());
spyOn(Date, 'now').and.returnValue(1000);
spyOn(errorLog, 'error'); //just to avoid annoying console output
spyOn(errorLog, 'error');
await db.clearAllAndLoad(fixtures);
setupTestUploadedPaths();
});
Expand All @@ -65,15 +65,15 @@ describe('public routes', () => {
);

const [newEntity] = await entities.get({ title: 'public submit' });
const attachments = newEntity.attachments || [];
const { attachments } = newEntity;
expect(attachments).toEqual([expect.objectContaining({ originalname: 'attachment.txt' })]);

const [uploadedFile] = await files.get({ entity: newEntity.sharedId });
expect(uploadedFile.originalname).toBe('12345.test.pdf');
expect(uploadedFile.status).toBe('ready');

expect(await fileExists(uploadsPath(uploadedFile.filename))).toBe(true);
expect(await fileExists(attachmentsPath(attachments[0].filename))).toBe(true);
expect(await fileExists(attachmentsPath(attachments?.[0].filename))).toBe(true);
});

it('should send an email', async () => {
Expand Down
Loading

0 comments on commit b670661

Please sign in to comment.