Skip to content

Commit 1e2e0e7

Browse files
authored
For templated queries: variables shown in title of result table
1 parent ac9f9cf commit 1e2e0e7

File tree

5 files changed

+40
-7
lines changed

5 files changed

+40
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Support for multiple configurations (#69, #49).
1313
- Collections of known configurations are gathered in subdirectories of main/configs (#175).
14+
- For templated queries: variables shown in title of result table (#163).
1415

1516
## [1.5.0] - 2025-01-02
1617

README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ inspect the corresponding results.
66
Table of contents:
77

88
* [Preface](#preface)
9-
* [Prerequistes](#prerequistes)
9+
* [Prerequisites](#prerequisites)
1010
* [Getting started](#getting-started)
1111
* [The supporting resources](#the-supporting-resources)
1212
* [Static, production build](#static-production-build)
@@ -25,6 +25,7 @@ Table of contents:
2525
* [For developers](#for-developers)
2626
* [Adding your own configuration](#adding-your-own-configuration)
2727
* [Testing](#testing)
28+
* [Additional prerequisites](#additional-prerequisites)
2829
* [Testing the production version](#testing-the-production-version)
2930
* [Testing the development version](#testing-the-development-version)
3031

@@ -41,9 +42,10 @@ In order to be able to maintain several different configurations (or *flavours*)
4142
Before launching or building the application, their contents need to be copied from the appropriate subdirectory of `main/configs`.
4243
The instructions below explain when and how to use the `select-config.cjs` script for this purpose.
4344

44-
## Prerequistes
45+
## Prerequisites
4546

4647
* Node >= 18 with npm
48+
* A Linux platform with a bash shell
4749

4850
## Getting started
4951

@@ -382,14 +384,28 @@ The easiest way to add your own configuration is:
382384

383385
### Testing
384386

385-
For testing with the provided configuration file, we use [Cypress](https://www.cypress.io/).
386-
387387
> It is important to test the production version at least at the end of a development cycle.
388388
389389
The development version might be tested repeatedly during development.
390390

391391
Both the production version and the development version are tested from a non-empty path in the base URL.
392392

393+
#### Additional prerequisites
394+
395+
Testing uses [Cypress](https://docs.cypress.io/app/get-started/why-cypress).
396+
The app will be installed with `npm install` as documented below, but you need to do take care of additional [Linux prerequisites](https://docs.cypress.io/app/get-started/install-cypress#Linux-Prerequisites).
397+
398+
We instruct Cypress to use the Chrome browser, so you'll need it on your system. Installation example:
399+
400+
```bash
401+
sudo apt update
402+
sudo apt -y upgrade
403+
sudo apt -y autoremove
404+
cd ~
405+
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
406+
sudo apt -y install ./google-chrome-stable_current_amd64.deb
407+
```
408+
393409
#### Testing the production version
394410

395411
1. Build the production version of the Web application and serve it:

main/src/components/ListResultTable/ListResultTable.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function ListResultTable(props) {
4747
sort={sort}
4848
>
4949
{isLoading && <Loading loadingSecondary={"The page is loading. Just a moment please."} />}
50-
{!isLoading && <QueryResultList resource={resource} { ...rest } />}
50+
{!isLoading && <QueryResultList resource={resource} variables={variables} { ...rest } />}
5151
</ListBase>
5252
);
5353
}

main/src/components/ListResultTable/QueryResultList/QueryResultList.jsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import CustomConversionButton from "../../CustomQueryEditor/customConversionButt
1818
* @returns {Component} custom ListViewer as defined by react-admin containing the results of the query with each variable its generic field.
1919
*/
2020
function QueryResultList(props) {
21-
const { resource, changeVariables, submitted } = props;
21+
const { resource, variables, changeVariables, submitted } = props;
2222
const resourceDef = useResourceDefinition();
2323

2424
const queryTitle = resourceDef.options.label;
@@ -42,7 +42,14 @@ function QueryResultList(props) {
4242
{submitted && <Aside changeVariables={changeVariables} />}
4343
{resourceDef.options.queryGroupId === 'cstm' ? <CustomQueryEditButton queryID={resourceDef.name} submitted={submitted} /> : <CustomConversionButton query={query} id={resourceDef.name}/>}
4444
</div>
45-
<Typography fontSize={"2rem"} mt={2} > {queryTitle} </Typography>
45+
<Typography sx={{ fontSize: '2rem' }} > {queryTitle} </Typography>
46+
{variables && <>
47+
{Object.keys(variables).map((key) => {
48+
return (<Typography sx={{ fontSize: '1.5rem' }} > {key}: {variables[key]} </Typography>)
49+
})
50+
}
51+
</>
52+
}
4653
{values ? (
4754
<ListView title=" " actions={<ActionBar />} {...props} >
4855
<Datagrid header={<TableHeader query={query} />} bulkActionButtons={false}>

test/cypress/e2e/templated-query.cy.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ describe("Templated query", () => {
1818
// Comfirm query
1919
cy.get('button').contains('Query').click();
2020

21+
// Check the display of the variable(s) and their value
22+
cy.contains("genre: \"Baroque\"");
23+
2124
// Check that the page loaded and that we can see the correct data
2225
cy.contains("Finished in:");
2326
cy.get('.column-name').find('span').contains("Johann Sebastian Bach");
@@ -69,6 +72,12 @@ describe("Templated query", () => {
6972
cy.get('li').contains('Mozart').click();
7073

7174
cy.get('button').contains('Query').click();
75+
76+
// Check the display of the variable(s) and their value
77+
cy.contains("genre: \"Classical\"");
78+
cy.contains("sameAsUrl: <https://en.wikipedia.org/wiki/Wolfgang_Amadeus_Mozart>");
79+
80+
// Check that the page loaded and that we can see the correct data
7281
cy.contains("Finished in:");
7382
cy.get('.column-name').find('span').contains("Wolfgang Amadeus Mozart");
7483
});

0 commit comments

Comments
 (0)