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

chore: post new note without parentId passed #153

Closed
wants to merge 39 commits into from
Closed

Conversation

D2J3D
Copy link

@D2J3D D2J3D commented Dec 15, 2023

Added two test for POST /note endpoint. Test "Post a new note without parentId passed" checks that POST request retrieves with 200 status code and created note publicId. Test "Returns status 401 when the user is not authorized" checks that status code of POST request is 401 when authorization data wasn't provided.

Copy link
Contributor

@elizachi elizachi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should remove all code related to child-parent-relationship because is not a finished feature yet. Leave only part of the code with your new tests.

src/presentation/http/router/note.test.ts Show resolved Hide resolved
src/presentation/http/router/note.test.ts Outdated Show resolved Hide resolved
@elizachi
Copy link
Contributor

elizachi commented Jan 6, 2024

Please, resolve conflict
Снимок экрана от 2024-01-06 19-13-09

docker-compose.yml Outdated Show resolved Hide resolved
src/presentation/http/router/note.ts Outdated Show resolved Hide resolved
src/presentation/http/router/note.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@elizachi elizachi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now looks perfect

src/presentation/http/router/note.test.ts Show resolved Hide resolved
},
});

expect(response?.statusCode).toBe(expectedStatus);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does response have body? if it does, you should check if returned note contains appended data

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If i'm not mistaken, definition of fastify.post in router/note.ts says, that method replies with notePublicId, so i check the returned id to be string with length > 0
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so i check the returned id to be string with length > 0

where is this check?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
in the test 'Post a new note without parentId passed.'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these checks should be added to this test case as well

body: {},
});

expect(response?.statusCode).toBe(expectedStatus);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to use expectedStatus variable, you can just use number literal

body: {},
});

expect(response?.statusCode).toBe(expectedStatus);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same about expectedStatus

expect(response?.json().message).toStrictEqual(expectedMessage);
});

test.todo('Update note by public id with 200 status, user is creator of the note');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/presentation/http/router/note.test.ts Show resolved Hide resolved
src/tests/test-data/notes.json Show resolved Hide resolved
D2J3D and others added 5 commits January 15, 2024 03:22
* Update migrations

* Update more migrations

* fix of rename tables migrations

- fixed `notes_settings` -> `note_settings` renaming
- fixed `teams` -> `note_teams` renaming

* test error fix

cannot change owner of sequence "note_teams_id_seq"

* deleted unwanted string

deleted commented string

---------

Co-authored-by: e11sy <[email protected]>

(cherry picked from commit 317c682)
migrations/tenant/[email protected] Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you have this file updated?

},
});

expect(response?.statusCode).toBe(expectedStatus);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so i check the returned id to be string with length > 0

where is this check?

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

test('Returns status 406 when the public id does not exist', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the difference between this test case and the previous one?

src/presentation/http/router/note.test.ts Outdated Show resolved Hide resolved
Copy link
Member

@neSpecc neSpecc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove irrelevant changes form PR please and reply to comments

},
});

expect(response?.statusCode).toBe(expectedStatus);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these checks should be added to this test case as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this file changed?

@neSpecc
Copy link
Member

neSpecc commented Jan 28, 2024

Closed to be reassigned

@neSpecc neSpecc closed this Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants