(core) updates from grist-core

This commit is contained in:
Paul Fitzpatrick
2024-02-05 06:51:24 -05:00
19 changed files with 289 additions and 99 deletions

View File

@@ -247,6 +247,7 @@ describe('gutil', function() {
assert.isTrue(gutil.isEmail('email@subdomain.do-main.com'));
assert.isTrue(gutil.isEmail('firstname+lastname@domain.com'));
assert.isTrue(gutil.isEmail('email@domain.co.jp'));
assert.isTrue(gutil.isEmail('marie@isola.corsica'));
assert.isFalse(gutil.isEmail('plainaddress'));
assert.isFalse(gutil.isEmail('@domain.com'));

View File

@@ -924,6 +924,21 @@ describe('ApiServerAccess', function() {
isMember: true,
}]
});
const deltaOrg = {
users: {
[kiwiEmail]: "owners",
}
};
const respDeltaOrg = await axios.patch(`${homeUrl}/api/orgs/${oid}/access`, {delta: deltaOrg}, chimpy);
assert.equal(respDeltaOrg.status, 200);
const resp3 = await axios.get(`${homeUrl}/api/workspaces/${wid}/access`, chimpy);
assert.include(resp3.data.users.find((user: any) => user.email === kiwiEmail), {
access: "editors",
parentAccess: "owners"
});
// Reset the access settings
const resetDelta = {
maxInheritedRole: "owners",
@@ -933,6 +948,13 @@ describe('ApiServerAccess', function() {
};
const resetResp = await axios.patch(`${homeUrl}/api/workspaces/${wid}/access`, {delta: resetDelta}, chimpy);
assert.equal(resetResp.status, 200);
const resetOrgDelta = {
users: {
[kiwiEmail]: "members",
}
};
const resetOrgResp = await axios.patch(`${homeUrl}/api/orgs/${oid}/access`, {delta: resetOrgDelta}, chimpy);
assert.equal(resetOrgResp.status, 200);
// Assert that ws guests are properly displayed.
// Tests a minor bug that showed ws guests as having null access.

View File

@@ -22,6 +22,7 @@ import * as path from 'path';
import {createInitialDb, removeConnection, setUpDB} from 'test/gen-server/seed';
import {setPlan} from 'test/gen-server/testUtils';
import {fixturesRoot} from 'test/server/testUtils';
import {isAffirmative} from 'app/common/gutil';
export class TestServer {
public serverUrl: string;
@@ -36,7 +37,7 @@ export class TestServer {
public async start(servers: ServerType[] = ["home"],
options: FlexServerOptions = {}): Promise<string> {
await createInitialDb();
this.server = await mergedServerMain(0, servers, {logToConsole: false,
this.server = await mergedServerMain(0, servers, {logToConsole: isAffirmative(process.env.DEBUG),
externalStorage: false,
...options});
this.serverUrl = this.server.getOwnUrl();

View File

@@ -5,6 +5,7 @@ import { setupTestSuite } from 'test/nbrowser/testUtils';
describe('CellColor', function() {
this.timeout(20000);
gu.bigScreen();
const cleanup = setupTestSuite();
let doc: string;
@@ -534,6 +535,9 @@ describe('CellColor', function() {
await gu.waitForServer();
await gu.setType(/Toggle/);
// make sure the view pane is scrolled all the way left
await gu.sendKeys(Key.ARROW_LEFT);
// enter 'true'
await gu.getCell('E', 1).click();
await gu.enterCell('true');

View File

@@ -22,6 +22,7 @@ async function setCustomWidget() {
describe('CustomView', function() {
this.timeout(20000);
gu.bigScreen();
const cleanup = setupTestSuite();
let serving: Serving;

View File

@@ -83,8 +83,9 @@ describe('GridViewNewColumnMenu', function () {
it('should create a new column', async function () {
await clickAddColumn();
await driver.findWait('.test-new-columns-menu-add-new', 100).click();
await gu.waitForServer();
//discard rename menu
await driver.findWait('.test-column-title-close', 100).click();
await driver.find('.test-column-title-close').click();
//check if new column is present
const columns = await gu.getColumnNames();
assert.include(columns, 'D', 'new column is not present');
@@ -194,24 +195,24 @@ describe('GridViewNewColumnMenu', function () {
"Attachment",
].map((option) => ({type:option, testClass: option.toLowerCase().replace(' ', '-')}));
for (const option of optionsToBeDisplayed) {
it(`should allow to select column type ${option.type}`, async function () {
// open add new colum menu
await clickAddColumn();
// select "Add Column With type" option
await driver.findWait('.test-new-columns-menu-add-with-type', 100).click();
// wait for submenu to appear
await driver.findWait('.test-new-columns-menu-add-with-type-submenu', 100);
// check if it is present in the menu
const element = await driver.findWait(
`.test-new-columns-menu-add-${option.testClass}`.toLowerCase(),
100,
`${option.type} option is not present`);
// click on the option and check if column is added with a proper type
await element.click();
it(`should allow to select column type ${option.type}`, async function () {
// open add new colum menu
await clickAddColumn();
// select "Add Column With type" option
await driver.findWait('.test-new-columns-menu-add-with-type', 100).click();
// wait for submenu to appear
await driver.findWait('.test-new-columns-menu-add-with-type-submenu', 100);
// check if it is present in the menu
const element = await driver.findWait(
`.test-new-columns-menu-add-${option.testClass}`.toLowerCase(),
100,
`${option.type} option is not present`);
// click on the option and check if column is added with a proper type
await element.click();
await gu.waitForServer();
//discard rename menu
await driver.findWait('.test-column-title-close', 100).click();
//check if new column is present
await gu.waitForServer();
await gu.selectColumn('D');
await gu.openColumnPanel();
const type = await gu.getType();

View File

@@ -294,6 +294,10 @@ describe('ReferenceColumns', function() {
assert.equal(await driver.find('.celleditor_text_editor').value(), 'da');
assert.equal(await driver.find('.test-ref-editor-item.selected').isPresent(), false);
// Clear the typed-in text temporarily. Something changed in a recent version of Chrome,
// causing the wrong item to be moused over below when the "Add New" option is visible.
await driver.sendKeys(Key.BACK_SPACE, Key.BACK_SPACE);
// Mouse over an item.
await driver.findContent('.test-ref-editor-item', /Dark Gray/).mouseMove();
assert.equal(await driver.find('.celleditor_text_editor').value(), 'Dark Gray');
@@ -301,10 +305,11 @@ describe('ReferenceColumns', function() {
// Mouse back out of the dropdown
await driver.find('.celleditor_text_editor').mouseMove();
assert.equal(await driver.find('.celleditor_text_editor').value(), 'da');
assert.equal(await driver.find('.celleditor_text_editor').value(), '');
assert.equal(await driver.find('.test-ref-editor-item.selected').isPresent(), false);
// Click away to save the typed-in text.
// Re-enter the typed-in text and click away to save it.
await driver.sendKeys('da', Key.UP);
await gu.getCell({section: 'References', col: 'Color', rowNum: 1}).doClick();
await gu.waitForServer();
assert.equal(await cell.getText(), "da");

View File

@@ -582,6 +582,10 @@ describe('ReferenceList', function() {
assert.equal(await driver.find('.cell_editor .test-tokenfield .test-tokenfield-input').value(), 'da');
assert.equal(await driver.find('.test-ref-editor-item.selected').isPresent(), false);
// Clear the typed-in text temporarily. Something changed in a recent version of Chrome,
// causing the wrong item to be moused over below when the "Add New" option is visible.
await driver.sendKeys(Key.BACK_SPACE, Key.BACK_SPACE);
// Mouse over an item.
await driver.findContent('.test-ref-editor-item', /Dark Gray/).mouseMove();
assert.equal(await driver.find('.cell_editor .test-tokenfield .test-tokenfield-input').value(), 'Dark Gray');
@@ -589,10 +593,12 @@ describe('ReferenceList', function() {
// Mouse back out of the dropdown
await driver.find('.cell_editor .test-tokenfield .test-tokenfield-input').mouseMove();
assert.equal(await driver.find('.cell_editor .test-tokenfield .test-tokenfield-input').value(), 'da');
assert.equal(await driver.find('.cell_editor .test-tokenfield .test-tokenfield-input').value(), '');
assert.equal(await driver.find('.test-ref-editor-item.selected').isPresent(), false);
// Click away and check the cell is now empty since no reference items were added.
// Re-enter the typed-in text and click away. Check the cell is now empty since
// no reference items were added.
await driver.sendKeys('da', Key.UP);
await gu.getCell({section: 'References', col: 'Colors', rowNum: 1}).doClick();
await gu.waitForServer();
assert.equal(await cell.getText(), "");