Run a browser test with the chat API on a different origin than the page
I maintainer di solito rispondono entro 1 giorno
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
In the browser tests the page and the mock chat API are on the same origin (e2e/fixtures/index.html, line 14, uses data-api-url="/api/chat"), so the browser never sends a CORS preflight. Real sites are almost always cross-origin: the page is on acme.com and the chat server is on api.acme.com or a Vercel URL. If the widget ever adds a request header that older servers don't allow, those sites break and our tests stay green. The next release changes the request format, so I want this test in place first.
What to do
- Make
e2e/server.mjslisten on a second port (E2E_API_PORT, default 4174) that serves onlyPOST /api/chatandOPTIONS /api/chat, using the same mock replies as now. - On that port, answer
OPTIONSexactly like a 0.5 server does:204,Access-Control-Allow-Origin: *,Access-Control-Allow-Methods: POST, OPTIONS,Access-Control-Allow-Headers: Content-Type. PutAccess-Control-Allow-Origin: *on thePOSTreplies too. - Add
e2e/fixtures/cross-origin.html, the same asindex.htmlbut withdata-api-urlpointing athttp://localhost:4174/api/chat. - Add
e2e/tests/cross-origin.spec.ts: open the page, send a message, and check that the streamed reply shows up. Also check that the browser sent a preflight first (a JSONPOSTalways needs one), for example by countingOPTIONSrequests in the mock and reading the count from the test. - Start both ports from the existing
webServerentry ine2e/playwright.config.ts.
Where to look
e2e/server.mjs,e2e/playwright.config.ts,e2e/tests/widget.spec.ts- CONTRIBUTING.md, "Browser tests"
Acceptance criteria
-
pnpm e2epasses, including the new spec - If you change the mock so
Access-Control-Allow-Headersis empty, the new test fails (try it, and say so in the PR) - The existing specs still pass and still use the same-origin page
- No changeset needed (
pnpm changeset --empty)
Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off dev, and open your PR against dev with Closes #<this issue number>. Setup notes (pnpm, build before test) are in CONTRIBUTING.md.
- Lingua principale
- TypeScript
- Stelle
- 13
- Fork
- 7
- Merge medio
- 3h 41m
- PR unite (30g)
- 155
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di codercops/chatcops
-
Document the pre-chat formForse già presa @masyarakatai l’ha presa 5 giorni fa. Apertadocumentation good first issue hacktoberfest widget
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
codercops/chatcops#70 · 5 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
docs: update the providers page for openai-compatible, registerProvider and provider importsForse già presa @prakashNalla l’ha presa oggi. Apertadocumentation good first issue hacktoberfest website
Difficoltà 3/5 1-2 giorni Idoneità per principianti 76/100
codercops/chatcops#291 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
docs: add a protocol reference page for custom clientsForse già presa @kachamsiddarth l’ha presa oggi. Apertadocumentation good first issue hacktoberfest website
codercops/chatcops#286 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Create @chatcops/store-cloudflare (D1, KV and a Durable Object counter)Forse già presa @bhushan4work l’ha presa oggi. Apertaenhancement hacktoberfest help wanted server
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
codercops/chatcops#249 · 2 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Create @chatcops/store-sqlite, a store for single-server setupsForse già presa @srikar-naidu l’ha presa oggi. Apertaenhancement hacktoberfest help wanted server
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
codercops/chatcops#247 · 3 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di codercops/chatcops
Issue simili
-
bug P3 UI/UX
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
StellarState/SS-backend#712 ·
I maintainer di solito rispondono entro 1 giorno
-
area: backend bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
snapotter-hq/SnapOtter#3473 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
gitroomhq/postiz-app#2304 ·
I maintainer di solito rispondono entro 1 giorno
-
harlan-agent-ready-to-implement routine:ci-review
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
harlan-zw/unlighthouse#454 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno