diff --git a/ui/tests/acceptance/job-allocations-test.js b/ui/tests/acceptance/job-allocations-test.js index 837cb692cb1f..ddb791264628 100644 --- a/ui/tests/acceptance/job-allocations-test.js +++ b/ui/tests/acceptance/job-allocations-test.js @@ -4,7 +4,7 @@ */ /* eslint-disable qunit/require-expect */ -import { currentURL } from '@ember/test-helpers'; +import { currentURL, click, find } from '@ember/test-helpers'; import { module, test } from 'qunit'; import { setupApplicationTest } from 'ember-qunit'; import { setupMirage } from 'ember-cli-mirage/test-support'; @@ -77,6 +77,33 @@ module('Acceptance | job allocations', function (hooks) { assert.equal(document.title, `Job ${job.name} allocations - Nomad`); }); + test('clicking an allocation results in the correct endpoint being hit', async function (assert) { + server.createList('allocation', Allocations.pageSize - 1, { + shallow: true, + }); + allocations = server.schema.allocations.where({ jobId: job.id }).models; + + await Allocations.visit({ id: job.id }); + + const firstAllocation = find('[data-test-allocation]'); + await click(firstAllocation); + + const requestToAllocationEndpoint = server.pretender.handledRequests.find( + (request) => + request.url.includes( + `/v1/allocation/${firstAllocation.dataset.testAllocation}` + ) + ); + + assert.ok(requestToAllocationEndpoint, 'the correct endpoint is hit'); + + assert.equal( + currentURL(), + `/allocations/${firstAllocation.dataset.testAllocation}`, + 'the URL is correct' + ); + }); + test('allocations table is sortable', async function (assert) { server.createList('allocation', Allocations.pageSize - 1); allocations = server.schema.allocations.where({ jobId: job.id }).models;