|
8 | 8 |
|
9 | 9 | namespace OCA\Libresign\Tests\Unit\Files; |
10 | 10 |
|
| 11 | +use OCA\Files\Event\LoadSidebar; |
| 12 | +use OCA\Libresign\AppInfo\Application; |
11 | 13 | use OCA\Libresign\Files\TemplateLoader; |
12 | 14 | use OCA\Libresign\Handler\CertificateEngine\CertificateEngineFactory; |
13 | 15 | use OCA\Libresign\Handler\CertificateEngine\IEngineHandler; |
@@ -141,4 +143,56 @@ private function getLoader(): TemplateLoader { |
141 | 143 | $this->docMdpConfigService, |
142 | 144 | ); |
143 | 145 | } |
| 146 | + |
| 147 | + /** |
| 148 | + * Regression test for https://github.com/LibreSign/libresign/issues/7632 |
| 149 | + * |
| 150 | + * The `icons` CSS style must NOT be registered separately because: |
| 151 | + * 1. It does not exist as a standalone CSS file in the Vite build output. |
| 152 | + * 2. Its content (.icon-libresign) is already bundled inside `libresign-tab`. |
| 153 | + * Loading a non-existent file causes a 404 on every page load with the |
| 154 | + * files sidebar, and any unscoped `list-style` rule in that file would |
| 155 | + * bleed into other Nextcloud apps (e.g. Notes, Markdown). |
| 156 | + */ |
| 157 | + public function testHandleDoesNotRegisterIconsStyleSeparately(): void { |
| 158 | + $this->appManager |
| 159 | + ->method('isEnabledForUser') |
| 160 | + ->with('libresign') |
| 161 | + ->willReturn(true); |
| 162 | + |
| 163 | + $engine = $this->createMock(IEngineHandler::class); |
| 164 | + $engine->method('isSetupOk')->willReturn(true); |
| 165 | + $this->certificateEngineFactory |
| 166 | + ->method('getEngine') |
| 167 | + ->willReturn($engine); |
| 168 | + $this->identifyMethodService |
| 169 | + ->method('getIdentifyMethodsSettings') |
| 170 | + ->willReturn([]); |
| 171 | + $this->appConfig |
| 172 | + ->method('getValueString') |
| 173 | + ->willReturn('none'); |
| 174 | + $this->docMdpConfigService |
| 175 | + ->method('getConfig') |
| 176 | + ->willReturn([]); |
| 177 | + $user = $this->createMock(IUser::class); |
| 178 | + $this->userSession |
| 179 | + ->method('getUser') |
| 180 | + ->willReturn($user); |
| 181 | + |
| 182 | + $stylesBefore = \OC_Util::$styles; |
| 183 | + $loader = $this->getLoader(); |
| 184 | + $loader->handle(new LoadSidebar()); |
| 185 | + $stylesAfter = \OC_Util::$styles; |
| 186 | + |
| 187 | + $newStyles = array_diff($stylesAfter, $stylesBefore); |
| 188 | + $iconsStylePath = Application::APP_ID . '/css/icons'; |
| 189 | + |
| 190 | + foreach ($newStyles as $style) { |
| 191 | + $this->assertStringNotContainsString( |
| 192 | + $iconsStylePath, |
| 193 | + $style, |
| 194 | + 'The "icons" CSS must not be registered separately — it is already bundled in libresign-tab and loading it would cause a 404 and potential global CSS leaks (issue #7632).' |
| 195 | + ); |
| 196 | + } |
| 197 | + } |
144 | 198 | } |
0 commit comments