Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

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

Aberta
#233 2 comentários 0 reações 1 responsável Ver no GitHub

Mantenedores costumam responder em até 1 dia

@piyusshhjangid já está trabalhando nisso.

Desde 20/10/2026.

  • #294 de @piyusshhjangid — aberto

Avaliação

Esta issue ainda não foi avaliada.

Descrição

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.

Linguagem predominante
TypeScript
Estrelas
13
Forks
7
Merge médio
3h 41min
PRs com merge (30d)
155

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de codercops/chatcops

Todas as issues de codercops/chatcops

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.