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
2e146b33
Commit
2e146b33
authored
Mar 18, 2021
by
Alexander Turinske
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update alert status components
- provide defaults - convert inject to prop - update tests
parent
12c0a7f7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
112 additions
and
49 deletions
+112
-49
app/assets/javascripts/vue_shared/alert_details/components/alert_status.vue
...ipts/vue_shared/alert_details/components/alert_status.vue
+5
-3
app/assets/javascripts/vue_shared/alert_details/components/sidebar/sidebar_status.vue
...hared/alert_details/components/sidebar/sidebar_status.vue
+1
-0
app/assets/javascripts/vue_shared/components/alert_details_table.vue
...javascripts/vue_shared/components/alert_details_table.vue
+2
-1
spec/frontend/vue_shared/alert_details/alert_status_spec.js
spec/frontend/vue_shared/alert_details/alert_status_spec.js
+19
-0
spec/frontend/vue_shared/alert_details/sidebar/alert_sidebar_status_spec.js
...shared/alert_details/sidebar/alert_sidebar_status_spec.js
+29
-2
spec/frontend/vue_shared/components/alert_details_table_spec.js
...rontend/vue_shared/components/alert_details_table_spec.js
+56
-43
No files found.
app/assets/javascripts/vue_shared/alert_details/components/alert_status.vue
View file @
2e146b33
...
...
@@ -20,9 +20,6 @@ export default {
trackAlertStatusUpdateOptions
:
{
default
:
null
,
},
statuses
:
{
default
:
PAGE_CONFIG
.
OPERATIONS
.
STATUSES
,
},
},
props
:
{
projectPath
:
{
...
...
@@ -41,6 +38,11 @@ export default {
type
:
Boolean
,
required
:
true
,
},
statuses
:
{
type
:
Object
,
required
:
false
,
default
:
()
=>
PAGE_CONFIG
.
OPERATIONS
.
STATUSES
,
},
},
computed
:
{
dropdownClass
()
{
...
...
app/assets/javascripts/vue_shared/alert_details/components/sidebar/sidebar_status.vue
View file @
2e146b33
...
...
@@ -94,6 +94,7 @@ export default {
:project-path=
"projectPath"
:is-dropdown-showing=
"isDropdownShowing"
:is-sidebar=
"true"
:statuses=
"statuses"
@
alert-error=
"$emit('alert-error', $event)"
@
hide-dropdown=
"hideDropdown"
@
handle-updating=
"handleUpdating"
...
...
app/assets/javascripts/vue_shared/components/alert_details_table.vue
View file @
2e146b33
...
...
@@ -7,6 +7,7 @@ import {
splitCamelCase
,
}
from
'
~/lib/utils/text_utility
'
;
import
{
s__
}
from
'
~/locale
'
;
import
{
PAGE_CONFIG
}
from
'
~/vue_shared/alert_details/constants
'
;
const
thClass
=
'
gl-bg-transparent! gl-border-1! gl-border-b-solid! gl-border-gray-200!
'
;
const
tdClass
=
'
gl-border-gray-100! gl-p-5!
'
;
...
...
@@ -45,7 +46,7 @@ export default {
statuses
:
{
type
:
Object
,
required
:
false
,
default
:
()
=>
({})
,
default
:
()
=>
PAGE_CONFIG
.
OPERATIONS
.
STATUSES
,
},
},
fields
:
[
...
...
spec/frontend/vue_shared/alert_details/alert_status_spec.js
View file @
2e146b33
...
...
@@ -12,6 +12,7 @@ describe('AlertManagementStatus', () => {
let
wrapper
;
const
findStatusDropdown
=
()
=>
wrapper
.
find
(
GlDropdown
);
const
findFirstStatusOption
=
()
=>
findStatusDropdown
().
find
(
GlDropdownItem
);
const
findAllStatusOptions
=
()
=>
findStatusDropdown
().
findAll
(
GlDropdownItem
);
const
selectFirstStatusOption
=
()
=>
{
findFirstStatusOption
().
vm
.
$emit
(
'
click
'
);
...
...
@@ -131,6 +132,24 @@ describe('AlertManagementStatus', () => {
});
});
describe
(
'
Statuses
'
,
()
=>
{
it
(
'
renders default translated statuses
'
,
()
=>
{
mountComponent
({});
expect
(
findAllStatusOptions
().
length
).
toBe
(
3
);
expect
(
findFirstStatusOption
().
text
()).
toBe
(
'
Triggered
'
);
});
it
(
'
renders translated statuses
'
,
()
=>
{
const
status
=
'
TEST
'
;
const
translatedStatus
=
'
Test
'
;
mountComponent
({
props
:
{
alert
:
{
...
mockAlert
,
status
},
statuses
:
{
[
status
]:
translatedStatus
}
},
});
expect
(
findAllStatusOptions
().
length
).
toBe
(
1
);
expect
(
findFirstStatusOption
().
text
()).
toBe
(
translatedStatus
);
});
});
describe
(
'
Snowplow tracking
'
,
()
=>
{
beforeEach
(()
=>
{
jest
.
spyOn
(
Tracking
,
'
event
'
);
...
...
spec/frontend/vue_shared/alert_details/sidebar/alert_sidebar_status_spec.js
View file @
2e146b33
import
{
GlDropdown
,
GlDropdownItem
,
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
updateAlertStatusMutation
from
'
~/graphql_shared/mutations/alert_status_update.mutation.graphql
'
;
import
AlertStatus
from
'
~/vue_shared/alert_details/components/alert_status.vue
'
;
import
AlertSidebarStatus
from
'
~/vue_shared/alert_details/components/sidebar/sidebar_status.vue
'
;
import
{
PAGE_CONFIG
}
from
'
~/vue_shared/alert_details/constants
'
;
import
mockAlerts
from
'
../mocks/alerts.json
'
;
const
mockAlert
=
mockAlerts
[
0
];
...
...
@@ -12,8 +14,16 @@ describe('Alert Details Sidebar Status', () => {
const
findStatusDropdownItem
=
()
=>
wrapper
.
find
(
GlDropdownItem
);
const
findStatusLoadingIcon
=
()
=>
wrapper
.
find
(
GlLoadingIcon
);
const
findStatusDropdownHeader
=
()
=>
wrapper
.
find
(
'
[data-testid="dropdown-header"]
'
);
const
findAlertStatus
=
()
=>
wrapper
.
findComponent
(
AlertStatus
);
const
findStatus
=
()
=>
wrapper
.
find
(
'
[data-testid="status"]
'
);
function
mountComponent
({
data
,
sidebarCollapsed
=
true
,
loading
=
false
,
stubs
=
{}
}
=
{})
{
function
mountComponent
({
data
,
sidebarCollapsed
=
true
,
loading
=
false
,
stubs
=
{},
provide
=
{},
}
=
{})
{
wrapper
=
mount
(
AlertSidebarStatus
,
{
propsData
:
{
alert
:
{
...
mockAlert
},
...
...
@@ -32,6 +42,7 @@ describe('Alert Details Sidebar Status', () => {
},
},
stubs
,
provide
,
});
}
...
...
@@ -96,8 +107,24 @@ describe('Alert Details Sidebar Status', () => {
jest
.
spyOn
(
wrapper
.
vm
.
$apollo
,
'
mutate
'
).
mockReturnValue
(
Promise
.
reject
(
new
Error
()));
findStatusDropdownItem
().
vm
.
$emit
(
'
click
'
);
expect
(
findStatusLoadingIcon
().
exists
()).
toBe
(
false
);
expect
(
wrapper
.
find
(
'
[data-testid="status"]
'
).
text
()).
toBe
(
'
Triggered
'
);
expect
(
findStatus
(
).
text
()).
toBe
(
'
Triggered
'
);
});
});
});
describe
(
'
Statuses
'
,
()
=>
{
it
(
'
renders default translated statuses
'
,
()
=>
{
mountComponent
({});
expect
(
findAlertStatus
().
props
(
'
statuses
'
)).
toBe
(
PAGE_CONFIG
.
OPERATIONS
.
STATUSES
);
expect
(
findStatus
().
text
()).
toBe
(
'
Triggered
'
);
});
it
(
'
renders translated statuses
'
,
()
=>
{
const
status
=
'
TEST
'
;
const
statuses
=
{
[
status
]:
'
Test
'
};
mountComponent
({
data
:
{
alert
:
{
...
mockAlert
,
status
}
},
provide
:
{
statuses
}
});
expect
(
findAlertStatus
().
props
(
'
statuses
'
)).
toBe
(
statuses
);
expect
(
findStatus
().
text
()).
toBe
(
statuses
.
TEST
);
});
});
});
spec/frontend/vue_shared/components/alert_details_table_spec.js
View file @
2e146b33
import
{
GlLoadingIcon
,
GlTable
}
from
'
@gitlab/ui
'
;
import
{
mount
}
from
'
@vue/test-utils
'
;
import
{
PAGE_CONFIG
}
from
'
~/vue_shared/alert_details/constants
'
;
import
AlertDetailsTable
from
'
~/vue_shared/components/alert_details_table.vue
'
;
const
mockAlert
=
{
...
...
@@ -76,54 +75,68 @@ describe('AlertDetails', () => {
});
describe
(
'
with table data
'
,
()
=>
{
beforeEach
(
mountComponent
);
it
(
'
renders a table
'
,
()
=>
{
expect
(
findTableComponent
().
exists
()).
toBe
(
true
);
});
it
(
'
renders a cell based on alert data
'
,
()
=>
{
expect
(
findTableComponent
().
text
()).
toContain
(
'
SyntaxError: Invalid or unexpected token
'
);
});
it
(
'
should show allowed alert fields
'
,
()
=>
{
const
fields
=
findTableKeys
();
expect
(
findTableField
(
fields
,
'
Iid
'
).
exists
()).
toBe
(
true
);
expect
(
findTableField
(
fields
,
'
Title
'
).
exists
()).
toBe
(
true
);
expect
(
findTableField
(
fields
,
'
Severity
'
).
exists
()).
toBe
(
true
);
expect
(
findTableField
(
fields
,
'
Status
'
).
exists
()).
toBe
(
true
);
expect
(
findTableField
(
fields
,
'
Hosts
'
).
exists
()).
toBe
(
true
);
expect
(
findTableField
(
fields
,
'
Environment
'
).
exists
()).
toBe
(
true
);
describe
(
'
default
'
,
()
=>
{
beforeEach
(
mountComponent
);
it
(
'
renders a table
'
,
()
=>
{
expect
(
findTableComponent
().
exists
()).
toBe
(
true
);
});
it
(
'
renders a cell based on alert data
'
,
()
=>
{
expect
(
findTableComponent
().
text
()).
toContain
(
'
SyntaxError: Invalid or unexpected token
'
);
});
it
(
'
should show allowed alert fields
'
,
()
=>
{
const
fields
=
findTableKeys
();
expect
(
findTableField
(
fields
,
'
Iid
'
).
exists
()).
toBe
(
true
);
expect
(
findTableField
(
fields
,
'
Title
'
).
exists
()).
toBe
(
true
);
expect
(
findTableField
(
fields
,
'
Severity
'
).
exists
()).
toBe
(
true
);
expect
(
findTableField
(
fields
,
'
Status
'
).
exists
()).
toBe
(
true
);
expect
(
findTableField
(
fields
,
'
Hosts
'
).
exists
()).
toBe
(
true
);
expect
(
findTableField
(
fields
,
'
Environment
'
).
exists
()).
toBe
(
true
);
});
it
(
'
should not show disallowed alert fields
'
,
()
=>
{
const
fields
=
findTableKeys
();
expect
(
findTableField
(
fields
,
'
Typename
'
).
exists
()).
toBe
(
false
);
expect
(
findTableField
(
fields
,
'
Todos
'
).
exists
()).
toBe
(
false
);
expect
(
findTableField
(
fields
,
'
Notes
'
).
exists
()).
toBe
(
false
);
expect
(
findTableField
(
fields
,
'
Assignees
'
).
exists
()).
toBe
(
false
);
});
});
it
(
'
should not show disallowed alert fields
'
,
()
=>
{
const
fields
=
findTableKeys
();
describe
(
'
environment
'
,
()
=>
{
it
(
'
should display only the name for the environment
'
,
()
=>
{
mountComponent
();
expect
(
findTableFieldValueByKey
(
'
Environment
'
).
text
()).
toBe
(
environmentName
);
});
expect
(
findTableField
(
fields
,
'
Typename
'
).
exists
()).
toBe
(
false
);
expect
(
findTableField
(
fields
,
'
Todos
'
).
exists
()).
toBe
(
false
);
expect
(
findTableField
(
fields
,
'
Notes
'
).
exists
()).
toBe
(
false
);
expect
(
findTableField
(
fields
,
'
Assignees
'
).
exists
()).
toBe
(
false
);
});
it
(
'
should display only the name for the environment
'
,
()
=>
{
expect
(
findTableFieldValueByKey
(
'
Environment
'
).
text
()).
toBe
(
environmentName
);
});
it
(
'
should not display the environment row if there is not data
'
,
()
=>
{
environmentData
=
{
name
:
null
,
path
:
null
};
mountComponent
();
expect
(
findTableFieldValueByKey
(
'
Environment
'
).
text
()).
toBeFalsy
();
});
it
(
'
should not display the environment row if there is not data
'
,
()
=>
{
environmentData
=
{
name
:
null
,
path
:
null
};
mountComponent
();
it
(
'
should show the provided status if statuses prop is not provided
'
,
()
=>
{
expect
(
findTableFieldValueByKey
(
'
Status
'
).
text
()).
toBe
(
'
TRIGGERED
'
);
expect
(
findTableFieldValueByKey
(
'
Environment
'
).
text
()).
toBeFalsy
();
}
);
});
it
(
'
should show the translated status if statuses prop is provided
'
,
()
=>
{
mountComponent
({
statuses
:
PAGE_CONFIG
.
OPERATIONS
.
STATUSES
});
expect
(
findTableFieldValueByKey
(
'
Status
'
).
text
()).
toBe
(
'
Triggered
'
);
describe
(
'
status
'
,
()
=>
{
it
(
'
should show the translated status for the default statuses
'
,
()
=>
{
mountComponent
();
expect
(
findTableFieldValueByKey
(
'
Status
'
).
text
()).
toBe
(
'
Triggered
'
);
});
it
(
'
should show the translated status for provided statuses
'
,
()
=>
{
const
translatedStatus
=
'
Test
'
;
mountComponent
({
statuses
:
{
TRIGGERED
:
translatedStatus
}
});
expect
(
findTableFieldValueByKey
(
'
Status
'
).
text
()).
toBe
(
translatedStatus
);
});
it
(
'
should show the provided status if value is not defined in statuses
'
,
()
=>
{
mountComponent
({
statuses
:
{}
});
expect
(
findTableFieldValueByKey
(
'
Status
'
).
text
()).
toBe
(
'
TRIGGERED
'
);
});
});
});
});
...
...
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