mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) bump mocha version to allow parallel tests; move more tests to core
Summary: This uses a newer version of mocha in grist-core so that tests can be run in parallel. That allows more tests to be moved without slowing things down overall. Tests moved are venerable browser tests; only the ones that "just work" or worked without too much trouble to are moved, in order to keep the diff from growing too large. Will wrestle with more in follow up. Parallelism is at the file level, rather than the individual test. The newer version of mocha isn't needed for grist-saas repo; tests are parallelized in our internal CI by other means. I've chosen to allocate files to workers in a cruder way than our internal CI, based on initial characters rather than an automated process. The automated process would need some reworking to be compatible with mocha running in parallel mode. Test Plan: this diff was tested first on grist-core, then ported to grist-saas so saas repo history will correctly track history of moved files. Reviewers: jarek Reviewed By: jarek Subscribers: jarek Differential Revision: https://phab.getgrist.com/D3927
This commit is contained in:
31
test/fixtures/plugins/browserInstalledPlugins/plugins/browser-GristDocAPI/main.js
vendored
Normal file
31
test/fixtures/plugins/browserInstalledPlugins/plugins/browser-GristDocAPI/main.js
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
|
||||
/* global grist, self */
|
||||
|
||||
self.importScripts('/grist-plugin-api.js');
|
||||
|
||||
grist.rpc.registerImpl("testApiBrowser", {
|
||||
getImportSource() {
|
||||
const api = grist.rpc.getStub('GristDocAPI@grist', grist.checkers.GristDocAPI);
|
||||
return api.getDocName()
|
||||
.then((result) => {
|
||||
const content = JSON.stringify({
|
||||
tables: [{
|
||||
table_name: '',
|
||||
column_metadata: [{
|
||||
id: 'getDocName',
|
||||
type: 'Text'
|
||||
}],
|
||||
table_data: [[result]]
|
||||
}]
|
||||
});
|
||||
const fileItem = {content, name: "GristDocAPI.jgrist"};
|
||||
return {
|
||||
item: { kind: "fileList", files: [fileItem] },
|
||||
description: "GristDocAPI results"
|
||||
};
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
grist.ready();
|
||||
12
test/fixtures/plugins/browserInstalledPlugins/plugins/browser-GristDocAPI/manifest.yml
vendored
Normal file
12
test/fixtures/plugins/browserInstalledPlugins/plugins/browser-GristDocAPI/manifest.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
name: browser-GristDocAPI
|
||||
version: 0.0.0
|
||||
description:
|
||||
components:
|
||||
safeBrowser: main.js
|
||||
|
||||
contributions:
|
||||
importSources:
|
||||
- importSource:
|
||||
component: safeBrowser
|
||||
name: testApiBrowser
|
||||
label: Test GristDocAPI
|
||||
28
test/fixtures/plugins/browserInstalledPlugins/plugins/custom-section/index-bis.html
vendored
Normal file
28
test/fixtures/plugins/browserInstalledPlugins/plugins/custom-section/index-bis.html
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<html>
|
||||
<body>
|
||||
<h1 id="hello-bis-title">Hello Bis</h1>
|
||||
</br>
|
||||
<!-- numerous lines to produce a scrollable area !-->
|
||||
0</br></br>
|
||||
1</br></br>
|
||||
2</br></br>
|
||||
3</br></br>
|
||||
4</br></br>
|
||||
5</br></br>
|
||||
6</br></br>
|
||||
7</br></br>
|
||||
8</br></br>
|
||||
9</br></br>
|
||||
10</br></br>
|
||||
11</br></br>
|
||||
12</br></br>
|
||||
13</br></br>
|
||||
14</br></br>
|
||||
15</br></br>
|
||||
16</br></br>
|
||||
17</br></br>
|
||||
18</br></br>
|
||||
19</br></br>
|
||||
20</br></br>
|
||||
</body>
|
||||
</html>
|
||||
28
test/fixtures/plugins/browserInstalledPlugins/plugins/custom-section/index.html
vendored
Normal file
28
test/fixtures/plugins/browserInstalledPlugins/plugins/custom-section/index.html
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<html>
|
||||
<body>
|
||||
<h1 id="hello-title">Hello</h1>
|
||||
</br>
|
||||
<!-- numerous lines to produce a scrollable area !-->
|
||||
0</br></br>
|
||||
1</br></br>
|
||||
2</br></br>
|
||||
3</br></br>
|
||||
4</br></br>
|
||||
5</br></br>
|
||||
6</br></br>
|
||||
7</br></br>
|
||||
8</br></br>
|
||||
9</br></br>
|
||||
10</br></br>
|
||||
11</br></br>
|
||||
12</br></br>
|
||||
13</br></br>
|
||||
14</br></br>
|
||||
15</br></br>
|
||||
16</br></br>
|
||||
17</br></br>
|
||||
18</br></br>
|
||||
19</br></br>
|
||||
20</br></br>
|
||||
</body>
|
||||
</html>
|
||||
14
test/fixtures/plugins/browserInstalledPlugins/plugins/custom-section/main.js
vendored
Normal file
14
test/fixtures/plugins/browserInstalledPlugins/plugins/custom-section/main.js
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
|
||||
/* globals self, grist */
|
||||
|
||||
self.importScripts("/grist-plugin-api.js");
|
||||
|
||||
class CustomSection {
|
||||
createSection(renderTarget) {
|
||||
return grist.api.render('index.html', renderTarget);
|
||||
}
|
||||
}
|
||||
|
||||
grist.rpc.registerImpl('hello', new CustomSection(), grist.CustomSectionDescription);
|
||||
grist.ready();
|
||||
12
test/fixtures/plugins/browserInstalledPlugins/plugins/custom-section/manifest.yml
vendored
Normal file
12
test/fixtures/plugins/browserInstalledPlugins/plugins/custom-section/manifest.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
name: helloSection
|
||||
version: 0.0.0
|
||||
components:
|
||||
safeBrowser: main.js
|
||||
contributions:
|
||||
customSections:
|
||||
- path: index.html
|
||||
name: Hello World
|
||||
- path: index-bis.html
|
||||
name: Hello World (bis)
|
||||
- path: test-subscribe-api.html
|
||||
name: dataAPI test
|
||||
11
test/fixtures/plugins/browserInstalledPlugins/plugins/custom-section/test-subscribe-api.html
vendored
Normal file
11
test/fixtures/plugins/browserInstalledPlugins/plugins/custom-section/test-subscribe-api.html
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="/grist-plugin-api.js"></script>
|
||||
<script src="/jquery/dist/jquery.min.js"></script>
|
||||
<script src="test-subscribe-api.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="data-api-section">Data API</h1>
|
||||
<div id="panel"></div>
|
||||
</body>
|
||||
</html>
|
||||
36
test/fixtures/plugins/browserInstalledPlugins/plugins/custom-section/test-subscribe-api.js
vendored
Normal file
36
test/fixtures/plugins/browserInstalledPlugins/plugins/custom-section/test-subscribe-api.js
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
|
||||
/* global grist, window, $, document */
|
||||
let tableId = 'Table1';
|
||||
|
||||
grist.ready();
|
||||
grist.api.subscribe(tableId);
|
||||
|
||||
window.onload = () => {
|
||||
showColumn('A');
|
||||
};
|
||||
|
||||
grist.rpc.on("message", (msg) => {
|
||||
if (msg.type === "docAction") {
|
||||
// There could by many doc actions and fetching table is expensive, in practice this call would
|
||||
// be be throttle
|
||||
if (msg.action[0] === 'RenameTable') {
|
||||
tableId = msg.action[2];
|
||||
}
|
||||
showColumn('A');
|
||||
}
|
||||
});
|
||||
|
||||
// fetch table and call the view with values of coldId
|
||||
function showColumn(colId) {
|
||||
grist.docApi.fetchTable(tableId).then(cols => updateView(cols[colId]));
|
||||
}
|
||||
|
||||
// show the first column
|
||||
function updateView(values) {
|
||||
$("#panel").empty();
|
||||
const res = $('<div class="result"></div>');
|
||||
const text = document.createTextNode(JSON.stringify(values));
|
||||
res.append(text);
|
||||
$("#panel").append(res);
|
||||
}
|
||||
22
test/fixtures/plugins/browserInstalledPlugins/plugins/dummy-importer/index.html
vendored
Normal file
22
test/fixtures/plugins/browserInstalledPlugins/plugins/dummy-importer/index.html
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="/grist-plugin-api.js"></script>
|
||||
<script src="script.js"></script>
|
||||
<!-- jquery is required for running browser test (see: `test/browser/webdriverjq.js`) -->
|
||||
<script src="/jquery/dist/jquery.min.js"></script>
|
||||
<style type="text/css">
|
||||
body {
|
||||
background-color: #ffffffb0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<input id="call-safePython" type="button" value="call safePython">
|
||||
<input id="call-unsafeNode" type="button" value="call unsafeNode">
|
||||
<input id="cancel" type="button" value="cancel">
|
||||
<br/>
|
||||
"name of the file: "
|
||||
<input id="name" type="text">
|
||||
<input id="ok" type="button" value="validate">
|
||||
</body>
|
||||
</html>
|
||||
9
test/fixtures/plugins/browserInstalledPlugins/plugins/dummy-importer/main.js
vendored
Normal file
9
test/fixtures/plugins/browserInstalledPlugins/plugins/dummy-importer/main.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
|
||||
/* global grist, self */
|
||||
|
||||
self.importScripts('/grist-plugin-api.js');
|
||||
|
||||
grist.addImporter('dummy', 'index.html', 'fullscreen');
|
||||
grist.addImporter('dummy-inlined', 'index.html', 'inline');
|
||||
grist.ready();
|
||||
16
test/fixtures/plugins/browserInstalledPlugins/plugins/dummy-importer/manifest.yml
vendored
Normal file
16
test/fixtures/plugins/browserInstalledPlugins/plugins/dummy-importer/manifest.yml
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
name: pluginName
|
||||
version: 0.0.1
|
||||
components:
|
||||
safeBrowser: main.js
|
||||
safePython: sandbox/main.py
|
||||
unsafeNode: node/main.js
|
||||
contributions:
|
||||
importSources:
|
||||
- importSource:
|
||||
component: safeBrowser
|
||||
name: dummy
|
||||
label: Dummy importer
|
||||
- importSource:
|
||||
component: safeBrowser
|
||||
name: dummy-inlined
|
||||
label: Inline Importer
|
||||
4
test/fixtures/plugins/browserInstalledPlugins/plugins/dummy-importer/node/main.js
vendored
Normal file
4
test/fixtures/plugins/browserInstalledPlugins/plugins/dummy-importer/node/main.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
const grist = require('grist-plugin-api');
|
||||
|
||||
grist.rpc.registerFunc("func1", (name) => `Yo: ${name}`);
|
||||
grist.ready();
|
||||
11
test/fixtures/plugins/browserInstalledPlugins/plugins/dummy-importer/sandbox/main.py
vendored
Normal file
11
test/fixtures/plugins/browserInstalledPlugins/plugins/dummy-importer/sandbox/main.py
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import sandbox
|
||||
|
||||
def greet(val):
|
||||
return "With love: " + val
|
||||
|
||||
def main():
|
||||
sandbox.register("func1", greet)
|
||||
sandbox.run()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
44
test/fixtures/plugins/browserInstalledPlugins/plugins/dummy-importer/script.js
vendored
Normal file
44
test/fixtures/plugins/browserInstalledPlugins/plugins/dummy-importer/script.js
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
|
||||
|
||||
/* global grist, window, document, $ */
|
||||
|
||||
let resolve; // eslint-disable-line no-unused-vars
|
||||
|
||||
const importer = {
|
||||
getImportSource: () => new Promise((_resolve) => {
|
||||
resolve = _resolve;
|
||||
})
|
||||
};
|
||||
|
||||
grist.rpc.registerImpl('dummy', importer );
|
||||
grist.rpc.registerImpl('dummy-inlined', importer );
|
||||
|
||||
grist.ready();
|
||||
|
||||
window.onload = function() {
|
||||
callFunctionOnClick('#call-safePython', 'func1@sandbox/main.py', 'Bob');
|
||||
callFunctionOnClick('#call-unsafeNode', 'func1@node/main.js', 'Alice');
|
||||
document.querySelector('#cancel').addEventListener('click', () => resolve());
|
||||
document.querySelector('#ok').addEventListener('click', () => {
|
||||
const name = $('#name').val();
|
||||
resolve({
|
||||
item: {
|
||||
kind: "fileList",
|
||||
files: [{content: "A,B\n1,2\n", name}]
|
||||
},
|
||||
description: name + " selected!"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function callFunctionOnClick(selector, funcName, ...args) {
|
||||
document.querySelector(selector).addEventListener('click', () => {
|
||||
grist.rpc.callRemoteFunc(funcName, ...args)
|
||||
.then(val => {
|
||||
const resElement = document.createElement('h1');
|
||||
resElement.classList.add(`result`);
|
||||
resElement.textContent = val;
|
||||
document.body.appendChild(resElement);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user