Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change join route params to body #257

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/presentation/http/router/join.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@
headers: {
authorization: `Bearer ${accessToken}`,
},
body: { invitationHash },
url: `/join/${invitationHash}`,
});

expect(response?.statusCode).toBe(406);

expect(response?.json()).toStrictEqual({

Check failure on line 51 in src/presentation/http/router/join.test.ts

View workflow job for this annotation

GitHub Actions / tests (fix/schema)

src/presentation/http/router/join.test.ts > Join API > POST /join/:hash > Returns 406 when user is already in the team

AssertionError: expected { Object (message) } to strictly equal { message: 'User already in team' } - Expected + Received Object { - "message": "User already in team", + "message": "WHERE parameter \"invitation_hash\" has invalid \"undefined\" value", } ❯ src/presentation/http/router/join.test.ts:51:32
message: 'User already in team',
});
});
Expand All @@ -61,6 +62,7 @@
headers: {
authorization: `Bearer ${accessToken}`,
},
body: { hash },
url: `/join/${hash}`,
});

Expand Down Expand Up @@ -107,10 +109,11 @@
headers: {
authorization: `Bearer ${accessToken}`,
},
body: { invitationHash },
url: `/join/${invitationHash}`,
});

expect(response?.statusCode).toBe(200);

Check failure on line 116 in src/presentation/http/router/join.test.ts

View workflow job for this annotation

GitHub Actions / tests (fix/schema)

src/presentation/http/router/join.test.ts > Join API > POST /join/:hash > Returns 200 when user is added to the team

AssertionError: expected 406 to be 200 // Object.is equality - Expected + Received - 200 + 406 ❯ src/presentation/http/router/join.test.ts:116:36

expect(response?.json()).toMatchObject({
result: {
Expand Down
10 changes: 5 additions & 5 deletions src/presentation/http/router/join.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface JoinRouterOptions {
/**
* Note settings service instance
*/
noteSettings: NoteSettingsService
noteSettings: NoteSettingsService;
}

/**
Expand All @@ -25,12 +25,12 @@ const JoinRouter: FastifyPluginCallback<JoinRouterOptions> = (fastify, opts, don
const noteSettingsService = opts.noteSettings;

fastify.post<{
Params: {
Body: {
hash: string
}
},
}>('/:hash', {
schema: {
params: {
body: {
hash: {
$ref: 'JoinSchemaParams#/properties/hash',
},
Expand All @@ -54,7 +54,7 @@ const JoinRouter: FastifyPluginCallback<JoinRouterOptions> = (fastify, opts, don
],
},
}, async (request, reply) => {
const { hash } = request.params;
const { hash } = request.body;
const { userId } = request;
let result: TeamMember | null = null;

Expand Down
Loading