Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

test(plugins): point styles-demo at the new pluginStyles config field

Gabe Kangas3ab8d14e6c75
diff --git a/lefthook.yml b/lefthook.yml
index a191311ee9..843c881e5a 100644
--- a/lefthook.yml
+++ b/lefthook.yml
@@ -21,6 +21,26 @@ pre-push:
web-build:
root: web/
run: npm run build
+ # End-to-end plugin suite: builds the SDK example plugins, installs them
+ # into a real Owncast instance, and asserts on the live HTTP/API surface.
+ # `go test` and the web build don't cover this — a change to the plugin
+ # API contract (e.g. moving plugin CSS out of /api/config customStyles
+ # into a separate pluginStyles field) leaves both green while breaking
+ # these tests, which previously only ran in CI. Scoped to plugin code so
+ # it doesn't fire on unrelated Go changes: the plugin host/services, the
+ # integration tests themselves, and the two handlers that serialize
+ # plugin output into the endpoints these tests hit (/api/config and
+ # /customjavascript). Heavy (clones the SDK, downloads ffmpeg, builds the
+ # server); set PLUGIN_SDK_DIR to a local SDK checkout to skip the clone,
+ # or push with --no-verify to bypass.
+ plugin-integration:
+ glob:
+ - 'pluginhost/**'
+ - 'services/plugins/**'
+ - 'test/automated/plugins/**'
+ - 'webserver/handlers/config.go'
+ - 'webserver/handlers/customJavascript.go'
+ run: cd test/automated/plugins && ./run.sh
pre-commit:
parallel: true
diff --git a/test/automated/plugins/styles-demo.test.js b/test/automated/plugins/styles-demo.test.js
index 3796f6cc8e..971058c233 100644
--- a/test/automated/plugins/styles-demo.test.js
+++ b/test/automated/plugins/styles-demo.test.js
@@ -1,8 +1,9 @@
// End-to-end: styles-demo (built from the SDK) ships a CSS file in
// `manifest.styles`. The host reads the file's bytes from the plugin
-// and appends them to the admin's customStyles on /api/config, so
-// the viewer renders one inline <style> block covering both
-// sources. Verifies the full pipeline against a running Owncast
+// and exposes them in a dedicated `pluginStyles` field on /api/config
+// (kept separate from the admin's own `customStyles` so the viewer can
+// render plugin CSS as a baseline before the admin's styling wins on
+// overlap). Verifies the full pipeline against a running Owncast
// instance.
const { test, expect, beforeAll } = require('@jest/globals');
var request = require('supertest');
@@ -16,27 +17,27 @@ beforeAll(async () => {
await enableOnly(PLUGIN);
});
-test('/api/config customStyles contains the plugin CSS with a delimiter naming the source', async () => {
+test('/api/config pluginStyles contains the plugin CSS with a delimiter naming the source', async () => {
const res = await request.get('/api/config').expect(200);
- const { customStyles } = res.body;
- expect(typeof customStyles).toBe('string');
+ const { pluginStyles } = res.body;
+ expect(typeof pluginStyles).toBe('string');
// The host prefixes each plugin contribution with a comment naming
// the source plugin so devtools "view source" can attribute a rule
// back to whichever plugin shipped it.
- expect(customStyles).toMatch(/\/\* plugin: styles-demo /);
+ expect(pluginStyles).toMatch(/\/\* plugin: styles-demo /);
// Plugin's own CSS body should be inline.
- expect(customStyles).toMatch(/--plugin-styles-demo-loaded/);
- expect(customStyles).toMatch(/body::before/);
+ expect(pluginStyles).toMatch(/--plugin-styles-demo-loaded/);
+ expect(pluginStyles).toMatch(/body::before/);
});
-test('disabling the plugin drops its CSS from /api/config customStyles', async () => {
+test('disabling the plugin drops its CSS from /api/config pluginStyles', async () => {
// Switch to a different plugin so styles-demo unloads. Any of the
// other examples works; pick one without `styles` so the assertion
// is unambiguous.
await enableOnly('echo-bot');
const res = await request.get('/api/config').expect(200);
- const { customStyles } = res.body;
- expect(typeof customStyles).toBe('string');
- expect(customStyles).not.toMatch(/plugin: styles-demo/);
- expect(customStyles).not.toMatch(/--plugin-styles-demo-loaded/);
+ const { pluginStyles } = res.body;
+ expect(typeof pluginStyles).toBe('string');
+ expect(pluginStyles).not.toMatch(/plugin: styles-demo/);
+ expect(pluginStyles).not.toMatch(/--plugin-styles-demo-loaded/);
});