Created browser test, updated view
This commit is contained in:
parent
c66f26457e
commit
0777268f3e
@ -17,6 +17,7 @@
|
||||
"beyondcode/laravel-dump-server": "^1.0",
|
||||
"filp/whoops": "^2.0",
|
||||
"fzaninotto/faker": "^1.4",
|
||||
"laravel/dusk": "^5.1",
|
||||
"mockery/mockery": "^1.0",
|
||||
"nunomaduro/collision": "^3.0",
|
||||
"phpunit/phpunit": "^7.5"
|
||||
|
127
composer.lock
generated
127
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "94d4bf9ac7f4a933030e46a346ee2917",
|
||||
"content-hash": "f5a0a61c9139ecda3fa774f43e4c4d47",
|
||||
"packages": [
|
||||
{
|
||||
"name": "dnoegel/php-xdg-base-dir",
|
||||
@ -2752,6 +2752,66 @@
|
||||
],
|
||||
"time": "2019-03-17T17:37:11+00:00"
|
||||
},
|
||||
{
|
||||
"name": "facebook/webdriver",
|
||||
"version": "1.6.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/facebook/php-webdriver.git",
|
||||
"reference": "bd8c740097eb9f2fc3735250fc1912bc811a954e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/facebook/php-webdriver/zipball/bd8c740097eb9f2fc3735250fc1912bc811a954e",
|
||||
"reference": "bd8c740097eb9f2fc3735250fc1912bc811a954e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-curl": "*",
|
||||
"ext-json": "*",
|
||||
"ext-mbstring": "*",
|
||||
"ext-zip": "*",
|
||||
"php": "^5.6 || ~7.0",
|
||||
"symfony/process": "^2.8 || ^3.1 || ^4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^2.0",
|
||||
"jakub-onderka/php-parallel-lint": "^0.9.2",
|
||||
"php-coveralls/php-coveralls": "^2.0",
|
||||
"php-mock/php-mock-phpunit": "^1.1",
|
||||
"phpunit/phpunit": "^5.7",
|
||||
"sebastian/environment": "^1.3.4 || ^2.0 || ^3.0",
|
||||
"squizlabs/php_codesniffer": "^2.6",
|
||||
"symfony/var-dumper": "^3.3 || ^4.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-SimpleXML": "For Firefox profile creation"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-community": "1.5-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Facebook\\WebDriver\\": "lib/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"Apache-2.0"
|
||||
],
|
||||
"description": "A PHP client for Selenium WebDriver",
|
||||
"homepage": "https://github.com/facebook/php-webdriver",
|
||||
"keywords": [
|
||||
"facebook",
|
||||
"php",
|
||||
"selenium",
|
||||
"webdriver"
|
||||
],
|
||||
"time": "2018-05-16T17:37:13+00:00"
|
||||
},
|
||||
{
|
||||
"name": "filp/whoops",
|
||||
"version": "2.3.1",
|
||||
@ -2911,6 +2971,71 @@
|
||||
],
|
||||
"time": "2016-01-20T08:20:44+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/dusk",
|
||||
"version": "v5.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/dusk.git",
|
||||
"reference": "a6ac3e6489dc774445aa9459cdc332104591634a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/dusk/zipball/a6ac3e6489dc774445aa9459cdc332104591634a",
|
||||
"reference": "a6ac3e6489dc774445aa9459cdc332104591634a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"ext-zip": "*",
|
||||
"facebook/webdriver": "^1.3",
|
||||
"illuminate/console": "~5.7.0|~5.8.0|~5.9.0",
|
||||
"illuminate/support": "~5.7.0|~5.8.0|~5.9.0",
|
||||
"nesbot/carbon": "^1.20|^2.0",
|
||||
"php": ">=7.1.0",
|
||||
"symfony/console": "^4.0",
|
||||
"symfony/finder": "^4.0",
|
||||
"symfony/process": "^4.0",
|
||||
"vlucas/phpdotenv": "^2.2|^3.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"mockery/mockery": "^1.0",
|
||||
"phpunit/phpunit": "^7.5|^8.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "5.0-dev"
|
||||
},
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Laravel\\Dusk\\DuskServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Laravel\\Dusk\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylor@laravel.com"
|
||||
}
|
||||
],
|
||||
"description": "Laravel Dusk provides simple end-to-end testing and browser automation.",
|
||||
"keywords": [
|
||||
"laravel",
|
||||
"testing",
|
||||
"webdriver"
|
||||
],
|
||||
"time": "2019-05-02T15:08:14+00:00"
|
||||
},
|
||||
{
|
||||
"name": "mockery/mockery",
|
||||
"version": "1.2.2",
|
||||
|
2
public/js/app.js
vendored
2
public/js/app.js
vendored
@ -2385,7 +2385,7 @@ mithril__WEBPACK_IMPORTED_MODULE_0__["default"].mount(document.body.querySelecto
|
||||
tanggalLahir: e.target.elements.tanggalLahir.value
|
||||
});
|
||||
}
|
||||
}, Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('.form-grid', [Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('.form-group', [Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('label.form-label[for=input-nisn]', 'NISN'), Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('input.form-input.input-text#input-nisn[name=nisn][type=text][autocomplete=off][required]'), Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('p.input-helper', !lodash_isempty__WEBPACK_IMPORTED_MODULE_1___default()(_models_Siswa__WEBPACK_IMPORTED_MODULE_2__["default"].error) && _models_Siswa__WEBPACK_IMPORTED_MODULE_2__["default"].error.errors.siswa != undefined ? Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('span.error', _models_Siswa__WEBPACK_IMPORTED_MODULE_2__["default"].error.errors.siswa + ' ') : 'Nomor Induk Siswa Nasional.')]), Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('.form-group', [Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('label.form-label[for=input-tanggalLahir]', 'Tanggal Lahir'), Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('input.form-input.input-text#input-tanggalLahir[name=tanggalLahir][type=text][autocomplete=off][required]'), Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('p.input-helper', [!lodash_isempty__WEBPACK_IMPORTED_MODULE_1___default()(_models_Siswa__WEBPACK_IMPORTED_MODULE_2__["default"].error) && _models_Siswa__WEBPACK_IMPORTED_MODULE_2__["default"].error.errors.tanggalLahir != undefined ? Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('span.error', _models_Siswa__WEBPACK_IMPORTED_MODULE_2__["default"].error.errors.tanggalLahir[0] + ' ') : '', 'Tanggal lahir dengan format YYYYMMDD. Contoh: untuk tanggal 29 Mei 2000 ditulis 20000529'])]), Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('button.form-submit[type=submit]', 'Lihat')])), Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])(!lodash_isempty__WEBPACK_IMPORTED_MODULE_1___default()(_models_Siswa__WEBPACK_IMPORTED_MODULE_2__["default"].current) ? '.letter' : '.letter.hidden', [Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('span.mobile-info', 'Untuk mencetak surat ini, harap gunakan browser di desktop PC.'), Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('button.print-button', {
|
||||
}, Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('.form-grid', [Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('.form-group', [Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('label.form-label[for=input-nisn]', 'NISN'), Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('input.form-input.input-text#input-nisn[name=nisn][type=text][autocomplete=off][required]'), Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('p.input-helper', [!lodash_isempty__WEBPACK_IMPORTED_MODULE_1___default()(_models_Siswa__WEBPACK_IMPORTED_MODULE_2__["default"].error) ? _models_Siswa__WEBPACK_IMPORTED_MODULE_2__["default"].error.errors.siswa != undefined ? Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('span.error', _models_Siswa__WEBPACK_IMPORTED_MODULE_2__["default"].error.errors.siswa[0] + ' ') : _models_Siswa__WEBPACK_IMPORTED_MODULE_2__["default"].error.errors.nisn != undefined ? Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('span.error', _models_Siswa__WEBPACK_IMPORTED_MODULE_2__["default"].error.errors.nisn[0] + ' ') : '' : '', 'Nomor Induk Siswa Nasional.'])]), Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('.form-group', [Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('label.form-label[for=input-tanggalLahir]', 'Tanggal Lahir'), Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('input.form-input.input-text#input-tanggalLahir[name=tanggalLahir][type=text][autocomplete=off][required]'), Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('p.input-helper', [!lodash_isempty__WEBPACK_IMPORTED_MODULE_1___default()(_models_Siswa__WEBPACK_IMPORTED_MODULE_2__["default"].error) && _models_Siswa__WEBPACK_IMPORTED_MODULE_2__["default"].error.errors.tanggalLahir != undefined ? Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('span.error', _models_Siswa__WEBPACK_IMPORTED_MODULE_2__["default"].error.errors.tanggalLahir[0] + ' ') : '', 'Tanggal lahir dengan format YYYYMMDD. Contoh: untuk tanggal 29 Mei 2000 ditulis 20000529'])]), Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('button.form-submit#input-submit[type=submit]', 'Lihat')])), Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])(!lodash_isempty__WEBPACK_IMPORTED_MODULE_1___default()(_models_Siswa__WEBPACK_IMPORTED_MODULE_2__["default"].current) ? '.letter' : '.letter.hidden', [Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('span.mobile-info', 'Untuk mencetak surat ini, harap gunakan browser di desktop PC.'), Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('button.print-button', {
|
||||
onclick: function onclick() {
|
||||
window.print();
|
||||
}
|
||||
|
10
resources/js/app.js
vendored
10
resources/js/app.js
vendored
@ -35,7 +35,13 @@ m.mount(document.body.querySelector('.container'), {
|
||||
m('.form-group', [
|
||||
m('label.form-label[for=input-nisn]', 'NISN'),
|
||||
m('input.form-input.input-text#input-nisn[name=nisn][type=text][autocomplete=off][required]'),
|
||||
m('p.input-helper', !_isEmpty(Siswa.error) && Siswa.error.errors.siswa != undefined ? m('span.error', Siswa.error.errors.siswa + ' ') : 'Nomor Induk Siswa Nasional.'),
|
||||
m('p.input-helper', [
|
||||
!_isEmpty(Siswa.error) ?
|
||||
Siswa.error.errors.siswa != undefined ? m('span.error', Siswa.error.errors.siswa[0] + ' ')
|
||||
: Siswa.error.errors.nisn != undefined ? m('span.error', Siswa.error.errors.nisn[0] + ' ')
|
||||
: '' : '',
|
||||
'Nomor Induk Siswa Nasional.',
|
||||
]),
|
||||
]),
|
||||
m('.form-group', [
|
||||
m('label.form-label[for=input-tanggalLahir]', 'Tanggal Lahir'),
|
||||
@ -45,7 +51,7 @@ m.mount(document.body.querySelector('.container'), {
|
||||
'Tanggal lahir dengan format YYYYMMDD. Contoh: untuk tanggal 29 Mei 2000 ditulis 20000529',
|
||||
]),
|
||||
]),
|
||||
m('button.form-submit[type=submit]', 'Lihat'),
|
||||
m('button.form-submit#input-submit[type=submit]', 'Lihat'),
|
||||
])),
|
||||
m(!_isEmpty(Siswa.current) ? '.letter' : '.letter.hidden', [
|
||||
m('span.mobile-info', 'Untuk mencetak surat ini, harap gunakan browser di desktop PC.'),
|
||||
|
41
tests/Browser/Pages/HomePage.php
Normal file
41
tests/Browser/Pages/HomePage.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Browser\Pages;
|
||||
|
||||
use Laravel\Dusk\Browser;
|
||||
|
||||
class HomePage extends Page
|
||||
{
|
||||
/**
|
||||
* Get the URL for the page.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function url()
|
||||
{
|
||||
return '/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the browser is on the page.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function assert(Browser $browser)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the element shortcuts for the page.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function elements()
|
||||
{
|
||||
return [
|
||||
'@element' => '#selector',
|
||||
];
|
||||
}
|
||||
}
|
20
tests/Browser/Pages/Page.php
Normal file
20
tests/Browser/Pages/Page.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Browser\Pages;
|
||||
|
||||
use Laravel\Dusk\Page as BasePage;
|
||||
|
||||
abstract class Page extends BasePage
|
||||
{
|
||||
/**
|
||||
* Get the global element shortcuts for the site.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function siteElements()
|
||||
{
|
||||
return [
|
||||
'@element' => '#selector',
|
||||
];
|
||||
}
|
||||
}
|
59
tests/Browser/SuratTest.php
Normal file
59
tests/Browser/SuratTest.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Browser;
|
||||
|
||||
use Tests\DuskTestCase;
|
||||
use Laravel\Dusk\Browser;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
|
||||
class SuratTest extends DuskTestCase
|
||||
{
|
||||
/**
|
||||
* A Dusk test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testExample()
|
||||
{
|
||||
$this->browse(function (Browser $browser) {
|
||||
$browser->visit('/')
|
||||
->assertSee('Bhakti Anindya');
|
||||
});
|
||||
}
|
||||
|
||||
public function testInputTanggalTidakSesuaiMelihatPesanError()
|
||||
{
|
||||
$this->browse(function (Browser $browser) {
|
||||
$browser->visit('/')
|
||||
->type('nisn', '1234567890')
|
||||
->type('tanggalLahir', '11223344')
|
||||
->click('#input-submit')
|
||||
->waitFor('.error', 3)
|
||||
->assertSee('Kolom tanggal lahir tidak sesuai.');
|
||||
});
|
||||
}
|
||||
|
||||
public function testInputNISNTidakSesuaiMelihatPesanError()
|
||||
{
|
||||
$this->browse(function (Browser $browser) {
|
||||
$browser->visit('/')
|
||||
->type('nisn', '1bcd5fghi0')
|
||||
->type('tanggalLahir', '20190511')
|
||||
->click('#input-submit')
|
||||
->waitFor('.error', 3)
|
||||
->assertSee('Kolom nisn tidak sesuai.');
|
||||
});
|
||||
}
|
||||
|
||||
public function testInputDataTidakDitemukanMelihatError()
|
||||
{
|
||||
$this->browse(function (Browser $browser) {
|
||||
$browser->visit('/')
|
||||
->type('nisn', '1234567890')
|
||||
->type('tanggalLahir', '20000529')
|
||||
->click('#input-submit')
|
||||
->waitFor('.error', 3)
|
||||
->assertSee('Siswa tidak ditemukan.');
|
||||
});
|
||||
}
|
||||
}
|
2
tests/Browser/console/.gitignore
vendored
Normal file
2
tests/Browser/console/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
2
tests/Browser/screenshots/.gitignore
vendored
Normal file
2
tests/Browser/screenshots/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
44
tests/DuskTestCase.php
Normal file
44
tests/DuskTestCase.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use Laravel\Dusk\TestCase as BaseTestCase;
|
||||
use Facebook\WebDriver\Chrome\ChromeOptions;
|
||||
use Facebook\WebDriver\Remote\RemoteWebDriver;
|
||||
use Facebook\WebDriver\Remote\DesiredCapabilities;
|
||||
|
||||
abstract class DuskTestCase extends BaseTestCase
|
||||
{
|
||||
use CreatesApplication;
|
||||
|
||||
/**
|
||||
* Prepare for Dusk test execution.
|
||||
*
|
||||
* @beforeClass
|
||||
* @return void
|
||||
*/
|
||||
public static function prepare()
|
||||
{
|
||||
static::startChromeDriver();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the RemoteWebDriver instance.
|
||||
*
|
||||
* @return \Facebook\WebDriver\Remote\RemoteWebDriver
|
||||
*/
|
||||
protected function driver()
|
||||
{
|
||||
$options = (new ChromeOptions)->addArguments([
|
||||
'--disable-gpu',
|
||||
'--headless',
|
||||
'--window-size=1920,1080',
|
||||
]);
|
||||
|
||||
return RemoteWebDriver::create(
|
||||
'http://localhost:9515', DesiredCapabilities::chrome()->setCapability(
|
||||
ChromeOptions::CAPABILITY, $options
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user