Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Run a browser test with the chat API on a different origin than the page

Aperta
#233 2 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@piyusshhjangid ci sta già lavorando.

Dal 20/10/2026.

  • #294 di @piyusshhjangid — aperta

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

enhancement hacktoberfest help wanted testing widget

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.mjs listen on a second port (E2E_API_PORT, default 4174) that serves only POST /api/chat and OPTIONS /api/chat, using the same mock replies as now.
  • On that port, answer OPTIONS exactly like a 0.5 server does: 204, Access-Control-Allow-Origin: *, Access-Control-Allow-Methods: POST, OPTIONS, Access-Control-Allow-Headers: Content-Type. Put Access-Control-Allow-Origin: * on the POST replies too.
  • Add e2e/fixtures/cross-origin.html, the same as index.html but with data-api-url pointing at http://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 JSON POST always needs one), for example by counting OPTIONS requests in the mock and reading the count from the test.
  • Start both ports from the existing webServer entry in e2e/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 e2e passes, including the new spec
  • If you change the mock so Access-Control-Allow-Headers is 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

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di codercops/chatcops

Tutte le issue di codercops/chatcops

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.