@@ -218,16 +218,28 @@ test.describe('Join Field', () => {
218
218
const titleAscButton = titleColumn . locator ( 'button.sort-column__asc' )
219
219
await expect ( titleAscButton ) . toBeVisible ( )
220
220
await titleAscButton . click ( )
221
- await expect ( joinField . locator ( 'tbody tr:first-child td:nth-child(2)' ) ) . toHaveText (
222
- 'Test Post 1' ,
223
- )
221
+ await expect ( joinField . locator ( 'tbody .row-1' ) ) . toContainText ( 'Test Post 1' )
224
222
225
223
const titleDescButton = titleColumn . locator ( 'button.sort-column__desc' )
226
224
await expect ( titleDescButton ) . toBeVisible ( )
227
225
await titleDescButton . click ( )
228
- await expect ( joinField . locator ( 'tbody tr:first-child td:nth-child(2)' ) ) . toHaveText (
229
- 'Test Post 3' ,
230
- )
226
+ await expect ( joinField . locator ( 'tbody .row-1' ) ) . toContainText ( 'Test Post 3' )
227
+ } )
228
+
229
+ test ( 'should display relationship table with columns from admin.defaultColumns' , async ( ) => {
230
+ await page . goto ( categoriesURL . edit ( categoryID ) )
231
+ const joinField = page . locator ( '#field-group__relatedPosts.field-type.join' )
232
+ const thead = joinField . locator ( '.relationship-table thead' )
233
+ await expect ( thead ) . toContainText ( 'ID' )
234
+ await expect ( thead ) . toContainText ( 'Created At' )
235
+ await expect ( thead ) . toContainText ( 'Title' )
236
+ const innerText = await thead . innerText ( )
237
+
238
+ // expect the order of columns to be 'ID', 'Created At', 'Title'
239
+ // eslint-disable-next-line payload/no-flaky-assertions
240
+ expect ( innerText . indexOf ( 'ID' ) ) . toBeLessThan ( innerText . indexOf ( 'Created At' ) )
241
+ // eslint-disable-next-line payload/no-flaky-assertions
242
+ expect ( innerText . indexOf ( 'Created At' ) ) . toBeLessThan ( innerText . indexOf ( 'Title' ) )
231
243
} )
232
244
233
245
test ( 'should update relationship table when new document is created' , async ( ) => {
@@ -276,9 +288,7 @@ test.describe('Join Field', () => {
276
288
await titleField . fill ( 'Test Post 1 Updated' )
277
289
await drawer . locator ( 'button[id="action-save"]' ) . click ( )
278
290
await expect ( drawer ) . toBeHidden ( )
279
- await expect ( joinField . locator ( 'tbody tr:first-child td:nth-child(2)' ) ) . toHaveText (
280
- 'Test Post 1 Updated' ,
281
- )
291
+ await expect ( joinField . locator ( 'tbody .row-1' ) ) . toContainText ( 'Test Post 1 Updated' )
282
292
} )
283
293
284
294
test ( 'should render empty relationship table when creating new document' , async ( ) => {
0 commit comments