File: D:/HostingSpaces/SBogers10/boldt.komma.pro/tests/Browser/PostTest.php
<?php
namespace Tests\Browser;
use App\Komma\Sites\Models\Site;
use App\Komma\Users\Models\User;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\PostSectionTestPage;
use Tests\DuskTestCase;
class PostTest extends DuskTestCase
{
use DatabaseTransactions; //Automatically rolls back database actions after tests
/**
* @group Post
* @test
*/
public function testCreatePost()
{
$site = Site::first();#
$postName = 'Dusk_test_post_'.mt_rand(1, 9999);
$counter = 0;
$this->browse(function (Browser $browser) use ($site, $postName, $counter) {
$browser->loginAs(User::find(1))
//Go to the section and press the add button
->visit(new PostSectionTestPage())
->screenshot($this->getName().'-'.++$counter)
->assertSee(__('kms/posts.section.subtitle'))
->click('@add_button')
->screenshot($this->getName().'-'.++$counter)->pause(350)
//Select the site
->type('@MultiSelect-site_id-fake', $site->getDisplayName())->pause(350)
->keys('@MultiSelect-site_id-fake', '{down}')->pause(350)
->keys('@MultiSelect-site_id-fake', '{enter}')->pause(350)
//Disable the active button
->click('@active_toggle')
->assertInputValue('@OnOff-active', '0')
->screenshot($this->getName())
//Set a date
->keys('@DatePicker-date_date', '{backspace}', '{backspace}', '{backspace}', '{backspace}', '{backspace}', '{backspace}', '{backspace}', '{backspace}', '{backspace}', '{backspace}') //Clear date
->type('@DatePicker-date_date', '02/10/2017')
->keys('@DatePicker-date_date', '{enter}')
//...And a time
->type('@DatePicker-date_time_hours', '09')
->type('@DatePicker-date_time_minutes', '01')
//Set the dutch title
->click('@entity_tab_nl')
->type('#TextField-name-nl', $postName)
//Save
->click('@save_button')
->assertSee($postName)
//Validate general tab
->click('@entity_tab_algemeen')
->pause(350)
->screenshot($this->getName().'-'.++$counter)
->assertSeeIn('@MultiSelect-site_id_items', $site->getDisplayName())
->assertInputValue('@OnOff-active', '0')
->assertInputValue('@DatePicker-date_date', '02/10/2017')
->assertInputValue('@DatePicker-date_time_hours', '09')
->assertInputValue('@DatePicker-date_time_minutes', '01')
//Delete the post
->type('@entity_search_input', $postName)
->screenshot($this->getName(false).'-'.++$counter)
->assertSeeIn('@search-result-counter', '1')
->click('@found_search_item')
->screenshot($this->getName(false).'-'.++$counter)
->assertSeeIn('@entity_header', $postName)
->click('@delete_button')
->assertSee(__('kms/global.confirm_deletion'))
->click('@confirmation_confirm')
->assertSee(__('kms/global.removed'))
->screenshot($this->getName(false).'-'.++$counter);
});
}
}