openvibers/openvibe.computer Commits

The site's name is the home row of its page list (#55)

OP OpenVibers committed 1 days ago · 21d5e2daab · 2 files, +18 −1

Pages on OpenVibe.Computer started with "Home"; the owner's rule is that the row carries the site's own name. It now says Computer on every page, and the test checks every page's navbar init and that every row is a route.

Changes

ddiff --git a/server/layout.js b/server/layout.js
iindex af326c7..e481b11 100644
---- a/server/layout.js
++++ b/server/layout.js
@@@ -4,7 +4,7 @@ const serve = require('openvibe-shared/serve');
const seo = require('openvibe-shared/seo');
const { esc } = require('./html');
const NAV = [
-- { label: 'Home', href: '/' }, { label: 'Templates', href: '/templates' }, { label: 'Pricing', href: '/pricing' },
++ { label: 'Computer', href: '/' }, { label: 'Templates', href: '/templates' }, { label: 'Pricing', href: '/pricing' },
{ label: 'Docs', href: '/docs' }, { label: 'Updates', href: '/updates' },
];
function page({ title, body, viewer, config, path = '/' }) {
ddiff --git a/test/computer.test.js b/test/computer.test.js
iindex 7e74fd8..5ec0f69 100644
---- a/test/computer.test.js
++++ b/test/computer.test.js
@@@ -4,6 +4,7 @@ const assert = require('node:assert/strict');
const http = require('node:http');
const express = require('express');
const { createApp } = require('../server/app');
++const { NAV } = require('../server/layout');
const { createRunClient } = require('../server/run-client');
const config = { port: 0, host: '127.0.0.1', baseUrl: 'http://computer.test', networkUrl: 'https://openvibe.network', runUrl: 'https://openvibe.run', browserFreeMinutes: null, desktopFreeMinutes: null, pricePerMinute: null };
@@@ -89,3 +90,19 @@ test('Run client sends the original bearer token on each upstream request', asyn
await client.list('one-token'); await client.get('another-token', 'ses_abc'); await client.create('third-token', { kind: 'browser', template: 'throwaway' });
assert.deepEqual(seen, [['https://run.example/api/v1/sessions', 'Bearer one-token', 'GET'], ['https://run.example/api/v1/sessions/ses_abc', 'Bearer another-token', 'GET'], ['https://run.example/api/v1/sessions?template=throwaway', 'Bearer third-token', 'POST']]);
});
++
++
++test('every page sends Computer\'s own page list, and every row is a route', async (t) => {
++ const s = await serve({ run: { list: async () => ({ sessions: [] }) } }); t.after(s.close);
++ assert.equal(NAV[0].label, 'Computer', 'the home row carries the site\'s name, never "Home"');
++ const own = NAV.map(({ label, href }) => ({ label, href }));
++ for (const path of NAV.map((x) => x.href)) {
++ const r = await fetch(`${s.base}${path}`);
++ assert.equal(r.status, 200, `${path} is a route of this server`);
++ const html = await r.text();
++ const init = /OpenVibeNavbar\.init\((\{[\s\S]*?\})\);/.exec(html);
++ assert.ok(init, `${path} starts the shared navbar`);
++ const nav = JSON.parse(init[1]);
++ assert.deepEqual(nav.links.map(({ label, href }) => ({ label, href })), own, `${path} sends the same list as the home`);
++ }
++});