Commit graph

98 commits

Author SHA1 Message Date
David Mehren
7adbc72a5f
Merge pull request #1130 from hedgedoc/history/transaction 2021-05-02 18:15:05 +02:00
Philip Molares
2ba1be6ea3 PrivateHistoryE2E: Extend POST /me/history
Test the correct behaviour in error cases

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-05-02 18:09:16 +02:00
David Mehren
5e61de9bd5
Use node12 TypeScript base config
TypeScript recommends using a base config from https://github.com/tsconfig/bases.

Using this config reduces compile times by ~30%
and the size of the dist folder by ~45%.
It also enables the recommended `esModuleInterop` option,
which necessitated some changes to imports.
See also https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html#support-for-import-d-from-cjs-from-commonjs-modules-with---esmoduleinterop

Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-29 22:55:01 +02:00
Yannick Bungers
0bad4827bf
Merge pull request #1179 from hedgedoc/util/replaceNull 2021-04-25 21:03:45 +02:00
Philip Molares
38ab6dc27b NotesE2ETest: Changed test for title and description
They should not return null and that's correctly tested now.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-24 21:33:47 +02:00
Philip Molares
1f897636bb PublicApi: Add option to keep media to DELETE /notes/{note}
This adds a body to the route DELETE /notes/{note} of the public api to specify if the associated media uploads of the note should be kept or deleted.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-22 23:13:13 +02:00
Philip Molares
6ac267a226 PrivateApi: Add option to keep media to DELETE /notes/{note}
This adds a body to the route DELETE /notes/{note} of the private api to specify if the associated media uploads of the note should be kept or deleted.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-22 23:13:13 +02:00
David Mehren
a60b959a64
Media E2E tests: Add error handling for upload cleanup
Previously, `fs.rmdir` was called multiple times on the same path,
even when the path was already deleted.
This causes test failures in Node 16.

This commit extracts the cleanup code into a utility function
and ensures that no error is thrown when the given path is already deleted.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-22 21:29:23 +02:00
Philip Molares
c3047509aa PrivateE2EMe: Add E2E test for private api /me routes
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-19 23:04:15 +02:00
Yannick Bungers
eaa5254418
Merge pull request #1039 from hedgedoc/fix/permissionsCreationAndFinding 2021-04-18 22:45:24 +02:00
Philip Molares
c6612f55c7 PublicNotesE2E: Add extra test for note deletion
This test checks if permission are correctly set and no error is thrown if the note is deleted.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-18 22:35:28 +02:00
David Mehren
6699e4b0c8
Merge pull request #1131 from hedgedoc/improve/logging 2021-04-18 22:28:11 +02:00
David Mehren
0e5ce048a3
Merge pull request #1127 from hedgedoc/history/entryRename 2021-04-17 19:23:19 +02:00
Philip Molares
434bc55bab Tests: Removed all eslint-disable lines
As we now disable what we don't need in the eslint config, we don't need this anymore.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-16 10:14:05 +02:00
Philip Molares
0269b5e87a Logging: Remove NestConsoleLoggerService
This is not necessary anymore, because we can inject ConsoleLoggerService directly.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-13 23:58:17 +02:00
Philip Molares
adffd68e68 PrivateAPI: Add lastVisited to HistoryEntryImportDto
As the DTO is only for importing an existing history the lastVisited of those entries should also be posted.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-11 12:37:47 +02:00
Philip Molares
4f858c51d2 PrivateAPI: Add pinStatus to HistoryEntryImportDto
As the DTO is only for importing an existing history the pinStatus of those entries should also be posted.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-11 12:37:38 +02:00
Philip Molares
085241999b PrivateAPI: Rename HistoryEntryCreationDto to HistoryEntryImportDto
As the DTO is used to import a whole list of history entries rather than creating a single history entry (there is no way of doing that at the moment)

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-10 23:26:58 +02:00
Philip Molares
70e7318180 NotesE2EPrivate: Fix copy&paste error
Since large parts of this test were copied from the public api e2e test, somethings still used the public api e2e test files.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-01 00:18:24 +02:00
Philip Molares
dbbc73be02 MediaE2E: Fix typo in comments
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-01 00:18:24 +02:00
Philip Molares
a2e7616484 E2ETests: Use recursive for 'uploads/' deletion.
This ensures the folder is always deleted, even if there are still files (from previous broken tests) in it.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-01 00:18:24 +02:00
Philip Molares
5a3ddc28fc MediaE2E: Extract 'uploads' deletion
The deletion of upload was moved to beforeEach and afterEach block in the 'POST /media' > 'fails' tests.
The test if the folder was not created, because there was no file uploaded, now correctly expects the behaviour.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-01 00:18:21 +02:00
Philip Molares
d586b84d8b MediaE2E: Add app.close() to afterAll
This terminates the app after all test have finished.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-31 22:36:14 +02:00
Philip Molares
d44af9dd5e PrivateE2EMedia: Add E2E test for private api /media routes
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-25 22:26:43 +01:00
Philip Molares
406c8d620a PrivateE2E: Add test fixtures for private api
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-25 22:26:43 +01:00
David Mehren
3bc0a46630
Merge pull request #1060 from hedgedoc/port/mediaE2ETests
PublicE2EMedia: Port the extra test from the private api
2021-03-25 22:08:35 +01:00
Philip Molares
8f2cc55e5b PrivateE2ENotes: Add E2E test for private api /notes routes
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-25 21:29:51 +01:00
Philip Molares
1249302321 PublicE2EMedia: Port the extra test from the private api
This ports the extra tests in the POST /media test from the private apis to the public apis E2E tests.
Also the whole test suit was renamed to 'Media'.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-25 20:12:22 +01:00
Philip Molares
69550a8243 PublicE2E: Remove uploaded files after test
This way the tests can run in any order as some of the media tests rely on an empty (or non-existing) uploads directory.
Also the me e2e test was renamed to the correct name.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-24 22:20:20 +01:00
Philip Molares
de82b72b62 Config: Create new config mocks for tests
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-21 20:08:09 +01:00
Philip Molares
381718f0eb Config: Move config mocks in own folder
To clean up the config folder, all mocks are now in it's own folder.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-21 19:59:05 +01:00
Philip Molares
9b427dc6d1 NotesE2ETest: Add GET /api/v2/notes/{note}/media test
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-21 19:22:40 +01:00
David Mehren
6d8780de4b
Merge pull request #1047 from hedgedoc/docs/apidocs 2021-03-21 19:07:14 +01:00
Philip Molares
168d85778c Docs: Add more documentation to the public api
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-20 10:18:44 +01:00
Philip Molares
25126eb03f PrivateE2E: Add history test
Test the /me/history route in the private API.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-18 21:56:39 +01:00
Yannick Bungers
ef352a1313 Add GET /me/media
Returns all media files uploaded by the authenticated user.

Signed-off-by: Yannick Bungers <git@innay.de>
2021-03-14 17:47:16 +01:00
David Mehren
b67ec817e6
Merge pull request #993 from hedgedoc/publicApi/me 2021-03-14 16:28:49 +01:00
Philip Molares
9199bd21a1 PublicE2E: Add test for GET /me/history/{note} in me.e2e-spec.ts
add test for GET /me/history/{note}
add error cases to PUT /me/history/{note} and DELETE /me/history/{note}
activate missing test GET /me/notes/

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-06 17:55:48 +01:00
Philip Molares
1df0bda61d NotesService: Add e2e tests for forbidden note alias
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-06 17:49:33 +01:00
Philip Molares
2f028a4aae Config: Add forbiddenNoteIds to AppConfig
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-27 23:04:49 +01:00
David Mehren
4d94739a9f
Fix various ESLint errors in E2E tests
Signed-off-by: David Mehren <git@herrmehren.de>
2021-02-27 16:11:27 +01:00
Yannick Bungers
e081bd196b Rename getNoteContentByNote to getNoteContent
Signed-off-by: Yannick Bungers <git@innay.de>
2021-02-22 22:34:18 +01:00
Philip Molares
5f49cb8d48 NotesService: Replace noteByIdOrAlias with note as parameter
As the NotesController has the note already, because it checked with it if the user has the permission to perform the action, it's not necessary to get the note from the DB again, instead we should just provide the note to the functions directly.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-20 19:51:27 +01:00
Philip Molares
54286d589d NotesE2ETests: Ensure posting the same note alias twice fails
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-20 19:51:27 +01:00
Philip Molares
336117cef5 NotesService: Rename getCurrentContent to getNoteContentByNote
The new name should better explain what this functions does.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-19 13:36:01 +01:00
Philip Molares
8e9717c92a NotesE2E: Fix e2e test
split success and fail cases in separate tests for better readability
add the correct user to all notes created by service (instead of api) to make the permissions checks viable.
extracted test content of notes to a global variable.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-18 22:25:55 +01:00
Philip Molares
604e08df6b Media E2E Tests: Delete uploaded files after test
Remove uploaded files after media e2e tests ran
Remove /uploads/ folder after all media e2e tests ran
This way the uploads folder doesn't grow while working on other e2e tests

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-16 21:23:24 +01:00
Philip Molares
e6c1cc7810 MediaService: Add unit tests
The file test.zip is used to fail the saveFile test with 'MIME Type not supported'

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-16 21:12:23 +01:00
Philip Molares
81c6ef178d Tests: Fix GET /me e2e test
Since the /me route does work now, we should reactivate (and fix) this test, too.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-06 10:58:34 +01:00
Philip Molares
24ccb1fcd0 Tests: Rename users.e2e-spec.ts to me.e2e-spec.ts
As users.e2e-spec.ts tests the MeController this commit renames the test appropriately

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-04 21:50:19 +01:00