1
0
Fork 0
mirror of synced 2024-05-25 14:50:33 +12:00

Ensure snippet context is disabled by default in test. Add override for search

This commit is contained in:
Dean 2024-05-02 17:59:55 +01:00
parent 407dacaf8c
commit 3823ffa4fd
3 changed files with 4 additions and 4 deletions

View file

@ -281,7 +281,7 @@ export function doInScimContext(task: any) {
return newContext(updates, task)
}
export async function ensureSnippetContext() {
export async function ensureSnippetContext(enabled = !env.isTest()) {
const ctx = getCurrentContext()
// If we've already added snippets to context, continue
@ -292,7 +292,7 @@ export async function ensureSnippetContext() {
// Otherwise get snippets for this app and update context
let snippets: Snippet[] | undefined
const db = getAppDB()
if (db) {
if (db && enabled) {
const app = await db.get<App>(DocumentType.APP_METADATA)
snippets = app.snippets
}

View file

@ -198,7 +198,7 @@ export async function destroy(ctx: UserCtx<DeleteRowRequest>) {
export async function search(ctx: Ctx<SearchRowRequest, SearchRowResponse>) {
const tableId = utils.getTableId(ctx)
await context.ensureSnippetContext()
await context.ensureSnippetContext(true)
const enrichedQuery = await utils.enrichSearchContext(
{ ...ctx.request.body.query },

View file

@ -57,7 +57,7 @@ export async function searchView(
})
}
await context.ensureSnippetContext()
await context.ensureSnippetContext(true)
const enrichedQuery = await enrichSearchContext(query, {
user: sdk.users.getUserContextBindings(ctx.user),