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
6d727432
Commit
6d727432
authored
Mar 13, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EE port of mr-widget-deployment-styling
parent
9acc13f5
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
429 additions
and
127 deletions
+429
-127
app/assets/javascripts/vue_merge_request_widget/components/deployment.vue
...cripts/vue_merge_request_widget/components/deployment.vue
+145
-0
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_deployment.js
...e_merge_request_widget/components/mr_widget_deployment.js
+0
-113
app/assets/javascripts/vue_merge_request_widget/dependencies.js
...sets/javascripts/vue_merge_request_widget/dependencies.js
+1
-1
app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js
...javascripts/vue_merge_request_widget/mr_widget_options.js
+7
-5
app/assets/stylesheets/pages/merge_requests.scss
app/assets/stylesheets/pages/merge_requests.scss
+39
-0
ee/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js
...javascripts/vue_merge_request_widget/mr_widget_options.js
+5
-4
spec/javascripts/vue_mr_widget/components/deployment_spec.js
spec/javascripts/vue_mr_widget/components/deployment_spec.js
+162
-0
spec/javascripts/vue_mr_widget/ee_mr_widget_options_spec.js
spec/javascripts/vue_mr_widget/ee_mr_widget_options_spec.js
+36
-0
spec/javascripts/vue_mr_widget/mr_widget_options_spec.js
spec/javascripts/vue_mr_widget/mr_widget_options_spec.js
+34
-4
No files found.
app/assets/javascripts/vue_merge_request_widget/components/deployment.vue
0 → 100644
View file @
6d727432
<
script
>
import
timeagoMixin
from
'
../../vue_shared/mixins/timeago
'
;
import
tooltip
from
'
../../vue_shared/directives/tooltip
'
;
import
LoadingButton
from
'
../../vue_shared/components/loading_button.vue
'
;
import
{
visitUrl
}
from
'
../../lib/utils/url_utility
'
;
import
createFlash
from
'
../../flash
'
;
import
MemoryUsage
from
'
./memory_usage.vue
'
;
import
StatusIcon
from
'
./mr_widget_status_icon.vue
'
;
import
MRWidgetService
from
'
../services/mr_widget_service
'
;
export
default
{
name
:
'
Deployment
'
,
components
:
{
LoadingButton
,
MemoryUsage
,
StatusIcon
,
},
directives
:
{
tooltip
,
},
mixins
:
[
timeagoMixin
,
],
props
:
{
deployment
:
{
type
:
Object
,
required
:
true
,
},
},
data
()
{
return
{
isStopping
:
false
,
};
},
computed
:
{
deployTimeago
()
{
return
this
.
timeFormated
(
this
.
deployment
.
deployed_at
);
},
hasExternalUrls
()
{
return
!!
(
this
.
deployment
.
external_url
&&
this
.
deployment
.
external_url_formatted
);
},
hasDeploymentTime
()
{
return
!!
(
this
.
deployment
.
deployed_at
&&
this
.
deployment
.
deployed_at_formatted
);
},
hasDeploymentMeta
()
{
return
!!
(
this
.
deployment
.
url
&&
this
.
deployment
.
name
);
},
hasMetrics
()
{
return
!!
(
this
.
deployment
.
metrics_url
);
},
},
methods
:
{
stopEnvironment
()
{
const
msg
=
'
Are you sure you want to stop this environment?
'
;
const
isConfirmed
=
confirm
(
msg
);
// eslint-disable-line
if
(
isConfirmed
)
{
this
.
isStopping
=
true
;
MRWidgetService
.
stopEnvironment
(
this
.
deployment
.
stop_url
)
.
then
(
res
=>
res
.
data
)
.
then
((
data
)
=>
{
if
(
data
.
redirect_url
)
{
visitUrl
(
data
.
redirect_url
);
}
this
.
isStopping
=
false
;
})
.
catch
(()
=>
{
createFlash
(
'
Something went wrong while stopping this environment. Please try again.
'
);
this
.
isStopping
=
false
;
});
}
},
},
};
</
script
>
<
template
>
<div
class=
"mr-widget-heading deploy-heading"
>
<div
class=
"ci-widget media"
>
<div
class=
"ci-status-icon ci-status-icon-success"
>
<span
class=
"js-icon-link icon-link"
>
<status-icon
status=
"success"
/>
</span>
</div>
<div
class=
"media-body"
>
<div
class=
"deploy-body"
>
<template
v-if=
"hasDeploymentMeta"
>
<span>
Deployed to
</span>
<a
:href=
"deployment.url"
target=
"_blank"
rel=
"noopener noreferrer nofollow"
class=
"deploy-link js-deploy-meta"
>
{{
deployment
.
name
}}
</a>
</
template
>
<
template
v-if=
"hasExternalUrls"
>
<span>
on
</span>
<a
:href=
"deployment.external_url"
target=
"_blank"
rel=
"noopener noreferrer nofollow"
class=
"deploy-link js-deploy-url"
>
<i
class=
"fa fa-external-link"
aria-hidden=
"true"
>
</i>
{{
deployment
.
external_url_formatted
}}
</a>
</
template
>
<span
v-if=
"hasDeploymentTime"
:data-title=
"deployment.deployed_at_formatted"
class=
"js-deploy-time"
data-toggle=
"tooltip"
data-placement=
"top"
>
{{ deployTimeago }}
</span>
<loading-button
v-if=
"deployment.stop_url"
container-class=
"btn btn-default btn-xs"
label=
"Stop environment"
:loading=
"isStopping"
@
click=
"stopEnvironment"
/>
</div>
<memory-usage
v-if=
"hasMetrics"
:metrics-url=
"deployment.metrics_url"
:metrics-monitoring-url=
"deployment.metrics_monitoring_url"
/>
</div>
</div>
</div>
</template>
app/assets/javascripts/vue_merge_request_widget/components/mr_widget_deployment.js
deleted
100644 → 0
View file @
9acc13f5
import
{
getTimeago
}
from
'
~/lib/utils/datetime_utility
'
;
import
{
visitUrl
}
from
'
../../lib/utils/url_utility
'
;
import
Flash
from
'
../../flash
'
;
import
MemoryUsage
from
'
./memory_usage.vue
'
;
import
StatusIcon
from
'
./mr_widget_status_icon.vue
'
;
import
MRWidgetService
from
'
../services/mr_widget_service
'
;
export
default
{
name
:
'
MRWidgetDeployment
'
,
props
:
{
mr
:
{
type
:
Object
,
required
:
true
},
service
:
{
type
:
Object
,
required
:
true
},
},
components
:
{
MemoryUsage
,
StatusIcon
,
},
methods
:
{
formatDate
(
date
)
{
return
getTimeago
().
format
(
date
);
},
hasExternalUrls
(
deployment
=
{})
{
return
deployment
.
external_url
&&
deployment
.
external_url_formatted
;
},
hasDeploymentTime
(
deployment
=
{})
{
return
deployment
.
deployed_at
&&
deployment
.
deployed_at_formatted
;
},
hasDeploymentMeta
(
deployment
=
{})
{
return
deployment
.
url
&&
deployment
.
name
;
},
stopEnvironment
(
deployment
)
{
const
msg
=
'
Are you sure you want to stop this environment?
'
;
const
isConfirmed
=
confirm
(
msg
);
// eslint-disable-line
if
(
isConfirmed
)
{
MRWidgetService
.
stopEnvironment
(
deployment
.
stop_url
)
.
then
(
res
=>
res
.
data
)
.
then
((
data
)
=>
{
if
(
data
.
redirect_url
)
{
visitUrl
(
data
.
redirect_url
);
}
})
.
catch
(()
=>
{
new
Flash
(
'
Something went wrong while stopping this environment. Please try again.
'
);
// eslint-disable-line
});
}
},
},
template
:
`
<div class="mr-widget-heading deploy-heading">
<div v-for="deployment in mr.deployments">
<div class="ci-widget media">
<div class="ci-status-icon ci-status-icon-success">
<span class="js-icon-link icon-link">
<status-icon status="success" />
</span>
</div>
<div class="media-body space-children">
<span>
<span
v-if="hasDeploymentMeta(deployment)">
Deployed to
</span>
<a
v-if="hasDeploymentMeta(deployment)"
:href="deployment.url"
target="_blank"
rel="noopener noreferrer nofollow"
class="js-deploy-meta inline">
{{deployment.name}}
</a>
<span
v-if="hasExternalUrls(deployment)">
on
</span>
<a
v-if="hasExternalUrls(deployment)"
:href="deployment.external_url"
target="_blank"
rel="noopener noreferrer nofollow"
class="js-deploy-url inline">
<i
class="fa fa-external-link"
aria-hidden="true" />
{{deployment.external_url_formatted}}
</a>
<span
v-if="hasDeploymentTime(deployment)"
:data-title="deployment.deployed_at_formatted"
class="js-deploy-time"
data-toggle="tooltip"
data-placement="top">
{{formatDate(deployment.deployed_at)}}
</span>
</span>
<button
type="button"
v-if="deployment.stop_url"
@click="stopEnvironment(deployment)"
class="btn btn-default btn-xs">
Stop environment
</button>
<memory-usage
v-if="deployment.metrics_url"
:metrics-url="deployment.metrics_url"
:metrics-monitoring-url="deployment.metrics_monitoring_url"
/>
</div>
</div>
</div>
</div>
`
,
};
app/assets/javascripts/vue_merge_request_widget/dependencies.js
View file @
6d727432
...
...
@@ -14,7 +14,7 @@ export { default as SmartInterval } from '~/smart_interval';
export
{
default
as
WidgetHeader
}
from
'
./components/mr_widget_header.vue
'
;
export
{
default
as
WidgetMergeHelp
}
from
'
./components/mr_widget_merge_help.vue
'
;
export
{
default
as
WidgetPipeline
}
from
'
./components/mr_widget_pipeline.vue
'
;
export
{
default
as
WidgetDeployment
}
from
'
./components/mr_widget_deployment
'
;
export
{
default
as
Deployment
}
from
'
./components/deployment.vue
'
;
export
{
default
as
WidgetMaintainerEdit
}
from
'
./components/mr_widget_maintainer_edit.vue
'
;
export
{
default
as
WidgetRelatedLinks
}
from
'
./components/mr_widget_related_links.vue
'
;
export
{
default
as
MergedState
}
from
'
./components/states/mr_widget_merged.vue
'
;
...
...
app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js
View file @
6d727432
...
...
@@ -5,7 +5,7 @@ import {
WidgetHeader
,
WidgetMergeHelp
,
WidgetPipeline
,
Widget
Deployment
,
Deployment
,
WidgetMaintainerEdit
,
WidgetRelatedLinks
,
MergedState
,
...
...
@@ -217,7 +217,7 @@ export default {
'
mr-widget-header
'
:
WidgetHeader
,
'
mr-widget-merge-help
'
:
WidgetMergeHelp
,
'
mr-widget-pipeline
'
:
WidgetPipeline
,
'
mr-widget-deployment
'
:
Widget
Deployment
,
Deployment
,
'
mr-widget-maintainer-edit
'
:
WidgetMaintainerEdit
,
'
mr-widget-related-links
'
:
WidgetRelatedLinks
,
'
mr-widget-merged
'
:
MergedState
,
...
...
@@ -251,10 +251,12 @@ export default {
:ci-status="mr.ciStatus"
:has-ci="mr.hasCI"
/>
<
mr-widget-
deployment
<deployment
v-if="shouldRenderDeployments"
:mr="mr"
:service="service" />
v-for="deployment in mr.deployments"
:key="deployment.id"
:deployment="deployment"
/>
<div class="mr-widget-section">
<component
:is="componentName"
...
...
app/assets/stylesheets/pages/merge_requests.scss
View file @
6d727432
...
...
@@ -768,6 +768,8 @@
}
.mr-memory-usage
{
width
:
100%
;
p
.usage-info-loading
.usage-info-load-spinner
{
margin-right
:
10px
;
font-size
:
16px
;
...
...
@@ -783,3 +785,40 @@
font-size
:
22px
;
margin
:
0
10px
0
0
;
}
.deploy-heading
{
.media-body
{
min-width
:
0
;
}
}
.deploy-body
{
display
:
flex
;
flex-wrap
:
wrap
;
@media
(
min-width
:
$screen-xs
)
{
flex-wrap
:
nowrap
;
white-space
:
nowrap
;
}
>
*
:not
(
:last-child
)
{
margin-right
:
.3em
;
}
.btn
{
margin-left
:
$gl-padding
;
}
}
.deploy-link
{
white-space
:
nowrap
;
overflow
:
hidden
;
text-overflow
:
ellipsis
;
min-width
:
100px
;
max-width
:
150px
;
@media
(
min-width
:
$screen-xs
)
{
min-width
:
0
;
max-width
:
100%
;
}
}
ee/app/assets/javascripts/vue_merge_request_widget/mr_widget_options.js
View file @
6d727432
...
...
@@ -298,11 +298,12 @@ export default {
:ci-status="mr.ciStatus"
:has-ci="mr.hasCI"
/>
<
mr-widget-
deployment
<deployment
v-if="shouldRenderDeployments"
:mr="mr"
:service="service"
/>
v-for="deployment in mr.deployments"
:key="deployment.id"
:deployment="deployment"
/>
<mr-widget-approvals
v-if="shouldRenderApprovals"
:mr="mr"
...
...
spec/javascripts/vue_mr_widget/components/
mr_widget_
deployment_spec.js
→
spec/javascripts/vue_mr_widget/components/deployment_spec.js
View file @
6d727432
import
Vue
from
'
vue
'
;
import
*
as
urlUtils
from
'
~/lib/utils/url_utility
'
;
import
deploymentComponent
from
'
~/vue_merge_request_widget/components/
mr_widget_deployment
'
;
import
deploymentComponent
from
'
~/vue_merge_request_widget/components/
deployment.vue
'
;
import
MRWidgetService
from
'
~/vue_merge_request_widget/services/mr_widget_service
'
;
import
{
getTimeago
}
from
'
~/lib/utils/datetime_utility
'
;
const
deploymentMockData
=
[
{
id
:
15
,
name
:
'
review/diplo
'
,
url
:
'
/root/acets-review-apps/environments/15
'
,
stop_url
:
'
/root/acets-review-apps/environments/15/stop
'
,
metrics_url
:
'
/root/acets-review-apps/environments/15/deployments/1/metrics
'
,
metrics_monitoring_url
:
'
/root/acets-review-apps/environments/15/metrics
'
,
external_url
:
'
http://diplo.
'
,
external_url_formatted
:
'
diplo.
'
,
deployed_at
:
'
2017-03-22T22:44:42.258Z
'
,
deployed_at_formatted
:
'
Mar 22, 2017 10:44pm
'
,
},
];
const
deploymentMockData
=
{
id
:
15
,
name
:
'
review/diplo
'
,
url
:
'
/root/acets-review-apps/environments/15
'
,
stop_url
:
'
/root/acets-review-apps/environments/15/stop
'
,
metrics_url
:
'
/root/acets-review-apps/environments/15/deployments/1/metrics
'
,
metrics_monitoring_url
:
'
/root/acets-review-apps/environments/15/metrics
'
,
external_url
:
'
http://diplo.
'
,
external_url_formatted
:
'
diplo.
'
,
deployed_at
:
'
2017-03-22T22:44:42.258Z
'
,
deployed_at_formatted
:
'
Mar 22, 2017 10:44pm
'
,
};
const
createComponent
=
()
=>
{
const
Component
=
Vue
.
extend
(
deploymentComponent
);
const
mr
=
{
deployments
:
deploymentMockData
,
};
const
service
=
{};
return
new
Component
({
el
:
document
.
createElement
(
'
div
'
),
propsData
:
{
mr
,
service
},
propsData
:
{
deployment
:
{
...
deploymentMockData
}
},
});
};
describe
(
'
MRWidgetDeployment
'
,
()
=>
{
describe
(
'
props
'
,
()
=>
{
it
(
'
should have props
'
,
()
=>
{
const
{
mr
,
service
}
=
deploymentComponent
.
props
;
expect
(
mr
.
type
instanceof
Object
).
toBeTruthy
();
expect
(
mr
.
required
).
toBeTruthy
();
describe
(
'
Deployment component
'
,
()
=>
{
let
vm
;
expect
(
service
.
type
instanceof
Object
).
toBeTruthy
();
expect
(
service
.
required
).
toBeTruthy
();
});
beforeEach
(()
=>
{
vm
=
createComponent
();
});
describe
(
'
methods
'
,
()
=>
{
let
vm
=
createComponent
();
const
deployment
=
deploymentMockData
[
0
]
;
afterEach
(
()
=>
{
vm
.
$destroy
();
})
;
describe
(
'
formatDate
'
,
()
=>
{
it
(
'
should work
'
,
()
=>
{
const
readable
=
getTimeago
().
format
(
deployment
.
deployed_at
);
expect
(
vm
.
formatDate
(
deployment
.
deployed_at
)).
toEqual
(
readable
);
describe
(
'
computed
'
,
()
=>
{
describe
(
'
deployTimeago
'
,
()
=>
{
it
(
'
return formatted date
'
,
()
=>
{
const
readable
=
getTimeago
().
format
(
deploymentMockData
.
deployed_at
);
expect
(
vm
.
deployTimeago
).
toEqual
(
readable
);
});
});
describe
(
'
hasExternalUrls
'
,
()
=>
{
it
(
'
should return true
'
,
()
=>
{
expect
(
vm
.
hasExternalUrls
(
deployment
)).
toBeTruthy
();
expect
(
vm
.
hasExternalUrls
).
toEqual
(
true
);
});
it
(
'
should return false when deployment has no external_url_formatted
'
,
()
=>
{
vm
.
deployment
.
external_url_formatted
=
null
;
expect
(
vm
.
hasExternalUrls
).
toEqual
(
false
);
});
it
(
'
should return false when
there is not enough information
'
,
()
=>
{
expect
(
vm
.
hasExternalUrls
()).
toBeFalsy
()
;
expect
(
vm
.
hasExternalUrls
({
external_url
:
'
Diplo
'
})).
toBeFalsy
();
expect
(
vm
.
hasExternalUrls
({
external_url_formatted
:
'
Diplo
'
})).
toBeFalsy
(
);
it
(
'
should return false when
deployment has no external_url
'
,
()
=>
{
vm
.
deployment
.
external_url
=
null
;
expect
(
vm
.
hasExternalUrls
).
toEqual
(
false
);
});
});
describe
(
'
hasDeploymentTime
'
,
()
=>
{
it
(
'
should return true
'
,
()
=>
{
expect
(
vm
.
hasDeploymentTime
(
deployment
)).
toBeTruthy
(
);
expect
(
vm
.
hasDeploymentTime
).
toEqual
(
true
);
});
it
(
'
should return false when there is not enough information
'
,
()
=>
{
expect
(
vm
.
hasDeploymentTime
()).
toBeFalsy
();
expect
(
vm
.
hasDeploymentTime
({
deployed_at
:
'
Diplo
'
})).
toBeFalsy
();
expect
(
vm
.
hasDeploymentTime
({
deployed_at_formatted
:
'
Diplo
'
})).
toBeFalsy
();
it
(
'
should return false when deployment has no deployed_at
'
,
()
=>
{
vm
.
deployment
.
deployed_at
=
null
;
expect
(
vm
.
hasDeploymentTime
).
toEqual
(
false
);
});
it
(
'
should return false when deployment has no deployed_at_formatted
'
,
()
=>
{
vm
.
deployment
.
deployed_at_formatted
=
null
;
expect
(
vm
.
hasDeploymentTime
).
toEqual
(
false
);
});
});
describe
(
'
hasDeploymentMeta
'
,
()
=>
{
it
(
'
should return true
'
,
()
=>
{
expect
(
vm
.
hasDeploymentMeta
(
deployment
)).
toBeTruthy
(
);
expect
(
vm
.
hasDeploymentMeta
).
toEqual
(
true
);
});
it
(
'
should return false when there is not enough information
'
,
()
=>
{
expect
(
vm
.
hasDeploymentMeta
()).
toBeFalsy
();
expect
(
vm
.
hasDeploymentMeta
({
url
:
'
Diplo
'
})).
toBeFalsy
();
expect
(
vm
.
hasDeploymentMeta
({
name
:
'
Diplo
'
})).
toBeFalsy
();
it
(
'
should return false when deployment has no url
'
,
()
=>
{
vm
.
deployment
.
url
=
null
;
expect
(
vm
.
hasDeploymentMeta
).
toEqual
(
false
);
});
it
(
'
should return false when deployment has no name
'
,
()
=>
{
vm
.
deployment
.
name
=
null
;
expect
(
vm
.
hasDeploymentMeta
).
toEqual
(
false
);
});
});
});
describe
(
'
methods
'
,
()
=>
{
describe
(
'
stopEnvironment
'
,
()
=>
{
const
url
=
'
/foo/bar
'
;
const
returnPromise
=
()
=>
new
Promise
((
resolve
)
=>
{
...
...
@@ -131,9 +140,7 @@ describe('MRWidgetDeployment', () => {
});
describe
(
'
template
'
,
()
=>
{
let
vm
;
let
el
;
const
[
deployment
]
=
deploymentMockData
;
beforeEach
(()
=>
{
vm
=
createComponent
(
deploymentMockData
);
...
...
@@ -141,39 +148,15 @@ describe('MRWidgetDeployment', () => {
});
it
(
'
should render template elements correctly
'
,
()
=>
{
expect
(
el
.
classList
.
contains
(
'
mr-widget-heading
'
)).
toBeTruthy
();
expect
(
el
.
querySelector
(
'
.js-icon-link
'
)).
toBeDefined
();
expect
(
el
.
querySelector
(
'
.js-deploy-meta
'
).
getAttribute
(
'
href
'
)).
toEqual
(
deployment
.
url
);
expect
(
el
.
querySelector
(
'
.js-deploy-meta
'
).
innerText
).
toContain
(
deployment
.
name
);
expect
(
el
.
querySelector
(
'
.js-deploy-url
'
).
getAttribute
(
'
href
'
)).
toEqual
(
deployment
.
external_url
);
expect
(
el
.
querySelector
(
'
.js-deploy-url
'
).
innerText
).
toContain
(
deployment
.
external_url_formatted
);
expect
(
el
.
querySelector
(
'
.js-deploy-time
'
).
innerText
).
toContain
(
vm
.
formatDate
(
deployment
.
deployed_at
));
expect
(
el
.
querySelector
(
'
.js-mr-memory-usage
'
)).
toBeDefined
();
expect
(
el
.
querySelector
(
'
button
'
)).
toBeDefined
();
});
it
(
'
should list multiple deployments
'
,
(
done
)
=>
{
vm
.
mr
.
deployments
.
push
(
deployment
);
vm
.
mr
.
deployments
.
push
(
deployment
);
Vue
.
nextTick
(()
=>
{
expect
(
el
.
querySelectorAll
(
'
.ci-widget
'
).
length
).
toEqual
(
3
);
expect
(
el
.
querySelectorAll
(
'
.js-mr-memory-usage
'
).
length
).
toEqual
(
3
);
done
();
});
});
it
(
'
should not have some elements when there is not enough data
'
,
(
done
)
=>
{
vm
.
mr
.
deployments
=
[{}];
Vue
.
nextTick
(()
=>
{
expect
(
el
.
querySelectorAll
(
'
.js-deploy-meta
'
).
length
).
toEqual
(
0
);
expect
(
el
.
querySelectorAll
(
'
.js-deploy-url
'
).
length
).
toEqual
(
0
);
expect
(
el
.
querySelectorAll
(
'
.js-deploy-time
'
).
length
).
toEqual
(
0
);
expect
(
el
.
querySelectorAll
(
'
.js-mr-memory-usage
'
).
length
).
toEqual
(
0
);
expect
(
el
.
querySelectorAll
(
'
.button
'
).
length
).
toEqual
(
0
);
done
();
});
expect
(
el
.
classList
.
contains
(
'
mr-widget-heading
'
)).
toEqual
(
true
);
expect
(
el
.
querySelector
(
'
.js-icon-link
'
)).
not
.
toBeNull
();
expect
(
el
.
querySelector
(
'
.js-deploy-meta
'
).
getAttribute
(
'
href
'
)).
toEqual
(
deploymentMockData
.
url
);
expect
(
el
.
querySelector
(
'
.js-deploy-meta
'
).
innerText
).
toContain
(
deploymentMockData
.
name
);
expect
(
el
.
querySelector
(
'
.js-deploy-url
'
).
getAttribute
(
'
href
'
)).
toEqual
(
deploymentMockData
.
external_url
);
expect
(
el
.
querySelector
(
'
.js-deploy-url
'
).
innerText
).
toContain
(
deploymentMockData
.
external_url_formatted
);
expect
(
el
.
querySelector
(
'
.js-deploy-time
'
).
innerText
).
toContain
(
vm
.
deployTimeago
);
expect
(
el
.
querySelector
(
'
.js-mr-memory-usage
'
)).
not
.
toBeNull
();
expect
(
el
.
querySelector
(
'
button
'
)).
not
.
toBeNull
();
});
});
});
spec/javascripts/vue_mr_widget/ee_mr_widget_options_spec.js
View file @
6d727432
...
...
@@ -821,4 +821,40 @@ describe('ee merge request widget options', () => {
});
});
});
describe
(
'
rendering deployments
'
,
()
=>
{
const
deploymentMockData
=
{
id
:
15
,
name
:
'
review/diplo
'
,
url
:
'
/root/acets-review-apps/environments/15
'
,
stop_url
:
'
/root/acets-review-apps/environments/15/stop
'
,
metrics_url
:
'
/root/acets-review-apps/environments/15/deployments/1/metrics
'
,
metrics_monitoring_url
:
'
/root/acets-review-apps/environments/15/metrics
'
,
external_url
:
'
http://diplo.
'
,
external_url_formatted
:
'
diplo.
'
,
deployed_at
:
'
2017-03-22T22:44:42.258Z
'
,
deployed_at_formatted
:
'
Mar 22, 2017 10:44pm
'
,
};
beforeEach
((
done
)
=>
{
vm
=
mountComponent
(
Component
,
{
mrData
:
{
...
mockData
,
},
});
vm
.
mr
.
deployments
.
push
({
...
deploymentMockData
,
},
{
...
deploymentMockData
,
id
:
deploymentMockData
.
id
+
1
,
});
vm
.
$nextTick
(
done
);
});
it
(
'
renders multiple deployments
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelectorAll
(
'
.deploy-heading
'
).
length
).
toBe
(
2
);
});
});
});
spec/javascripts/vue_mr_widget/mr_widget_options_spec.js
View file @
6d727432
...
...
@@ -189,16 +189,16 @@ describe('mrWidgetOptions', () => {
describe
(
'
fetchDeployments
'
,
()
=>
{
it
(
'
should fetch deployments
'
,
(
done
)
=>
{
spyOn
(
vm
.
service
,
'
fetchDeployments
'
).
and
.
returnValue
(
returnPromise
([{
deployment
:
1
}]));
spyOn
(
vm
.
service
,
'
fetchDeployments
'
).
and
.
returnValue
(
returnPromise
([{
id
:
1
}]));
vm
.
fetchDeployments
();
setTimeout
(()
=>
{
expect
(
vm
.
service
.
fetchDeployments
).
toHaveBeenCalled
();
expect
(
vm
.
mr
.
deployments
.
length
).
toEqual
(
1
);
expect
(
vm
.
mr
.
deployments
[
0
].
deployment
).
toEqual
(
1
);
expect
(
vm
.
mr
.
deployments
[
0
].
id
).
toBe
(
1
);
done
();
}
,
333
);
});
});
});
...
...
@@ -374,7 +374,7 @@ describe('mrWidgetOptions', () => {
expect
(
comps
[
'
mr-widget-header
'
]).
toBeDefined
();
expect
(
comps
[
'
mr-widget-merge-help
'
]).
toBeDefined
();
expect
(
comps
[
'
mr-widget-pipeline
'
]).
toBeDefined
();
expect
(
comps
[
'
mr-widget-deployment
'
]
).
toBeDefined
();
expect
(
comps
.
Deployment
).
toBeDefined
();
expect
(
comps
[
'
mr-widget-related-links
'
]).
toBeDefined
();
expect
(
comps
[
'
mr-widget-merged
'
]).
toBeDefined
();
expect
(
comps
[
'
mr-widget-closed
'
]).
toBeDefined
();
...
...
@@ -454,4 +454,34 @@ describe('mrWidgetOptions', () => {
});
});
});
describe
(
'
rendering deployments
'
,
()
=>
{
const
deploymentMockData
=
{
id
:
15
,
name
:
'
review/diplo
'
,
url
:
'
/root/acets-review-apps/environments/15
'
,
stop_url
:
'
/root/acets-review-apps/environments/15/stop
'
,
metrics_url
:
'
/root/acets-review-apps/environments/15/deployments/1/metrics
'
,
metrics_monitoring_url
:
'
/root/acets-review-apps/environments/15/metrics
'
,
external_url
:
'
http://diplo.
'
,
external_url_formatted
:
'
diplo.
'
,
deployed_at
:
'
2017-03-22T22:44:42.258Z
'
,
deployed_at_formatted
:
'
Mar 22, 2017 10:44pm
'
,
};
beforeEach
((
done
)
=>
{
vm
.
mr
.
deployments
.
push
({
...
deploymentMockData
,
},
{
...
deploymentMockData
,
id
:
deploymentMockData
.
id
+
1
,
});
vm
.
$nextTick
(
done
);
});
it
(
'
renders multiple deployments
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelectorAll
(
'
.deploy-heading
'
).
length
).
toBe
(
2
);
});
});
});
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