From 6560ceabc87d89b6a8816245ab1d2b6147ec29f9 Mon Sep 17 00:00:00 2001 From: Tim Leslie Date: Fri, 14 May 2021 10:59:11 +1000 Subject: [PATCH] Update more tests to new APIs --- tests/api-tests/access-control/authed.test.ts | 2 +- tests/api-tests/access-control/updateMany.test.ts | 2 +- tests/api-tests/access-control/utils.ts | 8 ++++---- tests/api-tests/auth-header.test.ts | 2 +- tests/api-tests/queries/cache-hints.test.ts | 4 ++-- tests/api-tests/queries/limits.test.ts | 4 ++-- .../nested-mutations/create-singular.test.ts | 4 ++-- tests/api-tests/server-side-graphql-client.test.ts | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/api-tests/access-control/authed.test.ts b/tests/api-tests/access-control/authed.test.ts index 5cf0b2cd76e..1c381065052 100644 --- a/tests/api-tests/access-control/authed.test.ts +++ b/tests/api-tests/access-control/authed.test.ts @@ -69,7 +69,7 @@ multiAdapterRunners().map(({ before, after, provider }) => for (const [listKey, _items] of Object.entries(initialData)) { items[listKey] = (await context.lists[listKey].createMany({ data: _items.map(x => ({ data: x })), - query: 'id, name', + query: 'id name', })) as { id: IdType; name: string }[]; } user = (await context.lists.User.createOne({ diff --git a/tests/api-tests/access-control/updateMany.test.ts b/tests/api-tests/access-control/updateMany.test.ts index 2e580ed9e78..2e5856195d2 100644 --- a/tests/api-tests/access-control/updateMany.test.ts +++ b/tests/api-tests/access-control/updateMany.test.ts @@ -40,7 +40,7 @@ multiAdapterRunners().map(({ runner, provider }) => })) as { id: any }[]; // Attempt to update all four items const _users = await context.exitSudo().lists.User.updateMany({ - data: users.map(({ id }) => ({ id, data: { name: 'new name' } })), + data: users.map(({ id }) => ({ where: { id }, data: { name: 'new name' } })), query: 'id name isUpdatable', }); // We don't expect an error, but only two of the items should get updated and returned diff --git a/tests/api-tests/access-control/utils.ts b/tests/api-tests/access-control/utils.ts index 189bd303025..625593d2c87 100644 --- a/tests/api-tests/access-control/utils.ts +++ b/tests/api-tests/access-control/utils.ts @@ -94,7 +94,7 @@ function setupKeystone(provider: ProviderName) { User: list({ fields: { name: text(), - email: text(), + email: text({ index: 'unique' }), password: password(), noRead: text({ access: { read: () => false } }), yesRead: text({ access: { read: () => true } }), @@ -127,9 +127,9 @@ function setupKeystone(provider: ProviderName) { access: { create: access.create, // arbitrarily restrict the data to a single item (see data.js) - read: () => access.read && { name: 'Hello' }, - update: () => access.update && { name: 'Hello' }, - delete: () => access.delete && { name: 'Hello' }, + read: () => access.read && { name: { equals: 'Hello' } }, + update: () => access.update && { name: { equals: 'Hello' } }, + delete: () => access.delete && { name: { equals: 'Hello' } }, }, }); }); diff --git a/tests/api-tests/auth-header.test.ts b/tests/api-tests/auth-header.test.ts index dfc230995af..38854927243 100644 --- a/tests/api-tests/auth-header.test.ts +++ b/tests/api-tests/auth-header.test.ts @@ -51,7 +51,7 @@ function setupKeystone(provider: ProviderName) { User: list({ fields: { name: text(), - email: text(), + email: text({ index: 'unique' }), password: password(), }, access: { diff --git a/tests/api-tests/queries/cache-hints.test.ts b/tests/api-tests/queries/cache-hints.test.ts index 22cbb34180e..ff3987034a7 100644 --- a/tests/api-tests/queries/cache-hints.test.ts +++ b/tests/api-tests/queries/cache-hints.test.ts @@ -207,7 +207,7 @@ multiAdapterRunners().map(({ runner, provider }) => app, query: ` query { - allUsers(where: { name: "nope" }) { + allUsers(where: { name: { equals: "nope" } }) { name } } @@ -303,7 +303,7 @@ multiAdapterRunners().map(({ runner, provider }) => query: ` query { allPosts { - author(where: { name: "nope" }) { + author(where: { name: { equals: "nope" } }) { name } } diff --git a/tests/api-tests/queries/limits.test.ts b/tests/api-tests/queries/limits.test.ts index 918b8fdd689..3e3760157e0 100644 --- a/tests/api-tests/queries/limits.test.ts +++ b/tests/api-tests/queries/limits.test.ts @@ -81,7 +81,7 @@ multiAdapterRunners().map(({ runner, provider }) => query: ` query { allUsers( - where: { name: "Nope" } + where: { name: { equals: "Nope" } } ) { name } @@ -139,7 +139,7 @@ multiAdapterRunners().map(({ runner, provider }) => query: ` query { allUsers( - where: { name: "Nope" }, + where: { name: { equals: "Nope" } }, first: 100000 ) { name diff --git a/tests/api-tests/relationships/nested-mutations/create-singular.test.ts b/tests/api-tests/relationships/nested-mutations/create-singular.test.ts index 9b1e4a3914f..2baf0e7a579 100644 --- a/tests/api-tests/relationships/nested-mutations/create-singular.test.ts +++ b/tests/api-tests/relationships/nested-mutations/create-singular.test.ts @@ -281,7 +281,7 @@ multiAdapterRunners().map(({ runner, provider }) => const data1 = await context.graphql.run({ query: ` query { - all${group.name}s(where: { name: "${groupName}" }) { + all${group.name}s(where: { name: { equals: "${groupName}" } }) { id name } @@ -353,7 +353,7 @@ multiAdapterRunners().map(({ runner, provider }) => const data2 = await context.graphql.run({ query: ` query { - all${group.name}s(where: { name: "${groupName}" }) { + all${group.name}s(where: { name: { equals: "${groupName}" } }) { id name } diff --git a/tests/api-tests/server-side-graphql-client.test.ts b/tests/api-tests/server-side-graphql-client.test.ts index 0b6d1b32246..e4912875488 100644 --- a/tests/api-tests/server-side-graphql-client.test.ts +++ b/tests/api-tests/server-side-graphql-client.test.ts @@ -176,7 +176,7 @@ multiAdapterRunners().map(({ runner, provider }) => context, listKey, returnFields, - where: { name: 'test15' }, + where: { name: { equals: 'test15' } }, }); expect(allItems).toEqual([{ name: 'test15', age: 150 }]);