Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: edit join field not rendering #9971

Merged
merged 2 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ jobs:
- admin-root
- auth
- auth-basic
- joins
- field-error-states
- fields-relationship
- fields__collections__Array
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/utilities/buildTableState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ export const buildTableState = async (
overrideAccess: false,
page: query?.page ? parseInt(query.page, 10) : undefined,
sort: query?.sort,
user: req.user,
where: query?.where,
})

Expand Down
38 changes: 23 additions & 15 deletions test/joins/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ const dirname = path.dirname(filename)
let payload: PayloadTestSDK<Config>
let serverURL: string

test.describe('Admin Panel', () => {
test.describe('Join Field', () => {
let page: Page
let categoriesURL: AdminUrlUtil
let uploadsURL: AdminUrlUtil
let categoriesJoinRestrictedURL: AdminUrlUtil
let categoryID

test.beforeAll(async ({ browser }, testInfo) => {
testInfo.setTimeout(TEST_TIMEOUT_LONG)
Expand All @@ -40,6 +41,16 @@ test.describe('Admin Panel', () => {
categoriesURL = new AdminUrlUtil(serverURL, categoriesSlug)
uploadsURL = new AdminUrlUtil(serverURL, uploadsSlug)
categoriesJoinRestrictedURL = new AdminUrlUtil(serverURL, categoriesJoinRestrictedSlug)
const { docs } = await payload.find({
collection: categoriesSlug,
where: {
name: {
equals: 'example',
},
},
})

;({ id: categoryID } = docs[0])

const context = await browser.newContext()
page = await context.newPage()
Expand Down Expand Up @@ -111,8 +122,8 @@ test.describe('Admin Panel', () => {
const joinField = page.locator('#field-hiddenPosts.field-type.join')
await expect(joinField).toBeVisible()
await expect(joinField.locator('.relationship-table table')).toBeVisible()
const columns = await joinField.locator('.relationship-table tbody tr').count()
expect(columns).toBe(1)
const columns = joinField.locator('.relationship-table tbody tr')
await expect(columns).toHaveCount(1)
const button = joinField.locator('button.doc-drawer__toggler.relationship-table__add-new')
await expect(button).toBeVisible()
await button.click()
Expand All @@ -122,9 +133,7 @@ test.describe('Admin Panel', () => {
await expect(titleField).toBeVisible()
await titleField.fill('Test Hidden Post')
await drawer.locator('button[id="action-save"]').click()
await expect(joinField.locator('.relationship-table tbody tr')).toBeVisible()
const newColumns = await joinField.locator('.relationship-table tbody tr').count()
expect(newColumns).toBe(2)
await expect(joinField.locator('.relationship-table tbody tr.row-2')).toBeVisible()
})

test('should render the create page and create doc with the join field', async () => {
Expand Down Expand Up @@ -152,11 +161,10 @@ test.describe('Admin Panel', () => {
})

test('should render collection type in first column of relationship table', async () => {
await navigateToDoc(page, categoriesURL)
await page.goto(categoriesURL.edit(categoryID))
const joinField = page.locator('#field-relatedPosts.field-type.join')
await expect(joinField).toBeVisible()
const collectionTypeColumn = joinField.locator('thead tr th#heading-collection:first-child')
const text = collectionTypeColumn
const text = joinField.locator('thead tr th#heading-collection:first-child')
await expect(text).toHaveText('Type')
const cells = joinField.locator('.relationship-table tbody tr td:first-child .pill__label')

Expand All @@ -171,7 +179,7 @@ test.describe('Admin Panel', () => {
})

test('should render drawer toggler without document link in second column of relationship table', async () => {
await navigateToDoc(page, categoriesURL)
await page.goto(categoriesURL.edit(categoryID))
const joinField = page.locator('#field-relatedPosts.field-type.join')
await expect(joinField).toBeVisible()
const actionColumn = joinField.locator('tbody tr td:nth-child(2)').first()
Expand Down Expand Up @@ -203,8 +211,8 @@ test.describe('Admin Panel', () => {
})

test('should sort relationship table by clicking on column headers', async () => {
await navigateToDoc(page, categoriesURL)
const joinField = page.locator('#field-relatedPosts.field-type.join')
await page.goto(categoriesURL.edit(categoryID))
const joinField = page.locator('#field-group__relatedPosts.field-type.join')
await expect(joinField).toBeVisible()
const titleColumn = joinField.locator('thead tr th#heading-title')
const titleAscButton = titleColumn.locator('button.sort-column__asc')
Expand All @@ -223,7 +231,7 @@ test.describe('Admin Panel', () => {
})

test('should update relationship table when new document is created', async () => {
await navigateToDoc(page, categoriesURL)
await page.goto(categoriesURL.edit(categoryID))
const joinField = page.locator('#field-relatedPosts.field-type.join')
await expect(joinField).toBeVisible()

Expand Down Expand Up @@ -253,8 +261,8 @@ test.describe('Admin Panel', () => {
})

test('should update relationship table when document is updated', async () => {
await navigateToDoc(page, categoriesURL)
const joinField = page.locator('#field-relatedPosts.field-type.join')
await page.goto(categoriesURL.edit(categoryID))
const joinField = page.locator('#field-group__relatedPosts.field-type.join')
await expect(joinField).toBeVisible()
const editButton = joinField.locator(
'tbody tr:first-child td:nth-child(2) button.doc-drawer__toggler',
Expand Down
2 changes: 1 addition & 1 deletion test/joins/payload-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ export interface CollectionRestricted {
id: string;
title?: string | null;
canRead?: boolean | null;
category?: (string | null) | RestrictedCategory;
category?: (string | null) | CategoriesJoinRestricted;
updatedAt: string;
createdAt: string;
}
Expand Down
Loading