extend(TestCase::class) ->use(RefreshDatabase::class) ->beforeEach(function () { // EnsureSetupComplete middleware redirects to /setup unless an admin exists. User::factory()->admin()->create(['email' => 'admin-setup@test.com']); }) ->in('Feature', 'Browser', 'Screenshots'); /* |-------------------------------------------------------------------------- | Expectations |-------------------------------------------------------------------------- | | When you're writing tests, you often need to check that values meet certain conditions. The | "expect()" function gives you access to a set of "expectations" methods that you can use | to assert different things. Of course, you may extend the Expectation API at any time. | */ expect()->extend('toBeOne', function () { return $this->toBe(1); }); /* |-------------------------------------------------------------------------- | Functions |-------------------------------------------------------------------------- | | While Pest is very powerful out-of-the-box, you may have some testing code specific to your | project that you don't want to repeat in every file. Here you can also expose helpers as | global functions to help you to reduce the number of lines of code in your test files. | */ function something() { // .. } /** * A page of SealShare, once it can be used: loaded, with Alpine and Livewire started. Shared by * every file under tests/Browser, so a browser test needs no visit() of its own to define it. */ function ready(mixed $page): mixed { return $page->waitForEvent('networkidle') ->assertScript("document.readyState === 'complete' && typeof window.Alpine !== 'undefined' && typeof window.Livewire !== 'undefined'"); } /** * A chunk of a registered file, encrypted with its share's key and its header's nonce prefix. */ function encryptedChunk(ShareFile $file, string $plaintext, int $index, bool $isLast): string { $encryption = app(FileEncryptionService::class); $header = $encryption->parseHeader(file_get_contents(app(ShareService::class)->storedFilePath($file), false, null, 0, FileEncryptionService::HEADER_LENGTH)); return $encryption->encryptChunk($plaintext, $file->share->encryption_key, $header['noncePrefix'], $index, $isLast); }