Skip to content

Commit

Permalink
Re-add old components to run cypress e2e tests on /old routes
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminCharmes committed Sep 16, 2024
1 parent 1ce390d commit c14e79e
Show file tree
Hide file tree
Showing 12 changed files with 407 additions and 38 deletions.
44 changes: 28 additions & 16 deletions webapp/cypress/e2e/batchSampleFeature.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,18 @@ let sample_ids = [
];

before(() => {
cy.visit("/");
cy.visit("/old-sample");
cy.removeAllTestSamples(sample_ids, true);
});

after(() => {
cy.visit("/");
cy.visit("/old-sample");
cy.removeAllTestSamples(sample_ids, true);
});

describe("Batch sample creation", () => {
beforeEach(() => {
cy.visit("/");
cy.visit("/old-sample");
});
it("Adds 3 valid samples", () => {
cy.contains("Add batch of items").click();
Expand Down Expand Up @@ -162,7 +162,8 @@ describe("Batch sample creation", () => {
cy.get(".datablock-content div").first().type("a comment is added here.");

cy.get(".fa-save").click();
cy.findByText("Home").click();
// cy.findByText("Home").click();
cy.visit("/old-sample");
});

it("modifies some data in the second sample", () => {
Expand All @@ -185,7 +186,8 @@ describe("Batch sample creation", () => {
cy.get("#synthesis-information tbody tr:nth-of-type(2) input").eq(0).type("100");

cy.get(".fa-save").click();
cy.findByText("Home").click();
// cy.findByText("Home").click();
cy.visit("/old-sample");
});

it("makes samples copied from others", () => {
Expand Down Expand Up @@ -223,7 +225,8 @@ describe("Batch sample creation", () => {
cy.findByLabelText("Name").should("have.value", "a copied sample");
cy.findByText("this is a description of baseA.");
cy.findByText("a comment is added here.");
cy.findByText("Home").click();
// cy.findByText("Home").click();
cy.visit("/old-sample");

cy.contains(/^baseB_copy$/).click();
cy.findByText("this is a description of baseB.");
Expand All @@ -236,7 +239,8 @@ describe("Batch sample creation", () => {
cy.get("#synthesis-information tbody tr:nth-of-type(2) input")
.eq(0)
.should("have.value", "100");
cy.findByText("Home").click();
// cy.findByText("Home").click();
cy.visit("/old-sample");

cy.findByText("baseB_copy2").click();
cy.findByText("this is a description of baseB.");
Expand All @@ -249,7 +253,8 @@ describe("Batch sample creation", () => {
cy.get("#synthesis-information tbody tr:nth-of-type(2) input")
.eq(0)
.should("have.value", "100");
cy.findByText("Home").click();
// cy.findByText("Home").click();
cy.visit("/old-sample");
});

it("creates samples using components", () => {
Expand Down Expand Up @@ -324,7 +329,8 @@ describe("Batch sample creation", () => {
cy.get("#synthesis-information table").contains("component2");
cy.get("#synthesis-information tbody tr:nth-of-type(1) input").eq(0).should("have.value", "");
cy.get("#synthesis-information tbody tr:nth-of-type(2) input").eq(0).should("have.value", "");
cy.findByText("Home").click();
// cy.findByText("Home").click();
cy.visit("/old-sample");

cy.contains("test102").click();
cy.findByLabelText("Name").should(
Expand All @@ -337,7 +343,8 @@ describe("Batch sample creation", () => {
cy.get("#synthesis-information tbody tr:nth-of-type(1) input").eq(0).should("have.value", "");
cy.get("#synthesis-information tbody tr:nth-of-type(2) input").eq(0).should("have.value", "");
cy.findByText("a comment is added here.");
cy.findByText("Home").click();
// cy.findByText("Home").click();
cy.visit("/old-sample");

cy.contains("test103").click();
cy.findByLabelText("Name").should(
Expand Down Expand Up @@ -370,7 +377,8 @@ describe("Batch sample creation", () => {

cy.findByText("a comment is added here.");
cy.findByText("a second comment is added here.");
cy.findByText("Home").click();
// cy.findByText("Home").click();
cy.visit("/old-sample");

cy.contains("test104").click();
cy.findByLabelText("Name").should(
Expand Down Expand Up @@ -412,7 +420,8 @@ describe("Batch sample creation", () => {
cy.findByText("a comment is added here.");
cy.findByText("a second comment is added here.");

cy.findByText("Home").click();
// cy.findByText("Home").click();
cy.visit("/old-sample");
});

it("uses the template id", () => {
Expand Down Expand Up @@ -539,7 +548,8 @@ describe("Batch sample creation", () => {

cy.findByText("a comment is added here.");
cy.findByText("a second comment is added here.");
cy.findByText("Home").click();
// cy.findByText("Home").click();
cy.visit("/old-sample");
}

checkCreatedSample("test_1");
Expand Down Expand Up @@ -645,7 +655,8 @@ describe("Batch sample creation", () => {

cy.findByText("a comment is added here.");
cy.findByText("a second comment is added here.");
cy.findByText("Home").click();
// cy.findByText("Home").click();
cy.visit("/old-sample");
}

cy.verifySample("test1", "name1");
Expand Down Expand Up @@ -716,7 +727,7 @@ describe("Batch sample creation", () => {

describe("Batch cell creation", () => {
beforeEach(() => {
cy.visit("/");
cy.visit("/old-sample");
});

it("creates a simple batch of cells", () => {
Expand Down Expand Up @@ -841,7 +852,8 @@ describe("Batch cell creation", () => {

cy.get("#neg-electrode-table").contains("comp2");

cy.findByText("Home").click();
// cy.findByText("Home").click();
cy.visit("/old-sample");
}

checkCreatedCell("cell_1");
Expand Down
17 changes: 10 additions & 7 deletions webapp/cypress/e2e/editPage.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ Cypress.on("window:before:load", (win) => {
let item_ids = ["editable_sample", "component1", "component2"];

before(() => {
cy.visit("/");
cy.visit("/old-sample");
cy.removeAllTestSamples(item_ids, true);
});

after(() => {
cy.visit("/");
cy.visit("/old-sample");
cy.removeAllTestSamples(item_ids, true);
});

describe("Edit Page", () => {
beforeEach(() => {
cy.visit("/");
cy.visit("/old-sample");
});

it("Loads the main page without any errors", () => {
Expand Down Expand Up @@ -51,12 +51,13 @@ describe("Edit Page", () => {
cy.findByText("Unsaved changes");
cy.get(".fa-save").click();
cy.contains("Unsaved changes").should("not.exist");
cy.contains("Home").click();
// cy.findByText("Home").click();
cy.visit("/old-sample");

cy.findByText("editable_sample");
cy.findByText("This is a sample name");
cy.findByText("1990-01-07");
cy.get("tbody tr:nth-of-type(3)").contains("NaCoO2"); // sorta check the formula
cy.findByText("NaCoO2"); // sorta check the formula
});

it("adds a chemical formula to component1", () => {
Expand Down Expand Up @@ -236,7 +237,9 @@ describe("Edit Page", () => {
cy.get(".fa-save").click();
cy.contains("Unsaved changes").should("not.exist");

cy.findByText("Home").click();
cy.get("[data-testid=sample-table] tr:nth-of-type(3) > td:nth-of-type(8)").contains(2); // 2 blocks are present
// cy.findByText("Home").click();
cy.visit("/old-sample");
cy.get("#test103").contains(2); // 2 blocks are present
// cy.get("[data-testid=sample-table] tr:nth-of-type(3) > td:nth-of-type(8)").contains(2); // 2 blocks are present
});
});
14 changes: 7 additions & 7 deletions webapp/cypress/e2e/equipment.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ Cypress.on("window:before:load", (win) => {
let item_ids = ["test_e1", "test_e2", "test_e3", "123equipment", "test_e3_copy"];

before(() => {
cy.visit("/equipment");
cy.visit("/old-equipment");
cy.removeAllTestSamples(item_ids);
cy.visit("/equipment").then(() => {
cy.visit("/old-equipment").then(() => {
cy.get("[data-testid='equipment-table'] > tbody > tr").should("have.length", 0);
});
});

after(() => {
cy.visit("/equipment");
cy.visit("/old-equipment");
cy.removeAllTestSamples(item_ids);
cy.visit("/equipment").then(() => {
cy.visit("/old-equipment").then(() => {
cy.get("[data-testid='equipment-table'] > tbody > tr").should("have.length", 0);
});
});

describe("Equipment table page", () => {
beforeEach(() => {
cy.visit("/equipment");
cy.visit("/old-equipment");
});

it("Loads the equipment page without any errors", () => {
Expand Down Expand Up @@ -113,7 +113,7 @@ describe("Equipment table page", () => {

describe("Equipment edit page", () => {
beforeEach(() => {
cy.visit("/equipment/");
cy.visit("/old-equipment/");
});

it("Checks the equipment edit page", () => {
Expand All @@ -135,7 +135,7 @@ describe("Equipment edit page", () => {
cy.get(".datablock-content div").first().type("a comment is added here.");

cy.get(".fa-save").click();
cy.visit("/equipment");
cy.visit("/old-equipment");
cy.verifyEquipment("test_e3", "my inst", "2000-01-01T00:00", "room 101");
});
});
8 changes: 4 additions & 4 deletions webapp/cypress/e2e/sampleTablePage.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ let sample_ids = [
];

before(() => {
cy.visit("/");
cy.visit("/old-sample");
cy.removeAllTestSamples(sample_ids, true);
});

after(() => {
cy.visit("/");
cy.visit("/old-sample");
cy.removeAllTestSamples(sample_ids, true);
});

describe("Sample table page", () => {
beforeEach(() => {
cy.visit("/");
cy.visit("/old-sample");
});

it("Loads the main page without any errors", () => {
Expand Down Expand Up @@ -183,7 +183,7 @@ describe("Sample table page", () => {

describe.only("Advanced sample creation features", () => {
beforeEach(() => {
cy.visit("/");
cy.visit("/old-sample");
});
it("Adds some valid samples", () => {
cy.createSample("testA", "the first test sample");
Expand Down
2 changes: 1 addition & 1 deletion webapp/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ Cypress.Commands.add("removeAllTestSamples", (item_ids, check_sample_table) => {
cy.deleteSampleViaAPI(item_id);
});
if (check_sample_table) {
cy.visit("/").then(() => {
cy.visit("/old-sample").then(() => {
cy.get("[data-testid=sample-table] > tbody > tr").should("have.length", 0);
});
}
Expand Down
3 changes: 0 additions & 3 deletions webapp/src/components/CollectionInformation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,18 @@
<CollectionRelationshipVisualization :collection_id="collection_id" />
</div>
</div>
<FancyCollectionSampleTable :collection_id="collection_id" />
</div>
</template>

<script>
import { createComputedSetterForCollectionField } from "@/field_utils.js";
import FancyCollectionSampleTable from "@/components/FancyCollectionSampleTable";
import TinyMceInline from "@/components/TinyMceInline";
import Creators from "@/components/Creators";
import CollectionRelationshipVisualization from "@/components/CollectionRelationshipVisualization";
export default {
components: {
TinyMceInline,
FancyCollectionSampleTable,
Creators,
CollectionRelationshipVisualization,
},
Expand Down
1 change: 1 addition & 0 deletions webapp/src/components/DynamicDataTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<DataTable
v-model:filters="filters"
v-model:selection="itemsSelected"
data-testid="sample-table"
selection-mode="multiple"
:value="data"
paginator
Expand Down
Loading

0 comments on commit c14e79e

Please sign in to comment.