Skip to content

Commit 29c1bb4

Browse files
Merge pull request #54 from oslabs-beta/v4_stage
Nick: puppeteer bug fix
2 parents 0667f50 + 3731042 commit 29c1bb4

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/context/reducers/puppeteerTestCaseReducer.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createContext } from 'react';
22
import { PuppeteerTestCaseState, PuppeteerAction } from '../../utils/puppeteerTypes';
3-
//import { actionTypes } from '../actions/puppeteerTestCaseActions';
3+
44
export const PuppeteerTestCaseContext = createContext<any>(null);
55

66
export const puppeteerTestCaseState = {
@@ -21,7 +21,7 @@ export const puppeteerTestCaseState = {
2121
browserOptionId: 0,
2222
},
2323
],
24-
statementId: 0,
24+
statementId: 1,
2525
modalOpen: false,
2626
};
2727

@@ -56,10 +56,14 @@ export const puppeteerTestCaseReducer = (
5656

5757
switch (action.type) {
5858
case 'DELETE_PUPPETEER_TEST':
59-
puppeteerStatements = puppeteerStatements.filter((statement) => statement.id !== action.id);
59+
puppeteerStatements.splice(action.id, 1);
60+
puppeteerStatements.forEach((statement) => {
61+
if (statement.id > action.id) statement.id -= 1;
62+
});
6063
return {
6164
...state,
6265
puppeteerStatements,
66+
statementId: state.statementId - 1,
6367
};
6468

6569
case 'ADD_PUPPETEER_PAINT_TIMING': {
@@ -90,7 +94,7 @@ export const puppeteerTestCaseReducer = (
9094
browserOptionId: 0,
9195
},
9296
],
93-
statementId: 0,
97+
statementId: 1,
9498
};
9599

96100
case 'DELETE_BROWSER_OPTION':
@@ -171,7 +175,6 @@ export const puppeteerTestCaseReducer = (
171175
puppeteerStatements: [...action.draggableStatements],
172176
};
173177
case 'OPEN_INFO_MODAL':
174-
console.log('reducer');
175178
return {
176179
...state,
177180
modalOpen: true,

0 commit comments

Comments
 (0)