Skip to content

Commit

Permalink
Merge branch '8.4' into 9.4
Browse files Browse the repository at this point in the history
  • Loading branch information
crynobone committed Jul 12, 2023
2 parents 1f0f3a8 + 2f2310d commit 540e1da
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 40 deletions.
2 changes: 1 addition & 1 deletion app/Nova/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function fields(NovaRequest $request): array
Text::make('Title', 'title')->rules('required')->sortable(),

$this->editorField($request, 'Excerpt', 'excerpt')->nullable(),
$this->editorField($request, 'Body', 'body')->rules('required')->stacked(),
$this->editorField($request, 'Body', 'body')->rules('required')->stacked()->fullWidth(),

File::make('Attachment')
->nullable()
Expand Down
57 changes: 43 additions & 14 deletions tests/Browser/CreateWithInlineRelationButtonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Database\Factories\PostFactory;
use Database\Factories\ShipFactory;
use Laravel\Dusk\Browser;
use Laravel\Nova\Testing\Browser\Components\Controls\RelationSelectControlComponent;
use Laravel\Nova\Testing\Browser\Components\FormComponent;
use Laravel\Nova\Testing\Browser\Components\SearchInputComponent;
use Laravel\Nova\Testing\Browser\Pages\Attach;
Expand Down Expand Up @@ -92,17 +93,21 @@ public function test_morph_to_resource_can_be_created_with_attaching_file_to_par
$this->browse(function (Browser $browser) {
PostFactory::new()->create();

$browser->loginAs(1)
$browser->loginAs(4)
->visit(new Create('comments'))
->within(new FormComponent(), function ($browser) {
$browser->select('@commentable-type', 'posts')
->pause(500)
->runInlineCreate('commentable', function ($browser) {
$browser->waitForText('Create User Post')
->selectRelation('users', 1)
->type('@title', 'Test Post')
->type('@body', 'Test Post Body')
->attach('@attachment', __DIR__.'/Fixtures/Document.pdf');
->whenAvailable(new RelationSelectControlComponent('users'), function ($browser) {
$browser->assertSelected('', 4)
->select('', 1);
})
->whenAvailable('@attachment', function ($browser) {
$browser->attach('', __DIR__.'/Fixtures/Document.pdf');
});
});
})
->waitForText('The user post was created!')
Expand All @@ -117,6 +122,13 @@ public function test_morph_to_resource_can_be_created_with_attaching_file_to_par
$comment = Comment::with('commentable')->latest()->first();
$this->assertNull($comment->attachment);
$this->assertNotNull($comment->commentable->attachment);

$this->assertDatabaseHas('posts', [
'user_id' => 1,
'title' => 'Test Post',
'body' => 'Test Post Body',
'attachment' => $comment->commentable->attachment,
]);
});
}

Expand All @@ -127,16 +139,19 @@ public function test_morph_to_resource_can_be_created_with_attaching_file_to_chi
$this->browse(function (Browser $browser) {
PostFactory::new()->create();

$browser->loginAs(1)
$browser->loginAs(4)
->visit(new Create('comments'))
->within(new FormComponent(), function ($browser) {
$browser->select('@commentable-type', 'posts')
->pause(500)
->runInlineCreate('commentable', function ($browser) {
$browser->waitForText('Create User Post')
->selectRelation('users', 1)
->type('@title', 'Test Post')
->type('@body', 'Test Post Body');
->type('@body', 'Test Post Body')
->whenAvailable(new RelationSelectControlComponent('users'), function ($browser) {
$browser->assertSelected('', 4)
->select('', 1);
});
});
})
->waitForText('The user post was created!')
Expand All @@ -152,6 +167,13 @@ public function test_morph_to_resource_can_be_created_with_attaching_file_to_chi
$comment = Comment::with('commentable')->latest()->first();
$this->assertNotNull($comment->attachment);
$this->assertNull($comment->commentable->attachment);

$this->assertDatabaseHas('posts', [
'user_id' => 1,
'title' => 'Test Post',
'body' => 'Test Post Body',
'attachment' => null,
]);
});
}

Expand All @@ -166,13 +188,13 @@ public function test_searchable_morph_to_resource_can_be_cancelled_and_use_diffe
->visit(new Create('comments'))
->within(new FormComponent(), function ($browser) {
$browser->select('@commentable-type', 'posts')
->pause(500)
->runInlineCreate('commentable', function ($browser) {
$browser->waitForText('Create User Post')
->type('@title', 'Test Post')
->type('@body', 'Test Post Body')
->searchFirstRelation('users', 1);
});
->pause(500)
->runInlineCreate('commentable', function ($browser) {
$browser->waitForText('Create User Post')
->type('@title', 'Test Post')
->type('@body', 'Test Post Body')
->searchFirstRelation('users', 1);
});
})
->waitForText('The user post was created!')
->within(new FormComponent(), function ($browser) use ($post) {
Expand All @@ -185,6 +207,13 @@ public function test_searchable_morph_to_resource_can_be_cancelled_and_use_diffe
->click('@cancel-create-button');

$browser->blank();

$this->assertDatabaseHas('posts', [
'user_id' => 1,
'title' => 'Test Post',
'body' => 'Test Post Body',
'attachment' => null,
]);
});
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Browser/DateFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function test_it_can_clear_the_date_field_value()
$this->browse(function (Browser $browser) use ($person) {
$browser->loginAs(1)
->visit(new Update('people', $person->getKey()))
->type('@date_of_birth', '')
->typeOnDate('@date_of_birth', '')
->update()
->waitForText('The person was updated!');

Expand Down
2 changes: 1 addition & 1 deletion tests/Browser/DateTimeFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function test_can_reset_datetime_input()

$browser->loginAs(1)
->visit(new Update('ships', $ship->id))
->type('@departed_at', '')
->typeOnDate('@departed_at', '')
->update()
->waitForText('The ship was updated!');

Expand Down
28 changes: 28 additions & 0 deletions tests/Browser/DependentBelongsToManyFieldTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Laravel\Nova\Tests\Browser;

use Laravel\Dusk\Browser;
use Laravel\Nova\Testing\Browser\Components\Controls\RelationSelectControlComponent;
use Laravel\Nova\Testing\Browser\Components\FormComponent;
use Laravel\Nova\Testing\Browser\Pages\Attach;
use Laravel\Nova\Tests\DuskTestCase;

class DependentBelongsToManyFieldTest extends DuskTestCase
{
public function test_it_can_listen_to_related_field_changes()
{
$this->browse(function (Browser $browser) {
$browser->loginAs(1)
->visit(new Attach('users', 1, 'books', 'personalBooks'))
->within(new FormComponent(), function ($browser) {
$browser->assertSee('Attach Book')
->assertSeeIn('p.help-text', 'Price starts from $0-$99')
->within(new RelationSelectControlComponent('attachable'), function ($browser) {
$browser->select('', 1);
})->pause(500)
->assertSeeIn('p.help-text', 'Price starts from $10-$199');
});
});
}
}
10 changes: 5 additions & 5 deletions tests/Browser/DependentBooleanGroupFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ public function test_it_can_apply_value_from_field_dependencies()
$browser->whenAvailable('input[type="checkbox"][name="selected"]', function ($browser) {
$browser->assertNotChecked('');
})
->whenAvailable('input[type="checkbox"][id="boolean-default-boolean-field"]', function ($browser) {
$browser->check('')->pause(2000);
})
->assertChecked('input[type="checkbox"][name="selected"]')
->assertChecked('input[type="checkbox"][id="boolean-default-boolean-field"]');
->whenAvailable('input[type="checkbox"][id="boolean-default-boolean-field"]', function ($browser) {
$browser->check('')->pause(2000);
})
->assertChecked('input[type="checkbox"][name="selected"]')
->assertChecked('input[type="checkbox"][id="boolean-default-boolean-field"]');
});
});

Expand Down
36 changes: 18 additions & 18 deletions tests/Browser/DependentFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,24 +203,24 @@ public function test_it_can_apply_cascading_depends_on_changes()
->within(new IndexComponent('captains'), function ($browser) {
$browser->runStandaloneAction('fields-action', function ($browser) {
$browser->waitFor('@select_1')
->assertMissing('@select_2')
->assertMissing('@select_3')
->select('@select_1', 'show')
->waitFor('@select_2')
->assertMissing('@select_3')
->select('@select_2', 'show')
->waitFor('@select_3')
->select('@select_3', 'show')
->select('@select_1', 'hide')
->pause(1000)
->assertMissing('@select_2')
->assertMissing('@select_3')
->select('@select_1', 'show')
->pause(1000)
->assertVisible('@select_2')
->assertSelected('@select_2', 'show')
->assertVisible('@select_3')
->assertSelected('@select_3', 'show');
->assertMissing('@select_2')
->assertMissing('@select_3')
->select('@select_1', 'show')
->waitFor('@select_2')
->assertMissing('@select_3')
->select('@select_2', 'show')
->waitFor('@select_3')
->select('@select_3', 'show')
->select('@select_1', 'hide')
->pause(1000)
->assertMissing('@select_2')
->assertMissing('@select_3')
->select('@select_1', 'show')
->pause(1000)
->assertVisible('@select_2')
->assertSelected('@select_2', 'show')
->assertVisible('@select_3')
->assertSelected('@select_3', 'show');
});
});

Expand Down

0 comments on commit 540e1da

Please sign in to comment.