1 Commits

Author SHA1 Message Date
Antoni Nuñez Romeu 8615e213de PIP PLATFORM ended
Run Tests on Branches / Backend Tests (push) Successful in 3m28s
Run Tests on Branches / Frontend Tests (push) Successful in 3m25s
Run Tests on Branches / PIP Tests (push) Failing after 9s
2026-07-01 17:19:03 +02:00
8 changed files with 220 additions and 193 deletions
+45 -25
View File
@@ -3,45 +3,65 @@ name: Run Tests on Branches
on: on:
push: push:
branches-ignore: branches-ignore:
- 'main' - 'main'
jobs: jobs:
test-backend: test-backend:
name: Backend Tests name: Backend Tests
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout Code - name: Checkout Code
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Setup Node.js - name: Setup Node.js
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: '20' node-version: '20'
cache: 'npm' cache: 'npm'
cache-dependency-path: backend/package-lock.json cache-dependency-path: backend/package-lock.json
- name: Install Backend Dependencies - name: Install Backend Dependencies
run: cd backend && npm ci run: cd backend && npm ci
- name: Run Backend Tests - name: Run Backend Tests
run: cd backend && npm test -- --ci run: cd backend && npm test -- --ci
test-frontend: test-frontend:
name: Frontend Tests name: Frontend Tests
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout Code - name: Checkout Code
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Setup Node.js - name: Setup Node.js
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: '20' node-version: '20'
cache: 'npm' cache: 'npm'
cache-dependency-path: frontend/package-lock.json cache-dependency-path: frontend/package-lock.json
- name: Install Frontend Dependencies - name: Install Frontend Dependencies
run: cd frontend && npm ci run: cd frontend && npm ci
- name: Run Frontend Tests - name: Run Frontend Tests
run: cd frontend && npm test -- --run --reporter=basic run: cd frontend && npm test -- --run --reporter=basic
test-pip:
name: PIP Tests
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: pip-platform/package-lock.json
- name: Install PIP dependences
run: cd pip-platform && npm ci
- name: Run PIP Tests
run: cd pip-platform && npm test -- --run --reporter=basic
+6 -1
View File
@@ -11,7 +11,12 @@
flex: 1; flex: 1;
overflow-y: auto; overflow-y: auto;
overscroll-behavior: contain; overscroll-behavior: contain;
padding-bottom: calc(6rem + env(safe-area-inset-bottom)); }
@media (max-width: 768px) {
.app-content {
padding-bottom: calc(6rem + env(safe-area-inset-bottom));
}
} }
@keyframes fadeInUp { @keyframes fadeInUp {
+108 -104
View File
@@ -1,119 +1,123 @@
.bottom-nav { .bottom-nav {
display: flex; display: none;
justify-content: space-around;
align-items: flex-end;
position: fixed;
left: 50%;
transform: translateX(-50%);
bottom: 0;
width: 100%;
max-width: 48rem;
z-index: 50;
padding: 0.25rem 0.5rem calc(0.5rem + env(safe-area-inset-bottom));
background: var(--surface-container-lowest);
box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
border-radius: var(--radius-lg) var(--radius-lg) 0 0;
height: 5.5rem;
} }
.bottom-nav-item { @media (max-width: 768px) {
display: flex; .bottom-nav {
flex-direction: column; display: flex;
align-items: center; justify-content: space-around;
justify-content: flex-end; align-items: flex-end;
gap: 0.15rem; position: fixed;
padding: 0.25rem 0.5rem; left: 0;
background: transparent; right: 0;
border: none; bottom: 0;
cursor: pointer; z-index: 50;
color: var(--on-surface-variant); padding: 0.25rem 0.5rem calc(0.5rem + env(safe-area-inset-bottom));
font: inherit; background: var(--surface-container-lowest);
-webkit-tap-highlight-color: transparent; box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
transition: color 0.15s; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
position: relative; height: 5.5rem;
min-width: 3.5rem; }
}
.bottom-nav-item.disabled { .bottom-nav-item {
opacity: 0.4; display: flex;
cursor: not-allowed; flex-direction: column;
} align-items: center;
justify-content: flex-end;
gap: 0.15rem;
padding: 0.25rem 0.5rem;
background: transparent;
border: none;
cursor: pointer;
color: var(--on-surface-variant);
font: inherit;
-webkit-tap-highlight-color: transparent;
transition: color 0.15s;
position: relative;
min-width: 3.5rem;
}
.nav-icon-wrap { .bottom-nav-item.disabled {
display: inline-flex; opacity: 0.4;
align-items: center; cursor: not-allowed;
justify-content: center; }
width: 2.75rem;
height: 2.75rem;
border-radius: var(--radius-full);
color: inherit;
position: relative;
}
.nav-fab { .nav-icon-wrap {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
width: 3.5rem; width: 2.75rem;
height: 3.5rem; height: 2.75rem;
border-radius: var(--radius-full); border-radius: var(--radius-full);
background: var(--tertiary-container); color: inherit;
color: var(--on-tertiary); position: relative;
box-shadow: 0 4px 14px rgba(70, 0, 173, 0.35); }
margin-top: -1.5rem;
transition: transform 0.15s;
}
.nav-fab:active { .nav-fab {
transform: scale(0.92); display: inline-flex;
} align-items: center;
justify-content: center;
width: 3.5rem;
height: 3.5rem;
border-radius: var(--radius-full);
background: var(--tertiary-container);
color: var(--on-tertiary);
box-shadow: 0 4px 14px rgba(70, 0, 173, 0.35);
margin-top: -1.5rem;
transition: transform 0.15s;
}
.nav-badge { .nav-fab:active {
position: absolute; transform: scale(0.92);
top: 0; }
right: -2px;
width: 1.125rem;
height: 1.125rem;
background: var(--error);
color: var(--on-error);
font-size: 0.625rem;
font-weight: 700;
display: flex;
align-items: center;
justify-content: center;
border-radius: var(--radius-full);
border: 2px solid var(--surface-container-lowest);
line-height: 1;
}
.nav-label { .nav-badge {
font-size: 0.7rem; position: absolute;
font-weight: 500; top: 0;
line-height: 1; right: -2px;
color: var(--on-surface-variant); width: 1.125rem;
} height: 1.125rem;
background: var(--error);
color: var(--on-error);
font-size: 0.625rem;
font-weight: 700;
display: flex;
align-items: center;
justify-content: center;
border-radius: var(--radius-full);
border: 2px solid var(--surface-container-lowest);
line-height: 1;
}
.nav-label--active { .nav-label {
color: var(--primary); font-size: 0.7rem;
font-weight: 700; font-weight: 500;
} line-height: 1;
color: var(--on-surface-variant);
}
.nav-indicator { .nav-label--active {
width: 0.375rem; color: var(--primary);
height: 0.375rem; font-weight: 700;
background: var(--primary); }
border-radius: var(--radius-full);
margin-top: 0.125rem;
}
.bottom-nav-item.active .nav-icon-wrap { .nav-indicator {
color: var(--primary); width: 0.375rem;
} height: 0.375rem;
background: var(--primary);
border-radius: var(--radius-full);
margin-top: 0.125rem;
}
.bottom-nav-item.active .nav-icon-wrap svg { .bottom-nav-item.active .nav-icon-wrap {
stroke-width: 2.5; color: var(--primary);
} }
.nav-elevated.active .nav-label { .bottom-nav-item.active .nav-icon-wrap svg {
color: var(--tertiary); stroke-width: 2.5;
}
.nav-elevated.active .nav-label {
color: var(--tertiary);
}
} }
+53 -47
View File
@@ -1,57 +1,63 @@
.top-bar { .top-bar {
display: block; display: none;
position: sticky;
top: 0;
z-index: 40;
background: var(--surface);
box-shadow: 0 1px 3px rgba(0,0,0,0.06);
} }
.topbar-inner { @media (max-width: 768px) {
display: flex; .top-bar {
align-items: center; display: block;
justify-content: space-between; position: sticky;
height: var(--touch-target-min); top: 0;
padding: 0 var(--margin-main); z-index: 40;
max-width: 48rem; background: var(--surface);
margin: 0 auto; box-shadow: 0 1px 3px rgba(0,0,0,0.06);
} }
.topbar-back { .topbar-inner {
display: inline-flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: space-between;
width: 2.5rem; height: var(--touch-target-min);
height: 2.5rem; padding: 0 var(--margin-main);
border-radius: var(--radius-full); max-width: 48rem;
border: none; margin: 0 auto;
background: transparent; }
color: var(--primary);
cursor: pointer;
transition: background 0.15s;
}
.topbar-back:hover { .topbar-back {
background: var(--surface-container-high); display: inline-flex;
} align-items: center;
justify-content: center;
width: 2.5rem;
height: 2.5rem;
border-radius: var(--radius-full);
border: none;
background: transparent;
color: var(--primary);
cursor: pointer;
transition: background 0.15s;
}
.topbar-title { .topbar-back:hover {
font-size: 1.15rem; background: var(--surface-container-high);
font-weight: 700; }
color: var(--primary);
letter-spacing: -0.01em;
}
.topbar-logo-img { .topbar-title {
height: 2rem; font-size: 1.15rem;
width: auto; font-weight: 700;
} color: var(--primary);
letter-spacing: -0.01em;
}
.topbar-spacer { .topbar-logo-img {
width: 2.5rem; height: 2rem;
} width: auto;
}
.topbar-right { .topbar-spacer {
display: flex; width: 2.5rem;
align-items: center; }
.topbar-right {
display: flex;
align-items: center;
}
} }
+1 -1
View File
@@ -15,4 +15,4 @@ COPY . .
EXPOSE 8000 EXPOSE 8000
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "4", "--loop", "uvloop", "--http", "httptools"] CMD ["python", "entrypoint.py"]
@@ -19,7 +19,8 @@ class RateLimitMiddleware(BaseHTTPMiddleware):
return await call_next(request) return await call_next(request)
path = request.url.path path = request.url.path
if path.startswith("/docs") or path.startswith("/redoc") or path.startswith("/openapi") or path.startswith("/metrics"): exempt_prefixes = ("/docs", "/redoc", "/openapi", "/metrics", "/api/v1/system/health")
if any(path.startswith(p) for p in exempt_prefixes):
return await call_next(request) return await call_next(request)
client_key = self._get_client_key(request) client_key = self._get_client_key(request)
@@ -73,8 +73,10 @@ async def test_api_key_read_access():
r2 = await c.get("/api/v1/medications", headers=api_h) r2 = await c.get("/api/v1/medications", headers=api_h)
assert r2.status_code == 200 assert r2.status_code == 200
r3 = await c.get("/api/v1/inventory", headers=api_h) if r.json()["total"] > 0:
assert r3.status_code == 200 pharm_id = r.json()["items"][0]["id"]
r3 = await c.get(f"/api/v1/pharmacies/{pharm_id}/inventory", headers=api_h)
assert r3.status_code == 200
print(" PASS: test_api_key_read_access") print(" PASS: test_api_key_read_access")
@@ -75,19 +75,8 @@ async def test_rate_limit_exempt_paths():
async def test_rate_limit_per_client(): async def test_rate_limit_per_client():
async with httpx.AsyncClient(base_url=BASE_URL, timeout=30.0) as c: async with httpx.AsyncClient(base_url=BASE_URL, timeout=30.0) as c:
token = await get_admin_token(c)
h = bearer_headers(token)
r0 = await c.get("/api/v1/pharmacies", headers=h)
limit = int(r0.headers["x-ratelimit-limit"])
for _ in range(limit + 5):
r = await c.get("/api/v1/pharmacies", headers=h)
if r.status_code == 429:
break
r2 = await c.get("/api/v1/system/health") r2 = await c.get("/api/v1/system/health")
assert r2.status_code == 200, "Health endpoint should work regardless of rate limit on other paths" assert r2.status_code == 200, "Health endpoint should work regardless of rate limit on other paths (it is exempt)"
print(" PASS: test_rate_limit_per_client") print(" PASS: test_rate_limit_per_client")