Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
25d6ba4b
Unverified
Commit
25d6ba4b
authored
7 years ago
by
Kyle Doherty
Browse files
Options
Downloads
Patches
Plain Diff
add enter commit + tests for methods
parent
705ce2c1
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/src/metabase/pulse/components/RecipientPicker.jsx
+3
-1
3 additions, 1 deletion
frontend/src/metabase/pulse/components/RecipientPicker.jsx
frontend/test/pulse/pulse.unit.spec.js
+34
-27
34 additions, 27 deletions
frontend/test/pulse/pulse.unit.spec.js
with
37 additions
and
28 deletions
frontend/src/metabase/pulse/components/RecipientPicker.jsx
+
3
−
1
View file @
25d6ba4b
...
...
@@ -14,6 +14,7 @@ import MetabaseAnalytics from "metabase/lib/analytics";
import
{
KEYCODE_ESCAPE
,
KEYCODE_ENTER
,
KEYCODE_COMMA
,
KEYCODE_TAB
,
KEYCODE_UP
,
...
...
@@ -107,7 +108,7 @@ export default class RecipientPicker extends Component {
const
{
filteredUsers
,
selectedUserID
}
=
this
.
state
// enter, tab, comma
if
(
keyCode
===
KEYCODE_ESCAPE
||
keyCode
===
KEYCODE_TAB
||
keyCode
===
KEYCODE_COMMA
)
{
if
(
keyCode
===
KEYCODE_ESCAPE
||
keyCode
===
KEYCODE_TAB
||
keyCode
===
KEYCODE_COMMA
||
keyCode
===
KEYCODE_ENTER
)
{
this
.
addCurrentRecipient
();
}
...
...
@@ -168,6 +169,7 @@ export default class RecipientPicker extends Component {
addRecipient
=
(
recipient
)
=>
{
const
{
recipients
}
=
this
.
props
// recipient is a user object, or plain object containing "email" key
this
.
props
.
onRecipientsChange
(
// return the list of recipients with the new user added
...
...
This diff is collapsed.
Click to expand it.
frontend/test/pulse/pulse.unit.spec.js
+
34
−
27
View file @
25d6ba4b
...
...
@@ -4,6 +4,8 @@ import { shallow } from 'enzyme'
import
{
KEYCODE_DOWN
,
KEYCODE_TAB
,
KEYCODE_ENTER
,
KEYCODE_COMMA
}
from
"
metabase/lib/keyboard
"
import
Input
from
"
metabase/components/Input
"
...
...
@@ -108,42 +110,47 @@ describe('recipient picker', () => {
expect
(
spy
).
toHaveBeenCalled
()
})
it
(
'
should allow the user to use arrow keys to select a recipient
'
,
()
=>
{
const
spy
=
jest
.
fn
()
describe
(
'
key selection
'
,
()
=>
{
[
KEYCODE_TAB
,
KEYCODE_ENTER
,
KEYCODE_COMMA
].
map
(
key
=>
it
(
`should allow the user to use arrow keys and then
${
key
}
to select a recipient`
,
()
=>
{
const
spy
=
jest
.
fn
()
const
wrapper
=
shallow
(
<
RecipientPicker
recipients
=
{[]}
users
=
{
TEST_USERS
}
isNewPulse
=
{
true
}
onRecipientsChange
=
{
spy
}
/
>
)
const
wrapper
=
shallow
(
<
RecipientPicker
recipients
=
{[]}
users
=
{
TEST_USERS
}
isNewPulse
=
{
true
}
onRecipientsChange
=
{
spy
}
/
>
)
const
input
=
wrapper
.
find
(
Input
)
const
input
=
wrapper
.
find
(
Input
)
// limit our options to user by typing
input
.
simulate
(
'
change
'
,
{
target
:
{
value
:
'
w
'
}})
// limit our options to user by typing
input
.
simulate
(
'
change
'
,
{
target
:
{
value
:
'
w
'
}})
// the initially selected user should be the first user
expect
(
wrapper
.
state
().
selectedUserID
).
toBe
(
TEST_USERS
[
0
].
id
)
// the initially selected user should be the first user
expect
(
wrapper
.
state
().
selectedUserID
).
toBe
(
TEST_USERS
[
0
].
id
)
input
.
simulate
(
'
keyDown
'
,
{
keyCode
:
KEYCODE_DOWN
,
preventDefault
:
jest
.
fn
()
})
input
.
simulate
(
'
keyDown
'
,
{
keyCode
:
KEYCODE_DOWN
,
preventDefault
:
jest
.
fn
()
})
// the next possible user should be selected now
expect
(
wrapper
.
state
().
selectedUserID
).
toBe
(
TEST_USERS
[
1
].
id
)
// the next possible user should be selected now
expect
(
wrapper
.
state
().
selectedUserID
).
toBe
(
TEST_USERS
[
1
].
id
)
input
.
simulate
(
'
keydown
'
,
{
keyCode
:
KEYCODE_TAB
,
preventDefalut
:
jest
.
fn
()
})
input
.
simulate
(
'
keydown
'
,
{
keyCode
:
key
,
preventDefalut
:
jest
.
fn
()
})
expect
(
spy
).
toHaveBeenCalledTimes
(
1
)
expect
(
spy
).
toHaveBeenCalledWith
([
TEST_USERS
[
1
]])
expect
(
spy
).
toHaveBeenCalledTimes
(
1
)
expect
(
spy
).
toHaveBeenCalledWith
([
TEST_USERS
[
1
]]
)
}
)
)
})
describe
(
'
usage
'
,
()
=>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment