diff --git a/tests/Browser/ClientPortalTest.php b/tests/Browser/ClientPortalTest.php new file mode 100644 index 000000000000..701cbef6159b --- /dev/null +++ b/tests/Browser/ClientPortalTest.php @@ -0,0 +1,102 @@ +browse(function ($browser){ + $browser->visit('/client/login') + ->assertPathIs('/client/login'); + }); + + } + + /** + * A valid user can be logged in. + * + * @return void + */ + public function testLoginAValidUser() + { + \Eloquent::unguard(); + + $faker = \Faker\Factory::create(); + + $account = factory(\App\Models\Account::class)->create(); + $company = factory(\App\Models\Company::class)->create([ + 'account_id' => $account->id, + 'domain' => 'ninja.test', + ]); + + $account->default_company_id = $company->id; + $account->save(); + + $user = factory(\App\Models\User::class)->create([ + 'email' => $faker->email, + // 'account_id' => $account->id, + 'confirmation_code' => $this->createDbHash(config('database.default')) + ]); + + $company_token = \App\Models\CompanyToken::create([ + 'user_id' => $user->id, + 'company_id' => $company->id, + 'account_id' => $account->id, + 'name' => 'test token', + 'token' => str_random(64), + ]); + + $user->companies()->attach($company->id, [ + 'account_id' => $account->id, + 'is_owner' => 1, + 'is_admin' => 1, + 'is_locked' => 0, + 'permissions' => json_encode([]), + 'settings' => json_encode(DefaultSettings::userSettings()), + ]); + + $client = factory(\App\Models\Client::class)->create([ + 'user_id' => $user->id, + 'company_id' => $company->id + ]); + + + $contact = new ClientContact; + $contact->first_name = $faker->firstName; + $contact->last_name = $faker->lastName; + $contact->email = $faker->email; + $contact->company_id = $company->id; + $contact->password = Hash::make(config('ninja.testvars.password')); + $contact->email_verified_at = now(); + $contact->client_id = $client->id; + $contact->save(); + + + $this->browse(function ($browser) use ($contact) { + $browser->visit('/client/login') + ->type('email', $contact->email) + ->type('password', config('ninja.testvars.password')) + ->press('Login') + ->assertPathIs('/client/dashboard'); + }); + + + } + +} diff --git a/tests/Browser/CreateAccountTest.php b/tests/Browser/CreateAccountTest.php index a530f3b623ae..c623e20cfdae 100644 --- a/tests/Browser/CreateAccountTest.php +++ b/tests/Browser/CreateAccountTest.php @@ -13,32 +13,10 @@ class CreateAccountTest extends DuskTestCase use WithFaker; - public function testSignupFormDisplayed() { $response = $this->get('/signup'); $response->assertStatus(200); } - /** - * A valid user can be logged in. - * - * @return void - - public function testCreateAValidUser() - { - $this->browse(function (Browser $browser) { - $browser->visit('/signup') - ->type('first_name',$this->faker->firstName()) - ->type('last_name', $this->faker->lastName()) - ->type('email', $this->faker->email()) - ->type('password', $this->faker->password(7)) - ->check('terms_of_service') - ->check('privacy_policy') - ->press(trans('texts.create_account')) - ->assertPathIs('/dashboard'); - }); - - } - */ } diff --git a/tests/Browser/ExampleTest.php b/tests/Browser/ExampleTest.php deleted file mode 100644 index 9c21a4da7977..000000000000 --- a/tests/Browser/ExampleTest.php +++ /dev/null @@ -1,23 +0,0 @@ -browse(function (Browser $browser) { - $browser->visit('/') - ->assertSee('Account'); - }); - } -} diff --git a/tests/Integration/MultiDBUserTest.php b/tests/Integration/MultiDBUserTest.php index d64c694aeb29..01e0ca293527 100644 --- a/tests/Integration/MultiDBUserTest.php +++ b/tests/Integration/MultiDBUserTest.php @@ -34,24 +34,24 @@ class MultiDBUserTest extends TestCase $ac = factory(\App\Models\Account::class)->make(); + $ac->setHidden(['hashed_id']); + $account = Account::on('db-ninja-01')->create($ac->toArray()); $account2 = Account::on('db-ninja-02')->create($ac->toArray()); $company = factory(\App\Models\Company::class)->make([ 'account_id' => $account->id, - 'domain' => 'ninja.test', - + 'domain' => 'ninja.test', ]); $company2 = factory(\App\Models\Company::class)->make([ 'account_id' => $account2->id, - 'domain' => 'ninja.test', - + 'domain' => 'ninja.test', ]); - $company->setHidden(['settings', 'settings_object']); - $company2->setHidden(['settings', 'settings_object']); + $company->setHidden(['settings', 'settings_object', 'hashed_id']); + $company2->setHidden(['settings', 'settings_object', 'hashed_id']); Company::on('db-ninja-01')->create($company->toArray()); Company::on('db-ninja-02')->create($company2->toArray()); diff --git a/tests/Integration/UniqueEmailTest.php b/tests/Integration/UniqueEmailTest.php index e306cc6fc43f..e7691032f5d5 100644 --- a/tests/Integration/UniqueEmailTest.php +++ b/tests/Integration/UniqueEmailTest.php @@ -34,14 +34,14 @@ class UniqueEmailTest extends TestCase $ac = factory(\App\Models\Account::class)->make(); + $ac->setHidden(['hashed_id']); + $account = Account::on('db-ninja-01')->create($ac->toArray()); $account2 = Account::on('db-ninja-02')->create($ac->toArray()); $company = factory(\App\Models\Company::class)->make([ 'account_id' => $account->id, - 'domain' => 'ninja.test', - - + 'domain' => 'ninja.test', ]); $company2 = factory(\App\Models\Company::class)->make([ @@ -50,8 +50,8 @@ class UniqueEmailTest extends TestCase ]); - $company->setHidden(['settings', 'settings_object']); - $company2->setHidden(['settings', 'settings_object']); + $company->setHidden(['settings', 'settings_object', 'hashed_id']); + $company2->setHidden(['settings', 'settings_object', 'hashed_id']); Company::on('db-ninja-01')->create($company->toArray()); Company::on('db-ninja-02')->create($company2->toArray());