Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion frontend/src/core/cells/__tests__/cells.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2109,7 +2109,7 @@ describe("cell reducer", () => {
actions.addSetupCellIfDoesntExist({ code: "# Updated setup code" });

// Check that the same setup cell was updated, not duplicated
expect(state.cellData[SETUP_CELL_ID].code).toBe("# Setup code");
expect(state.cellData[SETUP_CELL_ID].code).toBe("# Updated setup code");
expect(state.cellData[SETUP_CELL_ID].edited).toBe(true);
expect(state.cellIds.inOrderIds).toContain(SETUP_CELL_ID);
});
Expand Down Expand Up @@ -2143,6 +2143,24 @@ describe("cell reducer", () => {
expect(state.cellIds.inOrderIds).toContain(SETUP_CELL_ID);
});

it("can delete and then create a new setup cell", () => {
// Create the setup cell
actions.addSetupCellIfDoesntExist({ code: "# Setup code" });

// Delete the setup cell
actions.deleteCell({ cellId: SETUP_CELL_ID });

// Create a new setup cell
actions.addSetupCellIfDoesntExist({ code: "# New code" });

// Check that the new setup cell was created
expect(state.cellData[SETUP_CELL_ID].id).toBe(SETUP_CELL_ID);
expect(state.cellData[SETUP_CELL_ID].name).toBe("setup");
expect(state.cellData[SETUP_CELL_ID].code).toBe("# New code");
expect(state.cellData[SETUP_CELL_ID].edited).toBe(true);
expect(state.cellIds.inOrderIds).toContain(SETUP_CELL_ID);
});

it("can clear all outputs", () => {
// Add a cell and give it output
actions.createNewCell({
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/core/cells/cells.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1336,7 +1336,7 @@ const {
}

// First check if setup cell already exists
if (SETUP_CELL_ID in state.cellData) {
if (SETUP_CELL_ID in state.cellIds) {
// Just focus on the existing setup cell
return {
...state,
Expand Down
Loading