Compare commits
6 commits
claude/det
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| bf7ea1a9e6 | |||
| 90a831790d | |||
| a5248e5c23 | |||
| efa9d90ddb | |||
|
|
5218eb3717 | ||
| 6c5aebd3fb |
4 changed files with 59 additions and 16 deletions
|
|
@ -36,8 +36,6 @@ export function HistoryFilters({ vessels, accounts, perPageOptions, defaultPerPa
|
|||
|
||||
const [dateFrom, setDateFrom] = useState(sp.get("dateFrom") ?? "");
|
||||
const [dateTo, setDateTo] = useState(sp.get("dateTo") ?? "");
|
||||
const [approvedFrom, setApprovedFrom] = useState(sp.get("approvedFrom") ?? "");
|
||||
const [approvedTo, setApprovedTo] = useState(sp.get("approvedTo") ?? "");
|
||||
const [vesselId, setVesselId] = useState(sp.get("vesselId") ?? "");
|
||||
const [accountId, setAccountId] = useState(sp.get("accountId") ?? "");
|
||||
const [statuses, setStatuses] = useState<string[]>(sp.getAll("status"));
|
||||
|
|
@ -65,8 +63,6 @@ export function HistoryFilters({ vessels, accounts, perPageOptions, defaultPerPa
|
|||
const params = new URLSearchParams();
|
||||
if (dateFrom) params.set("dateFrom", dateFrom);
|
||||
if (dateTo) params.set("dateTo", dateTo);
|
||||
if (approvedFrom) params.set("approvedFrom", approvedFrom);
|
||||
if (approvedTo) params.set("approvedTo", approvedTo);
|
||||
if (vesselId) params.set("vesselId", vesselId);
|
||||
if (accountId) params.set("accountId", accountId);
|
||||
for (const s of statuses) params.append("status", s);
|
||||
|
|
@ -83,14 +79,14 @@ export function HistoryFilters({ vessels, accounts, perPageOptions, defaultPerPa
|
|||
}
|
||||
|
||||
function clear() {
|
||||
setDateFrom(""); setDateTo(""); setApprovedFrom(""); setApprovedTo(""); setVesselId(""); setAccountId(""); setStatuses([]);
|
||||
setDateFrom(""); setDateTo(""); setVesselId(""); setAccountId(""); setStatuses([]);
|
||||
const params = new URLSearchParams();
|
||||
if (perPage !== defaultPerPage) params.set("perPage", String(perPage));
|
||||
const qs = params.toString();
|
||||
router.push(qs ? `/history?${qs}` : "/history");
|
||||
}
|
||||
|
||||
const hasFilters = dateFrom || dateTo || approvedFrom || approvedTo || vesselId || accountId || statuses.length > 0;
|
||||
const hasFilters = dateFrom || dateTo || vesselId || accountId || statuses.length > 0;
|
||||
|
||||
const statusLabel =
|
||||
statuses.length === 0
|
||||
|
|
@ -112,16 +108,6 @@ export function HistoryFilters({ vessels, accounts, perPageOptions, defaultPerPa
|
|||
<input type="date" value={dateTo} onChange={(e) => setDateTo(e.target.value)}
|
||||
className="w-full rounded-lg border border-neutral-300 px-3 py-2 text-sm focus:border-primary-500 focus:outline-none focus:ring-2 focus:ring-primary-500/20" />
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-xs font-medium text-neutral-600 mb-1">Approved From</label>
|
||||
<input type="date" value={approvedFrom} onChange={(e) => setApprovedFrom(e.target.value)}
|
||||
className="w-full rounded-lg border border-neutral-300 px-3 py-2 text-sm focus:border-primary-500 focus:outline-none focus:ring-2 focus:ring-primary-500/20" />
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-xs font-medium text-neutral-600 mb-1">Approved To</label>
|
||||
<input type="date" value={approvedTo} onChange={(e) => setApprovedTo(e.target.value)}
|
||||
className="w-full rounded-lg border border-neutral-300 px-3 py-2 text-sm focus:border-primary-500 focus:outline-none focus:ring-2 focus:ring-primary-500/20" />
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-xs font-medium text-neutral-600 mb-1">Cost Centre</label>
|
||||
<select value={vesselId} onChange={(e) => setVesselId(e.target.value)}
|
||||
|
|
|
|||
36
App/tests/unit/history-filters.test.tsx
Normal file
36
App/tests/unit/history-filters.test.tsx
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import { describe, it, expect, vi } from "vitest";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
|
||||
// HistoryFilters reads the URL via next/navigation; mock both hooks it uses.
|
||||
vi.mock("next/navigation", () => ({
|
||||
useRouter: () => ({ push: vi.fn(), refresh: vi.fn() }),
|
||||
useSearchParams: () => new URLSearchParams(""),
|
||||
}));
|
||||
|
||||
import { HistoryFilters } from "@/app/(portal)/history/history-filters";
|
||||
|
||||
const props = {
|
||||
vessels: [{ id: "v1", name: "Vessel One" }],
|
||||
accounts: [],
|
||||
perPageOptions: [25, 50, 100],
|
||||
defaultPerPage: 25,
|
||||
};
|
||||
|
||||
describe("HistoryFilters", () => {
|
||||
// Regression guard for issue #136: the "Approved From" / "Approved To" date
|
||||
// filters were removed from PO History. They must not reappear.
|
||||
it("does not render the Approved From / Approved To filters", () => {
|
||||
render(<HistoryFilters {...props} />);
|
||||
expect(screen.queryByText("Approved From")).toBeNull();
|
||||
expect(screen.queryByText("Approved To")).toBeNull();
|
||||
});
|
||||
|
||||
it("still renders the remaining filters (created-date range, cost centre, accounting code, status)", () => {
|
||||
render(<HistoryFilters {...props} />);
|
||||
expect(screen.getByText("From")).toBeInTheDocument();
|
||||
expect(screen.getByText("To")).toBeInTheDocument();
|
||||
expect(screen.getByText("Cost Centre")).toBeInTheDocument();
|
||||
expect(screen.getByText("Accounting Code")).toBeInTheDocument();
|
||||
expect(screen.getByText("Status")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
|
@ -60,6 +60,11 @@ requires an interactive ESLint migration (a follow-up). Integration tests are
|
|||
type-checked here but executed against the `pelagia_test` DB by the autofix / locally
|
||||
(not in this shared CI, to avoid prod-mirror schema drift).
|
||||
|
||||
The **issue watcher pre-applies gate 1 (test-presence) locally** before opening a PR:
|
||||
if Claude's fix changes code under `App/app|lib|components|hooks` but adds no test, the
|
||||
watcher does **not** open a PR — it marks the issue `claude-failed` and comments — so it
|
||||
never raises a PR that this CI would immediately reject. Re-queue (`claude-queue`) to retry.
|
||||
|
||||
A [`PULL_REQUEST_TEMPLATE.md`](../.forgejo/PULL_REQUEST_TEMPLATE.md) carries the checklist.
|
||||
|
||||
## Components
|
||||
|
|
|
|||
|
|
@ -339,6 +339,22 @@ while [ "$f" -lt "$n_fix" ]; do
|
|||
|
||||
commits=$(git -C "$WORKDIR" rev-list "origin/$BASE_BRANCH..HEAD" --count)
|
||||
if [ "$commits" -gt 0 ]; then
|
||||
# Test-presence gate -- mirror .forgejo/workflows/pr-checks.yml so the watcher
|
||||
# never opens a PR the CI will immediately reject. "Code" = app source under
|
||||
# App/(app|lib|components|hooks); tests, prisma, config, docs are exempt.
|
||||
changed=$(git -C "$WORKDIR" diff --name-only "origin/$BASE_BRANCH...HEAD")
|
||||
code_changed=$(printf '%s\n' "$changed" | grep -E '^App/(app|lib|components|hooks)/' | grep -vE '(\.test\.|\.spec\.|/tests/)' || true)
|
||||
test_changed=$(printf '%s\n' "$changed" | grep -E '(\.test\.|\.spec\.|/tests/)' || true)
|
||||
if [ -n "$code_changed" ] && [ -z "$test_changed" ]; then
|
||||
log "Test-presence gate FAILED for #$num: code changed with no test; not opening a PR"
|
||||
set_labels "$num" "claude-working" "claude-failed"
|
||||
add_comment "$num" "$BOT_MARKER
|
||||
[Claude] Implemented a change but added **no test**, so no PR was opened. The contribution policy (\`pr-checks.yml\`) requires a test for any change under \`App/app|lib|components|hooks\`, and would reject this. Re-add \`claude-queue\` to retry, or pick it up interactively.
|
||||
|
||||
Code files that needed an accompanying test:
|
||||
$code_changed"
|
||||
continue
|
||||
fi
|
||||
log "Claude made $commits commit(s); pushing $branch"
|
||||
if ! git -C "$WORKDIR" push -f -u origin "$branch" -q 2>>"$LOG_FILE"; then
|
||||
log "push failed for #$num"; set_labels "$num" "claude-working" "claude-failed"; continue
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue