-
-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move getTemplateOrg method; enable template org in docker tests (#602)
* move getTemplateOrg method; enable template org in docker tests This moves the `getTemplateOrg` method to a neutral venue for the convenience of `grist-static`, otherwise a lot of awkward dependencies get pulled in needlessly in new parts of the app. This also fixes docker tests using the template org.
- Loading branch information
Showing
11 changed files
with
57 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {appSettings} from 'app/server/lib/AppSettings'; | ||
|
||
export function getTemplateOrg() { | ||
let org = appSettings.section('templates').flag('org').readString({ | ||
envVar: 'GRIST_TEMPLATE_ORG', | ||
}); | ||
if (!org) { return null; } | ||
|
||
if (process.env.GRIST_ID_PREFIX) { | ||
org += `-${process.env.GRIST_ID_PREFIX}`; | ||
} | ||
return org; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,26 @@ | ||
import * as _ from 'lodash'; | ||
import {addToRepl, assert, driver} from 'mocha-webdriver'; | ||
import {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 {setupTestSuite} from 'test/nbrowser/testUtils'; | ||
|
||
describe('SelectBySummary', function() { | ||
this.timeout(50000); | ||
setupTestSuite(); | ||
addToRepl('gu2', gu); | ||
const cleanup = setupTestSuite(); | ||
let headers: Record<string, string>; | ||
gu.bigScreen(); | ||
|
||
before(async function() { | ||
await server.simulateLogin("Chimpy", "[email protected]", 'nasa'); | ||
const doc = await gu.importFixturesDoc('chimpy', 'nasa', 'Horizon', | ||
'SelectBySummary.grist', false); | ||
await driver.get(`${server.getHost()}/o/nasa/doc/${doc.id}`); | ||
await gu.waitForDocToLoad(); | ||
const session = await gu.session().teamSite.login(); | ||
await session.tempDoc(cleanup, 'SelectBySummary.grist'); | ||
headers = { | ||
Authorization: `Bearer ${session.getApiKey()}` | ||
}; | ||
}); | ||
|
||
it('should filter a source table selected by a summary table', async function() { | ||
it('should filter a source table selected by a summary table (first option)', async function() { | ||
await checkSelectingRecords( | ||
headers, | ||
['onetwo'], | ||
[ | ||
'1', '16', | ||
|
@@ -40,8 +41,11 @@ describe('SelectBySummary', function() { | |
], | ||
], | ||
); | ||
}); | ||
|
||
it('should filter a source table selected by a summary table (second option)', async function() { | ||
await checkSelectingRecords( | ||
headers, | ||
['choices'], | ||
[ | ||
'a', '14', | ||
|
@@ -67,9 +71,11 @@ describe('SelectBySummary', function() { | |
], | ||
], | ||
); | ||
}); | ||
|
||
|
||
it('should filter a source table selected by a summary table (both options)', async function() { | ||
await checkSelectingRecords( | ||
headers, | ||
['onetwo', 'choices'], | ||
[ | ||
'1', 'a', '6', | ||
|
@@ -104,7 +110,6 @@ describe('SelectBySummary', function() { | |
], | ||
], | ||
); | ||
|
||
}); | ||
|
||
it('should create new rows in the source table (link target) with correct default values', | ||
|
@@ -153,6 +158,7 @@ describe('SelectBySummary', function() { | |
// selecting by the two less detailed summaries. | ||
// There was a bug previously that this would not work while the summary source table (Table1) was hidden. | ||
await checkSelectingRecords( | ||
headers, | ||
['onetwo'], | ||
[ | ||
'1', '16', | ||
|
@@ -175,6 +181,7 @@ describe('SelectBySummary', function() { | |
); | ||
|
||
await checkSelectingRecords( | ||
headers, | ||
['choices'], | ||
[ | ||
'a', '14', | ||
|
@@ -208,6 +215,7 @@ describe('SelectBySummary', function() { | |
* to the corresponding subarray of `targetData`. | ||
*/ | ||
async function checkSelectingRecords( | ||
headers: Record<string, string>, | ||
groubyColumns: string[], | ||
summaryData: string[], | ||
targetData: string[][], | ||
|
@@ -243,7 +251,7 @@ async function checkSelectingRecords( | |
); | ||
if (targetSection === 'TABLE1') { | ||
assert.equal(await countCell.getText(), numTargetRows.toString()); | ||
const csvCells = await gu.downloadSectionCsvGridCells(targetSection); | ||
const csvCells = await gu.downloadSectionCsvGridCells(targetSection, headers); | ||
// visible cells text uses newlines to separate list items, CSV export uses commas | ||
const expectedCsvCells = targetGroup.map(s => s.replace("\n", ", ")); | ||
assert.deepEqual(csvCells, expectedCsvCells); | ||
|
@@ -259,7 +267,7 @@ async function checkSelectingRecords( | |
for (let rowNum = 1; rowNum <= 8; rowNum++) { | ||
// Click an anchor link | ||
const anchorCell = gu.getCell({section: "Anchors", rowNum, col: 1}); | ||
await anchorCell.find('.test-tb-link').click(); | ||
await driver.withActions(a => a.click(anchorCell.find('.test-tb-link'))); | ||
|
||
// Check that navigation to the link target worked | ||
assert.equal(await gu.getActiveSectionTitle(), "TABLE1"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,7 @@ export const uploadFixtureDoc = homeUtil.uploadFixtureDoc.bind(homeUtil); | |
export const getWorkspaceId = homeUtil.getWorkspaceId.bind(homeUtil); | ||
export const listDocs = homeUtil.listDocs.bind(homeUtil); | ||
export const createHomeApi = homeUtil.createHomeApi.bind(homeUtil); | ||
export const getApiKey = homeUtil.getApiKey.bind(homeUtil); | ||
export const simulateLogin = homeUtil.simulateLogin.bind(homeUtil); | ||
export const removeLogin = homeUtil.removeLogin.bind(homeUtil); | ||
export const enableTips = homeUtil.enableTips.bind(homeUtil); | ||
|
@@ -2047,6 +2048,13 @@ export class Session { | |
return createHomeApi(this.settings.name, this.settings.orgDomain, this.settings.email); | ||
} | ||
|
||
public getApiKey(): string|null { | ||
if (this.settings.email === '[email protected]') { | ||
return getApiKey(null); | ||
} | ||
return getApiKey(this.settings.name, this.settings.email); | ||
} | ||
|
||
// Get the id of this user. | ||
public async getUserId(): Promise<number> { | ||
await this.login(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters