-
Notifications
You must be signed in to change notification settings - Fork 0
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
fix: added sample safety reviewers permission to submit review on sample safetyTest pr review #1
base: develop
Are you sure you want to change the base?
Conversation
Reviewer's Guide by SourceryThis pull request implements changes to allow Sample Safety Reviewers to submit reviews on sample safety. The main changes include updating the backend to handle sample safety reviews, modifying the frontend to support this new functionality, and adjusting the authorization logic. Additionally, some refactoring has been done to remove unused code and improve the overall structure of the application. Sequence DiagramsequenceDiagram
participant User as Sample Safety Reviewer
participant Frontend
participant Backend
participant DB as Database
User->>Frontend: Submit sample safety review
Frontend->>Backend: submitSampleReview mutation
Backend->>Backend: Authorize user
Backend->>DB: Update sample safety status and comment
DB-->>Backend: Confirm update
Backend-->>Frontend: Return updated sample
Frontend-->>User: Display success message
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Junjiequan - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Review instructions: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
</IconButton> | ||
</Tooltip> | ||
); | ||
// NOTE: For now preview works on proposal templates only. Another task is added to make it work for all of the templates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Consider generalizing preview functionality
While it's good that you've added a note about the limitation, consider creating a more general solution that can handle previews for all template types, not just proposals. This would make the code more flexible and easier to maintain in the long run.
const canPreview = (templateGroupId: TemplateGroupId) => {
// TODO: Implement preview functionality for all template types
return templateGroupId === TemplateGroupId.PROPOSAL;
};
if (canPreview(state.groupId)) {
topControlBarElements.push(
@@ -625,6 +625,80 @@ context('Samples tests', () => { | |||
cy.contains('HIGH_RISK'); // test if status has changed | |||
}); | |||
|
|||
it('Sample Safety Reviewer should be able to evaluate sample', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (complexity): Consider refactoring the test cases to reduce code duplication and improve maintainability.
The new test case for the Sample Safety Reviewer introduces unnecessary complexity through significant code duplication. To reduce complexity while maintaining specific role testing, consider the following improvements:
- Extract common setup steps into shared functions:
function createSampleAndSubmitProposal() {
cy.createSample({
proposalPk: createdProposalPk,
templateId: createdSampleTemplateId,
questionId: createdSampleQuestionId,
title: sampleTitle,
});
cy.submitProposal({ proposalPk: createdProposalPk });
}
function performSafetyReview(status, comment) {
cy.get('[data-cy="safety-status"]').click();
cy.contains(status).click();
if (comment) {
cy.get('[data-cy="safety-comment"]').type(comment);
}
cy.get('[data-cy="submit"]').click();
}
- Refactor the tests to use these shared functions:
it('User should be able to review sample safety', function () {
// ... existing setup code ...
createSampleAndSubmitProposal();
cy.login(user);
// ... navigation to sample ...
performSafetyReview('High risk');
cy.contains('HIGH_RISK');
});
it('Sample Safety Reviewer should be able to evaluate sample', function () {
if (!featureFlags.getEnabledFeatures().get(FeatureId.SAMPLE_SAFETY)) {
this.skip();
}
createSampleAndSubmitProposal();
const sampleSafetyReviewer = initialDBData.users.user1;
cy.updateUserRoles({
id: sampleSafetyReviewer.id,
roles: [initialDBData.roles.sampleSafetyReviewer],
});
cy.login(sampleSafetyReviewer);
// ... navigation to sample ...
performSafetyReview('Low risk', safetyComment);
// ... verification steps ...
performSafetyReview('High risk');
cy.contains('HIGH_RISK');
});
These changes will significantly reduce code duplication, improve maintainability, and make it easier to add future tests for different user roles or scenarios.
Description
Currently, Safety Review Manager cannot be able to submit review to the submitted samples due to permission error
Added sample safety reviewers permission to submit review on sample safety
Motivation and Context
Updated Roles and Permissions to the Safety Review Manager.
How Has This Been Tested
e2e
Fixes
Changes
Depends on
Tests included/Docs Updated?
Summary by Sourcery
Fix permission issues for sample safety reviewers by introducing a new mutation
submitSampleReview
to handle sample reviews. Refactor frontend components to simplify preview logic and remove unnecessary props. Add tests to ensure the new functionality works as expected.New Features:
submitSampleReview
to allow sample safety reviewers to submit reviews with safety status and comments.Bug Fixes:
Enhancements:
PreviewTemplateModal
component to simplify the rendering logic by removing thetemplateGroupId
parameter.previewMode
prop from various container components to streamline the component interfaces.Tests: