openvibers/openvibe.trade Commits

Trade: an empty instruments list draws the kit's empty state (#264)

OP OpenVibers committed 3 days ago · 79b0863048 · 3 files, +10 −2

Companies and currencies said 'No instruments have been added yet.' in a
bare line with no way forward. It now uses the shared kit's empty state
and its button, See the sources; the list loads kit.css. test/pages.test.js
renders the page with no instruments and checks the kit state and button.

Changes

ddiff --git a/server/http/pages.js b/server/http/pages.js
iindex 2eff459..7517313 100644
---- a/server/http/pages.js
++++ b/server/http/pages.js
@@@ -124,7 +124,7 @@ function createPages(ctx) {
common.page(req, res, {
title: pageNo === 1 ? 'Companies and currencies' : `Companies and currencies, page ${pageNo}`, canonical: urls.abs(path), decision: listing(path),
description: 'US-listed companies from the SEC\'s list and euro reference currencies, the newest filing or figure first, each with its source and time.',
-- feeds: FEEDS, body: views.instrumentsPage({ page, urls, pager, ...await headlines(page.instruments, ctx.store.now()) }),
++ feeds: FEEDS, styles: ['kit.css'], body: views.instrumentsPage({ page, urls, pager, ...await headlines(page.instruments, ctx.store.now()) }),
});
});
ddiff --git a/server/render/views.js b/server/render/views.js
iindex 6a62efe..3e2d199 100644
---- a/server/render/views.js
++++ b/server/render/views.js
@@@ -180,7 +180,7 @@ function instrumentsPage({ page, urls, pager, latest, latestDocs }) {
<input id="q" name="q" type="search" maxlength="200" required>
<button type="submit">Find</button>
</form>
--${page.instruments.length ? html`${instrumentsTable({ instruments: page.instruments, latest, latestDocs, urls })}${raw(paginationHtml(pager))}` : html`<p class="empty">No instruments have been added yet.</p>`}`;
++${page.instruments.length ? html`${instrumentsTable({ instruments: page.instruments, latest, latestDocs, urls })}${raw(paginationHtml(pager))}` : raw(kit.empty({ icon: 'list', title: 'No instruments have been added yet', text: 'Companies and currencies appear once a source has reported them.', action: { href: '/sources', label: 'See the sources', icon: 'live' } }))}`;
}
/** One filing as a list line: company, form (with its plain name), title, published and retrieved. */
ddiff --git a/test/pages.test.js b/test/pages.test.js
iindex fa2811e..94f3b7b 100644
---- a/test/pages.test.js
++++ b/test/pages.test.js
@@@ -220,6 +220,14 @@ const WORDS = (n) => Array.from({ length: n }, (_, i) => `word${i}`).join(' ');
assert.ok(body.includes('Frankfurter (ECB data)'));
});
++ await check('an empty instruments list draws the kit empty state and one button', () => {
++ const views = require('../server/render/views');
++ const body = String(views.instrumentsPage({ page: { instruments: [], total: 0 }, urls: {}, pager: {} }));
++ assert.match(body, /class="ovk-empty"/, 'the kit empty state is used, not a bare sentence');
++ assert.match(body, /No instruments have been added yet/);
++ assert.match(body, /class="ovk-btn[^"]*" href="\/sources"/, 'the empty state offers one button forward');
++ });
++
await t.close();
done();
})();