Skip to content

Commit 95d62e7

Browse files
committed
ZIP Imports/Exports: Fixed some lint and test issues
- Updated test handling to create imports folder when required. - Updated some tests to delete created import zip files.
1 parent 9ecc919 commit 95d62e7

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

resources/js/components/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export {HeaderMobileToggle} from './header-mobile-toggle';
3030
export {ImageManager} from './image-manager';
3131
export {ImagePicker} from './image-picker';
3232
export {ListSortControl} from './list-sort-control';
33-
export {LoadingButton} from './loading-button';
33+
export {LoadingButton} from './loading-button.ts';
3434
export {MarkdownEditor} from './markdown-editor';
3535
export {NewUserPassword} from './new-user-password';
3636
export {Notification} from './notification';

resources/js/components/page-comments.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ export class PageComments extends Component {
9393

9494
updateCount() {
9595
const count = this.getCommentCount();
96-
console.log('update count', count, this.container);
9796
this.commentsTitle.textContent = window.$trans.choice(this.countText, count, {count});
9897
}
9998

tests/Exports/ZipImportTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ public function test_import_upload_success()
168168
$resp->assertRedirect("/import/{$import->id}");
169169
$this->assertFileExists(storage_path($import->path));
170170
$this->assertActivityExists(ActivityType::IMPORT_CREATE);
171+
172+
ZipTestHelper::deleteZipForImport($import);
171173
}
172174

173175
public function test_import_show_page()
@@ -325,6 +327,8 @@ public function test_run_revalidates_content()
325327
$resp = $this->followRedirects($resp);
326328
$resp->assertSeeText('The name field is required.');
327329
$resp->assertSeeText('The id must be an integer.');
330+
331+
ZipTestHelper::deleteZipForImport($import);
328332
}
329333

330334
public function test_run_checks_permissions_on_import()
@@ -340,6 +344,8 @@ public function test_run_checks_permissions_on_import()
340344

341345
$resp = $this->followRedirects($resp);
342346
$resp->assertSeeText('You are lacking the required permissions to create books.');
347+
348+
ZipTestHelper::deleteZipForImport($import);
343349
}
344350

345351
public function test_run_requires_parent_for_chapter_and_page_imports()
@@ -379,6 +385,8 @@ public function test_run_validates_correct_parent_type()
379385

380386
$resp = $this->followRedirects($resp);
381387
$resp->assertSee('Parent book required for chapter import.');
388+
389+
ZipTestHelper::deleteZipForImport($import);
382390
}
383391

384392
protected function runImportFromFile(UploadedFile $file): TestResponse

tests/Exports/ZipTestHelper.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@ public static function importFromData(array $importData, array $zipData, array $
2020

2121
$import = Import::factory()->create($importData);
2222
$zip = static::zipUploadFromData($zipData, $files);
23-
rename($zip->getRealPath(), storage_path($import->path));
23+
$targetPath = storage_path($import->path);
24+
$targetDir = dirname($targetPath);
25+
26+
if (!file_exists($targetDir)) {
27+
mkdir($targetDir);
28+
}
29+
30+
rename($zip->getRealPath(), $targetPath);
2431

2532
return $import;
2633
}

0 commit comments

Comments
 (0)