Run a browser test with the chat API on a different origin than the page
Mantenedores costumam responder em até 1 dia
Avaliação
Esta issue ainda não foi avaliada.
Descrição
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.
- Linguagem predominante
- TypeScript
- Estrelas
- 13
- Forks
- 7
- Merge médio
- 3h 41min
- PRs com merge (30d)
- 155
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de codercops/chatcops
-
Document the pre-chat formTalvez já em andamento @masyarakatai assumiu há 5 dias. Abertadocumentation good first issue hacktoberfest widget
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 88/100
codercops/chatcops#70 · 5 comentários ·
Mantenedores costumam responder em até 1 dia
-
docs: update the providers page for openai-compatible, registerProvider and provider importsTalvez já em andamento @prakashNalla assumiu hoje. Abertadocumentation good first issue hacktoberfest website
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 76/100
codercops/chatcops#291 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
docs: add a protocol reference page for custom clientsTalvez já em andamento @kachamsiddarth assumiu hoje. Abertadocumentation good first issue hacktoberfest website
codercops/chatcops#286 · 2 comentários · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Create @chatcops/store-cloudflare (D1, KV and a Durable Object counter)Talvez já em andamento @bhushan4work assumiu hoje. Abertaenhancement hacktoberfest help wanted server
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 25/100
codercops/chatcops#249 · 2 comentários · 1 responsável ·
Mantenedores costumam responder em até 1 dia
-
Create @chatcops/store-sqlite, a store for single-server setupsTalvez já em andamento @srikar-naidu assumiu hoje. Abertaenhancement hacktoberfest help wanted server
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
codercops/chatcops#247 · 3 comentários · 1 responsável ·
Mantenedores costumam responder em até 1 dia
Todas as issues de codercops/chatcops
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 83/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 72/100
zts212653/clowder-ai#1678 ·
Mantenedores costumam responder em até 1 dia
-
good first issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 64/100
Progressive-Victory/the-website#680 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100