History

Cover whitespace-only provider turn validation

Julius Marminge committed 4 months ago

Commit 44a94f41 parent c56fe691 file · +19 −0Browse files

Unified · Split

apps/server/src/provider/ProviderService.test.ts+19−0
@@ -1810,6 +1810,25 @@ fanout.layer("ProviderServiceLive fanout", (it) => { · 1809 unmodified lines
18101810
18111811 const validation = makeProviderServiceLayer();
18121812 validation.layer("ProviderServiceLive validation", (it) => {
1813+ it.effect("rejects whitespace-only turns without attachments", () =>
1814+ Effect.gen(function* () {
1815+ const provider = yield* ProviderService.ProviderService;
1816+
1817+ validation.codex.sendTurn.mockClear();
1818+ const failure = yield* provider
1819+ .sendTurn({
1820+ threadId: asThreadId("thread-whitespace-only"),
1821+ input: " \n\t ",
1822+ attachments: [],
1823+ })
1824+ .pipe(Effect.flip);
1825+
1826+ assert.instanceOf(failure, ProviderValidationError);
1827+ assert.equal(failure.operation, "ProviderService.sendTurn");
1828+ assert.equal(validation.codex.sendTurn.mock.calls.length, 0);
1829+ }),
1830+ );
1831+
18131832 it.effect("rejects session starts without an explicit provider instance id", () =>
18141833 Effect.gen(function* () {
18151834 const provider = yield* ProviderService.ProviderService;