Skip to content

Commit d4dba9e

Browse files
Fix cypress tests
1 parent 625e04b commit d4dba9e

File tree

7 files changed

+31
-35
lines changed

7 files changed

+31
-35
lines changed

webapp/cypress/e2e/batchSampleFeature.cy.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ describe("Batch sample creation", () => {
8484
cy.visit("/");
8585
});
8686
it("Adds 3 valid samples", () => {
87-
cy.contains("Add batch of items").click();
87+
cy.findByTestId("batch-item-button").click();
8888
getSubmitButton().should("be.disabled");
8989
getBatchAddCell(1, 1).type("testA");
9090
getBatchAddCell(2, 1).type("testB");
@@ -107,7 +107,7 @@ describe("Batch sample creation", () => {
107107
});
108108

109109
it("adds two valid samples", () => {
110-
cy.contains("Add batch of items").click();
110+
cy.findByTestId("batch-item-button").click();
111111
cy.findByLabelText("Number of rows:").clear().type(2);
112112

113113
cy.get('[data-testid="batch-modal-container"]').findByText("Submit").should("be.disabled");
@@ -126,7 +126,7 @@ describe("Batch sample creation", () => {
126126
});
127127

128128
it("adds four base samples", () => {
129-
cy.contains("Add batch of items").click();
129+
cy.findByTestId("batch-item-button").click();
130130
cy.findByLabelText("Number of rows:").clear().type(4);
131131

132132
cy.get('[data-testid="batch-modal-container"]').findByText("Submit").should("be.disabled");
@@ -189,7 +189,7 @@ describe("Batch sample creation", () => {
189189
});
190190

191191
it("makes samples copied from others", () => {
192-
cy.contains("Add batch of items").click();
192+
cy.findByTestId("batch-item-button").click();
193193
getBatchAddCell(1, 1).type("baseA_copy");
194194
getBatchAddCell(1, 2).type("a copied sample");
195195
getBatchAddCell(1, 4, ".vs__search").type("BaseA");
@@ -253,7 +253,7 @@ describe("Batch sample creation", () => {
253253
});
254254

255255
it("creates samples using components", () => {
256-
cy.contains("Add batch of items").click();
256+
cy.findByTestId("batch-item-button").click();
257257
cy.findByLabelText("Number of rows:").clear().type(4);
258258

259259
// sample with two components
@@ -416,7 +416,7 @@ describe("Batch sample creation", () => {
416416
});
417417

418418
it("uses the template id", () => {
419-
cy.contains("Add batch of items").click();
419+
cy.findByTestId("batch-item-button").click();
420420
getBatchTemplateCell(1).type("test_{{}#{}}");
421421

422422
// manually type names and a date
@@ -441,7 +441,7 @@ describe("Batch sample creation", () => {
441441
});
442442

443443
it("uses the template id, name, and date", () => {
444-
cy.contains("Add batch of items").click();
444+
cy.findByTestId("batch-item-button").click();
445445
getBatchTemplateCell(1).type("test_{{}#{}}");
446446
getBatchTemplateCell(2).type("this is the test sample #{{}#{}}");
447447
getBatchTemplateCell(3).type("1980-02-01T05:35");
@@ -464,7 +464,7 @@ describe("Batch sample creation", () => {
464464
});
465465

466466
it("uses the template id, name, date, copyFrom, and components", () => {
467-
cy.contains("Add batch of items").click();
467+
cy.findByTestId("batch-item-button").click();
468468
getBatchTemplateCell(1).type("test_{{}#{}}");
469469
getBatchTemplateCell(2).type("this is the test sample #{{}#{}}");
470470
getBatchTemplateCell(3).type("1980-02-01T23:59");
@@ -545,7 +545,7 @@ describe("Batch sample creation", () => {
545545
});
546546

547547
it("plays with the number of rows", () => {
548-
cy.contains("Add batch of items").click();
548+
cy.findByTestId("batch-item-button").click();
549549
cy.findByLabelText("Number of rows:").clear().type(3);
550550
cy.get("[data-testid=batch-add-table] > tbody > tr").should("have.length", 3);
551551

@@ -653,7 +653,7 @@ describe("Batch sample creation", () => {
653653
});
654654

655655
it("checks errors on the row", () => {
656-
cy.contains("Add batch of items").click();
656+
cy.findByTestId("batch-item-button").click();
657657
getBatchTemplateCell("1").type("test10{{}#{}}");
658658
cy.wait(100);
659659
getSubmitButton().should("be.disabled");
@@ -716,7 +716,7 @@ describe("Batch cell creation", () => {
716716
});
717717

718718
it("creates a simple batch of cells", () => {
719-
cy.contains("Add batch of items").click();
719+
cy.findByTestId("batch-item-button").click();
720720
cy.get("[data-testid=batch-modal-container]").findByLabelText("Type:").select("cell");
721721
cy.findByLabelText("Number of rows:").clear().type(4);
722722
cy.get("[data-testid=batch-add-table] > tbody > tr").should("have.length", 4);
@@ -744,7 +744,7 @@ describe("Batch cell creation", () => {
744744
});
745745

746746
it("adds some component samples to be used for the next tests", () => {
747-
cy.contains("Add batch of items").click();
747+
cy.findByTestId("batch-item-button").click();
748748
cy.findByLabelText("Number of rows:").clear().type(2);
749749

750750
getBatchAddCell(1, 1).type("comp1");
@@ -757,7 +757,7 @@ describe("Batch cell creation", () => {
757757
});
758758

759759
it("creates a batch of cells using the template id, name, date, copyFrom, and components", () => {
760-
cy.contains("Add batch of items").click();
760+
cy.findByTestId("batch-item-button").click();
761761

762762
cy.get("[data-testid=batch-modal-container]").findByLabelText("Type:").select("cell");
763763

webapp/cypress/e2e/editPage.cy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe("Edit Page", () => {
2626
it("Loads the main page without any errors", () => {
2727
cy.findByText("About").should("exist");
2828
cy.findByText("Samples").should("exist");
29-
cy.findByText("Add an item").should("exist");
29+
cy.findByTestId("add-item-button").should("exist");
3030
cy.findByText("# of blocks").should("exist");
3131

3232
cy.contains("Server Error. Sample list could not be retreived.").should("not.exist");

webapp/cypress/e2e/equipment.cy.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe("Equipment table page", () => {
3232
it("Loads the equipment page without any errors", () => {
3333
cy.findByText("About").should("exist");
3434
cy.findByText("Equipment").should("exist");
35-
cy.findByText("Add an item").should("exist");
35+
cy.findByTestId("add-equipment-button").should("exist");
3636
cy.findByText("Maintainers").should("exist");
3737

3838
// Ensure no error messages or console errors. The wait is necessary so that
@@ -72,7 +72,7 @@ describe("Equipment table page", () => {
7272
});
7373

7474
it("Attempts to Add an item with the same name", () => {
75-
cy.findByText("Add an item").click();
75+
cy.findByTestId("add-equipment-button").click();
7676
cy.get('[data-testid="create-equipment-form"]').within(() => {
7777
cy.findByText("Add equipment").should("exist");
7878
cy.findByLabelText("ID:").type("test_e3");
@@ -97,7 +97,7 @@ describe("Equipment table page", () => {
9797
});
9898

9999
it("copies an equipment entry", () => {
100-
cy.findByText("Add an item").click();
100+
cy.findByTestId("add-equipment-button").click();
101101

102102
cy.get('[data-testid="create-equipment-form"]').within(() => {
103103
cy.findByLabelText("ID:").type("test_e3_copy");

webapp/cypress/e2e/sampleTablePage.cy.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe("Sample table page", () => {
5353
it("Loads the main page without any errors", () => {
5454
cy.findByText("About").should("exist");
5555
cy.findByText("Samples").should("exist");
56-
cy.findByText("Add an item").should("exist");
56+
cy.findByTestId("add-item-button").should("exist");
5757
cy.findByText("# of blocks").should("exist");
5858

5959
cy.contains("Server Error. Sample list could not be retreived.").should("not.exist");
@@ -77,7 +77,7 @@ describe("Sample table page", () => {
7777
});
7878

7979
it("Attempts to add an item with the same name", () => {
80-
cy.findByText("Add an item").click();
80+
cy.findByTestId("add-item-button").click();
8181
cy.get('[data-testid="create-item-form"]').within(() => {
8282
cy.findByLabelText("ID:").type("12345678910");
8383
cy.contains("already in use").should("exist");
@@ -195,7 +195,7 @@ describe.only("Advanced sample creation features", () => {
195195
});
196196

197197
it("Adds a third sample copied from the first", () => {
198-
cy.findByText("Add an item").click();
198+
cy.findByTestId("add-item-button").click();
199199
cy.get('[data-testid="create-item-form"]').within(() => {
200200
cy.findByLabelText("ID:").type("testAcopy");
201201
cy.findByLabelText("(Optional) Copy from existing sample:").type("testA");
@@ -243,7 +243,7 @@ describe.only("Advanced sample creation features", () => {
243243
});
244244

245245
it("copies the second sample", () => {
246-
cy.findByText("Add an item").click();
246+
cy.findByTestId("add-item-button").click();
247247
cy.get('[data-testid="create-item-form"]').within(() => {
248248
cy.findByLabelText("ID:").type("testBcopy");
249249
cy.findByLabelText("(Optional) Copy from existing sample:").type("testB");
@@ -268,7 +268,7 @@ describe.only("Advanced sample creation features", () => {
268268
});
269269

270270
it("copies the copied sample, this time with additional components", () => {
271-
cy.findByText("Add an item").click();
271+
cy.findByTestId("add-item-button").click();
272272
cy.get('[data-testid="create-item-form"]').within(() => {
273273
cy.findByLabelText("ID:").type("testBcopy_copy");
274274
cy.findByLabelText("(Optional) Copy from existing sample:").type("testBcopy");

webapp/cypress/support/commands.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const API_URL = Cypress.config("apiUrl");
3434
Cypress.Commands.add(
3535
"createSample",
3636
(item_id, name = null, date = null, generate_id_automatically = false) => {
37-
cy.findByText("Add an item").click();
37+
cy.findByTestId("add-item-button").click();
3838
cy.get('[data-testid="create-item-form"]').within(() => {
3939
cy.findByText("Add new item").should("exist");
4040
cy.findByLabelText("ID:").type(item_id);
@@ -151,7 +151,7 @@ Cypress.Commands.add("searchAndSelectItem", (search_text, selector, clickPlus =
151151
});
152152

153153
Cypress.Commands.add("createEquipment", (item_id, name = null, date = null) => {
154-
cy.findByText("Add an item").click();
154+
cy.findByTestId("add-equipment-button").click();
155155

156156
cy.get('[data-testid="create-equipment-form"]').within(() => {
157157
cy.findByText("Add equipment").should("exist");

webapp/src/components/DynamicDataTableButtons.vue

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<template>
22
<div v-if="showButtons" class="d-flex justify-content-between align-items-center flex-wrap gap-2">
3-
<!-- Section gauche : Boutons ou dropdown -->
43
<div class="d-flex flex-grow-1 align-items-center gap-2">
5-
<!-- Dropdown visible automatiquement en mobile -->
64
<div class="d-lg-none dropdown">
75
<button
86
class="btn btn-default dropdown-toggle"
@@ -16,7 +14,7 @@
1614
<li>
1715
<button
1816
v-if="dataType === 'samples'"
19-
data-testid="add-item-button"
17+
data-testid="add-item-button-mobile"
2018
class="dropdown-item"
2119
@click="$emit('open-create-item-modal')"
2220
>
@@ -26,7 +24,7 @@
2624
<li>
2725
<button
2826
v-if="dataType === 'samples'"
29-
data-testid="batch-item-button"
27+
data-testid="batch-item-button-mobile"
3028
class="dropdown-item"
3129
@click="$emit('open-batch-create-item-modal')"
3230
>
@@ -36,7 +34,7 @@
3634
<li>
3735
<button
3836
v-if="dataType === 'samples'"
39-
data-testid="scan-qr-button"
37+
data-testid="scan-qr-button-mobile"
4038
class="dropdown-item"
4139
@click="$emit('open-qr-scanner-modal')"
4240
>
@@ -46,7 +44,7 @@
4644
<li>
4745
<button
4846
v-if="dataType === 'collections'"
49-
data-testid="add-collection-button"
47+
data-testid="add-collection-button-mobile"
5048
class="dropdown-item"
5149
@click="$emit('open-create-collection-modal')"
5250
>
@@ -56,7 +54,7 @@
5654
<li>
5755
<button
5856
v-if="dataType === 'startingMaterials' && editableInventory"
59-
data-testid="add-starting-material-button"
57+
data-testid="add-starting-material-button-mobile"
6058
class="dropdown-item"
6159
@click="$emit('open-create-item-modal')"
6260
>
@@ -66,7 +64,7 @@
6664
<li>
6765
<button
6866
v-if="dataType === 'equipment'"
69-
data-testid="add-equipment-button"
67+
data-testid="add-equipment-button-mobile"
7068
class="dropdown-item"
7169
@click="$emit('open-create-equipment-modal')"
7270
>
@@ -76,7 +74,6 @@
7674
</ul>
7775
</div>
7876

79-
<!-- Boutons visibles en grand écran -->
8077
<div class="d-none d-lg-flex gap-2">
8178
<button
8279
v-if="dataType === 'samples'"
@@ -129,7 +126,6 @@
129126
</div>
130127
</div>
131128

132-
<!-- Section droite : Dropdown "Selected" et recherche -->
133129
<div class="d-flex align-items-center gap-2">
134130
<div class="dropdown">
135131
<button

webapp/src/views/EditPage.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
</span>
2727
<router-link class="nav-item nav-link" to="/">Home</router-link>
2828

29-
<div class="nav-item dropdown">
29+
<div data-testid="add-block-dropdown" class="nav-item dropdown">
3030
<a
3131
id="navbarDropdown"
3232
class="nav-link dropdown-toggle"

0 commit comments

Comments
 (0)