Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

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

Geschlossen
#233 2 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@piyusshhjangid arbeitet bereits daran.

Seit 20.10.2026.

  • #294 von @piyusshhjangid — gemerged

Bewertung

Dieses Issue wurde noch nicht bewertet.

Beschreibung

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.

Vorherrschende Sprache
TypeScript
Sterne
13
Forks
7
Ø Merge
3 Std. 33 Min.
Gemergte PRs (30 T.)
176

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus codercops/chatcops

Alle Issues in codercops/chatcops

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.