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

Added session feedback controller and service with tests for error an… #520

Conversation

ckirby19
Copy link
Contributor

…d success cases

Issue link / number:

#396

What changes did you make?

  • Added session-feedback dto, controller, interface, module and service
  • Added the module to app.module.ts
  • Added a spec.ts file to test the session-feedback service

Why did you make the changes?

As requested on the ticket

Did you run tests?

Yes, I added new tests for the success and error cases in the service, and these tests were successful. I was also able to hit the endpoint with a POST request using postman and have a new session feedback entity be added to the session feedback database table

@Injectable()
export class SessionFeedbackService {
constructor(
@InjectRepository(PartnerAccessEntity)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not exactly sure why all these repos are needed, as it does not seem to be the case for other services in this repo, but I had to add all of these to get rid of any errors created. The only other service that this service directly depends on is the session service - the rest of the dependencies are just transitive

Copy link
Contributor

Choose a reason for hiding this comment

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

It's a great question and you are right to pick it up. It is something we are slowly trying to fix. The issue is the function getUserByFirebaseId in the userService. It does waayyyyyy too much. It's unfortunately used in the AuthGuard. The FirebaseAuthGuard is used across all the services. What we are trying to do is start to divide up how we fetch the data and ensure everything is fetched separately. See this issue. It's going to be a slow process.

@ckirby19
Copy link
Contributor Author

@eleanorreem

@ApiProperty({
enum: FEEDBACK_TAGS_ENUM,
type: String,
example: Object.values(FEEDBACK_TAGS_ENUM),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will show all the enum values in the swagger "Example Value" section in a list - not sure if this is more or less convenient than it just saying "string"

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

describe('SessionFeedbackService', () => {
let service: SessionFeedbackService;
let mockPartnerAccessRepository: DeepMocked<Repository<PartnerAccessEntity>>;
let mockPartnerRepository: DeepMocked<Repository<PartnerEntity>>;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same comment/question as below about all the transitive dependencies for this service

@@ -0,0 +1,10 @@
import { ISession } from 'src/session/session.interface';
Copy link
Contributor

@eleanorreem eleanorreem Jul 14, 2024

Choose a reason for hiding this comment

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

Could I be a pain and say lets get rid of this interface and just use the SessionFeedbackEntity type in the service?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to clarify, you mean I should completely remove the session-feedback.interface? I think I am only using the SessionFeedbackEntity in the session-feedback.service anyway so this should not be a problem. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes please!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed now :)

@eleanorreem
Copy link
Contributor

eleanorreem commented Jul 14, 2024

@ckirby19 Thanks for all your comments and I agree with them all. I should have highlighted the new type patterns in the ticket. Apologies. We are only just starting to clean up the backend as it hasn't been a priority! I have one small request to remove the ISessionFeedback which you highlighted. Otherwise, this is good to go.

@eleanorreem
Copy link
Contributor

Brilliant - thanks @ckirby19

@eleanorreem eleanorreem merged commit 9020bf0 into chaynHQ:develop Jul 16, 2024
3 checks passed
@ckirby19 ckirby19 deleted the feature/ticket-396-add-session-feedback-controller branch July 16, 2024 13:46
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.

2 participants