mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) updates from grist-core
This commit is contained in:
43
test/fixtures/sites/config/page.js
vendored
43
test/fixtures/sites/config/page.js
vendored
@@ -4,28 +4,30 @@
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const ready = urlParams.get('ready') ? JSON.parse(urlParams.get('ready')) : undefined;
|
||||
|
||||
if (ready && ready.onEditOptions) {
|
||||
ready.onEditOptions = () => {
|
||||
document.getElementById('configure').innerHTML = 'called';
|
||||
};
|
||||
function setup() {
|
||||
if (ready && ready.onEditOptions) {
|
||||
ready.onEditOptions = () => {
|
||||
document.getElementById('configure').innerHTML = 'called';
|
||||
};
|
||||
}
|
||||
|
||||
grist.ready(ready);
|
||||
|
||||
grist.onOptions(data => {
|
||||
document.getElementById('onOptions').innerHTML = JSON.stringify(data);
|
||||
});
|
||||
|
||||
grist.onRecord((data, mappings) => {
|
||||
document.getElementById('onRecord').innerHTML = JSON.stringify(data);
|
||||
document.getElementById('onRecordMappings').innerHTML = JSON.stringify(mappings);
|
||||
});
|
||||
|
||||
grist.onRecords((data, mappings) => {
|
||||
document.getElementById('onRecords').innerHTML = JSON.stringify(data);
|
||||
document.getElementById('onRecordsMappings').innerHTML = JSON.stringify(mappings);
|
||||
});
|
||||
}
|
||||
|
||||
grist.ready(ready);
|
||||
|
||||
grist.onOptions(data => {
|
||||
document.getElementById('onOptions').innerHTML = JSON.stringify(data);
|
||||
});
|
||||
|
||||
grist.onRecord((data, mappings) => {
|
||||
document.getElementById('onRecord').innerHTML = JSON.stringify(data);
|
||||
document.getElementById('onRecordMappings').innerHTML = JSON.stringify(mappings);
|
||||
});
|
||||
|
||||
grist.onRecords((data, mappings) => {
|
||||
document.getElementById('onRecords').innerHTML = JSON.stringify(data);
|
||||
document.getElementById('onRecordsMappings').innerHTML = JSON.stringify(mappings);
|
||||
});
|
||||
|
||||
async function run(handler) {
|
||||
try {
|
||||
document.getElementById('output').innerText = 'waiting...';
|
||||
@@ -66,6 +68,7 @@ async function configure() {
|
||||
}
|
||||
|
||||
window.onload = () => {
|
||||
setup();
|
||||
document.getElementById('ready').innerText = 'ready';
|
||||
document.getElementById('access').innerHTML = urlParams.get('access');
|
||||
document.getElementById('readonly').innerHTML = urlParams.get('readonly');
|
||||
|
||||
@@ -7,7 +7,6 @@ describe('ColumnOps.ntest', function() {
|
||||
const cleanup = test.setupTestSuite(this);
|
||||
|
||||
before(async function() {
|
||||
this.timeout(Math.max(this.timeout(), 30000)); // Long-running test, unfortunately
|
||||
await gu.supportOldTimeyTestCode();
|
||||
await gu.useFixtureDoc(cleanup, "World.grist", true);
|
||||
await gu.toggleSidePanel('left', 'close');
|
||||
|
||||
@@ -223,10 +223,10 @@ describe('CustomWidgetsConfig', function () {
|
||||
constructor(public frameSelector = 'iframe') {}
|
||||
// Wait for a frame.
|
||||
public async waitForFrame() {
|
||||
await driver.wait(() => driver.find(this.frameSelector).isPresent(), 1000);
|
||||
await driver.wait(() => driver.find(this.frameSelector).isPresent(), 3000);
|
||||
const iframe = driver.find(this.frameSelector);
|
||||
await driver.switchTo().frame(iframe);
|
||||
await driver.wait(async () => (await driver.find('#ready').getText()) === 'ready', 1000);
|
||||
await driver.wait(async () => (await driver.find('#ready').getText()) === 'ready', 3000);
|
||||
await driver.switchTo().defaultContent();
|
||||
}
|
||||
public async content() {
|
||||
@@ -254,7 +254,7 @@ describe('CustomWidgetsConfig', function () {
|
||||
}
|
||||
// Wait for frame to close.
|
||||
public async waitForClose() {
|
||||
await driver.wait(async () => !(await driver.find(this.frameSelector).isPresent()), 1000);
|
||||
await driver.wait(async () => !(await driver.find(this.frameSelector).isPresent()), 3000);
|
||||
}
|
||||
// Wait for the onOptions event, and return its value.
|
||||
public async onOptions() {
|
||||
@@ -262,7 +262,7 @@ describe('CustomWidgetsConfig', function () {
|
||||
await driver.switchTo().frame(iframe);
|
||||
// Wait for options to get filled, initially this div is empty,
|
||||
// as first message it should get at least null as an options.
|
||||
await driver.wait(async () => await driver.find('#onOptions').getText(), 1000);
|
||||
await driver.wait(async () => await driver.find('#onOptions').getText(), 3000);
|
||||
const text = await driver.find('#onOptions').getText();
|
||||
await driver.switchTo().defaultContent();
|
||||
return JSON.parse(text);
|
||||
|
||||
@@ -116,8 +116,7 @@ describe("Localization", function() {
|
||||
// But only uz code is preloaded.
|
||||
notPresent(uzResponse, "uz-UZ");
|
||||
|
||||
// For Portuguese we have only en.
|
||||
notPresent(ptResponse, "pt", "pt-PR", "uz", "en-US");
|
||||
notPresent(ptResponse, "pt-PR", "uz", "en-US");
|
||||
});
|
||||
|
||||
it("loads correct languages from file system", async function() {
|
||||
|
||||
@@ -12,9 +12,6 @@ describe('RightPanelSelectBy', function() {
|
||||
const doc = await gu.importFixturesDoc('chimpy', 'nasa', 'Horizon', 'Favorite_Films_With_Linked_Ref.grist', false);
|
||||
await driver.get(`${server.getHost()}/o/nasa/doc/${doc.id}`);
|
||||
await gu.waitForDocToLoad();
|
||||
|
||||
await gu.toggleSidePanel('right', 'open');
|
||||
await driver.find('.test-config-data').click();
|
||||
}
|
||||
|
||||
it('should allow linking section with same table', async function() {
|
||||
@@ -24,7 +21,7 @@ describe('RightPanelSelectBy', function() {
|
||||
await driver.findContentWait('.test-treeview-itemHeader', /All/, 2000).click();
|
||||
await gu.waitForDocToLoad();
|
||||
|
||||
await openSelectByForSection('PERFORMANCES DETAIL');
|
||||
await gu.openSelectByForSection('PERFORMANCES DETAIL');
|
||||
|
||||
// the dollar in /...record$/ makes sure we match against the table main node and not a ref
|
||||
// columns such as '...record.Film'
|
||||
@@ -52,7 +49,7 @@ describe('RightPanelSelectBy', function() {
|
||||
});
|
||||
|
||||
it('should allow to remove link', async function() {
|
||||
await openSelectByForSection('PERFORMANCES DETAIL');
|
||||
await gu.openSelectByForSection('PERFORMANCES DETAIL');
|
||||
await driver.findContent('.test-select-row', /Select Widget/).click();
|
||||
await gu.waitForServer();
|
||||
|
||||
@@ -67,7 +64,7 @@ describe('RightPanelSelectBy', function() {
|
||||
|
||||
|
||||
it('should disallow creating cycles', async function() {
|
||||
await openSelectByForSection('PERFORMANCES RECORD');
|
||||
await gu.openSelectByForSection('PERFORMANCES RECORD');
|
||||
assert.equal(await driver.findContent('.test-select-row', /Performances detail/).isPresent(), false);
|
||||
});
|
||||
|
||||
@@ -81,7 +78,7 @@ describe('RightPanelSelectBy', function() {
|
||||
await gu.addNewSection(/Chart/, /Films/);
|
||||
|
||||
// open `SELECT BY`
|
||||
await openSelectByForSection('FILMS');
|
||||
await gu.openSelectByForSection('FILMS');
|
||||
|
||||
// check that there is a chart and we cannot link from it
|
||||
assert.equal(await gu.getSection('FILMS CHART').isPresent(), true);
|
||||
@@ -96,7 +93,7 @@ describe('RightPanelSelectBy', function() {
|
||||
await gu.getPageItem('Friends').click();
|
||||
await gu.waitForServer();
|
||||
await gu.addNewSection(/Table/, /Performances/);
|
||||
await openSelectByForSection('Performances');
|
||||
await gu.openSelectByForSection('Performances');
|
||||
assert.equal(await driver.findContent('.test-select-row', /FRIENDS.*Favorite Film/).isPresent(), true);
|
||||
await driver.findContent('.test-select-row', /FRIENDS.*Favorite Film/).click();
|
||||
await gu.waitForServer();
|
||||
@@ -135,7 +132,7 @@ describe('RightPanelSelectBy', function() {
|
||||
await gu.getPageItem('Friends').click();
|
||||
await gu.waitForServer();
|
||||
await gu.addNewSection(/Card/, /Films/);
|
||||
await openSelectByForSection('Films Card');
|
||||
await gu.openSelectByForSection('Films Card');
|
||||
assert.equal(await driver.findContent('.test-select-row', /FRIENDS.*Favorite Film/).isPresent(), true);
|
||||
await driver.findContent('.test-select-row', /FRIENDS.*Favorite Film/).click();
|
||||
await gu.waitForServer();
|
||||
@@ -194,8 +191,3 @@ describe('RightPanelSelectBy', function() {
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
export async function openSelectByForSection(section: string) {
|
||||
await gu.getSection(section).click();
|
||||
await driver.find('.test-right-select-by').click();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ import * as _ from 'lodash';
|
||||
import {addToRepl, assert, driver} from 'mocha-webdriver';
|
||||
import * as gu from 'test/nbrowser/gristUtils';
|
||||
import {server, setupTestSuite} from 'test/nbrowser/testUtils';
|
||||
import {openSelectByForSection} from "./RightPanelSelectBy";
|
||||
|
||||
describe('SelectByRefList', function() {
|
||||
this.timeout(60000);
|
||||
@@ -16,9 +15,6 @@ describe('SelectByRefList', function() {
|
||||
'SelectByRefList.grist', false);
|
||||
await driver.get(`${server.getHost()}/o/nasa/doc/${doc.id}`);
|
||||
await gu.waitForDocToLoad();
|
||||
|
||||
await gu.toggleSidePanel('right');
|
||||
await driver.find('.test-config-data').click();
|
||||
}
|
||||
|
||||
it('should filter a table selected by ref and reflist columns', async function() {
|
||||
@@ -182,7 +178,7 @@ describe('SelectByRefList', function() {
|
||||
* The values will depend on the link and the last row selected in the driving table.
|
||||
*/
|
||||
async function checkSelectingRecords(selectBy: string, sourceData: string[][], newRow: string[]) {
|
||||
await openSelectByForSection('LINKTARGET');
|
||||
await gu.openSelectByForSection('LINKTARGET');
|
||||
await driver.findContent('.test-select-row', new RegExp(selectBy + '$')).click();
|
||||
await gu.waitForServer();
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ import {addToRepl, assert, driver} from 'mocha-webdriver';
|
||||
import {enterRulePart, findDefaultRuleSet} from 'test/nbrowser/aclTestUtils';
|
||||
import * as gu from 'test/nbrowser/gristUtils';
|
||||
import {server, setupTestSuite} from 'test/nbrowser/testUtils';
|
||||
import {openSelectByForSection} from "./RightPanelSelectBy";
|
||||
|
||||
describe('SelectBySummary', function() {
|
||||
this.timeout(50000);
|
||||
@@ -17,9 +16,6 @@ describe('SelectBySummary', function() {
|
||||
'SelectBySummary.grist', false);
|
||||
await driver.get(`${server.getHost()}/o/nasa/doc/${doc.id}`);
|
||||
await gu.waitForDocToLoad();
|
||||
|
||||
await gu.toggleSidePanel('right', 'open');
|
||||
await driver.find('.test-config-data').click();
|
||||
});
|
||||
|
||||
it('should filter a source table selected by a summary table', async function() {
|
||||
@@ -219,7 +215,7 @@ async function checkSelectingRecords(
|
||||
) {
|
||||
const summarySection = `TABLE1 [by ${groubyColumns.join(', ')}]`;
|
||||
|
||||
await openSelectByForSection(targetSection);
|
||||
await gu.openSelectByForSection(targetSection);
|
||||
await driver.findContent('.test-select-row', summarySection).click();
|
||||
await gu.waitForServer();
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import {addToRepl, assert, driver, Key} from 'mocha-webdriver';
|
||||
import * as gu from 'test/nbrowser/gristUtils';
|
||||
import {server, setupTestSuite} from 'test/nbrowser/testUtils';
|
||||
import {openSelectByForSection} from "./RightPanelSelectBy";
|
||||
|
||||
describe('SelectBySummaryRef', function() {
|
||||
this.timeout(20000);
|
||||
@@ -14,9 +13,6 @@ describe('SelectBySummaryRef', function() {
|
||||
'SelectBySummaryRef.grist', false);
|
||||
await driver.get(`${server.getHost()}/o/nasa/doc/${doc.id}`);
|
||||
await gu.waitForDocToLoad();
|
||||
|
||||
await gu.toggleSidePanel('right', 'open');
|
||||
await driver.find('.test-config-data').click();
|
||||
});
|
||||
|
||||
it('should give correct options when linking with a summary table with ref/reflist columns', async () => {
|
||||
@@ -174,7 +170,7 @@ describe('SelectBySummaryRef', function() {
|
||||
|
||||
// Check that the 'Select by' menu in the right panel for the section has the expected options
|
||||
async function checkRightPanelSelectByOptions(section: string, expected: string[]) {
|
||||
await openSelectByForSection(section);
|
||||
await gu.openSelectByForSection(section);
|
||||
|
||||
const actual = await driver.findAll('.test-select-menu .test-select-row', (e) => e.getText());
|
||||
assert.deepEqual(actual, ['Select Widget', ...expected]);
|
||||
|
||||
@@ -53,7 +53,7 @@ async function applyPatchesToJquerylikeObject($) {
|
||||
// Adapt common old setup.
|
||||
const test = {
|
||||
setupTestSuite(self, ...args) {
|
||||
self.timeout(20000);
|
||||
self.timeout(40000);
|
||||
return setupTestSuite(...args);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1759,6 +1759,16 @@ export async function openAccessRulesDropdown(): Promise<void> {
|
||||
await driver.findWait('.grist-floating-menu', 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open "Select By" area in creator panel.
|
||||
*/
|
||||
export async function openSelectByForSection(section: string) {
|
||||
await toggleSidePanel('right', 'open');
|
||||
await driver.find('.test-config-data').click();
|
||||
await getSection(section).click();
|
||||
await driver.find('.test-right-select-by').click();
|
||||
}
|
||||
|
||||
export async function editOrgAcls(): Promise<void> {
|
||||
// To prevent a common flakiness problem, wait for a potentially open modal dialog
|
||||
// to close before attempting to open the account menu.
|
||||
|
||||
@@ -65,14 +65,14 @@ export class TestServerMerged extends EventEmitter implements IMochaServer {
|
||||
await this.stop();
|
||||
}
|
||||
this._starts++;
|
||||
const workerIdText = process.env.MOCHA_WORKER_ID || '0';
|
||||
if (reset) {
|
||||
if (process.env.TESTDIR) {
|
||||
this.testDir = process.env.TESTDIR;
|
||||
this.testDir = path.join(process.env.TESTDIR, workerIdText);
|
||||
} else {
|
||||
const workerId = process.env.MOCHA_WORKER_ID || '0';
|
||||
// Create a testDir of the form grist_test_{USER}_{SERVER_NAME}_{WORKER_ID}, removing any previous one.
|
||||
const username = process.env.USER || "nobody";
|
||||
this.testDir = path.join(tmpdir(), `grist_test_${username}_${this._name}_${workerId}`);
|
||||
this.testDir = path.join(tmpdir(), `grist_test_${username}_${this._name}_${workerIdText}`);
|
||||
await fse.remove(this.testDir);
|
||||
}
|
||||
}
|
||||
@@ -99,7 +99,7 @@ export class TestServerMerged extends EventEmitter implements IMochaServer {
|
||||
// logging. Server code uses a global logger, so it's hard to separate out (especially so if
|
||||
// we ever run different servers for different tests).
|
||||
const serverLog = process.env.VERBOSE ? 'inherit' : nodeLogFd;
|
||||
const workerId = parseInt(process.env.MOCHA_WORKER_ID || '0', 10);
|
||||
const workerId = parseInt(workerIdText, 10);
|
||||
const corePort = String(8295 + workerId * 2);
|
||||
const untrustedPort = String(8295 + workerId * 2 + 1);
|
||||
const env: Record<string, string> = {
|
||||
|
||||
@@ -64,4 +64,4 @@ TEST_ADD_SAMPLES=1 TEST_ACCOUNT_PASSWORD=not-needed \
|
||||
GRIST_SESSION_COOKIE=grist_test_cookie \
|
||||
GRIST_TEST_LOGIN=1 \
|
||||
NODE_PATH=_build:_build/stubs \
|
||||
$MOCHA _build/test/deployment/*.js --slow 6000 -g "${GREP_TESTS}" "$@"
|
||||
$MOCHA _build/test/deployment/*.js --slow 6000 -g "${GREP_TESTS:-}" "$@"
|
||||
|
||||
Reference in New Issue
Block a user