Indigo (the default), Blue, Teal, Green, Amber, Rose and Violet in the Vibrant style and Graphite in the Neutral style are generated from config into the stylesheet. Admin settings opens with a colour profile card: a swatch previews the profile on the page, and Save Settings stores it as color_profile, which AppServiceProvider hands to the package's resolver, so every page, mail and error page wears it. An unknown profile is refused, and a saved one that disappears falls back to indigo. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V9NnLxnPp8vaaurb3Z1MFy
37 lines
1.5 KiB
PHP
37 lines
1.5 KiB
PHP
<?php
|
|
|
|
use App\Models\Setting;
|
|
use App\Models\User;
|
|
use Illuminate\Auth\Notifications\ResetPassword;
|
|
use NoNameWeb\LivewireMaterial\Support\Scheme;
|
|
|
|
test('every page wears the colour profile the admin saved, indigo until then', function () {
|
|
$this->get(route('upload'))->assertOk()->assertSee('({"scheme":"indigo",', false);
|
|
|
|
Setting::set('color_profile', 'graphite');
|
|
|
|
$this->get(route('upload'))->assertSee('({"scheme":"graphite",', false);
|
|
$this->get('/s/does-not-exist')->assertNotFound()->assertSee('({"scheme":"graphite",', false);
|
|
});
|
|
|
|
test('a saved profile that no longer exists falls back to the default', function () {
|
|
Setting::set('color_profile', 'ocean');
|
|
|
|
expect(Scheme::profile())->toBe('indigo');
|
|
$this->get(route('upload'))->assertSee('({"scheme":"indigo",', false);
|
|
});
|
|
|
|
test('mails take the saved colour profile', function () {
|
|
Setting::set('color_profile', 'rose');
|
|
|
|
$html = (string) (new ResetPassword('token'))->toMail(User::factory()->create())->render();
|
|
|
|
expect($html)->toContain('background-color: '.Scheme::profiles()['rose']['light']['primary'])
|
|
->not->toContain('background-color: '.Scheme::profiles()['indigo']['light']['primary']);
|
|
});
|
|
|
|
test('the stylesheet carries all eight profiles', function () {
|
|
expect(array_keys(Scheme::profiles()))->toBe(['indigo', 'blue', 'teal', 'green', 'amber', 'rose', 'violet', 'graphite'])
|
|
->and(file_get_contents(resource_path('css/material-scheme.css')))->toContain("[data-scheme='graphite'][data-theme='dark']");
|
|
});
|