Ensure snippet context is disabled by default in test. Add override for search
This commit is contained in:
parent
407dacaf8c
commit
3823ffa4fd
|
@ -281,7 +281,7 @@ export function doInScimContext(task: any) {
|
||||||
return newContext(updates, task)
|
return newContext(updates, task)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function ensureSnippetContext() {
|
export async function ensureSnippetContext(enabled = !env.isTest()) {
|
||||||
const ctx = getCurrentContext()
|
const ctx = getCurrentContext()
|
||||||
|
|
||||||
// If we've already added snippets to context, continue
|
// 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
|
// Otherwise get snippets for this app and update context
|
||||||
let snippets: Snippet[] | undefined
|
let snippets: Snippet[] | undefined
|
||||||
const db = getAppDB()
|
const db = getAppDB()
|
||||||
if (db) {
|
if (db && enabled) {
|
||||||
const app = await db.get<App>(DocumentType.APP_METADATA)
|
const app = await db.get<App>(DocumentType.APP_METADATA)
|
||||||
snippets = app.snippets
|
snippets = app.snippets
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,7 +198,7 @@ export async function destroy(ctx: UserCtx<DeleteRowRequest>) {
|
||||||
export async function search(ctx: Ctx<SearchRowRequest, SearchRowResponse>) {
|
export async function search(ctx: Ctx<SearchRowRequest, SearchRowResponse>) {
|
||||||
const tableId = utils.getTableId(ctx)
|
const tableId = utils.getTableId(ctx)
|
||||||
|
|
||||||
await context.ensureSnippetContext()
|
await context.ensureSnippetContext(true)
|
||||||
|
|
||||||
const enrichedQuery = await utils.enrichSearchContext(
|
const enrichedQuery = await utils.enrichSearchContext(
|
||||||
{ ...ctx.request.body.query },
|
{ ...ctx.request.body.query },
|
||||||
|
|
|
@ -57,7 +57,7 @@ export async function searchView(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
await context.ensureSnippetContext()
|
await context.ensureSnippetContext(true)
|
||||||
|
|
||||||
const enrichedQuery = await enrichSearchContext(query, {
|
const enrichedQuery = await enrichSearchContext(query, {
|
||||||
user: sdk.users.getUserContextBindings(ctx.user),
|
user: sdk.users.getUserContextBindings(ctx.user),
|
||||||
|
|
Loading…
Reference in New Issue