Skip to content

Commit

Permalink
add e2e tests for batch cell creation
Browse files Browse the repository at this point in the history
  • Loading branch information
jdbocarsly committed Jul 25, 2024
1 parent 1e807f6 commit 271f7c0
Showing 1 changed file with 145 additions and 0 deletions.
145 changes: 145 additions & 0 deletions webapp/cypress/e2e/batchSampleFeature.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ let sample_ids = [
"test103_unique",
"test101_unique2",
"test101_unique",
"cell_A",
"cell_B",
"cell_C",
"cell_D",
"comp1",
"comp2",
"cell_1",
"cell_2",
"cell_3",
];

before(() => {
Expand Down Expand Up @@ -704,3 +713,139 @@ describe("Batch sample creation", () => {
cy.verifySample("test101_unique2");
});
});

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

it("creates a simple batch of cells", () => {
cy.contains("Add batch of items").click();
cy.get("[data-testid=batch-modal-container]").findByLabelText("Type:").select("cell");
cy.findByLabelText("Number of rows:").clear().type(4);
cy.get("[data-testid=batch-add-table] > tbody > tr").should("have.length", 4);

getSubmitButton().should("be.disabled");
getBatchAddCell(1, 1, "input").type("cell_A");
// set positive electrode for the first cell
getBatchAddCell(1, 5, "input.vs__search").eq(0).type("abcdef");
cy.get(".vs__dropdown-menu").contains("abcdef").click();

getBatchAddCell(2, 1, "input").type("cell_B");
getBatchAddCell(2, 2, "input").type("this cell has a name");

getSubmitButton().should("be.disabled");
getBatchAddCell(3, 1, "input").type("cell_C");
getBatchAddCell(3, 3, "input").type("2017-06-01T08:30");
getBatchAddCell(4, 1, "input").type("cell_D");

getSubmitButton().click();

cy.verifySample("cell_A");
cy.verifySample("cell_B", "this cell has a name");
cy.verifySample("cell_C", null, "2017-06-01");
cy.verifySample("cell_D");
});

it("adds some component samples to be used for the next tests", () => {
cy.contains("Add batch of items").click();
cy.findByLabelText("Number of rows:").clear().type(2);

getBatchAddCell(1, 1).type("comp1");
getBatchAddCell(1, 2).type("comp1 name");
getBatchAddCell(2, 1).type("comp2");

getSubmitButton().click();
cy.get("[data-testid=batch-modal-container]").contains("a", "comp1");
cy.get("[data-testid=batch-modal-container]").contains("a", "comp2");
});

it("creates a batch of cells using the template id, name, date, copyFrom, and components", () => {
cy.contains("Add batch of items").click();

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

getBatchTemplateCell(1, "input").eq(0).type("cell_{{}#{}}");
getBatchTemplateCell(2, "input").type("this is the test cell #{{}#{}}");
getBatchTemplateCell(3, "input").type("1980-02-01T23:59");

// select copyFrom sample, check that it is applied correctly
getBatchTemplateCell(4, ".vs__search").type("cell_B");
cy.get(".vs__dropdown-menu").contains(".badge", "cell_B").click();

getBatchAddCell(1, 4).contains("cell_B");
getBatchAddCell(2, 4).contains("cell_B");
getBatchAddCell(3, 4).contains("cell_B");

// change the copyFrom sample, check that it is applied correctly
getBatchTemplateCell(4, ".vs__search").type("cell_A");
cy.get(".vs__dropdown-menu").contains(".badge", "cell_A").click();

getBatchAddCell(1, 4).contains("cell_A");
getBatchAddCell(2, 4).contains("cell_A");
getBatchAddCell(3, 4).contains("cell_A");

// add a positive electrode, check that it is applied correctly
getBatchTemplateCell(5, ".vs__search").eq(0).type("comp1");
cy.get(".vs__dropdown-menu").contains(".badge", "comp1").click();

getBatchAddCell(1, 5).contains("comp1");
getBatchAddCell(2, 5).contains("comp1");
getBatchAddCell(3, 5).contains("comp1");

// add another component, this one tagged (i.e., not in the db) check that it is applied correctly
getBatchTemplateCell(5, ".vs__search").eq(0).type("tagged");
cy.get(".vs__dropdown-menu").eq(0).contains("tagged").click();

getBatchAddCell(1, 5).contains("comp1");
getBatchAddCell(1, 5).contains("tagged");
getBatchAddCell(2, 5).contains("comp1");
getBatchAddCell(2, 5).contains("tagged");
getBatchAddCell(3, 5).contains("comp1");
getBatchAddCell(3, 5).contains("tagged");

// add electrolyte
getBatchTemplateCell(5, ".vs__search").eq(1).type("elyte");
cy.get(".vs__dropdown-menu").eq(0).contains("elyte").click();
getBatchAddCell(1, 5).contains("elyte");
getBatchAddCell(2, 5).contains("elyte");
getBatchAddCell(3, 5).contains("elyte");

// add negative electrode
getBatchTemplateCell(5, ".vs__search").eq(2).type("comp2");
cy.get(".vs__dropdown-menu").eq(0).contains(".badge", "comp2").click();
getBatchAddCell(1, 5).contains("comp2");
getBatchAddCell(2, 5).contains("comp2");
getBatchAddCell(3, 5).contains("comp2");

getSubmitButton().click();
cy.get("[data-testid=batch-modal-container]").contains("a", "cell_1");
cy.get("[data-testid=batch-modal-container]").contains("a", "cell_2");
cy.get("[data-testid=batch-modal-container]").contains("a", "cell_3");

cy.findAllByText("Successfully created.").should("have.length", 3);

cy.get("[data-testid=batch-modal-container]").contains("Close").click();

cy.verifySample("cell_1", "this is the test cell #1", "1980-02-01T23:59");
cy.verifySample("cell_2", "this is the test cell #2", "1980-02-01T23:59");
cy.verifySample("cell_3", "this is the test cell #3", "1980-02-01T23:59");

function checkCreatedCell(item_id) {
cy.contains(item_id).click();
cy.get("#pos-electrode-table").contains("comp1");
cy.get("#pos-electrode-table").contains("tagged");
cy.get("#pos-electrode-table").contains("comp1 name");

cy.get("#electrolyte-table").contains("elyte");

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

cy.findByText("Home").click();
}

checkCreatedCell("cell_1");
checkCreatedCell("cell_2");
checkCreatedCell("cell_3");
});
});

0 comments on commit 271f7c0

Please sign in to comment.