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
471b4e8c
Commit
471b4e8c
authored
Dec 06, 2021
by
anna_vovchenko
Committed by
Anna Vovchenko
Dec 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented suggestions after the FE review
parent
bb42f323
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
16 deletions
+54
-16
app/assets/javascripts/ci_variable_list/components/ci_variable_modal.vue
...scripts/ci_variable_list/components/ci_variable_modal.vue
+13
-8
spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js
...end/ci_variable_list/components/ci_variable_modal_spec.js
+41
-8
No files found.
app/assets/javascripts/ci_variable_list/components/ci_variable_modal.vue
View file @
471b4e8c
...
...
@@ -209,21 +209,26 @@ export default {
}
},
trackVariableValidationErrors
()
{
if
(
this
.
variable
.
secret_value
?.
length
&&
!
this
.
validationErrorEventProperty
)
{
const
property
=
this
.
getTrackingErrorProperty
();
if
(
!
this
.
validationErrorEventProperty
&&
property
)
{
this
.
track
(
EVENT_ACTION
,
{
property
});
this
.
validationErrorEventProperty
=
property
;
}
},
getTrackingErrorProperty
()
{
let
property
;
if
(
this
.
variable
.
secret_value
?.
length
&&
!
property
)
{
if
(
this
.
displayMaskedError
&&
this
.
maskableRegex
?.
length
)
{
const
supportedChars
=
this
.
maskableRegex
.
replace
(
'
^
'
,
''
).
replace
(
/{
(\d
,
)
}
\$
/
,
''
);
const
regex
=
new
RegExp
(
supportedChars
,
'
g
'
);
const
error
=
this
.
variable
.
secret_value
.
replace
(
regex
,
''
);
this
.
track
(
EVENT_ACTION
,
{
property
:
error
});
this
.
validationErrorEventProperty
=
error
;
property
=
this
.
variable
.
secret_value
.
replace
(
regex
,
''
);
}
if
(
this
.
containsVariableReference
)
{
this
.
track
(
EVENT_ACTION
,
{
property
:
'
$
'
});
this
.
validationErrorEventProperty
=
'
$
'
;
property
=
'
$
'
;
}
}
return
property
;
},
resetValidationErrorEvents
()
{
this
.
validationErrorEventProperty
=
''
;
...
...
spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js
View file @
471b4e8c
...
...
@@ -128,10 +128,10 @@ describe('Ci variable modal', () => {
});
describe
.
each
`
value | secret | rendered
| event_sent
${
'
value
'
}
|
${
'
secret_value
'
}
|
${
false
}
|
${
0
}
${
'
dollar$ign
'
}
|
${
'
dollar$ign
'
}
|
${
true
}
|
${
1
}
`
(
'
Adding a new variable
'
,
({
value
,
secret
,
rendered
,
event_sent
})
=>
{
value | secret | rendered
${
'
value
'
}
|
${
'
secret_value
'
}
|
${
false
}
${
'
dollar$ign
'
}
|
${
'
dollar$ign
'
}
|
${
true
}
`
(
'
Adding a new variable
'
,
({
value
,
secret
,
rendered
})
=>
{
beforeEach
(()
=>
{
const
[
variable
]
=
mockData
.
mockVariables
;
const
invalidKeyVariable
=
{
...
...
@@ -149,10 +149,6 @@ describe('Ci variable modal', () => {
const
warning
=
wrapper
.
find
(
`[data-testid='contains-variable-reference']`
);
expect
(
warning
.
exists
()).
toBe
(
rendered
);
});
it
(
`
${
rendered
?
'
sends
'
:
'
does not send
'
}
the variable reference tracking event`
,
()
=>
{
expect
(
trackingSpy
).
toHaveBeenCalledTimes
(
event_sent
);
});
});
describe
(
'
Editing a variable
'
,
()
=>
{
...
...
@@ -254,6 +250,43 @@ describe('Ci variable modal', () => {
});
});
describe
.
each
`
value | secret | masked | eventSent | trackingErrorProperty
${
'
value
'
}
|
${
'
secretValue
'
}
|
${
false
}
|
${
0
}
|
${
null
}
${
'
shortMasked
'
}
|
${
'
short
'
}
|
${
true
}
|
${
0
}
|
${
null
}
${
'
withDollar$Sign
'
}
|
${
'
dollar$ign
'
}
|
${
false
}
|
${
1
}
|
${
'
$
'
}
${
'
withDollar$Sign
'
}
|
${
'
dollar$ign
'
}
|
${
true
}
|
${
1
}
|
${
'
$
'
}
${
'
unsupported
'
}
|
${
'
unsupported|char
'
}
|
${
true
}
|
${
1
}
|
${
'
|
'
}
${
'
unsupportedMasked
'
}
|
${
'
unsupported|char
'
}
|
${
false
}
|
${
0
}
|
${
null
}
`
(
'
Adding a new variable
'
,
({
value
,
secret
,
masked
,
eventSent
,
trackingErrorProperty
})
=>
{
beforeEach
(()
=>
{
const
[
variable
]
=
mockData
.
mockVariables
;
const
invalidKeyVariable
=
{
...
variable
,
key
:
'
key
'
,
value
,
secret_value
:
secret
,
masked
,
};
createComponent
(
mount
);
store
.
state
.
variable
=
invalidKeyVariable
;
trackingSpy
=
mockTracking
(
undefined
,
wrapper
.
element
,
jest
.
spyOn
);
});
it
(
`
${
eventSent
>
0
?
'
sends the correct
'
:
'
does not send the
'
}
variable validation tracking event`
,
()
=>
{
expect
(
trackingSpy
).
toHaveBeenCalledTimes
(
eventSent
);
if
(
eventSent
>
0
)
{
expect
(
trackingSpy
).
toHaveBeenCalledWith
(
undefined
,
EVENT_ACTION
,
{
label
:
EVENT_LABEL
,
property
:
trackingErrorProperty
,
});
}
});
});
describe
(
'
when both states are valid
'
,
()
=>
{
beforeEach
(()
=>
{
const
[
variable
]
=
mockData
.
mockVariables
;
...
...
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