-
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: Always add the active region as a query param to API requests #8477
Merged
DingoEatingFuzz
merged 7 commits into
master
from
b-ui/cross-region-alloc-lifecycle-buttons
Jul 21, 2020
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6bfebe2
Refactor job adapter test to simplify setting up region and namespace…
DingoEatingFuzz 23b024e
Always send region as a query param
DingoEatingFuzz 08bd435
Test region query param for job adapter actions
DingoEatingFuzz 4e152a7
Test all allocation adapter actions with and without a region
DingoEatingFuzz 4afedbd
Add region coverage to node adapter action tests
DingoEatingFuzz 9882614
Test coverage for the deployment adapter action
DingoEatingFuzz 544d941
Changelog entry for the region qp bug fix
DingoEatingFuzz 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
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,68 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
import { startMirage } from 'nomad-ui/initializers/ember-cli-mirage'; | ||
|
||
module('Unit | Adapter | Deployment', function(hooks) { | ||
setupTest(hooks); | ||
|
||
hooks.beforeEach(async function() { | ||
this.store = this.owner.lookup('service:store'); | ||
this.system = this.owner.lookup('service:system'); | ||
this.subject = () => this.store.adapterFor('deployment'); | ||
|
||
window.localStorage.clear(); | ||
|
||
this.server = startMirage(); | ||
|
||
this.initialize = async ({ region } = {}) => { | ||
if (region) window.localStorage.nomadActiveRegion = region; | ||
|
||
this.server.create('region', { id: 'region-1' }); | ||
this.server.create('region', { id: 'region-2' }); | ||
|
||
this.server.create('node'); | ||
const job = this.server.create('job', { createAllocations: false }); | ||
const deploymentRecord = server.schema.deployments.where({ jobId: job.id }).models[0]; | ||
|
||
this.system.get('shouldIncludeRegion'); | ||
await this.system.get('defaultRegion'); | ||
|
||
const deployment = await this.store.findRecord('deployment', deploymentRecord.id); | ||
this.server.pretender.handledRequests.length = 0; | ||
|
||
return deployment; | ||
}; | ||
}); | ||
|
||
hooks.afterEach(function() { | ||
this.server.shutdown(); | ||
}); | ||
|
||
const testCases = [ | ||
{ | ||
variation: '', | ||
region: null, | ||
promote: id => `POST /v1/deployment/promote/${id}`, | ||
}, | ||
{ | ||
variation: 'with non-default region', | ||
region: 'region-2', | ||
promote: id => `POST /v1/deployment/promote/${id}?region=region-2`, | ||
}, | ||
]; | ||
|
||
testCases.forEach(testCase => { | ||
test(`promote makes the correct API call ${testCase.variation}`, async function(assert) { | ||
const deployment = await this.initialize({ region: testCase.region }); | ||
await this.subject().promote(deployment); | ||
|
||
const request = this.server.pretender.handledRequests[0]; | ||
|
||
assert.equal(`${request.method} ${request.url}`, testCase.promote(deployment.id)); | ||
assert.deepEqual(JSON.parse(request.requestBody), { | ||
DeploymentId: deployment.id, | ||
All: true, | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.
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.
A nice clean intervention! 😍