style updates
This commit is contained in:
@@ -56,7 +56,7 @@ class AuthBrowserTest extends DuskTestCase
|
||||
|
||||
$browser->waitUntil(
|
||||
'window.location.pathname === "/" || window.location.pathname === "/login" || ! document.querySelector(".wms-app-shell")',
|
||||
15
|
||||
15,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ if (link) {
|
||||
window.location.href = expectedPath;
|
||||
}
|
||||
JS,
|
||||
json_encode($path, JSON_THROW_ON_ERROR)
|
||||
json_encode($path, JSON_THROW_ON_ERROR),
|
||||
));
|
||||
|
||||
$browser->waitForLocation($path, 15);
|
||||
|
||||
@@ -19,7 +19,7 @@ trait InteractsWithWmsData
|
||||
/**
|
||||
* Create or update the MPBA platform administrator used by browser tests.
|
||||
*
|
||||
* @param array<string, mixed> $overrides
|
||||
* @param array<string, mixed> $overrides
|
||||
*/
|
||||
protected function platformAdminUser(array $overrides = []): User
|
||||
{
|
||||
@@ -53,7 +53,7 @@ trait InteractsWithWmsData
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $overrides
|
||||
* @param array<string, mixed> $overrides
|
||||
*/
|
||||
protected function tenantCompany(array $overrides = []): Company
|
||||
{
|
||||
@@ -79,7 +79,7 @@ trait InteractsWithWmsData
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $overrides
|
||||
* @param array<string, mixed> $overrides
|
||||
*/
|
||||
protected function tenantUser(array $overrides = []): User
|
||||
{
|
||||
@@ -160,7 +160,8 @@ trait InteractsWithWmsData
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, string> $features
|
||||
* @param array<int, string> $features
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function platformPriceAttributes(
|
||||
|
||||
@@ -17,8 +17,8 @@ class PlatformAdministrationBrowserTest extends DuskTestCase
|
||||
$admin = $this->platformAdminUser();
|
||||
$this->seedPlatformDashboardData();
|
||||
|
||||
$companyName = 'Abbott Logistics '.uniqid();
|
||||
$billingEmail = 'billing+'.uniqid().'@abbott.example';
|
||||
$companyName = 'Abbott Logistics ' . uniqid();
|
||||
$billingEmail = 'billing+' . uniqid() . '@abbott.example';
|
||||
|
||||
$this->browse(function (Browser $browser) use ($admin): void {
|
||||
$browser->loginAs($admin)
|
||||
@@ -32,8 +32,8 @@ class PlatformAdministrationBrowserTest extends DuskTestCase
|
||||
$admin = $this->platformAdminUser();
|
||||
|
||||
$unique = str_replace('.', '', uniqid('', true));
|
||||
$companyName = 'Abbott Logistics '.$unique;
|
||||
$billingEmail = 'billing+'.$unique.'@abbott.example';
|
||||
$companyName = 'Abbott Logistics ' . $unique;
|
||||
$billingEmail = 'billing+' . $unique . '@abbott.example';
|
||||
|
||||
$this->browse(function (Browser $browser) use ($admin, $companyName, $billingEmail): void {
|
||||
$browser->loginAs($admin)
|
||||
|
||||
@@ -61,7 +61,7 @@ class PlatformPricingBrowserTest extends DuskTestCase
|
||||
$this->assertSingleProfessionalHeader($browser, '');
|
||||
$browser->assertPresent('input[name="name"]')
|
||||
->assertPresent('input[name="monthly_amount"]')
|
||||
->visit('/admin/prices/'.$price->id.'/edit');
|
||||
->visit('/admin/prices/' . $price->id . '/edit');
|
||||
|
||||
$this->assertSingleProfessionalHeaderExists($browser);
|
||||
$browser->assertPresent('input[name="name"]')
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace Tests\Browser;
|
||||
|
||||
use Laravel\Dusk\Browser;
|
||||
use Modules\Warehouse\app\Models\WarehouseValidationRule;
|
||||
use Tests\Browser\Concerns\InteractsWithWmsBrowser;
|
||||
use Tests\Browser\Concerns\InteractsWithWmsData;
|
||||
use Tests\DuskTestCase;
|
||||
@@ -17,8 +16,8 @@ class WarehouseBrowserTest extends DuskTestCase
|
||||
{
|
||||
$user = $this->tenantUser();
|
||||
$warehouse = $this->seedWarehouse($user->company);
|
||||
$ruleName = 'Require expiry date '.uniqid();
|
||||
$ruleKey = 'expiry-required-'.uniqid();
|
||||
$ruleName = 'Require expiry date ' . uniqid();
|
||||
$ruleKey = 'expiry-required-' . uniqid();
|
||||
|
||||
$this->browse(function (Browser $browser) use ($user, $warehouse, $ruleName, $ruleKey): void {
|
||||
$browser->loginAs($user)
|
||||
@@ -56,8 +55,8 @@ class WarehouseBrowserTest extends DuskTestCase
|
||||
|
||||
$user->company->warehouses()->delete();
|
||||
|
||||
$warehouseName = 'East Midlands DC '.uniqid();
|
||||
$warehouseCode = 'E'.substr(strtoupper(uniqid()), -4);
|
||||
$warehouseName = 'East Midlands DC ' . uniqid();
|
||||
$warehouseCode = 'E' . substr(strtoupper(uniqid()), -4);
|
||||
|
||||
$this->browse(function (Browser $browser) use ($user, $warehouseName, $warehouseCode): void {
|
||||
$browser->loginAs($user)
|
||||
@@ -79,8 +78,8 @@ class WarehouseBrowserTest extends DuskTestCase
|
||||
$user = $this->tenantUser();
|
||||
$warehouse = $this->seedWarehouse($user->company);
|
||||
|
||||
$ruleName = 'Require serial number '.uniqid();
|
||||
$ruleKey = 'serial-required-'.uniqid();
|
||||
$ruleName = 'Require serial number ' . uniqid();
|
||||
$ruleKey = 'serial-required-' . uniqid();
|
||||
|
||||
$this->browse(function (Browser $browser) use ($user, $warehouse, $ruleName, $ruleKey): void {
|
||||
$browser->loginAs($user)
|
||||
|
||||
@@ -12,7 +12,7 @@ trait CreatesApplication
|
||||
*/
|
||||
public function createApplication(): Application
|
||||
{
|
||||
$app = require __DIR__.'/../bootstrap/app.php';
|
||||
$app = require __DIR__ . '/../bootstrap/app.php';
|
||||
|
||||
$app->make(Kernel::class)->bootstrap();
|
||||
|
||||
|
||||
+13
-14
@@ -40,7 +40,7 @@ abstract class DuskTestCase extends BaseTestCase
|
||||
*/
|
||||
protected function driver(): RemoteWebDriver
|
||||
{
|
||||
$options = (new ChromeOptions())->addArguments([
|
||||
$options = (new ChromeOptions)->addArguments([
|
||||
'--disable-gpu',
|
||||
'--headless=new',
|
||||
'--window-size=1920,1080',
|
||||
@@ -56,8 +56,8 @@ abstract class DuskTestCase extends BaseTestCase
|
||||
$_ENV['DUSK_DRIVER_URL'] ?? 'http://127.0.0.1:9515',
|
||||
DesiredCapabilities::chrome()->setCapability(
|
||||
ChromeOptions::CAPABILITY,
|
||||
$options
|
||||
)
|
||||
$options,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ abstract class DuskTestCase extends BaseTestCase
|
||||
|
||||
$_ENV['APP_URL'] = $url;
|
||||
$_SERVER['APP_URL'] = $url;
|
||||
putenv('APP_URL='.$url);
|
||||
putenv('APP_URL=' . $url);
|
||||
|
||||
if (property_exists(BaseTestCase::class, 'baseUrl')) {
|
||||
static::$baseUrl = $url;
|
||||
@@ -94,7 +94,7 @@ abstract class DuskTestCase extends BaseTestCase
|
||||
$fallbackUrl = 'http://127.0.0.1:8000';
|
||||
$_ENV['APP_URL'] = $fallbackUrl;
|
||||
$_SERVER['APP_URL'] = $fallbackUrl;
|
||||
putenv('APP_URL='.$fallbackUrl);
|
||||
putenv('APP_URL=' . $fallbackUrl);
|
||||
|
||||
if (property_exists(BaseTestCase::class, 'baseUrl')) {
|
||||
static::$baseUrl = $fallbackUrl;
|
||||
@@ -115,14 +115,14 @@ abstract class DuskTestCase extends BaseTestCase
|
||||
private static function startLaravelServer(string $host, int $port): void
|
||||
{
|
||||
$root = dirname(__DIR__);
|
||||
$logPath = $root.'/storage/logs/dusk-server.log';
|
||||
$logPath = $root . '/storage/logs/dusk-server.log';
|
||||
|
||||
if (! is_dir(dirname($logPath))) {
|
||||
@mkdir(dirname($logPath), 0775, true);
|
||||
}
|
||||
|
||||
$php = escapeshellarg(PHP_BINARY);
|
||||
$artisan = escapeshellarg($root.'/artisan');
|
||||
$artisan = escapeshellarg($root . '/artisan');
|
||||
$hostArg = escapeshellarg($host);
|
||||
$portArg = (string) $port;
|
||||
$log = escapeshellarg($logPath);
|
||||
@@ -157,7 +157,7 @@ abstract class DuskTestCase extends BaseTestCase
|
||||
usleep(100_000);
|
||||
} while (microtime(true) < $deadline);
|
||||
|
||||
$log = dirname(__DIR__).'/storage/logs/dusk-server.log';
|
||||
$log = dirname(__DIR__) . '/storage/logs/dusk-server.log';
|
||||
$hint = is_file($log) ? " Check {$log}." : '';
|
||||
|
||||
throw new \RuntimeException("{$service} is not reachable at {$host}:{$port}.{$hint}");
|
||||
@@ -171,8 +171,8 @@ abstract class DuskTestCase extends BaseTestCase
|
||||
*/
|
||||
private static function ensureChromeDriverBinaryAlias(): void
|
||||
{
|
||||
$binDirectory = dirname(__DIR__).'/vendor/laravel/dusk/bin';
|
||||
$expected = $binDirectory.'/chromedriver-mac-arm';
|
||||
$binDirectory = dirname(__DIR__) . '/vendor/laravel/dusk/bin';
|
||||
$expected = $binDirectory . '/chromedriver-mac-arm';
|
||||
|
||||
if (is_file($expected)) {
|
||||
@chmod($expected, 0755);
|
||||
@@ -185,18 +185,17 @@ abstract class DuskTestCase extends BaseTestCase
|
||||
}
|
||||
|
||||
$candidates = array_values(array_filter(
|
||||
glob($binDirectory.'/chromedriver*') ?: [],
|
||||
glob($binDirectory . '/chromedriver*') ?: [],
|
||||
static function (string $path) use ($expected): bool {
|
||||
return is_file($path)
|
||||
&& $path !== $expected
|
||||
&& ! str_ends_with($path, '.zip')
|
||||
&& ! str_ends_with($path, '.txt');
|
||||
}
|
||||
},
|
||||
));
|
||||
|
||||
usort($candidates, static function (string $left, string $right): int {
|
||||
$score = static fn (string $path): int =>
|
||||
str_contains($path, 'mac-arm64') ? 0
|
||||
$score = static fn (string $path): int => str_contains($path, 'mac-arm64') ? 0
|
||||
: (str_contains($path, 'mac-arm') ? 1
|
||||
: (str_contains($path, 'mac') ? 2 : 3));
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ class EmailVerificationTest extends TestCase
|
||||
Event::assertDispatched(Verified::class);
|
||||
|
||||
$this->assertTrue($user->fresh()->hasVerifiedEmail());
|
||||
$response->assertRedirect(route('dashboard', absolute: false).'?verified=1');
|
||||
$response->assertRedirect(route('dashboard', absolute: false) . '?verified=1');
|
||||
}
|
||||
|
||||
public function test_email_is_not_verified_with_invalid_hash(): void
|
||||
@@ -80,7 +80,7 @@ class EmailVerificationTest extends TestCase
|
||||
);
|
||||
|
||||
$this->actingAs($user)->get($verificationUrl)
|
||||
->assertRedirect(route('dashboard', absolute: false).'?verified=1');
|
||||
->assertRedirect(route('dashboard', absolute: false) . '?verified=1');
|
||||
|
||||
$this->assertTrue($user->fresh()->hasVerifiedEmail());
|
||||
Event::assertNotDispatched(Verified::class);
|
||||
|
||||
@@ -46,7 +46,7 @@ class InternalApiCoverageTest extends TestCase
|
||||
{
|
||||
config(['platform.internal_api_key' => 'testing-secret']);
|
||||
$timestamp = now()->subMinutes(10)->toIso8601String();
|
||||
$signature = hash_hmac('sha256', $timestamp.'.', 'testing-secret');
|
||||
$signature = hash_hmac('sha256', $timestamp . '.', 'testing-secret');
|
||||
|
||||
$this->withHeaders([
|
||||
'X-WMS-Timestamp' => $timestamp,
|
||||
@@ -64,7 +64,7 @@ class InternalApiCoverageTest extends TestCase
|
||||
|
||||
$this->withHeaders([
|
||||
'X-WMS-Timestamp' => $timestamp,
|
||||
'X-WMS-Signature' => hash_hmac('sha256', $timestamp.'.', 'wrong-secret'),
|
||||
'X-WMS-Signature' => hash_hmac('sha256', $timestamp . '.', 'wrong-secret'),
|
||||
])->getJson('/api/internal/companies')->assertUnauthorized();
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ class InternalApiCoverageTest extends TestCase
|
||||
Warehouse::create(['company_id' => $company->id, 'code' => 'SUM', 'name' => 'Summary Warehouse']);
|
||||
|
||||
$timestamp = now()->toIso8601String();
|
||||
$signature = hash_hmac('sha256', $timestamp.'.', 'testing-secret');
|
||||
$signature = hash_hmac('sha256', $timestamp . '.', 'testing-secret');
|
||||
|
||||
$this->withHeaders([
|
||||
'X-WMS-Timestamp' => $timestamp,
|
||||
|
||||
@@ -241,7 +241,8 @@ class PlatformAdministrationTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $overrides
|
||||
* @param array<string, mixed> $overrides
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function pricePayload(array $overrides = []): array
|
||||
@@ -266,7 +267,8 @@ class PlatformAdministrationTest extends TestCase
|
||||
/**
|
||||
* Return payload with a valid test CSRF token.
|
||||
*
|
||||
* @param array<string, mixed> $payload
|
||||
* @param array<string, mixed> $payload
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function csrfPayload(array $payload = []): array
|
||||
|
||||
@@ -255,7 +255,8 @@ class PlatformPriceCrudTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $overrides
|
||||
* @param array<string, mixed> $overrides
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function pricePayload(array $overrides = []): array
|
||||
@@ -301,7 +302,8 @@ class PlatformPriceCrudTest extends TestCase
|
||||
/**
|
||||
* Return payload with a valid test CSRF token.
|
||||
*
|
||||
* @param array<string, mixed> $payload
|
||||
* @param array<string, mixed> $payload
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function csrfPayload(array $payload = []): array
|
||||
|
||||
@@ -205,7 +205,8 @@ class WarehouseCrudTest extends TestCase
|
||||
/**
|
||||
* Return payload with a valid test CSRF token.
|
||||
*
|
||||
* @param array<string, mixed> $payload
|
||||
* @param array<string, mixed> $payload
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function csrfPayload(array $payload = []): array
|
||||
|
||||
+5
-4
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use App\Http\Middleware\VerifyCsrfToken;
|
||||
use Illuminate\Foundation\Http\Middleware\ValidateCsrfToken;
|
||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||
use Illuminate\Testing\TestResponse;
|
||||
@@ -30,16 +31,16 @@ abstract class TestCase extends BaseTestCase
|
||||
$this->withoutMiddleware(ValidateCsrfToken::class);
|
||||
}
|
||||
|
||||
if (class_exists(\App\Http\Middleware\VerifyCsrfToken::class)) {
|
||||
\App\Http\Middleware\VerifyCsrfToken::except(['*']);
|
||||
$this->withoutMiddleware(\App\Http\Middleware\VerifyCsrfToken::class);
|
||||
if (class_exists(VerifyCsrfToken::class)) {
|
||||
VerifyCsrfToken::except(['*']);
|
||||
$this->withoutMiddleware(VerifyCsrfToken::class);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* POST with a real CSRF token for tests that intentionally verify web-form behaviour.
|
||||
*
|
||||
* @param array<string, mixed> $data
|
||||
* @param array<string, mixed> $data
|
||||
*/
|
||||
protected function csrfPost(string $uri, array $data = []): TestResponse
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user