mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 02:15:43 +03:00
Merge pull request #4124 from hashicorp/b-ui-nodes-before-addresses
UI: Defer showing alloc addresses until the node is loaded
This commit is contained in:
@@ -65,15 +65,23 @@
|
||||
<td data-test-ports>
|
||||
<ul>
|
||||
{{#each row.model.resources.networks.firstObject.reservedPorts as |port|}}
|
||||
<li>
|
||||
<li data-test-port>
|
||||
<strong>{{port.Label}}:</strong>
|
||||
<a href="http://{{row.model.allocation.node.address}}:{{port.Value}}" target="_blank">{{row.model.allocation.node.address}}:{{port.Value}}</a>
|
||||
{{#if row.model.allocation.node.address}}
|
||||
<a href="http://{{row.model.allocation.node.address}}:{{port.Value}}" target="_blank">{{row.model.allocation.node.address}}:{{port.Value}}</a>
|
||||
{{else}}
|
||||
...
|
||||
{{/if}}
|
||||
</li>
|
||||
{{/each}}
|
||||
{{#each row.model.resources.networks.firstObject.dynamicPorts as |port|}}
|
||||
<li>
|
||||
<strong>{{port.Label}}:</strong>
|
||||
<a href="http://{{row.model.allocation.node.address}}:{{port.Value}}" target="_blank">{{row.model.allocation.node.address}}:{{port.Value}}</a>
|
||||
{{#if row.model.allocation.node.address}}
|
||||
<a href="http://{{row.model.allocation.node.address}}:{{port.Value}}" target="_blank">{{row.model.allocation.node.address}}:{{port.Value}}</a>
|
||||
{{else}}
|
||||
...
|
||||
{{/if}}
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import $ from 'jquery';
|
||||
import { click, findAll, currentURL, find, visit } from 'ember-native-dom-helpers';
|
||||
import { click, findAll, currentURL, find, visit, waitFor } from 'ember-native-dom-helpers';
|
||||
import { test } from 'qunit';
|
||||
import moduleForAcceptance from 'nomad-ui/tests/helpers/module-for-acceptance';
|
||||
import moment from 'moment';
|
||||
@@ -139,3 +139,49 @@ test('when the allocation is not found, an error message is shown, but the URL p
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
moduleForAcceptance('Acceptance | allocation detail (loading states)', {
|
||||
beforeEach() {
|
||||
server.create('agent');
|
||||
|
||||
node = server.create('node');
|
||||
job = server.create('job', { groupCount: 0 });
|
||||
allocation = server.create('allocation', 'withTaskWithPorts');
|
||||
},
|
||||
});
|
||||
|
||||
test('when the node the allocation is on has yet to load, address links are in a loading state', function(assert) {
|
||||
server.get('/node/:id', { timing: true });
|
||||
|
||||
visit(`/allocations/${allocation.id}`);
|
||||
|
||||
waitFor('[data-test-port]').then(() => {
|
||||
assert.ok(
|
||||
find('[data-test-port]')
|
||||
.textContent.trim()
|
||||
.endsWith('...'),
|
||||
'The address is in a loading state'
|
||||
);
|
||||
assert.notOk(
|
||||
find('[data-test-port]').querySelector('a'),
|
||||
'While in the loading state, there is no link to the address'
|
||||
);
|
||||
|
||||
server.pretender.requestReferences.forEach(({ request }) => {
|
||||
server.pretender.resolve(request);
|
||||
});
|
||||
|
||||
andThen(() => {
|
||||
const taskResources = allocation.taskResourcesIds
|
||||
.map(id => server.db.taskResources.find(id))
|
||||
.sortBy('name')[0];
|
||||
const port = taskResources.resources.Networks[0].ReservedPorts[0];
|
||||
const addressText = find('[data-test-port]').textContent.trim();
|
||||
|
||||
assert.ok(addressText.includes(port.Label), `Found label ${port.Label}`);
|
||||
assert.ok(addressText.includes(port.Value), `Found value ${port.Value}`);
|
||||
assert.ok(addressText.includes(node.httpAddr.match(/(.+):.+$/)[1]), 'Found the node address');
|
||||
assert.ok(find('[data-test-port]').querySelector('a'), 'Link to address found');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user