@@ -4,10 +4,10 @@ import TradeDialog from '@/components/common/TradeDialog';
44
55/**
66 * The dialog's focus order is part of its accessibility contract — keyboard
7- * users tab through `amount input → Cancel → Confirm`, matching the
8- * left-to-right visual order. These tests guard against future refactors
9- * that accidentally swap Cancel and Confirm in the DOM (which would also
10- * swap them in the tab sequence) or remove the marker attributes .
7+ * users wrap through `Close → amount input → Cancel → Confirm`, matching
8+ * the visual top-to-bottom and left-to-right order. These tests guard
9+ * against future refactors that accidentally swap these elements in the
10+ * DOM (which would also swap them in the tab sequence) or remove markers .
1111 */
1212describe ( 'TradeDialog focus order' , ( ) => {
1313 function renderDialog ( overrides : Partial < React . ComponentProps < typeof TradeDialog > > = { } ) {
@@ -24,7 +24,7 @@ describe('TradeDialog focus order', () => {
2424 ) ;
2525 }
2626
27- it ( 'renders the focus-order markers on the three primary controls' , ( ) => {
27+ it ( 'renders the focus-order markers on the primary controls' , ( ) => {
2828 renderDialog ( ) ;
2929
3030 expect ( screen . getByTestId ( 'trade-dialog-amount' ) ) . toHaveAttribute (
@@ -41,20 +41,21 @@ describe('TradeDialog focus order', () => {
4141 ) ;
4242 } ) ;
4343
44- it ( 'orders the controls in DOM as amount → Cancel → Confirm so tab sequence matches' , ( ) => {
44+ it ( 'orders the controls in DOM as Close → amount → Cancel → Confirm so tab sequence matches' , ( ) => {
4545 renderDialog ( ) ;
4646
47- const ordered = Array . from (
48- document . querySelectorAll ( '[data-focus-order]' )
47+ const elements = Array . from (
48+ document . querySelectorAll ( '[data-slot="dialog-close"], [data- focus-order]' )
4949 ) . map ( el => ( {
50- testId : el . getAttribute ( 'data-testid' ) ,
51- order : el . getAttribute ( 'data-focus-order' ) ,
50+ identifier : el . getAttribute ( 'data-testid' ) || el . getAttribute ( 'data-slot ') ,
51+ order : el . getAttribute ( 'data-focus-order' ) || '0' ,
5252 } ) ) ;
5353
54- expect ( ordered ) . toEqual ( [
55- { testId : 'trade-dialog-amount' , order : '1' } ,
56- { testId : 'trade-dialog-cancel' , order : '2' } ,
57- { testId : 'trade-dialog-confirm' , order : '3' } ,
54+ expect ( elements ) . toEqual ( [
55+ { identifier : 'dialog-close' , order : '0' } ,
56+ { identifier : 'trade-dialog-amount' , order : '1' } ,
57+ { identifier : 'trade-dialog-cancel' , order : '2' } ,
58+ { identifier : 'trade-dialog-confirm' , order : '3' } ,
5859 ] ) ;
5960 } ) ;
6061
0 commit comments