Initial commit
This commit is contained in:
109
tests/Unit/Service/Forms/FormLogicPropertyResolverTest.php
Normal file
109
tests/Unit/Service/Forms/FormLogicPropertyResolverTest.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
use App\Service\Forms\FormLogicPropertyResolver;
|
||||
|
||||
it('can validate form logic property resolver', function ($property, $formData, $expectedResult) {
|
||||
$isRequired = FormLogicPropertyResolver::isRequired($property, $formData);
|
||||
expect($isRequired)->toBe($expectedResult);
|
||||
})->with([
|
||||
[
|
||||
[
|
||||
'id' => "title",
|
||||
'name' => "Name",
|
||||
'type' => 'text',
|
||||
'hidden' => false,
|
||||
'required' => true,
|
||||
'logic' => [
|
||||
"conditions" => [
|
||||
"operatorIdentifier"=> "and",
|
||||
"children"=> [
|
||||
[
|
||||
"identifier"=> "user",
|
||||
"value"=> [
|
||||
"operator"=> "is_not_empty",
|
||||
"property_meta"=> [
|
||||
'id'=> "93ea3198-353f-440b-8dc9-2ac9a7bee124",
|
||||
"type"=> "select",
|
||||
],
|
||||
"value"=> true
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
"actions" => ['make-it-optional']
|
||||
]
|
||||
],
|
||||
['93ea3198-353f-440b-8dc9-2ac9a7bee124'=>["One"]],
|
||||
false
|
||||
],
|
||||
[
|
||||
[
|
||||
'id' => "title",
|
||||
'name' => "Name",
|
||||
'type' => 'text',
|
||||
'hidden' => false,
|
||||
'required' => true,
|
||||
'logic' => [
|
||||
"conditions" => [
|
||||
"operatorIdentifier"=> "and",
|
||||
"children"=> [
|
||||
[
|
||||
"identifier"=> "user",
|
||||
"value"=> [
|
||||
"operator"=> "is_not_empty",
|
||||
"property_meta"=> [
|
||||
'id'=> "93ea3198-353f-440b-8dc9-2ac9a7bee124",
|
||||
"type"=> "select",
|
||||
],
|
||||
"value"=> true
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
"actions" => ['make-it-optional']
|
||||
]
|
||||
],
|
||||
['93ea3198-353f-440b-8dc9-2ac9a7bee124'=>[]],
|
||||
true
|
||||
],
|
||||
[
|
||||
[
|
||||
'id' => "title",
|
||||
'name' => "Name",
|
||||
'type' => 'text',
|
||||
'hidden' => false,
|
||||
'required' => true,
|
||||
'logic' => [
|
||||
"conditions" => [
|
||||
"operatorIdentifier"=> "or",
|
||||
"children"=> [
|
||||
[
|
||||
"identifier"=> "user",
|
||||
"value"=> [
|
||||
"operator"=> "is_not_empty",
|
||||
"property_meta"=> [
|
||||
'id'=> "93ea3198-353f-440b-8dc9-2ac9a7bee124",
|
||||
"type"=> "select",
|
||||
],
|
||||
"value"=> true
|
||||
]
|
||||
],
|
||||
[
|
||||
"identifier"=> "email",
|
||||
"value"=> [
|
||||
"operator"=> "contains",
|
||||
"property_meta"=> [
|
||||
'id'=> "93ea3198-353f-440b-8dc9-2ac9a7bee222",
|
||||
"type"=> "email",
|
||||
],
|
||||
"value"=> "abc"
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
"actions" => ['make-it-optional']
|
||||
]
|
||||
],
|
||||
['93ea3198-353f-440b-8dc9-2ac9a7bee124'=>[], '93ea3198-353f-440b-8dc9-2ac9a7bee222'=>['abc']],
|
||||
false
|
||||
]
|
||||
]);
|
||||
27
tests/Unit/Service/Storage/StorageFileNameParserTest.php
Normal file
27
tests/Unit/Service/Storage/StorageFileNameParserTest.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
uses(\Tests\TestCase::class);
|
||||
|
||||
it('can parse filenames', function () {
|
||||
$fileName = 'Notion_app_logo_85e16d7b-58ed-43bc-8dce-7d3ff7d69f41.png';
|
||||
$parsedFilename = \App\Service\Storage\StorageFileNameParser::parse($fileName);
|
||||
expect($parsedFilename->fileName)->toBe('Notion_app_logo');
|
||||
expect($parsedFilename->uuid)->toBe('85e16d7b-58ed-43bc-8dce-7d3ff7d69f41');
|
||||
expect($parsedFilename->extension)->toBe('png');
|
||||
expect($parsedFilename->getMovedFileName())->toBe($fileName);
|
||||
|
||||
$uuid = Str::uuid()->toString();
|
||||
$parsedFilename = \App\Service\Storage\StorageFileNameParser::parse($uuid);
|
||||
expect($parsedFilename->uuid)->toBe($uuid);
|
||||
expect($parsedFilename->fileName)->toBeNull();
|
||||
expect($parsedFilename->extension)->toBeNull();
|
||||
expect($parsedFilename->getMovedFileName())->toBe($uuid);
|
||||
|
||||
$randomString = Str::random(20);
|
||||
$parsedFilename = \App\Service\Storage\StorageFileNameParser::parse($randomString);
|
||||
expect($parsedFilename->fileName)->toBeNull();
|
||||
expect($parsedFilename->uuid)->toBeNull();
|
||||
expect($parsedFilename->extension)->toBeNull();
|
||||
expect($parsedFilename->getMovedFileName())->toBeNull();
|
||||
|
||||
});
|
||||
26
tests/Unit/TestHelpersTest.php
Normal file
26
tests/Unit/TestHelpersTest.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
uses(\Tests\TestCase::class);
|
||||
|
||||
use function Pest\Faker\faker;
|
||||
use Tests\Helpers\FormSubmissionDataFactory;
|
||||
|
||||
it('can create pro user who are subscribed', function () {
|
||||
$user = $this->actingAsProUser();
|
||||
expect($user->is_subscribed)->toBeTrue();
|
||||
});
|
||||
|
||||
it('can create test workspace', function () {
|
||||
$user = $this->actingAsProUser();
|
||||
$this->createUserWorkspace($user);
|
||||
expect($user->workspaces()->count())->toBe(1);
|
||||
});
|
||||
|
||||
it('can make a form for a database', function () {
|
||||
$user = $this->actingAsProUser();
|
||||
$workspace = $this->createUserWorkspace($user);
|
||||
$form = $this->makeForm($user,$workspace);
|
||||
expect($form->title)->not()->toBeNull();
|
||||
expect($form->description)->not()->toBeNull();
|
||||
expect(count($form->properties))->not()->toBe(0);
|
||||
});
|
||||
Reference in New Issue
Block a user