-
Notifications
You must be signed in to change notification settings - Fork 5
task: set status betterstack page conditionally for staging and production #434
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |||||||||||
| from loguru import logger | ||||||||||||
|
|
||||||||||||
| from aignostics.constants import WINDOW_TITLE | ||||||||||||
| from aignostics.platform import API_ROOT_PRODUCTION, API_ROOT_STAGING | ||||||||||||
| from aignostics.utils import __version__, open_user_data_directory | ||||||||||||
|
|
||||||||||||
| from ._theme import theme | ||||||||||||
|
|
@@ -29,6 +30,24 @@ | |||||||||||
| CLASSES_FULL_SIZE = f"{CLASSES_FULL_WIDTH} {CLASSES_FULL_HEIGHT}" | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| def get_status_page_url(api_root: str) -> str | None: | ||||||||||||
| """Get the status page URL based on the API root environment. | ||||||||||||
|
|
||||||||||||
| Args: | ||||||||||||
| api_root: The API root URL to determine the environment | ||||||||||||
|
|
||||||||||||
| Returns: | ||||||||||||
| The status page URL for production/staging, or None for dev/test | ||||||||||||
| """ | ||||||||||||
| if api_root == API_ROOT_PRODUCTION: | ||||||||||||
| return "https://status.platform.aignostics.com" | ||||||||||||
| elif api_root == API_ROOT_STAGING: | ||||||||||||
| return "https://status.platform-staging.aignostics.com" | ||||||||||||
| else: | ||||||||||||
| # No status page for dev and test environments | ||||||||||||
| return None | ||||||||||||
melifaro marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| @contextmanager | ||||||||||||
| def frame( # noqa: C901, PLR0915 | ||||||||||||
| navigation_title: str, | ||||||||||||
|
|
@@ -213,7 +232,9 @@ def _update_health() -> None: | |||||||||||
| coroutine=_health_load_and_render(), | ||||||||||||
| name="_health_load_and_render", | ||||||||||||
| ) | ||||||||||||
| ui.run_javascript("document.getElementById('betterstack').src = document.getElementById('betterstack').src;") | ||||||||||||
| # Only refresh the status iframe if it exists (production/staging) | ||||||||||||
| if get_status_page_url(settings().api_root): | ||||||||||||
| ui.run_javascript("document.getElementById('betterstack').src = document.getElementById('betterstack').src;") | ||||||||||||
|
||||||||||||
| ui.run_javascript("document.getElementById('betterstack').src = document.getElementById('betterstack').src;") | |
| ui.run_javascript( | |
| "var iframe = document.getElementById('betterstack');" | |
| "if (iframe) { iframe.src = iframe.src; }" | |
| ) |
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.
I'm not sure whether this is an actual problem or not. Are you able to start the Launchpad against all environments?
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.
@olivermeyer yes, it looks correct against the branch - no Betterstack status page icon for dev and test, different links for staging and prod.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """Tests for GUI module.""" |
|
Collaborator
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. If we decide to move the status page URL resolution to the existing |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| """Tests for GUI frame module.""" | ||
|
|
||
| import pytest | ||
|
|
||
| from aignostics.gui._frame import get_status_page_url | ||
| from aignostics.platform import ( | ||
| API_ROOT_DEV, | ||
| API_ROOT_PRODUCTION, | ||
| API_ROOT_STAGING, | ||
| API_ROOT_TEST, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.unit | ||
| def test_get_status_page_url_production(record_property) -> None: | ||
| """Test that production environment returns correct status page URL. | ||
|
|
||
| Args: | ||
| record_property: pytest record_property fixture | ||
| """ | ||
| record_property("tested-item-id", "SPEC-GUI-FRAME") | ||
| url = get_status_page_url(API_ROOT_PRODUCTION) | ||
| assert url == "https://status.platform.aignostics.com" | ||
|
|
||
|
|
||
| @pytest.mark.unit | ||
| def test_get_status_page_url_staging(record_property) -> None: | ||
| """Test that staging environment returns correct status page URL. | ||
|
|
||
| Args: | ||
| record_property: pytest record_property fixture | ||
| """ | ||
| record_property("tested-item-id", "SPEC-GUI-FRAME") | ||
| url = get_status_page_url(API_ROOT_STAGING) | ||
| assert url == "https://status.platform-staging.aignostics.com" | ||
|
|
||
|
|
||
| @pytest.mark.unit | ||
| def test_get_status_page_url_dev(record_property) -> None: | ||
| """Test that dev environment returns None (no status page). | ||
|
|
||
| Args: | ||
| record_property: pytest record_property fixture | ||
| """ | ||
| record_property("tested-item-id", "SPEC-GUI-FRAME") | ||
| url = get_status_page_url(API_ROOT_DEV) | ||
| assert url is None | ||
|
|
||
|
|
||
| @pytest.mark.unit | ||
| def test_get_status_page_url_test(record_property) -> None: | ||
| """Test that test environment returns None (no status page). | ||
|
|
||
| Args: | ||
| record_property: pytest record_property fixture | ||
| """ | ||
| record_property("tested-item-id", "SPEC-GUI-FRAME") | ||
| url = get_status_page_url(API_ROOT_TEST) | ||
| assert url is None | ||
|
|
||
|
|
||
| @pytest.mark.unit | ||
| def test_get_status_page_url_unknown(record_property) -> None: | ||
| """Test that unknown environment returns None (no status page). | ||
|
|
||
| Args: | ||
| record_property: pytest record_property fixture | ||
| """ | ||
| record_property("tested-item-id", "SPEC-GUI-FRAME") | ||
| url = get_status_page_url("https://custom.example.com") | ||
| assert url is None |
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.
Would it make sense to move this logic to here?