@photonhealth/react 2.0.0-rc.1 → 2.0.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/README.md +52 -9
  2. package/dist/adapters/tailwind.d.ts.map +1 -1
  3. package/dist/adapters/tailwind.js +7 -4
  4. package/dist/adapters/tailwind.js.map +1 -1
  5. package/dist/analytics/PhotonAnalyticsProvider.d.ts +19 -0
  6. package/dist/analytics/PhotonAnalyticsProvider.d.ts.map +1 -0
  7. package/dist/analytics/PhotonAnalyticsProvider.js +76 -0
  8. package/dist/analytics/PhotonAnalyticsProvider.js.map +1 -0
  9. package/dist/analytics/cardLifecycle.d.ts +10 -0
  10. package/dist/analytics/cardLifecycle.d.ts.map +1 -0
  11. package/dist/analytics/cardLifecycle.js +43 -0
  12. package/dist/analytics/cardLifecycle.js.map +1 -0
  13. package/dist/analytics/fieldInteraction.d.ts +18 -0
  14. package/dist/analytics/fieldInteraction.d.ts.map +1 -0
  15. package/dist/analytics/fieldInteraction.js +102 -0
  16. package/dist/analytics/fieldInteraction.js.map +1 -0
  17. package/dist/analytics/lifecycleOutcomes.d.ts +8 -0
  18. package/dist/analytics/lifecycleOutcomes.d.ts.map +1 -0
  19. package/dist/analytics/lifecycleOutcomes.js +16 -0
  20. package/dist/analytics/lifecycleOutcomes.js.map +1 -0
  21. package/dist/analytics/tracker.d.ts +19 -0
  22. package/dist/analytics/tracker.d.ts.map +1 -0
  23. package/dist/analytics/tracker.js +41 -0
  24. package/dist/analytics/tracker.js.map +1 -0
  25. package/dist/analytics/viewed.d.ts +11 -0
  26. package/dist/analytics/viewed.d.ts.map +1 -0
  27. package/dist/analytics/viewed.js +16 -0
  28. package/dist/analytics/viewed.js.map +1 -0
  29. package/dist/components/PhotonOrder.d.ts +18 -18
  30. package/dist/components/PhotonOrder.d.ts.map +1 -1
  31. package/dist/components/PhotonOrder.js +34 -19
  32. package/dist/components/PhotonOrder.js.map +1 -1
  33. package/dist/components/PhotonPatient.d.ts +7 -35
  34. package/dist/components/PhotonPatient.d.ts.map +1 -1
  35. package/dist/components/PhotonPatient.js +6 -78
  36. package/dist/components/PhotonPatient.js.map +1 -1
  37. package/dist/components/PhotonPrescription.d.ts +15 -26
  38. package/dist/components/PhotonPrescription.d.ts.map +1 -1
  39. package/dist/components/PhotonPrescription.js +6 -360
  40. package/dist/components/PhotonPrescription.js.map +1 -1
  41. package/dist/components/format.d.ts +2 -2
  42. package/dist/components/format.js +2 -2
  43. package/dist/components/index.d.ts +1 -1
  44. package/dist/components/index.d.ts.map +1 -1
  45. package/dist/components/index.js +1 -1
  46. package/dist/components/index.js.map +1 -1
  47. package/dist/components/open.d.ts +11 -13
  48. package/dist/components/open.d.ts.map +1 -1
  49. package/dist/components/open.js +7 -2
  50. package/dist/components/open.js.map +1 -1
  51. package/dist/components/order/DraftOrderPrompt.d.ts +18 -0
  52. package/dist/components/order/DraftOrderPrompt.d.ts.map +1 -0
  53. package/dist/components/order/DraftOrderPrompt.js +26 -0
  54. package/dist/components/order/DraftOrderPrompt.js.map +1 -0
  55. package/dist/components/patient/PatientCard/PatientCard.d.ts +30 -0
  56. package/dist/components/patient/PatientCard/PatientCard.d.ts.map +1 -0
  57. package/dist/components/patient/PatientCard/PatientCard.js +101 -0
  58. package/dist/components/patient/PatientCard/PatientCard.js.map +1 -0
  59. package/dist/components/patient/PatientCard/usePatientToShow.d.ts +22 -0
  60. package/dist/components/patient/PatientCard/usePatientToShow.d.ts.map +1 -0
  61. package/dist/components/patient/PatientCard/usePatientToShow.js +40 -0
  62. package/dist/components/patient/PatientCard/usePatientToShow.js.map +1 -0
  63. package/dist/components/patient/PatientIntakeForm.d.ts +16 -0
  64. package/dist/components/patient/PatientIntakeForm.d.ts.map +1 -0
  65. package/dist/components/patient/PatientIntakeForm.js +114 -0
  66. package/dist/components/patient/PatientIntakeForm.js.map +1 -0
  67. package/dist/components/patient/PatientSearch.d.ts +12 -0
  68. package/dist/components/patient/PatientSearch.d.ts.map +1 -0
  69. package/dist/components/patient/PatientSearch.js +148 -0
  70. package/dist/components/patient/PatientSearch.js.map +1 -0
  71. package/dist/components/patient/{Benefits.d.ts → PatientSummary/BenefitsInputForm.d.ts} +2 -2
  72. package/dist/components/patient/PatientSummary/BenefitsInputForm.d.ts.map +1 -0
  73. package/dist/components/patient/{Benefits.js → PatientSummary/BenefitsInputForm.js} +6 -5
  74. package/dist/components/patient/PatientSummary/BenefitsInputForm.js.map +1 -0
  75. package/dist/components/patient/{Clinical.d.ts → PatientSummary/ClinicalInputForm.d.ts} +15 -16
  76. package/dist/components/patient/PatientSummary/ClinicalInputForm.d.ts.map +1 -0
  77. package/dist/components/patient/{Clinical.js → PatientSummary/ClinicalInputForm.js} +29 -28
  78. package/dist/components/patient/PatientSummary/ClinicalInputForm.js.map +1 -0
  79. package/dist/components/patient/PatientSummary/CollapsedSummary.d.ts +5 -0
  80. package/dist/components/patient/PatientSummary/CollapsedSummary.d.ts.map +1 -0
  81. package/dist/components/patient/PatientSummary/CollapsedSummary.js +30 -0
  82. package/dist/components/patient/PatientSummary/CollapsedSummary.js.map +1 -0
  83. package/dist/components/patient/PatientSummary/PatientDetailsForm.d.ts +10 -0
  84. package/dist/components/patient/PatientSummary/PatientDetailsForm.d.ts.map +1 -0
  85. package/dist/components/patient/PatientSummary/PatientDetailsForm.js +65 -0
  86. package/dist/components/patient/PatientSummary/PatientDetailsForm.js.map +1 -0
  87. package/dist/components/patient/PatientSummary/PatientDetailsSchema.d.ts +53 -0
  88. package/dist/components/patient/PatientSummary/PatientDetailsSchema.d.ts.map +1 -0
  89. package/dist/components/patient/PatientSummary/PatientDetailsSchema.js +78 -0
  90. package/dist/components/patient/PatientSummary/PatientDetailsSchema.js.map +1 -0
  91. package/dist/components/patient/PatientSummary/PatientSummary.d.ts +46 -0
  92. package/dist/components/patient/PatientSummary/PatientSummary.d.ts.map +1 -0
  93. package/dist/components/patient/PatientSummary/PatientSummary.js +57 -0
  94. package/dist/components/patient/PatientSummary/PatientSummary.js.map +1 -0
  95. package/dist/components/patient/PatientSummary/SummaryHeader.d.ts +19 -0
  96. package/dist/components/patient/PatientSummary/SummaryHeader.d.ts.map +1 -0
  97. package/dist/components/patient/PatientSummary/SummaryHeader.js +22 -0
  98. package/dist/components/patient/PatientSummary/SummaryHeader.js.map +1 -0
  99. package/dist/components/patient/fields.d.ts +7 -26
  100. package/dist/components/patient/fields.d.ts.map +1 -1
  101. package/dist/components/patient/fields.js +11 -52
  102. package/dist/components/patient/fields.js.map +1 -1
  103. package/dist/components/patient/parsePatientSearchQuery.d.ts +16 -0
  104. package/dist/components/patient/parsePatientSearchQuery.d.ts.map +1 -0
  105. package/dist/components/patient/{query.js → parsePatientSearchQuery.js} +3 -10
  106. package/dist/components/patient/parsePatientSearchQuery.js.map +1 -0
  107. package/dist/components/prescription/PrescriptionCard.d.ts +51 -0
  108. package/dist/components/prescription/PrescriptionCard.d.ts.map +1 -0
  109. package/dist/components/prescription/PrescriptionCard.js +186 -0
  110. package/dist/components/prescription/PrescriptionCard.js.map +1 -0
  111. package/dist/components/prescription/PrescriptionDetailsForm/DirectionsInput.d.ts +15 -0
  112. package/dist/components/prescription/PrescriptionDetailsForm/DirectionsInput.d.ts.map +1 -0
  113. package/dist/components/prescription/PrescriptionDetailsForm/DirectionsInput.js +18 -0
  114. package/dist/components/prescription/PrescriptionDetailsForm/DirectionsInput.js.map +1 -0
  115. package/dist/components/prescription/PrescriptionDetailsForm/DispenseInputs.d.ts +23 -0
  116. package/dist/components/prescription/PrescriptionDetailsForm/DispenseInputs.d.ts.map +1 -0
  117. package/dist/components/prescription/PrescriptionDetailsForm/DispenseInputs.js +42 -0
  118. package/dist/components/prescription/PrescriptionDetailsForm/DispenseInputs.js.map +1 -0
  119. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.d.ts +27 -0
  120. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.d.ts.map +1 -0
  121. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.js +169 -0
  122. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.js.map +1 -0
  123. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.d.ts +8 -0
  124. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.d.ts.map +1 -0
  125. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.js +12 -0
  126. package/dist/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.js.map +1 -0
  127. package/dist/components/prescription/PrescriptionDetailsForm/TemplatePicker.d.ts +11 -0
  128. package/dist/components/prescription/PrescriptionDetailsForm/TemplatePicker.d.ts.map +1 -0
  129. package/dist/components/prescription/PrescriptionDetailsForm/TemplatePicker.js +25 -0
  130. package/dist/components/prescription/PrescriptionDetailsForm/TemplatePicker.js.map +1 -0
  131. package/dist/components/prescription/TreatmentSearch/TreatmentPicker.d.ts +50 -0
  132. package/dist/components/prescription/TreatmentSearch/TreatmentPicker.d.ts.map +1 -0
  133. package/dist/components/{TreatmentPicker.js → prescription/TreatmentSearch/TreatmentPicker.js} +113 -105
  134. package/dist/components/prescription/TreatmentSearch/TreatmentPicker.js.map +1 -0
  135. package/dist/components/prescription/TreatmentSearch/TreatmentSearch.d.ts +28 -0
  136. package/dist/components/prescription/TreatmentSearch/TreatmentSearch.d.ts.map +1 -0
  137. package/dist/components/prescription/TreatmentSearch/TreatmentSearch.js +146 -0
  138. package/dist/components/prescription/TreatmentSearch/TreatmentSearch.js.map +1 -0
  139. package/dist/components/schemaErrors.d.ts +13 -0
  140. package/dist/components/schemaErrors.d.ts.map +1 -0
  141. package/dist/components/schemaErrors.js +25 -0
  142. package/dist/components/schemaErrors.js.map +1 -0
  143. package/dist/components/search.d.ts +1 -1
  144. package/dist/components/search.js +1 -1
  145. package/dist/index.d.ts +2 -0
  146. package/dist/index.d.ts.map +1 -1
  147. package/dist/index.js +1 -0
  148. package/dist/index.js.map +1 -1
  149. package/dist/meta/version.d.ts +5 -0
  150. package/dist/meta/version.d.ts.map +1 -0
  151. package/dist/meta/version.js +5 -0
  152. package/dist/meta/version.js.map +1 -0
  153. package/dist/primitives/PhotonProvider.d.ts +3 -1
  154. package/dist/primitives/PhotonProvider.d.ts.map +1 -1
  155. package/dist/primitives/PhotonProvider.js +23 -11
  156. package/dist/primitives/PhotonProvider.js.map +1 -1
  157. package/dist/primitives/defaults.d.ts.map +1 -1
  158. package/dist/primitives/defaults.js +6 -3
  159. package/dist/primitives/defaults.js.map +1 -1
  160. package/dist/primitives/photonContext.d.ts +3 -0
  161. package/dist/primitives/photonContext.d.ts.map +1 -0
  162. package/dist/primitives/photonContext.js +3 -0
  163. package/dist/primitives/photonContext.js.map +1 -0
  164. package/dist/primitives/types.d.ts +15 -3
  165. package/dist/primitives/types.d.ts.map +1 -1
  166. package/dist/primitives/types.js.map +1 -1
  167. package/dist/primitives/useProvidedPhoton.d.ts +8 -0
  168. package/dist/primitives/useProvidedPhoton.d.ts.map +1 -0
  169. package/dist/primitives/useProvidedPhoton.js +8 -0
  170. package/dist/primitives/useProvidedPhoton.js.map +1 -0
  171. package/dist/styles.css +45 -3
  172. package/dist/test-utils/contract.d.ts.map +1 -1
  173. package/dist/test-utils/contract.js +23 -2
  174. package/dist/test-utils/contract.js.map +1 -1
  175. package/package.json +8 -3
  176. package/src/adapters/tailwind.tsx +52 -24
  177. package/src/analytics/PhotonAnalyticsProvider.test.tsx +190 -0
  178. package/src/analytics/PhotonAnalyticsProvider.tsx +151 -0
  179. package/src/analytics/cardLifecycle.test.tsx +272 -0
  180. package/src/analytics/cardLifecycle.ts +44 -0
  181. package/src/analytics/fieldInteraction.test.tsx +186 -0
  182. package/src/analytics/fieldInteraction.tsx +148 -0
  183. package/src/analytics/lifecycleOutcomes.test.ts +78 -0
  184. package/src/analytics/lifecycleOutcomes.ts +29 -0
  185. package/src/analytics/tracker.test.ts +52 -0
  186. package/src/analytics/tracker.ts +49 -0
  187. package/src/analytics/usePhotonAnalytics.test.tsx +106 -0
  188. package/src/analytics/viewed.ts +27 -0
  189. package/src/components/PhotonOrder.test.tsx +394 -0
  190. package/src/components/PhotonOrder.tsx +79 -53
  191. package/src/components/PhotonPatient.tsx +15 -166
  192. package/src/components/PhotonPrescription.test.tsx +120 -0
  193. package/src/components/PhotonPrescription.tsx +23 -583
  194. package/src/components/ScreeningAlerts.test.tsx +81 -0
  195. package/src/components/format.ts +2 -2
  196. package/src/components/index.ts +1 -1
  197. package/src/components/open.ts +13 -16
  198. package/src/components/order/DraftOrderPrompt.test.tsx +77 -0
  199. package/src/components/order/DraftOrderPrompt.tsx +81 -0
  200. package/src/components/patient/PatientCard/PatientCard.test.tsx +255 -0
  201. package/src/components/patient/PatientCard/PatientCard.tsx +177 -0
  202. package/src/components/patient/PatientCard/usePatientToShow.ts +44 -0
  203. package/src/components/patient/PatientIntakeForm.test.tsx +262 -0
  204. package/src/components/patient/PatientIntakeForm.tsx +222 -0
  205. package/src/components/patient/PatientSearch.test.tsx +204 -0
  206. package/src/components/patient/PatientSearch.tsx +221 -0
  207. package/src/components/patient/PatientSummary/BenefitsInputForm.test.tsx +164 -0
  208. package/src/components/patient/{Benefits.tsx → PatientSummary/BenefitsInputForm.tsx} +24 -16
  209. package/src/components/patient/PatientSummary/ClinicalInputForm.test.tsx +247 -0
  210. package/src/components/patient/{Clinical.tsx → PatientSummary/ClinicalInputForm.tsx} +53 -48
  211. package/src/components/patient/PatientSummary/CollapsedSummary.test.tsx +90 -0
  212. package/src/components/patient/PatientSummary/CollapsedSummary.tsx +46 -0
  213. package/src/components/patient/PatientSummary/PatientDetailsForm.test.tsx +201 -0
  214. package/src/components/patient/PatientSummary/PatientDetailsForm.tsx +320 -0
  215. package/src/components/patient/PatientSummary/PatientDetailsSchema.test.ts +296 -0
  216. package/src/components/patient/PatientSummary/PatientDetailsSchema.ts +95 -0
  217. package/src/components/patient/PatientSummary/PatientSummary.test.tsx +194 -0
  218. package/src/components/patient/PatientSummary/PatientSummary.tsx +225 -0
  219. package/src/components/patient/PatientSummary/SummaryHeader.test.tsx +183 -0
  220. package/src/components/patient/PatientSummary/SummaryHeader.tsx +85 -0
  221. package/src/components/patient/fields.tsx +12 -124
  222. package/src/components/patient/parsePatientSearchQuery.test.ts +107 -0
  223. package/src/components/patient/{query.ts → parsePatientSearchQuery.ts} +4 -15
  224. package/src/components/prescription/PrescriptionCard.test.tsx +247 -0
  225. package/src/components/prescription/PrescriptionCard.tsx +361 -0
  226. package/src/components/prescription/PrescriptionDetailsForm/DirectionsInput.test.tsx +82 -0
  227. package/src/components/prescription/PrescriptionDetailsForm/DirectionsInput.tsx +41 -0
  228. package/src/components/prescription/PrescriptionDetailsForm/DispenseInputs.test.tsx +206 -0
  229. package/src/components/prescription/PrescriptionDetailsForm/DispenseInputs.tsx +99 -0
  230. package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.test.tsx +453 -0
  231. package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsForm.tsx +238 -0
  232. package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.test.ts +63 -0
  233. package/src/components/prescription/PrescriptionDetailsForm/PrescriptionDetailsSchema.ts +15 -0
  234. package/src/components/prescription/PrescriptionDetailsForm/TemplatePicker.test.tsx +72 -0
  235. package/src/components/prescription/PrescriptionDetailsForm/TemplatePicker.tsx +41 -0
  236. package/src/components/prescription/TreatmentSearch/TreatmentPicker.tsx +375 -0
  237. package/src/components/prescription/TreatmentSearch/TreatmentSearch.test.tsx +695 -0
  238. package/src/components/prescription/TreatmentSearch/TreatmentSearch.tsx +220 -0
  239. package/src/components/schemaErrors.test.ts +49 -0
  240. package/src/components/schemaErrors.ts +34 -0
  241. package/src/components/search.tsx +1 -1
  242. package/src/index.ts +2 -0
  243. package/src/meta/version.test.ts +11 -0
  244. package/src/meta/version.ts +4 -0
  245. package/src/primitives/PhotonProvider.tsx +30 -15
  246. package/src/primitives/defaults.tsx +44 -21
  247. package/src/primitives/photonContext.ts +4 -0
  248. package/src/primitives/types.ts +15 -3
  249. package/src/primitives/useProvidedPhoton.ts +21 -0
  250. package/src/styles.css +45 -3
  251. package/src/test-utils/contract.tsx +45 -2
  252. package/dist/components/TreatmentPicker.d.ts +0 -45
  253. package/dist/components/TreatmentPicker.d.ts.map +0 -1
  254. package/dist/components/TreatmentPicker.js.map +0 -1
  255. package/dist/components/patient/Benefits.d.ts.map +0 -1
  256. package/dist/components/patient/Benefits.js.map +0 -1
  257. package/dist/components/patient/Clinical.d.ts.map +0 -1
  258. package/dist/components/patient/Clinical.js.map +0 -1
  259. package/dist/components/patient/IntakeForm.d.ts +0 -10
  260. package/dist/components/patient/IntakeForm.d.ts.map +0 -1
  261. package/dist/components/patient/IntakeForm.js +0 -324
  262. package/dist/components/patient/IntakeForm.js.map +0 -1
  263. package/dist/components/patient/Summary.d.ts +0 -48
  264. package/dist/components/patient/Summary.d.ts.map +0 -1
  265. package/dist/components/patient/Summary.js +0 -80
  266. package/dist/components/patient/Summary.js.map +0 -1
  267. package/dist/components/patient/query.d.ts +0 -23
  268. package/dist/components/patient/query.d.ts.map +0 -1
  269. package/dist/components/patient/query.js.map +0 -1
  270. package/src/components/TreatmentPicker.tsx +0 -350
  271. package/src/components/patient/IntakeForm.tsx +0 -532
  272. package/src/components/patient/Summary.tsx +0 -310
@@ -0,0 +1,296 @@
1
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
2
+ import { schemaErrors } from "../../schemaErrors.ts";
3
+ import { PatientDetailsSchema, type PatientDetailsFormValues } from "./PatientDetailsSchema.ts";
4
+
5
+ const errorsOf = (values: PatientDetailsFormValues) => schemaErrors(PatientDetailsSchema, values);
6
+
7
+ const blankAddress = { street1: "", street2: "", city: "", state: "", postalCode: "" };
8
+ const fullAddress = { street1: "1 Main St", street2: "Apt 2", city: "Boston", state: "MA", postalCode: "02101" };
9
+
10
+ /** Ada Lovelace with only the required fields filled in. */
11
+ const valid: PatientDetailsFormValues = {
12
+ firstName: "Ada",
13
+ lastName: "Lovelace",
14
+ dateOfBirth: "1990-01-01",
15
+ sex: "FEMALE",
16
+ phone: "",
17
+ email: "",
18
+ address: blankAddress,
19
+ };
20
+
21
+ // Date of birth checks compare against today, so pin today to 2026-11-24.
22
+ beforeEach(() => {
23
+ vi.useFakeTimers({ toFake: ["Date"] });
24
+ vi.setSystemTime(new Date(2026, 10, 24, 12));
25
+ });
26
+ afterEach(() => {
27
+ vi.useRealTimers();
28
+ });
29
+
30
+ describe("PatientDetailsSchema", () => {
31
+ it('only required fields filled in: no errors, blank phone and email parse as "", and a blank address as undefined', () => {
32
+ expect(errorsOf(valid)).toEqual({});
33
+ expect(PatientDetailsSchema.parse(valid)).toEqual({
34
+ firstName: "Ada",
35
+ lastName: "Lovelace",
36
+ dateOfBirth: "1990-01-01",
37
+ sex: "FEMALE",
38
+ phone: "",
39
+ email: "",
40
+ address: undefined,
41
+ });
42
+ });
43
+
44
+ it("errors in several fields at once: reports every field's error together", () => {
45
+ expect(
46
+ errorsOf({
47
+ ...valid,
48
+ firstName: "",
49
+ sex: null,
50
+ phone: "not a phone",
51
+ email: "not-an-email",
52
+ address: { ...blankAddress, city: "Boston" },
53
+ }),
54
+ ).toEqual({
55
+ firstName: "Required",
56
+ sex: "Required",
57
+ phone: "Enter a valid phone number",
58
+ email: "Enter a valid email",
59
+ address: { street1: "Required", state: "Required", postalCode: "Required" },
60
+ });
61
+ });
62
+
63
+ describe.each(["firstName", "lastName"] as const)("%s", (field) => {
64
+ it("filled in: no errors", () => {
65
+ expect(errorsOf({ ...valid, [field]: "Augusta" })).toEqual({});
66
+ });
67
+
68
+ it("typed with spaces around it: trims the value", () => {
69
+ expect(PatientDetailsSchema.parse({ ...valid, [field]: " Augusta " })[field]).toBe("Augusta");
70
+ });
71
+
72
+ it('empty string: errors with "Required"', () => {
73
+ expect(errorsOf({ ...valid, [field]: "" })).toEqual({ [field]: "Required" });
74
+ });
75
+
76
+ it('only spaces: errors with "Required"', () => {
77
+ expect(errorsOf({ ...valid, [field]: " " })).toEqual({ [field]: "Required" });
78
+ });
79
+ });
80
+
81
+ describe("dateOfBirth", () => {
82
+ it("valid date 1985-07-15: no errors, and parses the date as typed", () => {
83
+ expect(errorsOf({ ...valid, dateOfBirth: "1985-07-15" })).toEqual({});
84
+ expect(PatientDetailsSchema.parse({ ...valid, dateOfBirth: "1985-07-15" }).dateOfBirth).toBe("1985-07-15");
85
+ });
86
+
87
+ it('empty string: errors with "Required"', () => {
88
+ expect(errorsOf({ ...valid, dateOfBirth: "" })).toEqual({ dateOfBirth: "Required" });
89
+ });
90
+
91
+ it('only spaces: errors with "Required"', () => {
92
+ expect(errorsOf({ ...valid, dateOfBirth: " " })).toEqual({ dateOfBirth: "Required" });
93
+ });
94
+
95
+ it.each(["01/01/1990", "1990-1-1", "not a date"])(
96
+ 'invalid date format %j: errors with "Enter a valid date"',
97
+ (dateOfBirth) => {
98
+ expect(errorsOf({ ...valid, dateOfBirth })).toEqual({ dateOfBirth: "Enter a valid date" });
99
+ },
100
+ );
101
+
102
+ it.each(["2023-02-30", "2023-13-01", "2023-04-31"])(
103
+ 'nonexistent date %j: errors with "Enter a valid date"',
104
+ (dateOfBirth) => {
105
+ expect(errorsOf({ ...valid, dateOfBirth })).toEqual({ dateOfBirth: "Enter a valid date" });
106
+ },
107
+ );
108
+
109
+ it("a leap day, 2024-02-29: no errors", () => {
110
+ expect(errorsOf({ ...valid, dateOfBirth: "2024-02-29" })).toEqual({});
111
+ });
112
+
113
+ it("today, 2026-11-24: no errors", () => {
114
+ expect(errorsOf({ ...valid, dateOfBirth: "2026-11-24" })).toEqual({});
115
+ });
116
+
117
+ it('tomorrow, 2026-11-25: errors with "Date of birth can\'t be in the future"', () => {
118
+ expect(errorsOf({ ...valid, dateOfBirth: "2026-11-25" })).toEqual({
119
+ dateOfBirth: "Date of birth can't be in the future",
120
+ });
121
+ });
122
+ });
123
+
124
+ describe("sex", () => {
125
+ it.each(["MALE", "FEMALE", "UNKNOWN"] as const)("%s picked: no errors, and parses as the value picked", (sex) => {
126
+ expect(errorsOf({ ...valid, sex })).toEqual({});
127
+ expect(PatientDetailsSchema.parse({ ...valid, sex }).sex).toBe(sex);
128
+ });
129
+
130
+ it('nothing picked (null): errors with "Required"', () => {
131
+ expect(errorsOf({ ...valid, sex: null })).toEqual({ sex: "Required" });
132
+ });
133
+ });
134
+
135
+ describe("phone", () => {
136
+ // Common formats users might type
137
+ it.each([
138
+ ["415-555-0172", "+14155550172"],
139
+ ["(415) 555-0172", "+14155550172"],
140
+ ["4155550172", "+14155550172"],
141
+ ])("typed as %j: no errors, and parses the phone as %j", (phone, e164) => {
142
+ expect(errorsOf({ ...valid, phone })).toEqual({});
143
+ expect(PatientDetailsSchema.parse({ ...valid, phone }).phone).toBe(e164);
144
+ });
145
+
146
+ it('empty string: no errors because phone is optional, and parses as ""', () => {
147
+ expect(errorsOf({ ...valid, phone: "" })).toEqual({});
148
+ expect(PatientDetailsSchema.parse({ ...valid, phone: "" }).phone).toBe("");
149
+ });
150
+
151
+ it('only spaces: no errors because phone is optional, and parses as ""', () => {
152
+ expect(errorsOf({ ...valid, phone: " " })).toEqual({});
153
+ expect(PatientDetailsSchema.parse({ ...valid, phone: " " }).phone).toBe("");
154
+ });
155
+
156
+ it.each(["not a phone", "555-0172", "415-555-01723", "+44 20 7946 0958"])(
157
+ 'typed as %j: errors with "Enter a valid phone number"',
158
+ (phone) => {
159
+ expect(errorsOf({ ...valid, phone })).toEqual({ phone: "Enter a valid phone number" });
160
+ },
161
+ );
162
+ });
163
+
164
+ describe("email", () => {
165
+ it("typed with spaces around it: no errors, and trims the value", () => {
166
+ expect(errorsOf({ ...valid, email: " ada@example.com " })).toEqual({});
167
+ expect(PatientDetailsSchema.parse({ ...valid, email: " ada@example.com " }).email).toBe("ada@example.com");
168
+ });
169
+
170
+ it('empty string: no errors because email is optional, and parses as ""', () => {
171
+ expect(errorsOf({ ...valid, email: "" })).toEqual({});
172
+ expect(PatientDetailsSchema.parse({ ...valid, email: "" }).email).toBe("");
173
+ });
174
+
175
+ it('only spaces: no errors because email is optional, and parses as ""', () => {
176
+ expect(errorsOf({ ...valid, email: " " })).toEqual({});
177
+ expect(PatientDetailsSchema.parse({ ...valid, email: " " }).email).toBe("");
178
+ });
179
+
180
+ it.each(["not-an-email", "ada@", "ada@example", "ada lovelace@example.com"])(
181
+ 'typed as %j: errors with "Enter a valid email"',
182
+ (email) => {
183
+ expect(errorsOf({ ...valid, email })).toEqual({ email: "Enter a valid email" });
184
+ },
185
+ );
186
+ });
187
+
188
+ describe("address", () => {
189
+ it("every part is only spaces: no errors, because the address is optional, and parses as undefined", () => {
190
+ const spaces = { street1: " ", street2: " ", city: " ", state: " ", postalCode: " " };
191
+ expect(errorsOf({ ...valid, address: spaces })).toEqual({});
192
+ expect(PatientDetailsSchema.parse({ ...valid, address: spaces }).address).toBeUndefined();
193
+ });
194
+
195
+ // network-api's schema marks country optional, but its patient planner refuses an address without one, so the
196
+ // schema always sends "US"
197
+ it('every part filled in: no errors, and parses as the address to send, with country "US"', () => {
198
+ expect(errorsOf({ ...valid, address: fullAddress })).toEqual({});
199
+ expect(PatientDetailsSchema.parse({ ...valid, address: fullAddress }).address).toEqual({
200
+ street1: "1 Main St",
201
+ street2: "Apt 2",
202
+ city: "Boston",
203
+ state: "MA",
204
+ postalCode: "02101",
205
+ country: "US",
206
+ });
207
+ });
208
+
209
+ it('only street filled in: errors with "Required" on city, state and ZIP', () => {
210
+ expect(errorsOf({ ...valid, address: { ...blankAddress, street1: "1 Main St" } })).toEqual({
211
+ address: { city: "Required", state: "Required", postalCode: "Required" },
212
+ });
213
+ });
214
+
215
+ it('only Apt / suite filled in: errors with "Required" on street, city, state and ZIP', () => {
216
+ expect(errorsOf({ ...valid, address: { ...blankAddress, street2: "Apt 2" } })).toEqual({
217
+ address: { street1: "Required", city: "Required", state: "Required", postalCode: "Required" },
218
+ });
219
+ });
220
+
221
+ // Additional address validation runs in one superRefine, so ensure
222
+ // superRefine errors and "Required" errors are reported together
223
+ it('street missing and ZIP not valid: errors with "Required" on street and "Enter a 5-digit ZIP" on ZIP', () => {
224
+ expect(errorsOf({ ...valid, address: { ...fullAddress, street1: "", postalCode: "0210" } })).toEqual({
225
+ address: { street1: "Required", postalCode: "Enter a 5-digit ZIP" },
226
+ });
227
+ });
228
+
229
+ describe("address.street1", () => {
230
+ it('empty string, with the rest of the address filled in: errors with "Required"', () => {
231
+ expect(errorsOf({ ...valid, address: { ...fullAddress, street1: "" } })).toEqual({
232
+ address: { street1: "Required" },
233
+ });
234
+ });
235
+ });
236
+
237
+ describe("address.street2", () => {
238
+ it("empty string: no errors because Apt / suite is optional, and parses as undefined", () => {
239
+ const address = { ...fullAddress, street2: "" };
240
+ expect(errorsOf({ ...valid, address })).toEqual({});
241
+ expect(PatientDetailsSchema.parse({ ...valid, address }).address?.street2).toBeUndefined();
242
+ });
243
+ });
244
+
245
+ describe("address.city", () => {
246
+ it('empty string, with the rest of the address filled in: errors with "Required"', () => {
247
+ expect(errorsOf({ ...valid, address: { ...fullAddress, city: "" } })).toEqual({
248
+ address: { city: "Required" },
249
+ });
250
+ });
251
+ });
252
+
253
+ describe("address.state", () => {
254
+ it('empty string, with the rest of the address filled in: errors with "Required"', () => {
255
+ expect(errorsOf({ ...valid, address: { ...fullAddress, state: "" } })).toEqual({
256
+ address: { state: "Required" },
257
+ });
258
+ });
259
+
260
+ it('typed in lowercase, "ma": parses as "MA"', () => {
261
+ expect(PatientDetailsSchema.parse({ ...valid, address: { ...fullAddress, state: "ma" } }).address?.state).toBe(
262
+ "MA",
263
+ );
264
+ });
265
+
266
+ it.each(["M", "MAS", "M1", "Massachusetts"])('typed as %j: errors with "Enter a 2-letter state"', (state) => {
267
+ expect(errorsOf({ ...valid, address: { ...fullAddress, state } })).toEqual({
268
+ address: { state: "Enter a 2-letter state" },
269
+ });
270
+ });
271
+ });
272
+
273
+ describe("address.postalCode", () => {
274
+ it('empty string, with the rest of the address filled in: errors with "Required"', () => {
275
+ expect(errorsOf({ ...valid, address: { ...fullAddress, postalCode: "" } })).toEqual({
276
+ address: { postalCode: "Required" },
277
+ });
278
+ });
279
+
280
+ it("ZIP+4 format, 02101-1234: no errors, and parses as typed", () => {
281
+ const address = { ...fullAddress, postalCode: "02101-1234" };
282
+ expect(errorsOf({ ...valid, address })).toEqual({});
283
+ expect(PatientDetailsSchema.parse({ ...valid, address }).address?.postalCode).toBe("02101-1234");
284
+ });
285
+
286
+ it.each(["0210", "021011", "ABCDE", "02101-12"])(
287
+ 'typed as %j: errors with "Enter a 5-digit ZIP"',
288
+ (postalCode) => {
289
+ expect(errorsOf({ ...valid, address: { ...fullAddress, postalCode } })).toEqual({
290
+ address: { postalCode: "Enter a 5-digit ZIP" },
291
+ });
292
+ },
293
+ );
294
+ });
295
+ });
296
+ });
@@ -0,0 +1,95 @@
1
+ import { z } from "zod";
2
+ import { type Sex } from "@photonhealth/client";
3
+ import { PHONE_PATTERN, toE164 } from "../../format.ts";
4
+
5
+ const sexes: Sex[] = ["MALE", "FEMALE", "UNKNOWN"];
6
+
7
+ export const PatientDetailsSchema = z.object({
8
+ firstName: z.string().trim().min(1, "Required"),
9
+ lastName: z.string().trim().min(1, "Required"),
10
+ dateOfBirth: z
11
+ .string()
12
+ .trim()
13
+ .min(1, "Required")
14
+ .refine(isIsoDate, "Enter a valid date")
15
+ .refine((value) => value <= today(), "Date of birth can't be in the future"),
16
+ sex: z.enum(sexes, { error: "Required" }),
17
+ // network-api clears a phone or email sent as an empty string, so a blank phone or email parses as ""
18
+ phone: z
19
+ .string()
20
+ .trim()
21
+ .refine((value) => !value || isUsPhone(value), "Enter a valid phone number")
22
+ .transform((value) => toE164(value) ?? ""),
23
+ email: z
24
+ .string()
25
+ .trim()
26
+ .refine((value) => !value || z.email().safeParse(value).success, "Enter a valid email"),
27
+ address: z
28
+ .object({
29
+ street1: z.string().trim(),
30
+ street2: z.string().trim(),
31
+ city: z.string().trim(),
32
+ state: z.string().trim(),
33
+ postalCode: z.string().trim(),
34
+ })
35
+ .transform((value) =>
36
+ Object.values(value).some(Boolean)
37
+ ? {
38
+ street1: value.street1,
39
+ street2: value.street2 || undefined,
40
+ city: value.city,
41
+ state: value.state.toUpperCase(),
42
+ postalCode: value.postalCode,
43
+ // network-api's schema marks country optional, but its patient planner refuses an address without one.
44
+ // The form only takes US addresses (a 2-letter state, a 5-digit ZIP), so it always sends "US".
45
+ country: "US",
46
+ }
47
+ : undefined,
48
+ )
49
+ .superRefine((value, ctx) => {
50
+ if (!value) return;
51
+ for (const key of ["street1", "city", "state", "postalCode"] as const) {
52
+ if (!value[key]) ctx.addIssue({ code: "custom", path: [key], message: "Required" });
53
+ }
54
+ if (value.state && !/^[A-Z]{2}$/.test(value.state)) {
55
+ ctx.addIssue({ code: "custom", path: ["state"], message: "Enter a 2-letter state" });
56
+ }
57
+ if (value.postalCode && !/^\d{5}(-\d{4})?$/.test(value.postalCode)) {
58
+ ctx.addIssue({ code: "custom", path: ["postalCode"], message: "Enter a 5-digit ZIP" });
59
+ }
60
+ }),
61
+ });
62
+
63
+ /** The values to send, once every field is valid. */
64
+ export type PatientDetails = z.output<typeof PatientDetailsSchema>;
65
+
66
+ /** What the form holds while the prescriber edits it*/
67
+ export type PatientDetailsFormValues = {
68
+ firstName: string;
69
+ lastName: string;
70
+ dateOfBirth: string;
71
+ sex: Sex | null;
72
+ phone: string;
73
+ email: string;
74
+ address: { street1: string; street2: string; city: string; state: string; postalCode: string };
75
+ };
76
+
77
+ function isUsPhone(value: string) {
78
+ return new RegExp(`^(?:${PHONE_PATTERN})$`).test(value);
79
+ }
80
+
81
+ /** A real calendar date written as YYYY-MM-DD: "2023-02-30" is refused. */
82
+ function isIsoDate(value: string) {
83
+ const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
84
+ if (!match) return false;
85
+ const [year, month, day] = [Number(match[1]), Number(match[2]), Number(match[3])];
86
+ const date = new Date(Date.UTC(year, month - 1, day));
87
+ return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
88
+ }
89
+
90
+ /** Today's date in the prescriber's time zone, as YYYY-MM-DD, so it compares with a date of birth as text. */
91
+ function today() {
92
+ const now = new Date();
93
+ const pad = (n: number) => String(n).padStart(2, "0");
94
+ return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}`;
95
+ }
@@ -0,0 +1,194 @@
1
+ import { fireEvent, render, screen } from "@testing-library/react";
2
+ import userEvent from "@testing-library/user-event";
3
+ import { afterEach, beforeEach, describe, expect, it } from "vitest";
4
+ import { fakeNetworkApiClient, payload } from "@photonhealth/client/testing";
5
+ import { PhotonPatient } from "../../../index.ts";
6
+ import { patient } from "../../../../test/cards.fixtures.tsx";
7
+ import {
8
+ buildEditedEventsFor,
9
+ leaveField,
10
+ meAsPrescriber,
11
+ recordAnalytics,
12
+ type RecordedAnalytics,
13
+ typeInto,
14
+ unmountAndRestoreFetch,
15
+ withAnalytics,
16
+ } from "../../../../test/analytics.fixtures.tsx";
17
+
18
+ let analytics: RecordedAnalytics;
19
+ beforeEach(() => {
20
+ analytics = recordAnalytics();
21
+ });
22
+ afterEach(unmountAndRestoreFetch);
23
+
24
+ const editPatient = async () => {
25
+ render(<PhotonPatient patient="pat_1" />, {
26
+ wrapper: withAnalytics(
27
+ fakeNetworkApiClient({
28
+ ...meAsPrescriber,
29
+ GetPatient: () => payload("patient", "PatientPayload", patient),
30
+ UpdatePatient: () => payload("patient", "PatientPayload", patient),
31
+ }).client,
32
+ ),
33
+ });
34
+ await userEvent.click(await screen.findByRole("button", { name: "Edit patient" }));
35
+ };
36
+
37
+ describe("PatientSummary: Field Interaction", () => {
38
+ it("editing a patient: each field visited sends focus, one change and blur as update_patient_form", async () => {
39
+ await editPatient();
40
+ await typeInto("First name", "Zqx");
41
+ await typeInto("Last name", "Zqx");
42
+ await userEvent.click(screen.getByLabelText("Date of birth"));
43
+ fireEvent.change(screen.getByLabelText("Date of birth"), { target: { value: "1991-02-03" } });
44
+ leaveField();
45
+ await userEvent.selectOptions(screen.getByRole("combobox", { name: "Sex" }), "FEMALE");
46
+ leaveField();
47
+ await typeInto("Phone", "5555550100");
48
+ await typeInto("Email", "zqx@example.com");
49
+ await typeInto("Street", "Zqx");
50
+ await typeInto("Apt / suite", "Zqx");
51
+ await typeInto("City", "Zqx");
52
+ await typeInto("State", "{Backspace}Q");
53
+ await typeInto("ZIP", "99999");
54
+ for (const addLabel of ["Add allergy", "Add medication", "Add diagnosis"]) {
55
+ await userEvent.click(screen.getByRole("button", { name: addLabel }));
56
+ await userEvent.keyboard("Zqxentry");
57
+ leaveField();
58
+ }
59
+ await userEvent.click(screen.getByRole("button", { name: "Add insurance" }));
60
+ await userEvent.keyboard("987654");
61
+ await userEvent.tab();
62
+ await userEvent.keyboard("ZQXPCN");
63
+ leaveField();
64
+
65
+ const fields = {
66
+ firstName: false,
67
+ lastName: false,
68
+ dateOfBirth: false,
69
+ sex: false,
70
+ phone: true,
71
+ email: true,
72
+ address_street1: true,
73
+ address_street2: true,
74
+ address_city: true,
75
+ address_state: true,
76
+ address_zip: true,
77
+ allergies: true,
78
+ medications: true,
79
+ diagnoses: true,
80
+ insurance: true,
81
+ };
82
+ await analytics.expectEventLog([
83
+ "Prescribe Workflow Viewed",
84
+ ...buildEditedEventsFor("firstName"),
85
+ ...buildEditedEventsFor("lastName"),
86
+ ...buildEditedEventsFor("dateOfBirth"),
87
+ ...buildEditedEventsFor("sex"),
88
+ ...buildEditedEventsFor("phone"),
89
+ ...buildEditedEventsFor("email"),
90
+ ...buildEditedEventsFor("address_street1"),
91
+ ...buildEditedEventsFor("address_street2"),
92
+ ...buildEditedEventsFor("address_city"),
93
+ ...buildEditedEventsFor("address_state"),
94
+ ...buildEditedEventsFor("address_zip"),
95
+ ...buildEditedEventsFor("allergies"),
96
+ ...buildEditedEventsFor("medications"),
97
+ ...buildEditedEventsFor("diagnoses"),
98
+ ...buildEditedEventsFor("insurance"),
99
+ ]);
100
+ const sent = analytics.fieldInteractions();
101
+ expect(new Set(sent.map((s) => s.formName))).toEqual(new Set(["update_patient_form"]));
102
+ expect(Object.fromEntries(sent.map((s) => [s.fieldName, s.isOptional]))).toEqual(fields);
103
+ for (const body of analytics.bodies()) expect(body).not.toMatch(/Zqx|1991|5555550100|99999|987654|FEMALE/i);
104
+ });
105
+ });
106
+
107
+ describe("PatientSummary: Cancel editing patient", () => {
108
+ it('clicking "Cancel editing patient": closes the editors', async () => {
109
+ await editPatient();
110
+ await userEvent.click(screen.getByRole("button", { name: "Cancel editing patient" }));
111
+ expect(screen.queryByLabelText("First name")).not.toBeInTheDocument();
112
+ expect(screen.getByRole("button", { name: "Edit patient" })).toBeInTheDocument();
113
+ });
114
+ });
115
+
116
+ describe("PatientSummary: Save", () => {
117
+ /**
118
+ * Expands the editors with a patient that has every required field on file.
119
+ * `updates` lists each UpdatePatient sent. `updatePatient` answers them (by default, at once with the patient).
120
+ * */
121
+ const savable = { ...patient, demographic: { ...patient.demographic, sex: "FEMALE" } };
122
+ const editSavablePatient = async (
123
+ updatePatient: () => unknown = () => payload("patient", "PatientPayload", savable),
124
+ ) => {
125
+ const network = fakeNetworkApiClient({
126
+ ...meAsPrescriber,
127
+ GetPatient: () => payload("patient", "PatientPayload", savable),
128
+ UpdatePatient: updatePatient,
129
+ });
130
+ render(<PhotonPatient patient="pat_1" />, { wrapper: withAnalytics(network.client) });
131
+ await userEvent.click(await screen.findByRole("button", { name: "Edit patient" }));
132
+ return { updates: () => network.calls.filter((call) => call.name === "UpdatePatient") };
133
+ };
134
+
135
+ it("last name changed, clicking Save: sends one UpdatePatient with the last name, and closes the editors", async () => {
136
+ const { updates } = await editSavablePatient();
137
+ await userEvent.clear(screen.getByLabelText("Last name"));
138
+ await userEvent.type(screen.getByLabelText("Last name"), "Byron");
139
+ await userEvent.click(screen.getByRole("button", { name: "Save" }));
140
+ expect(await screen.findByRole("button", { name: "Edit patient" })).toBeInTheDocument();
141
+ expect(updates()).toHaveLength(1);
142
+ expect(JSON.stringify(updates()[0]!.vars)).toContain("Byron");
143
+ });
144
+
145
+ // Pins today's behavior: Save sends every field, changed or not
146
+ // TODO: Decide if it's important to send only fields that changed
147
+ it("nothing changed, clicking Save: still sends one UpdatePatient, and closes the editors", async () => {
148
+ const { updates } = await editSavablePatient();
149
+ await userEvent.click(screen.getByRole("button", { name: "Save" }));
150
+ expect(await screen.findByRole("button", { name: "Edit patient" })).toBeInTheDocument();
151
+ expect(updates()).toHaveLength(1);
152
+ });
153
+
154
+ /** An UpdatePatient that stays in flight until the test calls `finish`. */
155
+ const updateInFlight = () => {
156
+ let finish = () => {};
157
+ const respond = () =>
158
+ new Promise((resolve) => {
159
+ finish = () => resolve(payload("patient", "PatientPayload", savable));
160
+ });
161
+ return { respond, finish: () => finish() };
162
+ };
163
+
164
+ const changeLastNameAndSave = async () => {
165
+ await userEvent.clear(screen.getByLabelText("Last name"));
166
+ await userEvent.type(screen.getByLabelText("Last name"), "Byron");
167
+ await userEvent.click(screen.getByRole("button", { name: "Save" }));
168
+ };
169
+
170
+ describe("while the update is in flight", () => {
171
+ it("clicking Save: keeps the editors open, with Save disabled, until network-api answers", async () => {
172
+ const update = updateInFlight();
173
+ const { updates } = await editSavablePatient(update.respond);
174
+ await changeLastNameAndSave();
175
+ expect(updates()).toHaveLength(1);
176
+ expect(screen.getByRole("button", { name: "Save" })).toBeDisabled();
177
+ expect(screen.queryByRole("button", { name: "Edit patient" })).not.toBeInTheDocument();
178
+
179
+ update.finish();
180
+ expect(await screen.findByRole("button", { name: "Edit patient" })).toBeInTheDocument();
181
+ });
182
+ });
183
+
184
+ it('network-api refuses the update: keeps the editors open with the last name typed, and shows "Couldn\'t save" with the reason', async () => {
185
+ await editSavablePatient(() => {
186
+ throw new Error("network-api is down");
187
+ });
188
+ await changeLastNameAndSave();
189
+ expect(await screen.findByText("Couldn't save")).toBeInTheDocument();
190
+ expect(screen.getByText("network-api is down")).toBeInTheDocument();
191
+ expect(screen.getByLabelText("Last name")).toHaveValue("Byron");
192
+ expect(screen.getByRole("button", { name: "Save" })).toBeEnabled();
193
+ });
194
+ });