mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
603238e966
Summary: This adds a UI panel for managing webhooks. Work started by Cyprien Pindat. You can find the UI on a document's settings page. Main changes relative to Cyprien's demo: * Changed behavior of virtual table to be more consistent with the rest of Grist, by factoring out part of the implementation of on-demand tables. * Cell values that would create an error can now be denied and reverted (as for the rest of Grist). * Changes made by other users are integrated in a sane way. * Basic undo/redo support is added using the regular undo/redo stack. * The table list in the drop-down is now updated if schema changes. * Added a notification from back-end when webhook status is updated so constant polling isn't needed to support multi-user operation. * Factored out webhook specific logic from general virtual table support. * Made a bunch of fixes to various broken behavior. * Added tests. The code remains somewhat unpolished, and behavior in the presence of errors is imperfect in general but may be adequate for this case. I assume that we'll soon be lifting the restriction on the set of domains that are supported for webhooks - otherwise we'd want to provide some friendly way to discover that list of supported domains rather than just throwing an error. I don't actually know a lot about how the front-end works - it looks like tables/columns/fields/sections can be safely added if they have string ids that won't collide with bone fide numeric ids from the back end. Sneaky. Contains a migration, so needs an extra reviewer for that. Test Plan: added tests Reviewers: jarek, dsagal Reviewed By: jarek, dsagal Differential Revision: https://phab.getgrist.com/D3856
164 lines
5.9 KiB
TypeScript
164 lines
5.9 KiB
TypeScript
import { assert, driver, Key } from 'mocha-webdriver';
|
|
import * as gu from 'test/nbrowser/gristUtils';
|
|
import { setupTestSuite } from 'test/nbrowser/testUtils';
|
|
|
|
describe("saveViewSection", function() {
|
|
this.timeout(20000);
|
|
setupTestSuite();
|
|
gu.bigScreen();
|
|
|
|
const cleanup = setupTestSuite();
|
|
|
|
before(async function() {
|
|
const session = await gu.session().teamSite.login();
|
|
await session.tempNewDoc(cleanup, 'test-updateViewSection');
|
|
});
|
|
|
|
it("should work correctly when turning a table to 'summary'", async () => {
|
|
// add new section
|
|
await gu.addNewSection(/Table/, /Table1/);
|
|
|
|
// change name and edit data of the 1st section (first found - both have the same name)
|
|
await gu.renameSection('TABLE1', 'Foo');
|
|
|
|
// open right panel
|
|
await gu.toggleSidePanel('right');
|
|
await driver.find('.test-config-data').click();
|
|
|
|
// check there is no groupedBy
|
|
assert.equal(await driver.find('.test-pwc-groupedBy').isDisplayed(), false);
|
|
|
|
// click edit table data
|
|
await driver.find('.test-pwc-editDataSelection').doClick();
|
|
|
|
// summarize table by 'A' and save
|
|
await driver.findContent('.test-wselect-table', /Table1/).find('.test-wselect-pivot').doClick();
|
|
await driver.findContent('.test-wselect-column', /A/).doClick();
|
|
await driver.find('.test-wselect-addBtn').doClick();
|
|
|
|
// wait for server
|
|
await gu.waitForServer();
|
|
|
|
// check that new table is summarized
|
|
assert.equal(await driver.findWait('.test-pwc-table', 2000).getText(), 'Table1');
|
|
assert.deepEqual(await driver.findAll('.test-pwc-groupedBy-col', (e) => e.getText()), ['A']);
|
|
|
|
// check sections name did not change
|
|
assert.deepEqual(await gu.getSectionTitles(), ['Foo', 'TABLE1']);
|
|
|
|
// check 1st section is active
|
|
assert(await driver.find('.viewsection_content').matches('.active_section'));
|
|
});
|
|
|
|
it('should work correctly when changing table', async () => {
|
|
// click edit table data
|
|
await driver.find('.test-pwc-editDataSelection').doClick();
|
|
|
|
// create a new table
|
|
await driver.findContent('.test-wselect-table', /New Table/).doClick();
|
|
await driver.find('.test-wselect-addBtn').doClick();
|
|
|
|
// wait for server
|
|
await gu.waitForServer();
|
|
|
|
// check that first section shows table2 with no grouped by cols
|
|
assert.equal(await driver.findWait('.test-pwc-table', 2000).getText(), 'Table2');
|
|
assert.equal(await driver.find('.test-pwc-groupedBy').isDisplayed(), false);
|
|
|
|
// check sections name did not change
|
|
assert.deepEqual(await gu.getSectionTitles(), ['Foo', 'TABLE1']);
|
|
|
|
// check 1st section is active
|
|
assert(await driver.find('.viewsection_content').matches('.active_section'));
|
|
|
|
// revert to what it was
|
|
await gu.undo();
|
|
});
|
|
|
|
it("should work correctly when changing type", async () => {
|
|
|
|
async function switchTypeAndAssert(t: string) {
|
|
// open page widget picker
|
|
await driver.find('.test-pwc-editDataSelection').doClick();
|
|
|
|
// select type t and save
|
|
await driver.findContent('.test-wselect-type', gu.exactMatch(t)).doClick();
|
|
await driver.find('.test-wselect-addBtn').doClick();
|
|
await gu.waitForServer();
|
|
|
|
// check section's type
|
|
await driver.find('.test-pwc-editDataSelection').doClick();
|
|
assert.equal(await driver.find('.test-wselect-type[class*=-selected]').getText(), t);
|
|
|
|
// close page widget picker
|
|
await driver.sendKeys(Key.ESCAPE);
|
|
await gu.checkForErrors();
|
|
}
|
|
|
|
// TODO: check what's shown by asserting data for each type
|
|
await switchTypeAndAssert('Card');
|
|
await switchTypeAndAssert('Table');
|
|
await switchTypeAndAssert('Chart');
|
|
|
|
});
|
|
|
|
it("should work correctly when changing grouped by column", async () => {
|
|
|
|
// open page widget picker
|
|
await driver.find('.test-pwc-editDataSelection').doClick();
|
|
|
|
// Select column B
|
|
await driver.findContent('.test-wselect-column', /B/).doClick();
|
|
await driver.find('.test-wselect-addBtn').doClick();
|
|
await gu.waitForServer();
|
|
|
|
// check grouped by is now A, B
|
|
assert.deepEqual(await driver.findAll('.test-pwc-groupedBy-col', (e) => e.getText()), ['A', 'B']);
|
|
|
|
await gu.undo();
|
|
});
|
|
|
|
it("should not hide any columns when changing to a summary table", async () => {
|
|
// Previously, a bug when changing data selection would sometimes cause columns to be hidden.
|
|
// This test replicates a scenario that was used to reproduce the bug, and checks that it no
|
|
// longer occurs.
|
|
|
|
async function assertActiveSectionColumns(...expected: string[]) {
|
|
const activeSection = await driver.find('.active_section');
|
|
const actual = (await activeSection.findAll('.column_name', el => el.getText()))
|
|
.filter(name => name !== '+');
|
|
assert.deepEqual(actual, expected);
|
|
}
|
|
|
|
// Create a Places table with a single Place column.
|
|
await gu.addNewTable('Places');
|
|
await gu.renameColumn({col: 0}, 'Place');
|
|
await gu.sendKeys(Key.ARROW_RIGHT);
|
|
await gu.sendKeys(Key.chord(Key.ALT, '-'));
|
|
await gu.waitForServer();
|
|
await gu.sendKeys(Key.chord(Key.ALT, '-'));
|
|
await gu.waitForServer();
|
|
|
|
// Create an Orders table, and rename the last column to Test.
|
|
await gu.addNewTable('Orders');
|
|
await gu.renameColumn({col: 2}, 'Test');
|
|
|
|
// Duplicate the Places page.
|
|
await gu.openPageMenu('Places');
|
|
await driver.find('.test-docpage-duplicate').click();
|
|
await driver.find('.test-modal-confirm').click();
|
|
await driver.findContentWait('.test-docpage-label', /copy/, 1000);
|
|
await gu.waitForServer();
|
|
|
|
// Change the duplicated page's data to summarize Orders, grouping by column Test.
|
|
await driver.find('.test-pwc-editDataSelection').doClick();
|
|
await driver.findContent('.test-wselect-table', /Orders/).find('.test-wselect-pivot').doClick();
|
|
await driver.findContent('.test-wselect-column', /Test/).doClick();
|
|
await driver.find('.test-wselect-addBtn').doClick();
|
|
await gu.waitForServer();
|
|
|
|
// Check all columns are visible.
|
|
await assertActiveSectionColumns('Test', 'count');
|
|
});
|
|
});
|