Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test components for charting in apps #1878

Merged
merged 5 commits into from
Apr 8, 2024
Merged

Conversation

labkey-chrisj
Copy link
Contributor

@labkey-chrisj labkey-chrisj commented Apr 2, 2024

Rationale

We have added the ability (in biologics, with an experimental feature) to compose, edit, and delete charts on queryGrids. This change adds and updates classes necessary to interact with new UI in the apps.

The new Dialog QueryChartDialog supports create and edit of charts, and could (if we think that's a good idea) be refactored into 2 dialog classes that would only have methods related to buttons of the dialog in that mode. Here it is in create mode:
image
and in edit mode:
image

Because we've introduced the ability to add, edit, save, and delete charts in the apps, I've taken the liberty of creating a new component, QueryChartPanel (which contains the chart in the QueryGrid when charts or reports are shown) to surface the ability to find the chart's svg, to click to edit the chart, and to close the chart view- it's highlit in red, here:
image

Related Pull Requests

https://github.com/LabKey/limsModules/pull/105 <- contains test coverage using new/changed components in this PR

Changes

  • new create/edit chart dialog, QueryChartDialog
  • new chart/report panel in QueryGrid, QueryChartPanel (which provides the means to get the edit dialog, to dismiss the chart when it is shown, to find the chart/report)

Copy link
Contributor

@labkey-danield labkey-danield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is some clean up you should do.
Use the IntelliJ linter it will help identify some nit-pick things to clean up.

{
return elementCache().reactSelectByLabel("Y Axis").getValue();
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be useful to have a getSelectionOptions for XAxis, YAxis & GroupBy? It seems like there should be a test that validates the correct fields/columns are returned for the options.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, those are probably going to be useful to have. I'll implement them here while we're thinking about it

src/org/labkey/test/components/react/QueryChartDialog.java Outdated Show resolved Hide resolved
src/org/labkey/test/components/react/QueryChartDialog.java Outdated Show resolved Hide resolved
src/org/labkey/test/components/react/QueryChartDialog.java Outdated Show resolved Hide resolved
Comment on lines 136 to 145
public QueryChartDialog setChartType(CHART_TYPE chartType)
{
elementCache().selectChartType(chartType);
return this;
}

public CHART_TYPE getSelectedChartType()
{
return elementCache().getSelectedChartType();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public QueryChartDialog setChartType(CHART_TYPE chartType)
{
elementCache().selectChartType(chartType);
return this;
}
public CHART_TYPE getSelectedChartType()
{
return elementCache().getSelectedChartType();
}
public QueryChartDialog setChartType(CHART_TYPE chartType)
{
if (getSelectedChartType().equals(chartType))
return this;
// note: selecting a chart type will cause most select fields to go stale
var el = elementCache().chartBuilderType.withAttribute("data-name", chartType.getChartType())
.waitForElement(this, 1500);
getWrapper().shortWait().until(ExpectedConditions.elementToBeClickable(el));
el.click();
WebDriverWrapper.waitFor(()-> getSelectedChartType().equals(chartType),
"The requested chart type did not become selected", 2000);
return this;
}
public CHART_TYPE getSelectedChartType()
{
var selectedEl = elementCache().chartBuilderType.withAttributeContaining("class", "selected")
.waitForElement(this, 1500);
String dataName = selectedEl.getAttribute("data-name");
return CHART_TYPE.fromChartType(dataName);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would clean up the elementCache and remove the methods that aren't really elements on the dialog.

src/org/labkey/test/components/react/QueryChartPanel.java Outdated Show resolved Hide resolved
src/org/labkey/test/components/react/QueryChartPanel.java Outdated Show resolved Hide resolved
src/org/labkey/test/components/react/QueryChartPanel.java Outdated Show resolved Hide resolved
src/org/labkey/test/components/react/QueryChartPanel.java Outdated Show resolved Hide resolved
@labkey-chrisj labkey-chrisj merged commit d5635a1 into develop Apr 8, 2024
2 checks passed
@labkey-chrisj labkey-chrisj deleted the fb_charts_in_app_tests branch April 8, 2024 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants