add e2e test

This commit is contained in:
tak-amboss
2025-02-04 16:48:36 +01:00
parent 4e399adc46
commit 8e0632bdee
2 changed files with 49 additions and 0 deletions

View File

@@ -240,4 +240,44 @@ describe('Text', () => {
await expect(field.locator('.rs__value-container')).toContainText(input)
await expect(field.locator('.rs__value-container')).toContainText(furtherInput)
})
test('should allow editing hasMany text field values by clicking', async () => {
const originalText = 'original'
const newText = 'new'
await page.goto(url.create)
// fill required field
const requiredField = page.locator('#field-text')
await requiredField.fill(String(originalText))
const field = page.locator('.field-hasMany')
// Add initial value
await field.click()
await page.keyboard.type(originalText)
await page.keyboard.press('Enter')
// Click to edit existing value
const value = field.locator('.multi-value-label__text')
await value.click()
await value.dblclick()
await page.keyboard.type(newText)
await page.keyboard.press('Enter')
await saveDocAndAssert(page)
await expect(field.locator('.rs__value-container')).toContainText(`${newText}`)
})
test('should not allow editing hasMany text field values when disabled', async () => {
await page.goto(url.create)
const field = page.locator('.field-readOnlyHasMany')
// Try to click to edit
const value = field.locator('.multi-value-label__text')
await value.click({ force: true })
// Verify it does not become editable
await expect(field.locator('.multi-value-label__text')).not.toHaveClass(/.*--editable/)
})
})

View File

@@ -127,6 +127,15 @@ const TextFields: CollectionConfig = {
type: 'text',
hasMany: true,
},
{
name: 'readOnlyHasMany',
type: 'text',
hasMany: true,
admin: {
readOnly: true,
},
defaultValue: ['default'],
},
{
name: 'validatesHasMany',
type: 'text',