Skip to content

Commit 2261bd1

Browse files
parent 3a3dd79
author Benjamin CHARMES <benjamin.charmes@gmail.com> 1747149404 +0200 committer Benjamin CHARMES <benjamin.charmes@gmail.com> 1747395376 +0200 Upgrade Bootstrap 5, better mobile optimisation, refactor e2e tests and tidy up! Add two more components Fix cypress test with new classes Open Modal faster to try to fix Electron cypress test Add the old Modal Re-add new Modal to check which tests fails Update e2e test batchSampleFeature to check that Modal is open before typing Update cypress commands to close Modal Update cypress commands to close Modal Fix uppercase typo Fix uppercase typo Fix getSubmitButton Fix cypress e2e Fix cypress e2e Final cypress fix Improving column management in Datatable (#1170) Co-authored-by: Matthew Evans <git@ml-evs.science> Resolve conflicts Resolve conflicts Refactor e2e tests Fix typo in sampleTablePage Fix typo in sampleTablePage Do not update 'files' reference when saving item (#1055) Improving column management in Datatable (#1170) Co-authored-by: Matthew Evans <git@ml-evs.science> Resolve conflicts Remove 'boostrap' Fix search bar height
1 parent 3a3dd79 commit 2261bd1

File tree

67 files changed

+1456
-1229
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1456
-1229
lines changed

pydatalab/src/pydatalab/bokeh_plots.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ def selectable_axes_plot(
394394
)
395395
plot_columns = [table] + plot_columns
396396

397-
layout = column(*plot_columns)
397+
layout = column(*plot_columns, sizing_mode="scale_width", align="center")
398398

399399
p.js_on_event(DoubleTap, CustomJS(args=dict(p=p), code="p.reset.emit()"))
400400
return layout
@@ -632,4 +632,8 @@ def double_axes_echem_plot(
632632
else:
633633
grid = [[p1], [xaxis_select], [yaxis_select]]
634634

635-
return gridplot(grid, sizing_mode="scale_width", toolbar_location="below")
635+
return gridplot(
636+
grid,
637+
sizing_mode="scale_width",
638+
toolbar_location="above",
639+
)

pydatalab/src/pydatalab/routes/v0_1/items.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,7 @@ def save_item():
995995
for k in (
996996
"_id",
997997
"file_ObjectIds",
998+
"files",
998999
"creators",
9991000
"creator_ids",
10001001
"item_id",

webapp/cypress/e2e/batchSampleFeature.cy.js

Lines changed: 220 additions & 274 deletions
Large diffs are not rendered by default.

webapp/cypress/e2e/editPage.cy.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
const API_URL = Cypress.config("apiUrl");
22
console.log(API_URL);
33

4-
let consoleSpy; // keeps track of every time an error is written to the console
5-
Cypress.on("window:before:load", (win) => {
6-
consoleSpy = cy.spy(win.console, "error");
7-
});
8-
94
let item_ids = ["editable_sample", "component1", "component2"];
105

116
before(() => {
@@ -26,10 +21,10 @@ describe("Edit Page", () => {
2621
it("Loads the main page without any errors", () => {
2722
cy.findByText("About").should("exist");
2823
cy.findByText("Samples").should("exist");
29-
cy.findByText("Add an item").should("exist");
24+
cy.get('[data-testid="add-item-button"]').should("exist");
3025

3126
cy.contains("Server Error. Sample list could not be retreived.").should("not.exist");
32-
expect(consoleSpy).not.to.be.called;
27+
cy.get("@consoleSpy").should("not.be.called");
3328
});
3429

3530
it("Adds a valid sample", () => {
@@ -128,7 +123,7 @@ describe("Edit Page", () => {
128123
it("deletes synthesis components and re-adds them", () => {
129124
cy.get('[data-testid="search-input"]').type("editable_sample");
130125
cy.findByText("editable_sample").click();
131-
cy.get("#synthesis-information tbody > tr:nth-of-type(1) .close").click();
126+
cy.get("#synthesis-information tbody > tr:nth-of-type(1) .btn-close").click();
132127
cy.get("#synthesis-information tbody > tr").should("have.length", 2);
133128
cy.get("#synthesis-information tbody > tr:nth-of-type(1) td:nth-of-type(2) input").should(
134129
"have.value",
@@ -139,13 +134,14 @@ describe("Edit Page", () => {
139134
"pints",
140135
);
141136

142-
cy.get("#synthesis-information tbody > tr:nth-of-type(1) .close").click();
143-
cy.get("#synthesis-information tbody > tr").should("have.length", 1);
144-
145137
cy.get("svg.add-row-button").click();
146138
cy.get("#synthesis-information .vs__search").first().type("component2");
147139
cy.get(".vs__dropdown-menu").contains(".badge", "component2").click();
140+
cy.get("#synthesis-information tbody > tr").should("have.length", 3);
141+
142+
cy.get("#synthesis-information tbody > tr:nth-of-type(1) .btn-close").click();
148143
cy.get("#synthesis-information tbody > tr").should("have.length", 2);
144+
149145
cy.get("#synthesis-information").contains("component2");
150146
cy.get("#synthesis-information tbody > tr:nth-of-type(1) td:nth-of-type(2) input").should(
151147
"have.value",
@@ -273,7 +269,7 @@ describe("Edit Page", () => {
273269
cy.get('[data-testid="add-block-dropdown"]').findByText("Powder XRD").click();
274270

275271
cy.findByText("Select a file:").should("exist");
276-
cy.get("select.file-select-dropdown").select("example_data_XRD_example_bmb.xye");
272+
cy.get('[data-testid="file-select-dropdown"]').select("example_data_XRD_example_bmb.xye");
277273
cy.contains("label", "X axis").should("exist");
278274
cy.contains("label", "Y axis").should("exist");
279275
});
@@ -289,7 +285,7 @@ describe("Edit Page", () => {
289285
cy.findByText("Add a block").click();
290286
cy.get('[data-testid="add-block-dropdown"]').findByText("Media").click();
291287
cy.findAllByText("Select a file:").eq(1).should("exist");
292-
cy.get("select.file-select-dropdown").eq(1).select(test_fname);
288+
cy.get('[data-testid="file-select-dropdown"]').eq(1).select(test_fname);
293289

294290
// Check that the img with id "media-block-img" is present
295291
cy.get('img[data-testid="media-block-img"]').should("exist");
@@ -304,7 +300,7 @@ describe("Edit Page", () => {
304300
cy.findByText("Add a block").click();
305301
cy.get('[data-testid="add-block-dropdown"]').findByText("Raman spectroscopy").click();
306302
cy.findAllByText("Select a file:").eq(2).should("exist");
307-
cy.get("select.file-select-dropdown")
303+
cy.get('[data-testid="file-select-dropdown"]')
308304
.eq(2)
309305
.select("example_data_raman_labspec_raman_example.txt");
310306
cy.contains("label", "X axis").should("exist");

webapp/cypress/e2e/equipment.cy.js

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
11
const API_URL = Cypress.config("apiUrl");
22
console.log(API_URL);
33

4-
let consoleSpy; // keeps track of every time an error is written to the console
5-
Cypress.on("window:before:load", (win) => {
6-
consoleSpy = cy.spy(win.console, "error");
7-
});
8-
94
let item_ids = ["test_e1", "test_e2", "test_e3", "123equipment", "test_e3_copy"];
105

116
before(() => {
12-
cy.visit("/equipment");
13-
cy.removeAllTestSamples(item_ids);
14-
cy.visit("/equipment").then(() => {
15-
cy.get("[data-testid='equipment-table'] > tbody > tr").should("have.length", 0);
7+
cy.cleanTestEnvironment({
8+
itemIds: item_ids,
9+
visitPath: "/equipment",
10+
checkEmptyTables: true,
1611
});
1712
});
1813

1914
after(() => {
20-
cy.visit("/equipment");
21-
cy.removeAllTestSamples(item_ids);
22-
cy.visit("/equipment").then(() => {
23-
cy.get("[data-testid='equipment-table'] > tbody > tr").should("have.length", 0);
15+
cy.cleanTestEnvironment({
16+
itemIds: item_ids,
17+
visitPath: "/equipment",
18+
checkEmptyTables: true,
2419
});
2520
});
2621

@@ -32,7 +27,7 @@ describe("Equipment table page", () => {
3227
it("Loads the equipment page without any errors", () => {
3328
cy.findByText("About").should("exist");
3429
cy.findByText("Equipment").should("exist");
35-
cy.findByText("Add an item").should("exist");
30+
cy.findByTestId("add-equipment-button").should("exist");
3631
cy.findByText("Maintainers").should("exist");
3732

3833
// Ensure no error messages or console errors. The wait is necessary so that
@@ -42,7 +37,7 @@ describe("Equipment table page", () => {
4237
// a wait time in ms?
4338
cy.wait(100).then(() => {
4439
cy.contains("Server Error. Equipment list could not be retreived.").should("not.exist");
45-
expect(consoleSpy).not.to.be.called;
40+
cy.get("@consoleSpy").should("not.be.called");
4641
});
4742
});
4843

@@ -72,7 +67,7 @@ describe("Equipment table page", () => {
7267
});
7368

7469
it("Attempts to Add an item with the same name", () => {
75-
cy.findByText("Add an item").click();
70+
cy.openAndWaitForModal("[data-testid=add-equipment-button]");
7671
cy.get('[data-testid="create-equipment-form"]').within(() => {
7772
cy.findByText("Add equipment").should("exist");
7873
cy.findByLabelText("ID:").type("test_e3");
@@ -97,11 +92,12 @@ describe("Equipment table page", () => {
9792
});
9893

9994
it("copies an equipment entry", () => {
100-
cy.findByText("Add an item").click();
95+
cy.openAndWaitForModal("[data-testid=add-equipment-button]");
10196

10297
cy.get('[data-testid="create-equipment-form"]').within(() => {
10398
cy.findByLabelText("ID:").type("test_e3_copy");
10499
cy.findByLabelText("(Optional) Copy from existing equipment:").type("test_e3");
100+
cy.waitForVsDropdown();
105101
cy.findByLabelText("(Optional) Copy from existing equipment:")
106102
.contains(".vs__dropdown-menu .badge", "test_e3")
107103
.click();

webapp/cypress/e2e/sampleTablePage.cy.js

Lines changed: 25 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
const API_URL = Cypress.config("apiUrl");
22
console.log(API_URL);
33

4-
let consoleSpy; // keeps track of every time an error is written to the console
5-
Cypress.on("window:before:load", (win) => {
6-
consoleSpy = cy.spy(win.console, "error");
7-
});
8-
9-
let sample_ids = [
4+
let item_ids = [
105
"12345678910",
116
"test1",
127
"test2",
@@ -34,15 +29,17 @@ let sample_ids = [
3429
let collection_ids = ["test_collection"];
3530

3631
before(() => {
37-
cy.visit("/");
38-
cy.removeAllTestSamples(sample_ids, true);
39-
cy.removeAllTestCollections(collection_ids, true);
32+
cy.cleanTestEnvironment({
33+
itemIds: item_ids,
34+
collectionIds: collection_ids,
35+
});
4036
});
4137

4238
after(() => {
43-
cy.visit("/");
44-
cy.removeAllTestSamples(sample_ids, true);
45-
cy.removeAllTestCollections(collection_ids, true);
39+
cy.cleanTestEnvironment({
40+
itemIds: item_ids,
41+
collectionIds: collection_ids,
42+
});
4643
});
4744

4845
describe("Sample table page", () => {
@@ -53,11 +50,11 @@ describe("Sample table page", () => {
5350
it("Loads the main page without any errors", () => {
5451
cy.findByText("About").should("exist");
5552
cy.findByText("Samples").should("exist");
56-
cy.findByText("Add an item").should("exist");
53+
cy.findByTestId("add-item-button").should("exist");
5754
cy.findByText("# of blocks").should("exist");
5855

5956
cy.contains("Server Error. Sample list could not be retreived.").should("not.exist");
60-
expect(consoleSpy).not.to.be.called;
57+
cy.get("@consoleSpy").should("not.be.called");
6158
});
6259

6360
it("Adds a valid sample", () => {
@@ -77,7 +74,7 @@ describe("Sample table page", () => {
7774
});
7875

7976
it("Attempts to add an item with the same name", () => {
80-
cy.findByText("Add an item").click();
77+
cy.openAndWaitForModal("[data-testid=add-item-button]");
8178
cy.get('[data-testid="create-item-form"]').within(() => {
8279
cy.findByLabelText("ID:").type("12345678910");
8380
cy.contains("already in use").should("exist");
@@ -195,11 +192,10 @@ describe.only("Advanced sample creation features", () => {
195192
});
196193

197194
it("Adds a third sample copied from the first", () => {
198-
cy.findByText("Add an item").click();
195+
cy.openAndWaitForModal("[data-testid=add-item-button]");
199196
cy.get('[data-testid="create-item-form"]').within(() => {
200197
cy.findByLabelText("ID:").type("testAcopy");
201-
cy.findByLabelText("(Optional) Copy from existing sample:").type("testA");
202-
cy.get(".vs__dropdown-menu").contains(".badge", "testA").click();
198+
cy.selectVsOption("copy-from-select", "testA", { dataTestId: true });
203199
cy.findByDisplayValue("COPY OF the first test sample").clear().type("a copied sample");
204200
cy.findByText("Submit").click();
205201
});
@@ -226,14 +222,12 @@ describe.only("Advanced sample creation features", () => {
226222

227223
cy.get(".datablock-content div").first().type("a comment is added here.");
228224
cy.expandIfCollapsed("[data-testid=synthesis-block]");
229-
cy.get("#synthesis-information .vs__search").first().type("component3");
230-
cy.get(".vs__dropdown-menu").contains(".badge", "component3").click();
225+
cy.selectVsOption("synthesis-table", "component3", { dataTestId: true });
231226

232227
cy.get("#synthesis-information tbody tr:nth-of-type(1) input").eq(0).type("30");
233228

234229
cy.get("svg.add-row-button").click();
235-
cy.get("#synthesis-information .vs__search").first().type("component4");
236-
cy.get(".vs__dropdown-menu").contains(".badge", "component4").click();
230+
cy.selectVsOption("synthesis-table", "component4", { dataTestId: true });
237231

238232
cy.get("#synthesis-information tbody tr:nth-of-type(2) input").eq(0).type("100"); // eq(1) gets the second element that matches
239233

@@ -244,11 +238,10 @@ describe.only("Advanced sample creation features", () => {
244238
});
245239

246240
it("copies the second sample", () => {
247-
cy.findByText("Add an item").click();
241+
cy.openAndWaitForModal("[data-testid=add-item-button]");
248242
cy.get('[data-testid="create-item-form"]').within(() => {
249243
cy.findByLabelText("ID:").type("testBcopy");
250-
cy.findByLabelText("(Optional) Copy from existing sample:").type("testB");
251-
cy.get(".vs__dropdown-menu").contains(".badge", "testB").click();
244+
cy.selectVsOption("copy-from-select", "testB", { dataTestId: true });
252245
cy.findByText("Submit").click();
253246
});
254247
cy.verifySample("testBcopy", "COPY OF the second test sample");
@@ -269,23 +262,13 @@ describe.only("Advanced sample creation features", () => {
269262
});
270263

271264
it("copies the copied sample, this time with additional components", () => {
272-
cy.findByText("Add an item").click();
265+
cy.openAndWaitForModal("[data-testid=add-item-button]");
273266
cy.get('[data-testid="create-item-form"]').within(() => {
274267
cy.findByLabelText("ID:").type("testBcopy_copy");
275-
cy.findByLabelText("(Optional) Copy from existing sample:").type("testBcopy");
276-
cy.findByLabelText("(Optional) Copy from existing sample:")
277-
.contains(".vs__dropdown-menu .badge", "testBcopy")
278-
.click();
279268

280-
cy.findByLabelText("(Optional) Start with constituents:").type("component2");
281-
cy.findByLabelText("(Optional) Start with constituents:")
282-
.contains(".vs__dropdown-menu .badge", "component2")
283-
.click();
284-
285-
cy.findByLabelText("(Optional) Start with constituents:").type("component3");
286-
cy.findByLabelText("(Optional) Start with constituents:")
287-
.contains(".vs__dropdown-menu .badge", "component3")
288-
.click();
269+
cy.selectVsOption("copy-from-select", "testBcopy", { dataTestId: true });
270+
cy.selectVsOption("start-with-constituents", "component2", { dataTestId: true });
271+
cy.selectVsOption("start-with-constituents", "component3", { dataTestId: true });
289272

290273
cy.findByText("Submit").click();
291274
});
@@ -312,6 +295,9 @@ describe.only("Advanced sample creation features", () => {
312295
cy.selectItemCheckbox("sample", test_id);
313296
cy.get('[data-testid="selected-dropdown"]').click();
314297
cy.get('[data-testid="add-to-collection-button"]').click();
298+
299+
cy.waitForModal();
300+
315301
cy.findByLabelText("Insert into collection:").type("test_collection");
316302
cy.findByText('Create new collection: "test_collection"').click();
317303
cy.get('form[data-testid="add-to-collection-form"]').within(() => {

0 commit comments

Comments
 (0)