Skip to content

Commit

Permalink
Update actions
Browse files Browse the repository at this point in the history
  • Loading branch information
irshadahmad21 committed Oct 14, 2024
1 parent a0f58d5 commit 7ac3fe7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 3 additions & 1 deletion packages/js/shared-ui/wptelegram/channels-field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type ChannelsFieldProps = Pick<
name: string;
label: React.ReactNode;
description?: React.ReactNode;
addButtonLabel?: React.ReactNode;
};

export function ChannelsField({
Expand All @@ -26,6 +27,7 @@ export function ChannelsField({
placeholder,
'aria-label': ariaLabel,
showMemberCount,
addButtonLabel,
}: ChannelsFieldProps) {
const { control } = useFormContext();

Expand Down Expand Up @@ -66,7 +68,7 @@ export function ChannelsField({
variant="secondary"
>
<Plus className="me-2" size="16" />
{__('Add channel')}
{addButtonLabel || __('Add channel')}
</Button>
</div>
);
Expand Down
16 changes: 10 additions & 6 deletions tools/e2e-utils/src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,23 @@ export class Actions {
}

async assertChangesSaved() {
await this.assertNotification('success', 'Changes saved successfully.');
}

async assertNotification(status: 'success' | 'error', message: string) {
const notifications = this.page.getByRole('region', {
name: 'Notifications',
});

const notificationShown = notifications.locator('li[role="status"]', {
has: this.page.locator('div[data-status="success"]'),
});
const notificationShown = notifications
.locator('li[role="status"]', {
has: this.page.locator(`div[data-status="${status}"]`),
})
.last();

await notificationShown.waitFor();

expect(await notificationShown.textContent()).toContain(
'Changes saved successfully.',
);
expect(await notificationShown.textContent()).toContain(message);
}

/**
Expand Down

0 comments on commit 7ac3fe7

Please sign in to comment.