Skip to content

Conversation

@NishaSharma14
Copy link
Contributor

No description provided.

@NishaSharma14 NishaSharma14 self-assigned this Dec 18, 2025
@NishaSharma14 NishaSharma14 linked an issue Dec 18, 2025 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Dec 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.78%. Comparing base (6637646) to head (7d671d8).

Additional details and impacted files
@@                Coverage Diff                @@
##             development    #1322      +/-   ##
=================================================
+ Coverage          56.63%   57.78%   +1.14%     
  Complexity          2268     2268              
=================================================
  Files                207      207              
  Lines               8733     8733              
=================================================
+ Hits                4946     5046     +100     
+ Misses              3787     3687     -100     
Flag Coverage Δ
unittests 57.78% <100.00%> (+1.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds comprehensive test coverage for email notifications across the application and fixes critical bugs in mail classes that were preventing proper rendering. The changes ensure mailable classes work correctly with both array and object data structures while adding proper validation through tests.

  • Adds 167 lines of new tests for Study-related email notifications
  • Adds 168 lines of new tests for Project-related email notifications
  • Adds 180 lines of new tests for Draft processing email notifications
  • Fixes bugs in StudyPublish and DraftProcessedNotifyAdmins mail classes
  • Updates model fillable attributes to support proper invitation creation in tests

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/Feature/Study/StudyMailTest.php New test file covering StudyInvitation and StudyPublish mail rendering, properties, and queueable behavior
tests/Feature/Project/ProjectMailTest.php New test file covering ProjectInvitation, ProjectArchival, ProjectDeletion, and related notification mail classes
tests/Feature/DraftFeatureTest.php Adds tests for DraftProcessed and DraftProcessedNotifyAdmins mail classes with various scenarios including release dates and identifier handling
app/Mail/StudyPublish.php Fixes bug where studies array was accessed with array syntax instead of object property syntax
app/Mail/DraftProcessedNotifyAdmins.php Fixes critical bug where release_date was parsed before checking if project exists, preventing null pointer errors
app/Models/ProjectInvitation.php Adds project_id to fillable attributes to support invitation creation in tests
app/Models/TeamInvitation.php Adds team_id to fillable attributes to support invitation creation in tests
tests/Unit/Models/ProjectInvitationModelTest.php Updates test to verify project_id is in fillable attributes

]);

// Update identifier via database query
\DB::table('projects')->where('id', $project->id)->update(['identifier' => 123]);
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

The DB facade is used without being imported. Add use Illuminate\Support\Facades\DB; at the top of the file, and then use DB::table() instead of \DB::table().

Copilot uses AI. Check for mistakes.
Comment on lines +123 to +129
$this->project->deleted_on = Carbon::now();
putenv('COOL_OFF_PERIOD=45');

$mailable = new ProjectDeletion($this->project);
$content = $mailable->render();

$this->assertNotEmpty($content);
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

Using putenv() to change environment variables in tests can cause side effects and pollution between tests. Consider using Config::set() instead (which is already used elsewhere in this test file), or if you need to test environment-specific behavior, use the withoutMix() or withEnv() test helpers. Also, the changed environment variable is not cleaned up after the test, which could affect subsequent tests.

Suggested change
$this->project->deleted_on = Carbon::now();
putenv('COOL_OFF_PERIOD=45');
$mailable = new ProjectDeletion($this->project);
$content = $mailable->render();
$this->assertNotEmpty($content);
$this->withEnv(['COOL_OFF_PERIOD' => 45], function (): void {
$this->project->deleted_on = Carbon::now();
$mailable = new ProjectDeletion($this->project);
$content = $mailable->render();
$this->assertNotEmpty($content);
});

Copilot uses AI. Check for mistakes.
Comment on lines +45 to +71
public function test_project_invitation_mail_can_be_rendered(): void
{
$invitation = ProjectInvitationModel::create([
'project_id' => $this->project->id,
'email' => '[email protected]',
'role' => 'collaborator',
]);

$mailable = new ProjectInvitation($invitation);
$content = $mailable->render();

$this->assertNotEmpty($content);
}

public function test_project_invitation_mail_has_correct_properties(): void
{
$invitation = ProjectInvitationModel::create([
'project_id' => $this->project->id,
'email' => '[email protected]',
'role' => 'collaborator',
]);

$mailable = new ProjectInvitation($invitation);

$this->assertSame($invitation->id, $mailable->invitation->id);
$this->assertSame($invitation->email, $mailable->invitation->email);
}
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

The ProjectInvitation mailable implements ShouldQueue, but unlike the StudyInvitation tests (line 76-87 in StudyMailTest.php), there's no test verifying this queueable behavior. Consider adding a test similar to test_study_invitation_mail_is_queueable to ensure consistency in test coverage.

Copilot uses AI. Check for mistakes.
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.

Add tests for mails

2 participants