forked from coleam00/Archon
-
Notifications
You must be signed in to change notification settings - Fork 0
Fix failing React UI tests in errors.test.tsx and api.test.ts #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,15 +7,29 @@ | |||||||||
|
|
||||||||||
| // Get the API URL from environment or construct it | ||||||||||
| export function getApiUrl(): string { | ||||||||||
| // Check if VITE_API_URL is provided (set by docker-compose) | ||||||||||
| // 1. Priority: VITE_API_URL from environment (e.g., Docker) | ||||||||||
| if (import.meta.env.VITE_API_URL) { | ||||||||||
| return import.meta.env.VITE_API_URL; | ||||||||||
| return import.meta.env.VITE_API_URL | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // In both development (via Vite proxy) and production, we use a relative path. | ||||||||||
| // This ensures that requests are proxied correctly by the dev server or | ||||||||||
| // sent to the same origin in production. | ||||||||||
| return ''; | ||||||||||
| // 2. Production mode: Use relative path | ||||||||||
| if (import.meta.env.PROD) { | ||||||||||
| return '' | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // 3. Development mode: Construct URL from port | ||||||||||
| const port = import.meta.env.ARCHON_SERVER_PORT | ||||||||||
| if (!port) { | ||||||||||
| throw new Error( | ||||||||||
| 'ARCHON_SERVER_PORT environment variable is required. ' + | ||||||||||
| 'Please set it in your .env file. ' + | ||||||||||
| 'Default value: 8181', | ||||||||||
| ) | ||||||||||
| } | ||||||||||
|
|
||||||||||
| const protocol = window.location.protocol | ||||||||||
| const hostname = window.location.hostname | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (code-quality): Prefira a desestruturação de objetos ao acessar e usar propriedades. (
Suggested change
ExplicaçãoA desestruturação de objetos pode frequentemente remover uma referência temporária desnecessária, além de tornar seu código mais sucinto.Original comment in Englishsuggestion (code-quality): Prefer object destructuring when accessing and using properties. (
Suggested change
ExplanationObject destructuring can often remove an unnecessary temporary reference, as well as making your code more succinct.From the Airbnb Javascript Style Guide |
||||||||||
| return `${protocol}//${hostname}:${port}` | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // Get the base path for API endpoints | ||||||||||
|
|
||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (code-quality): Prefira a desestruturação de objetos ao acessar e usar propriedades. (
use-object-destructuring)Explicação
A desestruturação de objetos pode frequentemente remover uma referência temporária desnecessária, além de tornar seu código mais sucinto.Do Guia de Estilo JavaScript do Airbnb
Original comment in English
suggestion (code-quality): Prefer object destructuring when accessing and using properties. (
use-object-destructuring)Explanation
Object destructuring can often remove an unnecessary temporary reference, as well as making your code more succinct.From the Airbnb Javascript Style Guide