Skip to content

Commit

Permalink
Fix tests broken due to widget gallery changes (#144)
Browse files Browse the repository at this point in the history
* Makes tests correctly select from widget gallery
  • Loading branch information
Spoffy authored Nov 13, 2024
1 parent 121037e commit be9a2ba
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
9 changes: 6 additions & 3 deletions test/chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@ describe('chart', function () {
await chooseColumnFromFieldDropdown(/Values/, /num/);
await chooseColumnFromFieldDropdown(/Labels/, /choice list/);

assert.equal(
await driver.find('.plotly_editor_plot').getText(),
const result =
// Percentages inside the pie chart
'55.6%\n44.4%\n' +
// Legend
'choice B\nchoice A',
'choice B\nchoice A';

assert.equal(
await driver.findContentWait('.plotly_editor_plot', result, 2000).getText(),
result
);
});
});
Expand Down
11 changes: 6 additions & 5 deletions test/getGrist.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {ChildProcess, execSync, spawn} from 'child_process';
import FormData from 'form-data';
import fs from 'fs';
import {driver} from 'mocha-webdriver';
import { driver, enableDebugCapture } from 'mocha-webdriver';
import fetch from 'node-fetch';

import {GristWebDriverUtils} from 'test/gristWebDriverUtils';
Expand All @@ -17,6 +17,8 @@ export function getGrist(): GristUtils {
const server = new GristTestServer();
const grist = new GristUtils(server);

enableDebugCapture();

before(async function () {
// Server will have started up in a global fixture, we just
// need to make sure it is ready.
Expand Down Expand Up @@ -198,17 +200,16 @@ export class GristUtils extends GristWebDriverUtils {
await this.waitForServer();
}



public async clickWidgetPane() {
const elem = this.driver.find('.test-config-widget-select .test-select-open');
const elem = this.driver.find('.test-custom-widget-gallery-container');
if (await elem.isPresent()) {
await elem.click();
}
}

public async selectCustomWidget(text: string | RegExp) {
await this.driver.findContent('.test-select-menu li', text).click();
await this.driver.findContent('.test-custom-widget-gallery-widget', text).click();
await this.driver.find('.test-custom-widget-gallery-save').click();
await this.waitForServer();
}

Expand Down
4 changes: 3 additions & 1 deletion test/gristWebDriverUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ export class GristWebDriverUtils {
if (options.dismissTips) { await this.dismissBehavioralPrompts(); }

if (tableRe) {
const tableEl = driver.findContent('.test-wselect-table', tableRe);
const tableEl = driver.findContentWait('.test-wselect-table', tableRe, 2000);

if (options.dismissTips) { await this.dismissBehavioralPrompts(); }

// unselect all selected columns
for (const col of (await driver.findAll('.test-wselect-column[class*=-selected]'))) {
Expand Down
2 changes: 1 addition & 1 deletion test/inspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('inspect', function() {
await grist.toggleSidePanel('right', 'open');
await grist.addNewSection(/Custom/, /School/, {dismissTips: true});
await grist.clickWidgetPane();
await grist.selectCustomWidget('Inspect Record');
await grist.selectCustomWidget('Inspect record');
await grist.setCustomWidgetAccess('full');
await grist.waitToPass(async () => {
const txt = await grist.getCustomWidgetBody();
Expand Down

0 comments on commit be9a2ba

Please sign in to comment.