fix: fields-relationship e2e tests
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
@import '../../../../../../scss/styles.scss';
|
||||
|
||||
.single-value {
|
||||
.relationship--single-value {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { useAuth } from '../../../../../utilities/Auth';
|
||||
import { Option } from '../../types';
|
||||
import './index.scss';
|
||||
|
||||
const baseClass = 'single-value';
|
||||
const baseClass = 'relationship--single-value';
|
||||
|
||||
export const SingleValue: React.FC<SingleValueProps<Option>> = (props) => {
|
||||
const {
|
||||
@@ -43,7 +43,9 @@ export const SingleValue: React.FC<SingleValueProps<Option>> = (props) => {
|
||||
<div className={baseClass}>
|
||||
<div className={`${baseClass}__label`}>
|
||||
<SelectComponents.SingleValue {...props}>
|
||||
<div className={`${baseClass}__text`}>
|
||||
{children}
|
||||
</div>
|
||||
{relationTo && hasReadPermission && (
|
||||
<Fragment>
|
||||
<DocumentDrawerToggler
|
||||
|
||||
@@ -131,15 +131,17 @@ describe('fields - relationship', () => {
|
||||
|
||||
await expect(options).toHaveCount(2); // Two relationship options
|
||||
|
||||
const values = page.locator('#field-relationshipHasMany .relationship--multi-value-label__text');
|
||||
|
||||
// Add one relationship
|
||||
await options.locator(`text=${relationOneDoc.id}`).click();
|
||||
await expect(field).toContainText(relationOneDoc.id);
|
||||
await expect(field).not.toContainText(anotherRelationOneDoc.id);
|
||||
await expect(values).toHaveText([relationOneDoc.id]);
|
||||
await expect(values).not.toHaveText([anotherRelationOneDoc.id]);
|
||||
|
||||
// Add second relationship
|
||||
await field.click({ delay: 100 });
|
||||
await options.locator(`text=${anotherRelationOneDoc.id}`).click();
|
||||
await expect(field).toContainText(anotherRelationOneDoc.id);
|
||||
await expect(values).toHaveText([relationOneDoc.id, anotherRelationOneDoc.id]);
|
||||
|
||||
// No options left
|
||||
await field.locator('.rs__input').click({ delay: 100 });
|
||||
@@ -152,6 +154,7 @@ describe('fields - relationship', () => {
|
||||
await page.goto(url.create);
|
||||
|
||||
const field = page.locator('#field-relationshipMultiple');
|
||||
const value = page.locator('#field-relationshipMultiple .relationship--single-value__text');
|
||||
|
||||
await field.click({ delay: 100 });
|
||||
|
||||
@@ -161,12 +164,12 @@ describe('fields - relationship', () => {
|
||||
|
||||
// Add one relationship
|
||||
await options.locator(`text=${relationOneDoc.id}`).click();
|
||||
await expect(field).toContainText(relationOneDoc.id);
|
||||
await expect(value).toContainText(relationOneDoc.id);
|
||||
|
||||
// Add relationship of different collection
|
||||
await field.click({ delay: 100 });
|
||||
await options.locator(`text=${relationTwoDoc.id}`).click();
|
||||
await expect(field).toContainText(relationTwoDoc.id);
|
||||
await expect(value).toContainText(relationTwoDoc.id);
|
||||
|
||||
await saveDocAndAssert(page);
|
||||
});
|
||||
@@ -176,7 +179,7 @@ describe('fields - relationship', () => {
|
||||
|
||||
await page.locator('.btn.duplicate').first().click();
|
||||
await expect(page.locator('.Toastify')).toContainText('successfully');
|
||||
const field = page.locator('#field-relationship .rs__value-container');
|
||||
const field = page.locator('#field-relationship .relationship--single-value__text');
|
||||
|
||||
await expect(field).toHaveText(relationOneDoc.id);
|
||||
});
|
||||
@@ -308,7 +311,7 @@ describe('fields - relationship', () => {
|
||||
test('should show useAsTitle on relation', async () => {
|
||||
await page.goto(url.edit(docWithExistingRelations.id));
|
||||
|
||||
const field = page.locator('#field-relationshipWithTitle .react-select');
|
||||
const field = page.locator('#field-relationshipWithTitle .relationship--single-value__text');
|
||||
|
||||
// Check existing relationship for correct title
|
||||
await expect(field).toHaveText(relationWithTitle.name);
|
||||
|
||||
Reference in New Issue
Block a user