Skip to content

Commit

Permalink
Hint bind and rebind tests
Browse files Browse the repository at this point in the history
  • Loading branch information
philrenaud committed Mar 27, 2024
1 parent 3cb2696 commit 76a7229
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/20235.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
ui: When you re-bind keyboard shortcuts they now correctly show up in shift-held hints
```
24 changes: 24 additions & 0 deletions ui/tests/acceptance/keyboard-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ module('Acceptance | keyboard', function (hooks) {
'end up on the clients page after typing g c'
);

await triggerEvent('.page-layout', 'keydown', { key: 'Shift' });
assert.dom('[data-shortcut="g,c"]').exists('g c shortcut is shown');
await triggerEvent('.page-layout', 'keyup', { key: 'Shift' });

triggerEvent('.page-layout', 'keydown', { key: 'g' });
await triggerEvent('.page-layout', 'keydown', { key: 'j' });
assert.equal(
Expand Down Expand Up @@ -180,6 +184,16 @@ module('Acceptance | keyboard', function (hooks) {
'text unchanged when I hit escape during recording'
);

// when holding shift, the previous "g c" command is now "r o f l"
await triggerEvent('.page-layout', 'keydown', { key: 'Shift' });
assert
.dom('[data-shortcut="g,c"]')
.doesNotExist('g c shortcut is no longer shown');
assert
.dom('[data-shortcut="r,o,f,l"]')
.exists('r o f l shortcut is shown in its place');
await triggerEvent('.page-layout', 'keyup', { key: 'Shift' });

await click(
'[data-test-command-label="Go to Clients"] button.reset-to-default'
);
Expand All @@ -188,6 +202,16 @@ module('Acceptance | keyboard', function (hooks) {
'[data-test-command-label="Go to Clients"] button[data-test-rebinder]'
)
.hasText('g c', 'Resetting to default rebinds the shortcut');

// when holding shift, the now-reset command is back to "g c"
await triggerEvent('.page-layout', 'keydown', { key: 'Shift' });
assert
.dom('[data-shortcut="g,c"]')
.exists('g c shortcut is back after reset to default');
assert
.dom('[data-shortcut="r,o,f,l"]')
.doesNotExist('r o f l shortcut is gone after reset to default');
await triggerEvent('.page-layout', 'keyup', { key: 'Shift' });
});

test('Rebound shortcuts persist from localStorage', async function (assert) {
Expand Down

0 comments on commit 76a7229

Please sign in to comment.