Added the support for generating docs from template doc
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
use App\Models\DocumentTemplate;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Pest\Laravel; // for static analysis hints
|
||||
use function Pest\Laravel\actingAs;
|
||||
use function Pest\Laravel\get;
|
||||
use function Pest\Laravel\post;
|
||||
|
||||
it('shows index page', function () {
|
||||
$user = User::factory()->create();
|
||||
$user->givePermissionTo('manage-settings');
|
||||
$this->actingAs($user);
|
||||
|
||||
$resp = $this->get(route('admin.document-templates.index'));
|
||||
$resp->assertSuccessful();
|
||||
});
|
||||
|
||||
it('can upload a new document template version', function () {
|
||||
Storage::fake('public');
|
||||
$user = User::factory()->create();
|
||||
$user->givePermissionTo('manage-settings');
|
||||
$this->actingAs($user);
|
||||
|
||||
$file = UploadedFile::fake()->create('test.docx', 12, 'application/vnd.openxmlformats-officedocument.wordprocessingml.document');
|
||||
|
||||
$resp = $this->post(route('admin.document-templates.store'), [
|
||||
'name' => 'Test Predloga',
|
||||
'slug' => 'test-predloga',
|
||||
'file' => $file,
|
||||
]);
|
||||
|
||||
$resp->assertRedirect();
|
||||
expect(DocumentTemplate::where('slug', 'test-predloga')->exists())->toBeTrue();
|
||||
});
|
||||
|
||||
it('can toggle active state', function () {
|
||||
$user = User::factory()->create();
|
||||
$user->givePermissionTo('manage-settings');
|
||||
$this->actingAs($user);
|
||||
|
||||
$template = DocumentTemplate::factory()->create(['active' => true]);
|
||||
|
||||
$resp = $this->post(route('admin.document-templates.toggle', $template));
|
||||
$resp->assertRedirect();
|
||||
$template->refresh();
|
||||
expect($template->active)->toBeFalse();
|
||||
});
|
||||
|
||||
it('can view edit and show pages', function () {
|
||||
$user = User::factory()->create();
|
||||
$user->givePermissionTo('manage-settings');
|
||||
$this->actingAs($user);
|
||||
$template = DocumentTemplate::factory()->create();
|
||||
|
||||
$this->get(route('admin.document-templates.show', $template))->assertSuccessful();
|
||||
$this->get(route('admin.document-templates.edit', $template))->assertSuccessful();
|
||||
});
|
||||
Reference in New Issue
Block a user