|
1 | 1 | import { describe, expect, it } from "vitest"; |
2 | 2 | import { |
3 | | - buildGatewayPropertyHeaders, |
4 | 3 | getLlmGatewayUrl, |
5 | 4 | resolveGatewayProduct, |
6 | 5 | resolveLlmGatewayUrl, |
@@ -60,83 +59,6 @@ describe("resolveGatewayProduct", () => { |
60 | 59 | ); |
61 | 60 | }); |
62 | 61 |
|
63 | | -describe("buildGatewayPropertyHeaders", () => { |
64 | | - it("renders each property as an x-posthog-property header line", () => { |
65 | | - expect( |
66 | | - buildGatewayPropertyHeaders({ |
67 | | - task_origin_product: "signal_report", |
68 | | - task_internal: true, |
69 | | - }), |
70 | | - ).toBe( |
71 | | - "x-posthog-property-task_origin_product: signal_report\nx-posthog-property-task_internal: true", |
72 | | - ); |
73 | | - }); |
74 | | - |
75 | | - it("drops null and undefined values but keeps falsy primitives", () => { |
76 | | - expect( |
77 | | - buildGatewayPropertyHeaders({ |
78 | | - task_origin_product: null, |
79 | | - task_internal: false, |
80 | | - task_count: 0, |
81 | | - }), |
82 | | - ).toBe( |
83 | | - "x-posthog-property-task_internal: false\nx-posthog-property-task_count: 0", |
84 | | - ); |
85 | | - }); |
86 | | - |
87 | | - it("returns an empty string when no usable properties remain", () => { |
88 | | - expect( |
89 | | - buildGatewayPropertyHeaders({ |
90 | | - task_origin_product: null, |
91 | | - task_internal: undefined, |
92 | | - }), |
93 | | - ).toBe(""); |
94 | | - }); |
95 | | - |
96 | | - it.each([ |
97 | | - { |
98 | | - description: "LF", |
99 | | - title: "Fix the bug\nx-posthog-property-task_internal: true", |
100 | | - }, |
101 | | - { |
102 | | - description: "CRLF", |
103 | | - title: "Fix the bug\r\nx-posthog-property-task_internal: true", |
104 | | - }, |
105 | | - { |
106 | | - description: "CR", |
107 | | - title: "Fix the bug\rx-posthog-property-task_internal: true", |
108 | | - }, |
109 | | - { |
110 | | - description: "consecutive newlines", |
111 | | - title: "Fix the bug\n\nx-posthog-property-task_internal: true", |
112 | | - }, |
113 | | - ])( |
114 | | - "collapses $description in values so they cannot inject extra headers", |
115 | | - ({ title }) => { |
116 | | - expect( |
117 | | - buildGatewayPropertyHeaders({ |
118 | | - task_title: title, |
119 | | - task_id: "task-abc", |
120 | | - }), |
121 | | - ).toBe( |
122 | | - "x-posthog-property-task_title: Fix the bug x-posthog-property-task_internal: true\nx-posthog-property-task_id: task-abc", |
123 | | - ); |
124 | | - }, |
125 | | - ); |
126 | | - |
127 | | - it("strips characters an HTTP header value cannot carry", () => { |
128 | | - expect(buildGatewayPropertyHeaders({ task_title: "don’t🚀ship" })).toBe( |
129 | | - "x-posthog-property-task_title: dontship", |
130 | | - ); |
131 | | - }); |
132 | | - |
133 | | - it("keeps latin1 characters such as accents", () => { |
134 | | - expect(buildGatewayPropertyHeaders({ task_title: "café" })).toBe( |
135 | | - "x-posthog-property-task_title: café", |
136 | | - ); |
137 | | - }); |
138 | | -}); |
139 | | - |
140 | 62 | describe("resolveLlmGatewayUrl", () => { |
141 | 63 | it("appends the product slug to an env-provided base URL", () => { |
142 | 64 | expect( |
|
0 commit comments