Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jwhulette committed Jun 1, 2024
1 parent 97de294 commit beb7d67
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 26 deletions.
22 changes: 11 additions & 11 deletions .env.dusk.local
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ APP_DEBUG=false

APP_URL=http://localhost:8000
DUSK_DRIVER=chrome
DUSK_HEADLESS_DISABLED=true
DUSK_HEADLESS_DISABLED=false

LOG_CHANNEL=stack

Expand All @@ -19,14 +19,14 @@ SESSION_DRIVER=file
SESSION_LIFETIME=120
SESSION_SECURE_COOKIE=true

PUHSER_HOST=
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1
REVERB_APP_ID=383604
REVERB_APP_KEY=nxwjzn6y1tmarsc7kmpu
REVERB_APP_SECRET=buik4yvca1kyo4gmkapq
REVERB_HOST="localhost"
REVERB_PORT=8080
REVERB_SCHEME=http

VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
MIX_USE_LOCAL=true
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
VITE_REVERB_APP_KEY="${REVERB_APP_KEY}"
VITE_REVERB_HOST="${REVERB_HOST}"
VITE_REVERB_PORT="${REVERB_PORT}"
VITE_REVERB_SCHEME="${REVERB_SCHEME}"
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,15 @@
"./vendor/bin/phpstan analyse --memory-limit=2G",
"./vendor/bin/phpunit"
],
"dusk": [
"@php artisan reverb:start --port=8082 > /dev/null 2>&1 &",
"@php artisan serve --env=dusk.local > /dev/null 2>&1 &",
"@php artisan dusk"
],
"ts": [
"./vendor/bin/phpstan analyse --memory-limit=2G",
"@php artisan test",
"@php artisan dusk"
"@dusk"
]
}
}
5 changes: 4 additions & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@

Route::post('/room', [RoomController::class, 'index'])->name('rooms_index');

Route::get('/room/{roomId}/', [RoomController::class, 'room'])->name('room');
Route::get('/{roomId}/room', [RoomController::class, 'room'])->name('room');
//Route::get('/{roomId}/room', fn () => redirect()->route('room', ['roomId' => $roomId]));

//Route::get('/room/{roomId}', [RoomController::class, 'room'])->name('room');

Route::put('/join', [PlayerController::class, 'store'])->name('join');

Expand Down
8 changes: 5 additions & 3 deletions tests/Browser/JoinRoomTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use Laravel\Dusk\Browser;
use Tests\DuskTestCase;

use function route;

/**
* @group join
*/
Expand Down Expand Up @@ -43,20 +45,20 @@ public function test_user_can_be_added_to_room(): void

$observer = $users->get(2);

$browser1->visit("room/$roomUuid")
$browser1->visit(route('room', ['roomId' => $roomUuid]))
->type('name', $userOne->name)
->press('Player')
->waitForText($userOne->name)
->assertSee($userOne->name);

$browser2->visit("room/$roomUuid")
$browser2->visit(route('room', ['roomId' => $roomUuid]))
->type('name', $userTwo->name)
->press('Player')
->waitForText($userTwo->name)
->assertSee($userOne->name)
->assertSee($userTwo->name);

$browser3->visit("room/$roomUuid")
$browser3->visit(route('room', ['roomId' => $roomUuid]))
->type('name', $observer->name)
->press('Observer')
->waitForText($observer->name)
Expand Down
14 changes: 8 additions & 6 deletions tests/Browser/VoteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use Laravel\Dusk\Browser;
use Tests\DuskTestCase;

use function route;

/**
* @group vote
*/
Expand Down Expand Up @@ -42,13 +44,13 @@ public function test_users_can_vote(): void
$userTwo = $users->get(1);

// userOne joins
$browser1->visit("$roomUuid/room")
$browser1->visit(route('room', ['roomId' => $roomUuid]))
->type('name', $userOne->name)
->press('Player')
->waitForText($userOne->name);

// userTwo joins
$browser2->visit("$roomUuid/room")
$browser2->visit(route('room', ['roomId' => $roomUuid]))
->type('name', $userTwo->name)
->press('Player')
->waitForText($userTwo->name);
Expand All @@ -62,7 +64,7 @@ public function test_users_can_vote(): void
->text('@avg-vote');

// if userOne was able to change their mind the average will be three
$this->assertEquals($text, '3.0');
$this->assertEquals('3.0', $text);
});
}

Expand All @@ -78,13 +80,13 @@ public function test_users_can_change_vote_before_reveal(): void
$userTwo = $users->get(1);

// userOne joins
$browser1->visit("$roomUuid/room")
$browser1->visit(route('room', ['roomId' => $roomUuid]))
->type('name', $userOne->name)
->press('Player')
->waitForText($userOne->name);

// userTwo joins
$browser2->visit("$roomUuid/room")
$browser2->visit(route('room', ['roomId' => $roomUuid]))
->type('name', $userTwo->name)
->press('Player')
->waitForText($userTwo->name);
Expand All @@ -101,7 +103,7 @@ public function test_users_can_change_vote_before_reveal(): void
->text('@avg-vote');

// if userOne was able to change their mind the average will be three
$this->assertEquals($text, '3.0');
$this->assertEquals('3.0', $text);
});
}
}
2 changes: 0 additions & 2 deletions tests/DuskTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ protected function driver(): RemoteWebDriver
return $items->merge([
'--disable-gpu',
'--headless=new',
'--remote-debugging-port=9222',
'--no-sandbox',
]);
})->all());

Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/RoomRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class RoomRequestTest extends TestCase
{
public static function validData(): array
{
$faker = Factory::create(Factory::DEFAULT_LOCALE);
$faker = Factory::create();

return [
[
Expand All @@ -33,7 +33,7 @@ public static function validData(): array

public static function inValidData(): array
{
$faker = Factory::create(Factory::DEFAULT_LOCALE);
$faker = Factory::create();

return [
[[]], // missing fields
Expand Down

0 comments on commit beb7d67

Please sign in to comment.