Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
joshhanley committed May 14, 2024
1 parent 3ec17a5 commit b0a075a
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 114 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ on:
push:
branches:
- "**"
pull_request:
types: [ready_for_review, synchronize, opened]
# pull_request:
# types: [ready_for_review, synchronize, opened]

jobs:
tests-on-phpunit-9:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [8.1, 8.2, 8.3]
php: [8.1] #, 8.2, 8.3]
laravel: [10.*]

name: PHP:${{ matrix.php }} / Laravel:${{ matrix.laravel }}
Expand Down
222 changes: 111 additions & 111 deletions tests/Browser/AutocompleteDatabaseTest/AutocompleteDatabaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,132 +55,132 @@ public function dropdown_shows_list_of_results()
;
}

/** @test */
public function results_are_filtered_based_on_input()
{
Item::updateOrCreate(['id' => 1], ['name' => 'test1']);
Item::updateOrCreate(['id' => 2], ['name' => 'test2']);
Item::updateOrCreate(['id' => 3], ['name' => 'test3']);
Item::updateOrCreate(['id' => 4], ['name' => 'other1']);
Item::updateOrCreate(['id' => 5], ['name' => 'other2']);

Livewire::visit(DatabaseResultsAutocompleteComponent::class)
->click('@autocomplete-input')
->waitForLivewire()->type('@autocomplete-input', 'o')
->assertDontSeeIn('@autocomplete-dropdown', 'test1')
->assertDontSeeIn('@autocomplete-dropdown', 'test2')
->assertDontSeeIn('@autocomplete-dropdown', 'test3')
->assertSeeInOrder('@autocomplete-dropdown', [
'other1',
'other2',
])
;
}

/** @test */
public function ensure_results_count_gets_updated_so_focus_cant_go_off_the_end_of_results()
{
Item::updateOrCreate(['id' => 1], ['name' => 'test1']);
Item::updateOrCreate(['id' => 2], ['name' => 'test2']);
Item::updateOrCreate(['id' => 3], ['name' => 'test3']);
Item::updateOrCreate(['id' => 4], ['name' => 'other1']);
Item::updateOrCreate(['id' => 5], ['name' => 'other2']);
// /** @test */
// public function results_are_filtered_based_on_input()
// {
// Item::updateOrCreate(['id' => 1], ['name' => 'test1']);
// Item::updateOrCreate(['id' => 2], ['name' => 'test2']);
// Item::updateOrCreate(['id' => 3], ['name' => 'test3']);
// Item::updateOrCreate(['id' => 4], ['name' => 'other1']);
// Item::updateOrCreate(['id' => 5], ['name' => 'other2']);

Livewire::visit(DatabaseResultsAutocompleteComponent::class)
->click('@autocomplete-input')
->keys('@autocomplete-input', '{ARROW_DOWN}')
->waitForLivewire()->type('@autocomplete-input', 'o')
->assertSeeInOrder('@autocomplete-dropdown', [
'other1',
'other2',
])
->keys('@autocomplete-input', '{ARROW_DOWN}')
->keys('@autocomplete-input', '{ARROW_DOWN}')
->assertHasClass('@result-1', 'bg-blue-500')
->keys('@autocomplete-input', '{ARROW_DOWN}')
->assertHasClass('@result-1', 'bg-blue-500')
;
}
// Livewire::visit(DatabaseResultsAutocompleteComponent::class)
// ->click('@autocomplete-input')
// ->waitForLivewire()->type('@autocomplete-input', 'o')
// ->assertDontSeeIn('@autocomplete-dropdown', 'test1')
// ->assertDontSeeIn('@autocomplete-dropdown', 'test2')
// ->assertDontSeeIn('@autocomplete-dropdown', 'test3')
// ->assertSeeInOrder('@autocomplete-dropdown', [
// 'other1',
// 'other2',
// ])
// ;
// }

// /** @test */
// public function results_dropdown_is_not_shown_if_there_are_no_results_found()
// public function ensure_results_count_gets_updated_so_focus_cant_go_off_the_end_of_results()
// {
// Item::updateOrCreate(['id' => 1], ['name' => 'test1']);
// Item::updateOrCreate(['id' => 2], ['name' => 'test2']);
// Item::updateOrCreate(['id' => 3], ['name' => 'test3']);
// Item::updateOrCreate(['id' => 4], ['name' => 'other1']);
// Item::updateOrCreate(['id' => 5], ['name' => 'other2']);

// $this->browse(function (Browser $browser) {
// Livewire::visit(DatabaseResultsAutocompleteComponent::class)
// ->assertMissing('@autocomplete-dropdown')
// ->click('@autocomplete-input')
// ->waitForLivewire()->type('@autocomplete-input', 'o')
// ->assertSeeInOrder('@autocomplete-dropdown', [
// 'other1',
// 'other2',
// ])
// ->assertVisible('@autocomplete-dropdown')
// ->waitForLivewire()->type('@autocomplete-input', 'a')
// // Pause to allow transitions to run
// ->pause(101)
// ->assertMissing('@autocomplete-dropdown')
// ;
// });
// Livewire::visit(DatabaseResultsAutocompleteComponent::class)
// ->click('@autocomplete-input')
// ->keys('@autocomplete-input', '{ARROW_DOWN}')
// ->waitForLivewire()->type('@autocomplete-input', 'o')
// ->assertSeeInOrder('@autocomplete-dropdown', [
// 'other1',
// 'other2',
// ])
// ->keys('@autocomplete-input', '{ARROW_DOWN}')
// ->keys('@autocomplete-input', '{ARROW_DOWN}')
// ->assertHasClass('@result-1', 'bg-blue-500')
// ->keys('@autocomplete-input', '{ARROW_DOWN}')
// ->assertHasClass('@result-1', 'bg-blue-500')
// ;
// }

/** @test */
public function selected_item_can_be_cleared()
{
Item::updateOrCreate(['id' => 1], ['name' => 'test1']);
Item::updateOrCreate(['id' => 2], ['name' => 'test2']);
Item::updateOrCreate(['id' => 3], ['name' => 'test3']);
Item::updateOrCreate(['id' => 4], ['name' => 'other1']);
Item::updateOrCreate(['id' => 5], ['name' => 'other2']);
// // /** @test */
// // public function results_dropdown_is_not_shown_if_there_are_no_results_found()
// // {
// // Item::updateOrCreate(['id' => 1], ['name' => 'test1']);
// // Item::updateOrCreate(['id' => 2], ['name' => 'test2']);
// // Item::updateOrCreate(['id' => 3], ['name' => 'test3']);
// // Item::updateOrCreate(['id' => 4], ['name' => 'other1']);
// // Item::updateOrCreate(['id' => 5], ['name' => 'other2']);

// // $this->browse(function (Browser $browser) {
// // Livewire::visit(DatabaseResultsAutocompleteComponent::class)
// // ->assertMissing('@autocomplete-dropdown')
// // ->click('@autocomplete-input')
// // ->waitForLivewire()->type('@autocomplete-input', 'o')
// // ->assertSeeInOrder('@autocomplete-dropdown', [
// // 'other1',
// // 'other2',
// // ])
// // ->assertVisible('@autocomplete-dropdown')
// // ->waitForLivewire()->type('@autocomplete-input', 'a')
// // // Pause to allow transitions to run
// // ->pause(101)
// // ->assertMissing('@autocomplete-dropdown')
// // ;
// // });
// // }

Livewire::visit(DatabaseResultsAutocompleteComponent::class)
->click('@autocomplete-input')
->waitForLivewire()->click('@result-1')
->assertValue('@autocomplete-input', 'test2')
->assertSeeIn('@result-output', 'ID:2')
->waitForLivewire()->click('@clear')
->assertValue('@autocomplete-input', '')
->assertSeeNothingIn('@result-output')
;
}
// /** @test */
// public function selected_item_can_be_cleared()
// {
// Item::updateOrCreate(['id' => 1], ['name' => 'test1']);
// Item::updateOrCreate(['id' => 2], ['name' => 'test2']);
// Item::updateOrCreate(['id' => 3], ['name' => 'test3']);
// Item::updateOrCreate(['id' => 4], ['name' => 'other1']);
// Item::updateOrCreate(['id' => 5], ['name' => 'other2']);

/** @test */
public function clear_button_cant_be_pressed_if_nothing_selected()
{
Item::updateOrCreate(['id' => 1], ['name' => 'test1']);
Item::updateOrCreate(['id' => 2], ['name' => 'test2']);
Item::updateOrCreate(['id' => 3], ['name' => 'test3']);
Item::updateOrCreate(['id' => 4], ['name' => 'other1']);
Item::updateOrCreate(['id' => 5], ['name' => 'other2']);
// Livewire::visit(DatabaseResultsAutocompleteComponent::class)
// ->click('@autocomplete-input')
// ->waitForLivewire()->click('@result-1')
// ->assertValue('@autocomplete-input', 'test2')
// ->assertSeeIn('@result-output', 'ID:2')
// ->waitForLivewire()->click('@clear')
// ->assertValue('@autocomplete-input', '')
// ->assertSeeNothingIn('@result-output')
// ;
// }

Livewire::visit(DatabaseResultsAutocompleteComponent::class)
->click('@autocomplete-input')
->assertMissing('@clear')
// ->waitForLivewire()->click('@clear')
;
}
// /** @test */
// public function clear_button_cant_be_pressed_if_nothing_selected()
// {
// Item::updateOrCreate(['id' => 1], ['name' => 'test1']);
// Item::updateOrCreate(['id' => 2], ['name' => 'test2']);
// Item::updateOrCreate(['id' => 3], ['name' => 'test3']);
// Item::updateOrCreate(['id' => 4], ['name' => 'other1']);
// Item::updateOrCreate(['id' => 5], ['name' => 'other2']);

/** @test */
public function input_cannot_be_focused_when_item_is_selected()
{
Item::updateOrCreate(['id' => 1], ['name' => 'test1']);
Item::updateOrCreate(['id' => 2], ['name' => 'test2']);
Item::updateOrCreate(['id' => 3], ['name' => 'test3']);
Item::updateOrCreate(['id' => 4], ['name' => 'other1']);
Item::updateOrCreate(['id' => 5], ['name' => 'other2']);
// Livewire::visit(DatabaseResultsAutocompleteComponent::class)
// ->click('@autocomplete-input')
// ->assertMissing('@clear')
// // ->waitForLivewire()->click('@clear')
// ;
// }

Livewire::visit(DatabaseResultsAutocompleteComponent::class)
->click('@autocomplete-input')
->waitForLivewire()->click('@result-1')
->assertValue('@autocomplete-input', 'test2')
->assertNotFocused('@autocomplete-input')
->click('@autocomplete-input')
->assertNotFocused('@autocomplete-input')
;
}
// /** @test */
// public function input_cannot_be_focused_when_item_is_selected()
// {
// Item::updateOrCreate(['id' => 1], ['name' => 'test1']);
// Item::updateOrCreate(['id' => 2], ['name' => 'test2']);
// Item::updateOrCreate(['id' => 3], ['name' => 'test3']);
// Item::updateOrCreate(['id' => 4], ['name' => 'other1']);
// Item::updateOrCreate(['id' => 5], ['name' => 'other2']);

// Livewire::visit(DatabaseResultsAutocompleteComponent::class)
// ->click('@autocomplete-input')
// ->waitForLivewire()->click('@result-1')
// ->assertValue('@autocomplete-input', 'test2')
// ->assertNotFocused('@autocomplete-input')
// ->click('@autocomplete-input')
// ->assertNotFocused('@autocomplete-input')
// ;
// }
}

0 comments on commit b0a075a

Please sign in to comment.