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

[Debt] Refactors tests to remove Pool Operator, Request Responder, and Community Manager roles #12530

Merged
merged 76 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from 71 commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
a686e9a
Remove tests that test role itself for Pool Operator
mnigh Jan 14, 2025
da828b8
Remove tests that test role itself for Request Responder
mnigh Jan 14, 2025
f8fa716
Remove tests that test role itself for Community Manager
mnigh Jan 14, 2025
339bd8c
Remove [email protected] user
mnigh Jan 14, 2025
ab82041
Replace asPoolOperator with asProcessOperator
mnigh Jan 14, 2025
3efea1c
Remove tests for AsPoolOperator
mnigh Jan 14, 2025
6484eb2
Remove tests for AsRequestResponder
mnigh Jan 14, 2025
33c0ee8
Remove tests for AsCommunityManager
mnigh Jan 14, 2025
460c09c
Remove poolRoles
mnigh Jan 14, 2025
5a328f5
Remove TeamsTest
mnigh Jan 14, 2025
02b4176
Replace pool_operator with process_operator
mnigh Jan 14, 2025
52f60de
Replace poolOperatorRole with processOperatorRole
mnigh Jan 14, 2025
1bd7265
Remove Pool Operator
mnigh Jan 14, 2025
a654fa2
Remove Pool Operator
mnigh Jan 14, 2025
e424f83
Remove pool operator
mnigh Jan 14, 2025
1bc90d0
Replace pool operator with process operator
mnigh Jan 14, 2025
5911ba5
Refactor tests
mnigh Jan 17, 2025
c1a1c5c
Refactor tests
mnigh Jan 17, 2025
c7cdda0
Refactor tests
mnigh Jan 17, 2025
102a265
Remove poolOperator
mnigh Jan 17, 2025
3375fb5
Replace requestResponder with communityRecruiter
mnigh Jan 17, 2025
9c95d99
Replace asRequestResponder with asCommunityRecruiter
mnigh Jan 17, 2025
86d7087
Remove asRequestResponder
mnigh Jan 17, 2025
18e0667
Remove requestResponder
mnigh Jan 17, 2025
8b3978c
Fix name
mnigh Jan 17, 2025
5c79e3e
Remove RequestResponder; Replace team with community
mnigh Jan 17, 2025
a092383
Refactor tests
mnigh Jan 17, 2025
a04c60c
Remove Team
mnigh Jan 17, 2025
cac5d72
Remove asRequestResponder
mnigh Jan 17, 2025
c5254d9
Replace asRequestResponder with asCommunityRecruiter
mnigh Jan 17, 2025
13ff3c7
Replace requestResponder with communityRecruiter
mnigh Jan 17, 2025
b323c0d
Refactor tests
mnigh Jan 17, 2025
6b4717b
Replace requestResponderUser with communityRecruiterUser
mnigh Jan 17, 2025
429002a
Remove responderUser
mnigh Jan 17, 2025
d65cf37
Remove requestResponderUser
mnigh Jan 17, 2025
acbf0e1
Remove requestResponderUser
mnigh Jan 17, 2025
6d48d87
Remove responderRoles
mnigh Jan 17, 2025
deb9f6b
Remove requestResponder
mnigh Jan 17, 2025
7eeb6f6
Remove asRequestResponder
mnigh Jan 17, 2025
597c1da
Replace request_responder with community_recruiter
mnigh Jan 17, 2025
e6d42ea
Remove asRequestResponder
mnigh Jan 17, 2025
ea66e99
Remove asRequestResponder
mnigh Jan 17, 2025
40044d9
Remove requestResponder
mnigh Jan 17, 2025
e7a04ee
Remove asCommunityManager
mnigh Jan 17, 2025
1da74fe
Remove asCommunityManager
mnigh Jan 17, 2025
1b25e7f
Replace communityManager with communityAdmin
mnigh Jan 17, 2025
6692bca
Replace communityManager with communityAdmin
mnigh Jan 17, 2025
9d2c132
Remove asCommunityManager
mnigh Jan 17, 2025
c43cf4a
Remove communityManagerUser
mnigh Jan 17, 2025
b9173c7
Update comment
mnigh Jan 17, 2025
bd871fd
Remove communityManagerUser
mnigh Jan 17, 2025
149d68b
Remove request_responder
mnigh Jan 17, 2025
e128472
Fix formatting
mnigh Jan 17, 2025
5ce53a9
Remove commented code
mnigh Jan 17, 2025
dbdbd02
Update name
mnigh Jan 20, 2025
3d29072
Refactor tests
mnigh Jan 20, 2025
aa1da1b
Refactor tests
mnigh Jan 20, 2025
d46f30d
Refactor tests
mnigh Jan 20, 2025
2773b72
Refactor tests
mnigh Jan 20, 2025
b145db6
Refactor tests
mnigh Jan 20, 2025
0480fcf
Refactor tests
mnigh Jan 20, 2025
56fc5d5
Fix email to match role
mnigh Jan 20, 2025
c2e6b4f
Refactor tests
mnigh Jan 20, 2025
cfa0e88
Merge branch 'main' into 12300-tests-refactor-legacy-roles
mnigh Jan 20, 2025
995a307
Update comments
mnigh Jan 20, 2025
c1734be
Remove testPlaceCandidateMutationSuspensionLogic
mnigh Jan 20, 2025
2b23654
Merge branch 'main' into 12300-tests-refactor-legacy-roles
mnigh Jan 20, 2025
02de58e
Remove asCommunityManager, asRequestResponder from seeder
mnigh Jan 20, 2025
b67aeb0
Remove asCommunityManager, asPoolOperator, asRequestResponder functions
mnigh Jan 20, 2025
e22d182
Remove tests for Request responder, Community manager
mnigh Jan 20, 2025
5e65459
Remove Request responder, Community manager users
mnigh Jan 20, 2025
7857ab8
Split tests into testManualStatusPlacedUpdatesTimestamps and testManu…
mnigh Jan 23, 2025
42276d3
Remove testPoolTeamScope
mnigh Jan 23, 2025
ac1a3ce
Remove testManualStatusPlacedUpdatesTimestamps
mnigh Jan 23, 2025
db2f02c
Replace processOperatorUser with communityRecruiterUser; Re-add Place…
mnigh Jan 23, 2025
c53c4c6
Fix formatting
mnigh Jan 23, 2025
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
43 changes: 0 additions & 43 deletions api/database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,49 +296,6 @@ public function asApplicant()
});
}

/**
* Attach the request responder role to a user after creation.
*
* @return $this
*/
public function asRequestResponder()
{
return $this->afterCreating(function (User $user) {
$user->addRole('request_responder');
});
}

/**
* Attach the pool operator role to a user after creation.
*
* @param string|array $team Name of the team or teams to attach the role to
* @return $this
*/
public function asPoolOperator(string|array $team)
{
return $this->afterCreating(function (User $user) use ($team) {
if (is_array($team)) {
foreach ($team as $singleTeam) {
$user->addRole('pool_operator', $singleTeam);
}
} else {
$user->addRole('pool_operator', $team);
}
});
}

/**
* Attach the Community Manager role to a user after creation.
*
* @return $this
*/
public function asCommunityManager()
{
return $this->afterCreating(function (User $user) {
$user->addRole('community_manager');
});
}

/**
* Attach the admin role to a user after creation.
*
Expand Down
39 changes: 0 additions & 39 deletions api/database/seeders/UserTestSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ public function run()
// shared auth users for testing
User::factory()
->asApplicant()
->asRequestResponder()
->asCommunityManager()
->asCommunityAdmin([$digitalCommunityId, $atipCommunityId])
->asAdmin()
->asPoolOperator(['digital-community-management', 'office-of-indigenous-initiatives'])
->withSkillsAndExperiences()
->asGovEmployee()
->create([
Expand All @@ -52,42 +49,6 @@ public function run()
'sub' => '[email protected]',
]);

User::factory()
->asApplicant()
->asCommunityManager()
->withSkillsAndExperiences()
->asGovEmployee()
->create([
'first_name' => 'Darcy',
'last_name' => 'Hussein',
'email' => '[email protected]',
'sub' => '[email protected]',
]);

User::factory()
->asApplicant()
->asRequestResponder()
->withSkillsAndExperiences()
->asGovEmployee()
->create([
'first_name' => 'Denver',
'last_name' => 'Reagan',
'email' => '[email protected]',
'sub' => '[email protected]',
]);

User::factory()
->asApplicant()
->asPoolOperator(['digital-community-management', 'office-of-indigenous-initiatives'])
->withSkillsAndExperiences()
->asGovEmployee()
->create([
'first_name' => 'Fang',
'last_name' => 'Dupont',
'email' => '[email protected]',
'sub' => '[email protected]',
]);

User::factory()
->asApplicant()
->withSkillsAndExperiences()
Expand Down
4 changes: 2 additions & 2 deletions api/tests/Feature/ActivityLogTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ protected function setUp(): void
'email' => '[email protected]',
'sub' => '[email protected]',
]);

$community = Community::factory()->create(['name' => 'test-community']);
$this->adminUser = User::factory()
->asApplicant()
->asRequestResponder()
->asCommunityRecruiter($community->id)
->asAdmin()
->create([
'email' => '[email protected]',
Expand Down
1 change: 0 additions & 1 deletion api/tests/Feature/ApplicantFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ protected function setUp(): void
// Create super user we run tests as
// Note: this extra user does change the results of a couple queries
$this->adminUser = User::factory()
->asRequestResponder()
->asAdmin()
->create([
'email' => '[email protected]',
Expand Down
1 change: 0 additions & 1 deletion api/tests/Feature/ApplicantTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ protected function setUp(): void

$this->adminUser = User::factory()
->asApplicant()
->asRequestResponder()
->asAdmin()
->create([
'email' => '[email protected]',
Expand Down
46 changes: 23 additions & 23 deletions api/tests/Feature/AssessmentResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
use App\Facades\Notify;
use App\Models\AssessmentResult;
use App\Models\AssessmentStep;
use App\Models\Community;
use App\Models\Pool;
use App\Models\PoolCandidate;
use App\Models\PoolSkill;
use App\Models\Skill;
use App\Models\Team;
use App\Models\User;
use Database\Seeders\RolePermissionSeeder;
use Illuminate\Foundation\Testing\RefreshDatabase;
Expand All @@ -33,9 +33,9 @@ class AssessmentResultTest extends TestCase
use RefreshesSchemaCache;
use UsesProtectedGraphqlEndpoint;

protected $teamUser;
protected $communityUser;

protected $team;
protected $community;

protected $pool;

Expand All @@ -45,16 +45,16 @@ protected function setUp(): void
Notify::spy(); // don't send any notifications
$this->seed(RolePermissionSeeder::class);
$this->bootRefreshesSchemaCache();
$this->team = Team::factory()->create();
$this->community = Community::factory()->create(['name' => 'test-community']);
$this->pool = Pool::factory()->create([
'team_id' => $this->team->id,
'community_id' => $this->community->id,
]);
$this->teamUser = User::factory()
$this->communityUser = User::factory()
->asApplicant()
->asPoolOperator($this->team->name)
->asProcessOperator($this->pool->id)
->create([
'email' => 'team[email protected]',
'sub' => 'team[email protected]',
'email' => 'community[email protected]',
'sub' => 'community[email protected]',
]);
}

Expand Down Expand Up @@ -119,7 +119,7 @@ public function testCreatingAssessmentResult(): void
$poolSkillModel = PoolSkill::first();

// can create education assessment result without pool skill
$this->actingAs($this->teamUser, 'api')
$this->actingAs($this->communityUser, 'api')
->graphQL(
$this->createAssessmentResult,
[
Expand All @@ -142,7 +142,7 @@ public function testCreatingAssessmentResult(): void
]);

// can create skill assessment result with pool skill
$this->actingAs($this->teamUser, 'api')
$this->actingAs($this->communityUser, 'api')
->graphQL(
$this->createAssessmentResult,
[
Expand Down Expand Up @@ -178,7 +178,7 @@ public function testUpdatingAssessmentResult(): void
'pool_id' => $this->pool->id,
]);

$this->actingAs($this->teamUser, 'api')
$this->actingAs($this->communityUser, 'api')
->graphQL(
$this->createAssessmentResult,
[
Expand All @@ -193,7 +193,7 @@ public function testUpdatingAssessmentResult(): void

$assessmentResult = AssessmentResult::first();

$this->actingAs($this->teamUser, 'api')
$this->actingAs($this->communityUser, 'api')
->graphQL(
$this->updateAssessmentResult,
[
Expand Down Expand Up @@ -225,7 +225,7 @@ public function testDeletingAssessmentResult(): void
'pool_id' => $this->pool->id,
]);

$this->actingAs($this->teamUser, 'api')
$this->actingAs($this->communityUser, 'api')
->graphQL(
$this->createAssessmentResult,
[
Expand All @@ -239,7 +239,7 @@ public function testDeletingAssessmentResult(): void

$assessmentResult = AssessmentResult::first();

$this->actingAs($this->teamUser, 'api')
$this->actingAs($this->communityUser, 'api')
->graphQL(
$this->deleteAssessmentResult,
[
Expand Down Expand Up @@ -274,7 +274,7 @@ public function testAssessmentResultPoolValidation(): void
$randomPoolSkillModel = PoolSkill::first(); // filled when calling pool factory above, this happens when calling it after skills seeded

// trying combinations of pools and assert they fail, with and without pool skill
$this->actingAs($this->teamUser, 'api')
$this->actingAs($this->communityUser, 'api')
->graphQL(
$this->createAssessmentResult,
[
Expand All @@ -285,7 +285,7 @@ public function testAssessmentResultPoolValidation(): void
]
)
->assertGraphQLValidationError('createAssessmentResult.assessmentStepId', 'AssessmentResultReferencesMultiplePools');
$this->actingAs($this->teamUser, 'api')
$this->actingAs($this->communityUser, 'api')
->graphQL(
$this->createAssessmentResult,
[
Expand All @@ -296,7 +296,7 @@ public function testAssessmentResultPoolValidation(): void
]
)
->assertGraphQLValidationError('createAssessmentResult.assessmentStepId', 'AssessmentResultReferencesMultiplePools');
$this->actingAs($this->teamUser, 'api')
$this->actingAs($this->communityUser, 'api')
->graphQL(
$this->createAssessmentResult,
[
Expand All @@ -310,7 +310,7 @@ public function testAssessmentResultPoolValidation(): void
->assertGraphQLValidationError('createAssessmentResult.assessmentStepId', 'AssessmentResultReferencesMultiplePools');

// success when all three reference one pool
$this->actingAs($this->teamUser, 'api')
$this->actingAs($this->communityUser, 'api')
->graphQL(
$this->createAssessmentResult,
[
Expand Down Expand Up @@ -341,7 +341,7 @@ public function testAssessmentResultUpdatingValidation(): void
]);
$poolSkillModel = PoolSkill::first();

$this->actingAs($this->teamUser, 'api')
$this->actingAs($this->communityUser, 'api')
->graphQL(
$this->createAssessmentResult,
[
Expand All @@ -360,7 +360,7 @@ public function testAssessmentResultUpdatingValidation(): void

// assert validation blocks some update combinations
// cannot have skill type with education justifications, validation draws from saved model
$this->actingAs($this->teamUser, 'api')
$this->actingAs($this->communityUser, 'api')
->graphQL(
$this->updateAssessmentResult,
[
Expand All @@ -373,7 +373,7 @@ public function testAssessmentResultUpdatingValidation(): void
->assertGraphQLValidationError('updateAssessmentResult.justifications', 'EducationJustificationsForSkillAssessment');

// cannot have skill decision level for unsuccessful, input changes it from successful
$this->actingAs($this->teamUser, 'api')
$this->actingAs($this->communityUser, 'api')
->graphQL(
$this->updateAssessmentResult,
[
Expand All @@ -398,7 +398,7 @@ public function testSkillAssessmentRequiresSkill(): void
'pool_id' => $this->pool->id,
]);

$this->actingAs($this->teamUser, 'api')
$this->actingAs($this->communityUser, 'api')
->graphQL(
$this->createAssessmentResult,
[
Expand Down
Loading
Loading