Skip to content

Commit 5d6b80a

Browse files
authored
Templated queries: changing variables dialogue is preloaded with previous values (#179)
1 parent 1e2e0e7 commit 5d6b80a

File tree

7 files changed

+122
-115
lines changed

7 files changed

+122
-115
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ 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).
14+
- Templated queries: variables shown in title of result table (#163).
15+
- Templated queries: changing variables dialogue is preloaded with previous values (#167).
1516

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

README.md

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -79,40 +79,26 @@ In case of the `demo` configuration:
7979

8080
## The supporting resources
8181

82-
The supporting resources are located in directory `test`.
82+
The supporting resources are located in directory `test`, along with some scripts useful for testing.
8383

84-
These include:
84+
Resources:
8585

8686
* a local pod containing data used in the `demo` and `test` configurations;
87-
* proxies used int the `demo` and `test` configurations;
88-
* scripts to support automated testing.
87+
* proxies used in the `demo` and `test` configurations.
8988

90-
To install, go to directory `test` and execute:
89+
Go to directory `test`.
90+
91+
To install, execute:
9192

9293
```bash
9394
npm install
9495
```
9596

96-
Next, activate the supporting resources by executing each of the following steps
97-
in a new terminal window, also in directory `test`:
98-
99-
1. Prepare and start the local pods:
100-
101-
```bash
102-
npm run reset:pods && npm run start:pods
103-
```
104-
105-
2. Start the http proxy:
106-
107-
```bash
108-
npm run start:proxy
109-
```
97+
Spin up resources:
11098

111-
3. Start a server which denies all CORS headers:
112-
113-
```bash
114-
npm run start:badCors
115-
```
99+
```bash
100+
npm run start:support
101+
```
116102

117103
## Static, production build
118104

main/src/components/ListResultTable/TemplatedQueryForm.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import CustomQueryEditButton from "../CustomQueryEditor/customQueryEditButton";
66

77
const MyToolbar = () => (
88
<Toolbar>
9-
<SaveButton icon={<DoneIcon/>} label="Query"/>
9+
<SaveButton icon={<DoneIcon/>} label="Query" alwaysEnable />
1010
</Toolbar>
1111
);
1212

@@ -43,6 +43,7 @@ const TemplatedQueryForm = (props) => {
4343
label={name}
4444
validate={required()}
4545
fullWidth={true}
46+
defaultValue={searchPar[name]}
4647
choices={
4748
options.map((option) => ({
4849
id: option,

test/cypress/e2e/indirect-variables.cy.js

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -52,75 +52,6 @@ describe("Indirect variable query", () => {
5252
cy.get('.column-name').find('span').contains("Johann Sebastian Bach").should("not.exist");
5353
cy.get('.column-name').find('span').contains("Ludwig van Beethoven").should("not.exist");
5454

55-
// Run some testcases now
56-
57-
cy.get('button').contains("Change Variables").should("exist");
58-
cy.get('button').contains("Change Variables").click();
59-
60-
// Existing combination (only Mozart)
61-
cy.get('form').within(() => {
62-
cy.get('#genre').click();
63-
});
64-
cy.get('li').contains('Classical').click();
65-
66-
cy.get('form').within(() => {
67-
cy.get('#sameAsUrl').click();
68-
});
69-
cy.get('li').contains('Mozart').click();
70-
71-
cy.get('button[type="submit"]').click();
72-
73-
74-
cy.contains("Finished in:");
75-
cy.get('.column-name').find('span').contains("Wolfgang Amadeus Mozart").should("exist");;
76-
77-
cy.get('.column-name').find('span').contains("Franz Schubert").should("not.exist");
78-
cy.get('.column-name').find('span').contains("Johann Sebastian Bach").should("not.exist");
79-
cy.get('.column-name').find('span').contains("Ludwig van Beethoven").should("not.exist");
80-
81-
// Change variables and make an unexisting combination
82-
cy.get('button').contains("Change Variables").should("exist");
83-
cy.get('button').contains("Change Variables").click();
84-
85-
cy.get('form').within(() => {
86-
cy.get('#genre').click();
87-
});
88-
cy.get('li').contains('Baroque').click();
89-
90-
cy.get('form').within(() => {
91-
cy.get('#sameAsUrl').click();
92-
});
93-
cy.get('li').contains('Beethoven').click();
94-
95-
cy.get('button[type="submit"]').click();
96-
97-
cy.get('span').contains("The result list is empty.").should("exist");
98-
99-
100-
101-
// Change variables and make another existing combination
102-
103-
cy.get('button').contains("Change Variables").should("exist");
104-
cy.get('button').contains("Change Variables").click();
105-
106-
cy.get('form').within(() => {
107-
cy.get('#genre').click();
108-
});
109-
cy.get('li').contains('Romantic').click();
110-
111-
cy.get('form').within(() => {
112-
cy.get('#sameAsUrl').click();
113-
});
114-
cy.get('li').contains('Schubert').click();
115-
116-
cy.get('button[type="submit"]').click();
117-
118-
cy.get('span').contains("The result list is empty.").should("not.exist");
119-
cy.get('.column-name').find('span').contains("Ludwig van Beethoven").should("not.exist");
120-
cy.get('.column-name').find('span').contains("Johann Sebastian Bach").should("not.exist");
121-
cy.get('.column-name').find('span').contains("Antonio Vivaldi").should("not.exist");
122-
cy.get('.column-name').find('span').contains("Franz Schubert").should("exist");
123-
12455
});
12556

12657

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

Lines changed: 56 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe("Templated query", () => {
99
cy.contains("Example queries").click();
1010
cy.contains("A templated query about musicians").click();
1111

12-
// Fill in the query, select Baroque (7 existant artists -> perfect for this test)
12+
// Fill in the query, select Baroque (7 existing artists -> perfect for this test)
1313
cy.get('form').within(() => {
1414
cy.get('#genre').click();
1515
});
@@ -57,7 +57,7 @@ describe("Templated query", () => {
5757
cy.get('.column-name').find('span').should("have.length", 2);
5858
});
5959

60-
it("With 2 variables", () => {
60+
it("With 2 variables; change variables", () => {
6161
cy.visit("/");
6262
cy.contains("Example queries").click();
6363
cy.contains("A templated query about musicians (two variables)").click();
@@ -79,35 +79,71 @@ describe("Templated query", () => {
7979

8080
// Check that the page loaded and that we can see the correct data
8181
cy.contains("Finished in:");
82-
cy.get('.column-name').find('span').contains("Wolfgang Amadeus Mozart");
83-
});
82+
cy.get('.column-name').find('span').contains("Wolfgang Amadeus Mozart").should("exist");;
83+
cy.get('.column-name').find('span').contains("Franz Schubert").should("not.exist");
84+
cy.get('.column-name').find('span').contains("Johann Sebastian Bach").should("not.exist");
85+
cy.get('.column-name').find('span').contains("Ludwig van Beethoven").should("not.exist");
8486

85-
it("Able to change variables after making a templated query", () => {
86-
cy.visit("/");
87-
cy.contains("Example queries").click();
88-
cy.contains("A templated query about musicians").click();
87+
// Check if the button to make a new query exists and use it
88+
cy.get('button').contains("Change Variables").should("exist");
89+
cy.get('button').contains("Change Variables").click();
90+
91+
// Making sure we get the form to enter new variables
92+
// and that the previously selected value(s) are still there
93+
cy.get('form').within(() => {
94+
cy.get('#genre').should('have.value', '"Classical"');
95+
cy.get('#sameAsUrl').should('have.value', '<https://en.wikipedia.org/wiki/Wolfgang_Amadeus_Mozart>');
96+
});
97+
98+
// Previously selected variables are still there; submit the same combination again
99+
cy.get('button[type="submit"]').click();
100+
101+
cy.contains("Finished in:");
102+
cy.get('.column-name').find('span').contains("Wolfgang Amadeus Mozart").should("exist");;
103+
cy.get('.column-name').find('span').contains("Franz Schubert").should("not.exist");
104+
cy.get('.column-name').find('span').contains("Johann Sebastian Bach").should("not.exist");
105+
cy.get('.column-name').find('span').contains("Ludwig van Beethoven").should("not.exist");
106+
107+
// Change variables and make a nonexisting combination
108+
cy.get('button').contains("Change Variables").should("exist");
109+
cy.get('button').contains("Change Variables").click();
89110

90-
// Fill in the query
91111
cy.get('form').within(() => {
92112
cy.get('#genre').click();
93113
});
94114
cy.get('li').contains('Baroque').click();
95115

96-
// Comfirm query
97-
cy.get('button').contains('Query').click();
116+
cy.get('form').within(() => {
117+
cy.get('#sameAsUrl').click();
118+
});
119+
cy.get('li').contains('Beethoven').click();
98120

99-
// Check that the page loaded and that we can see the correct data
100-
cy.contains("Finished in:");
101-
cy.get('.column-name').find('span').contains("Johann Sebastian Bach");
121+
cy.get('button[type="submit"]').click();
102122

103-
// Check if the button to make a new query exists and use it
123+
cy.get('span').contains("The result list is empty.").should("exist");
124+
125+
// Change variables and make another existing combination
104126
cy.get('button').contains("Change Variables").should("exist");
105127
cy.get('button').contains("Change Variables").click();
106128

107-
// Making sure we get the form to enter new variables
108129
cy.get('form').within(() => {
109-
cy.get('#genre').should("exist");
130+
cy.get('#genre').click();
131+
});
132+
cy.get('li').contains('Romantic').click();
133+
134+
cy.get('form').within(() => {
135+
cy.get('#sameAsUrl').click();
110136
});
137+
cy.get('li').contains('Schubert').click();
138+
139+
cy.get('button[type="submit"]').click();
140+
141+
cy.get('span').contains("The result list is empty.").should("not.exist");
142+
cy.get('.column-name').find('span').contains("Ludwig van Beethoven").should("not.exist");
143+
cy.get('.column-name').find('span').contains("Johann Sebastian Bach").should("not.exist");
144+
cy.get('.column-name').find('span').contains("Antonio Vivaldi").should("not.exist");
145+
cy.get('.column-name').find('span').contains("Franz Schubert").should("exist");
146+
111147
});
112148

113149
it("Correct message displayed when no resulting data", () => {
@@ -161,8 +197,11 @@ describe("Templated query", () => {
161197
cy.get('button').contains("Change Variables").click();
162198

163199
// Making sure we get the form to enter new variables
200+
// and that the previously selected value(s) are still there
164201
cy.get('form').within(() => {
165202
cy.get('#genre').should("exist");
203+
cy.get('#genre').should('have.value', '"Classical"');
204+
cy.get('#sameAsUrl').should('have.value', '<https://en.wikipedia.org/wiki/Johann_Sebastian_Bach>');
166205
});
167206

168207
});

test/package-lock.json

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@
1313
"start:pods": "npx @solid/community-server -c @css:config/file-no-setup.json -f pods -p 8080",
1414
"reset:pods": "rimraf pods && npm run prepare:pods",
1515
"start:proxy": "node scripts/local-proxy.mjs",
16-
"start:badCors": "node scripts/start-bad-cors-server.mjs"
16+
"start:badCors": "node scripts/start-bad-cors-server.mjs",
17+
"start:support": "concurrently --kill-others \"npm run reset:pods && npm run start:pods\" \"npm run start:proxy\" \"npm run start:badCors\""
1718
},
1819
"dependencies": {
1920
"@solid/community-server": "^6.0.1",
21+
"concurrently": "^9.1.2",
2022
"copyfiles": "^2.4.1",
2123
"cors": "^2.8.5",
2224
"cors-anywhere": "^0.4.4",
2325
"cypress": "^13.8.0",
2426
"express": "^4.18.2",
25-
"rimraf": "^5.0.1",
26-
"http-server": "^14.1.1"
27+
"http-server": "^14.1.1",
28+
"rimraf": "^5.0.1"
2729
}
2830
}

0 commit comments

Comments
 (0)