[CDX-492] Add _dt to recommendations module#479
Conversation
There was a problem hiding this comment.
Code Review
This PR adds the _dt (timestamp) query parameter to the recommendations module URL builder, consistent with how it is already implemented in search, autocomplete, browse, pia, agent, quizzes, and tracker modules. The change is minimal, correct, and well-tested.
Inline comments: 2 discussions added
Overall Assessment:
| expect(requestedUrlParams).to.have.property('s'); | ||
| expect(requestedUrlParams).to.have.property('c').to.equal(clientVersion); | ||
| expect(requestedUrlParams).to.have.property('item_id').to.equal(itemId); | ||
| expect(requestedUrlParams).to.have.property('_dt'); |
There was a problem hiding this comment.
Suggestion: The three new _dt assertions only verify that the parameter exists in the URL, but do not verify that it is a numeric timestamp (which is what Date.now() returns). Other test suites in the project also only do the existence check, so this is consistent — however, it means a regression where _dt is set to undefined or an empty string would still pass.
Consider asserting a reasonable value, e.g.:
expect(requestedUrlParams).to.have.property('_dt').to.match(/^\d+$/);This is a low-priority suggestion; staying consistent with the existing test pattern is also acceptable.
There was a problem hiding this comment.
Pull request overview
Adds a cache-busting timestamp query parameter (_dt) to the Recommendations module’s request URL, aligning it with other modules that already send _dt.
Changes:
- Append
_dt=Date.now()to recommendations request query params before serialization. - Extend recommendations module specs to assert
_dtis present in outgoing requests.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/modules/recommendations.js | Adds _dt to the recommendations request query params. |
| spec/src/modules/recommendations.js | Updates tests to expect _dt in recommendations request URLs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // eslint-disable-next-line no-underscore-dangle | ||
| queryParams._dt = Date.now(); |
No description provided.