Skip to content

Commit 445819d

Browse files
author
Daniel Lobo
committed
bug fixes on test cases
1 parent c6775a1 commit 445819d

2 files changed

Lines changed: 66 additions & 8 deletions

File tree

components/TestCases/CreateTestCase.js

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class CreateTestCase extends React.Component {
4444
exerciseQuestion: '',
4545
visibility: '',
4646
timeout: '',
47+
stdin: '',
4748
programArguments: '',
4849
expectedOutputs: ''
4950
}
@@ -60,10 +61,14 @@ class CreateTestCase extends React.Component {
6061
this.setState({ timeout: timeout.target.value })
6162
}
6263

63-
onInputsChange = programArguments => {
64+
onProgramArgumentsChange = programArguments => {
6465
this.setState({ programArguments: programArguments.target.value })
6566
}
6667

68+
onStdinChange = stdin => {
69+
this.setState({ stdin: stdin.target.value })
70+
}
71+
6772
onExpectedOutputsChange = expectedOutputs => {
6873
this.setState({ expectedOutputs: expectedOutputs.target.value })
6974
}
@@ -95,6 +100,10 @@ class CreateTestCase extends React.Component {
95100
.split(',')
96101
.map(str => str.replace(/\s/g, ''))
97102

103+
const stdinArray = this.state.stdin
104+
.split(',')
105+
.map(str => str.replace(/\s/g, ''))
106+
98107
const url = `${process.env.API_HOST}/exercises/${this.state.exerciseID}/test-cases`
99108

100109
console.log(
@@ -117,6 +126,7 @@ class CreateTestCase extends React.Component {
117126
body: JSON.stringify({
118127
visibility: this.state.visibility,
119128
timeout: this.state.timeout,
129+
stdin: stdinArray,
120130
programArguments: programArgumentsArray,
121131
expectedOutputs: expectedOutputsArray
122132
})
@@ -201,10 +211,10 @@ class CreateTestCase extends React.Component {
201211
<Grid item xs={6}>
202212
<TextField
203213
id="outlined-name"
204-
label="Inputs"
214+
label="Program Arguments"
205215
placeholder="input1, input2, input3"
206216
style={{ margin: 20 }}
207-
onChange={this.onInputsChange}
217+
onChange={this.onProgramArgumentsChange}
208218
value={this.state.programArguments}
209219
fullWidth
210220
margin="normal"
@@ -213,6 +223,22 @@ class CreateTestCase extends React.Component {
213223
</Grid>
214224
</Grid>
215225

226+
<Grid container spacing={24} alignItems="center">
227+
<Grid item xs={6}>
228+
<TextField
229+
id="outlined-name"
230+
label="Stdin"
231+
placeholder="one, two, three"
232+
style={{ margin: 20 }}
233+
onChange={this.onStdinChange}
234+
value={this.state.stdin}
235+
fullWidth
236+
margin="normal"
237+
variant="outlined"
238+
/>
239+
</Grid>
240+
</Grid>
241+
216242
<Grid container spacing={24} alignItems="center">
217243
<Grid item xs={6}>
218244
<TextField

components/TestCases/ModifyTestCase.js

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class ModifyTestCase extends React.Component {
4646
exerciseQuestion: '',
4747
visibility: '',
4848
timeout: '',
49+
stdin: '',
4950
programArguments: '',
5051
expectedOutputs: ''
5152
}
@@ -88,8 +89,9 @@ class ModifyTestCase extends React.Component {
8889
testCaseID: testCaseID,
8990
visibility: testCaseJSONResponse.visibility,
9091
timeout: testCaseJSONResponse.timeout,
91-
programArguments: testCaseJSONResponse.programArguments,
92-
expectedOutputs: testCaseJSONResponse.expectedOutputs
92+
stdin: testCaseJSONResponse.stdin.join(),
93+
programArguments: testCaseJSONResponse.programArguments.join(),
94+
expectedOutputs: testCaseJSONResponse.expectedOutputs.join()
9395
})
9496
})
9597
.catch(err => console.log(err))
@@ -107,15 +109,23 @@ class ModifyTestCase extends React.Component {
107109
this.setState({ timeout: timeout.target.value })
108110
}
109111

110-
onInputsChange = programArguments => {
112+
onProgramArgumentsChange = programArguments => {
111113
this.setState({ programArguments: programArguments.target.value })
112114
}
113115

116+
onStdinChange = stdin => {
117+
this.setState({ stdin: stdin.target.value })
118+
}
119+
114120
onExpectedOutputsChange = expectedOutputs => {
115121
this.setState({ expectedOutputs: expectedOutputs.target.value })
116122
}
117123

118124
modifyTestCase = () => {
125+
console.log('object1', this.state.programArguments)
126+
console.log('object2', this.state.expectedOutputs)
127+
console.log('object3', this.state.stdin)
128+
119129
const programArgumentsArray =
120130
this.state.programArguments === []
121131
? []
@@ -130,6 +140,11 @@ class ModifyTestCase extends React.Component {
130140
.split(',')
131141
.map(str => str.replace(/\s/g, ''))
132142

143+
const stdinArray =
144+
this.state.stdin === []
145+
? []
146+
: this.state.stdin.split(',').map(str => str.replace(/\s/g, ''))
147+
133148
const url = `${process.env.API_HOST}/test-cases/${this.state.testCaseID}`
134149
this.props.enqueueSnackbar('Modificando test case', { variant: 'info' })
135150

@@ -142,6 +157,7 @@ class ModifyTestCase extends React.Component {
142157
body: JSON.stringify({
143158
visibility: this.state.visibility,
144159
timeout: this.state.timeout,
160+
stdin: stdinArray,
145161
programArguments: programArgumentsArray,
146162
expectedOutputs: expectedOutputsArray
147163
})
@@ -225,10 +241,10 @@ class ModifyTestCase extends React.Component {
225241
<Grid item xs={6}>
226242
<TextField
227243
id="outlined-name"
228-
label="Inputs"
244+
label="Program Arguments"
229245
placeholder="input1, input2, input3"
230246
style={{ margin: 20 }}
231-
onChange={this.onInputsChange}
247+
onChange={this.onProgramArgumentsChange}
232248
value={this.state.programArguments}
233249
fullWidth
234250
margin="normal"
@@ -237,6 +253,22 @@ class ModifyTestCase extends React.Component {
237253
</Grid>
238254
</Grid>
239255

256+
<Grid container spacing={24} alignItems="center">
257+
<Grid item xs={6}>
258+
<TextField
259+
id="outlined-name"
260+
label="Stdin"
261+
placeholder="one, two, three"
262+
style={{ margin: 20 }}
263+
onChange={this.onStdinChange}
264+
value={this.state.stdin}
265+
fullWidth
266+
margin="normal"
267+
variant="outlined"
268+
/>
269+
</Grid>
270+
</Grid>
271+
240272
<Grid container spacing={24} alignItems="center">
241273
<Grid item xs={6}>
242274
<TextField

0 commit comments

Comments
 (0)