Skip to content

Instantly share code, notes, and snippets.

@Tmeister
Created September 8, 2021 00:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tmeister/4533ac45920f0a11d8764900cf9a8ab1 to your computer and use it in GitHub Desktop.
Save Tmeister/4533ac45920f0a11d8764900cf9a8ab1 to your computer and use it in GitHub Desktop.
<?php
test('a register user should see the onboarding page and update the data', function () {
$user = User::create([
'uuid' => Str::random(12),
'firstname' => 'John',
'lastname' => 'Doe',
'email' => 'john@doe.com',
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
]);
actingAs($user)->get(route('dashboard'))->assertInertia(function (Assert $page) {
$page->component('Onboarding/Index');
});
// Update Location
$location = [
'country_id' => 233,
'state_id' => 1416,
'city_id' => 120784,
'zip' => '90210',
];
actingAs($user)->post('/update-user-location', $location)->assertStatus(200);
// Refresh User with new data
$user = $user->fresh();
expect($user->country->iso2)->toBe('US');
expect($user->state->name)->toBe('California');
expect($user->city->name)->toBe('Los Angeles');
expect($user->zip)->toBe('90210');
// Update Personal Data
$personal = [
'phone' => '5566778899',
'profile_url' => 'https://some.com',
'brief' => 'Hello World!',
];
actingAs($user)->post('/update-user-info', $personal)->assertStatus(200);
// Refresh User with new data
$user = $user->fresh();
expect($user->phone)->toBe('5566778899');
expect($user->profile_url)->toBe('https://some.com');
expect($user->brief)->toBe('Hello World!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment