diff --git a/templates/style.css b/css/style.css similarity index 100% rename from templates/style.css rename to css/style.css diff --git a/lib/Controller/CalendarController.php b/lib/Controller/CalendarController.php index 17087c2..bafada0 100644 --- a/lib/Controller/CalendarController.php +++ b/lib/Controller/CalendarController.php @@ -20,6 +20,7 @@ use OCP\IURLGenerator; use OCP\IUserSession; use OCP\IDateTimeZone; use OCP\IL10N; +use OCP\Util; use Psr\Log\LoggerInterface; use Sabre\VObject\Reader; @@ -347,6 +348,12 @@ class CalendarController extends Controller string $calendarId = '', string $error = '' ): TemplateResponse { + /* + * Stylesheets are not auto-loaded, css/style.css + * must be registered for the page layout. + */ + Util::addStyle(Application::APP_ID, 'style'); + return new TemplateResponse( Application::APP_ID, 'confirm', diff --git a/tests/Unit/CalendarControllerTest.php b/tests/Unit/CalendarControllerTest.php index f8d0b08..87f391b 100644 --- a/tests/Unit/CalendarControllerTest.php +++ b/tests/Unit/CalendarControllerTest.php @@ -24,6 +24,8 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; +require_once __DIR__ . '/OCUtilStub.php'; + class CalendarControllerTest extends TestCase { private IManager&MockObject $calendarManager; @@ -709,4 +711,20 @@ class CalendarControllerTest extends TestCase $response->getParams()['errors'][0]['error'] ); } + + public function testConfirmRegistersStylesheet(): void + { + $this->userSession->method('getUser')->willReturn($this->mockUser('alice')); + $this->setUpWritableCalendars(); + $this->urlGenerator->method('getAbsoluteURL')->willReturn('https://cloud.example.com/'); + + $c = $this->newController(); + + $c->confirm('Weekly sync', '', '2026-10-07T14:15', '2026-10-07T15:15'); + + $this->assertContains( + ['atocal', 'style', false], + \OC_Util::$styles + ); + } } diff --git a/tests/Unit/OCUtilStub.php b/tests/Unit/OCUtilStub.php new file mode 100644 index 0000000..b519831 --- /dev/null +++ b/tests/Unit/OCUtilStub.php @@ -0,0 +1,23 @@ + */ + public static array $styles = []; + + public static function addStyle( + string $application, + ?string $file = null, + bool $prepend = false + ): void { + self::$styles[] = [$application, $file, $prepend]; + } + } +}