From 8e0632bdeee78a17e4b0e2cf03fee4a7cd144ec8 Mon Sep 17 00:00:00 2001 From: tak-amboss Date: Tue, 4 Feb 2025 16:48:36 +0100 Subject: [PATCH] add e2e test --- test/fields/collections/Text/e2e.spec.ts | 40 ++++++++++++++++++++++++ test/fields/collections/Text/index.ts | 9 ++++++ 2 files changed, 49 insertions(+) diff --git a/test/fields/collections/Text/e2e.spec.ts b/test/fields/collections/Text/e2e.spec.ts index 26fe940e97..68ab222e59 100644 --- a/test/fields/collections/Text/e2e.spec.ts +++ b/test/fields/collections/Text/e2e.spec.ts @@ -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/) + }) }) diff --git a/test/fields/collections/Text/index.ts b/test/fields/collections/Text/index.ts index f850e71c8f..fb22b46538 100644 --- a/test/fields/collections/Text/index.ts +++ b/test/fields/collections/Text/index.ts @@ -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',