mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
bcbf57d590
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
62 lines
2.4 KiB
JavaScript
62 lines
2.4 KiB
JavaScript
import { assert } from 'mocha-webdriver';
|
|
import { $, gu, test } from 'test/nbrowser/gristUtil-nbrowser';
|
|
|
|
const fse = require('fs-extra');
|
|
const path = require('path');
|
|
const axios = require('axios');
|
|
|
|
// Authentication headers to include into axios requests.
|
|
const headers = {Authorization: 'Bearer api_key_for_userz'};
|
|
|
|
describe('Export.ntest', function() {
|
|
const cleanup = test.setupTestSuite(this);
|
|
const pathsExpected = {
|
|
base: path.resolve(gu.fixturesRoot, "export-csv", "CCTransactions.csv"),
|
|
sorted: path.resolve(gu.fixturesRoot, "export-csv", "CCTransactions-DBA-desc.csv")
|
|
};
|
|
let dataExpected = {};
|
|
|
|
before(async function() {
|
|
await gu.supportOldTimeyTestCode();
|
|
await gu.useFixtureDoc(cleanup, "CCTransactions.grist", true);
|
|
|
|
// Read the expected contents before the test case starts, to simplify the promises there.
|
|
// (don't really need that simplification any more though).
|
|
for (const [key, fname] of Object.entries(pathsExpected)) {
|
|
dataExpected[key] = await fse.readFile(fname, {encoding: 'utf8'});
|
|
}
|
|
});
|
|
|
|
afterEach(function() {
|
|
return gu.checkForErrors();
|
|
});
|
|
|
|
it('should export correct data', async function() {
|
|
await $('.test-tb-share').click();
|
|
// Once the menu opens, get the href of the link.
|
|
await $('.grist-floating-menu').wait();
|
|
const href = await $('.grist-floating-menu a:contains(CSV)').wait().getAttribute('href');
|
|
// Download the data at the link and compare to expected.
|
|
const resp = await axios.get(href, {responseType: 'text', headers});
|
|
assert.equal(resp.headers['content-disposition'],
|
|
'attachment; filename="CCTransactions.csv"');
|
|
assert.equal(resp.data, dataExpected.base);
|
|
await $('.test-tb-share').click();
|
|
});
|
|
|
|
it('should respect active sort', async function() {
|
|
await gu.openColumnMenu('Doing Business As');
|
|
await $('.grist-floating-menu .test-sort-dsc').click()
|
|
await $('.test-tb-share').click();
|
|
// Once the menu opens, get the href of the link.
|
|
await $('.grist-floating-menu').wait();
|
|
const href = await $('.grist-floating-menu a:contains(CSV)').wait().getAttribute('href');
|
|
// Download the data at the link and compare to expected.
|
|
const resp = await axios.get(href, {responseType: 'text', headers});
|
|
assert.equal(resp.data, dataExpected.sorted);
|
|
});
|
|
|
|
// TODO: We should have a test case with multiple sections on the screen, that checks that
|
|
// export runs for the currently selected section.
|
|
});
|