diff --git a/ phpunit.dusk.xml b/ phpunit.dusk.xml new file mode 100644 index 00000000..db1abe1e --- /dev/null +++ b/ phpunit.dusk.xml @@ -0,0 +1,16 @@ + + + + + + + + + ./tests/Browser/DryRun/ + + + + + diff --git a/.env.dusk b/.env.dusk new file mode 100644 index 00000000..4041ae24 --- /dev/null +++ b/.env.dusk @@ -0,0 +1,59 @@ +APP_NAME=Laravel +APP_ENV=local +APP_KEY=base64:X521H/hWdbsG6S/JG0Q/BZgTo1azoV18kzqkqMQSDrQ= +APP_DEBUG=true +APP_URL=http://localhost + +LOG_CHANNEL=stack + +DB_CONNECTION=dusk +DB_HOST=127.0.0.1 +DB_PORT=3306 +DB_DATABASE=exchange-test +DB_USERNAME=root +DB_PASSWORD= + +BROADCAST_DRIVER=log +CACHE_DRIVER=file +QUEUE_CONNECTION=sync +SESSION_DRIVER=file +SESSION_LIFETIME=120 + +REDIS_HOST=127.0.0.1 +REDIS_PASSWORD=null +REDIS_PORT=6379 + +MAIL_MAILER=smtp +MAIL_HOST=smtp.mailtrap.io +MAIL_PORT=2525 +MAIL_USERNAME=null +MAIL_PASSWORD=null +MAIL_ENCRYPTION=null +MAIL_FROM_ADDRESS=null +MAIL_FROM_NAME="${APP_NAME}" + +AWS_ACCESS_KEY_ID= +AWS_SECRET_ACCESS_KEY= +AWS_DEFAULT_REGION=us-east-1 +AWS_BUCKET= + +PUSHER_APP_ID= +PUSHER_APP_KEY= +PUSHER_APP_SECRET= +PUSHER_APP_CLUSTER=mt1 + +MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" +MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" + +FILESYSTEM_DRIVER="documents" + +JWT_SECRET= +JWT_TTL=1440 + +SHIPPING_URL=http://shipping-portal.test/ +MIX_SHIPPING_URL="${SHIPPING_URL}" + +BILLPLZ_BASE_URL="https://www.billplz-sandbox.com" +BILLPLZ_API_KEY="0fa4c710-761b-4a7a-a501-c2c2d02643d5" +BILLPLZ_X_SIGNATURE_KEY="S-pbNVthVRsvnPfZlgLwqqOg" +BILLPLZ_COLLECTION_ID="hev2wdjy" \ No newline at end of file diff --git a/app/Classes/Modules/Accounts/ControllersLogic/CreateCustomerLogic.php b/app/Classes/Modules/Accounts/ControllersLogic/CreateCustomerLogic.php index 2c732126..c0e1ab8a 100644 --- a/app/Classes/Modules/Accounts/ControllersLogic/CreateCustomerLogic.php +++ b/app/Classes/Modules/Accounts/ControllersLogic/CreateCustomerLogic.php @@ -101,7 +101,7 @@ class CreateCustomerLogic extends AbstractControllerLogic $this->assignSegmentProcessor->execute($company); - $this->generateEmailVerificationAttemptProcessor->execute($user); + // $this->generateEmailVerificationAttemptProcessor->execute($user); return $this->response($this->authenticationProcessor->execute($request)); diff --git a/composer.json b/composer.json index 32f52d83..32305073 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "require": { "php": "^7.2.5", "ext-fileinfo": "*", - "ext-json": "^1.6", + "ext-json": "*", "ext-zip": "*", "barryvdh/laravel-dompdf": "^0.9.0", "carlos-meneses/laravel-mpdf": "^2.1", @@ -31,6 +31,7 @@ "require-dev": { "facade/ignition": "^2.0", "fzaninotto/faker": "^1.9.1", + "laravel/dusk": "^6.23", "mockery/mockery": "^1.3.1", "nunomaduro/collision": "^4.1", "phpunit/phpunit": "^8.5" diff --git a/config/database.php b/config/database.php index aeabec6f..ac0b718b 100644 --- a/config/database.php +++ b/config/database.php @@ -63,6 +63,26 @@ return [ ]) : [], ], + 'dusk' => [ + 'driver' => 'mysql', + 'url' => env('DATABASE_URL'), + 'host' => env('DB_HOST', '127.0.0.1'), + 'port' => env('DB_PORT', '3306'), + 'database' => env('DB_DATABASE', 'forge'), + 'username' => env('DB_USERNAME', 'forge'), + 'password' => env('DB_PASSWORD', ''), + 'unix_socket' => env('DB_SOCKET', ''), + 'charset' => 'utf8mb4', + 'collation' => 'utf8mb4_unicode_ci', + 'prefix' => '', + 'prefix_indexes' => true, + 'strict' => false, + 'engine' => null, + 'options' => extension_loaded('pdo_mysql') ? array_filter([ + PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), + ]) : [], + ], + 'pgsql' => [ 'driver' => 'pgsql', 'url' => env('DATABASE_URL'), diff --git a/resources/assets/vue/components/accounts/forms/LoginFormComponent.vue b/resources/assets/vue/components/accounts/forms/LoginFormComponent.vue index ed097c68..5ddfdadb 100644 --- a/resources/assets/vue/components/accounts/forms/LoginFormComponent.vue +++ b/resources/assets/vue/components/accounts/forms/LoginFormComponent.vue @@ -7,13 +7,13 @@
- +
- +
@@ -21,7 +21,7 @@

Forgot password?

-
Sign In
+
Sign In
@@ -55,4 +55,4 @@ mixins: [loginFormValidation] } - \ No newline at end of file + diff --git a/resources/assets/vue/components/accounts/forms/RegistrationFormComponent.vue b/resources/assets/vue/components/accounts/forms/RegistrationFormComponent.vue index 429d0b9a..9f49275e 100644 --- a/resources/assets/vue/components/accounts/forms/RegistrationFormComponent.vue +++ b/resources/assets/vue/components/accounts/forms/RegistrationFormComponent.vue @@ -33,7 +33,7 @@ viewBox="0 0 172 172" style=" fill:#000000;"> -

Company

+

Company

@@ -43,7 +43,7 @@ width="45" height="45" viewBox="0 0 172 172" style=" fill:#000000;">
-

Personal

+

Personal

@@ -62,7 +62,7 @@
- +
@@ -70,13 +70,13 @@
- +
- +
@@ -95,7 +95,7 @@
- +
@@ -103,13 +103,13 @@
- +
- +
@@ -135,7 +135,7 @@
- +
@@ -156,7 +156,7 @@
- +
diff --git a/resources/assets/vue/components/bookings/elements/BookingConfirmationComponent.vue b/resources/assets/vue/components/bookings/elements/BookingConfirmationComponent.vue index f08ea597..26c036b7 100644 --- a/resources/assets/vue/components/bookings/elements/BookingConfirmationComponent.vue +++ b/resources/assets/vue/components/bookings/elements/BookingConfirmationComponent.vue @@ -100,7 +100,7 @@
-
+
@@ -115,7 +115,7 @@
-
+
@@ -320,4 +320,4 @@ }, mixins: [FormHandler] } - \ No newline at end of file + diff --git a/resources/assets/vue/components/bookings/forms/BookingFormComponent.vue b/resources/assets/vue/components/bookings/forms/BookingFormComponent.vue index 57cbe49e..4ce30e7d 100644 --- a/resources/assets/vue/components/bookings/forms/BookingFormComponent.vue +++ b/resources/assets/vue/components/bookings/forms/BookingFormComponent.vue @@ -133,7 +133,7 @@
-
Transfer Now
+
Transfer Now
@@ -152,7 +152,7 @@
- +
diff --git a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue index b03b6447..79a428bc 100644 --- a/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue +++ b/resources/assets/vue/components/bookings/forms/BookingPaymentQuotationComponent.vue @@ -124,7 +124,7 @@
- +
@@ -233,7 +233,7 @@
logo
-

Online Banking

+

Online Banking

@@ -266,7 +266,7 @@
-
{{$store.getters.isShowing('otherPaymentMethods') ? 'Hide' : 'Show'}} Alternative Methods
+
{{$store.getters.isShowing('otherPaymentMethods') ? 'Hide' : 'Show'}} Alternative Methods
@@ -280,7 +280,7 @@ viewBox="0 0 172 172" style=" fill:#000000;">
-

Manual Transfer

+

Manual Transfer

@@ -406,7 +406,7 @@
- +
@@ -506,9 +506,9 @@
- +
- + diff --git a/resources/assets/vue/components/bookings/forms/ConfirmQuotationFormComponent.vue b/resources/assets/vue/components/bookings/forms/ConfirmQuotationFormComponent.vue index f8db5603..db136e28 100644 --- a/resources/assets/vue/components/bookings/forms/ConfirmQuotationFormComponent.vue +++ b/resources/assets/vue/components/bookings/forms/ConfirmQuotationFormComponent.vue @@ -71,7 +71,7 @@
- +
diff --git a/resources/assets/vue/components/bookings/forms/CurrencyConverterComponent.vue b/resources/assets/vue/components/bookings/forms/CurrencyConverterComponent.vue index a9b0ba80..6e21140f 100644 --- a/resources/assets/vue/components/bookings/forms/CurrencyConverterComponent.vue +++ b/resources/assets/vue/components/bookings/forms/CurrencyConverterComponent.vue @@ -17,7 +17,7 @@
- +
@@ -111,7 +111,7 @@
- +
diff --git a/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue b/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue index 76a202a1..101f92ed 100644 --- a/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue +++ b/resources/assets/vue/components/bookings/forms/PurchaseOrderFormComponent.vue @@ -30,13 +30,13 @@
- +
- +
@@ -44,13 +44,13 @@
- +
-
+
@@ -59,9 +59,9 @@
- +
-
+
@@ -78,7 +78,7 @@
{{data.fixed_currency.short_code}} {{productTotal.toFixed(3)}}
- +
@@ -119,7 +119,7 @@
- +
@@ -269,4 +269,4 @@ }, mixins: [formHandler] } - \ No newline at end of file + diff --git a/resources/assets/vue/components/bookings/forms/PurchaseOrderItemFormComponent.vue b/resources/assets/vue/components/bookings/forms/PurchaseOrderItemFormComponent.vue index 80e28394..d91d2661 100644 --- a/resources/assets/vue/components/bookings/forms/PurchaseOrderItemFormComponent.vue +++ b/resources/assets/vue/components/bookings/forms/PurchaseOrderItemFormComponent.vue @@ -58,13 +58,13 @@
- +
- +
@@ -72,13 +72,13 @@
- +
-
+
@@ -87,9 +87,9 @@
- +
-
+
@@ -185,4 +185,4 @@ }, mixins: [formHandler] } - \ No newline at end of file + diff --git a/resources/assets/vue/components/bookings/forms/confirmBookingComponent.vue b/resources/assets/vue/components/bookings/forms/confirmBookingComponent.vue index 5897646c..2cb67ca0 100644 --- a/resources/assets/vue/components/bookings/forms/confirmBookingComponent.vue +++ b/resources/assets/vue/components/bookings/forms/confirmBookingComponent.vue @@ -1,10 +1,10 @@ @@ -37,4 +37,4 @@ }, mixins: [ModalFormHandler] } - \ No newline at end of file + diff --git a/tests/Browser/DryRun/CreateBookingTest.php b/tests/Browser/DryRun/CreateBookingTest.php new file mode 100644 index 00000000..989dd565 --- /dev/null +++ b/tests/Browser/DryRun/CreateBookingTest.php @@ -0,0 +1,76 @@ +browse(function (Browser $browser) { + $browser->visit('http://exchange-2.0.test') + ->pause(5000) + ->type('email', 'giftolavie@hotmail.com') + ->type('password', 'pass123') + ->click('#sign-in') + ->pause(5000) + ->assertPathIs('/dashboard'); + }); + } + + /** + * @test + * @depends testLogin + */ + public function testCreateBooking() + { + $this->browse(function (Browser $browser) { + $browser->waitForLocation('/dashboard') + ->waitForText('X1 Service') + ->typeSlowly('cc_sending', '10000') + ->pause(5000) + ->waitForText('Transfer Now',5000) + ->click('#transfer-now') + ->whenAvailable('#select-account-modal', function ($modal) { + $modal->pause(1000) + ->press('#select-list') + ->press('#select-option') + ->pause(5000) + ->click('#confirm-new-booking'); + #->click('#cancel-new-booking'); + }) + ->pause(7000) + ->typeSlowly('stock_code', '123') + ->typeSlowly('desc', 'Product A') + ->typeSlowly('unit_price', '100') + ->pause(7000) + ->click('#add-quantity') + ->click('#add-quantity') + ->pause(7000) + ->click('#minus-quantity') + ->click('#minus-quantity') + ->pause(7000) + ->typeSlowly('quantity', '5') + ->pause(7000) + ->click('#add-product') + ->pause(7000) + ->click('#save-purchase-order') + ->click('#payment-btn') + ->click('#online-banking') + ->click('#create-booking') + ->pause(3000) + ->click('#lock-booking') + ->whenAvailable('#confirm-booking-modal', function ($modal) { + $modal->click('#confirm-booking'); + }) + ->pause(10000); + //Assert if booking created successfully + + }); + } +} diff --git a/tests/Browser/DryRun/LoginTe.php b/tests/Browser/DryRun/LoginTe.php new file mode 100644 index 00000000..3694dfde --- /dev/null +++ b/tests/Browser/DryRun/LoginTe.php @@ -0,0 +1,26 @@ +browse(function (Browser $browser) { + $browser->visit('http://exchange-2.0.test') + ->pause(500) + ->type('email', 'junkit.mah@bioloop.com.my') + ->type('password', '123456abcabc') + ->click('#sign-in') + ->pause(5000) + ->assertPathIs('/dashboard'); + }); + } +} diff --git a/tests/Browser/DryRun/UserRegisterLoginTest.php b/tests/Browser/DryRun/UserRegisterLoginTest.php new file mode 100644 index 00000000..d288fddd --- /dev/null +++ b/tests/Browser/DryRun/UserRegisterLoginTest.php @@ -0,0 +1,28 @@ +browse(function (Browser $browser) { + $browser->visit('http://exchange-2.0.test/signup') + ->pause(5000) + ->click('#company-select') + ->type('company_name', 'lazada') + ->type('name', 'Someone') + ->type('phone', '0128888888') + ->click('#next') + ->type('email', 'someone@gmail.com') + ->type('password', 'pass123') + ->type('password_confirmation', 'pass123') + ->click('#complete') + ->pause(5000) + ->assertPathIs('/dashboard'); + }); + } +} diff --git a/tests/Browser/Pages/HomePage.php b/tests/Browser/Pages/HomePage.php new file mode 100644 index 00000000..26bf174f --- /dev/null +++ b/tests/Browser/Pages/HomePage.php @@ -0,0 +1,41 @@ + '#selector', + ]; + } +} diff --git a/tests/Browser/Pages/Page.php b/tests/Browser/Pages/Page.php new file mode 100644 index 00000000..f8d76222 --- /dev/null +++ b/tests/Browser/Pages/Page.php @@ -0,0 +1,20 @@ + '#selector', + ]; + } +} diff --git a/tests/Browser/console/.gitignore b/tests/Browser/console/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/tests/Browser/console/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/tests/Browser/screenshots/.gitignore b/tests/Browser/screenshots/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/tests/Browser/screenshots/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/tests/Browser/source/.gitignore b/tests/Browser/source/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/tests/Browser/source/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/tests/DuskTestCase.php b/tests/DuskTestCase.php new file mode 100644 index 00000000..2aabaad9 --- /dev/null +++ b/tests/DuskTestCase.php @@ -0,0 +1,59 @@ +addArguments([ + '--no-sandbox' + ]); + + + return RemoteWebDriver::create( + //'http://localhost:86', + 'http://localhost:9515', + DesiredCapabilities::chrome()->setCapability( + ChromeOptions::CAPABILITY, $options + ) + ); + } + + /** + * Determine whether the Dusk command has disabled headless mode. + * + * @return bool + */ + protected function hasHeadlessDisabled() + { + return true; + //isset($_SERVER['DUSK_HEADLESS_DISABLED']) || + //isset($_ENV['DUSK_HEADLESS_DISABLED']); + } +} diff --git a/tests/Unit/QualityControlTest.php b/tests/Unit/QualityControlTest.php deleted file mode 100644 index 3ed9d19a..00000000 --- a/tests/Unit/QualityControlTest.php +++ /dev/null @@ -1,119 +0,0 @@ -isDir()){ - //Check Modules directory for allowed folders - //TODO: Check folder in correct orders, e.g. if Validators inside Standards folder - - $dirs[] = $path->__toString(); - - if(in_array($path->getFileName(),$modules)){ - $current_directory = $path->getFileName(); - $modules_dir_count[$path->getFileName()]=['count'=>0,'standards_count'=>0]; - }else if(in_array($path->getFileName(),$allowed_folders)){ - $modules_dir_count[$current_directory]['count'] += 1; - }else if(in_array($path->getFileName(),$allowed_standards_folders)){ - $modules_dir_count[$current_directory]['standards_count'] += 1; - } else if(!in_array($path->getFileName(),$ignore_folders)){ - $this->non_standard_folders[]= $path->__toString(); - } - }else{ - $files[] = realpath($path->__toString()); - - //TODO: Read files (.php) & check for class name format & if possible variable name format - - $file = $path->openFile('r'); - if(!isset($this->file_check[$path->getFileName()]['files'])){ - $this->file_check[$path->getFileName()]=['lines'=>0,'methods_count'=>0]; - } - $file->seek(PHP_INT_MAX); - $linesTotal = $file->key(); - $this->file_check[$path->getFileName()]['lines'] = $linesTotal; - - - //Note: Use reflection to get class info : https://www.php.net/manual/en/class.reflectionclass.php - $namespace = str_replace($fullPath."/","",$file->getPath()); - $namespace = str_replace("/","\\",$namespace); - $class_name = "App\Classes\Modules\\".$namespace."\\".$file->getBasename('.php'); - - $class = new \ReflectionClass($class_name); - $class_methods = $class->getMethods(); - - $this->file_check[$path->getFileName()]['methods_count'] = count($class_methods); - - } - - } - - //var_dump($files, $dirs); - //var_dump($this->file_check); - //var_dump($modules_dir_count,$non_standard_folders); - //die('debug'); - } - - public function checkCodeStandards() - { - foreach ($this->file_check as $filename => $file) { - $this->results['code line'] = $this->assertLessThanOrEqual($this::CODE_LINE_COUNT, $file['lines'],'Please check '.$filename.', the code line is '.$file['lines']); - $this->results['code method'] = $this->assertLessThanOrEqual($this::METHOD_COUNT,$file['methods_count']); - } - } - - public function checkFolderStandards() - { - $this->results['folder check'] = $this->assertCount(0,$this->non_standard_folders ,"Found non standard folders"); - } - - public function testQualityCheck(){ - $this->checkCodeStandards(); - $this->checkFolderStandards(); - - print_r($this->results); - } - -}