Title: [Feat]: add test suite for running e2e tests behind proxy/not root · Issue #5337 · coder/code-server · GitHub
Open Graph Title: [Feat]: add test suite for running e2e tests behind proxy/not root · Issue #5337 · coder/code-server
X Title: [Feat]: add test suite for running e2e tests behind proxy/not root · Issue #5337 · coder/code-server
Description: What is your suggestion? To modify our e2e test setup to run the same tests but in an environment that runs code-server not on the root path i.e. behind /ide or something. Why do you want this feature? It mimics how many of our users run...
Open Graph Description: What is your suggestion? To modify our e2e test setup to run the same tests but in an environment that runs code-server not on the root path i.e. behind /ide or something. Why do you want this feat...
X Description: What is your suggestion? To modify our e2e test setup to run the same tests but in an environment that runs code-server not on the root path i.e. behind /ide or something. Why do you want this feat...
Opengraph URL: https://github.com/coder/code-server/issues/5337
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Feat]: add test suite for running e2e tests behind proxy/not root","articleBody":"## What is your suggestion?\r\n\r\nTo modify our e2e test setup to run the same tests but in an environment that runs code-server not on the root path i.e. behind `/ide` or something.\r\n\r\n## Why do you want this feature?\r\n\r\nIt mimics how many of our users run code-server and also mimics how we run code-server in both Coder and Coder OSS.\r\n\r\nIt would have prevented a high-impact bug we accidentally introduced in 4.5.0.\r\n\r\nSee https://github.com/coder/code-server/issues/5321\r\n\r\n## Are there any workarounds to get this functionality today?\r\n\r\nManually testing code-server behind a reverse proxy with Caddy before each release 😅\r\n\r\n## Are you interested in submitting a PR for this?\r\n\r\nYes\r\n\r\n### Notes\r\n\r\nInstead of duplicating tests, it would be cool if we added a new script like `yarn test:e2e:caddy` or something which spun up Caddy in front of code-server and then ran the tests using that environment.\r\n\r\nCurrently the e2e tests run in parallel (I believe) and use random ports so we'd have to use a wildcard in Caddy (I'm pretty sure it can do that).\r\n\r\nWe'd also have to make sure code-server's [address](https://github.com/coder/code-server/blob/main/test/e2e/models/CodeServer.ts#L52-L62) had the path in it. I'm guessing we could do some environment variable logic or something like `PATH_TO_USE=\"/ide\"` and then dynamically set `address`.\r\n\r\n\r\n_notes from Discord call with @code-asher _\r\n- install Caddy\r\n- launch Caddy\r\n- set env variable to use proxy or special path \r\n\r\nwe might be able to use [named matchers](https://caddyserver.com/docs/caddyfile/matchers#named-matchers).\r\n\r\nsimplest way to do this:\r\n- write `Caddyfile`\r\n- run code-server on one port and make sure it works as expected\r\n- run it on another port and make sure it works\r\n\r\n\r\n```sh\r\n:80 {\r\n @portLocalhost header_regexp port Host ^([0-9]+)\\.localhost$\r\n handle @portLocalhost {\r\n reverse_proxy localhost:{re.port.1}\r\n }\r\n \r\n handle { \r\n respond \"Bad hostname\" 400\r\n }\r\n}\r\n```\r\n\r\n`USE_PROXY=1`\r\n\r\n`caddy start`\r\n\r\n```ts\r\nif(USE_PROXY && USE_PROXY=1) {\r\n return port.localhost\r\n}\r\n```\r\n\r\n```ts\r\nconst uri = new URL(address)\r\nconst port = uri.port\r\n```\r\n\r\n- [ ] add support for `USE_PROXY`\r\n- [ ] add Caddyfile","author":{"url":"https://github.com/jsjoeio","@type":"Person","name":"jsjoeio"},"datePublished":"2022-07-14T00:05:32Z","url":"https://github.com/coder/code-server/issues/5337"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:41306728-8548-e827-7e93-9f2e7faa8fc7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BBA8:785A9:2927A35:343C2D0:6B01A154 |
| html-safe-nonce | da357eb76fca01af992dbc183073e2bf31b2546cb4722283d26222d77fd600a9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQkE4Ojc4NUE5OjI5MjdBMzU6MzQzQzJEMDo2QjAxQTE1NCIsInZpc2l0b3JfaWQiOiIzMTI5NTQzODg2NDE5MTA4MTgwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 3e66079131fcbdc66c94d539a012a01a08ade7f846971aaf7cfc00da7121ab0c |
| hovercard-subject-tag | issue:1304062063 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/coder/code-server/5337/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8aeb3cce591a86cf547c35ed2a3e3d260b9d7ef5fdef0e769cbeee1d61329e4e/coder/code-server/issues/5337 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8aeb3cce591a86cf547c35ed2a3e3d260b9d7ef5fdef0e769cbeee1d61329e4e/coder/code-server/issues/5337 |
| og:image:alt | What is your suggestion? To modify our e2e test setup to run the same tests but in an environment that runs code-server not on the root path i.e. behind /ide or something. Why do you want this feat... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jsjoeio |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/coder/code-server git https://github.com/coder/code-server.git |
| octolytics-dimension-user_id | 95932066 |
| octolytics-dimension-user_login | coder |
| octolytics-dimension-repository_id | 172953845 |
| octolytics-dimension-repository_nwo | coder/code-server |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 172953845 |
| octolytics-dimension-repository_network_root_nwo | coder/code-server |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width