(core) updates from grist-core

This commit is contained in:
Paul Fitzpatrick
2023-08-21 09:15:53 -04:00
19 changed files with 221 additions and 55 deletions

View File

@@ -287,8 +287,8 @@ describe('gristUrlState', function() {
it('should support an update function to pushUrl and makeUrl', async function() {
mockWindow.location = new URL('https://bar.example.com/doc/DOC/p/5') as unknown as Location;
const state = UrlState.create(null, mockWindow, prod) as UrlState<IGristUrlState>;
await state.pushUrl({params: {style: 'light', linkParameters: {foo: 'A', bar: 'B'}}});
assert.equal(mockWindow.location.href, 'https://bar.example.com/doc/DOC/p/5?style=light&foo_=A&bar_=B');
await state.pushUrl({params: {style: 'singlePage', linkParameters: {foo: 'A', bar: 'B'}}});
assert.equal(mockWindow.location.href, 'https://bar.example.com/doc/DOC/p/5?style=singlePage&foo_=A&bar_=B');
state.loadState(); // changing linkParameters requires a page reload
assert.equal(state.makeUrl((prevState) => merge({}, prevState, {params: {style: 'full'}})),
'https://bar.example.com/doc/DOC/p/5?style=full&foo_=A&bar_=B');

View File

@@ -1,8 +1,52 @@
import {parseFirstUrlPart} from 'app/common/gristUrls';
import {decodeUrl, IGristUrlState, parseFirstUrlPart} from 'app/common/gristUrls';
import {assert} from 'chai';
describe('gristUrls', function() {
function assertUrlDecode(url: string, expected: Partial<IGristUrlState>) {
const actual = decodeUrl({}, new URL(url));
for (const property in expected) {
const expectedValue = expected[property as keyof IGristUrlState];
const actualValue = actual[property as keyof IGristUrlState];
assert.deepEqual(actualValue, expectedValue);
}
}
describe('encodeUrl', function() {
it('should detect theme appearance override', function() {
assertUrlDecode(
'http://localhost/?themeAppearance=light',
{params: {themeAppearance: 'light'}},
);
assertUrlDecode(
'http://localhost/?themeAppearance=dark',
{params: {themeAppearance: 'dark'}},
);
});
it('should detect theme sync with os override', function() {
assertUrlDecode(
'http://localhost/?themeSyncWithOs=true',
{params: {themeSyncWithOs: true}},
);
});
it('should detect theme name override', function() {
assertUrlDecode(
'http://localhost/?themeName=GristLight',
{params: {themeName: 'GristLight'}},
);
assertUrlDecode(
'http://localhost/?themeName=GristDark',
{params: {themeName: 'GristDark'}},
);
});
});
describe('parseFirstUrlPart', function() {
it('should strip out matching tag', function() {
assert.deepEqual(parseFirstUrlPart('o', '/o/foo/bar?x#y'), {value: 'foo', path: '/bar?x#y'});

View File

@@ -15,6 +15,9 @@
*
* USAGE:
* OPENAI_API_KEY=<my_openai_api_key> node core/test/formula-dataset/runCompletion.js
* or
* ASSISTANT_CHAT_COMPLETION_ENDPOINT=http.... node core/test/formula-dataset/runCompletion.js
* (see Assistance.ts for more options).
*
* # WITH VERBOSE:
* VERBOSE=1 OPENAI_API_KEY=<my_openai_api_key> node core/test/formula-dataset/runCompletion.js
@@ -68,7 +71,8 @@ const SIMULATE_CONVERSATION = true;
const FOLLOWUP_EVALUATE = false;
export async function runCompletion() {
ActiveDocDeps.ACTIVEDOC_TIMEOUT = 600;
// This could take a long time for LLMs running on underpowered hardware >:)
ActiveDocDeps.ACTIVEDOC_TIMEOUT = 500000;
// if template directory not exists, make it
if (!fs.existsSync(path.join(PATH_TO_DOC))) {

View File

@@ -675,7 +675,7 @@ async function openMenu(tableId: string) {
}
async function waitForRawData() {
await driver.findWait('.test-raw-data-list', 1000);
await driver.findWait('.test-raw-data-list', 2000);
await gu.waitForServer();
}