From bbf114b82273a4f9747681fa37aff519fc8f5505 Mon Sep 17 00:00:00 2001 From: Jacob Fletcher Date: Mon, 22 May 2023 23:59:09 -0400 Subject: [PATCH] chore: writes e2e test for relationships created using the document drawer --- test/fields-relationship/e2e.spec.ts | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/test/fields-relationship/e2e.spec.ts b/test/fields-relationship/e2e.spec.ts index f02c058db7..7e578c703c 100644 --- a/test/fields-relationship/e2e.spec.ts +++ b/test/fields-relationship/e2e.spec.ts @@ -277,6 +277,33 @@ describe('fields - relationship', () => { await expect(documentDrawer).toBeVisible(); }); + test('should open document drawer and append newly created docs onto the parent field', async () => { + await page.goto(url.edit(docWithExistingRelations.id)); + + const field = page.locator('#field-relationshipHasMany'); + + // open the document drawer + const addNewButton = await field.locator('button.relationship-add-new__add-button.doc-drawer__toggler'); + await addNewButton.click(); + const documentDrawer = await page.locator('[id^=doc-drawer_relation-one_1_]'); + await expect(documentDrawer).toBeVisible(); + + // fill in the field and save the document, keep the drawer open for further testing + const drawerField = await documentDrawer.locator('#field-name'); + await drawerField.fill('Newly created document'); + const saveButton = await documentDrawer.locator('#action-save'); + await saveButton.click(); + await expect(page.locator('.Toastify')).toContainText('successfully'); + + // count the number of values in the field to ensure only one was added + await expect(await page.locator('#field-relationshipHasMany .value-container .rs__multi-value')).toHaveCount(1); + + // save the same document again to ensure the relationship field doesn't receive duplicative values + await saveButton.click(); + await expect(page.locator('.Toastify')).toContainText('successfully'); + await expect(await page.locator('#field-relationshipHasMany .value-container .rs__multi-value')).toHaveCount(1); + }); + describe('existing relationships', () => { test('should highlight existing relationship', async () => { await page.goto(url.edit(docWithExistingRelations.id)); @@ -365,7 +392,6 @@ describe('fields - relationship', () => { describe('externally update field', () => { beforeAll(async () => { - url = new AdminUrlUtil(serverURL, relationUpdatedExternallySlug); await page.goto(url.create); });