Add Country field to forms
This commit is contained in:
parent
17808c6eb1
commit
144af1bf71
|
@ -0,0 +1,256 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contribution\Enums;
|
||||
|
||||
enum Country: string {
|
||||
case AD = 'Andorra';
|
||||
case AE = 'Vereinigte Arabische Emirate';
|
||||
case AF = 'Afghanistan';
|
||||
case AG = 'Antigua und Barbuda';
|
||||
case AI = 'Anguilla';
|
||||
case AL = 'Albanien';
|
||||
case AM = 'Armenien';
|
||||
case AN = 'Niederländische Antillen';
|
||||
case AO = 'Angola';
|
||||
case AQ = 'Antarktis';
|
||||
case AR = 'Argentinien';
|
||||
case AS = 'Amerikanisch-Samoa';
|
||||
case AT = 'Österreich (Austria)';
|
||||
case AU = 'Australien';
|
||||
case AW = 'Aruba';
|
||||
case AZ = 'Azerbaijan';
|
||||
case BA = 'Bosnien-Herzegovina';
|
||||
case BB = 'Barbados';
|
||||
case BD = 'Bangladesh';
|
||||
case BE = 'Belgien';
|
||||
case BF = 'Burkina Faso';
|
||||
case BG = 'Bulgarien';
|
||||
case BH = 'Bahrain';
|
||||
case BI = 'Burundi';
|
||||
case BJ = 'Benin';
|
||||
case BM = 'Bermudas';
|
||||
case BN = 'Brunei Darussalam';
|
||||
case BO = 'Bolivien';
|
||||
case BR = 'Brasilien';
|
||||
case BS = 'Bahamas';
|
||||
case BT = 'Bhutan';
|
||||
case BV = 'Bouvet Island';
|
||||
case BW = 'Botswana';
|
||||
case BY = 'Weißrußland (Belarus)';
|
||||
case BZ = 'Belize';
|
||||
case CA = 'Canada';
|
||||
case CC = 'Cocos (Keeling) Islands';
|
||||
case CD = 'Demokratische Republik Kongo';
|
||||
case CF = 'Zentralafrikanische Republik';
|
||||
case CG = 'Kongo';
|
||||
case CH = 'Schweiz';
|
||||
case CI = 'Elfenbeinküste (Cote D’Ivoire)';
|
||||
case CK = 'Cook Islands';
|
||||
case CL = 'Chile';
|
||||
case CM = 'Kamerun';
|
||||
case CN = 'China';
|
||||
case CO = 'Kolumbien';
|
||||
case CR = 'Costa Rica';
|
||||
case CS = 'Tschechoslowakei (ehemalige)';
|
||||
case CU = 'Kuba';
|
||||
case CV = 'Kap Verde';
|
||||
case CX = 'Christmas Island';
|
||||
case CY = 'Zypern';
|
||||
case CZ = 'Tschechische Republik';
|
||||
case DE = 'Deutschland';
|
||||
case DJ = 'Djibouti';
|
||||
case DK = 'Dänemark';
|
||||
case DM = 'Dominica';
|
||||
case DO = 'Dominikanische Republik';
|
||||
case DZ = 'Algerien';
|
||||
case EC = 'Ecuador';
|
||||
case EE = 'Estland';
|
||||
case EG = 'Ägypten';
|
||||
case EH = 'Westsahara';
|
||||
case ER = 'Eritrea';
|
||||
case ES = 'Spanien';
|
||||
case ET = 'Äthiopien';
|
||||
case FI = 'Finnland';
|
||||
case FJ = 'Fiji';
|
||||
case FK = 'Falkland-Inseln (Malvinas)';
|
||||
case FM = 'Micronesien';
|
||||
case FO = 'Faröer-Inseln';
|
||||
case FR = 'Frankreich';
|
||||
case FX = 'France, Metropolitan';
|
||||
case GA = 'Gabon';
|
||||
case GD = 'Grenada';
|
||||
case GE = 'Georgien';
|
||||
case GF = 'Französisch Guiana';
|
||||
case GH = 'Ghana';
|
||||
case GI = 'Gibraltar';
|
||||
case GL = 'Grönland';
|
||||
case GM = 'Gambia';
|
||||
case GN = 'Guinea';
|
||||
case GP = 'Guadeloupe';
|
||||
case GQ = 'Äquatorialguinea';
|
||||
case GR = 'Griechenland';
|
||||
case GS = 'Südgeorgien und Südliche Sandwich-Inseln';
|
||||
case GT = 'Guatemala';
|
||||
case GU = 'Guam';
|
||||
case GW = 'Guinea-Bissau';
|
||||
case GY = 'Guyana';
|
||||
case HK = 'Kong Hong';
|
||||
case HM = 'Heard und Mc Donald Islands';
|
||||
case HN = 'Honduras';
|
||||
case HT = 'Haiti';
|
||||
case HU = 'Ungarn';
|
||||
case ID = 'Indonesien';
|
||||
case IE = 'Irland';
|
||||
case IL = 'Israel';
|
||||
case IN = 'Indien';
|
||||
case IO = 'British Indian Ocean Territory';
|
||||
case IQ = 'Irak';
|
||||
case IR = 'Iran (Islamische Republik)';
|
||||
case IS = 'Island';
|
||||
case IT = 'Italien';
|
||||
case JM = 'Jamaica';
|
||||
case JO = 'Jordanien';
|
||||
case JP = 'Japan';
|
||||
case KE = 'Kenya';
|
||||
case KG = 'Kirgisien';
|
||||
case KH = 'Königreich Kambodscha';
|
||||
case KI = 'Kiribati';
|
||||
case KM = 'Komoren';
|
||||
case KN = 'Saint Kitts und Nevis';
|
||||
case KP = 'Korea, Volksrepublik';
|
||||
case KR = 'Korea';
|
||||
case KW = 'Kuwait';
|
||||
case KY = 'Kayman Islands';
|
||||
case KZ = 'Kasachstan';
|
||||
case LA = 'Laos';
|
||||
case LB = 'Libanon';
|
||||
case LC = 'Saint Lucia';
|
||||
case LI = 'Liechtenstein';
|
||||
case LK = 'Sri Lanka';
|
||||
case LR = 'Liberia';
|
||||
case LS = 'Lesotho';
|
||||
case LT = 'Littauen';
|
||||
case LU = 'Luxemburg';
|
||||
case LV = 'Lettland';
|
||||
case LY = 'Libyen';
|
||||
case MA = 'Marokko';
|
||||
case MC = 'Monaco';
|
||||
case MD = 'Moldavien';
|
||||
case MG = 'Madagaskar';
|
||||
case MH = 'Marshall-Inseln';
|
||||
case MK = 'Mazedonien, ehem. Jugoslawische Republik';
|
||||
case ML = 'Mali';
|
||||
case MM = 'Myanmar';
|
||||
case MN = 'Mongolei';
|
||||
case MO = 'Macao';
|
||||
case MP = 'Nördliche Marianneninseln';
|
||||
case MQ = 'Martinique';
|
||||
case MR = 'Mauretanien';
|
||||
case MS = 'Montserrat';
|
||||
case MT = 'Malta';
|
||||
case MU = 'Mauritius';
|
||||
case MV = 'Malediven';
|
||||
case MW = 'Malawi';
|
||||
case MX = 'Mexico';
|
||||
case MY = 'Malaysien';
|
||||
case MZ = 'Mozambique';
|
||||
case NA = 'Namibia';
|
||||
case NC = 'Neu Kaledonien';
|
||||
case NE = 'Niger';
|
||||
case NF = 'Norfolk Island';
|
||||
case NG = 'Nigeria';
|
||||
case NI = 'Nicaragua';
|
||||
case NL = 'Niederlande';
|
||||
case NO = 'Norwegen';
|
||||
case NP = 'Nepal';
|
||||
case NR = 'Nauru';
|
||||
case NU = 'Niue';
|
||||
case NZ = 'Neuseeland';
|
||||
case OM = 'Oman';
|
||||
case PA = 'Panama';
|
||||
case PE = 'Peru';
|
||||
case PF = 'Französisch Polynesien';
|
||||
case PG = 'Papua Neuguinea';
|
||||
case PH = 'Philippinen';
|
||||
case PK = 'Pakistan';
|
||||
case PL = 'Polen';
|
||||
case PM = 'St. Pierre und Miquelon';
|
||||
case PN = 'Pitcairn';
|
||||
case PR = 'Puerto Rico';
|
||||
case PT = 'Portugal';
|
||||
case PW = 'Palau';
|
||||
case PY = 'Paraguay';
|
||||
case QA = 'Katar';
|
||||
case RE = 'Reunion';
|
||||
case RO = 'Rumänien';
|
||||
case RU = 'Russische Föderation';
|
||||
case RW = 'Ruanda';
|
||||
case SA = 'Saudi Arabien';
|
||||
case SB = 'Salomonen';
|
||||
case SC = 'Seychellen';
|
||||
case SD = 'Sudan';
|
||||
case SE = 'Schweden';
|
||||
case SG = 'Singapur';
|
||||
case SH = 'St. Helena';
|
||||
case SI = 'Slovenien';
|
||||
case SJ = 'Svalbard und Jan Mayen Islands';
|
||||
case SK = 'Slowakei';
|
||||
case SL = 'Sierra Leone';
|
||||
case SM = 'San Marino';
|
||||
case SN = 'Senegal';
|
||||
case SO = 'Somalia';
|
||||
case SR = 'Surinam';
|
||||
case ST = 'Sao Tome und Principe';
|
||||
case SV = 'El Salvador';
|
||||
case SY = 'Syrien, Arabische Republik';
|
||||
case SZ = 'Swaziland';
|
||||
case TC = 'Turk und Caicos-Inseln';
|
||||
case TD = 'Tschad';
|
||||
case TF = 'Französisches Südl.Territorium';
|
||||
case TG = 'Togo';
|
||||
case TH = 'Thailand';
|
||||
case TJ = 'Tadschikistan';
|
||||
case TK = 'Tokelau';
|
||||
case TM = 'Turkmenistan';
|
||||
case TN = 'Tunesien';
|
||||
case TO = 'Tonga';
|
||||
case TP = 'Ost-Timor';
|
||||
case TR = 'Türkei';
|
||||
case TT = 'Trinidad und Tobago';
|
||||
case TV = 'Tuvalu';
|
||||
case TW = 'Taiwan';
|
||||
case TZ = 'Tansania, United Republic of';
|
||||
case UA = 'Ukraine';
|
||||
case UG = 'Uganda';
|
||||
case GB = 'Großbritannien';
|
||||
case US = 'Vereinigte Staaten';
|
||||
case UM = 'Vereinigte Staaten, Minor Outlying Islands';
|
||||
case UY = 'Uruguay';
|
||||
case UZ = 'Usbekistan';
|
||||
case VA = 'Vatikanstaat';
|
||||
case VC = 'Saint Vincent und Grenadines';
|
||||
case VE = 'Venezuela';
|
||||
case VG = 'Virgin Islands (Britisch)';
|
||||
case VI = 'Virgin Islands (U.S.)';
|
||||
case VN = 'Vietnam';
|
||||
case VU = 'Vanuatu';
|
||||
case WF = 'Wallis und Futuna Islands';
|
||||
case WS = 'Samoa';
|
||||
case YE = 'Jemen';
|
||||
case YT = 'Mayotte';
|
||||
case YU = 'Jugoslawien';
|
||||
case ZA = 'Südafrika';
|
||||
case ZM = 'Sambia';
|
||||
case ZW = 'Zimbabw';
|
||||
|
||||
/**
|
||||
* @return array<int, array{name: string, id: string}>
|
||||
*/
|
||||
public static function forSelect(): array
|
||||
{
|
||||
return collect(static::cases())
|
||||
->map(fn ($case) => ['id' => $case->value, 'name' => $case->value])
|
||||
->toArray();
|
||||
}
|
||||
}
|
||||
|
|
@ -38,6 +38,7 @@ class FormStoreAction
|
|||
'prevention_conditions' => 'array',
|
||||
'zip' => 'present|nullable|string',
|
||||
'location' => 'present|nullable|string',
|
||||
'country' => 'nullable|string|max:255',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ class FormUpdateAction
|
|||
'prevention_conditions' => 'array',
|
||||
'location' => 'present|nullable|string',
|
||||
'zip' => 'present|nullable|string',
|
||||
'country' => 'nullable|string|max:255',
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Form\Models;
|
||||
|
||||
use App\Contribution\Enums\Country;
|
||||
use App\Form\Actions\UpdateParticipantSearchIndexAction;
|
||||
use App\Form\Data\ExportData;
|
||||
use App\Form\Data\FieldCollection;
|
||||
|
@ -48,6 +49,7 @@ class Form extends Model implements HasMedia
|
|||
'to' => 'datetime',
|
||||
'registration_from' => 'datetime',
|
||||
'registration_until' => 'datetime',
|
||||
'country' => Country::class
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -68,7 +70,6 @@ class Form extends Model implements HasMedia
|
|||
return $this->hasMany(Participant::class);
|
||||
}
|
||||
|
||||
|
||||
public function registerMediaCollections(): void
|
||||
{
|
||||
$this->addMediaCollection('headerImage')
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Form\Resources;
|
||||
|
||||
use App\Contribution\Enums\Country;
|
||||
use App\Form\Data\ExportData;
|
||||
use App\Form\Enums\NamiType;
|
||||
use App\Form\Enums\SpecialType;
|
||||
|
@ -55,6 +56,7 @@ class FormResource extends JsonResource
|
|||
'prevention_conditions' => $this->prevention_conditions,
|
||||
'zip' => $this->zip,
|
||||
'location' => $this->location,
|
||||
'country' => $this->country,
|
||||
'links' => [
|
||||
'participant_index' => route('form.participant.index', ['form' => $this->getModel(), 'parent' => null]),
|
||||
'participant_root_index' => route('form.participant.index', ['form' => $this->getModel(), 'parent' => -1]),
|
||||
|
@ -85,6 +87,7 @@ class FormResource extends JsonResource
|
|||
'templates' => FormtemplateResource::collection(Formtemplate::get()),
|
||||
'namiTypes' => NamiType::forSelect(),
|
||||
'specialTypes' => SpecialType::forSelect(),
|
||||
'countries' => Country::forSelect(),
|
||||
'default' => [
|
||||
'description' => [],
|
||||
'is_active' => true,
|
||||
|
@ -106,6 +109,7 @@ class FormResource extends JsonResource
|
|||
'prevention_conditions' => ['mode' => 'all', 'ifs' => []],
|
||||
'zip' => '',
|
||||
'location' => '',
|
||||
'country' => null,
|
||||
],
|
||||
'section_default' => [
|
||||
'name' => '',
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('forms', function (Blueprint $table) {
|
||||
$table->string('country')->nullable()->after('location');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('forms', function (Blueprint $table) {
|
||||
$table->dropColumn('country');
|
||||
});
|
||||
}
|
||||
};
|
|
@ -20,14 +20,15 @@
|
|||
<ui-popup v-if="single !== null && single.config !== null" :heading="`Veranstaltung ${single.id ? 'bearbeiten' : 'erstellen'}`" full @close="cancel">
|
||||
<div class="flex flex-col mt-3">
|
||||
<ui-tabs v-model="active" :entries="tabs" />
|
||||
<div v-show="active === 0" class="grid grid-cols-2 gap-3">
|
||||
<div class="flex space-x-3">
|
||||
<div v-show="active === 0" class="grid grid-cols-4 gap-3">
|
||||
<div class="flex space-x-3 col-span-2">
|
||||
<f-text id="name" v-model="single.name" class="grow" label="Name" required />
|
||||
<f-switch id="is_active" v-model="single.is_active" name="is_active" label="Aktiv" />
|
||||
<f-switch id="is_private" v-model="single.is_private" name="is_private" label="Privat" />
|
||||
</div>
|
||||
<f-singlefile id="header_image"
|
||||
v-model="single.header_image"
|
||||
class="col-span-2"
|
||||
label="Bild"
|
||||
name="header_image"
|
||||
parent-name="form"
|
||||
|
@ -35,14 +36,11 @@
|
|||
collection="headerImage"
|
||||
required
|
||||
/>
|
||||
<div class="grid gap-3 grid-cols-2">
|
||||
<f-text id="from" v-model="single.from" type="date" label="Von" required />
|
||||
<f-text id="to" v-model="single.to" type="date" label="Bis" required />
|
||||
</div>
|
||||
<div class="grid gap-3 grid-cols-2">
|
||||
<f-text id="zip" v-model="single.zip" label="PLZ" />
|
||||
<f-text id="location" v-model="single.location" label="Ort" />
|
||||
</div>
|
||||
<f-text id="from" v-model="single.from" type="date" label="Von" required />
|
||||
<f-text id="to" v-model="single.to" type="date" label="Bis" required />
|
||||
<f-text id="zip" v-model="single.zip" label="PLZ" />
|
||||
<f-text id="location" v-model="single.location" label="Ort" />
|
||||
<f-select id="country" v-model="single.country" class="col-span-2" name="country" label="Land" :options="meta.countries" />
|
||||
<f-text id="registration_from" v-model="single.registration_from" type="datetime-local" label="Registrierung von" required />
|
||||
<f-text id="registration_until" v-model="single.registration_until" type="datetime-local" label="Registrierung bis" required />
|
||||
<f-textarea id="excerpt"
|
||||
|
@ -50,6 +48,7 @@
|
|||
hint="Gebe hier eine kurze Beschreibung für die Veranstaltungs-Übersicht ein (Maximal 130 Zeichen)."
|
||||
label="Auszug"
|
||||
:rows="5"
|
||||
class="col-span-full"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Tests\EndToEnd\Form;
|
||||
|
||||
use App\Contribution\Enums\Country;
|
||||
use App\Fileshare\Data\FileshareResourceData;
|
||||
use App\Form\Data\ExportData;
|
||||
use App\Form\FormSettings;
|
||||
|
@ -11,192 +12,192 @@ use App\Form\Models\Participant;
|
|||
use Carbon\Carbon;
|
||||
use Tests\Feature\Form\FormtemplateSectionRequest;
|
||||
use Tests\RequestFactories\EditorRequestFactory;
|
||||
use Tests\Lib\CreatesFormFields;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Tests\EndToEndTestCase;
|
||||
|
||||
class FormIndexActionTest extends FormTestCase
|
||||
{
|
||||
uses(CreatesFormFields::class);
|
||||
uses(DatabaseTransactions::class);
|
||||
uses(EndToEndTestCase::class);
|
||||
|
||||
public function testItDisplaysForms(): void
|
||||
{
|
||||
Carbon::setTestNow(Carbon::parse('2023-03-03'));
|
||||
$this->login()->loginNami()->withoutExceptionHandling();
|
||||
$form = Form::factory()
|
||||
->name('lala')
|
||||
->excerpt('fff')
|
||||
->description(EditorRequestFactory::new()->text(10, 'desc'))
|
||||
->from('2023-05-05')
|
||||
->to('2023-06-07')
|
||||
->mailTop(EditorRequestFactory::new()->text(10, 'Guten Tag'))
|
||||
->mailBottom(EditorRequestFactory::new()->text(10, 'Cheers'))
|
||||
->registrationFrom('2023-05-06 04:00:00')
|
||||
->registrationUntil('2023-04-01 05:00:00')
|
||||
->sections([FormtemplateSectionRequest::new()->name('sname')->fields([$this->textField()])])
|
||||
->has(Participant::factory()->count(5))
|
||||
->zip('12345')
|
||||
->location('SG')
|
||||
->create();
|
||||
it('testItDisplaysForms', function () {
|
||||
Carbon::setTestNow(Carbon::parse('2023-03-03'));
|
||||
$this->login()->loginNami()->withoutExceptionHandling();
|
||||
$form = Form::factory()
|
||||
->name('lala')
|
||||
->excerpt('fff')
|
||||
->description(EditorRequestFactory::new()->text(10, 'desc'))
|
||||
->from('2023-05-05')
|
||||
->to('2023-06-07')
|
||||
->mailTop(EditorRequestFactory::new()->text(10, 'Guten Tag'))
|
||||
->mailBottom(EditorRequestFactory::new()->text(10, 'Cheers'))
|
||||
->registrationFrom('2023-05-06 04:00:00')
|
||||
->registrationUntil('2023-04-01 05:00:00')
|
||||
->sections([FormtemplateSectionRequest::new()->name('sname')->fields([$this->textField()])])
|
||||
->has(Participant::factory()->count(5))
|
||||
->zip('12345')
|
||||
->location('SG')
|
||||
->country(Country::CH)
|
||||
->create();
|
||||
|
||||
sleep(1);
|
||||
$this->get(route('form.index'))
|
||||
->assertOk()
|
||||
->assertInertiaPath('data.data.0.name', 'lala')
|
||||
->assertInertiaPath('data.data.0.config.sections.0.name', 'sname')
|
||||
->assertInertiaPath('data.data.0.id', $form->id)
|
||||
->assertInertiaPath('data.data.0.excerpt', 'fff')
|
||||
->assertInertiaPath('data.data.0.description.blocks.0.data.text', 'desc')
|
||||
->assertInertiaPath('data.data.0.mail_top.blocks.0.data.text', 'Guten Tag')
|
||||
->assertInertiaPath('data.data.0.mail_bottom.blocks.0.data.text', 'Cheers')
|
||||
->assertInertiaPath('data.data.0.from_human', '05.05.2023')
|
||||
->assertInertiaPath('data.data.0.to_human', '07.06.2023')
|
||||
->assertInertiaPath('data.data.0.from', '2023-05-05')
|
||||
->assertInertiaPath('data.data.0.zip', '12345')
|
||||
->assertInertiaPath('data.data.0.location', 'SG')
|
||||
->assertInertiaPath('data.data.0.participants_count', 5)
|
||||
->assertInertiaPath('data.data.0.to', '2023-06-07')
|
||||
->assertInertiaPath('data.data.0.is_active', true)
|
||||
->assertInertiaPath('data.data.0.is_private', false)
|
||||
->assertInertiaPath('data.data.0.registration_from', '2023-05-06 04:00:00')
|
||||
->assertInertiaPath('data.data.0.needs_prevention', false)
|
||||
->assertInertiaPath('data.data.0.registration_until', '2023-04-01 05:00:00')
|
||||
->assertInertiaPath('data.data.0.links.participant_index', route('form.participant.index', ['form' => $form]))
|
||||
->assertInertiaPath('data.data.0.links.export', route('form.export', ['form' => $form]))
|
||||
->assertInertiaPath('data.meta.links.store', route('form.store'))
|
||||
->assertInertiaPath('data.meta.links.formtemplate_index', route('formtemplate.index'))
|
||||
->assertInertiaPath('data.meta.default.name', '')
|
||||
->assertInertiaPath('data.meta.default.prevention_conditions', ['mode' => 'all', 'ifs' => []])
|
||||
->assertInertiaPath('data.meta.default.prevention_text.version', '1.0')
|
||||
->assertInertiaPath('data.meta.default.description', [])
|
||||
->assertInertiaPath('data.meta.default.excerpt', '')
|
||||
->assertInertiaPath('data.meta.default.is_active', true)
|
||||
->assertInertiaPath('data.meta.default.is_private', false)
|
||||
->assertInertiaPath('data.meta.default.mailattachments', [])
|
||||
->assertInertiaPath('data.meta.default.export', ['root' => null, 'group_by' => null, 'to_group_field' => null])
|
||||
->assertInertiaPath('data.meta.default.config', null)
|
||||
->assertInertiaPath('data.meta.base_url', url(''))
|
||||
->assertInertiaPath('data.meta.namiTypes.0', ['id' => 'Vorname', 'name' => 'Vorname'])
|
||||
->assertInertiaPath('data.meta.specialTypes.0', ['id' => 'Vorname', 'name' => 'Vorname'])
|
||||
->assertInertiaPath('data.meta.section_default.name', '')
|
||||
->assertInertiaPath('data.meta.default.zip', '')
|
||||
->assertInertiaPath('data.meta.default.location', '');
|
||||
}
|
||||
sleep(1);
|
||||
$this->get(route('form.index'))
|
||||
->assertOk()
|
||||
->assertInertiaPath('data.data.0.name', 'lala')
|
||||
->assertInertiaPath('data.data.0.config.sections.0.name', 'sname')
|
||||
->assertInertiaPath('data.data.0.id', $form->id)
|
||||
->assertInertiaPath('data.data.0.excerpt', 'fff')
|
||||
->assertInertiaPath('data.data.0.description.blocks.0.data.text', 'desc')
|
||||
->assertInertiaPath('data.data.0.mail_top.blocks.0.data.text', 'Guten Tag')
|
||||
->assertInertiaPath('data.data.0.mail_bottom.blocks.0.data.text', 'Cheers')
|
||||
->assertInertiaPath('data.data.0.from_human', '05.05.2023')
|
||||
->assertInertiaPath('data.data.0.to_human', '07.06.2023')
|
||||
->assertInertiaPath('data.data.0.from', '2023-05-05')
|
||||
->assertInertiaPath('data.data.0.zip', '12345')
|
||||
->assertInertiaPath('data.data.0.location', 'SG')
|
||||
->assertInertiaPath('data.data.0.country', 'Schweiz')
|
||||
->assertInertiaPath('data.data.0.participants_count', 5)
|
||||
->assertInertiaPath('data.data.0.to', '2023-06-07')
|
||||
->assertInertiaPath('data.data.0.is_active', true)
|
||||
->assertInertiaPath('data.data.0.is_private', false)
|
||||
->assertInertiaPath('data.data.0.registration_from', '2023-05-06 04:00:00')
|
||||
->assertInertiaPath('data.data.0.needs_prevention', false)
|
||||
->assertInertiaPath('data.data.0.registration_until', '2023-04-01 05:00:00')
|
||||
->assertInertiaPath('data.data.0.links.participant_index', route('form.participant.index', ['form' => $form]))
|
||||
->assertInertiaPath('data.data.0.links.export', route('form.export', ['form' => $form]))
|
||||
->assertInertiaPath('data.meta.links.store', route('form.store'))
|
||||
->assertInertiaPath('data.meta.links.formtemplate_index', route('formtemplate.index'))
|
||||
->assertInertiaPath('data.meta.default.name', '')
|
||||
->assertInertiaPath('data.meta.default.prevention_conditions', ['mode' => 'all', 'ifs' => []])
|
||||
->assertInertiaPath('data.meta.default.prevention_text.version', '1.0')
|
||||
->assertInertiaPath('data.meta.default.description', [])
|
||||
->assertInertiaPath('data.meta.default.excerpt', '')
|
||||
->assertInertiaPath('data.meta.default.zip', '')
|
||||
->assertInertiaPath('data.meta.default.location', '')
|
||||
->assertInertiaPath('data.meta.default.country', null)
|
||||
->assertInertiaPath('data.meta.default.is_active', true)
|
||||
->assertInertiaPath('data.meta.default.is_private', false)
|
||||
->assertInertiaPath('data.meta.default.mailattachments', [])
|
||||
->assertInertiaPath('data.meta.default.export', ['root' => null, 'group_by' => null, 'to_group_field' => null])
|
||||
->assertInertiaPath('data.meta.default.config', null)
|
||||
->assertInertiaPath('data.meta.countries.0.id', 'Andorra')
|
||||
->assertInertiaPath('data.meta.countries.0.name', 'Andorra')
|
||||
->assertInertiaPath('data.meta.base_url', url(''))
|
||||
->assertInertiaPath('data.meta.namiTypes.0', ['id' => 'Vorname', 'name' => 'Vorname'])
|
||||
->assertInertiaPath('data.meta.specialTypes.0', ['id' => 'Vorname', 'name' => 'Vorname'])
|
||||
->assertInertiaPath('data.meta.section_default.name', '')
|
||||
->assertInertiaPath('data.meta.default.zip', '')
|
||||
->assertInertiaPath('data.meta.default.location', '');
|
||||
});
|
||||
|
||||
public function testFormtemplatesHaveData(): void
|
||||
{
|
||||
$this->login()->loginNami()->withoutExceptionHandling();
|
||||
Formtemplate::factory()->name('tname')->sections([FormtemplateSectionRequest::new()->name('sname')->fields([
|
||||
$this->textField('vorname')
|
||||
])])
|
||||
->mailTop(EditorRequestFactory::new()->text(10, 'lala'))
|
||||
->mailBottom(EditorRequestFactory::new()->text(10, 'lalb'))
|
||||
->create();
|
||||
it('testFormtemplatesHaveData', function () {
|
||||
$this->login()->loginNami()->withoutExceptionHandling();
|
||||
Formtemplate::factory()->name('tname')->sections([FormtemplateSectionRequest::new()->name('sname')->fields([
|
||||
$this->textField('vorname')
|
||||
])])
|
||||
->mailTop(EditorRequestFactory::new()->text(10, 'lala'))
|
||||
->mailBottom(EditorRequestFactory::new()->text(10, 'lalb'))
|
||||
->create();
|
||||
|
||||
sleep(1);
|
||||
$this->get(route('form.index'))
|
||||
->assertOk()
|
||||
->assertInertiaPath('data.meta.templates.0.name', 'tname')
|
||||
->assertInertiaPath('data.meta.templates.0.name', 'tname')
|
||||
->assertInertiaPath('data.meta.templates.0.config.sections.0.name', 'sname')
|
||||
->assertInertiaPath('data.meta.templates.0.config.sections.0.fields.0.key', 'vorname')
|
||||
->assertInertiaPath('data.meta.templates.0.mail_top.blocks.0.data.text', 'lala')
|
||||
->assertInertiaPath('data.meta.templates.0.mail_bottom.blocks.0.data.text', 'lalb');
|
||||
}
|
||||
sleep(1);
|
||||
$this->get(route('form.index'))
|
||||
->assertOk()
|
||||
->assertInertiaPath('data.meta.templates.0.name', 'tname')
|
||||
->assertInertiaPath('data.meta.templates.0.name', 'tname')
|
||||
->assertInertiaPath('data.meta.templates.0.config.sections.0.name', 'sname')
|
||||
->assertInertiaPath('data.meta.templates.0.config.sections.0.fields.0.key', 'vorname')
|
||||
->assertInertiaPath('data.meta.templates.0.mail_top.blocks.0.data.text', 'lala')
|
||||
->assertInertiaPath('data.meta.templates.0.mail_bottom.blocks.0.data.text', 'lalb');
|
||||
});
|
||||
|
||||
public function testItDisplaysExport(): void
|
||||
{
|
||||
$this->login()->loginNami()->withoutExceptionHandling();
|
||||
Form::factory()
|
||||
->name('lala')
|
||||
->export(ExportData::from(['root' => FileshareResourceData::from(['connection_id' => 2, 'resource' => '/dir']), 'group_by' => 'lala', 'to_group_field' => 'abc']))
|
||||
->create();
|
||||
it('testItDisplaysExport', function () {
|
||||
$this->login()->loginNami()->withoutExceptionHandling();
|
||||
Form::factory()
|
||||
->name('lala')
|
||||
->export(ExportData::from(['root' => FileshareResourceData::from(['connection_id' => 2, 'resource' => '/dir']), 'group_by' => 'lala', 'to_group_field' => 'abc']))
|
||||
->create();
|
||||
|
||||
sleep(1);
|
||||
$this->get(route('form.index'))
|
||||
->assertInertiaPath('data.data.0.export.group_by', 'lala')
|
||||
->assertInertiaPath('data.data.0.export.root.connection_id', 2)
|
||||
->assertInertiaPath('data.data.0.export.root.resource', '/dir')
|
||||
->assertInertiaPath('data.data.0.export.to_group_field', 'abc');
|
||||
}
|
||||
sleep(1);
|
||||
$this->get(route('form.index'))
|
||||
->assertInertiaPath('data.data.0.export.group_by', 'lala')
|
||||
->assertInertiaPath('data.data.0.export.root.connection_id', 2)
|
||||
->assertInertiaPath('data.data.0.export.root.resource', '/dir')
|
||||
->assertInertiaPath('data.data.0.export.to_group_field', 'abc');
|
||||
});
|
||||
|
||||
public function testItHandlesFullTextSearch(): void
|
||||
{
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
Form::factory()->to(now()->addYear())->name('ZEM 2024')->create();
|
||||
Form::factory()->to(now()->addYear())->name('Rover-Spek 2025')->create();
|
||||
it('testItHandlesFullTextSearch', function () {
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
Form::factory()->to(now()->addYear())->name('ZEM 2024')->create();
|
||||
Form::factory()->to(now()->addYear())->name('Rover-Spek 2025')->create();
|
||||
|
||||
sleep(1);
|
||||
$this->callFilter('form.index', ['search' => 'ZEM'])
|
||||
->assertInertiaCount('data.data', 1);
|
||||
$this->callFilter('form.index', [])
|
||||
->assertInertiaCount('data.data', 2);
|
||||
}
|
||||
sleep(1);
|
||||
$this->callFilter('form.index', ['search' => 'ZEM'])
|
||||
->assertInertiaCount('data.data', 1);
|
||||
$this->callFilter('form.index', [])
|
||||
->assertInertiaCount('data.data', 2);
|
||||
});
|
||||
|
||||
public function testItDisplaysParentLinkForFormWithNamiFields(): void
|
||||
{
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
$form = Form::factory()->fields([$this->namiField('mitglieder')])->create();
|
||||
it('testItDisplaysParentLinkForFormWithNamiFields', function () {
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
$form = Form::factory()->fields([$this->namiField('mitglieder')])->create();
|
||||
|
||||
sleep(1);
|
||||
$this->callFilter('form.index', [])
|
||||
->assertInertiaPath('data.data.0.has_nami_field', true)
|
||||
->assertInertiaPath('data.data.0.links.participant_root_index', route('form.participant.index', ['form' => $form, 'parent' => -1]))
|
||||
->assertInertiaPath('data.data.0.links.participant_index', route('form.participant.index', ['form' => $form, 'parent' => null]));
|
||||
}
|
||||
sleep(1);
|
||||
$this->callFilter('form.index', [])
|
||||
->assertInertiaPath('data.data.0.has_nami_field', true)
|
||||
->assertInertiaPath('data.data.0.links.participant_root_index', route('form.participant.index', ['form' => $form, 'parent' => -1]))
|
||||
->assertInertiaPath('data.data.0.links.participant_index', route('form.participant.index', ['form' => $form, 'parent' => null]));
|
||||
});
|
||||
|
||||
public function testItDisplaysRegisterUrl(): void
|
||||
{
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
FormSettings::fake(['registerUrl' => 'https://example.com/form/{slug}/register']);
|
||||
Form::factory()->to(now()->addYear())->name('ZEM 2024')->create();
|
||||
it('testItDisplaysRegisterUrl', function () {
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
FormSettings::fake(['registerUrl' => 'https://example.com/form/{slug}/register']);
|
||||
Form::factory()->to(now()->addYear())->name('ZEM 2024')->create();
|
||||
|
||||
sleep(1);
|
||||
$this->callFilter('form.index', [])->assertInertiaPath('data.data.0.links.frontend', 'https://example.com/form/zem-2024/register');
|
||||
}
|
||||
sleep(1);
|
||||
$this->callFilter('form.index', [])->assertInertiaPath('data.data.0.links.frontend', 'https://example.com/form/zem-2024/register');
|
||||
});
|
||||
|
||||
public function testItDisplaysCopyUrl(): void
|
||||
{
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
$form = Form::factory()->create();
|
||||
it('testItDisplaysCopyUrl', function () {
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
$form = Form::factory()->create();
|
||||
|
||||
sleep(1);
|
||||
$this->callFilter('form.index', [])->assertInertiaPath('data.data.0.links.copy', route('form.copy', $form));
|
||||
}
|
||||
sleep(1);
|
||||
$this->callFilter('form.index', [])->assertInertiaPath('data.data.0.links.copy', route('form.copy', $form));
|
||||
});
|
||||
|
||||
public function testItDoesntReturnInactiveForms(): void
|
||||
{
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
Form::factory()->isActive(false)->count(1)->create();
|
||||
Form::factory()->isActive(true)->count(2)->create();
|
||||
it('testItDoesntReturnInactiveForms', function () {
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
Form::factory()->isActive(false)->count(1)->create();
|
||||
Form::factory()->isActive(true)->count(2)->create();
|
||||
|
||||
sleep(1);
|
||||
$this->callFilter('form.index', [])->assertInertiaCount('data.data', 2);
|
||||
$this->callFilter('form.index', ['inactive' => true])->assertInertiaCount('data.data', 3);
|
||||
$this->callFilter('form.index', ['inactive' => false])->assertInertiaCount('data.data', 2);
|
||||
}
|
||||
sleep(1);
|
||||
$this->callFilter('form.index', [])->assertInertiaCount('data.data', 2);
|
||||
$this->callFilter('form.index', ['inactive' => true])->assertInertiaCount('data.data', 3);
|
||||
$this->callFilter('form.index', ['inactive' => false])->assertInertiaCount('data.data', 2);
|
||||
});
|
||||
|
||||
public function testItOrdersByStartDateDesc(): void
|
||||
{
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
$form1 = Form::factory()->from(now()->addDays(4))->to(now()->addYear())->create();
|
||||
$form2 = Form::factory()->from(now()->addDays(3))->to(now()->addYear())->create();
|
||||
$form3 = Form::factory()->from(now()->addDays(2))->to(now()->addYear())->create();
|
||||
it('testItOrdersByStartDateDesc', function () {
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
$form1 = Form::factory()->from(now()->addDays(4))->to(now()->addYear())->create();
|
||||
$form2 = Form::factory()->from(now()->addDays(3))->to(now()->addYear())->create();
|
||||
$form3 = Form::factory()->from(now()->addDays(2))->to(now()->addYear())->create();
|
||||
|
||||
sleep(1);
|
||||
$this->callFilter('form.index', [])
|
||||
->assertInertiaPath('data.data.0.id', $form3->id)
|
||||
->assertInertiaPath('data.data.1.id', $form2->id)
|
||||
->assertInertiaPath('data.data.2.id', $form1->id);
|
||||
}
|
||||
sleep(1);
|
||||
$this->callFilter('form.index', [])
|
||||
->assertInertiaPath('data.data.0.id', $form3->id)
|
||||
->assertInertiaPath('data.data.1.id', $form2->id)
|
||||
->assertInertiaPath('data.data.2.id', $form1->id);
|
||||
});
|
||||
|
||||
public function testItShowsPastEvents(): void
|
||||
{
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
Form::factory()->count(5)->to(now()->subDays(2))->create();
|
||||
Form::factory()->count(3)->to(now()->subDays(5))->create();
|
||||
Form::factory()->count(2)->to(now()->addDays(3))->create();
|
||||
it('testItShowsPastEvents', function () {
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
Form::factory()->count(5)->to(now()->subDays(2))->create();
|
||||
Form::factory()->count(3)->to(now()->subDays(5))->create();
|
||||
Form::factory()->count(2)->to(now()->addDays(3))->create();
|
||||
|
||||
sleep(1);
|
||||
$this->callFilter('form.index', ['past' => true])
|
||||
->assertInertiaCount('data.data', 10);
|
||||
$this->callFilter('form.index', [])
|
||||
->assertInertiaCount('data.data', 2);
|
||||
}
|
||||
}
|
||||
sleep(1);
|
||||
$this->callFilter('form.index', ['past' => true])
|
||||
->assertInertiaCount('data.data', 10);
|
||||
$this->callFilter('form.index', [])
|
||||
->assertInertiaCount('data.data', 2);
|
||||
});
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Tests\Feature\Form;
|
||||
|
||||
use App\Contribution\Enums\Country;
|
||||
use App\Fileshare\Data\FileshareResourceData;
|
||||
use App\Form\Data\ExportData;
|
||||
use App\Form\Enums\NamiType;
|
||||
|
@ -34,6 +35,7 @@ it('testItStoresForm', function () {
|
|||
->headerImage('htzz.jpg')
|
||||
->zip('12345')
|
||||
->location('Solingen')
|
||||
->country('Schweiz')
|
||||
->sections([FormtemplateSectionRequest::new()->name('sname')->fields([$this->textField()->namiType(NamiType::BIRTHDAY)->forMembers(false)->hint('hhh')])])
|
||||
->fake();
|
||||
|
||||
|
@ -59,6 +61,7 @@ it('testItStoresForm', function () {
|
|||
$this->assertEquals('formname.jpg', $form->getMedia('headerImage')->first()->file_name);
|
||||
$this->assertEquals('Solingen', $form->location);
|
||||
$this->assertEquals('12345', $form->zip);
|
||||
$this->assertEquals(Country::CH, $form->country);
|
||||
Event::assertDispatched(Succeeded::class, fn(Succeeded $event) => $event->message === 'Veranstaltung gespeichert.');
|
||||
$this->assertFrontendCacheCleared();
|
||||
});
|
||||
|
|
|
@ -118,16 +118,17 @@ it('testItUpdatesActiveState', function () {
|
|||
$this->assertTrue($form->fresh()->is_active);
|
||||
});
|
||||
|
||||
it('updates zip and location', function () {
|
||||
it('updates meta info', function () {
|
||||
$this->login()->loginNami()->withoutExceptionHandling();
|
||||
$form = Form::factory()->create();
|
||||
$request = FormRequest::new()->zip('12345')->location('Musterstadt')->create();
|
||||
$request = FormRequest::new()->zip('12345')->location('Musterstadt')->country('Schweiz')->create();
|
||||
|
||||
$this->patchJson(route('form.update', ['form' => $form]), $request)->assertOk();
|
||||
test()->assertDatabaseHas('forms', [
|
||||
'id' => $form->id,
|
||||
'zip' => '12345',
|
||||
'location' => 'Musterstadt',
|
||||
'country' => 'Schweiz',
|
||||
]);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue