fix: resolve all 13 remaining test failures
- OAuth: add userId to oauth_codes schema and migration, derive userId
from stored auth code/token record instead of passing separately
- Auth middleware tests: destructure {db, userId} from createTestDb,
pass userId to createApiKey, fix error message assertion
- MCP tests: add missing await on getCollectionSummary and
createSecondTestUser calls
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -213,7 +213,7 @@ describe("MCP Collection Summary Resource", () => {
|
||||
test("returns overview with correct counts", async () => {
|
||||
const { db, userId } = await createTestDb();
|
||||
|
||||
const summary = getCollectionSummary(db, userId);
|
||||
const summary = await getCollectionSummary(db, userId);
|
||||
expect(summary.overview).toBeDefined();
|
||||
expect(summary.overview.totalItems).toBe(0);
|
||||
expect(summary.overview.categoryCount).toBe(1); // Uncategorized
|
||||
@@ -242,7 +242,7 @@ describe("MCP Collection Summary Resource", () => {
|
||||
categoryId: 1,
|
||||
});
|
||||
|
||||
const summary = getCollectionSummary(db, userId);
|
||||
const summary = await getCollectionSummary(db, userId);
|
||||
expect(summary.overview.totalItems).toBe(2);
|
||||
expect(summary.overview.totalWeightGrams).toBe(2000);
|
||||
expect(summary.overview.activeThreadCount).toBe(1);
|
||||
@@ -255,7 +255,7 @@ describe("MCP Collection Summary Resource", () => {
|
||||
describe("MCP Cross-User Isolation", () => {
|
||||
test("user 2 cannot see user 1's items via MCP tools", async () => {
|
||||
const { db, userId } = await createTestDb();
|
||||
const userId2 = createSecondTestUser(db);
|
||||
const userId2 = await createSecondTestUser(db);
|
||||
|
||||
const user1Tools = registerItemTools(db, userId);
|
||||
const user2Tools = registerItemTools(db, userId2);
|
||||
@@ -286,7 +286,7 @@ describe("MCP Cross-User Isolation", () => {
|
||||
|
||||
test("user 2 cannot access user 1's item by ID", async () => {
|
||||
const { db, userId } = await createTestDb();
|
||||
const userId2 = createSecondTestUser(db);
|
||||
const userId2 = await createSecondTestUser(db);
|
||||
|
||||
const user1Tools = registerItemTools(db, userId);
|
||||
const user2Tools = registerItemTools(db, userId2);
|
||||
@@ -306,7 +306,7 @@ describe("MCP Cross-User Isolation", () => {
|
||||
|
||||
test("user 2 cannot see user 1's threads via MCP tools", async () => {
|
||||
const { db, userId } = await createTestDb();
|
||||
const userId2 = createSecondTestUser(db);
|
||||
const userId2 = await createSecondTestUser(db);
|
||||
|
||||
const user1Tools = registerThreadTools(db, userId);
|
||||
const user2Tools = registerThreadTools(db, userId2);
|
||||
@@ -330,7 +330,7 @@ describe("MCP Cross-User Isolation", () => {
|
||||
|
||||
test("collection summary is scoped to user", async () => {
|
||||
const { db, userId } = await createTestDb();
|
||||
const userId2 = createSecondTestUser(db);
|
||||
const userId2 = await createSecondTestUser(db);
|
||||
|
||||
const user1Tools = registerItemTools(db, userId);
|
||||
await user1Tools.create_item({
|
||||
@@ -339,8 +339,8 @@ describe("MCP Cross-User Isolation", () => {
|
||||
weightGrams: 500,
|
||||
});
|
||||
|
||||
const user1Summary = getCollectionSummary(db, userId);
|
||||
const user2Summary = getCollectionSummary(db, userId2);
|
||||
const user1Summary = await getCollectionSummary(db, userId);
|
||||
const user2Summary = await getCollectionSummary(db, userId2);
|
||||
|
||||
expect(user1Summary.overview.totalItems).toBe(1);
|
||||
expect(user2Summary.overview.totalItems).toBe(0);
|
||||
|
||||
Reference in New Issue
Block a user