mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-10 13:22:14 +00:00
test(onboarding): the AI panel names the variant it settled on
The panel paints before its status query answers, and every variant inside it is conditional, so an assertion that a variant is absent could pass on a question that had simply not been answered yet — which is how the journey for the unmeasured-provider case passed on a retry against the very defect it was written to catch. The panel now carries the variant it settled on, absent until it has settled, and the three journeys wait on that instead of racing it. The third journey covers the state a freshly deployed instance is in before its first AI call: no offer, and no claim of an outage either.
This commit is contained in:
1 parent
41596d1cb8
commit
34caeeea3c
4 files changed
+92
-3
No files matched your search
@@ -179,6 +179,7 @@ describe("<DoneScreen> shared-provider offer", () => {
|
||||
serverProviderConsent: false,
|
||||
};
|
||||
const html = render();
|
||||
expect(html).toContain('data-ai-state="offer"');
|
||||
expect(html).toContain('data-slot="onboarding-ai-offer"');
|
||||
expect(html).toContain('data-slot="onboarding-ai-offer-grant"');
|
||||
// The unproven promise is gone from this branch.
|
||||
@@ -194,6 +195,7 @@ describe("<DoneScreen> shared-provider offer", () => {
|
||||
serverProviderConsent: false,
|
||||
};
|
||||
const html = render();
|
||||
expect(html).toContain('data-ai-state="unavailable"');
|
||||
expect(html).toContain('data-slot="onboarding-ai-unavailable"');
|
||||
expect(html).not.toContain('data-slot="onboarding-ai-offer-grant"');
|
||||
expect(html).not.toContain('data-slot="onboarding-ai-shared-key"');
|
||||
@@ -214,6 +216,7 @@ describe("<DoneScreen> shared-provider offer", () => {
|
||||
serverProviderConsent: false,
|
||||
};
|
||||
const html = render();
|
||||
expect(html).toContain('data-ai-state="neutral"');
|
||||
expect(html).not.toContain('data-slot="onboarding-ai-unavailable"');
|
||||
expect(html).not.toContain('data-slot="onboarding-ai-offer-grant"');
|
||||
expect(html).not.toContain('data-slot="onboarding-ai-shared-key"');
|
||||
@@ -230,6 +233,7 @@ describe("<DoneScreen> shared-provider offer", () => {
|
||||
serverProviderConsent: true,
|
||||
};
|
||||
const html = render();
|
||||
expect(html).toContain('data-ai-state="consent"');
|
||||
expect(html).toContain('data-slot="onboarding-ai-shared-key"');
|
||||
expect(html).not.toContain('data-slot="onboarding-ai-offer-grant"');
|
||||
expect(html).not.toContain('data-slot="onboarding-ai-unavailable"');
|
||||
@@ -252,6 +256,8 @@ describe("<DoneScreen> shared-provider offer", () => {
|
||||
it("says nothing at all while the status is still in flight", () => {
|
||||
aiProviderState.data = undefined;
|
||||
const html = render();
|
||||
// Not even the settled marker: the question is genuinely unanswered.
|
||||
expect(html).not.toContain("data-ai-state");
|
||||
expect(html).not.toContain('data-slot="onboarding-ai-offer"');
|
||||
expect(html).not.toContain('data-slot="onboarding-ai-unavailable"');
|
||||
});
|
||||
|
||||
@@ -225,6 +225,22 @@ export function DoneScreen({ state }: { state: OnboardingStateDto }) {
|
||||
<section
|
||||
aria-labelledby="onboarding-ai-panel-title"
|
||||
data-slot="onboarding-ai-panel"
|
||||
/* Which of the four variants the panel SETTLED on, and absent until
|
||||
it has settled. The panel itself is unconditional and paints
|
||||
immediately, so without this an assertion that a variant is absent
|
||||
passes on a status that has simply not arrived yet. The value is
|
||||
the same tri-state decision made once, above. */
|
||||
data-ai-state={
|
||||
aiProvider === undefined
|
||||
? undefined
|
||||
: consentOnFile && operatorProvides
|
||||
? "consent"
|
||||
: offerShared
|
||||
? "offer"
|
||||
: sharedUnavailable
|
||||
? "unavailable"
|
||||
: "neutral"
|
||||
}
|
||||
className="border-border bg-card mx-auto flex w-full max-w-md flex-col gap-4 rounded-xl border p-4 text-left md:p-6"
|
||||
>
|
||||
<header className="flex items-start gap-3">
|
||||
|
||||
Reference in new issue
Block a user