Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addon/components/widget/proof-of-delivery.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default class WidgetProofOfDeliveryComponent extends Component {
@task({ restartable: true }) *load() {
this.error = null;
try {
const response = yield this.fetch.get('fleet-ops/proofs/recent', { limit: WidgetProofOfDeliveryComponent.limit });
const response = yield this.fetch.get('proofs/recent', { limit: WidgetProofOfDeliveryComponent.limit });
this.proofs = response?.proofs ?? [];
} catch (err) {
this.error = err?.message ?? 'Failed to load';
Expand Down
12 changes: 9 additions & 3 deletions tests/unit/components/widget/proof-of-delivery-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ import { settled } from '@ember/test-helpers';
import { setupTest } from 'dummy/tests/helpers';
import WidgetProofOfDeliveryComponent from 'dummy/components/widget/proof-of-delivery';

// Records the URL the fetch service would request: the namespace option (the console's
// default is `int/v1`) joined to the path, plus the query string. Recording the bare
// path hid that `fleet-ops/proofs/recent` resolves to a URL the API does not route.
class FetchStub extends Service {
requests = [];
response = Promise.resolve({ proofs: [] });

get(path, query) {
this.requests.push([path, query]);
get(path, query = {}, options = {}) {
const params = new URLSearchParams(query).toString();
this.requests.push(`GET ${options.namespace ?? 'int/v1'}/${path}${params ? `?${params}` : ''}`);

return this.response;
}
Expand Down Expand Up @@ -44,7 +48,9 @@ module('Unit | Component | widget/proof-of-delivery', function (hooks) {

const component = await this.makeWidget();

assert.deepEqual(this.fetch.requests, [['fleet-ops/proofs/recent', { limit: 12 }]]);
// `GET int/v1/proofs/recent` is the `proofs` resource route in server/src/routes.php;
// it is not under the `fleet-ops` prefix group.
assert.deepEqual(this.fetch.requests, ['GET int/v1/proofs/recent?limit=12']);
assert.deepEqual(component.proofs, proofs);
assert.strictEqual(component.error, null);
});
Expand Down
Loading