Skip to content

Commit

Permalink
Merge branch 'main' into 10368-remove-teams-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
mnigh authored Dec 20, 2024
2 parents e2b217f + ad77880 commit 72317fa
Show file tree
Hide file tree
Showing 23 changed files with 1,113 additions and 790 deletions.
71 changes: 50 additions & 21 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ on:
- "**.md"

pull_request:
paths-ignore:
- "**.md"
paths:
- .github/workflows/*playwright*.yml
- apps/**
- packages/**
- api/**
merge_group:
branches: [main]
# Concurrency is used to cancel other currently-running jobs, to preserve
Expand All @@ -29,6 +32,11 @@ jobs:
playwright:
name: Playwright
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2, 3, 4]
shardTotal: [4]
env:
# Use native docker command within docker compose
COMPOSE_DOCKER_CLI_BUILD: 1
Expand Down Expand Up @@ -69,28 +77,49 @@ jobs:
- name: Install Playwright Browsers
run: npx playwright install chromium webkit --with-deps

- name: Run Chromium Tests
run: pnpm run e2e:playwright:chromium
- name: Run Tests
run: pnpm run e2e:playwright --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
- uses: actions/upload-artifact@v4
if: always()
with:
name: chromium-report
path: ./apps/playwright/playwright-report/
retention-days: 30
name: blob-report-${{ matrix.shardIndex }}
path: ./apps/playwright/blob-report
retention-days: 1

- name: Run Webkit Tests
run: pnpm run e2e:playwright:webkit
- uses: actions/upload-artifact@v4
if: always()
with:
name: webkit-report
path: ./apps/playwright/playwright-report/
retention-days: 30
merge-reports:
# Merge reports after playwright-tests, even if some shards have failed
if: ${{ !cancelled() }}
needs: [playwright]
runs-on: ubuntu-latest
env:
PNPM_VERSION: "9.12.3"
steps:
- uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: pnpm

# Fix some issue with cache in setup-node
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Download blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@v4
with:
path: all-blob-reports
pattern: blob-report-*
merge-multiple: true

- name: Check status of containers
if: failure()
run: docker compose ps
- name: Merge into HTML Report
run: npx playwright merge-reports --reporter html ./all-blob-reports

- name: "Check logs: web server container"
if: failure()
run: docker compose logs webserver
- name: Upload HTML report
uses: actions/upload-artifact@v4
with:
name: html-report--attempt-${{ github.run_attempt }}
path: playwright-report
retention-days: 14
50 changes: 50 additions & 0 deletions api/app/Console/Commands/SuspendPlacedCandidates.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace App\Console\Commands;

use App\Enums\PoolCandidateStatus;
use App\Models\PoolCandidate;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\Collection;

class SuspendPlacedCandidates extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:suspend-placed-candidates';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Set suspended at date to now() for placed term and indeterminate candidates';

/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$applicableStatuses = [PoolCandidateStatus::PLACED_TERM->name, PoolCandidateStatus::PLACED_INDETERMINATE->name];

PoolCandidate::whereIn('pool_candidate_status', $applicableStatuses)
->whereNull('suspended_at')
->with('user')
->chunkById(100, function (Collection $candidates) {
foreach ($candidates as $candidate) {
/** @var \App\Models\PoolCandidate $candidate */
$candidate->suspended_at = Carbon::now();
$candidate->save();
}
}
);

return Command::SUCCESS;
}
}
3 changes: 3 additions & 0 deletions api/app/Enums/PoolCandidateStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ enum PoolCandidateStatus
case EXPIRED;
case REMOVED;

// searchable candidates, so the available status and others treated as available for search purposes
public static function qualifiedEquivalentGroup(): array
{
return [
PoolCandidateStatus::QUALIFIED_AVAILABLE->name,
PoolCandidateStatus::PLACED_TENTATIVE->name,
PoolCandidateStatus::PLACED_CASUAL->name,
PoolCandidateStatus::PLACED_TERM->name,
PoolCandidateStatus::PLACED_INDETERMINATE->name,
];
}

Expand Down
8 changes: 8 additions & 0 deletions api/app/GraphQL/Mutations/PlaceCandidate.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\GraphQL\Mutations;

use App\Enums\PlacementType;
use App\Models\PoolCandidate;
use Carbon\Carbon;

Expand All @@ -25,6 +26,13 @@ public function __invoke($_, array $args)
$candidate->computed_final_decision = $finalDecision['decision'];
$candidate->computed_final_decision_weight = $finalDecision['weight'];

// If setting to term or indeterminate automatically suspend the candidate, otherwise null the field
if ($placementType === PlacementType::PLACED_TERM->name || $placementType === PlacementType::PLACED_INDETERMINATE->name) {
$candidate->suspended_at = $now;
} else {
$candidate->suspended_at = null;
}

$candidate->save();

return $candidate;
Expand Down
1 change: 1 addition & 0 deletions api/app/GraphQL/Mutations/RevertPlaceCandidate.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function __invoke($_, array $args)
$candidate->pool_candidate_status = PoolCandidateStatus::QUALIFIED_AVAILABLE->name;
$candidate->placed_at = null;
$candidate->placed_department_id = null;
$candidate->suspended_at = null;

$candidate->save();

Expand Down
2 changes: 1 addition & 1 deletion api/app/GraphQL/Queries/CountPoolCandidatesByPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __invoke($_, array $args)
}
});

// available candidates scope (scope CANDIDATE_STATUS_QUALIFIED_AVAILABLE or CANDIDATE_STATUS_PLACED_CASUAL, or PLACED_TENTATIVE)
// available candidates scope (qualifiedEquivalentGroup, not expired, not suspended)
PoolCandidate::scopeAvailable($queryBuilder);

// Only display IT & OTHER publishing group candidates
Expand Down
2 changes: 1 addition & 1 deletion api/app/Models/PoolCandidate.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
* @property ?int $status_weight
* @property string $pool_id
* @property string $user_id
* @property ?\Illuminate\Support\Carbon $suspended_at
* @property ?\Carbon\Carbon $suspended_at
* @property \Illuminate\Support\Carbon $created_at
* @property ?\Illuminate\Support\Carbon $updated_at
* @property array $submitted_steps
Expand Down
54 changes: 54 additions & 0 deletions api/tests/Feature/CountPoolCandidatesByPoolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -828,4 +828,58 @@ public function testAdditionalAvailabilityScopes()
],
]);
}

// asserts placed term/indeterminate candidates can appear in this query, can't check by id though so check that 2 out of 3 appear
public function testPlacedSuspendedNotSuspendedCandidates()
{
$itPool = Pool::factory()->create([
...$this->poolData(),
'publishing_group' => PublishingGroup::IT_JOBS->name,
]);
PoolCandidate::truncate();
PoolCandidate::factory()->availableInSearch()->create([
'pool_id' => $itPool,
'pool_candidate_status' => PoolCandidateStatus::PLACED_TERM->name,
'suspended_at' => null,
]);
PoolCandidate::factory()->availableInSearch()->create([
'pool_id' => $itPool,
'pool_candidate_status' => PoolCandidateStatus::PLACED_INDETERMINATE->name,
'suspended_at' => null,
]);
PoolCandidate::factory()->availableInSearch()->create([
'pool_id' => $itPool,
'pool_candidate_status' => PoolCandidateStatus::PLACED_TERM->name,
'suspended_at' => config('constants.far_past_datetime'),
]);

// expect 2, the 2 un-suspended ones
$this->graphQL(
/** @lang GraphQL */
'
query ($where: ApplicantFilterInput) {
countPoolCandidatesByPool(where: $where) {
pool { id }
candidateCount
}
}
',
[
'where' => [
'pools' => [
['id' => $itPool->id],
],
],
]
)->assertSimilarJson([
'data' => [
'countPoolCandidatesByPool' => [
[
'pool' => ['id' => $itPool->id],
'candidateCount' => 2,
],
],
],
]);
}
}
33 changes: 33 additions & 0 deletions api/tests/Feature/PoolCandidateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
use Tests\TestCase;
use Tests\UsesProtectedGraphqlEndpoint;

use function PHPUnit\Framework\assertEqualsCanonicalizing;

class PoolCandidateTest extends TestCase
{
use MakesGraphQLRequests;
Expand Down Expand Up @@ -849,4 +851,35 @@ public function testScopeCandidatesInCommunity(): void
])->assertJsonFragment(['total' => 1])
->assertJsonFragment(['id' => $communityCandidate->id]);
}

// test scopeAvailable
public function testScopeAvailable(): void
{
PoolCandidate::truncate();
$candidate = PoolCandidate::factory()->availableInSearch()->create([
'pool_candidate_status' => PoolCandidateStatus::PLACED_TERM->name,
'expiry_date' => null,
'suspended_at' => null,
]);

$suspendedCandidate = PoolCandidate::factory()->availableInSearch()->create([
'pool_candidate_status' => PoolCandidateStatus::PLACED_TERM->name,
'expiry_date' => null,
'suspended_at' => config('constants.far_past_datetime'),
]);

$expiredCandidate = PoolCandidate::factory()->availableInSearch()->create([
'pool_candidate_status' => PoolCandidateStatus::PLACED_TERM->name,
'expiry_date' => config('constants.past_date'),
'suspended_at' => null,
]);

$queryBuilder = PoolCandidate::query();
$candidateIds = PoolCandidate::scopeAvailable($queryBuilder)->get()->pluck('id')->toArray();

// suspended and expired not present
assertEqualsCanonicalizing([
$candidate->id,
], $candidateIds);
}
}
Loading

0 comments on commit 72317fa

Please sign in to comment.