diff --git a/src/button/__tests__/button.test.tsx b/src/button/__tests__/button.test.tsx
index c3124a79cb..4d3f62edfe 100644
--- a/src/button/__tests__/button.test.tsx
+++ b/src/button/__tests__/button.test.tsx
@@ -4,7 +4,10 @@ import React from 'react';
import { act, fireEvent, render } from '@testing-library/react';
import { clearMessageCache } from '@cloudscape-design/component-toolkit/internal';
-import { renderWithSingleTabStopNavigation } from '@cloudscape-design/component-toolkit/internal/testing';
+import {
+ setTestSingleTabStopNavigationTarget,
+ TestSingleTabStopNavigationProvider,
+} from '@cloudscape-design/component-toolkit/internal/testing';
import Button, { ButtonProps } from '../../../lib/components/button';
import InternalButton from '../../../lib/components/button/internal';
@@ -811,30 +814,34 @@ describe('table grid navigation support', () => {
}
test('does not override tab index when keyboard navigation is not active', () => {
- renderWithSingleTabStopNavigation(, { navigationActive: false });
+ render(
+
+
+
+ );
expect(getButton('#button')).not.toHaveAttribute('tabIndex');
});
test('overrides tab index when keyboard navigation is active', () => {
- const { setCurrentTarget } = renderWithSingleTabStopNavigation(
-
+ render(
+
-
+
);
- setCurrentTarget(getButton('#button1'));
+ setTestSingleTabStopNavigationTarget(getButton('#button1'));
expect(getButton('#button1')).toHaveAttribute('tabIndex', '0');
expect(getButton('#button2')).toHaveAttribute('tabIndex', '-1');
});
test('does not override explicit tab index with 0', () => {
- const { setCurrentTarget } = renderWithSingleTabStopNavigation(
-
+ render(
+
-
+
);
- setCurrentTarget(getButton('#button1'));
+ setTestSingleTabStopNavigationTarget(getButton('#button1'));
expect(getButton('#button1')).toHaveAttribute('tabIndex', '-2');
expect(getButton('#button2')).toHaveAttribute('tabIndex', '-2');
});
diff --git a/src/checkbox/__tests__/checkbox.test.tsx b/src/checkbox/__tests__/checkbox.test.tsx
index 7912f158cc..6020cb5d68 100644
--- a/src/checkbox/__tests__/checkbox.test.tsx
+++ b/src/checkbox/__tests__/checkbox.test.tsx
@@ -3,7 +3,10 @@
import React, { useState } from 'react';
import { render } from '@testing-library/react';
-import { renderWithSingleTabStopNavigation } from '@cloudscape-design/component-toolkit/internal/testing';
+import {
+ setTestSingleTabStopNavigationTarget,
+ TestSingleTabStopNavigationProvider,
+} from '@cloudscape-design/component-toolkit/internal/testing';
import Checkbox, { CheckboxProps } from '../../../lib/components/checkbox';
import InternalCheckbox from '../../../lib/components/checkbox/internal';
@@ -243,30 +246,34 @@ describe('table grid navigation support', () => {
}
test('does not override tab index when keyboard navigation is not active', () => {
- renderWithSingleTabStopNavigation(, { navigationActive: false });
+ render(
+
+
+
+ );
expect(getCheckboxInput('#checkbox')).not.toHaveAttribute('tabIndex');
});
test('overrides tab index when keyboard navigation is active', () => {
- const { setCurrentTarget } = renderWithSingleTabStopNavigation(
-
+ render(
+
-
+
);
- setCurrentTarget(getCheckboxInput('#checkbox1'));
+ setTestSingleTabStopNavigationTarget(getCheckboxInput('#checkbox1'));
expect(getCheckboxInput('#checkbox1')).toHaveAttribute('tabIndex', '0');
expect(getCheckboxInput('#checkbox2')).toHaveAttribute('tabIndex', '-1');
});
test('does not override explicit tab index with 0', () => {
- const { setCurrentTarget } = renderWithSingleTabStopNavigation(
-
+ render(
+
-
+
);
- setCurrentTarget(getCheckboxInput('#checkbox1'));
+ setTestSingleTabStopNavigationTarget(getCheckboxInput('#checkbox1'));
expect(getCheckboxInput('#checkbox1')).toHaveAttribute('tabIndex', '-1');
expect(getCheckboxInput('#checkbox2')).toHaveAttribute('tabIndex', '-1');
});
diff --git a/src/link/__tests__/index.test.tsx b/src/link/__tests__/index.test.tsx
index 996234d020..4b92151b9b 100644
--- a/src/link/__tests__/index.test.tsx
+++ b/src/link/__tests__/index.test.tsx
@@ -3,7 +3,10 @@
import React from 'react';
import { act, render } from '@testing-library/react';
-import { renderWithSingleTabStopNavigation } from '@cloudscape-design/component-toolkit/internal/testing';
+import {
+ setTestSingleTabStopNavigationTarget,
+ TestSingleTabStopNavigationProvider,
+} from '@cloudscape-design/component-toolkit/internal/testing';
import { KeyCode } from '@cloudscape-design/test-utils-core/utils';
import FormField from '../../../lib/components/form-field';
@@ -285,23 +288,31 @@ describe('table grid navigation support', () => {
}
test('does not override tab index for button link when keyboard navigation is not active', () => {
- renderWithSingleTabStopNavigation(, { navigationActive: false });
+ render(
+
+
+
+ );
expect(getLink('#link')).toHaveAttribute('tabIndex', '0');
});
test('does not override tab index for anchor link when keyboard navigation is not active', () => {
- renderWithSingleTabStopNavigation(, { navigationActive: false });
+ render(
+
+
+
+ );
expect(getLink('#link')).not.toHaveAttribute('tabIndex');
});
test.each([undefined, '#'])('overrides tab index when keyboard navigation is active href=%s', href => {
- const { setCurrentTarget } = renderWithSingleTabStopNavigation(
-
+ render(
+
-
+
);
- setCurrentTarget(getLink('#link1'));
+ setTestSingleTabStopNavigationTarget(getLink('#link1'));
expect(getLink('#link1')).toHaveAttribute('tabIndex', '0');
expect(getLink('#link2')).toHaveAttribute('tabIndex', '-1');
});
diff --git a/src/popover/__tests__/popover.test.tsx b/src/popover/__tests__/popover.test.tsx
index e129bbfd79..daf786f83f 100644
--- a/src/popover/__tests__/popover.test.tsx
+++ b/src/popover/__tests__/popover.test.tsx
@@ -3,7 +3,10 @@
import React from 'react';
import { act, render } from '@testing-library/react';
-import { renderWithSingleTabStopNavigation } from '@cloudscape-design/component-toolkit/internal/testing';
+import {
+ setTestSingleTabStopNavigationTarget,
+ TestSingleTabStopNavigationProvider,
+} from '@cloudscape-design/component-toolkit/internal/testing';
import { KeyCode } from '@cloudscape-design/test-utils-core/utils';
import '../../__a11y__/to-validate-a11y';
@@ -366,29 +369,33 @@ describe('table grid navigation support', () => {
}
test('does not override tab index when keyboard navigation is not active', () => {
- renderWithSingleTabStopNavigation(Trigger, { navigationActive: false });
+ render(
+
+ Trigger
+
+ );
expect(getTrigger()).not.toHaveAttribute('tabIndex');
});
test('overrides tab index when keyboard navigation is active', () => {
- const { setCurrentTarget } = renderWithSingleTabStopNavigation(
-
+ render(
+
Trigger
Trigger
-
+
);
- setCurrentTarget(getTrigger('#popover1'));
+ setTestSingleTabStopNavigationTarget(getTrigger('#popover1'));
expect(getTrigger('#popover1')).toHaveAttribute('tabIndex', '0');
expect(getTrigger('#popover2')).toHaveAttribute('tabIndex', '-1');
});
test('does not override tab index for custom trigger', () => {
- const { setCurrentTarget } = renderWithSingleTabStopNavigation(
-
+
);
- setCurrentTarget(getTrigger());
+ setTestSingleTabStopNavigationTarget(getTrigger());
expect(getTrigger()).not.toHaveAttribute('tabIndex');
});
});
diff --git a/src/radio-group/__tests__/radio-group.test.tsx b/src/radio-group/__tests__/radio-group.test.tsx
index 662c82b8ec..14e707c30b 100644
--- a/src/radio-group/__tests__/radio-group.test.tsx
+++ b/src/radio-group/__tests__/radio-group.test.tsx
@@ -3,7 +3,10 @@
import React, { useState } from 'react';
import { act, render } from '@testing-library/react';
-import { renderWithSingleTabStopNavigation } from '@cloudscape-design/component-toolkit/internal/testing';
+import {
+ setTestSingleTabStopNavigationTarget,
+ TestSingleTabStopNavigationProvider,
+} from '@cloudscape-design/component-toolkit/internal/testing';
import '../../__a11y__/to-validate-a11y';
import RadioGroup, { RadioGroupProps } from '../../../lib/components/radio-group';
@@ -369,20 +372,22 @@ describe('table grid navigation support', () => {
}
test('does not override tab index when keyboard navigation is not active', () => {
- renderWithSingleTabStopNavigation(, {
- navigationActive: false,
- });
+ render(
+
+
+
+ );
expect(getRadioInput('#radio')).not.toHaveAttribute('tabIndex');
});
test('overrides tab index when keyboard navigation is active', () => {
- const { setCurrentTarget } = renderWithSingleTabStopNavigation(
-
+ render(
+
-
+
);
- setCurrentTarget(getRadioInput('#radio1'));
+ setTestSingleTabStopNavigationTarget(getRadioInput('#radio1'));
expect(getRadioInput('#radio1')).toHaveAttribute('tabIndex', '0');
expect(getRadioInput('#radio2')).toHaveAttribute('tabIndex', '-1');
});
diff --git a/src/table/__tests__/body-cell.test.tsx b/src/table/__tests__/body-cell.test.tsx
index 9b5e62c88c..5101175c37 100644
--- a/src/table/__tests__/body-cell.test.tsx
+++ b/src/table/__tests__/body-cell.test.tsx
@@ -3,7 +3,10 @@
import * as React from 'react';
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
-import { renderWithSingleTabStopNavigation } from '@cloudscape-design/component-toolkit/internal/testing';
+import {
+ setTestSingleTabStopNavigationTarget,
+ TestSingleTabStopNavigationProvider,
+} from '@cloudscape-design/component-toolkit/internal/testing';
import { LiveRegionController } from '../../../lib/components/live-region/controller.js';
import { TableBodyCell, TableBodyCellProps } from '../../../lib/components/table/body-cell';
@@ -336,13 +339,17 @@ describe('TableBodyCell', () => {
});
test('does not set tab index when negative', () => {
- const { setCurrentTarget } = renderWithSingleTabStopNavigation(, { navigationActive: true });
+ render(
+
+
+
+ );
const tableCell = wrapper().find('td')!.getElement();
expect(tableCell).not.toHaveAttribute('tabIndex');
- setCurrentTarget(tableCell);
+ setTestSingleTabStopNavigationTarget(tableCell);
expect(tableCell).toHaveAttribute('tabIndex', '0');
- setCurrentTarget(null);
+ setTestSingleTabStopNavigationTarget(null);
expect(tableCell).not.toHaveAttribute('tabIndex');
});
diff --git a/src/table/__tests__/header-cell.test.tsx b/src/table/__tests__/header-cell.test.tsx
index f22c1c47b9..a525db2467 100644
--- a/src/table/__tests__/header-cell.test.tsx
+++ b/src/table/__tests__/header-cell.test.tsx
@@ -4,7 +4,10 @@ import * as React from 'react';
import { fireEvent, render } from '@testing-library/react';
import { ContainerQueryEntry } from '@cloudscape-design/component-toolkit';
-import { renderWithSingleTabStopNavigation } from '@cloudscape-design/component-toolkit/internal/testing';
+import {
+ setTestSingleTabStopNavigationTarget,
+ TestSingleTabStopNavigationProvider,
+} from '@cloudscape-design/component-toolkit/internal/testing';
import TestI18nProvider from '../../../lib/components/i18n/testing';
import { TableHeaderCell, TableHeaderCellProps } from '../../../lib/components/table/header-cell';
@@ -124,15 +127,17 @@ describe('i18n', () => {
});
test('does not set tab index when negative', () => {
- const { setCurrentTarget } = renderWithSingleTabStopNavigation(, {
- navigationActive: true,
- });
+ render(
+
+
+
+ );
const headerCell = document.querySelector('th')!;
expect(headerCell).not.toHaveAttribute('tabIndex');
- setCurrentTarget(headerCell);
+ setTestSingleTabStopNavigationTarget(headerCell);
expect(headerCell).toHaveAttribute('tabIndex', '0');
- setCurrentTarget(null);
+ setTestSingleTabStopNavigationTarget(null);
expect(headerCell).not.toHaveAttribute('tabIndex');
});
});