Compare commits

...

9 Commits

Author SHA1 Message Date
philipp lang c6072a6ac3 --wip-- [skip ci] 2024-09-12 22:42:27 +02:00
philipp lang 3830f3d1d4 Remove tests for member create and edit 2024-09-12 22:42:27 +02:00
philipp lang 6d102d9319 Fix tests 2024-09-12 22:42:27 +02:00
philipp lang 18a786bf1e Remove edit route from searchable array 2024-09-12 22:42:27 +02:00
philipp lang c058a1b78a Fix UpdateTest 2024-09-12 22:42:27 +02:00
philipp lang 4b73c79139 Fix member links 2024-09-12 22:42:27 +02:00
philipp lang 2023011b75 Remove member create and edit routes 2024-09-12 22:42:27 +02:00
philipp lang b335c20777 Update CHANGELOG
continuous-integration/drone/tag Build is passing Details
continuous-integration/drone/push Build is passing Details
2024-09-12 11:17:45 +02:00
philipp lang c63c8316b5 Update adrema-form
continuous-integration/drone/push Build is passing Details
2024-09-12 11:15:58 +02:00
17 changed files with 335 additions and 481 deletions

View File

@ -1,5 +1,9 @@
# Letzte Änderungen # Letzte Änderungen
### 1.10.20
- Fixed: Bei Textfeldern wird nun die Einleitung dargestellt
### 1.10.19 ### 1.10.19
- Fixed: Erweiterte Führungszeugnisse und Präventionsschulungen nur für aktive Mitgliedschaften auf Dashboard anzeigen - Fixed: Erweiterte Führungszeugnisse und Präventionsschulungen nur für aktive Mitgliedschaften auf Dashboard anzeigen

View File

@ -4,38 +4,24 @@ namespace App\Member\Actions;
use App\Member\Member; use App\Member\Member;
use App\Member\MemberResource; use App\Member\MemberResource;
use Inertia\Inertia; use Illuminate\Http\JsonResponse;
use Inertia\Response;
use Lorisleiva\Actions\Concerns\AsAction; use Lorisleiva\Actions\Concerns\AsAction;
class MemberShowAction class MemberShowAction
{ {
use AsAction; use AsAction;
/** public function asController(Member $member): JsonResponse
* @return array{data: MemberResource}
*/
public function handle(Member $member): array
{ {
return [ return response()->json([
'data' => new MemberResource( 'data' => new MemberResource($member
$member
->load('memberships') ->load('memberships')
->load('invoicePositions.invoice') ->load('invoicePositions.invoice')
->load('nationality') ->load('nationality')
->load('region') ->load('region')
->load('subscription') ->load('subscription')
->load('courses.course') ->load('courses.course')),
),
'meta' => MemberResource::meta(), 'meta' => MemberResource::meta(),
]; ]);
}
public function asController(Member $member): Response
{
session()->put('menu', 'member');
session()->put('title', 'Mitglied ' . $member->fullname);
return Inertia::render('member/ShowView', $this->handle($member));
} }
} }

View File

@ -538,7 +538,6 @@ class Member extends Model implements Geolocatable
'group_name' => $this->group->inner_name ?: $this->group->name, 'group_name' => $this->group->inner_name ?: $this->group->name,
'links' => [ 'links' => [
'show' => route('member.show', ['member' => $this], false), 'show' => route('member.show', ['member' => $this], false),
'edit' => route('member.edit', ['member' => $this], false),
], ],
'age_group_icon' => $this->ageGroupMemberships->first()?->subactivity->slug, 'age_group_icon' => $this->ageGroupMemberships->first()?->subactivity->slug,
'is_leader' => $this->leaderMemberships()->count() > 0, 'is_leader' => $this->leaderMemberships()->count() > 0,

View File

@ -4,6 +4,7 @@ namespace App\Member;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Setting\NamiSettings; use App\Setting\NamiSettings;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Inertia\Response; use Inertia\Response;
@ -27,17 +28,6 @@ class MemberController extends Controller
]); ]);
} }
public function create(): Response
{
session()->put('menu', 'member');
session()->put('title', 'Mitglied erstellen');
return Inertia::render('member/VForm', [
'mode' => 'create',
'meta' => MemberResource::meta(),
]);
}
public function store(MemberRequest $request, NamiSettings $settings): RedirectResponse public function store(MemberRequest $request, NamiSettings $settings): RedirectResponse
{ {
$request->persistCreate($settings); $request->persistCreate($settings);
@ -45,27 +35,14 @@ class MemberController extends Controller
return redirect()->route('member.index'); return redirect()->route('member.index');
} }
public function edit(Member $member, Request $request): Response public function update(Member $member, MemberRequest $request): JsonResponse
{
session()->put('menu', 'member');
session()->put('title', "Mitglied {$member->firstname} {$member->lastname} bearbeiten");
return Inertia::render('member/VForm', [
'data' => new MemberResource($member),
'mode' => 'edit',
'conflict' => '1' === $request->query('conflict', '0'),
'meta' => MemberResource::meta(),
]);
}
public function update(Member $member, MemberRequest $request): RedirectResponse
{ {
try { try {
$request->persistUpdate($member); $request->persistUpdate($member);
} catch (ConflictException $e) { } catch (ConflictException $e) {
return redirect()->route('member.edit', ['member' => $member, 'conflict' => '1']); return response()->json([], 409);
} }
return redirect()->route('member.index'); return response()->json([]);
} }
} }

View File

@ -111,7 +111,7 @@ class MemberResource extends JsonResource
'invoiceposition_index' => route('member.invoice-position.index', ['member' => $this->getModel()]), 'invoiceposition_index' => route('member.invoice-position.index', ['member' => $this->getModel()]),
'course_index' => route('member.course.index', ['member' => $this->getModel()]), 'course_index' => route('member.course.index', ['member' => $this->getModel()]),
'show' => route('member.show', ['member' => $this->getModel()]), 'show' => route('member.show', ['member' => $this->getModel()]),
'edit' => route('member.edit', ['member' => $this->getModel()]), 'update' => route('member.update', ['member' => $this->getModel()]),
], ],
]; ];
} }
@ -155,7 +155,6 @@ class MemberResource extends JsonResource
'members' => Member::ordered()->get()->map(fn ($member) => ['id' => $member->id, 'name' => $member->fullname]), 'members' => Member::ordered()->get()->map(fn ($member) => ['id' => $member->id, 'name' => $member->fullname]),
'links' => [ 'links' => [
'index' => route('member.index'), 'index' => route('member.index'),
'create' => route('member.create'),
], ],
'default_membership_filter' => [ 'default_membership_filter' => [
'group_ids' => [], 'group_ids' => [],

View File

@ -92,6 +92,8 @@ services:
socketi: socketi:
image: quay.io/soketi/soketi:89604f268623cf799573178a7ba56b7491416bde-16-debian image: quay.io/soketi/soketi:89604f268623cf799573178a7ba56b7491416bde-16-debian
ports:
- '6001:6001'
environment: environment:
SOKETI_DEFAULT_APP_ID: adremaid SOKETI_DEFAULT_APP_ID: adremaid
SOKETI_DEFAULT_APP_KEY: adremakey SOKETI_DEFAULT_APP_KEY: adremakey
@ -104,6 +106,8 @@ services:
meilisearch: meilisearch:
image: getmeili/meilisearch:v1.6 image: getmeili/meilisearch:v1.6
ports:
- '7700:7700'
volumes: volumes:
- ./data/meilisearch:/meili_data - ./data/meilisearch:/meili_data
env_file: env_file:

@ -1 +1 @@
Subproject commit 768cf47bd3f5a6199d178b12ff6fd68e94dd1949 Subproject commit a4a2a2b3fd7a099cf1e5a9360d5d5450030bf673

View File

@ -1,5 +1,5 @@
<template> <template>
<page-layout> <!--
<template #toolbar> <template #toolbar>
<page-toolbar-button :href="meta.links.index" color="primary" icon="undo">zurück</page-toolbar-button> <page-toolbar-button :href="meta.links.index" color="primary" icon="undo">zurück</page-toolbar-button>
<page-toolbar-button v-if="mode === 'edit'" :href="data.links.show" color="primary" icon="eye">anschauen</page-toolbar-button> <page-toolbar-button v-if="mode === 'edit'" :href="data.links.show" color="primary" icon="eye">anschauen</page-toolbar-button>
@ -7,6 +7,7 @@
<template #right> <template #right>
<f-save-button form="memberedit"></f-save-button> <f-save-button form="memberedit"></f-save-button>
</template> </template>
-->
<form id="memberedit" class="flex grow relative" @submit.prevent="submit"> <form id="memberedit" class="flex grow relative" @submit.prevent="submit">
<ui-popup v-if="conflict === true" heading="Ein Konflikt ist aufgetreten"> <ui-popup v-if="conflict === true" heading="Ein Konflikt ist aufgetreten">
<div> <div>
@ -20,7 +21,7 @@
</ui-popup> </ui-popup>
<!-- ***************************** Hauptbereich ****************************** --> <!-- ***************************** Hauptbereich ****************************** -->
<div class="grow grid md:grid-cols-2 gap-3 p-3"> <div class="grow grid md:grid-cols-2 gap-3">
<ui-box heading="Stammdaten"> <ui-box heading="Stammdaten">
<div class="grid sm:grid-cols-2 gap-3"> <div class="grid sm:grid-cols-2 gap-3">
<div class="grid grid-cols-2 gap-3"> <div class="grid grid-cols-2 gap-3">
@ -129,53 +130,71 @@
</ui-box> </ui-box>
</div> </div>
</form> </form>
</page-layout>
</template> </template>
<script> <script setup>
import {ref, computed, inject} from 'vue';
const axios = inject('axios');
function issetComputed(val) { function issetComputed(val) {
return { return {
set(v) { set(v) {
this.inner[val] = v ? '' : null; inner.value[val] = v ? '' : null;
}, },
get() { get() {
return this.inner[val] !== null; return inner.value[val] !== null;
}, },
}; };
} }
export default { const props = defineProps({
props: {
mode: {}, mode: {},
data: {}, data: {},
conflict: {}, conflict: {},
model: {},
meta: {}, meta: {},
}, });
data: function () {
return {
original: this.mode === 'create' ? {...this.meta.default} : {...this.data},
inner: this.mode === 'create' ? {...this.meta.default} : {...this.data},
active: 0,
};
},
methods: { const inner = ref({});
submit() { const original = ref({});
this.mode === 'create' ? this.$inertia.post(`/member`, this.inner) : this.$inertia.patch(`/member/${this.inner.id}`, this.inner); const activeTab = ref(0);
}, const tabs = ref([{title: 'Kontakt'}, {title: 'System'}, {title: 'Prävention'}]);
resync() {
this.$inertia.get(`/member/${this.inner.id}/resync`);
},
forceWrite() {},
},
computed: { async function load() {
hasEfz: issetComputed('efz'), if (props.model.id) {
hasPs: issetComputed('ps_at'), const response = await axios.get(props.model.links.show);
hasMorePs: issetComputed('more_ps_at'), inner.value = response.data.data;
isRecertified: issetComputed('recertified_at'), } else {
hasWithoutEfz: issetComputed('without_efz_at'), inner.value = props.model;
hasWithoutEducation: issetComputed('without_education_at'), original.value = props.model;
}, }
}; }
await load();
// data: function () {
// return {
// original: this.mode === 'create' ? {...this.meta.default} : {...this.data},
// inner: this.mode === 'create' ? {...this.meta.default} : {...this.data},
// };
// },
//
// methods: {
// submit() {
// this.mode === 'create' ? this.$inertia.post(`/member`, this.inner) : this.$inertia.patch(`/member/${this.inner.id}`, this.inner);
// },
// resync() {
// this.$inertia.get(`/member/${this.inner.id}/resync`);
// },
// forceWrite() {},
// },
//
// computed: {
const hasEfz = computed(issetComputed('efz'));
const hasPs = computed(issetComputed('ps_at'));
const hasMorePs = computed(issetComputed('more_ps_at'));
const isRecertified = computed(issetComputed('recertified_at'));
const hasWithoutEfz = computed(issetComputed('without_efz_at'));
const hasWithoutEducation = computed(issetComputed('without_education_at'));
// },
</script> </script>

View File

@ -1,8 +1,11 @@
<template> <template>
<page-layout page-class="pb-6"> <page-layout page-class="pb-6">
<template #toolbar> <template #toolbar>
<page-toolbar-button :href="meta.links.create" color="primary" icon="plus">Mitglied anlegen</page-toolbar-button> <page-toolbar-button color="primary" icon="plus" @click="create">Mitglied anlegen</page-toolbar-button>
</template> </template>
<ui-popup v-if="single !== null" heading="Mitglied erstellen" full @close="cancel">
<v-form :meta="meta" :model="single"></v-form>
</ui-popup>
<ui-popup v-if="deleting !== null" heading="Mitglied löschen?" @close="deleting.reject()"> <ui-popup v-if="deleting !== null" heading="Mitglied löschen?" @close="deleting.reject()">
<div> <div>
<p class="mt-4">Das Mitglied "{{ deleting.member.fullname }}" löschen?</p> <p class="mt-4">Das Mitglied "{{ deleting.member.fullname }}" löschen?</p>
@ -109,7 +112,7 @@
<ui-label :value="member.pending_payment" fallback="---"></ui-label> <ui-label :value="member.pending_payment" fallback="---"></ui-label>
</td> </td>
<td> <td>
<actions :member="member" @sidebar="openSidebar($event, member)" @remove="remove(member)"></actions> <actions :member="member" @sidebar="openSidebar($event, member)" @edit="edit(member)" @remove="remove(member)"></actions>
</td> </td>
</tr> </tr>
</table> </table>
@ -124,7 +127,7 @@
<tags :member="member"></tags> <tags :member="member"></tags>
<ui-label v-show="hasModule('bill')" class="text-gray-100 block" :value="member.pending_payment" fallback=""></ui-label> <ui-label v-show="hasModule('bill')" class="text-gray-100 block" :value="member.pending_payment" fallback=""></ui-label>
</div> </div>
<actions class="mt-2" :member="member" @sidebar="openSidebar($event, member)" @remove="remove(member)"> </actions> <actions class="mt-2" :member="member" @sidebar="openSidebar($event, member)" @edit="edit(member)" @remove="remove(member)"> </actions>
<div class="absolute right-0 top-0 h-full flex items-center mr-2"> <div class="absolute right-0 top-0 h-full flex items-center mr-2">
<i-link v-tooltip="`Details`" :href="member.links.show"><ui-sprite src="chevron" class="w-6 h-6 text-teal-100 -rotate-90"></ui-sprite></i-link> <i-link v-tooltip="`Details`" :href="member.links.show"><ui-sprite src="chevron" class="w-6 h-6 text-teal-100 -rotate-90"></ui-sprite></i-link>
</div> </div>
@ -135,10 +138,10 @@
<ui-pagination class="mt-4" :value="meta" @reload="reloadPage"></ui-pagination> <ui-pagination class="mt-4" :value="meta" @reload="reloadPage"></ui-pagination>
</div> </div>
<ui-sidebar v-if="single !== null" @close="closeSidebar"> <ui-sidebar v-if="sidebar !== null" @close="closeSidebar">
<member-invoice-positions v-if="single.type === 'invoicePosition'" :url="single.model.links.invoiceposition_index" @close="closeSidebar"></member-invoice-positions> <member-invoice-positions v-if="sidebar.type === 'invoicePosition'" :url="sidebar.model.links.invoiceposition_index" @close="closeSidebar"></member-invoice-positions>
<member-memberships v-if="single.type === 'membership'" :url="single.model.links.membership_index" @close="closeSidebar"></member-memberships> <member-memberships v-if="sidebar.type === 'membership'" :url="sidebar.model.links.membership_index" @close="closeSidebar"></member-memberships>
<member-courses v-if="single.type === 'courses'" :url="single.model.links.course_index" @close="closeSidebar"></member-courses> <member-courses v-if="sidebar.type === 'courses'" :url="sidebar.model.links.course_index" @close="closeSidebar"></member-courses>
</ui-sidebar> </ui-sidebar>
</page-layout> </page-layout>
</template> </template>
@ -149,15 +152,16 @@ import MemberMemberships from './MemberMemberships.vue';
import MemberCourses from './MemberCourses.vue'; import MemberCourses from './MemberCourses.vue';
import Tags from './Tags.vue'; import Tags from './Tags.vue';
import Actions from './index/Actions.vue'; import Actions from './index/Actions.vue';
import { indexProps, useIndex } from '../../composables/useIndex.js'; import VForm from './VForm.vue';
import { indexProps, useIndex } from '../../composables/useInertiaApiIndex.js';
import { ref, defineProps } from 'vue'; import { ref, defineProps } from 'vue';
const single = ref(null); const sidebar = ref(null);
const deleting = ref(null); const deleting = ref(null);
const membershipFilters = ref(null); const membershipFilters = ref(null);
const props = defineProps(indexProps); const props = defineProps(indexProps);
var { router, data, meta, getFilter, setFilter, filterString, reloadPage } = useIndex(props.data, 'member'); var { router, data, meta, getFilter, setFilter, filterString, reloadPage, edit, create, single, cancel } = useIndex(props.data, 'member');
function exportMembers() { function exportMembers() {
window.open(`/member-export?filter=${filterString.value}`); window.open(`/member-export?filter=${filterString.value}`);
@ -175,12 +179,12 @@ async function remove(member) {
} }
function openSidebar(type, model) { function openSidebar(type, model) {
single.value = { sidebar.value = {
type: type, type: type,
model: model, model: model,
}; };
} }
function closeSidebar() { function closeSidebar() {
single.value = null; sidebar.value = null;
} }
</script> </script>

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="flex space-x-1"> <div class="flex space-x-1">
<i-link v-tooltip="`Details`" :href="member.links.show" class="inline-flex btn btn-primary btn-sm"><ui-sprite src="eye"></ui-sprite></i-link> <i-link v-tooltip="`Details`" :href="member.links.show" class="inline-flex btn btn-primary btn-sm"><ui-sprite src="eye"></ui-sprite></i-link>
<i-link v-tooltip="`Bearbeiten`" :href="member.links.edit" class="inline-flex btn btn-warning btn-sm"><ui-sprite src="pencil"></ui-sprite></i-link> <a v-tooltip="`Bearbeiten`" class="inline-flex btn btn-warning btn-sm" @click.prevent="$emit('edit')"><ui-sprite src="pencil"></ui-sprite></a>
<a v-show="hasModule('bill')" v-tooltip="`Zahlungen`" href="#" class="inline-flex btn btn-info btn-sm" @click.prevent="$emit('sidebar', 'invoicePosition')" <a v-show="hasModule('bill')" v-tooltip="`Zahlungen`" href="#" class="inline-flex btn btn-info btn-sm" @click.prevent="$emit('sidebar', 'invoicePosition')"
><ui-sprite src="money"></ui-sprite ><ui-sprite src="money"></ui-sprite
></a> ></a>

View File

@ -90,7 +90,7 @@ Route::group(['middleware' => 'auth:web'], function (): void {
Route::post('/nami/search', NamiSearchAction::class)->name('nami.search'); Route::post('/nami/search', NamiSearchAction::class)->name('nami.search');
Route::get('/initialize', InitializeFormAction::class)->name('initialize.form'); Route::get('/initialize', InitializeFormAction::class)->name('initialize.form');
Route::post('/initialize', InitializeAction::class)->name('initialize.store'); Route::post('/initialize', InitializeAction::class)->name('initialize.store');
Route::resource('member', MemberController::class)->except('show', 'destroy'); Route::resource('member', MemberController::class)->except('show', 'destroy', 'edit', 'create');
Route::delete('/member/{member}', MemberDeleteAction::class); Route::delete('/member/{member}', MemberDeleteAction::class);
Route::get('/member/{member}', MemberShowAction::class)->name('member.show'); Route::get('/member/{member}', MemberShowAction::class)->name('member.show');
Route::resource('subscription', SubscriptionController::class); Route::resource('subscription', SubscriptionController::class);

View File

@ -36,9 +36,11 @@ class MemberIndexTest extends EndToEndTestCase
->assertInertiaCount('data.data', 1); ->assertInertiaCount('data.data', 1);
} }
public function testItGetsDefaultCountryFromDefaultModel(): void public function testItGetsDefault(): void
{ {
$this->callFilter('member.index', [])->assertInertiaPath('data.meta.default.country_id', Country::firstWhere('name', 'Deutschland')->id); $this->callFilter('member.index', [])
->assertInertiaPath('data.meta.default.country_id', Country::firstWhere('name', 'Deutschland')->id)
->assertInertiaPath('data.meta.default.address', '');
} }
public function testItHandlesAddress(): void public function testItHandlesAddress(): void
@ -264,4 +266,24 @@ class MemberIndexTest extends EndToEndTestCase
$this->callFilter('member.index', ['hasBirthday' => false, 'exclude' => [$member->id]]) $this->callFilter('member.index', ['hasBirthday' => false, 'exclude' => [$member->id]])
->assertInertiaCount('data.data', 0); ->assertInertiaCount('data.data', 0);
} }
public function testItDisplaysActivityMeta(): void
{
$activity = Activity::factory()->inNami(5)->hasAttached(Subactivity::factory()->inNami(23)->name('Biber'))->name('€ Mitglied')->create();
$subactivity = $activity->subactivities->first();
$this->callFilter('member.index', [])
->assertInertiaPath("data.meta.formSubactivities.{$activity->id}.{$subactivity->id}", 'Biber')
->assertInertiaPath("data.meta.formActivities.{$activity->id}", '€ Mitglied')
->assertInertiaPath('data.meta.billKinds.0', ['id' => 'E-Mail', 'name' => 'E-Mail']);
}
public function testItDoesntDisplayActivitiesAndSubactivitiesNotInNami(): void
{
Activity::factory()->hasAttached(Subactivity::factory()->name('Biber'))->name('€ Mitglied')->create();
$this->callFilter('member.index', [])
->assertInertiaCount('data.meta.formCreateSubactivities', 0)
->assertInertiaCount('data.meta.formCreateActivities', 0);
}
} }

View File

@ -13,11 +13,11 @@ class MemberSearchTest extends EndToEndTestCase
{ {
parent::setUp(); parent::setUp();
Country::factory()->create(['name' => 'Deutschland']); Country::factory()->create(['name' => 'Deutschland']);
$this->withoutExceptionHandling()->login()->loginNami();
} }
public function testItHandlesFullTextSearch(): void public function testItHandlesFullTextSearch(): void
{ {
$this->withoutExceptionHandling()->login()->loginNami();
Member::factory()->defaults()->count(2)->create(['firstname' => 'Alexander']); Member::factory()->defaults()->count(2)->create(['firstname' => 'Alexander']);
Member::factory()->defaults()->create(['firstname' => 'Heinrich']); Member::factory()->defaults()->create(['firstname' => 'Heinrich']);

View File

@ -1,54 +0,0 @@
<?php
namespace Tests\Feature\Member;
use App\Activity;
use App\Country;
use App\Subactivity;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;
class CreateTest extends TestCase
{
use DatabaseTransactions;
public function setUp(): void
{
parent::setUp();
$this->withoutExceptionHandling();
$this->login()->loginNami();
Country::factory()->create(['name' => 'Deutschland']);
}
public function testItDisplaysCreatePage(): void
{
$activity = Activity::factory()->inNami(5)->hasAttached(Subactivity::factory()->inNami(23)->name('Biber'))->name('€ Mitglied')->create();
$subactivity = $activity->subactivities->first();
$response = $this->get(route('member.create'));
$this->assertInertiaHas('Biber', $response, "meta.formSubactivities.{$activity->id}.{$subactivity->id}");
$this->assertInertiaHas('€ Mitglied', $response, "meta.formActivities.{$activity->id}");
$this->assertInertiaHas(['name' => 'E-Mail', 'id' => 'E-Mail'], $response, 'meta.billKinds.0');
$this->assertInertiaHas([
'efz' => null,
'ps_at' => null,
'more_ps_at' => null,
'without_education_at' => null,
'without_efz_at' => null,
'address' => '',
], $response, 'meta.default');
}
public function testItDoesntDisplayActivitiesAndSubactivitiesNotInNami(): void
{
Activity::factory()->hasAttached(Subactivity::factory()->name('Biber'))->name('€ Mitglied')->create();
$response = $this->get(route('member.create'));
$this->assertCount(0, $this->inertia($response, 'meta.formCreateSubactivities'));
$this->assertCount(0, $this->inertia($response, 'meta.formCreateActivities'));
}
}

View File

@ -1,90 +0,0 @@
<?php
namespace Tests\Feature\Member;
use App\Activity;
use App\Country;
use App\Member\Member;
use App\Subactivity;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase;
class EditTest extends TestCase
{
use DatabaseTransactions;
public function setUp(): void
{
parent::setUp();
Country::factory()->create(['name' => 'Deutschland']);
}
public function testItDisplaysEditPage(): void
{
$this->withoutExceptionHandling();
$this->login()->loginNami();
$member = Member::factory()->defaults()->create(['salutation' => 'Doktor', 'firstname' => 'Max', 'comment' => 'Lorem bla']);
$activity = Activity::factory()->inNami(66)->hasAttached(Subactivity::factory()->inNami(56)->name('Biber'))->name('€ Mitglied')->create();
$subactivity = $activity->subactivities->first();
$response = $this->get(route('member.edit', ['member' => $member]));
$this->assertInertiaHas('Biber', $response, "meta.formSubactivities.{$activity->id}.{$subactivity->id}");
$this->assertInertiaHas('€ Mitglied', $response, "meta.formActivities.{$activity->id}");
$this->assertInertiaHas('Max', $response, 'data.firstname');
$this->assertInertiaHas('Doktor', $response, 'data.salutation');
$this->assertInertiaHas('Lorem bla', $response, 'data.comment');
$this->assertInertiaHas('edit', $response, 'mode');
$this->assertInertiaHas(false, $response, 'conflict');
$this->assertInertiaHas(['name' => 'E-Mail', 'id' => 'E-Mail'], $response, 'meta.billKinds.0');
}
public function testItDisplaysEducation(): void
{
$this->withoutExceptionHandling()->login()->loginNami();
$member = Member::factory()
->defaults()
->create([
'efz' => '2022-09-20',
'ps_at' => '2022-04-20',
'more_ps_at' => '2022-06-02',
'without_education_at' => '2022-06-03',
'without_efz_at' => '2022-06-04',
'recertified_at' => '2022-06-04',
'has_vk' => true,
'has_svk' => true,
'multiply_pv' => true,
'multiply_more_pv' => true,
]);
$response = $this->get(route('member.edit', ['member' => $member]));
$this->assertInertiaHas([
'efz' => '2022-09-20',
'ps_at' => '2022-04-20',
'more_ps_at' => '2022-06-02',
'without_education_at' => '2022-06-03',
'without_efz_at' => '2022-06-04',
'recertified_at' => '2022-06-04',
'has_vk' => true,
'has_svk' => true,
'multiply_pv' => true,
'multiply_more_pv' => true,
], $response, 'data');
}
public function testItDisplaysSystem(): void
{
$this->withoutExceptionHandling()->login()->loginNami();
$member = Member::factory()
->defaults()
->emailBillKind()
->create();
$response = $this->get(route('member.edit', ['member' => $member]));
$this->assertInertiaHas([
'bill_kind' => 'E-Mail',
], $response, 'data');
}
}

View File

@ -2,6 +2,7 @@
namespace Tests\Feature\Member; namespace Tests\Feature\Member;
use App\Activity;
use App\Country; use App\Country;
use App\Course\Models\Course; use App\Course\Models\Course;
use App\Course\Models\CourseMember; use App\Course\Models\CourseMember;
@ -14,6 +15,7 @@ use App\Member\Membership;
use App\Nationality; use App\Nationality;
use App\Payment\Subscription; use App\Payment\Subscription;
use App\Region; use App\Region;
use App\Subactivity;
use Carbon\Carbon; use Carbon\Carbon;
use Generator; use Generator;
use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTransactions;
@ -75,70 +77,59 @@ class ShowTest extends TestCase
'mitgliedsnr' => 998, 'mitgliedsnr' => 998,
'lon' => 19.05, 'lon' => 19.05,
'lat' => 14.053, 'lat' => 14.053,
'comment' => 'Lorem bla'
]); ]);
$response = $this->get("/member/{$member->id}"); $this->getJson(route('member.show', ['member' => $member]))
->assertJsonPath('data.firstname', 'Max')
$this->assertInertiaHas([ ->assertJsonPath('data.birthday_human', '20.04.1991')
'birthday_human' => '20.04.1991', ->assertJsonPath('data.age', 14)
'age' => 14, ->assertJsonPath('data.group_name', 'Stamm Beispiel')
'group_name' => 'Stamm Beispiel', ->assertJsonPath('data.full_address', 'Itterstr 3, 42719 Solingen')
'full_address' => 'Itterstr 3, 42719 Solingen', ->assertJsonPath('data.region.name', 'NRW')
'region' => ['name' => 'NRW'], ->assertJsonPath('data.other_country', 'other')
'other_country' => 'other', ->assertJsonPath('data.main_phone', '+49 212 1266775')
'main_phone' => '+49 212 1266775', ->assertJsonPath('data.mobile_phone', '+49 212 1266776')
'mobile_phone' => '+49 212 1266776', ->assertJsonPath('data.work_phone', '+49 212 1266777')
'work_phone' => '+49 212 1266777', ->assertJsonPath('data.children_phone', '+49 212 1266778')
'children_phone' => '+49 212 1266778', ->assertJsonPath('data.email', 'a@b.de')
'email' => 'a@b.de', ->assertJsonPath('data.email_parents', 'b@c.de')
'email_parents' => 'b@c.de', ->assertJsonPath('data.fax', '+49 212 1255674')
'fax' => '+49 212 1255674', ->assertJsonPath('data.fullname', 'Herr Max Muster')
'fullname' => 'Herr Max Muster', ->assertJsonPath('data.efz_human', '20.09.2022')
'efz_human' => '20.09.2022', ->assertJsonPath('data.ps_at_human', '20.04.2022')
'ps_at_human' => '20.04.2022', ->assertJsonPath('data.more_ps_at_human', '02.06.2022')
'more_ps_at_human' => '02.06.2022', ->assertJsonPath('data.without_education_at_human', '03.06.2022')
'without_education_at_human' => '03.06.2022', ->assertJsonPath('data.without_efz_at_human', '04.06.2022')
'without_efz_at_human' => '04.06.2022', ->assertJsonPath('data.recertified_at_human', '13.06.2022')
'recertified_at_human' => '13.06.2022', ->assertJsonPath('data.has_vk', true)
'has_vk' => true, ->assertJsonPath('data.has_svk', true)
'has_svk' => true, ->assertJsonPath('data.multiply_pv', true)
'multiply_pv' => true, ->assertJsonPath('data.multiply_more_pv', true)
'multiply_more_pv' => true, ->assertJsonPath('data.has_nami', true)
'has_nami' => true, ->assertJsonPath('data.nami_id', 123)
'nami_id' => 123, ->assertJsonPath('data.send_newspaper', true)
'send_newspaper' => true, ->assertJsonPath('data.joined_at_human', '11.06.2022')
'joined_at_human' => '11.06.2022', ->assertJsonPath('data.bill_kind_name', 'Post')
'bill_kind_name' => 'Post', ->assertJsonPath('data.mitgliedsnr', 998)
'mitgliedsnr' => 998, ->assertJsonPath('data.lon', 19.05)
'lon' => 19.05, ->assertJsonPath('data.lat', 14.053)
'lat' => 14.053, ->assertJsonPath('data.subscription.name', 'Sub')
'subscription' => [ ->assertJsonPath('data.comment', 'Lorem bla')
'name' => 'Sub', ->assertJsonPath('data.memberships.0.activity_name', '€ LeiterIn')
], ->assertJsonPath('data.memberships.0.subactivity_name', 'Jungpfadfinder')
], $response, 'data'); ->assertJsonPath('data.memberships.0.id', $member->memberships->first()->id)
$this->assertInertiaHas([ ->assertJsonPath('data.memberships.0.human_date', '19.11.2022')
'activity_name' => '€ LeiterIn', ->assertJsonPath('data.memberships.0.promised_at', now()->format('Y-m-d'))
'subactivity_name' => 'Jungpfadfinder', ->assertJsonPath('data.courses.0.organizer', 'DPSG')
'id' => $member->memberships->first()->id, ->assertJsonPath('data.courses.0.event_name', 'Wochenende')
'human_date' => '19.11.2022', ->assertJsonPath('data.courses.0.completed_at_human', '03.03.2022')
'promised_at' => now()->format('Y-m-d'), ->assertJsonPath('data.courses.0.course.name', ' Baustein 2e - Gewalt gegen Kinder und Jugendliche: Vertiefung, Prävention ')
], $response, 'data.memberships.0'); ->assertJsonPath('data.courses.0.course.short_name', '2e')
$this->assertInertiaHas([ ->assertJsonPath('data.invoicePositions.0.description', 'uu')
'organizer' => 'DPSG', ->assertJsonPath('data.invoicePositions.0.price_human', '10,50 €')
'event_name' => 'Wochenende', ->assertJsonPath('data.invoicePositions.0.invoice.status', 'Neu')
'completed_at_human' => '03.03.2022', ->assertJsonPath('data.links.update', route('member.update', ['member' => $member]));
'course' => [
'name' => ' Baustein 2e - Gewalt gegen Kinder und Jugendliche: Vertiefung, Prävention ',
'short_name' => '2e',
],
], $response, 'data.courses.0');
$this->assertInertiaHas([
'description' => 'uu',
'price_human' => '10,50 €',
'invoice' => [
'status' => 'Neu',
]
], $response, 'data.invoicePositions.0');
} }
public function testItShowsMinimalSingleMember(): void public function testItShowsMinimalSingleMember(): void
@ -150,24 +141,14 @@ class ShowTest extends TestCase
->for(Subscription::factory()->forFee()) ->for(Subscription::factory()->forFee())
->create(['firstname' => 'Max', 'lastname' => 'Muster']); ->create(['firstname' => 'Max', 'lastname' => 'Muster']);
$response = $this->get("/member/{$member->id}"); $this->get(route('member.show', ['member' => $member]))
->assertJsonPath('data.has_vk', false)
$this->assertInertiaHas([ ->assertJsonPath('data.has_svk', false)
'region' => ['name' => '-- kein --'], ->assertJsonPath('data.multiply_pv', false)
'fullname' => 'Max Muster', ->assertJsonPath('data.multiply_more_pv', false)
'nationality' => [ ->assertJsonPath('data.nationality.name', 'deutsch')
'name' => 'deutsch', ->assertJsonPath('data.region.name', '-- kein --')
], ->assertJsonPath('data.fullname', 'Max Muster');
'efz_human' => null,
'ps_at_human' => null,
'more_ps_at_human' => null,
'without_education_at_human' => null,
'without_efz_at_human' => null,
'has_vk' => false,
'has_svk' => false,
'multiply_pv' => false,
'multiply_more_pv' => false,
], $response, 'data');
} }
public function membershipDataProvider(): Generator public function membershipDataProvider(): Generator
@ -188,8 +169,21 @@ class ShowTest extends TestCase
->has(Membership::factory()->in('€ LeiterIn', 455, 'Pfadfinder', 15)->state(['from' => $from, 'to' => $to])) ->has(Membership::factory()->in('€ LeiterIn', 455, 'Pfadfinder', 15)->state(['from' => $from, 'to' => $to]))
->create(); ->create();
$response = $this->get("/member/{$member->id}"); $this->get(route('member.show', ['member' => $member]))
->assertJsonPath('data.memberships.0.is_active', $isActive);
}
$this->assertInertiaHas($isActive, $response, 'data.memberships.0.is_active'); public function testItDisplaysMeta(): void
{
$this->withoutExceptionHandling();
$this->login()->loginNami();
$member = Member::factory()->defaults()->create(['salutation' => 'Doktor', 'firstname' => 'Max', 'comment' => 'Lorem bla']);
$activity = Activity::factory()->inNami(66)->hasAttached(Subactivity::factory()->inNami(56)->name('Biber'))->name('€ Mitglied')->create();
$subactivity = $activity->subactivities->first();
$this->get(route('member.show', ['member' => $member]))
->assertJsonPath("meta.formActivities.{$activity->id}", '€ Mitglied')
->assertJsonPath("meta.formSubactivities.{$activity->id}.{$subactivity->id}", 'Biber')
->assertJsonPath("meta.billKinds.0", ['id' => 'E-Mail', 'name' => 'E-Mail']);
} }
} }

View File

@ -30,11 +30,8 @@ class UpdateTest extends TestCase
$this->fakeRequest(); $this->fakeRequest();
NamiPutMemberAction::allowToRun(); NamiPutMemberAction::allowToRun();
$response = $this $this->patch("/member/{$member->id}", array_merge($member->getAttributes(), ['has_nami' => true]));
->from("/member/{$member->id}")
->patch("/member/{$member->id}", array_merge($member->getAttributes(), ['has_nami' => true]));
$response->assertRedirect('/member');
NamiPutMemberAction::spy()->shouldHaveReceived('handle')->withArgs( NamiPutMemberAction::spy()->shouldHaveReceived('handle')->withArgs(
fn (Member $memberParam, ?Activity $activityParam, ?Subactivity $subactivityParam) => $memberParam->is($member) fn (Member $memberParam, ?Activity $activityParam, ?Subactivity $subactivityParam) => $memberParam->is($member)
&& null === $activityParam && null === $activityParam
@ -49,11 +46,8 @@ class UpdateTest extends TestCase
$member->update(['version' => 43]); $member->update(['version' => 43]);
$this->fakeRequest(); $this->fakeRequest();
$response = $this $this->patch("/member/{$member->id}", array_merge($member->getAttributes(), ['has_nami' => true, 'firstname' => '::firstname::']))
->from("/member/{$member->id}") ->assertStatus(409);
->patch("/member/{$member->id}", array_merge($member->getAttributes(), ['has_nami' => true, 'firstname' => '::firstname::']));
$response->assertRedirect("/member/{$member->id}/edit?conflict=1");
} }
public function testItUpdatesPhoneNumber(): void public function testItUpdatesPhoneNumber(): void
@ -99,9 +93,7 @@ class UpdateTest extends TestCase
$member = $this->member(['nami_id' => null]); $member = $this->member(['nami_id' => null]);
$this->fakeRequest(); $this->fakeRequest();
$response = $this $this->patch("/member/{$member->id}", array_merge($member->getAttributes(), [
->from("/member/{$member->id}")
->patch("/member/{$member->id}", array_merge($member->getAttributes(), [
'other_country' => 'englisch', 'other_country' => 'englisch',
])); ]));
@ -158,9 +150,7 @@ class UpdateTest extends TestCase
$member = $this->member(['nami_id' => null]); $member = $this->member(['nami_id' => null]);
$this->fakeRequest(); $this->fakeRequest();
$response = $this $this->patch("/member/{$member->id}", array_merge($member->getAttributes(), [
->from("/member/{$member->id}")
->patch("/member/{$member->id}", array_merge($member->getAttributes(), [
'ps_at' => '2021-02-01', 'ps_at' => '2021-02-01',
'more_ps_at' => '2021-02-02', 'more_ps_at' => '2021-02-02',
'has_svk' => true, 'has_svk' => true,