dishplanner/tests/Browser/Users/CreateUserTest.php

43 lines
1.2 KiB
PHP

<?php
it('can access the users page', function () {
loginAndGoToUsers()
->assertSee('MANAGE USERS')
->assertSee('Add User');
});
it('can open the create user modal', function () {
loginAndGoToUsers()
->click('button[wire\:click="create"]')
->assertSee('Add New User')
->assertSee('Name')
->assertSee('Cancel')
->assertSee('Create User');
});
it('validates the user name field', function () {
loginAndGoToUsers()
->click('button[wire\:click="create"]')
->press('Create User')
->assertSee('The name field is required');
});
it('can create a user', function () {
$userName = 'TestCreate_'.uniqid();
loginAndGoToUsers()
->click('button[wire\:click="create"]')
->type('input[wire\:model="name"]', $userName)
->press('Create User')
->assertSee('User created successfully')
->assertSee($userName);
});
it('can cancel user creation', function () {
loginAndGoToUsers()
->click('button[wire\:click="create"]')
->type('input[wire\:model="name"]', 'Test Cancel User')
->press('Cancel')
->assertSee('MANAGE USERS')
->assertDontSee('Add New User');
});