Skip to content

Commit 98e51a1

Browse files
committed
test(cli): protect whoami machine output
1 parent 467a0a1 commit 98e51a1

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

apps/cli/src/commands/whoami/whoami.integration.test.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,33 @@ describe("whoami integration", () => {
8181
}).pipe(Effect.provide(layer));
8282
});
8383

84-
it.live("emits the profile object for --output-format json", () => {
84+
it.live("emits stable CLI identity fields for --output-format json", () => {
8585
const { layer, out } = setup({ format: "json" });
8686
return Effect.gen(function* () {
8787
yield* whoami({});
88-
expect(out.messages.find((message) => message.type === "success")?.data).toEqual(
89-
SAMPLE_PROFILE,
90-
);
88+
expect(JSON.parse(out.stdoutText)).toEqual({
89+
id: SAMPLE_PROFILE.gotrue_id,
90+
email: SAMPLE_PROFILE.primary_email,
91+
username: SAMPLE_PROFILE.username,
92+
});
9193
}).pipe(Effect.provide(layer));
9294
});
9395

94-
it.live("emits the profile object for --output-format stream-json", () => {
96+
it.live("emits stable CLI identity fields for --output-format stream-json", () => {
9597
const { layer, out } = setup({ format: "stream-json" });
9698
return Effect.gen(function* () {
9799
yield* whoami({});
98-
expect(out.messages.find((message) => message.type === "success")?.data).toEqual(
99-
SAMPLE_PROFILE,
100-
);
100+
expect(out.events).toEqual([
101+
{
102+
type: "result",
103+
data: {
104+
id: SAMPLE_PROFILE.gotrue_id,
105+
email: SAMPLE_PROFILE.primary_email,
106+
username: SAMPLE_PROFILE.username,
107+
},
108+
timestamp: expect.any(String),
109+
},
110+
]);
101111
}).pipe(Effect.provide(layer));
102112
});
103113

0 commit comments

Comments
 (0)