Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
2125a2c4
Commit
2125a2c4
authored
Aug 20, 2021
by
Anna Vovchenko
Committed by
Olena Horal-Koretska
Aug 20, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upsell the GitLab Terraform feature - tracking
parent
84c13147
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
0 deletions
+40
-0
app/assets/javascripts/projects/terraform_notification/components/terraform_notification.vue
...raform_notification/components/terraform_notification.vue
+10
-0
app/assets/javascripts/projects/terraform_notification/constants.js
.../javascripts/projects/terraform_notification/constants.js
+3
-0
spec/frontend/projects/terraform_notification/terraform_notification_spec.js
...cts/terraform_notification/terraform_notification_spec.js
+27
-0
No files found.
app/assets/javascripts/projects/terraform_notification/components/terraform_notification.vue
View file @
2125a2c4
...
...
@@ -3,6 +3,10 @@ import { GlBanner } from '@gitlab/ui';
import
{
helpPagePath
}
from
'
~/helpers/help_page_helper
'
;
import
{
setCookie
}
from
'
~/lib/utils/common_utils
'
;
import
{
s__
}
from
'
~/locale
'
;
import
Tracking
from
'
~/tracking
'
;
import
{
EVENT_LABEL
,
DISMISS_EVENT
,
CLICK_EVENT
}
from
'
../constants
'
;
const
trackingMixin
=
Tracking
.
mixin
({
label
:
EVENT_LABEL
});
export
default
{
name
:
'
TerraformNotification
'
,
...
...
@@ -16,6 +20,7 @@ export default {
components
:
{
GlBanner
,
},
mixins
:
[
trackingMixin
],
inject
:
[
'
terraformImagePath
'
,
'
bannerDismissedKey
'
],
data
()
{
return
{
...
...
@@ -31,6 +36,10 @@ export default {
handleClose
()
{
setCookie
(
this
.
bannerDismissedKey
,
true
);
this
.
isVisible
=
false
;
this
.
track
(
DISMISS_EVENT
);
},
buttonClick
()
{
this
.
track
(
CLICK_EVENT
);
},
},
};
...
...
@@ -43,6 +52,7 @@ export default {
:button-link=
"docsUrl"
:svg-path=
"terraformImagePath"
variant=
"promotion"
@
primary=
"buttonClick"
@
close=
"handleClose"
>
<p>
{{
$options
.
i18n
.
description
}}
</p>
...
...
app/assets/javascripts/projects/terraform_notification/constants.js
0 → 100644
View file @
2125a2c4
export
const
EVENT_LABEL
=
'
terraform_banner
'
;
export
const
DISMISS_EVENT
=
'
dismiss_banner
'
;
export
const
CLICK_EVENT
=
'
click_button
'
;
spec/frontend/projects/terraform_notification/terraform_notification_spec.js
View file @
2125a2c4
import
{
GlBanner
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
mockTracking
,
unmockTracking
}
from
'
helpers/tracking_helper
'
;
import
{
setCookie
,
parseBoolean
}
from
'
~/lib/utils/common_utils
'
;
import
TerraformNotification
from
'
~/projects/terraform_notification/components/terraform_notification.vue
'
;
import
{
EVENT_LABEL
,
DISMISS_EVENT
,
CLICK_EVENT
,
}
from
'
~/projects/terraform_notification/constants
'
;
jest
.
mock
(
'
~/lib/utils/common_utils
'
);
...
...
@@ -10,6 +16,7 @@ const bannerDismissedKey = 'terraform_notification_dismissed';
describe
(
'
TerraformNotificationBanner
'
,
()
=>
{
let
wrapper
;
let
trackingSpy
;
const
provideData
=
{
terraformImagePath
,
...
...
@@ -22,11 +29,13 @@ describe('TerraformNotificationBanner', () => {
provide
:
provideData
,
stubs
:
{
GlBanner
},
});
trackingSpy
=
mockTracking
(
undefined
,
wrapper
.
element
,
jest
.
spyOn
);
});
afterEach
(()
=>
{
wrapper
.
destroy
();
parseBoolean
.
mockReturnValue
(
false
);
unmockTracking
();
});
describe
(
'
when the dismiss cookie is not set
'
,
()
=>
{
...
...
@@ -44,8 +53,26 @@ describe('TerraformNotificationBanner', () => {
expect
(
setCookie
).
toHaveBeenCalledWith
(
bannerDismissedKey
,
true
);
});
it
(
'
should send the dismiss event
'
,
()
=>
{
expect
(
trackingSpy
).
toHaveBeenCalledWith
(
undefined
,
DISMISS_EVENT
,
{
label
:
EVENT_LABEL
,
});
});
it
(
'
should remove the banner
'
,
()
=>
{
expect
(
findBanner
().
exists
()).
toBe
(
false
);
});
});
describe
(
'
when docs link is clicked
'
,
()
=>
{
beforeEach
(
async
()
=>
{
await
findBanner
().
vm
.
$emit
(
'
primary
'
);
});
it
(
'
should send button click event
'
,
()
=>
{
expect
(
trackingSpy
).
toHaveBeenCalledWith
(
undefined
,
CLICK_EVENT
,
{
label
:
EVENT_LABEL
,
});
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment