Skip to content

Commit

Permalink
Update Test
Browse files Browse the repository at this point in the history
  • Loading branch information
awhiteside1 committed Sep 16, 2024
1 parent aa2c4c1 commit 8c8968d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
auto-install-peers=true
2 changes: 2 additions & 0 deletions packages/llm-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"type": "module",
"types": "./dist/index.d.ts",
"module": "./dist/index.mjs",
"version": "0.0.1",
"files": ["dist/"],
"exports": {
".": {
Expand All @@ -11,6 +12,7 @@
}
},
"scripts": {
"prepack": "pnpm run build",
"test": "vitest --run",
"bench": "vitest --run bench",
"build:stub": "unbuild --stub",
Expand Down
3 changes: 3 additions & 0 deletions packages/semantic-search/e2e/_setup/vitest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ export default async function setup({ provide }: GlobalSetupContext) {
await mongo.start()
}
provide('mongoURL', mongo.getUri())
return async () => {
await mongo.stop()
}
}

declare module 'vitest' {
Expand Down
12 changes: 7 additions & 5 deletions packages/semantic-search/e2e/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ import { mongooseAdapter } from '@payloadcms/db-mongodb'
import { MongoMemoryReplSet } from 'mongodb-memory-server'
import payload, { buildConfig, type Payload } from 'payload'
import { list } from 'radash'
import { beforeAll, expect } from 'vitest'
import { afterAll, beforeAll, expect } from 'vitest'
import { semanticSearchPlugin } from '../src'
import {
givenACollectionConfig,
givenAVectorDB,
givenAnEnvironment,
} from './_setup/createConfig'

describe('Semantic Search', () => {
describe('Semantic Search', async () => {
let instance: Payload
const mongo = await MongoMemoryReplSet.create()

const spys = {
embeddingSpy: vi.fn(() =>
Expand All @@ -21,8 +22,6 @@ describe('Semantic Search', () => {
}

beforeAll(async () => {
const mongo = await MongoMemoryReplSet.create()

const environment = givenAnEnvironment({
collections: [givenACollectionConfig({ slug: 'myCollection' })],
plugins: [
Expand All @@ -38,10 +37,13 @@ describe('Semantic Search', () => {
})
instance = await payload.init({
config: buildConfig(environment),
loggerOptions: { enabled: true },
loggerOptions: { enabled: false },
})
})

afterAll(async () => {
await mongo.stop()
})
it('should insert a vector on create', async () => {
const item = await instance.create({
collection: 'myCollection',
Expand Down
3 changes: 2 additions & 1 deletion packages/semantic-search/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@payload-llm-plugins/semantic-search",
"type": "module",
"version": "0.0.1",
"types": "./dist/index.d.ts",
"module": "./dist/index.mjs",
"files": ["dist/"],
Expand All @@ -11,6 +12,7 @@
}
},
"scripts": {
"prepack": "pnpm run build",
"test": "vitest --run",
"bench": "vitest --run bench",
"build:stub": "unbuild --stub",
Expand All @@ -32,7 +34,6 @@
"defu": "^6.1.4",
"radash": "^12.1.0"
},
"bundledDependencies": ["@workspace/llm-utils"],
"peerDependencies": {
"payload": "^3.0.0-beta.107"
}
Expand Down

0 comments on commit 8c8968d

Please sign in to comment.