feat: add data-test attributes for improved testing in various components
This commit is contained in:
@@ -155,6 +155,7 @@ export function ApplicationWorkflow({
|
||||
size="sm"
|
||||
variant="default"
|
||||
disabled={isPending}
|
||||
data-test="application-approve-btn"
|
||||
onClick={() => handleApprove(appId)}
|
||||
>
|
||||
Genehmigen
|
||||
@@ -163,6 +164,7 @@ export function ApplicationWorkflow({
|
||||
size="sm"
|
||||
variant="destructive"
|
||||
disabled={isPending}
|
||||
data-test="application-reject-btn"
|
||||
onClick={() => handleReject(appId)}
|
||||
>
|
||||
Ablehnen
|
||||
|
||||
@@ -145,6 +145,7 @@ export function DuesCategoryManager({
|
||||
<label className="text-sm font-medium">Name *</label>
|
||||
<Input
|
||||
placeholder="z.B. Standardbeitrag"
|
||||
data-test="dues-name-input"
|
||||
{...form.register('name', { required: true })}
|
||||
/>
|
||||
</div>
|
||||
@@ -155,6 +156,7 @@ export function DuesCategoryManager({
|
||||
step="0.01"
|
||||
min="0"
|
||||
placeholder="0.00"
|
||||
data-test="dues-amount-input"
|
||||
{...form.register('amount', {
|
||||
required: true,
|
||||
valueAsNumber: true,
|
||||
@@ -184,7 +186,12 @@ export function DuesCategoryManager({
|
||||
</label>
|
||||
</div>
|
||||
<div className="flex items-end">
|
||||
<Button type="submit" disabled={isCreating} className="w-full">
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={isCreating}
|
||||
className="w-full"
|
||||
data-test="dues-create-btn"
|
||||
>
|
||||
{isCreating ? 'Erstelle...' : 'Erstellen'}
|
||||
</Button>
|
||||
</div>
|
||||
@@ -244,6 +251,7 @@ export function DuesCategoryManager({
|
||||
size="sm"
|
||||
variant="destructive"
|
||||
disabled={isDeletePending}
|
||||
data-test="dues-delete-btn"
|
||||
onClick={() => handleDelete(catId, catName)}
|
||||
>
|
||||
Löschen
|
||||
|
||||
@@ -174,6 +174,7 @@ export function MandateManager({
|
||||
<label className="text-sm font-medium">IBAN *</label>
|
||||
<Input
|
||||
placeholder="DE89 3704 0044 0532 0130 00"
|
||||
data-test="mandate-iban-input"
|
||||
{...form.register('iban', { required: true })}
|
||||
onChange={(e) => {
|
||||
const value = e.target.value
|
||||
@@ -185,12 +186,17 @@ export function MandateManager({
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<label className="text-sm font-medium">BIC</label>
|
||||
<Input placeholder="COBADEFFXXX" {...form.register('bic')} />
|
||||
<Input
|
||||
placeholder="COBADEFFXXX"
|
||||
data-test="mandate-bic-input"
|
||||
{...form.register('bic')}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<label className="text-sm font-medium">Kontoinhaber *</label>
|
||||
<Input
|
||||
placeholder="Max Mustermann"
|
||||
data-test="mandate-holder-input"
|
||||
{...form.register('accountHolder', { required: true })}
|
||||
/>
|
||||
</div>
|
||||
@@ -214,7 +220,11 @@ export function MandateManager({
|
||||
</select>
|
||||
</div>
|
||||
<div className="sm:col-span-2 lg:col-span-3">
|
||||
<Button type="submit" disabled={isCreating}>
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={isCreating}
|
||||
data-test="mandate-create-btn"
|
||||
>
|
||||
{isCreating ? 'Erstelle...' : 'Mandat erstellen'}
|
||||
</Button>
|
||||
</div>
|
||||
@@ -282,6 +292,7 @@ export function MandateManager({
|
||||
size="sm"
|
||||
variant="destructive"
|
||||
disabled={isRevoking}
|
||||
data-test="mandate-revoke-btn"
|
||||
onClick={() => handleRevoke(mandateId, reference)}
|
||||
>
|
||||
Widerrufen
|
||||
|
||||
@@ -136,6 +136,7 @@ export function MemberDetailView({
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
data-test="member-edit-btn"
|
||||
onClick={() =>
|
||||
router.push(`/home/${account}/members-cms/${memberId}/edit`)
|
||||
}
|
||||
@@ -152,6 +153,7 @@ export function MemberDetailView({
|
||||
<Button
|
||||
variant="destructive"
|
||||
disabled={isDeleting}
|
||||
data-test="member-terminate-btn"
|
||||
onClick={handleDelete}
|
||||
>
|
||||
{isDeleting ? 'Wird gekündigt...' : 'Kündigen'}
|
||||
|
||||
@@ -110,9 +110,15 @@ export function MembersDataTable({
|
||||
<Input
|
||||
placeholder="Mitglied suchen..."
|
||||
className="w-64"
|
||||
data-test="members-search-input"
|
||||
{...form.register('search')}
|
||||
/>
|
||||
<Button type="submit" variant="outline" size="sm">
|
||||
<Button
|
||||
type="submit"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
data-test="members-search-btn"
|
||||
>
|
||||
Suchen
|
||||
</Button>
|
||||
</form>
|
||||
@@ -121,6 +127,7 @@ export function MembersDataTable({
|
||||
<select
|
||||
value={currentStatus}
|
||||
onChange={handleStatusChange}
|
||||
data-test="members-status-filter"
|
||||
className="border-input bg-background flex h-9 rounded-md border px-3 py-1 text-sm shadow-sm"
|
||||
>
|
||||
{STATUS_OPTIONS.map((opt) => (
|
||||
@@ -132,6 +139,7 @@ export function MembersDataTable({
|
||||
|
||||
<Button
|
||||
size="sm"
|
||||
data-test="members-new-btn"
|
||||
onClick={() => router.push(`/home/${account}/members-cms/new`)}
|
||||
>
|
||||
Neues Mitglied
|
||||
|
||||
@@ -9,8 +9,12 @@ export function computeAge(
|
||||
const birth = new Date(dateOfBirth);
|
||||
const today = new Date();
|
||||
let age = today.getFullYear() - birth.getFullYear();
|
||||
const m = today.getMonth() - birth.getMonth();
|
||||
if (m < 0 || (m === 0 && today.getDate() < birth.getDate())) age--;
|
||||
const monthDifference = today.getMonth() - birth.getMonth();
|
||||
if (
|
||||
monthDifference < 0 ||
|
||||
(monthDifference === 0 && today.getDate() < birth.getDate())
|
||||
)
|
||||
age--;
|
||||
return age;
|
||||
}
|
||||
|
||||
@@ -21,8 +25,12 @@ export function computeMembershipYears(
|
||||
const entry = new Date(entryDate);
|
||||
const today = new Date();
|
||||
let years = today.getFullYear() - entry.getFullYear();
|
||||
const m = today.getMonth() - entry.getMonth();
|
||||
if (m < 0 || (m === 0 && today.getDate() < entry.getDate())) years--;
|
||||
const monthDifference = today.getMonth() - entry.getMonth();
|
||||
if (
|
||||
monthDifference < 0 ||
|
||||
(monthDifference === 0 && today.getDate() < entry.getDate())
|
||||
)
|
||||
years--;
|
||||
return Math.max(0, years);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user