Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/Reseller/InvitationsTest.php
Show All 39 Lines | class InvitationsTest extends TestCaseDusk | ||||
* Test Invitations creation | * Test Invitations creation | ||||
*/ | */ | ||||
public function testInvitationCreate(): void | public function testInvitationCreate(): void | ||||
{ | { | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$date_regexp = '/^20[0-9]{2}-/'; | $date_regexp = '/^20[0-9]{2}-/'; | ||||
$browser->visit(new Home()) | $browser->visit(new Home()) | ||||
->submitLogon('reseller@kolabnow.com', 'reseller', true) | ->submitLogon('reseller@' . \config('app.domain'), \App\Utils::generatePassphrase(), true) | ||||
->on(new Dashboard()) | ->on(new Dashboard()) | ||||
->assertSeeIn('@links .link-invitations', 'Invitations') | ->assertSeeIn('@links .link-invitations', 'Invitations') | ||||
->click('@links .link-invitations') | ->click('@links .link-invitations') | ||||
->on(new Invitations()) | ->on(new Invitations()) | ||||
->assertElementsCount('@table tbody tr', 0) | ->assertElementsCount('@table tbody tr', 0) | ||||
->assertMissing('#more-loader') | ->assertMissing('#more-loader') | ||||
->assertSeeIn('@table tfoot td', "There are no invitations in the database.") | ->assertSeeIn('@table tfoot td', "There are no invitations in the database.") | ||||
->assertSeeIn('@create-button', 'Create invite(s)'); | ->assertSeeIn('@create-button', 'Create invite(s)'); | ||||
▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | public function testInvitationDeleteAndResend(): void | ||||
Queue::fake(); | Queue::fake(); | ||||
$i1 = SignupInvitation::create(['email' => 'test1@domain.org']); | $i1 = SignupInvitation::create(['email' => 'test1@domain.org']); | ||||
$i2 = SignupInvitation::create(['email' => 'test2@domain.org']); | $i2 = SignupInvitation::create(['email' => 'test2@domain.org']); | ||||
SignupInvitation::where('id', $i2->id) | SignupInvitation::where('id', $i2->id) | ||||
->update(['created_at' => now()->subHours('2'), 'status' => SignupInvitation::STATUS_FAILED]); | ->update(['created_at' => now()->subHours('2'), 'status' => SignupInvitation::STATUS_FAILED]); | ||||
// Test deleting | // Test deleting | ||||
$browser->visit(new Invitations()) | $browser->visit(new Invitations()) | ||||
// ->submitLogon('reseller@kolabnow.com', 'reseller', true) | // ->submitLogon('reseller@' . \config('app.domain'), \App\Utils::generatePassphrase(), true) | ||||
->assertElementsCount('@table tbody tr', 2) | ->assertElementsCount('@table tbody tr', 2) | ||||
->click('@table tbody tr:first-child button.button-delete') | ->click('@table tbody tr:first-child button.button-delete') | ||||
->assertToast(Toast::TYPE_SUCCESS, "Invitation deleted successfully.") | ->assertToast(Toast::TYPE_SUCCESS, "Invitation deleted successfully.") | ||||
->assertElementsCount('@table tbody tr', 1); | ->assertElementsCount('@table tbody tr', 1); | ||||
// Test resending | // Test resending | ||||
$browser->click('@table tbody tr:first-child button.button-resend') | $browser->click('@table tbody tr:first-child button.button-resend') | ||||
->assertToast(Toast::TYPE_SUCCESS, "Invitation added to the sending queue successfully.") | ->assertToast(Toast::TYPE_SUCCESS, "Invitation added to the sending queue successfully.") | ||||
Show All 26 Lines | public function testInvitationsList(): void | ||||
SignupInvitation::where('id', $i2->id) | SignupInvitation::where('id', $i2->id) | ||||
->update(['created_at' => now()->subHours('3'), 'status' => SignupInvitation::STATUS_SENT]); | ->update(['created_at' => now()->subHours('3'), 'status' => SignupInvitation::STATUS_SENT]); | ||||
SignupInvitation::where('id', $i3->id) | SignupInvitation::where('id', $i3->id) | ||||
->update(['created_at' => now()->subHours('4'), 'status' => SignupInvitation::STATUS_COMPLETED]); | ->update(['created_at' => now()->subHours('4'), 'status' => SignupInvitation::STATUS_COMPLETED]); | ||||
SignupInvitation::where('id', $i11->id)->update(['created_at' => now()->subDays('3')]); | SignupInvitation::where('id', $i11->id)->update(['created_at' => now()->subDays('3')]); | ||||
// Test paging (load more) feature | // Test paging (load more) feature | ||||
$browser->visit(new Invitations()) | $browser->visit(new Invitations()) | ||||
// ->submitLogon('reseller@kolabnow.com', 'reseller', true) | // ->submitLogon('reseller@' . \config('app.domain'), \App\Utils::generatePassphrase(), true) | ||||
->assertElementsCount('@table tbody tr', 10) | ->assertElementsCount('@table tbody tr', 10) | ||||
->assertSeeIn('#more-loader button', 'Load more') | ->assertSeeIn('#more-loader button', 'Load more') | ||||
->with('@table tbody', function ($browser) use ($i1, $i2, $i3) { | ->with('@table tbody', function ($browser) use ($i1, $i2, $i3) { | ||||
$browser->assertSeeIn('tr:nth-child(1) td.email', $i1->email) | $browser->assertSeeIn('tr:nth-child(1) td.email', $i1->email) | ||||
->assertText('tr:nth-child(1) td.email svg.text-danger title', 'Sending failed') | ->assertText('tr:nth-child(1) td.email svg.text-danger title', 'Sending failed') | ||||
->assertVisible('tr:nth-child(1) td.buttons button.button-delete') | ->assertVisible('tr:nth-child(1) td.buttons button.button-delete') | ||||
->assertVisible('tr:nth-child(1) td.buttons button.button-resend:not(:disabled)') | ->assertVisible('tr:nth-child(1) td.buttons button.button-resend:not(:disabled)') | ||||
->assertSeeIn('tr:nth-child(2) td.email', $i2->email) | ->assertSeeIn('tr:nth-child(2) td.email', $i2->email) | ||||
Show All 39 Lines |