fix: corrects permission access reading for disabling fields (#6815)

Fixes issues where access control was not properly affecting the read-only setting on fields.
This commit is contained in:
Jarrod Flesch
2024-06-17 18:33:45 -04:00
committed by GitHub
parent 45871489d0
commit cedd916816
9 changed files with 99 additions and 27 deletions

View File

@@ -30,6 +30,7 @@ import { initPayloadE2ENoConfig } from '../helpers/initPayloadE2ENoConfig.js'
import { POLL_TOPASS_TIMEOUT, TEST_TIMEOUT_LONG } from '../playwright.config.js'
import {
createNotUpdateCollectionSlug,
disabledSlug,
docLevelAccessSlug,
fullyRestrictedSlug,
noAdminAccessEmail,
@@ -67,6 +68,7 @@ describe('access control', () => {
let restrictedVersionsUrl: AdminUrlUtil
let userRestrictedCollectionURL: AdminUrlUtil
let userRestrictedGlobalURL: AdminUrlUtil
let disabledFields: AdminUrlUtil
let serverURL: string
let context: BrowserContext
let logoutURL: string
@@ -83,6 +85,7 @@ describe('access control', () => {
restrictedVersionsUrl = new AdminUrlUtil(serverURL, restrictedVersionsSlug)
userRestrictedCollectionURL = new AdminUrlUtil(serverURL, userRestrictedCollectionSlug)
userRestrictedGlobalURL = new AdminUrlUtil(serverURL, userRestrictedGlobalSlug)
disabledFields = new AdminUrlUtil(serverURL, disabledSlug)
context = await browser.newContext()
page = await context.newPage()
@@ -521,6 +524,34 @@ describe('access control', () => {
await expect(page.locator('.next-error-h1')).toBeVisible()
})
})
describe('read-only from access control', () => {
test('should be read-only when update returns false', async () => {
await page.goto(disabledFields.create)
// group field
await page.locator('#field-group__text').fill('group')
// named tab
await page.locator('#field-namedTab__text').fill('named tab')
// unnamed tab
await page.locator('.tabs-field__tab-button').nth(1).click()
await page.locator('#field-unnamedTab').fill('unnamed tab')
// array field
await page.locator('#field-array button').click()
await page.locator('#field-array__0__text').fill('array row 0')
await saveDocAndAssert(page)
await expect(page.locator('#field-group__text')).toBeDisabled()
await expect(page.locator('#field-namedTab__text')).toBeDisabled()
await page.locator('.tabs-field__tab-button').nth(1).click()
await expect(page.locator('#field-unnamedTab')).toBeDisabled()
await expect(page.locator('#field-array__0__text')).toBeDisabled()
})
})
})
// eslint-disable-next-line @typescript-eslint/require-await