(core) Add TSV and DSV import/export

Summary: Adds support for importing .dsv files (an April Fools 2024 easter egg), and options for exporting .dsv and .tsv files from the Share menu.

Test Plan: Browser and server tests.

Reviewers: jarek

Reviewed By: jarek

Differential Revision: https://phab.getgrist.com/D4210
This commit is contained in:
George Gevoian
2024-03-20 09:58:24 -04:00
parent 48a8af83fc
commit 07fcce548b
15 changed files with 2672 additions and 45 deletions

File diff suppressed because it is too large Load Diff

4
test/fixtures/export-dsv/text.dsv vendored Normal file
View File

@@ -0,0 +1,4 @@
Foo💩Bar💩Id is Baz Label is this💩Link💩Formula
1💩a💩hello💩grist https://www.getgrist.com/💩a --- grist https://www.getgrist.com/
2💩b ,d💩world💩https://www.getgrist.com/💩b ,d --- https://www.getgrist.com/
3💩"the ""quote marks"" ?"💩💩💩"the ""quote marks"" ? --- "

File diff suppressed because it is too large Load Diff

4
test/fixtures/export-tsv/text.tsv vendored Normal file
View File

@@ -0,0 +1,4 @@
Foo Bar Id is Baz Label is this Link Formula
1 a hello grist https://www.getgrist.com/ a --- grist https://www.getgrist.com/
2 b ,d world https://www.getgrist.com/ b ,d --- https://www.getgrist.com/
3 "the ""quote marks"" ?" "the ""quote marks"" ? --- "
1 Foo Bar Id is Baz Label is this Link Formula
2 1 a hello grist https://www.getgrist.com/ a --- grist https://www.getgrist.com/
3 2 b ,d world https://www.getgrist.com/ b ,d --- https://www.getgrist.com/
4 3 the "quote marks" ? the "quote marks" ? ---

View File

@@ -1,4 +1,4 @@
import { assert } from 'mocha-webdriver';
import { assert, driver } from 'mocha-webdriver';
import { $, gu, test } from 'test/nbrowser/gristUtil-nbrowser';
const fse = require('fs-extra');
@@ -35,7 +35,10 @@ describe('Export.ntest', 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');
const submenu = $('.test-tb-share-option:contains(Export as...)');
await driver.withActions(a => a.move({origin: submenu.elem()}));
const href = await $('.grist-floating-menu a:contains(Comma Separated Values)').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'],
@@ -50,7 +53,10 @@ describe('Export.ntest', 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');
const submenu = $('.test-tb-share-option:contains(Export as...)');
await driver.withActions(a => a.move({origin: submenu.elem()}));
const href = await $('.grist-floating-menu a:contains(Comma Separated Values)').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);