From 1a57ce82800f1b55b02ac27ce4322cf0b25ccf91 Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 30 Aug 2024 01:27:33 +0100 Subject: [PATCH] Basic (failing) create asset test Signed-off-by: snipe --- composer.json | 1 + composer.lock | 45 ++++++++++++++++++++++++++++- tests/Browser/CreateAssetTest.php | 47 +++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 tests/Browser/CreateAssetTest.php diff --git a/composer.json b/composer.json index f00f19af9b..7c95242682 100644 --- a/composer.json +++ b/composer.json @@ -82,6 +82,7 @@ "nunomaduro/phpinsights": "^2.11", "php-mock/php-mock-phpunit": "^2.10", "phpunit/phpunit": "^10.0", + "roquie/laravel-dusk-select2": "^2.1", "squizlabs/php_codesniffer": "^3.5", "symfony/css-selector": "^4.4", "symfony/dom-crawler": "^4.4", diff --git a/composer.lock b/composer.lock index bd85f58589..b206945224 100644 --- a/composer.lock +++ b/composer.lock @@ -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": "7a5bb887aeb2368dafece0dc0da75738", + "content-hash": "a6cc2df01ac4e971aee4100446503331", "packages": [ { "name": "alek13/slack", @@ -15075,6 +15075,49 @@ ], "time": "2024-06-11T12:45:25+00:00" }, + { + "name": "roquie/laravel-dusk-select2", + "version": "2.1.0", + "source": { + "type": "git", + "url": "https://github.com/roquie/laravel-dusk-select2.git", + "reference": "eb13801b753d77384948b8447ebe82beab76f5c5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/roquie/laravel-dusk-select2/zipball/eb13801b753d77384948b8447ebe82beab76f5c5", + "reference": "eb13801b753d77384948b8447ebe82beab76f5c5", + "shasum": "" + }, + "require-dev": { + "laravel/dusk": "^5 || ^6", + "php": ">=7.1", + "phpunit/phpunit": "^8 || ^9", + "symfony/var-dumper": "^4 || ^5" + }, + "type": "library", + "autoload": { + "files": [ + "src/macro.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "roquie", + "email": "roquie0@gmail.com" + } + ], + "description": "Select2.js support for the Laravel Dusk testing.", + "support": { + "issues": "https://github.com/roquie/laravel-dusk-select2/issues", + "source": "https://github.com/roquie/laravel-dusk-select2/tree/2.1.0" + }, + "time": "2020-09-03T12:55:45+00:00" + }, { "name": "sebastian/cli-parser", "version": "2.0.1", diff --git a/tests/Browser/CreateAssetTest.php b/tests/Browser/CreateAssetTest.php new file mode 100644 index 0000000000..29cdfba75d --- /dev/null +++ b/tests/Browser/CreateAssetTest.php @@ -0,0 +1,47 @@ +make([ + ]); + + $user = User::factory()->createAssets()->create([ + 'password' => Hash::make('password'), + ]); + + $this->browse(function (Browser $browser) use ($user, $asset) { + $browser->logout(); + + $browser->visit('/login') + ->type('username', $user->username) + ->type('password', 'password') + ->press('Login') + ->visit('/hardware/create') + ->type('asset_tags[1]', $asset->asset_tag) + ->select2('#model_select_id', 'Macbook') + ->waitForText('Macbook Pro') + ->click('label:first-child') // close the previous select + ->select2('#status_select_id') + ->waitForText('Ready to Deploy') + ->click('label:first-child') // close the previous select + ->press('Save') + ->assertPresent('.alert-success') + ->assertNotPresent('.alert-msg'); + + $browser->logout(); + }); + } + +}