Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- run: cp .env.example .env && php artisan key:generate
working-directory: apps/api
# PageAuditTest drives a real browser through tools/qa-page.cjs. Without playwright-core
# and a headless shell the auditor answers "skipped" and eleven tests fail on it.
# the tests skip, and without a headless shell eleven of them fail.
- uses: actions/setup-node@v4
with:
node-version: 22
Expand Down
7 changes: 6 additions & 1 deletion apps/api/app/Domain/Qa/PageAudit.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ class PageAudit

public function __construct(private readonly string $script, private readonly ?string $node = null) {}

/**
* Node, the script and the browser driver it requires. Without playwright-core beside the
* script (`npm --prefix tools ci`, as the image and CI do) the script dies on its first line.
*/
public function available(): bool
{
return is_file($this->script) && $this->binary() !== null;
return is_file($this->script) && $this->binary() !== null
&& is_file(dirname($this->script).'/node_modules/playwright-core/package.json');
}

/**
Expand Down
8 changes: 4 additions & 4 deletions apps/api/tests/Feature/PageAuditTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
/**
* The auditor itself, driving a real browser over a real page.
*
* Skipped where node or chromium is not installed, which is every developer machine that has not
* asked for them and no CI box we run. That is deliberate: the checks are only meaningful against
* a browser, and a mocked browser would test the mock.
* Skipped where node or playwright-core is missing: run `npm --prefix tools ci --omit=dev` once to
* get them. CI installs both and runs these for real. That is deliberate: the checks are only
* meaningful against a browser, and a mocked browser would test the mock.
*/
class PageAuditTest extends TestCase
{
private function audit(): PageAudit
{
$a = app(PageAudit::class);
if (! $a->available()) {
$this->markTestSkipped('no node or no qa-page.cjs on this machine');
$this->markTestSkipped('no node, qa-page.cjs or playwright-core on this machine (npm --prefix tools ci)');
}

return $a;
Expand Down
Loading