openvibers/openvibe.computer Commits
The site's name is the home row of its page list (#55)
Changes
@@@ -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 = '/' }) {@@@ -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', asynawait 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`);++ }++});
@@ -4,7 +4,7 @@ const serve = require('openvibe-shared/serve');
@@ -4,7 +4,7 @@ const serve = require('openvibe-shared/serve');
const seo = require('openvibe-shared/seo');
const seo = require('openvibe-shared/seo');
const { esc } = require('./html');
const { esc } = require('./html');
const NAV = [
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' },
{ label: 'Docs', href: '/docs' }, { label: 'Updates', href: '/updates' },
];
];
function page({ title, body, viewer, config, path = '/' }) {
function page({ title, body, viewer, config, path = '/' }) {
@@ -4,6 +4,7 @@ const assert = require('node:assert/strict');
@@ -4,6 +4,7 @@ const assert = require('node:assert/strict');
const http = require('node:http');
const http = require('node:http');
const express = require('express');
const express = require('express');
const { createApp } = require('../server/app');
const { createApp } = require('../server/app');
+const { NAV } = require('../server/layout');
const { createRunClient } = require('../server/run-client');
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 };
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
@@ -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' });
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']]);
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`);
+ }
+});