fix: [sc-105230] particle-api-js getEventStream does not honor setContext / X-Particle-Tool http header correctly#147
Conversation
…e-Project http headers
get set as we'd expect when using setContext('tool') or setContext('project')
Specifically, this change makes this linter error go away:
/Users/me/git/particle-api-js/test/Particle.spec.js:941:78: Parsing error: Unexpected token => [Error]`
This makes it so that PARTICLE_API_TOKEN and PARTICLE_API_BASE_URL don't have to be specified for `npm run test:unit` and other npm run commands
586d595 to
fbf6100
Compare
| The `Agent` integration tests ([source](./test/Agent.integration.js)) depend on a real HTTP api backend and a valid Particle access token. Be sure to set relevant environment variables to avoid test failures. You can prefix commands test commands like this `PARTICLE_API_BASE_URL=<url> PARTICLE_API_TOKEN=<token> npm test` | ||
|
|
There was a problem hiding this comment.
Also, eliminates problem where PARTICLE_API_TOKEN had to be specified for many npm run commands by moving *.js files that require these to an e2e-tests that does NOT run in CI. This is not a step down in terms of quality; as these tests were not designed to be run in this CI context, but rather manually by developers working on the event stream.
fwiw, @deleonn updated CI over in #142 to ensure at least the node-side event e2e tests ran with their required perquisites - here's an example of them running and "passing":
further complicating things, the reference to "Agent integration tests" in these docs is incorrect - it's actually the test/EventStream-e2e-node.js file which is running in CI.
all that said, at this point i'd just delete all of those (e2e-tests directory and related) as they're likely to cause more confusion than help.
|
Cool. I'll remove circle ci vars, nuke |

Description
Fixes bug sc-105230 by passing
X-Particle-ToolorX-Particle-Projecthttp headers accordingly to event stream http requests that honorparticleAPI.setContext('tool|project'). This work makes it so that Delorean CLI telemetry will be accurate when event stream consuming commands are introduced.Also, eliminates problem where PARTICLE_API_TOKEN had to be specified for many
npm runcommands by moving*.jsfiles that require these to an e2e-tests that does NOT run in CI. This is not a step down in terms of quality; as these tests were not designed to be run in this CI context, but rather manually by developers working on the event stream.How to test?
Get the branch setup: git checkout, cd into repo, nvm use,
npm i👍npm run compilenpm run test:ci; observe no failures due to PARTICLE_API_TOKEN not being setfoo.jssnippet in the parent dir where your git checkout isnode foo.js_headershasyoyo@6.6.6in it (thus proving http headers are now honored)