Skip to content

Commit

Permalink
added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fomalhautb committed Oct 1, 2024
1 parent 1842608 commit 6985443
Showing 1 changed file with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,59 @@ it("cannot create duplicate contact channels", async ({ expect }) => {
`);
});

it("create contact channel on the server", async ({ expect }) => {
await Project.createAndSwitch({ config: { magic_link_enabled: true } });
const { userId } = await Auth.Otp.signIn();

const response = await niceBackendFetch(`/api/v1/contact-channels/${userId}`, {
accessType: "server",
method: "POST",
body: {
value: "[email protected]",
type: "email",
used_for_auth: false,
is_verified: true,
}
});
expect(response).toMatchInlineSnapshot(`
NiceResponse {
"status": 201,
"body": {
"id": "<stripped UUID>",
"is_verified": true,
"type": "email",
"used_for_auth": false,
"value": "[email protected]",
},
"headers": Headers { <some fields may have been hidden> },
}
`);

const userResponse = await niceBackendFetch(`/api/v1/users/${userId}`, {
accessType: "server",
});
expect(userResponse.body.contact_channels).toMatchInlineSnapshot(`
[
{
"id": "<stripped UUID>",
"is_primary": true,
"is_verified": true,
"type": "email",
"used_for_auth": true,
"value": "<stripped UUID>@stack-generated.example.com",
},
{
"id": "<stripped UUID>",
"is_primary": false,
"is_verified": true,
"type": "email",
"used_for_auth": false,
"value": "[email protected]",
},
]
`);
});


it("delete contact channel on the client", async ({ expect }) => {
await Project.createAndSwitch({ config: { magic_link_enabled: true } });
Expand Down

0 comments on commit 6985443

Please sign in to comment.