-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1842608
commit 6985443
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 } }); | ||
|