-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UI: Remodel task-group-deployment-summary to properly use PlacedCanaries #4325
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import ApplicationSerializer from './application'; | ||
|
||
export default ApplicationSerializer.extend({ | ||
normalize(typeHash, hash) { | ||
hash.PlacedCanaryAllocations = hash.PlacedCanaries || []; | ||
delete hash.PlacedCanaries; | ||
return this._super(typeHash, hash); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,8 @@ import { test } from 'qunit'; | |
import moment from 'moment'; | ||
import moduleForAcceptance from 'nomad-ui/tests/helpers/module-for-acceptance'; | ||
|
||
const sum = (list, key) => list.reduce((sum, item) => sum + get(item, key), 0); | ||
const sum = (list, key, getter = a => a) => | ||
list.reduce((sum, item) => sum + getter(get(item, key)), 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice helper! |
||
|
||
let job; | ||
let deployments; | ||
|
@@ -40,9 +41,7 @@ test('/jobs/:id/deployments should list all job deployments', function(assert) { | |
}); | ||
}); | ||
|
||
test('each deployment mentions the deployment shortId, status, version, and time since it was submitted', function( | ||
assert | ||
) { | ||
test('each deployment mentions the deployment shortId, status, version, and time since it was submitted', function(assert) { | ||
visit(`/jobs/${job.id}/deployments`); | ||
|
||
andThen(() => { | ||
|
@@ -82,9 +81,7 @@ test('each deployment mentions the deployment shortId, status, version, and time | |
}); | ||
}); | ||
|
||
test('when the deployment is running and needs promotion, the deployment item says so', function( | ||
assert | ||
) { | ||
test('when the deployment is running and needs promotion, the deployment item says so', function(assert) { | ||
// Ensure the deployment needs deployment | ||
const deployment = sortedDeployments.models[0]; | ||
const taskGroupSummary = deployment.deploymentTaskGroupSummaryIds.map(id => | ||
|
@@ -96,7 +93,7 @@ test('when the deployment is running and needs promotion, the deployment item sa | |
|
||
taskGroupSummary.update({ | ||
desiredCanaries: 1, | ||
placedCanaries: 0, | ||
placedCanaries: [], | ||
promoted: false, | ||
}); | ||
|
||
|
@@ -152,7 +149,7 @@ test('when open, a deployment shows the deployment metrics', function(assert) { | |
andThen(() => { | ||
assert.equal( | ||
find('[data-test-deployment-metric="canaries"]').textContent.trim(), | ||
`${sum(taskGroupSummaries, 'placedCanaries')} / ${sum( | ||
`${sum(taskGroupSummaries, 'placedCanaries', a => a.length)} / ${sum( | ||
taskGroupSummaries, | ||
'desiredCanaries' | ||
)}`, | ||
|
@@ -192,9 +189,7 @@ test('when open, a deployment shows the deployment metrics', function(assert) { | |
}); | ||
}); | ||
|
||
test('when open, a deployment shows a list of all task groups and their respective stats', function( | ||
assert | ||
) { | ||
test('when open, a deployment shows a list of all task groups and their respective stats', function(assert) { | ||
visit(`/jobs/${job.id}/deployments`); | ||
|
||
andThen(() => { | ||
|
@@ -241,7 +236,7 @@ test('when open, a deployment shows a list of all task groups and their respecti | |
); | ||
assert.equal( | ||
taskGroupRow.querySelector('[data-test-deployment-task-group-canaries]').textContent.trim(), | ||
`${taskGroup.placedCanaries} / ${taskGroup.desiredCanaries}`, | ||
`${taskGroup.placedCanaries.length} / ${taskGroup.desiredCanaries}`, | ||
'Canaries' | ||
); | ||
assert.equal( | ||
|
@@ -265,9 +260,7 @@ test('when open, a deployment shows a list of all task groups and their respecti | |
}); | ||
}); | ||
|
||
test('when open, a deployment shows a list of all allocations for the deployment', function( | ||
assert | ||
) { | ||
test('when open, a deployment shows a list of all allocations for the deployment', function(assert) { | ||
visit(`/jobs/${job.id}/deployments`); | ||
|
||
andThen(() => { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need this if you are setting the defaultValue above? (or vice versa)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defaultValue
isn't invoked when the value isnull
(as opposed toundefined
), so this is needed. I suppose thedefaultValue
in the model isn't strictly necessary, but I like that it kinda doubles as a type annotation.