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
a8dc07be
Unverified
Commit
a8dc07be
authored
5 years ago
by
Tom Robinson
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Port pulse e2e test (#11661)
parent
ec965c57
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/test/metabase/pulse/pulse.e2e.spec.js
+0
-156
0 additions, 156 deletions
frontend/test/metabase/pulse/pulse.e2e.spec.js
frontend/test/metabase/scenarios/pulse.cy.spec.js
+66
-0
66 additions, 0 deletions
frontend/test/metabase/scenarios/pulse.cy.spec.js
with
66 additions
and
156 deletions
frontend/test/metabase/pulse/pulse.e2e.spec.js
deleted
100644 → 0
+
0
−
156
View file @
ec965c57
import
{
useSharedAdminLogin
,
createTestStore
,
createSavedQuestion
,
}
from
"
__support__/e2e
"
;
import
{
click
,
setInputValue
}
from
"
__support__/enzyme
"
;
import
React
from
"
react
"
;
import
{
mount
}
from
"
enzyme
"
;
import
{
CardApi
,
PulseApi
}
from
"
metabase/services
"
;
import
Question
from
"
metabase-lib/lib/Question
"
;
import
PulseEditApp
from
"
metabase/pulse/containers/PulseEditApp
"
;
import
QuestionSelect
from
"
metabase/containers/QuestionSelect
"
;
import
PulseCardPreview
from
"
metabase/pulse/components/PulseCardPreview
"
;
import
Toggle
from
"
metabase/components/Toggle
"
;
import
{
SET_EDITING_PULSE
,
SAVE_EDITING_PULSE
,
FETCH_PULSE_CARD_PREVIEW
,
}
from
"
metabase/pulse/actions
"
;
describe
(
"
Pulse
"
,
()
=>
{
let
questionCount
,
questionRaw
;
const
normalFormInput
=
PulseApi
.
form_input
;
beforeAll
(
async
()
=>
{
useSharedAdminLogin
();
const
formInput
=
await
PulseApi
.
form_input
();
PulseApi
.
form_input
=
()
=>
({
channels
:
{
...
formInput
.
channels
,
email
:
{
...
formInput
.
channels
.
email
,
configured
:
true
,
},
},
});
questionCount
=
await
createSavedQuestion
(
Question
.
create
({
databaseId
:
1
,
tableId
:
1
,
metadata
:
null
})
.
query
()
.
aggregate
([
"
count
"
])
.
question
()
.
setDisplay
(
"
scalar
"
)
.
setDisplayName
(
"
count
"
),
);
questionRaw
=
await
createSavedQuestion
(
Question
.
create
({
databaseId
:
1
,
tableId
:
1
,
metadata
:
null
})
.
query
()
.
question
()
.
setDisplay
(
"
table
"
)
.
setDisplayName
(
"
table
"
),
);
// possibly not necessary, but just to be sure we start with clean slate
for
(
const
pulse
of
await
PulseApi
.
list
())
{
await
PulseApi
.
delete
({
pulseId
:
pulse
.
id
});
}
});
afterAll
(
async
()
=>
{
PulseApi
.
form_input
=
normalFormInput
;
await
CardApi
.
delete
({
cardId
:
questionCount
.
id
()
});
await
CardApi
.
delete
({
cardId
:
questionRaw
.
id
()
});
for
(
const
pulse
of
await
PulseApi
.
list
())
{
await
PulseApi
.
delete
({
pulseId
:
pulse
.
id
});
}
});
let
store
;
beforeEach
(
async
()
=>
{
store
=
await
createTestStore
();
});
it
(
"
should load create pulse
"
,
async
()
=>
{
store
.
pushPath
(
"
/pulse/create
"
);
const
app
=
mount
(
store
.
connectContainer
(
<
PulseEditApp
/>
));
await
store
.
waitForActions
([
SET_EDITING_PULSE
]);
// no previews yet
expect
(
app
.
find
(
PulseCardPreview
).
length
).
toBe
(
0
);
// set name to 'foo'
setInputValue
(
app
.
find
(
"
input
"
).
first
(),
"
foo
"
);
// email channel should be enabled
expect
(
app
.
find
(
Toggle
)
.
first
()
.
props
().
value
,
).
toBe
(
true
);
// add count card
app
.
find
(
QuestionSelect
)
.
first
()
.
props
()
.
onChange
(
questionCount
.
id
());
await
store
.
waitForActions
([
FETCH_PULSE_CARD_PREVIEW
]);
// add raw card
app
.
find
(
QuestionSelect
)
.
first
()
.
props
()
.
onChange
(
questionRaw
.
id
());
await
store
.
waitForActions
([
FETCH_PULSE_CARD_PREVIEW
]);
let
previews
=
app
.
find
(
PulseCardPreview
);
expect
(
previews
.
length
).
toBe
(
2
);
// NOTE: check text content since enzyme doesn't doesn't seem to work well with dangerouslySetInnerHTML
expect
(
previews
.
at
(
0
).
text
()).
toBe
(
"
count18,760
"
);
expect
(
previews
.
at
(
0
).
find
(
"
.Icon-attachment
"
).
length
).
toBe
(
1
);
expect
(
previews
.
at
(
1
).
text
()).
toEqual
(
expect
.
stringContaining
(
"
Showing 20 of 18,760 rows
"
),
);
expect
(
previews
.
at
(
1
).
find
(
"
.Icon-attachment
"
).
length
).
toBe
(
0
);
// toggle email channel off
click
(
app
.
find
(
Toggle
).
first
());
previews
=
app
.
find
(
PulseCardPreview
);
expect
(
previews
.
at
(
0
).
text
()).
toBe
(
"
count18,760
"
);
expect
(
previews
.
at
(
0
).
find
(
"
.Icon-attachment
"
).
length
).
toBe
(
0
);
expect
(
previews
.
at
(
1
).
text
()).
toEqual
(
expect
.
stringContaining
(
"
Showing 20 of 18,760 rows
"
),
);
expect
(
previews
.
at
(
1
).
find
(
"
.Icon-attachment
"
).
length
).
toBe
(
0
);
// toggle email channel on
click
(
app
.
find
(
Toggle
).
first
());
// save
const
saveButton
=
app
.
find
(
"
.PulseEdit-footer .Button
"
).
first
();
expect
(
saveButton
.
hasClass
(
"
Button--primary
"
)).
toBe
(
true
);
click
(
saveButton
);
await
store
.
waitForActions
([
SAVE_EDITING_PULSE
]);
const
[
pulse
]
=
await
PulseApi
.
list
();
expect
(
pulse
.
name
).
toBe
(
"
foo
"
);
expect
(
pulse
.
cards
[
0
].
id
).
toBe
(
questionCount
.
id
());
expect
(
pulse
.
cards
[
1
].
id
).
toBe
(
questionRaw
.
id
());
expect
(
pulse
.
channels
[
0
].
channel_type
).
toBe
(
"
email
"
);
expect
(
pulse
.
channels
[
0
].
enabled
).
toBe
(
true
);
});
});
This diff is collapsed.
Click to expand it.
frontend/test/metabase/scenarios/pulse.cy.spec.js
0 → 100644
+
66
−
0
View file @
a8dc07be
import
{
signInAsAdmin
,
restore
}
from
"
__support__/cypress
"
;
const
MOCK_PULSE_FORM_INPUT
=
{
channels
:
{
email
:
{
type
:
"
email
"
,
name
:
"
Email
"
,
allows_recipients
:
true
,
configured
:
true
,
recipients
:
[
"
user
"
,
"
email
"
],
schedules
:
[
"
daily
"
,
"
weekly
"
,
"
monthly
"
],
},
},
};
describe
(
"
pulse
"
,
()
=>
{
before
(
restore
);
beforeEach
(
signInAsAdmin
);
it
(
"
should be able get to the new pulse page from the nav bar
"
,
()
=>
{
cy
.
visit
(
"
/
"
);
cy
.
get
(
"
.Icon-add
"
).
click
();
cy
.
contains
(
"
New pulse
"
).
click
();
cy
.
url
().
should
(
"
match
"
,
/
\/
pulse
\/
create$/
);
});
it
(
"
should create a new pulse
"
,
()
=>
{
cy
.
server
();
cy
.
route
(
"
GET
"
,
"
/api/pulse/form_input
"
,
MOCK_PULSE_FORM_INPUT
);
cy
.
visit
(
"
/pulse/create
"
);
cy
.
get
(
'
[placeholder="Important metrics"]
'
)
.
wait
(
10
)
.
type
(
"
pulse title
"
);
cy
.
contains
(
"
Select a question
"
).
click
();
cy
.
contains
(
"
Orders, Count
"
).
click
();
// pulse card preview
cy
.
contains
(
"
18,760
"
);
cy
.
contains
(
"
Create pulse
"
).
click
();
cy
.
url
().
should
(
"
match
"
,
/
\/
collection
\/
root$/
);
cy
.
contains
(
"
pulse title
"
);
});
it
(
"
should load existing pulses
"
,
()
=>
{
cy
.
visit
(
"
/collection/root
"
);
cy
.
contains
(
"
pulse title
"
).
click
({
force
:
true
});
cy
.
contains
(
"
18,760
"
);
});
it
(
"
should edit existing pulses
"
,
()
=>
{
cy
.
visit
(
"
/pulse/1
"
);
cy
.
get
(
'
[placeholder="Important metrics"]
'
)
.
clear
()
.
type
(
"
new pulse title
"
);
cy
.
contains
(
"
Save changes
"
).
click
();
cy
.
url
().
should
(
"
match
"
,
/
\/
collection
\/
root$/
);
cy
.
contains
(
"
new pulse title
"
);
});
});
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