Skip to content

Commit 96b000a

Browse files
BenjaminCharmesml-evs
authored andcommitted
Update tests to include item status
1 parent d2804a4 commit 96b000a

File tree

4 files changed

+76
-29
lines changed

4 files changed

+76
-29
lines changed

webapp/cypress/component/EquipmentTableTest.cy.jsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ describe("EquipmentTable Component Tests", () => {
7373
const headers = [
7474
"", // checkbox
7575
"ID",
76+
"Status",
7677
"Name",
7778
"Date",
7879
"Location",
@@ -92,10 +93,10 @@ describe("EquipmentTable Component Tests", () => {
9293
.within(() => {
9394
cy.get("td").eq(0).should("contain.text", "");
9495
cy.get("td").eq(1).should("contain.text", "equipment1");
95-
cy.get("td").eq(2).should("contain.text", "Equipment One");
96-
cy.get("td").eq(3).should("contain.text", "9/1/2023");
97-
cy.get("td").eq(4).should("contain.text", "Warehouse A");
98-
cy.get("td").eq(5).find(".avatar").should("have.length", 1);
96+
cy.get("td").eq(3).should("contain.text", "Equipment One");
97+
cy.get("td").eq(4).should("contain.text", "9/1/2023");
98+
cy.get("td").eq(5).should("contain.text", "Warehouse A");
99+
cy.get("td").eq(6).find(".avatar").should("have.length", 1);
99100
});
100101

101102
cy.get(".p-datatable-tbody")
@@ -104,10 +105,10 @@ describe("EquipmentTable Component Tests", () => {
104105
.within(() => {
105106
cy.get("td").eq(0).should("contain.text", "");
106107
cy.get("td").eq(1).should("contain.text", "equipment2");
107-
cy.get("td").eq(2).should("contain.text", "Equipment Two");
108-
cy.get("td").eq(3).should("contain.text", "8/15/2023");
109-
cy.get("td").eq(4).should("contain.text", "Warehouse B");
110-
cy.get("td").eq(5).find(".avatar").should("have.length", 2);
108+
cy.get("td").eq(3).should("contain.text", "Equipment Two");
109+
cy.get("td").eq(4).should("contain.text", "8/15/2023");
110+
cy.get("td").eq(5).should("contain.text", "Warehouse B");
111+
cy.get("td").eq(6).find(".avatar").should("have.length", 2);
111112
});
112113
});
113114

@@ -128,12 +129,12 @@ describe("EquipmentTable Component Tests", () => {
128129
cy.get(".p-datatable-tbody tr")
129130
.eq(0)
130131
.within(() => {
131-
cy.get("td").eq(5).find(".avatar").should("exist");
132+
cy.get("td").eq(6).find(".avatar").should("exist");
132133
});
133134
cy.get(".p-datatable-tbody tr")
134135
.eq(1)
135136
.within(() => {
136-
cy.get("td").eq(5).find(".avatar").should("exist");
137+
cy.get("td").eq(6).find(".avatar").should("exist");
137138
});
138139
});
139140
});

webapp/cypress/component/SampleTableTest.cy.jsx

Lines changed: 60 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ describe("SampleTable Component Tests", () => {
2626
item_id: "sample1",
2727
type: "samples",
2828
name: "Sample 1",
29+
status: "PLANNED",
2930
chemform: "H2O",
3031
date: "2023-09-01T12:34:56Z",
3132
collections: [{ collection_id: "collection1" }],
@@ -38,6 +39,7 @@ describe("SampleTable Component Tests", () => {
3839
item_id: "sample2",
3940
type: "samples",
4041
name: "Sample 2",
42+
status: "ACTIVE",
4143
chemform: "H2O",
4244
date: "2023-09-02T12:34:56Z",
4345
collections: [{ collection_id: "collection2" }],
@@ -50,6 +52,7 @@ describe("SampleTable Component Tests", () => {
5052
item_id: "sample3",
5153
type: "samples",
5254
name: "Sample 3",
55+
status: "FAILED",
5356
chemform: "H2O",
5457
date: "2023-09-03T12:34:56Z",
5558
collections: [{ collection_id: "collection3" }],
@@ -62,6 +65,7 @@ describe("SampleTable Component Tests", () => {
6265
item_id: "cell1",
6366
type: "cells",
6467
name: "Cell 1",
68+
status: "CYCLED",
6569
chemform: "CH4",
6670
date: "2023-08-15T08:45:30Z",
6771
collections: [{ collection_id: "collection1" }],
@@ -74,6 +78,7 @@ describe("SampleTable Component Tests", () => {
7478
item_id: "cell2",
7579
type: "cells",
7680
name: "Cell 2",
81+
status: "DISMANTLED",
7782
chemform: "CH4",
7883
date: "2023-08-16T08:45:30Z",
7984
collections: [{ collection_id: "collection1" }, { collection_id: "collection2" }],
@@ -86,6 +91,7 @@ describe("SampleTable Component Tests", () => {
8691
item_id: "cell3",
8792
type: "cells",
8893
name: "Cell 3",
94+
status: "SHORTED",
8995
chemform: "CH4",
9096
date: "2023-08-17T08:45:30Z",
9197
collections: [
@@ -138,8 +144,8 @@ describe("SampleTable Component Tests", () => {
138144
"", //checkbox
139145
"ID",
140146
"Type",
141-
"Sample name",
142-
"Formula",
147+
"Status",
148+
"Name",
143149
"Date",
144150
"Collections",
145151
"Creators",
@@ -160,8 +166,7 @@ describe("SampleTable Component Tests", () => {
160166
cy.get("td").eq(0).should("contain.text", "");
161167
cy.get("td").eq(1).should("contain.text", "sample1");
162168
cy.get("td").eq(2).should("contain.text", "samples");
163-
cy.get("td").eq(3).should("contain.text", "Sample 1");
164-
cy.get("td").eq(4).should("contain.text", "H2O");
169+
cy.get("td").eq(4).should("contain.text", "Sample 1");
165170
cy.get("td").eq(5).should("contain.text", "9/1/2023");
166171
cy.get("td").eq(6).find(".badge").should("have.length", 1);
167172
cy.get("td").eq(7).find(".avatar").should("have.length", 1);
@@ -174,8 +179,7 @@ describe("SampleTable Component Tests", () => {
174179
cy.get("td").eq(0).should("contain.text", "");
175180
cy.get("td").eq(1).should("contain.text", "cell1");
176181
cy.get("td").eq(2).should("contain.text", "cells");
177-
cy.get("td").eq(3).should("contain.text", "Cell 1");
178-
cy.get("td").eq(4).should("contain.text", "CH4");
182+
cy.get("td").eq(4).should("contain.text", "Cell 1");
179183
cy.get("td").eq(5).should("contain.text", "8/15/2023");
180184
cy.get("td").eq(6).find(".badge").should("have.length", 1);
181185
cy.get("td").eq(7).find(".avatar").should("have.length", 2);
@@ -259,20 +263,28 @@ describe("SampleTable Component Tests", () => {
259263
cy.get(".p-datatable-tbody tr").eq(1).find("td").eq(2).should("contain.text", "samples");
260264

261265
cy.get(".p-datatable-thead th").eq(3).find(".p-datatable-sort-icon").click();
262-
cy.get(".p-datatable-tbody tr").eq(0).find("td").eq(3).should("contain.text", "Cell 1");
263-
cy.get(".p-datatable-tbody tr").eq(1).find("td").eq(3).should("contain.text", "Cell 2");
266+
cy.get(".p-datatable-tbody tr").eq(0).find("td").eq(3).should("contain.text", "ACTIVE");
267+
cy.get(".p-datatable-tbody tr").eq(1).find("td").eq(3).should("contain.text", "CYCLED");
268+
cy.get(".p-datatable-tbody tr").eq(2).find("td").eq(3).should("contain.text", "DISMANTLED");
269+
cy.get(".p-datatable-tbody tr").eq(3).find("td").eq(3).should("contain.text", "FAILED");
270+
cy.get(".p-datatable-tbody tr").eq(4).find("td").eq(3).should("contain.text", "PLANNED");
271+
cy.get(".p-datatable-tbody tr").eq(5).find("td").eq(3).should("contain.text", "SHORTED");
264272

265273
cy.get(".p-datatable-thead th").eq(3).find(".p-datatable-sort-icon").click();
266-
cy.get(".p-datatable-tbody tr").eq(0).find("td").eq(3).should("contain.text", "Sample 3");
267-
cy.get(".p-datatable-tbody tr").eq(1).find("td").eq(3).should("contain.text", "Sample 2");
274+
cy.get(".p-datatable-tbody tr").eq(0).find("td").eq(3).should("contain.text", "SHORTED");
275+
cy.get(".p-datatable-tbody tr").eq(1).find("td").eq(3).should("contain.text", "PLANNED");
276+
cy.get(".p-datatable-tbody tr").eq(2).find("td").eq(3).should("contain.text", "FAILED");
277+
cy.get(".p-datatable-tbody tr").eq(3).find("td").eq(3).should("contain.text", "DISMANTLED");
278+
cy.get(".p-datatable-tbody tr").eq(4).find("td").eq(3).should("contain.text", "CYCLED");
279+
cy.get(".p-datatable-tbody tr").eq(5).find("td").eq(3).should("contain.text", "ACTIVE");
268280

269281
cy.get(".p-datatable-thead th").eq(4).find(".p-datatable-sort-icon").click();
270-
cy.get(".p-datatable-tbody tr").eq(0).find("td").eq(4).should("contain.text", "CH4");
271-
cy.get(".p-datatable-tbody tr").eq(1).find("td").eq(4).should("contain.text", "CH4");
282+
cy.get(".p-datatable-tbody tr").eq(0).find("td").eq(4).should("contain.text", "Cell 1");
283+
cy.get(".p-datatable-tbody tr").eq(1).find("td").eq(4).should("contain.text", "Cell 2");
272284

273285
cy.get(".p-datatable-thead th").eq(4).find(".p-datatable-sort-icon").click();
274-
cy.get(".p-datatable-tbody tr").eq(0).find("td").eq(4).should("contain.text", "H2O");
275-
cy.get(".p-datatable-tbody tr").eq(1).find("td").eq(4).should("contain.text", "H2O");
286+
cy.get(".p-datatable-tbody tr").eq(0).find("td").eq(4).should("contain.text", "Sample 3");
287+
cy.get(".p-datatable-tbody tr").eq(1).find("td").eq(4).should("contain.text", "Sample 2");
276288

277289
cy.get(".p-datatable-thead th").eq(5).find(".p-datatable-sort-icon").click();
278290
cy.get(".p-datatable-tbody tr").eq(0).find("td").eq(5).should("contain.text", "8/15/2023");
@@ -366,6 +378,40 @@ describe("SampleTable Component Tests", () => {
366378
cy.get(".p-datatable-tbody tr").eq(2).find("td").eq(1).should("contain.text", "cell3");
367379
});
368380

381+
it("filters by Status correctly", () => {
382+
cy.get(".p-datatable-thead th").eq(3).find(".p-datatable-column-filter-button").click();
383+
cy.get(".p-datatable-filter-overlay").find(".p-multiselect-label-container").click();
384+
cy.get(".p-multiselect-list-container").findByText("ACTIVE").click();
385+
cy.get(".p-datatable-tbody tr").should("have.length", 1);
386+
cy.findByText("Clear").click();
387+
388+
cy.get(".p-datatable-thead th").eq(3).find(".p-datatable-column-filter-button").click();
389+
cy.get(".p-datatable-filter-overlay").find(".p-multiselect-label-container").click();
390+
cy.get(".p-multiselect-list-container").findByText("CYCLED").click();
391+
cy.get(".p-datatable-tbody tr").should("have.length", 1);
392+
cy.findByText("Clear").click();
393+
394+
cy.get(".p-datatable-thead th").eq(3).find(".p-datatable-column-filter-button").click();
395+
cy.get(".p-datatable-filter-overlay").find(".p-multiselect-label-container").click();
396+
cy.get(".p-multiselect-list-container").findByText("ACTIVE").click();
397+
cy.get(".p-datatable-tbody tr").should("have.length", 1);
398+
cy.get(".p-datatable-filter-overlay").find(".p-multiselect-label-container").click();
399+
cy.get(".p-multiselect-list-container").findByText("CYCLED").click();
400+
cy.get(".p-datatable-tbody tr").should("have.length", 2);
401+
cy.get(".p-datatable-filter-overlay").find(".p-multiselect-label-container").click();
402+
cy.get(".p-multiselect-list-container").findByText("PLANNED").click();
403+
cy.get(".p-datatable-tbody tr").should("have.length", 3);
404+
cy.get(".p-datatable-filter-overlay").find(".p-multiselect-label-container").click();
405+
cy.get(".p-multiselect-list-container").findByText("FAILED").click();
406+
cy.get(".p-datatable-tbody tr").should("have.length", 4);
407+
cy.get(".p-datatable-filter-overlay").find(".p-multiselect-label-container").click();
408+
cy.get(".p-multiselect-list-container").findByText("SHORTED").click();
409+
cy.get(".p-datatable-tbody tr").should("have.length", 5);
410+
cy.get(".p-datatable-filter-overlay").find(".p-multiselect-label-container").click();
411+
cy.get(".p-multiselect-list-container").findByText("DISMANTLED").click();
412+
cy.get(".p-datatable-tbody tr").should("have.length", 6);
413+
});
414+
369415
it("filters by Collections correctly", () => {
370416
cy.get(".p-datatable-thead th").eq(6).find(".p-datatable-column-filter-button").click();
371417
cy.get(".p-datatable-filter-overlay").find(".p-multiselect-label-container").click();

webapp/cypress/component/StartingMaterialTableTest.cy.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ describe("StartingMaterialTable Component Tests", () => {
7979
const headers = [
8080
"", // checkbox
8181
"ID",
82+
"Status",
8283
"", // barcode
8384
"Name",
8485
"Formula",
@@ -101,11 +102,10 @@ describe("StartingMaterialTable Component Tests", () => {
101102
.within(() => {
102103
cy.get("td").eq(0).should("contain.text", "");
103104
cy.get("td").eq(1).should("contain.text", "material1");
104-
cy.get("td").eq(2).should("contain.text", "123");
105105
cy.get("td").eq(3).should("contain.text", "Material One");
106106
cy.get("td").eq(4).should("contain.text", "H2O");
107107
cy.get("td").eq(5).should("contain.text", "9/1/2023");
108-
cy.get("td").eq(6).should("contain.text", "King's Lynn");
108+
cy.get("td").eq(6).should("contain.text", "99%");
109109
cy.get("td").eq(7).should("contain.text", "1");
110110
});
111111

webapp/cypress/e2e/editPage.cy.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ describe("Edit Page", () => {
4343

4444
it("Adds a valid sample", () => {
4545
cy.createSample("editable_sample", "This is a sample name", "1990-01-07T00:00");
46-
cy.get("tr>td").eq(8).should("be.empty"); // 0 blocks are present
47-
cy.get("tr>td").eq(9).should("be.empty"); // 0 files are present
46+
cy.get("tr>td").eq(9).should("be.empty"); // 0 blocks are present
47+
cy.get("tr>td").eq(10).should("be.empty"); // 0 files are present
4848
});
4949

5050
it("Add some more samples, to use as components", () => {
@@ -263,7 +263,7 @@ describe("Edit Page", () => {
263263

264264
cy.findByText("Home").click();
265265
cy.get('[data-testid="search-input"]').type("editable_sample");
266-
cy.get("[data-testid=sample-table] tr:nth-of-type(1) > td:nth-of-type(9)").contains(2); // 2 blocks are present
266+
cy.get("[data-testid=sample-table] tr:nth-of-type(1) > td:nth-of-type(10)").contains(2); // 2 blocks are present
267267
});
268268

269269
it("Clicks the upload buttons and checks that the modals are shown", () => {

0 commit comments

Comments
 (0)