feat(projects): t-paliad-232 Verfahrenstyp picker + Schriftsätze CTA
Two-part fix from m's 2026-05-21 finding that the Schriftsätze tab
told users "Bitte zuerst einen Verfahrenstyp setzen" while the
project form had no field to set it. The `proceeding_type_id`
column was already on `paliad.projects` and accepted by the API.
Part 1 — Verfahrenstyp picker on the case-fields block
* frontend/src/components/ProjectFormFields.tsx — new optional
<select id="project-proceeding-type-id"> rendered between
Aktenzeichen and Mandantenrolle inside the type=case block.
First option is "(nicht gesetzt)" / "(unset)".
* frontend/src/client/project-form.ts — shared
loadProceedingTypes() + populateProceedingTypeSelect()
helpers. Options sorted by `code` (de.* → dpma.* → epa.* →
upc.*). readPayload sends `proceeding_type_id` only when the
user picked a value; prefillForm restores the saved id via
dataset.preselect to survive the async populate race.
* frontend/src/client/projects-new.ts — kicks off populate on
DOMContentLoaded.
* frontend/src/client/projects-detail.ts — edit-modal preload
now awaits populate; the local loadProceedingTypes duplicate
(used by the counterclaim modal) is replaced by the shared
helper so both surfaces hit the same cache.
Part 2 — Actionable empty-state on the Schriftsätze tab
* frontend/src/projects-detail.tsx — the static <p> empty-state
becomes a div with a "Projekt bearbeiten" button.
* frontend/src/client/projects-detail.ts — openEditModal now
accepts an optional focusFieldID; the new
#project-submissions-edit-cta click handler calls it with
"project-proceeding-type-id" so the picker is scrolled into
view and focused right after the modal opens.
i18n: new keys projects.field.proceeding_type{,.unset,.hint} and
projects.detail.submissions.empty.no_proceeding.cta; reworded
no_proceeding copy to match the new "edit the project" CTA.
Backend already validates via validateProceedingTypeCategory
(mig 087/088 fristenrechner-category guard). Added
TestProjectService_CaseProceedingTypePicker exercising both the
happy and reject paths through a `case`-typed Create.
Manual test path: open any case project → Edit → the Verfahrenstyp
picker shows below Aktenzeichen → save → the Schriftsätze tab now
lists the submission codes. Clicking the empty-state CTA jumps
straight to the picker.
This commit is contained in:
@@ -1335,7 +1335,10 @@ const translations: Record<Lang, Record<string, string>> = {
|
||||
"projects.field.grant_date": "Erteilungstag",
|
||||
"projects.field.court": "Gericht",
|
||||
"projects.field.case_number": "Aktenzeichen (Gericht)",
|
||||
"projects.field.proceeding_type_id": "Verfahrensart",
|
||||
"projects.field.proceeding_type_id": "Verfahrenstyp",
|
||||
"projects.field.proceeding_type": "Verfahrenstyp",
|
||||
"projects.field.proceeding_type.unset": "(nicht gesetzt)",
|
||||
"projects.field.proceeding_type.hint": "Bestimmt, welche Schriftsätze-Vorlagen für dieses Verfahren angezeigt werden.",
|
||||
"projects.field.our_side": "Wir vertreten",
|
||||
"projects.field.our_side.hint": "Bestimmt die Voreinstellung der Perspektive im Fristenrechner-Determinator. Lässt sich dort jederzeit überschreiben.",
|
||||
"projects.field.our_side.unset": "Unbekannt / nicht gesetzt",
|
||||
@@ -1425,7 +1428,8 @@ const translations: Record<Lang, Record<string, string>> = {
|
||||
"projects.detail.export.button": "Daten exportieren",
|
||||
"projects.detail.export.tooltip": "Daten dieses Projekts (mit Unter-Projekten) als Excel + JSON + CSV herunterladen.",
|
||||
"projects.detail.submissions.empty": "Für dieses Verfahren sind keine Schriftsätze hinterlegt.",
|
||||
"projects.detail.submissions.empty.no_proceeding": "Bitte zuerst einen Verfahrenstyp setzen.",
|
||||
"projects.detail.submissions.empty.no_proceeding": "Für dieses Projekt ist noch kein Verfahrenstyp gesetzt. Bitte im Projekt bearbeiten.",
|
||||
"projects.detail.submissions.empty.no_proceeding.cta": "Projekt bearbeiten",
|
||||
"projects.detail.submissions.col.name": "Schriftsatz",
|
||||
"projects.detail.submissions.col.party": "Partei",
|
||||
"projects.detail.submissions.col.source": "Rechtsgrundlage",
|
||||
@@ -4199,6 +4203,9 @@ const translations: Record<Lang, Record<string, string>> = {
|
||||
"projects.field.court": "Court",
|
||||
"projects.field.case_number": "Case number (court)",
|
||||
"projects.field.proceeding_type_id": "Proceeding type",
|
||||
"projects.field.proceeding_type": "Proceeding type",
|
||||
"projects.field.proceeding_type.unset": "(unset)",
|
||||
"projects.field.proceeding_type.hint": "Determines which submission templates show up on this proceeding.",
|
||||
"projects.field.our_side": "We represent",
|
||||
"projects.field.our_side.hint": "Pre-selects the perspective chip in the Fristenrechner Determinator. Always overridable from there.",
|
||||
"projects.field.our_side.unset": "Unknown / not set",
|
||||
@@ -4288,7 +4295,8 @@ const translations: Record<Lang, Record<string, string>> = {
|
||||
"projects.detail.export.button": "Export data",
|
||||
"projects.detail.export.tooltip": "Download this project's data (including sub-projects) as Excel + JSON + CSV.",
|
||||
"projects.detail.submissions.empty": "No submissions are configured for this proceeding.",
|
||||
"projects.detail.submissions.empty.no_proceeding": "Please set a proceeding type first.",
|
||||
"projects.detail.submissions.empty.no_proceeding": "No proceeding type is set for this project yet. Edit the project to choose one.",
|
||||
"projects.detail.submissions.empty.no_proceeding.cta": "Edit project",
|
||||
"projects.detail.submissions.col.name": "Submission",
|
||||
"projects.detail.submissions.col.party": "Party",
|
||||
"projects.detail.submissions.col.source": "Legal basis",
|
||||
|
||||
@@ -1,8 +1,37 @@
|
||||
import { t, tDyn } from "./i18n";
|
||||
import { t, tDyn, getLang } from "./i18n";
|
||||
|
||||
// Shared logic for the Project form rendered by ProjectFormFields.tsx.
|
||||
// Used by /projects/new and the edit modal on /projects/{id}.
|
||||
|
||||
export interface ProceedingTypeRow {
|
||||
id: number;
|
||||
code: string;
|
||||
name: string;
|
||||
name_en: string;
|
||||
jurisdiction?: string;
|
||||
is_active: boolean;
|
||||
}
|
||||
|
||||
let proceedingTypesCache: ProceedingTypeRow[] | null = null;
|
||||
|
||||
// loadProceedingTypes fetches active fristenrechner-category proceeding
|
||||
// types — the only set a project may bind to (mig 087/088 + service
|
||||
// validation guard `validateProceedingTypeCategory`). Cached at module
|
||||
// level so the page only pays for one fetch even when both the new-
|
||||
// project page and the edit modal exercise the picker.
|
||||
export async function loadProceedingTypes(): Promise<ProceedingTypeRow[]> {
|
||||
if (proceedingTypesCache) return proceedingTypesCache;
|
||||
try {
|
||||
const resp = await fetch("/api/proceeding-types-db?category=fristenrechner");
|
||||
if (!resp.ok) return [];
|
||||
const rows = ((await resp.json()) ?? []) as ProceedingTypeRow[];
|
||||
proceedingTypesCache = rows.filter((r) => r.is_active);
|
||||
return proceedingTypesCache;
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export interface ProjectMini {
|
||||
id: string;
|
||||
title: string;
|
||||
@@ -136,6 +165,34 @@ export function wireTypeChange() {
|
||||
typeSel.addEventListener("change", () => showFieldsForType(typeSel.value));
|
||||
}
|
||||
|
||||
// populateProceedingTypeSelect fills #project-proceeding-type-id with one
|
||||
// option per fristenrechner-category proceeding type, ordered by `code`
|
||||
// (so the user scans `de.*`, `dpma.*`, `epa.*`, `upc.*` in stable
|
||||
// jurisdiction-grouped order). The first option is the empty "unset"
|
||||
// choice already in the markup; this helper only appends rows below it.
|
||||
// Idempotent — clearing rows[1..] on re-call so a re-open of the edit
|
||||
// modal doesn't double-render the list.
|
||||
export async function populateProceedingTypeSelect(): Promise<void> {
|
||||
const sel = tryGet("project-proceeding-type-id") as HTMLSelectElement | null;
|
||||
if (!sel) return;
|
||||
const rows = await loadProceedingTypes();
|
||||
rows.sort((a, b) => a.code.localeCompare(b.code));
|
||||
while (sel.options.length > 1) sel.remove(1);
|
||||
const isEN = getLang() === "en";
|
||||
for (const row of rows) {
|
||||
const opt = document.createElement("option");
|
||||
opt.value = String(row.id);
|
||||
const label = isEN && row.name_en ? row.name_en : row.name;
|
||||
opt.textContent = `${label} (${row.code})`;
|
||||
sel.appendChild(opt);
|
||||
}
|
||||
// Honour a pre-selection value that prefillForm wrote before the
|
||||
// option set existed. dataset.preselect is set to "" or the saved id;
|
||||
// restoring it here keeps the edit modal's saved value visible.
|
||||
const preselect = sel.dataset.preselect;
|
||||
if (preselect !== undefined) sel.value = preselect;
|
||||
}
|
||||
|
||||
// readPayload collects the form's current values into a CreateProjectInput /
|
||||
// UpdateProjectInput compatible JSON payload. Returns null + sets msg when
|
||||
// title is missing.
|
||||
@@ -208,6 +265,22 @@ export function readPayload(
|
||||
stringField("project-court", "court");
|
||||
stringField("project-case-number", "case_number");
|
||||
|
||||
// Proceeding type — optional picker. Per t-paliad-232, an empty
|
||||
// pick simply omits the key from the payload (create: column stays
|
||||
// NULL; edit: server's `omitempty` skips the SET). Clearing a
|
||||
// previously-set value isn't supported in this slice; once bound,
|
||||
// a project's proceeding type can be swapped but not unset from
|
||||
// the form. The server's validateProceedingTypeCategory backs the
|
||||
// selected id with a category check.
|
||||
const ptSel = tryGet("project-proceeding-type-id") as HTMLSelectElement | null;
|
||||
if (ptSel) {
|
||||
const v = ptSel.value.trim();
|
||||
if (v) {
|
||||
const n = parseInt(v, 10);
|
||||
if (!isNaN(n)) payload.proceeding_type_id = n;
|
||||
}
|
||||
}
|
||||
|
||||
// Client Role (DB column: our_side) — case-only after t-paliad-222.
|
||||
// The select uses "" for the unset option; the service maps empty
|
||||
// string to NULL via nullableOurSide.
|
||||
@@ -259,6 +332,16 @@ export function prefillForm(p: Record<string, unknown>) {
|
||||
if (osSel) osSel.value = String(p.our_side ?? "");
|
||||
const ocEl = tryGet("project-opponent-code") as HTMLInputElement | null;
|
||||
if (ocEl) ocEl.value = String(p.opponent_code ?? "");
|
||||
// Proceeding-type picker — populated lazily by populateProceedingTypeSelect.
|
||||
// Set the value here even if the options haven't arrived yet; the post-
|
||||
// populate render runs ApplyProceedingTypeValue to re-select the saved id
|
||||
// once the option exists.
|
||||
const ptSel = tryGet("project-proceeding-type-id") as HTMLSelectElement | null;
|
||||
if (ptSel) {
|
||||
const v = p.proceeding_type_id == null ? "" : String(p.proceeding_type_id);
|
||||
ptSel.dataset.preselect = v;
|
||||
ptSel.value = v;
|
||||
}
|
||||
getTA("project-description").value = String(p.description ?? "");
|
||||
getSel("project-status").value = String(p.status ?? "active");
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import {
|
||||
wireTypeChange,
|
||||
prefillForm,
|
||||
readPayload,
|
||||
populateProceedingTypeSelect,
|
||||
loadProceedingTypes as loadProceedingTypesShared,
|
||||
} from "./project-form";
|
||||
import { mountFilterBar, type BarHandle } from "./filter-bar";
|
||||
import type { FilterSpec, RenderSpec } from "./views/types";
|
||||
@@ -1450,36 +1452,9 @@ function initSmartTimelineAddModal(id: string) {
|
||||
initCounterclaimRoute(id, modal, choices, form);
|
||||
}
|
||||
|
||||
interface ProceedingTypeRow {
|
||||
id: number;
|
||||
code: string;
|
||||
name: string;
|
||||
name_en: string;
|
||||
jurisdiction?: string;
|
||||
is_active: boolean;
|
||||
}
|
||||
|
||||
let proceedingTypesCache: ProceedingTypeRow[] | null = null;
|
||||
|
||||
// loadProceedingTypes fetches active proceeding types for the project
|
||||
// picker. Phase 3 Slice 5 (t-paliad-186) restricts project-binding to
|
||||
// fristenrechner-category codes (design §3.F + m's Q2 ruling), so the
|
||||
// picker only ever shows those — never the 7 legacy litigation codes
|
||||
// (INF / REV / CCR / APM / APP / AMD / ZPO_CIVIL). The matching
|
||||
// server-side service validation + DB trigger (mig 088) are the
|
||||
// defence-in-depth backstops for any non-UI writer.
|
||||
async function loadProceedingTypes(): Promise<ProceedingTypeRow[]> {
|
||||
if (proceedingTypesCache) return proceedingTypesCache;
|
||||
try {
|
||||
const resp = await fetch("/api/proceeding-types-db?category=fristenrechner");
|
||||
if (!resp.ok) return [];
|
||||
const rows = ((await resp.json()) ?? []) as ProceedingTypeRow[];
|
||||
proceedingTypesCache = rows.filter((r) => r.is_active);
|
||||
return proceedingTypesCache;
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
// loadProceedingTypes is shared from ./project-form so the counterclaim
|
||||
// modal here and the project-edit picker hit the same cache.
|
||||
const loadProceedingTypes = loadProceedingTypesShared;
|
||||
|
||||
function initCounterclaimRoute(
|
||||
id: string,
|
||||
@@ -1760,9 +1735,14 @@ async function prepareEditForm() {
|
||||
// as the new parent (server would reject anyway).
|
||||
await loadParentCandidates(project?.id);
|
||||
initParentPicker();
|
||||
await populateProceedingTypeSelect();
|
||||
}
|
||||
|
||||
function openEditModal() {
|
||||
// openEditModal opens the project-edit modal, optionally scrolling +
|
||||
// focusing a specific field after the form is prefilled. Callers like
|
||||
// the Schriftsätze empty-state CTA pass focusFieldID="project-proceeding-
|
||||
// type-id" to land the user directly on the picker they came to set.
|
||||
function openEditModal(focusFieldID?: string) {
|
||||
if (!project) return;
|
||||
const modal = document.getElementById("project-edit-modal");
|
||||
const msg = document.getElementById("project-edit-msg");
|
||||
@@ -1798,6 +1778,19 @@ function openEditModal() {
|
||||
};
|
||||
}
|
||||
renderTypeChangeWarning();
|
||||
if (focusFieldID) {
|
||||
// Wait a tick so the modal has laid out before scrolling — the
|
||||
// wrapping flex container is display:flex so the field's offset
|
||||
// height is only reliable after the next animation frame.
|
||||
requestAnimationFrame(() => {
|
||||
const target = document.getElementById(focusFieldID);
|
||||
if (!target) return;
|
||||
target.scrollIntoView({ behavior: "smooth", block: "center" });
|
||||
if (target instanceof HTMLSelectElement || target instanceof HTMLInputElement) {
|
||||
target.focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
msg.textContent = "";
|
||||
msg.className = "form-msg";
|
||||
@@ -1876,13 +1869,26 @@ function initEditModal() {
|
||||
const msg = document.getElementById("project-edit-msg") as HTMLParagraphElement | null;
|
||||
if (!editBtn || !modal || !closeBtn || !cancelBtn || !form || !msg) return;
|
||||
|
||||
editBtn.addEventListener("click", openEditModal);
|
||||
editBtn.addEventListener("click", () => openEditModal());
|
||||
closeBtn.addEventListener("click", closeEditModal);
|
||||
cancelBtn.addEventListener("click", closeEditModal);
|
||||
modal.addEventListener("click", (e) => {
|
||||
if (e.target === e.currentTarget) closeEditModal();
|
||||
});
|
||||
|
||||
// Schriftsätze empty-state CTA — when the panel reports "no proceeding
|
||||
// set", clicking the button opens the edit modal directly on the
|
||||
// Verfahrenstyp picker so the lawyer can resolve the gap in one step
|
||||
// (t-paliad-232).
|
||||
const submissionsCTA = document.getElementById(
|
||||
"project-submissions-edit-cta",
|
||||
) as HTMLButtonElement | null;
|
||||
if (submissionsCTA) {
|
||||
submissionsCTA.addEventListener("click", () => {
|
||||
openEditModal("project-proceeding-type-id");
|
||||
});
|
||||
}
|
||||
|
||||
form.addEventListener("submit", async (e) => {
|
||||
e.preventDefault();
|
||||
if (!project) return;
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
wireTypeChange,
|
||||
showFieldsForType,
|
||||
readPayload,
|
||||
populateProceedingTypeSelect,
|
||||
} from "./project-form";
|
||||
|
||||
// /projects/new client. Posts v2 CreateProjectInput shape using the shared
|
||||
@@ -106,5 +107,8 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||
await loadParentCandidates();
|
||||
initParentPicker();
|
||||
await applyParentFromQueryString();
|
||||
// Fire-and-forget — the picker is hidden until type=case, so no need
|
||||
// to block initial render on the fetch.
|
||||
void populateProceedingTypeSelect();
|
||||
submitForm();
|
||||
});
|
||||
|
||||
@@ -171,6 +171,16 @@ export function ProjectFormFields(): string {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="form-field">
|
||||
<label htmlFor="project-proceeding-type-id" data-i18n="projects.field.proceeding_type">Verfahrenstyp</label>
|
||||
<select id="project-proceeding-type-id">
|
||||
<option value="" data-i18n="projects.field.proceeding_type.unset">(nicht gesetzt)</option>
|
||||
</select>
|
||||
<p className="form-hint" data-i18n="projects.field.proceeding_type.hint">
|
||||
Bestimmt, welche Schriftsätze-Vorlagen für dieses Verfahren angezeigt werden.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="form-field">
|
||||
<label htmlFor="project-our-side" data-i18n="projects.field.client_role">Mandantenrolle</label>
|
||||
<select id="project-our-side">
|
||||
|
||||
@@ -2258,6 +2258,7 @@ export type I18nKey =
|
||||
| "projects.detail.submissions.col.source"
|
||||
| "projects.detail.submissions.empty"
|
||||
| "projects.detail.submissions.empty.no_proceeding"
|
||||
| "projects.detail.submissions.empty.no_proceeding.cta"
|
||||
| "projects.detail.submissions.hint"
|
||||
| "projects.detail.tab.checklisten"
|
||||
| "projects.detail.tab.fristen"
|
||||
@@ -2354,6 +2355,9 @@ export type I18nKey =
|
||||
| "projects.field.parent.hint"
|
||||
| "projects.field.parent.placeholder"
|
||||
| "projects.field.patent_number"
|
||||
| "projects.field.proceeding_type"
|
||||
| "projects.field.proceeding_type.hint"
|
||||
| "projects.field.proceeding_type.unset"
|
||||
| "projects.field.proceeding_type_id"
|
||||
| "projects.field.ref"
|
||||
| "projects.field.ref.placeholder"
|
||||
|
||||
@@ -627,9 +627,18 @@ export function renderProjectsDetail(): string {
|
||||
proceeding bound; otherwise enumerates every active
|
||||
filing rule for the proceeding. */}
|
||||
<section className="entity-tab-panel" id="tab-submissions" style="display:none">
|
||||
<p id="project-submissions-no-proceeding" className="entity-events-empty" style="display:none" data-i18n="projects.detail.submissions.empty.no_proceeding">
|
||||
Bitte zuerst einen Verfahrenstyp setzen.
|
||||
</p>
|
||||
<div id="project-submissions-no-proceeding" className="entity-events-empty" style="display:none">
|
||||
<p data-i18n="projects.detail.submissions.empty.no_proceeding">
|
||||
Für dieses Projekt ist noch kein Verfahrenstyp gesetzt. Bitte im Projekt bearbeiten.
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
id="project-submissions-edit-cta"
|
||||
className="btn-primary btn-small"
|
||||
data-i18n="projects.detail.submissions.empty.no_proceeding.cta">
|
||||
Projekt bearbeiten
|
||||
</button>
|
||||
</div>
|
||||
<p id="project-submissions-empty" className="entity-events-empty" style="display:none" data-i18n="projects.detail.submissions.empty">
|
||||
Für dieses Verfahren sind keine Schriftsätze hinterlegt.
|
||||
</p>
|
||||
|
||||
@@ -253,3 +253,95 @@ func TestProjectService_InstanceLevel_Roundtrip(t *testing.T) {
|
||||
t.Errorf("want ErrInvalidInput, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// TestProjectService_CaseProceedingTypePicker covers the t-paliad-232
|
||||
// data path for the new project-form Verfahrenstyp picker:
|
||||
//
|
||||
// 1. Creating a `case`-typed project with a fristenrechner-category
|
||||
// proceeding_type_id round-trips the column.
|
||||
// 2. The same code path rejects a non-fristenrechner-category id with
|
||||
// ErrInvalidProceedingTypeCategory (mirror of the guard test above,
|
||||
// this time exercised through a 'case' shape).
|
||||
//
|
||||
// Skipped when TEST_DATABASE_URL is unset.
|
||||
func TestProjectService_CaseProceedingTypePicker(t *testing.T) {
|
||||
url := os.Getenv("TEST_DATABASE_URL")
|
||||
if url == "" {
|
||||
t.Skip("TEST_DATABASE_URL not set — skipping live DB test")
|
||||
}
|
||||
if err := db.ApplyMigrations(url); err != nil {
|
||||
t.Fatalf("apply migrations: %v", err)
|
||||
}
|
||||
pool, err := sqlx.Connect("postgres", url)
|
||||
if err != nil {
|
||||
t.Fatalf("connect: %v", err)
|
||||
}
|
||||
defer pool.Close()
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
var fristenrechnerID int
|
||||
if err := pool.GetContext(ctx, &fristenrechnerID,
|
||||
`SELECT id FROM paliad.proceeding_types
|
||||
WHERE category = 'fristenrechner' AND code = $1 AND is_active = true`,
|
||||
CodeUPCInfringement); err != nil {
|
||||
t.Fatalf("look up %s id: %v", CodeUPCInfringement, err)
|
||||
}
|
||||
var nonFristenrechnerID int
|
||||
if err := pool.GetContext(ctx, &nonFristenrechnerID,
|
||||
`SELECT id FROM paliad.proceeding_types
|
||||
WHERE category <> 'fristenrechner'
|
||||
ORDER BY id
|
||||
LIMIT 1`); err != nil {
|
||||
t.Fatalf("look up non-fristenrechner id: %v", err)
|
||||
}
|
||||
|
||||
users := NewUserService(pool)
|
||||
svc := NewProjectService(pool, users)
|
||||
|
||||
userID := uuid.New()
|
||||
cleanup := func() {
|
||||
pool.ExecContext(ctx, `DELETE FROM paliad.projects WHERE created_by = $1`, userID)
|
||||
pool.ExecContext(ctx, `DELETE FROM paliad.users WHERE id = $1`, userID)
|
||||
pool.ExecContext(ctx, `DELETE FROM auth.users WHERE id = $1`, userID)
|
||||
}
|
||||
cleanup()
|
||||
defer cleanup()
|
||||
|
||||
if _, err := pool.ExecContext(ctx,
|
||||
`INSERT INTO auth.users (id, email) VALUES ($1, 't-paliad-232-test@hlc.com')`,
|
||||
userID); err != nil {
|
||||
t.Fatalf("seed auth.users: %v", err)
|
||||
}
|
||||
if _, err := pool.ExecContext(ctx,
|
||||
`INSERT INTO paliad.users (id, email, display_name, office, role, lang)
|
||||
VALUES ($1, 't-paliad-232-test@hlc.com', 'Picker Test', 'munich', 'associate', 'de')`,
|
||||
userID); err != nil {
|
||||
t.Fatalf("seed paliad.users: %v", err)
|
||||
}
|
||||
|
||||
// 1. Case-typed create with a fristenrechner id succeeds.
|
||||
created, err := svc.Create(ctx, userID, CreateProjectInput{
|
||||
Type: ProjectTypeCase,
|
||||
Title: "t-paliad-232 — case with proceeding_type_id",
|
||||
ProceedingTypeID: &fristenrechnerID,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Create case with fristenrechner id: %v", err)
|
||||
}
|
||||
if created.ProceedingTypeID == nil || *created.ProceedingTypeID != fristenrechnerID {
|
||||
t.Errorf("created proceeding_type_id = %v, want %d", created.ProceedingTypeID, fristenrechnerID)
|
||||
}
|
||||
|
||||
// 2. Case-typed create with a non-fristenrechner id is rejected.
|
||||
_, err = svc.Create(ctx, userID, CreateProjectInput{
|
||||
Type: ProjectTypeCase,
|
||||
Title: "t-paliad-232 — case with non-fristenrechner id",
|
||||
ProceedingTypeID: &nonFristenrechnerID,
|
||||
})
|
||||
if err == nil {
|
||||
t.Error("Create case with non-fristenrechner proceeding_type_id should fail, but succeeded")
|
||||
} else if !errors.Is(err, ErrInvalidProceedingTypeCategory) {
|
||||
t.Errorf("expected ErrInvalidProceedingTypeCategory, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user