Skip to content

Commit 9bcaf16

Browse files
committed
fix tests
1 parent e5bfcac commit 9bcaf16

File tree

12 files changed

+74
-132
lines changed

12 files changed

+74
-132
lines changed

examples/custom-session-passport/schema.graphql

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,24 +206,25 @@ type KeystoneAdminMeta {
206206

207207
type KeystoneAdminUIListMeta {
208208
key: String!
209-
itemQueryName: String!
210-
listQueryName: String!
211-
hideCreate: Boolean!
212-
hideDelete: Boolean!
213209
path: String!
214210
label: String!
215211
singular: String!
216212
plural: String!
217213
description: String
218-
initialColumns: [String!]!
219214
pageSize: Int!
220215
labelField: String!
221216
fields: [KeystoneAdminUIFieldMeta!]!
222217
groups: [KeystoneAdminUIFieldGroupMeta!]!
223218
graphql: KeystoneAdminUIGraphQL!
219+
initialColumns: [String!]!
220+
initialSearchFields: [String!]!
224221
initialSort: KeystoneAdminUISort
225-
isHidden: Boolean!
226222
isSingleton: Boolean!
223+
hideCreate: Boolean!
224+
hideDelete: Boolean!
225+
isHidden: Boolean!
226+
itemQueryName: String!
227+
listQueryName: String!
227228
}
228229

229230
type KeystoneAdminUIFieldMeta {

examples/document-field-customisation/keystone-server/schema.graphql

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,24 +231,25 @@ type KeystoneAdminMeta {
231231

232232
type KeystoneAdminUIListMeta {
233233
key: String!
234-
itemQueryName: String!
235-
listQueryName: String!
236-
hideCreate: Boolean!
237-
hideDelete: Boolean!
238234
path: String!
239235
label: String!
240236
singular: String!
241237
plural: String!
242238
description: String
243-
initialColumns: [String!]!
244239
pageSize: Int!
245240
labelField: String!
246241
fields: [KeystoneAdminUIFieldMeta!]!
247242
groups: [KeystoneAdminUIFieldGroupMeta!]!
248243
graphql: KeystoneAdminUIGraphQL!
244+
initialColumns: [String!]!
245+
initialSearchFields: [String!]!
249246
initialSort: KeystoneAdminUISort
250-
isHidden: Boolean!
251247
isSingleton: Boolean!
248+
hideCreate: Boolean!
249+
hideDelete: Boolean!
250+
isHidden: Boolean!
251+
itemQueryName: String!
252+
listQueryName: String!
252253
}
253254

254255
type KeystoneAdminUIFieldMeta {

examples/framework-astro/schema.graphql

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,24 +117,25 @@ type KeystoneAdminMeta {
117117

118118
type KeystoneAdminUIListMeta {
119119
key: String!
120-
itemQueryName: String!
121-
listQueryName: String!
122-
hideCreate: Boolean!
123-
hideDelete: Boolean!
124120
path: String!
125121
label: String!
126122
singular: String!
127123
plural: String!
128124
description: String
129-
initialColumns: [String!]!
130125
pageSize: Int!
131126
labelField: String!
132127
fields: [KeystoneAdminUIFieldMeta!]!
133128
groups: [KeystoneAdminUIFieldGroupMeta!]!
134129
graphql: KeystoneAdminUIGraphQL!
130+
initialColumns: [String!]!
131+
initialSearchFields: [String!]!
135132
initialSort: KeystoneAdminUISort
136-
isHidden: Boolean!
137133
isSingleton: Boolean!
134+
hideCreate: Boolean!
135+
hideDelete: Boolean!
136+
isHidden: Boolean!
137+
itemQueryName: String!
138+
listQueryName: String!
138139
}
139140

140141
type KeystoneAdminUIFieldMeta {

examples/framework-nextjs-app-directory/schema.graphql

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,24 +137,25 @@ type KeystoneAdminMeta {
137137

138138
type KeystoneAdminUIListMeta {
139139
key: String!
140-
itemQueryName: String!
141-
listQueryName: String!
142-
hideCreate: Boolean!
143-
hideDelete: Boolean!
144140
path: String!
145141
label: String!
146142
singular: String!
147143
plural: String!
148144
description: String
149-
initialColumns: [String!]!
150145
pageSize: Int!
151146
labelField: String!
152147
fields: [KeystoneAdminUIFieldMeta!]!
153148
groups: [KeystoneAdminUIFieldGroupMeta!]!
154149
graphql: KeystoneAdminUIGraphQL!
150+
initialColumns: [String!]!
151+
initialSearchFields: [String!]!
155152
initialSort: KeystoneAdminUISort
156-
isHidden: Boolean!
157153
isSingleton: Boolean!
154+
hideCreate: Boolean!
155+
hideDelete: Boolean!
156+
isHidden: Boolean!
157+
itemQueryName: String!
158+
listQueryName: String!
158159
}
159160

160161
type KeystoneAdminUIFieldMeta {

examples/framework-nextjs-pages-directory/schema.graphql

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,24 +135,25 @@ type KeystoneAdminMeta {
135135

136136
type KeystoneAdminUIListMeta {
137137
key: String!
138-
itemQueryName: String!
139-
listQueryName: String!
140-
hideCreate: Boolean!
141-
hideDelete: Boolean!
142138
path: String!
143139
label: String!
144140
singular: String!
145141
plural: String!
146142
description: String
147-
initialColumns: [String!]!
148143
pageSize: Int!
149144
labelField: String!
150145
fields: [KeystoneAdminUIFieldMeta!]!
151146
groups: [KeystoneAdminUIFieldGroupMeta!]!
152147
graphql: KeystoneAdminUIGraphQL!
148+
initialColumns: [String!]!
149+
initialSearchFields: [String!]!
153150
initialSort: KeystoneAdminUISort
154-
isHidden: Boolean!
155151
isSingleton: Boolean!
152+
hideCreate: Boolean!
153+
hideDelete: Boolean!
154+
isHidden: Boolean!
155+
itemQueryName: String!
156+
listQueryName: String!
156157
}
157158

158159
type KeystoneAdminUIFieldMeta {

examples/framework-remix/schema.graphql

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,24 +117,25 @@ type KeystoneAdminMeta {
117117

118118
type KeystoneAdminUIListMeta {
119119
key: String!
120-
itemQueryName: String!
121-
listQueryName: String!
122-
hideCreate: Boolean!
123-
hideDelete: Boolean!
124120
path: String!
125121
label: String!
126122
singular: String!
127123
plural: String!
128124
description: String
129-
initialColumns: [String!]!
130125
pageSize: Int!
131126
labelField: String!
132127
fields: [KeystoneAdminUIFieldMeta!]!
133128
groups: [KeystoneAdminUIFieldGroupMeta!]!
134129
graphql: KeystoneAdminUIGraphQL!
130+
initialColumns: [String!]!
131+
initialSearchFields: [String!]!
135132
initialSort: KeystoneAdminUISort
136-
isHidden: Boolean!
137133
isSingleton: Boolean!
134+
hideCreate: Boolean!
135+
hideDelete: Boolean!
136+
isHidden: Boolean!
137+
itemQueryName: String!
138+
listQueryName: String!
138139
}
139140

140141
type KeystoneAdminUIFieldMeta {

examples/graphql-ts-gql/schema.graphql

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,24 +251,25 @@ type KeystoneAdminMeta {
251251

252252
type KeystoneAdminUIListMeta {
253253
key: String!
254-
itemQueryName: String!
255-
listQueryName: String!
256-
hideCreate: Boolean!
257-
hideDelete: Boolean!
258254
path: String!
259255
label: String!
260256
singular: String!
261257
plural: String!
262258
description: String
263-
initialColumns: [String!]!
264259
pageSize: Int!
265260
labelField: String!
266261
fields: [KeystoneAdminUIFieldMeta!]!
267262
groups: [KeystoneAdminUIFieldGroupMeta!]!
268263
graphql: KeystoneAdminUIGraphQL!
264+
initialColumns: [String!]!
265+
initialSearchFields: [String!]!
269266
initialSort: KeystoneAdminUISort
270-
isHidden: Boolean!
271267
isSingleton: Boolean!
268+
hideCreate: Boolean!
269+
hideDelete: Boolean!
270+
isHidden: Boolean!
271+
itemQueryName: String!
272+
listQueryName: String!
272273
}
273274

274275
type KeystoneAdminUIFieldMeta {

packages/core/src/fields/types/relationship/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,18 @@ type ManyDbConfig = {
8282
}
8383

8484
function throwIfMissingFields (
85+
localListMeta: ListMetaRootVal,
8586
foreignListMeta: ListMetaRootVal,
8687
refLabelField: string,
8788
refSearchFields: string[]
8889
) {
8990
if (!(refLabelField in foreignListMeta.fieldsByKey)) {
90-
throw new Error(`${refLabelField} is not a field of the ${foreignListMeta.key} list`)
91+
throw new Error(`"${refLabelField}" is not a field of list "${foreignListMeta.key}"`)
9192
}
9293

9394
for (const searchFieldKey of refSearchFields) {
9495
if (searchFieldKey in foreignListMeta.fieldsByKey) continue
95-
throw new Error(`${refSearchFields} is not a field of the ${foreignListMeta.key} list`)
96+
throw new Error(`"${refSearchFields}" is not a field of list "${foreignListMeta.key}"`)
9697
}
9798
}
9899

@@ -183,7 +184,7 @@ export function relationship <ListTypeInfo extends BaseListTypeInfo>({
183184
refSearchFields,
184185
}
185186

186-
throwIfMissingFields(foreignListMeta, inlineConnectConfig.refLabelField, inlineConnectConfig.refSearchFields)
187+
throwIfMissingFields(localListMeta, foreignListMeta, inlineConnectConfig.refLabelField, inlineConnectConfig.refSearchFields)
187188
return {
188189
displayMode: 'cards',
189190
refFieldKey: foreignFieldKey,
@@ -204,7 +205,7 @@ export function relationship <ListTypeInfo extends BaseListTypeInfo>({
204205
// prefer the local definition to the foreign list, if provided
205206
const specificRefLabelField = config.ui?.labelField || refLabelField
206207
const specificRefSearchFields = config.ui?.searchFields || refSearchFields
207-
throwIfMissingFields(foreignListMeta, specificRefLabelField, specificRefSearchFields)
208+
throwIfMissingFields(localListMeta, foreignListMeta, specificRefLabelField, specificRefSearchFields)
208209
return {
209210
displayMode: 'select',
210211
refFieldKey: foreignFieldKey,

tests/api-tests/admin-meta.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ test(
156156
},
157157
groups: [],
158158
initialColumns: ['name', 'something'],
159+
initialSearchFields: ['name'],
159160
initialSort: null,
160161
itemQueryName: 'User',
161162
key: 'User',

tests/api-tests/relationships/label-search-field-validation.test.ts

Lines changed: 4 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ test("labelField that doesn't exist is rejected with displayMode: select", () =>
3737
}),
3838
{} as any
3939
)
40-
).toThrowErrorMatchingInlineSnapshot(
41-
`"The ui.labelField option for field 'A.something' uses 'doesNotExist' but that field doesn't exist."`
42-
)
40+
).toThrowErrorMatchingInlineSnapshot(`""doesNotExist" is not a field of list "Thing""`)
4341
})
4442

4543
test("labelField that doesn't exist is rejected with displayMode: cards", () => {
@@ -69,9 +67,7 @@ test("labelField that doesn't exist is rejected with displayMode: cards", () =>
6967
}),
7068
{} as any
7169
)
72-
).toThrowErrorMatchingInlineSnapshot(
73-
`"The ui.inlineConnect.labelField option for field 'A.something' uses 'doesNotExist' but that field doesn't exist."`
74-
)
70+
).toThrowErrorMatchingInlineSnapshot(`""doesNotExist" is not a field of list "Thing""`)
7571
})
7672

7773
test("searchFields that don't exist are rejected with displayMode: select", () => {
@@ -99,9 +95,7 @@ test("searchFields that don't exist are rejected with displayMode: select", () =
9995
}),
10096
{} as any
10197
)
102-
).toThrowErrorMatchingInlineSnapshot(
103-
`"The ui.searchFields option for relationship field 'A.something' includes 'doesNotExist' but that field doesn't exist."`
104-
)
98+
).toThrowErrorMatchingInlineSnapshot(`""doesNotExist" is not a field of list "Thing""`)
10599
})
106100

107101
test("searchFields that don't exist are rejected with displayMode: cards", () => {
@@ -131,69 +125,5 @@ test("searchFields that don't exist are rejected with displayMode: cards", () =>
131125
}),
132126
{} as any
133127
)
134-
).toThrowErrorMatchingInlineSnapshot(
135-
`"The ui.inlineConnect.searchFields option for relationship field 'A.something' includes 'doesNotExist' but that field doesn't exist."`
136-
)
137-
})
138-
139-
test("searchFields that aren't searchable are rejected with displayMode: select", () => {
140-
expect(() =>
141-
getContext(
142-
({
143-
db: {
144-
provider: 'sqlite',
145-
url: 'file://'
146-
},
147-
lists: {
148-
A: list({
149-
access: allowAll,
150-
fields: {
151-
something: relationship({
152-
ref: 'Thing',
153-
ui: {
154-
searchFields: ['notText'],
155-
},
156-
}),
157-
},
158-
}),
159-
Thing,
160-
},
161-
}),
162-
{} as any
163-
)
164-
).toThrowErrorMatchingInlineSnapshot(
165-
`"The ui.searchFields option for field 'A.something' includes 'notText' but that field doesn't have a contains filter that accepts a GraphQL String"`
166-
)
167-
})
168-
169-
test("searchFields that aren't searchable are rejected with displayMode: cards", () => {
170-
expect(() =>
171-
getContext(
172-
({
173-
db: {
174-
provider: 'sqlite',
175-
url: 'file://'
176-
},
177-
lists: {
178-
A: list({
179-
access: allowAll,
180-
fields: {
181-
something: relationship({
182-
ref: 'Thing',
183-
ui: {
184-
displayMode: 'cards',
185-
cardFields: ['name'],
186-
inlineConnect: { labelField: 'name', searchFields: ['notText'] },
187-
},
188-
}),
189-
},
190-
}),
191-
Thing,
192-
},
193-
}),
194-
{} as any
195-
)
196-
).toThrowErrorMatchingInlineSnapshot(
197-
`"The ui.searchFields option for field 'A.something' includes 'notText' but that field doesn't have a contains filter that accepts a GraphQL String"`
198-
)
128+
).toThrowErrorMatchingInlineSnapshot(`""doesNotExist" is not a field of list "Thing""`)
199129
})

0 commit comments

Comments
 (0)