mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Remove transform columns on shutdown
Summary: Call a new user action `RemoveTransformColumns` in ActiveDoc shutdown. Test Plan: Added nbrowser test Reviewers: georgegevoian, paulfitz Reviewed By: georgegevoian Differential Revision: https://phab.getgrist.com/D4107
This commit is contained in:
BIN
test/fixtures/docs/RemoveTransformColumns.grist
vendored
Normal file
BIN
test/fixtures/docs/RemoveTransformColumns.grist
vendored
Normal file
Binary file not shown.
35
test/nbrowser/RemoveTransformColumns.ts
Normal file
35
test/nbrowser/RemoveTransformColumns.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import {assert, driver} from 'mocha-webdriver';
|
||||
|
||||
import * as gu from 'test/nbrowser/gristUtils';
|
||||
import {server, setupTestSuite} from "test/nbrowser/testUtils";
|
||||
|
||||
describe('RemoveTransformColumns', function () {
|
||||
this.timeout(4000);
|
||||
setupTestSuite();
|
||||
|
||||
it('should remove transform columns when the doc shuts down', async function () {
|
||||
await server.simulateLogin("Chimpy", "chimpy@getgrist.com", 'nasa');
|
||||
const doc = await gu.importFixturesDoc('chimpy', 'nasa', 'Horizon', 'RemoveTransformColumns.grist', false);
|
||||
await driver.get(`${server.getHost()}/o/nasa/doc/${doc.id}`);
|
||||
await gu.waitForDocToLoad();
|
||||
|
||||
assert.deepEqual(await gu.getVisibleGridCells({col: 'B', rowNums: [1]}), [
|
||||
'manualSort, A, B, C, ' +
|
||||
'gristHelper_Converted, gristHelper_Transform, ' +
|
||||
'gristHelper_Converted2, gristHelper_Transform2'
|
||||
]);
|
||||
|
||||
const userAPI = gu.createHomeApi('chimpy', 'nasa');
|
||||
await userAPI.applyUserActions(doc.id, [["Calculate"]]); // finish loading fully
|
||||
await userAPI.getDocAPI(doc.id).forceReload();
|
||||
await driver.get(`${server.getHost()}/o/nasa/doc/${doc.id}`);
|
||||
await gu.waitForDocToLoad();
|
||||
|
||||
assert.deepEqual(await gu.getVisibleGridCells({col: 'B', rowNums: [1]}), [
|
||||
'manualSort, A, B, C'
|
||||
]);
|
||||
|
||||
await gu.checkForErrors();
|
||||
});
|
||||
|
||||
});
|
||||
@@ -67,7 +67,7 @@ class CaptureTransport extends winston.Transport {
|
||||
private _captureFunc: (level: string, msg: string, meta: any) => void;
|
||||
|
||||
public constructor(options: any) {
|
||||
super();
|
||||
super(options);
|
||||
this._captureFunc = options.captureFunc;
|
||||
if (options.name) {
|
||||
this.name = options.name;
|
||||
@@ -125,7 +125,8 @@ export function setTmpLogLevel(level: string, optCaptureFunc?: (level: string, m
|
||||
* strings. These may be tested using testUtils.assertMatchArray(). Callback may return a promise.
|
||||
*/
|
||||
export async function captureLog(
|
||||
minLevel: string, callback: (messages: string[]) => void|Promise<void>
|
||||
minLevel: string, callback: (messages: string[]) => void|Promise<void>,
|
||||
options: {timestamp: boolean} = {timestamp: false}
|
||||
): Promise<string[]> {
|
||||
const messages: string[] = [];
|
||||
const prevLogLevel = log.transports.file.level;
|
||||
@@ -133,14 +134,15 @@ export async function captureLog(
|
||||
|
||||
function capture(level: string, msg: string, meta: any) {
|
||||
if ((log as any).levels[level] <= (log as any).levels[minLevel]) { // winston types are off?
|
||||
messages.push(level + ': ' + msg + (meta ? ' ' + serialize(meta) : ''));
|
||||
const timePrefix = options.timestamp ? new Date().toISOString() + ' ' : '';
|
||||
messages.push(`${timePrefix}${level}: ${msg}${meta ? ' ' + serialize(meta) : ''}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (!process.env.VERBOSE) {
|
||||
log.transports.file.level = -1 as any; // Suppress all log output.
|
||||
}
|
||||
log.add(CaptureTransport as any, { captureFunc: capture, name }); // types are off.
|
||||
log.add(CaptureTransport as any, { captureFunc: capture, name, level: minLevel}); // types are off.
|
||||
try {
|
||||
await callback(messages);
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user