Skip to content

Commit 82e4f85

Browse files
Copilotpatrickrb
andauthored
Fix "No Station Configured" warning flash during page load (#127)
* Initial plan * Fix "No Station Configured" warning flash during page load Co-authored-by: patrickrb <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: patrickrb <[email protected]>
1 parent 785f968 commit 82e4f85

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

src/app/new-contact/page.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ interface Station {
2222

2323
export default function NewContactPage() {
2424
const [stations, setStations] = useState<Station[]>([]);
25+
const [stationsLoading, setStationsLoading] = useState(true);
2526
const [selectedStationId, setSelectedStationId] = useState<string>('');
2627
const [isLiveLogging, setIsLiveLogging] = useState(false);
2728
const [formData, setFormData] = useState({
@@ -93,6 +94,7 @@ export default function NewContactPage() {
9394

9495
const fetchStations = async () => {
9596
try {
97+
setStationsLoading(true);
9698
const response = await fetch('/api/stations');
9799
if (response.ok) {
98100
const data = await response.json();
@@ -106,6 +108,8 @@ export default function NewContactPage() {
106108
}
107109
} catch {
108110
// Silent error handling for stations fetch
111+
} finally {
112+
setStationsLoading(false);
109113
}
110114
};
111115

@@ -321,7 +325,7 @@ export default function NewContactPage() {
321325
)}
322326

323327
{/* No stations warning */}
324-
{stations.length === 0 && (
328+
{!stationsLoading && stations.length === 0 && (
325329
<div className="bg-yellow-50 dark:bg-yellow-950/30 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4">
326330
<div className="flex items-start">
327331
<AlertCircle className="h-5 w-5 text-yellow-600 dark:text-yellow-500 mt-0.5 mr-3" />

tests/contact-management.spec.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,42 @@
11
import { test, expect } from '@playwright/test';
22

33
test.describe('Contact Management Pages', () => {
4+
test('new contact page should not show station warning during loading', async ({ page }) => {
5+
// Track if the warning appears during page load
6+
let warningAppeared = false;
7+
8+
// Monitor for the "No Station Configured" warning
9+
page.on('domcontentloaded', async () => {
10+
try {
11+
// Check if warning is visible immediately after DOM content loaded
12+
const warning = page.locator('text=No Station Configured');
13+
if (await warning.isVisible({ timeout: 100 })) {
14+
warningAppeared = true;
15+
}
16+
} catch {
17+
// Warning not found, which is good
18+
}
19+
});
20+
21+
// Navigate to the new contact page
22+
const response = await page.goto('/new-contact');
23+
24+
// Check that the response is valid
25+
if (response?.status()) {
26+
expect(response.status()).toBeLessThan(500);
27+
}
28+
29+
// Wait a moment for any initial rendering and API calls
30+
await page.waitForTimeout(1000);
31+
32+
// The warning should not have appeared during the initial loading phase
33+
expect(warningAppeared).toBe(false);
34+
35+
// Check that we're on the new contact page or redirected appropriately
36+
const url = page.url();
37+
expect(url).toMatch(/(new-contact|install|login)/);
38+
});
39+
440
test('new contact page should load correctly', async ({ page }) => {
541
// The page should load without server errors
642
const response = await page.goto('/new-contact');

0 commit comments

Comments
 (0)