Skip to content

Commit dfe482d

Browse files
committed
:(
1 parent 9045648 commit dfe482d

File tree

3 files changed

+24
-18
lines changed

3 files changed

+24
-18
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ name: CI
44
# events but only for the master branch
55
on:
66
push:
7-
branches: [main, prototype, "renovate/*"]
7+
branches: [main, "renovate/*"]
88
pull_request:
9-
branches: [main, prototype]
9+
branches: [main]
1010

1111
env:
1212
PG_PORT: 5432
@@ -33,5 +33,7 @@ jobs:
3333
run: cd frontend && npm install && npm run types
3434
- name: Building docker containers using docker-compose
3535
run: GO_MOD=go.mod docker-compose up -d --build
36+
- name: Check logs
37+
run: docker logs go_backend
3638
- name: React tests
3739
run: cd frontend && npm test

frontend/src/packages/api/tests/filesystemConsistency.test.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
11
import { describe } from "@jest/globals";
22
import { configureApiUrl, FilesystemAPI, resetApiUrl } from "../filesystem";
3-
import { CreateFilesystemEntryResponse, FilesystemEntry } from "../types/filesystem";
3+
import { CreateFilesystemEntryResponse, FilesystemEntry, IsCreateFilesystemEntryResponse, IsFilesystemEntry } from "../types/filesystem";
44
import { APIError, IsEmptyApiResponse } from "../types/general";
55

66
// filesystemConsistencyTests ensure that the contract maintained between the frontend and backend regarding endpoint input/response types are consistent
77
// note: requires the BE container to be up and running
8-
const hasFieldOfType = (o: any, fieldName: string, type: string): boolean =>
9-
fieldName in o && (typeof o[fieldName]) === type;
10-
11-
const IsFilesystemEntry = (o: any): o is FilesystemEntry =>
12-
hasFieldOfType(o, "EntityID", "string") &&
13-
hasFieldOfType(o, "EntityName", "string") &&
14-
hasFieldOfType(o, "IsDocument", "boolean") &&
15-
hasFieldOfType(o, "Parent", "string") &&
16-
hasFieldOfType(o, "Children", typeof []) &&
17-
o.Children.every((child: any) => IsFilesystemEntry(child));
18-
19-
const IsCreateFilesystemEntryResponse = (o: any): o is CreateFilesystemEntryResponse =>
20-
hasFieldOfType(o, "NewID", "string");
21-
228
beforeAll(() => {
239
configureApiUrl("http://localhost:8080")
2410
});

frontend/src/packages/api/types/filesystem.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,22 @@ export type FilesystemEntry = {
99

1010
export type CreateFilesystemEntryResponse = {
1111
NewID: string
12-
}
12+
}
13+
14+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
15+
export const hasFieldOfType = (o: any, fieldName: string, type: string): boolean =>
16+
fieldName in o && (typeof o[fieldName]) === type;
17+
18+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
19+
export const IsFilesystemEntry = (o: any): o is FilesystemEntry =>
20+
hasFieldOfType(o, "EntityID", "string") &&
21+
hasFieldOfType(o, "EntityName", "string") &&
22+
hasFieldOfType(o, "IsDocument", "boolean") &&
23+
hasFieldOfType(o, "Parent", "string") &&
24+
hasFieldOfType(o, "Children", typeof []) &&
25+
o.Children.every((child: any) => IsFilesystemEntry(child));
26+
27+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
28+
export const IsCreateFilesystemEntryResponse = (o: any): o is CreateFilesystemEntryResponse =>
29+
hasFieldOfType(o, "NewID", "string");
30+

0 commit comments

Comments
 (0)