Lint PHP code psr-12, add GH action

This commit is contained in:
Julien Nahum
2024-02-23 11:54:12 +01:00
parent e85e4df7fe
commit 62971a2ef4
226 changed files with 2338 additions and 2144 deletions

View File

@@ -12,30 +12,28 @@ it('can login onboarded users', function () {
$this->createUserWorkspace($user);
$this->browse(function ($browser) use ($user) {
$browser->visit(new Login)
$browser->visit(new Login())
->submit($user->email, 'password')
->assertPageIs(Home::class);
});
});
it('cannot login with invalid credentials',function()
{
it('cannot login with invalid credentials', function () {
$this->browse(function ($browser) {
$browser->visit(new Login)
$browser->visit(new Login())
->submit('test@test.app', 'password')
->pause(100)
->assertSee('These credentials do not match our records.');
});
});
it('can log out the user',function()
{
it('can log out the user', function () {
$user = User::factory()->create();
$this->browse(function ($browser) use ($user) {
$browser->visit(new Login)
$browser->visit(new Login())
->submit($user->email, 'password')
->on(new Home)
->on(new Home())
->clickLogout()
->assertPageIs(Login::class);
});

View File

@@ -19,7 +19,6 @@ class Home extends Page
/**
* Assert that the browser is on the page.
*
* @param Browser $browser
* @return void
*/
public function assert(Browser $browser)
@@ -40,7 +39,7 @@ class Home extends Page
/**
* Click on the log out link.
*
* @param \Laravel\Dusk\Browser $browser
* @param \Laravel\Dusk\Browser $browser
* @return void
*/
public function clickLogout($browser)

View File

@@ -19,7 +19,6 @@ class HomePage extends Page
/**
* Assert that the browser is on the page.
*
* @param \Laravel\Dusk\Browser $browser
* @return void
*/
public function assert(Browser $browser)

View File

@@ -17,16 +17,16 @@ class Login extends Page
/**
* Submit the form with the given credentials.
*
* @param \Laravel\Dusk\Browser $browser
* @param string $email
* @param string $password
* @param \Laravel\Dusk\Browser $browser
* @param string $email
* @param string $password
* @return void
*/
public function submit($browser, $email, $password)
{
$browser->type('email', $email)
->type('password', $password)
->press('@btn_login')
->pause(500);
->type('password', $password)
->press('@btn_login')
->pause(500);
}
}

View File

@@ -19,7 +19,6 @@ class Onboarding extends Page
/**
* Assert that the browser is on the page.
*
* @param Browser $browser
* @return void
*/
public function assert(Browser $browser)

View File

@@ -10,7 +10,6 @@ abstract class Page extends BasePage
/**
* Assert that the browser is on the page.
*
* @param Browser $browser
* @return void
*/
public function assert(Browser $browser)

View File

@@ -17,8 +17,7 @@ class Register extends Page
/**
* Submit the form with the given data.
*
* @param \Laravel\Dusk\Browser $browser
* @param array $data
* @param \Laravel\Dusk\Browser $browser
* @return void
*/
public function submit($browser, array $data = [])

View File

@@ -22,7 +22,7 @@ class RegisterTest extends DuskTestCase
/**
* Pick Random option from custom select
* @param Browser $browser
*
* @throws \Facebook\WebDriver\Exception\TimeOutException
*/
public function selectHearAboutUsReason(Browser $browser)
@@ -39,7 +39,7 @@ class RegisterTest extends DuskTestCase
public function register_with_valid_data()
{
$this->browse(function (Browser $browser) {
$browser->visit(new Register);
$browser->visit(new Register());
$this->selectHearAboutUsReason($browser);
$browser->submit([
'name' => 'Test User',
@@ -57,7 +57,7 @@ class RegisterTest extends DuskTestCase
$user = User::factory()->create();
$this->browse(function (Browser $browser) use ($user) {
$browser->visit(new Register);
$browser->visit(new Register());
$this->selectHearAboutUsReason($browser);
$browser->submit([
'name' => 'Test User',

View File

@@ -12,22 +12,24 @@ use Laravel\Dusk\TestCase as BaseTestCase;
Browser::macro('assertPageIs', function ($page) {
if (! $page instanceof Page) {
$page = new $page;
$page = new $page();
}
// waiting for location before asserting, because window.location.pathname may be updated asynchronously
return $this->waitForLocation($page->url())->assertPathIs($page->url());
});
abstract class DuskTestCase extends BaseTestCase
{
use DatabaseMigrations;
use CreatesApplication;
use DatabaseMigrations;
use TestHelpers;
/**
* Prepare for Dusk test execution.
*
* @beforeClass
*
* @return void
*/
public static function prepare()
@@ -42,15 +44,17 @@ abstract class DuskTestCase extends BaseTestCase
*/
protected function driver()
{
$options = (new ChromeOptions)->addArguments([
$options = (new ChromeOptions())->addArguments([
'--disable-gpu',
'--headless',
'--window-size=1920,1080',
]);
return RemoteWebDriver::create(
'http://localhost:9515', DesiredCapabilities::chrome()->setCapability(
ChromeOptions::CAPABILITY, $options
'http://localhost:9515',
DesiredCapabilities::chrome()->setCapability(
ChromeOptions::CAPABILITY,
$options
)
);
}

View File

@@ -10,7 +10,6 @@ it('can answer a form', function () {
// TODO: generate random response given a form and un-skip
})->skip('Need to finish writing a class to generated random responses');
it('can submit form if close date is in future', function () {
$user = $this->actingAsUser();
$workspace = $this->createUserWorkspace($user);
@@ -23,7 +22,7 @@ it('can submit form if close date is in future', function () {
->assertSuccessful()
->assertJson([
'type' => 'success',
'message' => 'Form submission saved.'
'message' => 'Form submission saved.',
]);
});
@@ -48,12 +47,12 @@ it('can submit form till max submissions count is not reached at limit', functio
$formData = FormSubmissionDataFactory::generateSubmissionData($form);
// Can submit form
for($i=1;$i<=3;$i++){
for ($i = 1; $i <= 3; $i++) {
$this->postJson(route('forms.answer', $form->slug), $formData)
->assertSuccessful()
->assertJson([
'type' => 'success',
'message' => 'Form submission saved.'
'message' => 'Form submission saved.',
]);
}
@@ -66,7 +65,7 @@ it('can not open draft form', function () {
$user = $this->actingAsUser();
$workspace = $this->createUserWorkspace($user);
$form = $this->createForm($user, $workspace, [
'visibility' => 'draft'
'visibility' => 'draft',
]);
$this->getJson(route('forms.show', $form->slug))
@@ -77,7 +76,7 @@ it('can not submit draft form', function () {
$user = $this->actingAsUser();
$workspace = $this->createUserWorkspace($user);
$form = $this->createForm($user, $workspace, [
'visibility' => 'draft'
'visibility' => 'draft',
]);
$formData = FormSubmissionDataFactory::generateSubmissionData($form);
@@ -89,7 +88,7 @@ it('can not submit visibility closed form', function () {
$user = $this->actingAsUser();
$workspace = $this->createUserWorkspace($user);
$form = $this->createForm($user, $workspace, [
'visibility' => 'closed'
'visibility' => 'closed',
]);
$formData = FormSubmissionDataFactory::generateSubmissionData($form);
@@ -104,10 +103,11 @@ it('can not submit form with past dates', function () {
$submissionData = [];
$form->properties = collect($form->properties)->map(function ($property) use (&$submissionData) {
if(in_array($property['type'], ['date'])){
$property["disable_past_dates"] = true;
if (in_array($property['type'], ['date'])) {
$property['disable_past_dates'] = true;
$submissionData[$property['id']] = now()->subDays(4)->format('Y-m-d');
}
return $property;
})->toArray();
$form->update();
@@ -117,7 +117,7 @@ it('can not submit form with past dates', function () {
$this->postJson(route('forms.answer', $form->slug), $formData)
->assertStatus(422)
->assertJson([
'message' => 'The Date must be a date after or equal to today.'
'message' => 'The Date must be a date after or equal to today.',
]);
});
@@ -128,10 +128,11 @@ it('can not submit form with future dates', function () {
$submissionData = [];
$form->properties = collect($form->properties)->map(function ($property) use (&$submissionData) {
if(in_array($property['type'], ['date'])){
$property["disable_future_dates"] = true;
if (in_array($property['type'], ['date'])) {
$property['disable_future_dates'] = true;
$submissionData[$property['id']] = now()->addDays(4)->format('Y-m-d');
}
return $property;
})->toArray();
$form->update();
@@ -141,6 +142,6 @@ it('can not submit form with future dates', function () {
$this->postJson(route('forms.answer', $form->slug), $formData)
->assertStatus(422)
->assertJson([
'message' => 'The Date must be a date before or equal to today.'
'message' => 'The Date must be a date before or equal to today.',
]);
});

View File

@@ -1,6 +1,6 @@
<?php
use Illuminate\Support\Facades\Artisan;
use Spatie\Mailcoach\Domain\TransactionalMail\Models\TransactionalMail;
it('check form statistic for views & submissions counts', function () {
$user = $this->actingAsUser();
@@ -8,7 +8,7 @@ it('check form statistic for views & submissions counts', function () {
$form = $this->createForm($user, $workspace, []);
// Create 10 views & submissions (in the past of 1 day so that it's cleaned)
for($i=1;$i<=10;$i++){
for ($i = 1; $i <= 10; $i++) {
$submission = $form->submissions()->create();
$submission->created_at = now()->subDay();
$submission->save();
@@ -29,7 +29,7 @@ it('check form statistic for views & submissions counts', function () {
Artisan::call('forms:database-cleanup');
// Create 5 views & submissions
for($i=1;$i<=5;$i++){
for ($i = 1; $i <= 5; $i++) {
$form->views()->create();
$form->submissions()->create();
}
@@ -41,8 +41,8 @@ it('check form statistic for views & submissions counts', function () {
expect($form->views()->count())->toBe(5);
expect($form->submissions()->count())->toBe(16);
expect(count($statistics))->toBe(2); // 1 per day for 2 different dates
expect($statistics[0]["date"])->toBe(now()->subDays(2)->toDateString());
expect($statistics[0]["data"])->toBe(["views"=>1,"submissions"=>1]);
expect($statistics[1]["date"])->toBe(now()->subDay()->toDateString());
expect($statistics[1]["data"])->toBe(["views"=>10,"submissions"=>10]);
});
expect($statistics[0]['date'])->toBe(now()->subDays(2)->toDateString());
expect($statistics[0]['data'])->toBe(['views' => 1, 'submissions' => 1]);
expect($statistics[1]['date'])->toBe(now()->subDay()->toDateString());
expect($statistics[1]['data'])->toBe(['views' => 10, 'submissions' => 10]);
});

View File

@@ -1,7 +1,7 @@
<?php
use Illuminate\Support\Facades\Mail;
use App\Mail\Forms\SubmissionConfirmationMail;
use Illuminate\Support\Facades\Mail;
it('creates confirmation emails with the submitted data', function () {
$user = $this->actingAsUser();
@@ -17,7 +17,7 @@ it('creates confirmation emails with the submitted data', function () {
$formData = [
collect($form->properties)->first(function ($property) {
return $property['type'] == 'email';
})["id"] => "test@test.com",
})['id'] => 'test@test.com',
];
$event = new \App\Events\Forms\FormSubmitted($form, $formData);
$mailable = new SubmissionConfirmationMail($event);
@@ -40,7 +40,7 @@ it('creates confirmation emails without the submitted data', function () {
$formData = [
collect($form->properties)->first(function ($property) {
return $property['type'] == 'email';
})["id"] => "test@test.com",
})['id'] => 'test@test.com',
];
$event = new \App\Events\Forms\FormSubmitted($form, $formData);
$mailable = new SubmissionConfirmationMail($event);
@@ -61,7 +61,7 @@ it('sends a confirmation email if needed', function () {
return $property['type'] == 'email';
});
$formData = [
$emailProperty["id"] => "test@test.com",
$emailProperty['id'] => 'test@test.com',
];
Mail::fake();
@@ -70,13 +70,15 @@ it('sends a confirmation email if needed', function () {
->assertSuccessful()
->assertJson([
'type' => 'success',
'message' => 'Form submission saved.'
'message' => 'Form submission saved.',
]);
Mail::assertQueued(SubmissionConfirmationMail::class,
function (SubmissionConfirmationMail $mail) use ($formData, $emailProperty) {
return $mail->hasTo("test@test.com");
});
Mail::assertQueued(
SubmissionConfirmationMail::class,
function (SubmissionConfirmationMail $mail) {
return $mail->hasTo('test@test.com');
}
);
});
it('does not send a confirmation email if not needed', function () {
@@ -89,7 +91,7 @@ it('does not send a confirmation email if not needed', function () {
return $property['type'] == 'email';
});
$formData = [
$emailProperty["id"] => "test@test.com",
$emailProperty['id'] => 'test@test.com',
];
Mail::fake();
@@ -98,12 +100,13 @@ it('does not send a confirmation email if not needed', function () {
->assertSuccessful()
->assertJson([
'type' => 'success',
'message' => 'Form submission saved.'
'message' => 'Form submission saved.',
]);
Mail::assertNotQueued(SubmissionConfirmationMail::class,
function (SubmissionConfirmationMail $mail) use ($formData, $emailProperty) {
return $mail->hasTo("test@test.com");
});
Mail::assertNotQueued(
SubmissionConfirmationMail::class,
function (SubmissionConfirmationMail $mail) {
return $mail->hasTo('test@test.com');
}
);
});

View File

@@ -1,17 +1,19 @@
<?php
use Tests\Helpers\FormSubmissionDataFactory;
it('can submit form with dyanamic select option', function () {
$user = $this->actingAsUser();
$workspace = $this->createUserWorkspace($user);
$form = $this->createForm($user, $workspace);
$selectionsPreData = [];
$form->properties = collect($form->properties)->map(function ($property) use (&$selectionsPreData) {
if(in_array($property['type'], ['select','multi_select'])){
$property["allow_creation"] = true;
$selectionsPreData[$property['id']] = ($property['type'] == "select") ? "New single select - ".time() : ["New multi select - ".time()];
if (in_array($property['type'], ['select', 'multi_select'])) {
$property['allow_creation'] = true;
$selectionsPreData[$property['id']] = ($property['type'] == 'select') ? 'New single select - '.time() : ['New multi select - '.time()];
}
return $property;
})->toArray();
$form->update();
@@ -21,6 +23,6 @@ it('can submit form with dyanamic select option', function () {
->assertSuccessful()
->assertJson([
'type' => 'success',
'message' => 'Form submission saved.'
'message' => 'Form submission saved.',
]);
});
});

View File

@@ -16,5 +16,5 @@ it('create form with captcha and raise validation issue', function () {
'Please complete the captcha.',
],
],
]);
]);
});

View File

@@ -1,6 +1,6 @@
<?php
use Illuminate\Testing\Fluent\AssertableJson;
use Illuminate\Testing\Fluent\AssertableJson;
it('create form with logic', function () {
$user = $this->actingAsUser();
@@ -8,103 +8,100 @@ it('create form with logic', function () {
$form = $this->createForm($user, $workspace, [
'properties' => [
[
'id' => "title",
'name' => "Name",
'id' => 'title',
'name' => 'Name',
'type' => 'title',
'hidden' => false,
'required' => true,
'logic' => [
"conditions" => [
"operatorIdentifier"=> "and",
"children"=> [
'conditions' => [
'operatorIdentifier' => 'and',
'children' => [
[
"identifier"=> "email",
"value"=> [
"operator"=> "is_empty",
"property_meta"=> [
'id'=> "93ea3198-353f-440b-8dc9-2ac9a7bee124",
"type"=> "email",
'identifier' => 'email',
'value' => [
'operator' => 'is_empty',
'property_meta' => [
'id' => '93ea3198-353f-440b-8dc9-2ac9a7bee124',
'type' => 'email',
],
"value"=> true
]
]
]
'value' => true,
],
],
],
],
"actions" => ['make-it-optional']
]
]
'actions' => ['make-it-optional'],
],
],
],
]);
$this->getJson(route('forms.show', $form->slug))
->assertSuccessful()
->assertJson(function (AssertableJson $json) use ($form) {
return $json->where('id', $form->id)
->where('properties', function($values){
return (count($values[0]['logic']) > 0);
->where('properties', function ($values) {
return count($values[0]['logic']) > 0;
})
->etc();
});
// Should submit form
$forData = ['93ea3198-353f-440b-8dc9-2ac9a7bee124' => ""];
$forData = ['93ea3198-353f-440b-8dc9-2ac9a7bee124' => ''];
$this->postJson(route('forms.answer', $form->slug), $forData)
->assertSuccessful()
->assertJson([
'type' => 'success',
'message' => 'Form submission saved.'
'message' => 'Form submission saved.',
]);
});
it('create form with multi select logic', function () {
$user = $this->actingAsUser();
$workspace = $this->createUserWorkspace($user);
$form = $this->createForm($user, $workspace, [
'properties' => [
[
'id' => "title",
'name' => "Name",
'id' => 'title',
'name' => 'Name',
'type' => 'title',
'hidden' => false,
'required' => false,
'logic' => [
"conditions" => [
"operatorIdentifier"=> "and",
"children"=> [
'conditions' => [
'operatorIdentifier' => 'and',
'children' => [
[
"identifier"=> "multi_select",
"value"=> [
"operator"=> "contains",
"property_meta"=> [
'id'=> "93ea3198-353f-440b-8dc9-2ac9a7bee124",
"type"=> "multi_select",
'identifier' => 'multi_select',
'value' => [
'operator' => 'contains',
'property_meta' => [
'id' => '93ea3198-353f-440b-8dc9-2ac9a7bee124',
'type' => 'multi_select',
],
"value"=> 'One'
]
]
]
'value' => 'One',
],
],
],
],
"actions" => ['require-answer']
]
]
'actions' => ['require-answer'],
],
],
],
]);
$this->getJson(route('forms.show', $form->slug))
->assertSuccessful()
->assertJson(function (AssertableJson $json) use ($form) {
return $json->where('id', $form->id)
->where('properties', function($values){
return (count($values[0]['logic']) > 0);
->where('properties', function ($values) {
return count($values[0]['logic']) > 0;
})
->etc();
});
// Should submit form
$forData = ['93ea3198-353f-440b-8dc9-2ac9a7bee124' => ["One"]];
$forData = ['93ea3198-353f-440b-8dc9-2ac9a7bee124' => ['One']];
$this->postJson(route('forms.answer', $form->slug), $forData)
->assertStatus(422)
->assertJson([
@@ -114,5 +111,5 @@ it('create form with multi select logic', function () {
'The Name field is required.',
],
],
]);
]);
});

View File

@@ -1,10 +1,10 @@
<?php
use Illuminate\Testing\Fluent\AssertableJson;
use Tests\Helpers\FormSubmissionDataFactory;
beforeEach(function () {
$this->password = "12345";
$this->password = '12345';
$user = $this->actingAsUser();
$workspace = $this->createUserWorkspace($user);
$this->form = $this->createForm($user, $workspace, [
@@ -13,7 +13,6 @@ beforeEach(function () {
$this->formData = FormSubmissionDataFactory::generateSubmissionData($this->form);
});
it('can allow form owner to access and submit form without password', function () {
// As Form Owner so can access form without password
$this->getJson(route('forms.show', $this->form->slug))
@@ -30,7 +29,7 @@ it('can allow form owner to access and submit form without password', function (
->assertSuccessful()
->assertJson([
'type' => 'success',
'message' => 'Form submission saved.'
'message' => 'Form submission saved.',
]);
});
@@ -54,26 +53,26 @@ it('can not submit form without password for guest user', function () {
->assertStatus(403)
->assertJson([
'status' => 'Unauthorized',
'message' => 'Form is protected.'
'message' => 'Form is protected.',
]);
});
it('can not submit form with wrong password for guest user', function () {
$this->actingAsGuest();
$this->withHeaders(['form-password'=>hash('sha256', 'WRONGPASSWORD')])
$this->withHeaders(['form-password' => hash('sha256', 'WRONGPASSWORD')])
->postJson(route('forms.answer', $this->form->slug), $this->formData)
->assertStatus(403)
->assertJson([
'status' => 'Unauthorized',
'message' => 'Form is protected.'
'message' => 'Form is protected.',
]);
});
it('can access form with right password for guest user', function () {
$this->actingAsGuest();
$this->withHeaders(['form-password'=>hash('sha256', $this->password)])
$this->withHeaders(['form-password' => hash('sha256', $this->password)])
->getJson(route('forms.show', $this->form->slug))
->assertSuccessful()
->assertJson(function (AssertableJson $json) {
@@ -87,11 +86,11 @@ it('can access form with right password for guest user', function () {
it('can submit form with right password for guest user', function () {
$this->actingAsGuest();
$this->withHeaders(['form-password'=>hash('sha256', $this->password)])
$this->withHeaders(['form-password' => hash('sha256', $this->password)])
->postJson(route('forms.answer', $this->form->slug), $this->formData)
->assertSuccessful()
->assertJson([
'type' => 'success',
'message' => 'Form submission saved.'
'message' => 'Form submission saved.',
]);
});

View File

@@ -1,202 +1,201 @@
<?php
<?php
use App\Rules\FormPropertyLogicRule;
it('can validate form logic rules for actions', function () {
$rules = [
'properties.*.logic' => ['array', 'nullable', new FormPropertyLogicRule()]
'properties.*.logic' => ['array', 'nullable', new FormPropertyLogicRule()],
];
$data = [
'properties' => [
[
'id' => "title",
'name' => "Name",
'id' => 'title',
'name' => 'Name',
'type' => 'title',
'hidden' => false,
'required' => false,
'logic' => [
"conditions" => null,
"actions" => []
]
]
]
'conditions' => null,
'actions' => [],
],
],
],
];
$validatorObj = $this->app['validator']->make($data, $rules);
$this->assertTrue($validatorObj->passes());
$data = [
'properties' => [
[
'id' => "title",
'name' => "Name",
'id' => 'title',
'name' => 'Name',
'type' => 'title',
'hidden' => true,
'required' => false,
'logic' => [
"conditions" => [
"operatorIdentifier"=> "and",
"children"=> [
'conditions' => [
'operatorIdentifier' => 'and',
'children' => [
[
"identifier"=> "title",
"value"=> [
"operator"=> "equals",
"property_meta"=> [
"id"=> "title",
"type"=> "text"
'identifier' => 'title',
'value' => [
'operator' => 'equals',
'property_meta' => [
'id' => 'title',
'type' => 'text',
],
"value"=> "TEST"
]
]
]
'value' => 'TEST',
],
],
],
],
"actions" => ['hide-block']
]
]
]
'actions' => ['hide-block'],
],
],
],
];
$validatorObj = $this->app['validator']->make($data, $rules);
$this->assertFalse($validatorObj->passes());
expect($validatorObj->errors()->messages()['properties.0.logic'][0])->toBe("The logic actions for Name are not valid.");
expect($validatorObj->errors()->messages()['properties.0.logic'][0])->toBe('The logic actions for Name are not valid.');
$data = [
'properties' => [
[
'id' => "text",
'name' => "Custom Test",
'id' => 'text',
'name' => 'Custom Test',
'type' => 'nf-text',
'logic' => [
"conditions" => [
"operatorIdentifier"=> "and",
"children"=> [
'conditions' => [
'operatorIdentifier' => 'and',
'children' => [
[
"identifier"=> "title",
"value"=> [
"operator"=> "equals",
"property_meta"=> [
"id"=> "title",
"type"=> "text"
'identifier' => 'title',
'value' => [
'operator' => 'equals',
'property_meta' => [
'id' => 'title',
'type' => 'text',
],
"value"=> "TEST"
]
]
]
'value' => 'TEST',
],
],
],
],
"actions" => ['require-answer']
]
]
]
'actions' => ['require-answer'],
],
],
],
];
$validatorObj = $this->app['validator']->make($data, $rules);
$this->assertFalse($validatorObj->passes());
expect($validatorObj->errors()->messages()['properties.0.logic'][0])->toBe("The logic actions for Custom Test are not valid.");
expect($validatorObj->errors()->messages()['properties.0.logic'][0])->toBe('The logic actions for Custom Test are not valid.');
});
it('can validate form logic rules for conditions', function () {
$rules = [
'properties.*.logic' => ['array', 'nullable', new FormPropertyLogicRule()]
'properties.*.logic' => ['array', 'nullable', new FormPropertyLogicRule()],
];
$data = [
'properties' => [
[
'id' => "title",
'name' => "Name",
'id' => 'title',
'name' => 'Name',
'type' => 'text',
'hidden' => false,
'required' => false,
'logic' => [
"conditions" => [
"operatorIdentifier"=> "and",
"children"=> [
'conditions' => [
'operatorIdentifier' => 'and',
'children' => [
[
"identifier"=> "title",
"value"=> [
"operator"=> "equals",
"property_meta"=> [
"id"=> "title",
"type"=> "text"
'identifier' => 'title',
'value' => [
'operator' => 'equals',
'property_meta' => [
'id' => 'title',
'type' => 'text',
],
"value"=> "TEST"
]
]
]
'value' => 'TEST',
],
],
],
],
"actions" => ['hide-block']
]
]
]
'actions' => ['hide-block'],
],
],
],
];
$validatorObj = $this->app['validator']->make($data, $rules);
$this->assertTrue($validatorObj->passes());
$data = [
'properties' => [
[
'id' => "title",
'name' => "Name",
'id' => 'title',
'name' => 'Name',
'type' => 'text',
'hidden' => false,
'required' => false,
'logic' => [
"conditions" => [
"operatorIdentifier"=> "and",
"children"=> [
'conditions' => [
'operatorIdentifier' => 'and',
'children' => [
[
"identifier"=> "title",
"value"=> [
"operator"=> "starts_with",
"property_meta"=> [
"id"=> "title",
"type"=> "text"
'identifier' => 'title',
'value' => [
'operator' => 'starts_with',
'property_meta' => [
'id' => 'title',
'type' => 'text',
],
]
]
]
],
],
],
],
"actions" => ['hide-block']
]
]
]
'actions' => ['hide-block'],
],
],
],
];
$validatorObj = $this->app['validator']->make($data, $rules);
$this->assertFalse($validatorObj->passes());
expect($validatorObj->errors()->messages()['properties.0.logic'][0])->toBe("The logic conditions for Name are not complete. Error detail(s): missing condition value");
expect($validatorObj->errors()->messages()['properties.0.logic'][0])->toBe('The logic conditions for Name are not complete. Error detail(s): missing condition value');
$data = [
'properties' => [
[
'id' => "title",
'name' => "Name",
'id' => 'title',
'name' => 'Name',
'type' => 'text',
'hidden' => false,
'required' => false,
'logic' => [
"conditions" => [
"operatorIdentifier"=> null,
"children"=> [
'conditions' => [
'operatorIdentifier' => null,
'children' => [
[
"identifier"=> "title",
"value"=> [
"operator"=> "starts_with",
"property_meta"=> [
"id"=> "title",
"type"=> "text"
'identifier' => 'title',
'value' => [
'operator' => 'starts_with',
'property_meta' => [
'id' => 'title',
'type' => 'text',
],
]
]
]
],
],
],
],
"actions" => ['hide-block']
]
]
]
'actions' => ['hide-block'],
],
],
],
];
$validatorObj = $this->app['validator']->make($data, $rules);
$this->assertFalse($validatorObj->passes());
expect($validatorObj->errors()->messages()['properties.0.logic'][0])->toBe("The logic conditions for Name are not complete. Error detail(s): missing operator");
});
expect($validatorObj->errors()->messages()['properties.0.logic'][0])->toBe('The logic conditions for Name are not complete. Error detail(s): missing operator');
});

View File

@@ -1,4 +1,5 @@
<?php
use Illuminate\Support\Facades\Artisan;
it('check formstat chart data', function () {
@@ -9,7 +10,7 @@ it('check formstat chart data', function () {
$views = [];
$submissions = [];
// Create 10 views & submissions for past days
for($i=1;$i<=10;$i++){
for ($i = 1; $i <= 10; $i++) {
$date = now()->subDays($i);
$dateString = $date->format('d-m-Y');
@@ -28,7 +29,7 @@ it('check formstat chart data', function () {
Artisan::call('forms:database-cleanup');
// Create 5 views & submissions
for($i=1;$i<=5;$i++){
for ($i = 1; $i <= 5; $i++) {
$form->views()->create();
$form->submissions()->create();
@@ -43,20 +44,22 @@ it('check formstat chart data', function () {
->assertJson(function (\Illuminate\Testing\Fluent\AssertableJson $json) use ($views, $submissions) {
return $json->whereType('views', 'array')
->whereType('submissions', 'array')
->where('views', function($values) use ($views) {
foreach($values as $date=>$count){
if((isset($views[$date]) && $views[$date] != $count) || (!isset($views[$date]) && $count != 0)){
->where('views', function ($values) use ($views) {
foreach ($values as $date => $count) {
if ((isset($views[$date]) && $views[$date] != $count) || (! isset($views[$date]) && $count != 0)) {
return false;
}
}
return true;
})
->where('submissions', function($values) use ($submissions) {
foreach($values as $date=>$count){
if((isset($submissions[$date]) && $submissions[$date] != $count) || (!isset($submissions[$date]) && $count != 0)){
->where('submissions', function ($values) use ($submissions) {
foreach ($values as $date => $count) {
if ((isset($submissions[$date]) && $submissions[$date] != $count) || (! isset($submissions[$date]) && $count != 0)) {
return false;
}
}
return true;
})
->etc();

View File

@@ -12,7 +12,7 @@ it('can create a contact form', function () {
->assertSuccessful()
->assertJson([
'type' => 'success',
'message' => 'Form created.'
'message' => 'Form created.',
]);
expect($workspace->forms()->count())->toBe(1);
@@ -47,7 +47,7 @@ it('can update a form', function () {
->assertSuccessful()
->assertJson([
'type' => 'success',
'message' => 'Form updated.'
'message' => 'Form updated.',
]);
$this->assertDatabaseHas('forms', [
@@ -73,10 +73,13 @@ it('can regenerate a form url', function () {
->assertJson(function (AssertableJson $json) {
return $json->where('type', 'success')
->where('form.slug', function ($value) {
if (!is_string($value) || (preg_match('/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/',
$value) !== 1)) {
if (! is_string($value) || (preg_match(
'/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/',
$value
) !== 1)) {
return false;
}
return true;
})
->etc();
@@ -103,7 +106,7 @@ it('can duplicate a form', function () {
->assertSuccessful()
->assertJson([
'type' => 'success',
'message' => 'Form successfully duplicated.'
'message' => 'Form successfully duplicated.',
]);
expect($user->forms()->count())->toBe(2);
@@ -124,7 +127,7 @@ it('can delete a form', function () {
->assertSuccessful()
->assertJson([
'type' => 'success',
'message' => 'Form was deleted.'
'message' => 'Form was deleted.',
]);
expect($user->forms()->count())->toBe(0);
expect($workspace->forms()->count())->toBe(0);
@@ -134,7 +137,7 @@ it('can create form with dark mode', function () {
$user = $this->actingAsUser();
$workspace = $this->createUserWorkspace($user);
$form = $this->createForm($user, $workspace, [
'dark_mode' => "dark",
'dark_mode' => 'dark',
]);
$formData = (new \App\Http\Resources\FormResource($form))->toArray(request());
@@ -142,7 +145,7 @@ it('can create form with dark mode', function () {
->assertSuccessful()
->assertJson([
'type' => 'success',
'message' => 'Form created.'
'message' => 'Form created.',
]);
$this->getJson(route('forms.show', $form->slug))

View File

@@ -11,7 +11,7 @@ it('can update form with existing record', function () {
$nameProperty = collect($form->properties)->filter(function ($property) {
return $property['name'] == 'Name';
})->first();
})->first();
$response = $this->postJson(route('forms.answer', $form->slug), [$nameProperty['id'] => 'Testing'])
->assertSuccessful()
@@ -22,8 +22,8 @@ it('can update form with existing record', function () {
$submissionId = $response->json('submission_id');
expect($submissionId)->toBeString();
if($submissionId){
$formData = FormSubmissionDataFactory::generateSubmissionData($form, ['submission_id'=>$submissionId, $nameProperty['id'] => 'Testing Updated']);
if ($submissionId) {
$formData = FormSubmissionDataFactory::generateSubmissionData($form, ['submission_id' => $submissionId, $nameProperty['id'] => 'Testing Updated']);
$response = $this->postJson(route('forms.answer', $form->slug), $formData)
->assertSuccessful()
->assertJson([
@@ -35,7 +35,7 @@ it('can update form with existing record', function () {
expect($submissionId2)->toBe($submissionId);
$response = $this->getJson(route('forms.fetchSubmission', [$form->slug, $submissionId]))
->assertSuccessful();
->assertSuccessful();
expect($response->json('data.'.$nameProperty['id']))->toBe('Testing Updated');
}
});

View File

@@ -17,7 +17,6 @@ it('can see form without counting view for form owner', function () {
expect($form->views()->count())->toBe(0);
});
it('can see form and count view for guest', function () {
$user = $this->actingAsUser();
$workspace = $this->createUserWorkspace($user);

View File

@@ -1,6 +1,7 @@
<?php
use Tests\Helpers\FormSubmissionDataFactory;
use App\Models\User;
use Tests\Helpers\FormSubmissionDataFactory;
it('can validate Update Workspace Select Option Job', function () {
$user = $this->actingAsUser();
@@ -12,7 +13,7 @@ it('can validate Update Workspace Select Option Job', function () {
->assertSuccessful()
->assertJson([
'type' => 'success',
'message' => 'Form submission saved.'
'message' => 'Form submission saved.',
]);
$formData = FormSubmissionDataFactory::generateSubmissionData($form);
@@ -20,7 +21,7 @@ it('can validate Update Workspace Select Option Job', function () {
->assertSuccessful()
->assertJson([
'type' => 'success',
'message' => 'Form submission saved.'
'message' => 'Form submission saved.',
]);
});
@@ -30,6 +31,6 @@ it('can validate scope with active subscription', function () {
$this->createProUser();
$this->createProUser();
$this->createUser();
expect(User::WithActiveSubscription()->count())->toBe(3);
});
});

View File

@@ -6,9 +6,9 @@ it('can login to Forms', function () {
$user = User::factory()->create();
$this->postJson('/login', [
'email' => $user->email,
'password' => 'password',
])
'email' => $user->email,
'password' => 'password',
])
->assertSuccessful()
->assertJsonStructure(['token', 'expires_in'])
->assertJson(['token_type' => 'bearer']);
@@ -28,11 +28,10 @@ it('can log out', function () {
])->assertSuccessful();
$this->assertAuthenticated();
$this->postJson("/logout")
$this->postJson('/logout')
->assertSuccessful();
$this->assertGuest();
$this->getJson("/user")
$this->getJson('/user')
->assertStatus(401);
});

View File

@@ -1,7 +1,7 @@
<?php
use App\Models\User;
use Tests\TestCase;
use function Pest\Faker\faker;
it('can register', function () {
@@ -11,13 +11,13 @@ it('can register', function () {
'hear_about_us' => 'google',
'password' => 'secret',
'password_confirmation' => 'secret',
'agree_terms' => true
'agree_terms' => true,
])
->assertSuccessful()
->assertJsonStructure(['id', 'name', 'email']);
$this->assertDatabaseHas('users', [
'name' => 'Test User',
'email' => 'test@test.app'
'email' => 'test@test.app',
]);
});
@@ -40,17 +40,17 @@ it('cannot register with disposable email', function () {
'dumliyupse@gufum.com',
'kcs79722@zslsz.com',
'pfizexwxtdifxupdhr@tpwlb.com',
'qvj86ypqfm@email.edu.pl'
'qvj86ypqfm@email.edu.pl',
]);
$this->postJson('/register', [
'name' => 'Test disposable',
'email' => $email,
'hear_about_us' => 'google',
'password' => 'secret',
'password_confirmation' => 'secret',
'agree_terms' => true
])
'name' => 'Test disposable',
'email' => $email,
'hear_about_us' => 'google',
'password' => 'secret',
'password_confirmation' => 'secret',
'agree_terms' => true,
])
->assertStatus(422)
->assertJsonValidationErrors(['email'])
->assertJson([

View File

@@ -2,31 +2,30 @@
use App\Models\User;
use Illuminate\Support\Facades\Hash;
use Tests\TestCase;
it('update profile info',function() {
$this->actingAs($user = User::factory()->create())
->patchJson('/settings/profile', [
'name' => 'Test User',
'email' => 'test@test.app',
])
->assertSuccessful()
->assertJsonStructure(['id', 'name', 'email']);
$this->assertDatabaseHas('users', [
'id' => $user->id,
it('update profile info', function () {
$this->actingAs($user = User::factory()->create())
->patchJson('/settings/profile', [
'name' => 'Test User',
'email' => 'test@test.app',
]);
])
->assertSuccessful()
->assertJsonStructure(['id', 'name', 'email']);
$this->assertDatabaseHas('users', [
'id' => $user->id,
'name' => 'Test User',
'email' => 'test@test.app',
]);
});
it('update password',function() {
$this->actingAs($user = User::factory()->create())
->patchJson('/settings/password', [
'password' => 'updated',
'password_confirmation' => 'updated',
])
->assertSuccessful();
it('update password', function () {
$this->actingAs($user = User::factory()->create())
->patchJson('/settings/password', [
'password' => 'updated',
'password_confirmation' => 'updated',
])
->assertSuccessful();
$this->assertTrue(Hash::check('updated', $user->password));
$this->assertTrue(Hash::check('updated', $user->password));
});

View File

@@ -9,23 +9,23 @@ it('can update form submission', function () {
$form = $this->createForm($user, $workspace, [
'closes_at' => \Carbon\Carbon::now()->addDays(1)->toDateTimeString(),
]);
$formData = FormSubmissionDataFactory::generateSubmissionData($form, ['text' => 'John']);
$formData = FormSubmissionDataFactory::generateSubmissionData($form, ['text' => 'John']);
$textFieldId = array_keys($formData)[0];
$updatedFormData = $formData;
$updatedFormTextValue = "Updated text";
$updatedFormTextValue = 'Updated text';
$updatedFormData[$textFieldId] = $updatedFormTextValue;
$this->postJson(route('forms.answer', $form->slug), $formData)
->assertSuccessful()
->assertJson([
'type' => 'success',
'message' => 'Form submission saved.'
'message' => 'Form submission saved.',
]);
$submission = $form->submissions()->first();
$updateResponse = $this->putJson(route('open.forms.submissions.update', ['id'=>$form->id, 'submission_id' => $submission->id]), $updatedFormData)
$updateResponse = $this->putJson(route('open.forms.submissions.update', ['id' => $form->id, 'submission_id' => $submission->id]), $updatedFormData)
->assertSuccessful()
->assertJson([
'type' => 'success',
'message' => 'Record successfully updated.'
'message' => 'Record successfully updated.',
]);
$expectedTextString = $updateResponse->json('data')['data'][$textFieldId];
expect($expectedTextString)->toBe($updatedFormTextValue);
@@ -34,28 +34,26 @@ it('can update form submission', function () {
});
it('cannot update form submission as non admin', function () {
$secondUser =$this->createUser();
$secondUser = $this->createUser();
$user = $this->actingAsUser();
$workspace = $this->createUserWorkspace($user);
$form = $this->makeForm($user, $workspace);
$form = $this->createForm($user, $workspace, [
'closes_at' => \Carbon\Carbon::now()->addDays(1)->toDateTimeString(),
]);
$formData = FormSubmissionDataFactory::generateSubmissionData($form, ['text' => 'John']);
$formData = FormSubmissionDataFactory::generateSubmissionData($form, ['text' => 'John']);
$textFieldId = array_keys($formData)[0];
$updatedFormData = $formData;
$updatedFormTextValue = "Updated text";
$updatedFormTextValue = 'Updated text';
$updatedFormData[$textFieldId] = $updatedFormTextValue;
$this->postJson(route('forms.answer', $form->slug), $formData)
->assertSuccessful()
->assertJson([
'type' => 'success',
'message' => 'Form submission saved.'
'message' => 'Form submission saved.',
]);
$submission = $form->submissions()->first();
$this->actingAs($secondUser);
$updateResponse = $this->putJson(route('open.forms.submissions.update', ['id'=>$form->id, 'submission_id' => $submission->id]), $updatedFormData)
$updateResponse = $this->putJson(route('open.forms.submissions.update', ['id' => $form->id, 'submission_id' => $submission->id]), $updatedFormData)
->assertStatus(403);
});

View File

@@ -2,7 +2,7 @@
it('can create template', function () {
$user = $this->createUser([
'email' => 'admin@opnform.com'
'email' => 'admin@opnform.com',
]);
$this->actingAsUser($user);
@@ -19,12 +19,12 @@ it('can create template', function () {
'image_url' => 'https://d3ietpyl4f2d18.cloudfront.net/6c35a864-ee3a-4039-80a4-040b6c20ac60/img/pages/welcome/product_cover.jpg',
'publicly_listed' => true,
'form' => $form->getAttributes(),
'questions' => [['question'=>'Question 1','answer'=>'Answer 1 will be here...']]
'questions' => [['question' => 'Question 1', 'answer' => 'Answer 1 will be here...']],
];
$this->postJson(route('templates.create', $templateData))
->assertSuccessful()
->assertJson([
'type' => 'success',
'message' => 'Template was created.'
'message' => 'Template was created.',
]);
});

View File

@@ -1,12 +1,9 @@
<?php
use App\Models\User;
use App\Notifications\VerifyEmail;
use Illuminate\Auth\Events\Verified;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\URL;
use Tests\TestCase;
it('can verify email', function () {
$user = User::factory()->create(['email_verified_at' => null]);

View File

@@ -3,31 +3,31 @@
it('can create and delete Workspace', function () {
$user = $this->actingAsUser();
for($i=1;$i<=3;$i++){
for ($i = 1; $i <= 3; $i++) {
$this->postJson(route('open.workspaces.create'), [
'name' => 'Workspace Test - '.$i,
'icon' => '🧪',
])
'name' => 'Workspace Test - '.$i,
'icon' => '🧪',
])
->assertSuccessful()
->assertJson([
'type' => 'success',
'message' => 'Workspace created.'
'message' => 'Workspace created.',
]);
}
expect($user->workspaces()->count())->toBe(3);
$i=0;
foreach($user->workspaces as $workspace){
$i = 0;
foreach ($user->workspaces as $workspace) {
$i++;
if($i !== 3){
if ($i !== 3) {
$this->deleteJson(route('open.workspaces.delete', $workspace->id))
->assertSuccessful()
->assertJson([
'type' => 'success',
'message' => 'Workspace deleted.'
'message' => 'Workspace deleted.',
]);
}else{
} else {
// Last workspace can not delete
$this->deleteJson(route('open.workspaces.delete', $workspace->id))
->assertStatus(403);

View File

@@ -7,8 +7,7 @@ use Faker;
class FormSubmissionDataFactory
{
private Faker\Generator|null $faker;
private ?Faker\Generator $faker;
public function __construct(private Form $form)
{
@@ -68,24 +67,27 @@ class FormSubmissionDataFactory
private function generateSelectValue($property)
{
$values = [];
if (isset($property["select"]["options"]) && count($property["select"]["options"]) > 0) {
$values = collect($property["select"]["options"])->map(function ($option) {
if (isset($property['select']['options']) && count($property['select']['options']) > 0) {
$values = collect($property['select']['options'])->map(function ($option) {
return $option['name'];
})->toArray();
}
return ($values) ? $this->faker->randomElement($values) : null;
}
private function generateMultiSelectValues($property)
{
$values = [];
if (isset($property["multi_select"]["options"]) && count($property["multi_select"]["options"]) > 0) {
$values = collect($property["multi_select"]["options"])->map(function ($option) {
if (isset($property['multi_select']['options']) && count($property['multi_select']['options']) > 0) {
$values = collect($property['multi_select']['options'])->map(function ($option) {
return $option['name'];
})->toArray();
}
return ($values) ? $this->faker->randomElements(
$values,
$this->faker->numberBetween(1, count($values))) : null;
$this->faker->numberBetween(1, count($values))
) : null;
}
}

View File

@@ -2,14 +2,12 @@
namespace Tests;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Illuminate\Support\Str;
abstract class TestCase extends BaseTestCase
{
use RefreshDatabase;
use CreatesApplication;
use RefreshDatabase;
use TestHelpers;
}

View File

@@ -1,12 +1,10 @@
<?php
namespace Tests;
use App\Models\Forms\Form;
use App\Models\Workspace;
use App\Models\User;
use App\Models\Workspace;
use Database\Factories\FormFactory;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Str;
@@ -15,11 +13,12 @@ trait TestHelpers
{
/**
* Creates a workspace for a user
* @param User $user
*/
public function createUserWorkspace(User $user)
{
if(!$user){ return null; }
if (! $user) {
return null;
}
$workspace = Workspace::create([
'name' => 'Form Testing',
@@ -28,8 +27,8 @@ trait TestHelpers
$user->workspaces()->sync([
$workspace->id => [
'role' => 'admin'
]
'role' => 'admin',
],
], false);
return $workspace;
@@ -37,8 +36,7 @@ trait TestHelpers
/**
* Generates a Form instance (not saved)
* @param User $user
* @param Workspace $workspace
*
* @return array
*/
public function makeForm(User $user, Workspace $workspace, array $data = [])
@@ -48,20 +46,20 @@ trait TestHelpers
'name' => 'Name',
'type' => 'text',
'hidden' => false,
'required' => false
'required' => false,
],
[
'name' => 'Message',
'type' => 'text',
'hidden' => false,
'required' => false,
'multi_lines' => true
'multi_lines' => true,
],
[
'name' => 'Number',
'type' => 'number',
'hidden' => false,
'required' => false
'required' => false,
],
[
'name' => 'Select',
@@ -70,8 +68,8 @@ trait TestHelpers
'required' => false,
'allow_creation' => false,
'select' => [
'options' => [['id' => 'First','name' => 'First'], ['id' => 'Second','name' => 'Second']]
]
'options' => [['id' => 'First', 'name' => 'First'], ['id' => 'Second', 'name' => 'Second']],
],
],
[
'name' => 'Multi Select',
@@ -80,45 +78,45 @@ trait TestHelpers
'required' => false,
'allow_creation' => false,
'multi_select' => [
'options' => [['id' => 'One','name' => 'One'], ['id' => 'Two','name' => 'Two'], ['id' => 'Three','name' => 'Three']]
]
'options' => [['id' => 'One', 'name' => 'One'], ['id' => 'Two', 'name' => 'Two'], ['id' => 'Three', 'name' => 'Three']],
],
],
[
'name' => 'Date',
'type' => 'date',
'hidden' => false,
'required' => false
'required' => false,
],
[
'name' => 'Checkbox',
'type' => 'checkbox',
'hidden' => false,
'required' => false
'required' => false,
],
[
'name' => 'URL',
'type' => 'url',
'hidden' => false,
'required' => false
'required' => false,
],
[
'name' => 'Email',
'type' => 'email',
'hidden' => false,
'required' => false
'required' => false,
],
[
'name' => 'Phone Number',
'type' => 'phone_number',
'hidden' => false,
'required' => false
'required' => false,
],
[
'name' => 'Files',
'type' => 'files',
'hidden' => false,
'required' => false,
]
],
];
return Form::factory()
@@ -132,6 +130,7 @@ trait TestHelpers
{
$form = $this->makeForm($user, $workspace, $data);
$form->save();
return $form;
}
@@ -155,7 +154,7 @@ trait TestHelpers
return $user;
}
public function actingAsUser(User $user = null)
public function actingAsUser(?User $user = null)
{
if ($user == null) {
$user = $this->createUser();
@@ -172,10 +171,9 @@ trait TestHelpers
/**
* Creates a user with a Pro subscription
*
* @param User|null $user
* @return User|\Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Model|null
*/
public function actingAsProUser(User $user = null)
public function actingAsProUser(?User $user = null)
{
if ($user == null) {
$user = $this->createProUser();
@@ -191,5 +189,4 @@ trait TestHelpers
}
$this->assertGuest();
}
}

View File

@@ -1,4 +1,5 @@
<?php
use App\Service\Forms\FormLogicPropertyResolver;
it('can validate form logic property resolver', function ($property, $formData, $expectedResult) {
@@ -7,103 +8,103 @@ it('can validate form logic property resolver', function ($property, $formData,
})->with([
[
[
'id' => "title",
'name' => "Name",
'id' => 'title',
'name' => 'Name',
'type' => 'text',
'hidden' => false,
'required' => true,
'logic' => [
"conditions" => [
"operatorIdentifier"=> "and",
"children"=> [
'conditions' => [
'operatorIdentifier' => 'and',
'children' => [
[
"identifier"=> "user",
"value"=> [
"operator"=> "is_not_empty",
"property_meta"=> [
'id'=> "93ea3198-353f-440b-8dc9-2ac9a7bee124",
"type"=> "select",
'identifier' => 'user',
'value' => [
'operator' => 'is_not_empty',
'property_meta' => [
'id' => '93ea3198-353f-440b-8dc9-2ac9a7bee124',
'type' => 'select',
],
"value"=> true
]
]
]
'value' => true,
],
],
],
],
"actions" => ['make-it-optional']
]
'actions' => ['make-it-optional'],
],
],
['93ea3198-353f-440b-8dc9-2ac9a7bee124'=>["One"]],
false
['93ea3198-353f-440b-8dc9-2ac9a7bee124' => ['One']],
false,
],
[
[
'id' => "title",
'name' => "Name",
'id' => 'title',
'name' => 'Name',
'type' => 'text',
'hidden' => false,
'required' => true,
'logic' => [
"conditions" => [
"operatorIdentifier"=> "and",
"children"=> [
'conditions' => [
'operatorIdentifier' => 'and',
'children' => [
[
"identifier"=> "user",
"value"=> [
"operator"=> "is_not_empty",
"property_meta"=> [
'id'=> "93ea3198-353f-440b-8dc9-2ac9a7bee124",
"type"=> "select",
'identifier' => 'user',
'value' => [
'operator' => 'is_not_empty',
'property_meta' => [
'id' => '93ea3198-353f-440b-8dc9-2ac9a7bee124',
'type' => 'select',
],
"value"=> true
]
]
]
'value' => true,
],
],
],
],
"actions" => ['make-it-optional']
]
'actions' => ['make-it-optional'],
],
],
['93ea3198-353f-440b-8dc9-2ac9a7bee124'=>[]],
true
['93ea3198-353f-440b-8dc9-2ac9a7bee124' => []],
true,
],
[
[
'id' => "title",
'name' => "Name",
'id' => 'title',
'name' => 'Name',
'type' => 'text',
'hidden' => false,
'required' => true,
'logic' => [
"conditions" => [
"operatorIdentifier"=> "or",
"children"=> [
'conditions' => [
'operatorIdentifier' => 'or',
'children' => [
[
"identifier"=> "user",
"value"=> [
"operator"=> "is_not_empty",
"property_meta"=> [
'id'=> "93ea3198-353f-440b-8dc9-2ac9a7bee124",
"type"=> "select",
'identifier' => 'user',
'value' => [
'operator' => 'is_not_empty',
'property_meta' => [
'id' => '93ea3198-353f-440b-8dc9-2ac9a7bee124',
'type' => 'select',
],
"value"=> true
]
'value' => true,
],
],
[
"identifier"=> "email",
"value"=> [
"operator"=> "contains",
"property_meta"=> [
'id'=> "93ea3198-353f-440b-8dc9-2ac9a7bee222",
"type"=> "email",
'identifier' => 'email',
'value' => [
'operator' => 'contains',
'property_meta' => [
'id' => '93ea3198-353f-440b-8dc9-2ac9a7bee222',
'type' => 'email',
],
"value"=> "abc"
]
]
]
'value' => 'abc',
],
],
],
],
"actions" => ['make-it-optional']
]
'actions' => ['make-it-optional'],
],
],
['93ea3198-353f-440b-8dc9-2ac9a7bee124'=>[], '93ea3198-353f-440b-8dc9-2ac9a7bee222'=>['abc']],
false
]
]);
['93ea3198-353f-440b-8dc9-2ac9a7bee124' => [], '93ea3198-353f-440b-8dc9-2ac9a7bee222' => ['abc']],
false,
],
]);

View File

@@ -2,7 +2,7 @@
uses(\Tests\TestCase::class);
use \Illuminate\Support\Str;
use Illuminate\Support\Str;
it('can parse filenames', function () {
$fileName = 'Notion_app_logo_85e16d7b-58ed-43bc-8dce-7d3ff7d69f41.png';

View File

@@ -2,9 +2,6 @@
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();
@@ -19,7 +16,7 @@ it('can create test workspace', function () {
it('can make a form for a database', function () {
$user = $this->actingAsProUser();
$workspace = $this->createUserWorkspace($user);
$form = $this->makeForm($user,$workspace);
$form = $this->makeForm($user, $workspace);
expect($form->title)->not()->toBeNull();
expect($form->description)->not()->toBeNull();
expect(count($form->properties))->not()->toBe(0);