Skip to content

Commit 8d78d07

Browse files
committed
wip
Signed-off-by: Mior Muhammad Zaki <[email protected]>
1 parent 17100c7 commit 8d78d07

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

tests/Browser/RegisterUserTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
use App\Models\User;
4+
35
test('it can show the register page', function () {
46
visit('/register')
57
->assertNoConsoleLogs()
@@ -19,3 +21,32 @@
1921

2022
$this->assertAuthenticated();
2123
});
24+
25+
test('it cannot register a new user when email has already been taken', function () {
26+
User::factory()->create([
27+
'name' => 'Taylor',
28+
'email' => '[email protected]',
29+
]);
30+
31+
visit('/register')
32+
->fill('name', 'Taylor Otwell')
33+
->fill('email', '[email protected]')
34+
->fill('password', 'password')
35+
->fill('password_confirmation', 'password')
36+
->press('Create account')
37+
->assertSee('The email has already been taken.');
38+
39+
$this->assertGuest();
40+
});
41+
42+
test('it cannot register a new user when password does not match', function () {
43+
visit('/register')
44+
->fill('name', 'Taylor Otwell')
45+
->fill('email', '[email protected]')
46+
->fill('password', 'password')
47+
->fill('password_confirmation', 'secret')
48+
->press('Create account')
49+
->assertSee('The password field confirmation does not match.');
50+
51+
$this->assertGuest();
52+
});

tests/Browser/WelcomeTest.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,22 @@
99
->assertSee('Register');
1010
});
1111

12-
1312
test('it can browse to the register page', function () {
1413
visit('/')
15-
->assertNoConsoleLogs()
16-
->assertNoJavaScriptErrors()
1714
->click('Register')
1815
->assertPathEndsWith('/register')
1916
->assertNoConsoleLogs()
2017
->assertNoJavaScriptErrors()
2118
->assertSee('Create an account')
2219
->assertSee('Enter your details below to create your account');
2320
});
21+
22+
test('it can browse to the login page', function () {
23+
visit('/')
24+
->click('Log in')
25+
->assertPathEndsWith('/login')
26+
->assertNoConsoleLogs()
27+
->assertNoJavaScriptErrors()
28+
->assertSee('Log in to your account')
29+
->assertSee('Enter your email and password below to log in');
30+
});

0 commit comments

Comments
 (0)