Skip to content

Instantly share code, notes, and snippets.

@colinfwren
Created August 4, 2024 20:17
Show Gist options
  • Save colinfwren/4ed1179881a1c728ab5bb752e364d74e to your computer and use it in GitHub Desktop.
Save colinfwren/4ed1179881a1c728ab5bb752e364d74e to your computer and use it in GitHub Desktop.
Reading values from Appwrite after test
async function getRecordDetails(recId: String): Promise<Models.Doc> {
const client = new Client()
.setEndpoint(APPWRITE_URL)
.setProject(APPWRITE_PROJECT)
.setKey(APPWRITE_API_KEY)
const databases = new Databases(client)
return databases.getDocument(DATABASE_ID, COL_ID, recId)
}
test('that created thing has permissions', async () => {
const { user, jwt } = await getNewUser()
const recId = await someFunctionThatCreatesSomethingViaGraphQL()
const createdThing = await getRecordDetails(recId)
expect(createdTodo.$permissions).toMatchObject([
`read("user:${user.$id}")`,
`update("user:${user.$id}")`,
`delete("user:${user.$id}")`
])
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment