HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/helder.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 PostTest
     * @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('@addButton')
                ->screenshot($this->getName().'-'.++$counter)->pause(350)
                //Select the site
                ->type('@siteInput', $site->getDisplayName())->pause(350)
                ->keys('@siteInput', '{down}')->pause(350)
                ->keys('@siteInput', '{enter}')->pause(350)
                //Disable the active button
                ->click('@activeToggle')
                ->assertInputValue('#OnOff-active', '0')
                ->screenshot($this->getName())
                //Set a date
                ->keys('@DatePickerDate', '{backspace}', '{backspace}', '{backspace}', '{backspace}', '{backspace}', '{backspace}', '{backspace}', '{backspace}', '{backspace}', '{backspace}') //Clear date
                ->type('@DatePickerDate', '02/10/2017')
                ->keys('@DatePickerDate', '{enter}')

                //...And a time
                ->type('@DatePickerHours', '09')
                ->type('@DatePickerMinutes', '01')

                //Set the dutch title
                ->click('@nlTab')
                ->type('#TextField-name-nl', $postName)
                //Save
                ->click('@saveButton')
                ->assertSee($postName)

                //Validate general tab
                ->click('@generalTab')
                ->pause(350)
                ->screenshot($this->getName().'-'.++$counter)
                ->assertSeeIn('#AutocompleteInput-site_id_items > p', $site->getDisplayName())
                ->assertInputValue('#OnOff-active', '0')
                ->assertInputValue('@DatePickerDate', '02/10/2017')
                ->assertInputValue('@DatePickerHours', '09')
                ->assertInputValue('@DatePickerMinutes', '01')

                //Delete the post
                ->type('@searchInput', $postName)
                ->screenshot($this->getName(false).'-'.++$counter)
                ->assertSeeIn('#search-result-counter', '1')
                ->click('#posts-searchlist > li.entities-list-item.active > a')
                ->screenshot($this->getName(false).'-'.++$counter)
                ->assertSeeIn('#entity > div.entity-header > div.entity-header-attributes > h2', $postName)
                ->click('@deleteButton')
                ->assertSee(__('kms/global.confirm_deletion'))
                ->click('@confirmYes')
                ->assertSee(__('kms/global.removed'))
                ->screenshot($this->getName(false).'-'.++$counter);
        });
    }
}