Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ export const editDisplayNameFromPanel = async (
await editButton.waitFor({ state: 'visible' });
await editButton.click();

const modal = page.locator('.ant-modal');
const modal = page.locator('[role="dialog"]');
await modal.waitFor({ state: 'visible' });
Comment on lines +613 to 614

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 [role="dialog"] may match multiple elements in test context

Replacing .ant-modal (a CSS class unique to the Ant Design modal) with [role="dialog"] is semantically correct, but the new selector is far more generic — any ARIA dialog rendered on the page matches it. If another dialog (e.g., a confirmation toast or a nested modal from a different component) is visible when editDisplayNameFromPanel runs, page.locator('[role="dialog"]') will return multiple elements. Playwright's strict-mode will then throw a strict mode violation error when the subsequent .locator('#displayName') is called. Consider scoping the locator, e.g. page.locator('[role="dialog"][data-testid="…"]') or using page.getByRole('dialog', { name: … }) to match by dialog title.


const displayNameInput = modal.locator('#displayName');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
Button,
Col,
Dropdown,
Form,
Row,
Select,
TableProps,
Expand Down Expand Up @@ -106,10 +105,7 @@ import Table from '../../common/Table/Table';
import TestCaseStatusSummaryIndicator from '../../common/TestCaseStatusSummaryIndicator/TestCaseStatusSummaryIndicator.component';
import { useGenericContext } from '../../Customization/GenericProvider/GenericContext';
import EntityNameModal from '../../Modals/EntityNameModal/EntityNameModal.component';
import {
EntityName,
EntityNameWithAdditionFields,
} from '../../Modals/EntityNameModal/EntityNameModal.interface';
import { EntityName } from '../../Modals/EntityNameModal/EntityNameModal.interface';
import { ColumnFilter } from '../ColumnFilter/ColumnFilter.component';
import TableDescription from '../TableDescription/TableDescription.component';
import TableTags from '../TableTags/TableTags.component';
Expand Down Expand Up @@ -169,6 +165,7 @@ const SchemaTable = () => {
} = useFqn({ type: EntityType.TABLE });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 editConstraint loses Constraint enum type

The old implementation stored the constraint value inside the antd Form context typed as the Constraint enum; the new state is useState<string | undefined>(), which widens the type. The Select's onChange still receives a valid Constraint string at runtime, but TypeScript can no longer enforce it — a future change that accidentally passes an arbitrary string into setEditConstraint would not be caught at compile time. Consider typing this as useState<Constraint | undefined>() to preserve the original type safety.


const [editColumnDisplayName, setEditColumnDisplayName] = useState<Column>();
const [editConstraint, setEditConstraint] = useState<string | undefined>();

const {
permissions: tablePermissions,
Expand Down Expand Up @@ -599,10 +596,11 @@ const SchemaTable = () => {

const handleEditDisplayNameClick = useCallback((record: Column) => {
setEditColumnDisplayName(record);
setEditConstraint(record.constraint);
}, []);

const handleEditColumnData = async (data: EntityName) => {
const { displayName, constraint } = data as EntityNameWithAdditionFields;
const { displayName } = data;
if (
!isUndefined(editColumnDisplayName) &&
editColumnDisplayName.fullyQualifiedName
Expand All @@ -612,21 +610,23 @@ const SchemaTable = () => {
editColumnDisplayName.fullyQualifiedName,
{
displayName: displayName,
...(isEmpty(constraint)
...(isEmpty(editConstraint)
? {
removeConstraint: true,
}
: { constraint }),
},
: { constraint: editConstraint }),
} as Partial<Column>,
'displayName'
);
} catch (error) {
showErrorToast(error as AxiosError);
} finally {
setEditColumnDisplayName(undefined);
setEditConstraint(undefined);
}
} else {
setEditColumnDisplayName(undefined);
setEditConstraint(undefined);
}
};

Expand Down Expand Up @@ -920,11 +920,12 @@ const SchemaTable = () => {
);

const additionalFieldsInEntityNameModal = (
<Form.Item
label={t('label.entity-type-plural', {
entity: t('label.constraint'),
})}
name="constraint">
<div className="tw:flex tw:flex-col tw:gap-1.5">
<label className="tw:text-sm tw:font-medium tw:text-secondary">
{t('label.entity-type-plural', {
entity: t('label.constraint'),
})}
</label>
<Select
allowClear
data-testid="constraint-type-select"
Expand All @@ -934,8 +935,10 @@ const SchemaTable = () => {
entity: t('label.constraint'),
}),
})}
value={editConstraint}
onChange={(value) => setEditConstraint(value)}
/>
</Form.Item>
</div>
);

const handleEditTable = () => {
Expand Down
Loading
Loading