فهرست منبع

Add failing test for keyboard controls with `x-teleport`

Jens Ahrengot Boddum 1 سال پیش
والد
کامیت
1a86f08c6d
1فایلهای تغییر یافته به همراه48 افزوده شده و 0 حذف شده
  1. 48 0
      tests/cypress/integration/plugins/ui/menu.spec.js

+ 48 - 0
tests/cypress/integration/plugins/ui/menu.spec.js

@@ -219,6 +219,54 @@ test('keyboard controls',
     },
     },
 )
 )
 
 
+test('keyboard controls with x-teleport',
+    [html`
+        <div x-data x-menu>
+            <span>
+                <button x-menu:button trigger>
+                    <span>Options</span>
+                </button>
+            </span>
+
+            <template x-teleport="body">
+                <div x-menu:items items>
+                    <a x-menu:item href="#account-settings" :class="$menuItem.isActive && 'active'">
+                        Account settings
+                    </a>
+                    <a x-menu:item href="#support" :class="$menuItem.isActive && 'active'">
+                        Support
+                    </a>
+                </div>
+            </template>
+        </div>`],
+    ({ get }) => {
+        get('.active').should(notExist())
+        get('[trigger]').type(' ')
+        get('[items]')
+            .should(beVisible())
+            .should(haveFocus())
+            .type('{downarrow}')
+        get('[href="#account-settings"]')
+            .should(haveClasses(['active']))
+        get('[items]')
+            .type('{downarrow}')
+        get('[href="#support"]')
+            .should(haveClasses(['active']))
+            .type('{uparrow}')
+        get('[href="#account-settings"]')
+            .should(haveClasses(['active']))
+        get('[items]')
+            .tab()
+            .should(haveFocus())
+            .should(beVisible())
+            .tab({ shift: true})
+            .should(haveFocus())
+            .should(beVisible())
+            .type('{esc}')
+            .should(notBeVisible())
+    },
+)
+
 test('search',
 test('search',
     [html`
     [html`
         <div x-data x-menu>
         <div x-data x-menu>