Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/DistlistTest.php
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | public function testList(): void | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$browser->visit('/distlists') | $browser->visit('/distlists') | ||||
->assertErrorPage(403); | ->assertErrorPage(403); | ||||
}); | }); | ||||
// Create a single group, add beta+distlist entitlements | // Create a single group, add beta+distlist entitlements | ||||
$john = $this->getTestUser('john@kolab.org'); | $john = $this->getTestUser('john@kolab.org'); | ||||
$this->addDistlistEntitlement($john); | $this->addDistlistEntitlement($john); | ||||
$group = $this->getTestGroup('group-test@kolab.org'); | $group = $this->getTestGroup('group-test@kolab.org', ['name' => 'Test Group']); | ||||
$group->assignToWallet($john->wallets->first()); | $group->assignToWallet($john->wallets->first()); | ||||
// Test distribution lists page | // Test distribution lists page | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$browser->visit(new Dashboard()) | $browser->visit(new Dashboard()) | ||||
->assertSeeIn('@links .link-distlists', 'Distribution lists') | ->assertSeeIn('@links .link-distlists', 'Distribution lists') | ||||
->click('@links .link-distlists') | ->click('@links .link-distlists') | ||||
->on(new DistlistList()) | ->on(new DistlistList()) | ||||
->whenAvailable('@table', function (Browser $browser) { | ->whenAvailable('@table', function (Browser $browser) { | ||||
$browser->waitFor('tbody tr') | $browser->waitFor('tbody tr') | ||||
->assertSeeIn('thead tr th:nth-child(1)', 'Name') | |||||
->assertSeeIn('thead tr th:nth-child(2)', 'Email') | |||||
->assertElementsCount('tbody tr', 1) | ->assertElementsCount('tbody tr', 1) | ||||
->assertSeeIn('tbody tr:nth-child(1) a', 'group-test@kolab.org') | ->assertSeeIn('tbody tr:nth-child(1) td:nth-child(1) a', 'Test Group') | ||||
->assertText('tbody tr:nth-child(1) svg.text-danger title', 'Not Ready') | ->assertText('tbody tr:nth-child(1) td:nth-child(1) svg.text-danger title', 'Not Ready') | ||||
->assertSeeIn('tbody tr:nth-child(1) td:nth-child(2) a', 'group-test@kolab.org') | |||||
->assertMissing('tfoot'); | ->assertMissing('tfoot'); | ||||
}); | }); | ||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* Test distlist creation/editing/deleting | * Test distlist creation/editing/deleting | ||||
* | * | ||||
Show All 18 Lines | public function testCreateUpdateDelete(): void | ||||
->click('button.create-list') | ->click('button.create-list') | ||||
->on(new DistlistInfo()) | ->on(new DistlistInfo()) | ||||
->assertSeeIn('#distlist-info .card-title', 'New distribution list') | ->assertSeeIn('#distlist-info .card-title', 'New distribution list') | ||||
->assertSeeIn('@nav #tab-general', 'General') | ->assertSeeIn('@nav #tab-general', 'General') | ||||
->assertMissing('@nav #tab-settings') | ->assertMissing('@nav #tab-settings') | ||||
->with('@general', function (Browser $browser) { | ->with('@general', function (Browser $browser) { | ||||
// Assert form content | // Assert form content | ||||
$browser->assertMissing('#status') | $browser->assertMissing('#status') | ||||
->assertSeeIn('div.row:nth-child(1) label', 'Email') | ->assertFocused('#name') | ||||
->assertSeeIn('div.row:nth-child(1) label', 'Name') | |||||
->assertValue('div.row:nth-child(1) input[type=text]', '') | ->assertValue('div.row:nth-child(1) input[type=text]', '') | ||||
->assertSeeIn('div.row:nth-child(2) label', 'Recipients') | ->assertSeeIn('div.row:nth-child(2) label', 'Email') | ||||
->assertVisible('div.row:nth-child(2) .list-input') | ->assertValue('div.row:nth-child(2) input[type=text]', '') | ||||
->assertSeeIn('div.row:nth-child(3) label', 'Recipients') | |||||
->assertVisible('div.row:nth-child(3) .list-input') | |||||
->with(new ListInput('#members'), function (Browser $browser) { | ->with(new ListInput('#members'), function (Browser $browser) { | ||||
$browser->assertListInputValue([]) | $browser->assertListInputValue([]) | ||||
->assertValue('@input', ''); | ->assertValue('@input', ''); | ||||
}) | }) | ||||
->assertSeeIn('button[type=submit]', 'Submit'); | ->assertSeeIn('button[type=submit]', 'Submit'); | ||||
}) | }) | ||||
// Test error conditions | // Test error conditions | ||||
->type('#name', str_repeat('A', 192)) | |||||
->type('#email', 'group-test@kolabnow.com') | ->type('#email', 'group-test@kolabnow.com') | ||||
->click('@general button[type=submit]') | ->click('@general button[type=submit]') | ||||
->waitFor('#email + .invalid-feedback') | |||||
->assertSeeIn('#email + .invalid-feedback', 'The specified domain is not available.') | |||||
->assertFocused('#email') | |||||
->waitFor('#members + .invalid-feedback') | ->waitFor('#members + .invalid-feedback') | ||||
->assertSeeIn('#email + .invalid-feedback', 'The specified domain is not available.') | |||||
->assertSeeIn('#name + .invalid-feedback', 'The name may not be greater than 191 characters.') | |||||
->assertSeeIn('#members + .invalid-feedback', 'At least one recipient is required.') | ->assertSeeIn('#members + .invalid-feedback', 'At least one recipient is required.') | ||||
->assertFocused('#name') | |||||
->assertToast(Toast::TYPE_ERROR, 'Form validation error') | ->assertToast(Toast::TYPE_ERROR, 'Form validation error') | ||||
// Test successful group creation | // Test successful group creation | ||||
->type('#name', 'Test Group') | |||||
->type('#email', 'group-test@kolab.org') | ->type('#email', 'group-test@kolab.org') | ||||
->with(new ListInput('#members'), function (Browser $browser) { | ->with(new ListInput('#members'), function (Browser $browser) { | ||||
$browser->addListEntry('test1@gmail.com') | $browser->addListEntry('test1@gmail.com') | ||||
->addListEntry('test2@gmail.com'); | ->addListEntry('test2@gmail.com'); | ||||
}) | }) | ||||
->click('@general button[type=submit]') | ->click('@general button[type=submit]') | ||||
->assertToast(Toast::TYPE_SUCCESS, 'Distribution list created successfully.') | ->assertToast(Toast::TYPE_SUCCESS, 'Distribution list created successfully.') | ||||
->on(new DistlistList()) | ->on(new DistlistList()) | ||||
->assertElementsCount('@table tbody tr', 1); | ->assertElementsCount('@table tbody tr', 1); | ||||
// Test group update | // Test group update | ||||
$browser->click('@table tr:nth-child(1) a') | $browser->click('@table tr:nth-child(1) td:first-child a') | ||||
->on(new DistlistInfo()) | ->on(new DistlistInfo()) | ||||
->assertSeeIn('#distlist-info .card-title', 'Distribution list') | ->assertSeeIn('#distlist-info .card-title', 'Distribution list') | ||||
->with('@general', function (Browser $browser) { | ->with('@general', function (Browser $browser) { | ||||
// Assert form content | // Assert form content | ||||
$browser->assertSeeIn('div.row:nth-child(1) label', 'Status') | $browser->assertFocused('#name') | ||||
->assertSeeIn('div.row:nth-child(1) label', 'Status') | |||||
->assertSeeIn('div.row:nth-child(1) span.text-danger', 'Not Ready') | ->assertSeeIn('div.row:nth-child(1) span.text-danger', 'Not Ready') | ||||
->assertSeeIn('div.row:nth-child(2) label', 'Email') | ->assertSeeIn('div.row:nth-child(2) label', 'Name') | ||||
->assertValue('div.row:nth-child(2) input[type=text]:disabled', 'group-test@kolab.org') | ->assertValue('div.row:nth-child(2) input[type=text]', 'Test Group') | ||||
->assertSeeIn('div.row:nth-child(3) label', 'Recipients') | ->assertSeeIn('div.row:nth-child(3) label', 'Email') | ||||
->assertVisible('div.row:nth-child(3) .list-input') | ->assertValue('div.row:nth-child(3) input[type=text]:disabled', 'group-test@kolab.org') | ||||
->assertSeeIn('div.row:nth-child(4) label', 'Recipients') | |||||
->assertVisible('div.row:nth-child(4) .list-input') | |||||
->with(new ListInput('#members'), function (Browser $browser) { | ->with(new ListInput('#members'), function (Browser $browser) { | ||||
$browser->assertListInputValue(['test1@gmail.com', 'test2@gmail.com']) | $browser->assertListInputValue(['test1@gmail.com', 'test2@gmail.com']) | ||||
->assertValue('@input', ''); | ->assertValue('@input', ''); | ||||
}) | }) | ||||
->assertSeeIn('button[type=submit]', 'Submit'); | ->assertSeeIn('button[type=submit]', 'Submit'); | ||||
}) | }) | ||||
// Test error handling | // Test error handling | ||||
->with(new ListInput('#members'), function (Browser $browser) { | ->with(new ListInput('#members'), function (Browser $browser) { | ||||
Show All 13 Lines | public function testCreateUpdateDelete(): void | ||||
->assertMissing('.invalid-feedback') | ->assertMissing('.invalid-feedback') | ||||
->on(new DistlistList()) | ->on(new DistlistList()) | ||||
->assertElementsCount('@table tbody tr', 1); | ->assertElementsCount('@table tbody tr', 1); | ||||
$group = Group::where('email', 'group-test@kolab.org')->first(); | $group = Group::where('email', 'group-test@kolab.org')->first(); | ||||
$this->assertSame(['test1@gmail.com'], $group->members); | $this->assertSame(['test1@gmail.com'], $group->members); | ||||
// Test group deletion | // Test group deletion | ||||
$browser->click('@table tr:nth-child(1) a') | $browser->click('@table tr:nth-child(1) td:first-child a') | ||||
->on(new DistlistInfo()) | ->on(new DistlistInfo()) | ||||
->assertSeeIn('button.button-delete', 'Delete list') | ->assertSeeIn('button.button-delete', 'Delete list') | ||||
->click('button.button-delete') | ->click('button.button-delete') | ||||
->assertToast(Toast::TYPE_SUCCESS, 'Distribution list deleted successfully.') | ->assertToast(Toast::TYPE_SUCCESS, 'Distribution list deleted successfully.') | ||||
->on(new DistlistList()) | ->on(new DistlistList()) | ||||
->assertElementsCount('@table tbody tr', 0) | ->assertElementsCount('@table tbody tr', 0) | ||||
->assertVisible('@table tfoot'); | ->assertVisible('@table tfoot'); | ||||
▲ Show 20 Lines • Show All 103 Lines • Show Last 20 Lines |