Skip to content

Commit c6d151d

Browse files
committed
adding option to clean up output folder while exporting
1 parent b474537 commit c6d151d

3 files changed

Lines changed: 30 additions & 10 deletions

File tree

app/assets/app.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1506,10 +1506,13 @@ summary:hover {
15061506
margin-bottom: 1em;
15071507
}
15081508

1509-
.allure-test-report-checkbox {
1509+
.export-extra-checkbox-group {
15101510
margin-top: -8px;
15111511
margin-bottom: 8px;
15121512
}
1513+
.export-extra-checkbox-group > * {
1514+
margin-right: 16px;
1515+
}
15131516

15141517
.indent-left {
15151518
margin-left: 8px;

src/component/Modal/ExportProjectModal.jsx

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const CheckboxGroup = Checkbox.Group,
3434
format: "jest",
3535
loading: false,
3636
allure: false,
37+
cleanup: true,
3738
error: ""
3839
};
3940

@@ -58,7 +59,7 @@ export class ExportProjectModal extends AbstractTestRunnerModal {
5859
environment: PropTypes.any
5960
}
6061

61-
state = DEFAULT_STATE;
62+
state = { ...DEFAULT_STATE };
6263

6364
constructor( props ) {
6465
super( props );
@@ -73,6 +74,12 @@ export class ExportProjectModal extends AbstractTestRunnerModal {
7374
});
7475
}
7576

77+
onChangeCleanUp = ( e ) => {
78+
this.setState({
79+
cleanup: e.target.checked
80+
});
81+
}
82+
7683
onChange = ( checkedList ) => {
7784
const { files } = this.props;
7885
this.setState({
@@ -172,8 +179,12 @@ export class ExportProjectModal extends AbstractTestRunnerModal {
172179
sharedTargets: project.targets,
173180
env: envDto,
174181
projectOptions: browserOptions,
175-
suiteOptions: { allure: this.state.allure },
176-
exportOptions: {}
182+
suiteOptions: {
183+
allure: this.state.allure
184+
},
185+
exportOptions: {
186+
cleanup: this.state.cleanup
187+
}
177188
});
178189
message.info( `Project exported in ${ selectedDirectory }` );
179190
break;
@@ -219,7 +230,7 @@ export class ExportProjectModal extends AbstractTestRunnerModal {
219230
// Do not update until visible
220231
shouldComponentUpdate( nextProps ) {
221232
if ( this.props.isVisible !== nextProps.isVisible ) {
222-
this.setState( DEFAULT_STATE );
233+
nextProps.isVisible || this.setState( DEFAULT_STATE );
223234
return true;
224235
}
225236
if ( !nextProps.isVisible ) {
@@ -293,7 +304,7 @@ export class ExportProjectModal extends AbstractTestRunnerModal {
293304
style={{ width: 348 }}
294305
placeholder="Select an output format"
295306
onChange={ this.onChangeFormat }
296-
defaultValue="jest"
307+
value={ format }
297308
>
298309
<Option value="jest" key="jest">Jest/Puppeteer project (CI-friendly)</Option>
299310
<Option value="text" key="text">test specification</Option>
@@ -316,10 +327,14 @@ export class ExportProjectModal extends AbstractTestRunnerModal {
316327
id="inExportProjectModal"
317328
label="Select a directory to export" />
318329

319-
{ format === "jest" && <div className="allure-test-report-checkbox">
320-
<Checkbox onChange={ this.onChangeAllure }>generate
330+
<div className="export-extra-checkbox-group">
331+
{ format === "jest" && <Checkbox onChange={ this.onChangeAllure }>generate
321332
{ " " } <a onClick={ this.onExtClick } href="http://allure.qatools.ru/">Allure Test Report</a>
322-
</Checkbox></div> }
333+
</Checkbox> }
334+
<Checkbox defaultChecked={ this.state.cleanup } onChange={ this.onChangeCleanUp }>
335+
clean up output folder
336+
</Checkbox>
337+
</div>
323338

324339
<If exp={ files.length }>
325340
<p>Please select suites to export:</p>

src/service/io.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ export async function exportProject({
191191
JEST_PKG = getJestPkgDirectory();
192192

193193
try {
194-
removeExport( outputDirectory );
194+
if ( exportOptions.cleanup ) {
195+
removeExport( outputDirectory );
196+
}
195197

196198
shell.mkdir( "-p" , testDir );
197199
shell.rm( "-rf" , join( projectDirectory, DIR_SCREENSHOTS ) );

0 commit comments

Comments
 (0)