Skip to content

Commit

Permalink
test: use btnTestId prop to identify specific button during tests
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Nov 27, 2024
1 parent 9d4b8be commit 13801d1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/frontend/e2e/02-mapper-flow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ test.describe('mapper flow', () => {
});

// 2. Lock task for mapping
await expect(page.getByRole('button', { name: 'START MAPPING' })).toBeVisible();
await page.getByRole('button', { name: 'START MAPPING' }).click();
await expect(page.getByTestId('StartMapping')).toBeVisible();
await page.getByTestId('StartMapping').click();
await page.waitForSelector('div:has-text("updated to LOCKED_FOR_MAPPING"):nth-of-type(1)');
await expect(
page
Expand Down Expand Up @@ -114,7 +114,7 @@ test.describe('mapper flow', () => {
},
});
await expect(page.getByText('Status: UNLOCKED_TO_MAP')).toBeVisible();
await expect(page.getByRole('button', { name: 'START MAPPING' })).toBeVisible();
await expect(page.getByTestId('StartMapping')).toBeVisible();

// 2. Click on a specific feature / Entity within a task
// assert feature popup visibility
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/components/DialogTaskActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export default function Dialog({ taskId, feature }: dialogPropType) {
return list_of_task_actions?.length != 0 ? (
<Button
btnId={data.value}
btnTestId="StartMapping"
key={index}
onClick={(e) => {
if (
Expand Down
4 changes: 3 additions & 1 deletion src/frontend/src/components/common/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface IButton {
disabled?: boolean;
loadingText?: string;
btnId?: string;
btnTestId?: string;
}

const btnStyle = (btnType, className) => {
Expand Down Expand Up @@ -45,11 +46,12 @@ const Button = ({
isLoading,
loadingText,
btnId,
btnTestId,
}: IButton) => (
<div>
<button
data-btnid={btnId}
data-testid="test-button"
data-testid={btnTestId}
type={type === 'submit' ? 'submit' : 'button'}
onClick={onClick}
className={`fmtm-text-lg fmtm-group fmtm-flex fmtm-items-center fmtm-gap-2 fmtm-outline-none ${btnStyle(
Expand Down

0 comments on commit 13801d1

Please sign in to comment.