Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đã đóng
#233 2 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@piyusshhjangid đang làm issue này rồi.

Từ ngày 20/10/2026.

  • #294 của @piyusshhjangid — đã merge

Đánh giá

Issue này chưa được đánh giá.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
13
Fork
7
Merge trung bình
3 giờ 33 phút
Pull request đã merge (30 ngày)
176

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của codercops/chatcops

Tất cả issue của codercops/chatcops

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.