From 6cedb25e58fa8760075f243baffcc69929415bce Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Thu, 15 Oct 2026 15:14:28 +0800 Subject: [PATCH] fix(widget): request proof-of-delivery photos from int/v1/proofs/recent The recent-proofs route is registered as a fleetbaseRoutes('proofs') resource in the main internal v1 group, not under the fleet-ops prefix, so the widget's fleet-ops/proofs/recent request 404'd and the tile always showed its empty state. The unit test now records the full URL (namespace + path + query) the fetch service would request and asserts GET int/v1/proofs/recent?limit=12. Co-Authored-By: Claude --- addon/components/widget/proof-of-delivery.js | 2 +- .../unit/components/widget/proof-of-delivery-test.js | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/addon/components/widget/proof-of-delivery.js b/addon/components/widget/proof-of-delivery.js index 1d68d2f6d..900800caf 100644 --- a/addon/components/widget/proof-of-delivery.js +++ b/addon/components/widget/proof-of-delivery.js @@ -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'; diff --git a/tests/unit/components/widget/proof-of-delivery-test.js b/tests/unit/components/widget/proof-of-delivery-test.js index 6161a7f69..094eabbdc 100644 --- a/tests/unit/components/widget/proof-of-delivery-test.js +++ b/tests/unit/components/widget/proof-of-delivery-test.js @@ -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; } @@ -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); });