mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Moving widget tests to core
Summary: - Custom widget tests are now in grist-core - Adding buildtools for grist-plugin-api.js Test Plan: Existing tests Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D3617
This commit is contained in:
21
test/fixtures/sites/readout/index.html
vendored
Normal file
21
test/fixtures/sites/readout/index.html
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<script src="/grist-plugin-api.js"></script>
|
||||
<script src="page.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Readout</h1>
|
||||
<h2>placeholder</h2>
|
||||
<div id="placeholder"></div>
|
||||
<h2>rowId</h2>
|
||||
<div id="rowId"></div>
|
||||
<h2>tableId</h2>
|
||||
<div id="tableId"></div>
|
||||
<hr />
|
||||
<h2>record</h2>
|
||||
<div id="record"></div>
|
||||
<h2>records</h2>
|
||||
<div id="records"></div>
|
||||
</body>
|
||||
</html>
|
||||
37
test/fixtures/sites/readout/page.js
vendored
Normal file
37
test/fixtures/sites/readout/page.js
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
|
||||
/* global document, grist, window */
|
||||
|
||||
function readDoc() {
|
||||
const fetchTable = grist.docApi.fetchSelectedTable();
|
||||
const placeholder = document.getElementById('placeholder');
|
||||
const fallback = setTimeout(() => {
|
||||
placeholder.innerHTML = '<div id="output">no joy</div>';
|
||||
}, 1000);
|
||||
fetchTable
|
||||
.then(table => {
|
||||
clearTimeout(fallback);
|
||||
placeholder.innerHTML = `<div id="output">${JSON.stringify(table)}</div>`;
|
||||
});
|
||||
}
|
||||
|
||||
function setup() {
|
||||
grist.ready();
|
||||
grist.on('message', function(e) {
|
||||
if ('options' in e) return;
|
||||
document.getElementById('rowId').innerHTML = e.rowId || '';
|
||||
document.getElementById('tableId').innerHTML = e.tableId || '';
|
||||
readDoc();
|
||||
});
|
||||
grist.onRecord(function(rec) {
|
||||
document.getElementById('record').innerHTML = JSON.stringify(rec);
|
||||
});
|
||||
grist.onRecords(function(recs) {
|
||||
document.getElementById('records').innerHTML = JSON.stringify(recs);
|
||||
});
|
||||
grist.onNewRecord(function(rec) {
|
||||
document.getElementById('record').innerHTML = 'new';
|
||||
});
|
||||
}
|
||||
|
||||
window.onload = setup;
|
||||
Reference in New Issue
Block a user