fix: DDMA Create claim stale element, tooth dropdown select, longer page waits

step2: wait for patient list //tbody//tr then 3s stabilize; wait for patient
name link to be element_to_be_clickable before reading href; wait for Create
claim button to be element_to_be_clickable (visible+enabled) then 3s for React
to finish re-rendering.

step3: re-find Create claim button fresh each attempt (avoids stale element
from React re-render); try selenium click → js events → js.click() in sequence;
verify URL changed before declaring success.

step4: open tooth dropdown via JS focus (avoids element-not-interactable on
click); select the matching tooth number option directly from 1-32 listbox
instead of typing characters.

step7: find Submit claim button with individual XPaths to avoid NoneType crash.

claims-page: use wouter setLocation for URL param cleanup so internal search
state stays in sync.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ff
2026-06-07 00:28:01 -04:00
parent d02e8c8dcb
commit 730c41f9b0
2 changed files with 163 additions and 59 deletions

View File

@@ -11,7 +11,7 @@ import { ClaimForm } from "@/components/claims/claim-form";
import { useToast } from "@/hooks/use-toast";
import { useAuth } from "@/hooks/use-auth";
import { apiRequest, queryClient } from "@/lib/queryClient";
import { useLocation } from "wouter";
import { useLocation, useSearch } from "wouter";
import { useAppDispatch, useAppSelector } from "@/redux/hooks";
import {
setTaskStatus,
@@ -203,15 +203,18 @@ export default function ClaimsPage() {
}
}
if (changed) {
window.history.replaceState({}, document.title, url.toString());
// Use wouter's setLocation so its internal search state updates too
const newRelative = url.pathname + (url.search ? url.search : "") + url.hash;
setWouterLocation(newRelative, { replace: true });
}
} catch (e) {
// ignore (URL API or history.replaceState might throw in very old envs)
// ignore
}
};
// case1: - this params are set by pdf extraction/patient page or either by patient-add-form. then used in claim page here.
const [location] = useLocation();
const [location, setWouterLocation] = useLocation();
const search = useSearch();
const { newPatient, mode } = useMemo(() => {
const params = new URLSearchParams(window.location.search);
@@ -219,7 +222,7 @@ export default function ClaimsPage() {
newPatient: params.get("newPatient"),
mode: params.get("mode"), // direct | manual | null};
};
}, [location]);
}, [location, search]);
const handleNewClaim = (patientId: number, appointmentId?: number) => {
setSelectedPatientId(patientId);
@@ -296,6 +299,16 @@ export default function ClaimsPage() {
const patientId = appointment?.patientId;
if (!cancelled && patientId) {
// Check if chatbot requested auto-submit with a specific insurance
try {
const raw = sessionStorage.getItem("chatbot_claim_prefill");
if (raw) {
const parsed = JSON.parse(raw);
if (parsed?.autoSubmit && parsed?.siteKey) {
setChatbotAutoSubmitSiteKey(parsed.siteKey);
}
}
} catch {}
handleNewClaim(patientId, appointmentId);
clearUrlParams(["appointmentId"]);
}
@@ -314,7 +327,7 @@ export default function ClaimsPage() {
return () => {
cancelled = true;
};
}, [location, newPatient]);
}, [location, search, newPatient]);
// 1. upsert appointment.
const handleAppointmentSubmit = async (