Skip to content

Commit

Permalink
Update hasMany browser tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pboivin authored and ifox committed Sep 16, 2021
1 parent b36eabd commit 8531c43
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
21 changes: 17 additions & 4 deletions tests/integration/BrowsersTest.php
Expand Up @@ -143,7 +143,7 @@ public function createWriterWithbios()

$bios = collect([1, 2])->map(function ($i) {
return app(BioRepository::class)->create([
'title' => 'Lorem ipsum dolor sit amet',
'title' => 'Biography ' . $i,
'published' => true,
]);
});
Expand Down Expand Up @@ -378,9 +378,21 @@ public function testBrowserHasManyPreview()
{
$writer = $this->createWriterWithBios();

// User can preview
$this->httpRequestAssert("/twill/writers/preview/{$writer->id}", 'PUT', []);
// User can preview modifications
$this->httpRequestAssert("/twill/writers/preview/{$writer->id}", 'PUT', [
'browsers' => [
'bios' => [
[
'id' => 2,
'name' => 'Biography 2',
'endpointType' => 'App\\Models\\Writer',
'edit' => '',
],
],
],
]);
$this->assertSee('This is a writer');
$this->assertSee('Bios: Biography 2');
}

public function testBrowserHasManyPreviewRevisions()
Expand All @@ -389,9 +401,10 @@ public function testBrowserHasManyPreviewRevisions()

// User can preview revisions
$this->httpRequestAssert("/twill/writers/preview/{$writer->id}", 'PUT', [
'revisionId' => $writer->revisions->last()->id,
'revisionId' => $writer->revisions->first()->id,
]);
$this->assertSee('This is a writer');
$this->assertSee('No bios');
}

public function testBrowserHasManyRestoreRevisions()
Expand Down
10 changes: 10 additions & 0 deletions tests/stubs/browsers/writers-view.blade.php
@@ -1 +1,11 @@
<div>This is a writer</div>

<div>
@php $titles = $item->bios->pluck('title'); @endphp

@if ($titles->isNotEmpty())
Bios: {{ $titles->sort()->join(', ') }}
@else
No bios
@endif
</div>

0 comments on commit 8531c43

Please sign in to comment.