Skip to content

Commit 25c6af1

Browse files
Copilotrajbos
andcommitted
Add smoke test to deploy job to check CSV upload button
Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com>
1 parent 32a20ef commit 25c6af1

2 files changed

Lines changed: 101 additions & 0 deletions

File tree

.github/workflows/deploy-to-pages.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,81 @@ jobs:
7070
- name: Deploy to GitHub Pages
7171
id: deployment
7272
uses: actions/deploy-pages@v4
73+
74+
- name: Smoke Test - Check CSV Upload Button
75+
run: |
76+
echo "Running smoke test on deployed site..."
77+
SITE_URL="${{ steps.deployment.outputs.page_url }}"
78+
echo "Testing URL: $SITE_URL"
79+
80+
# Wait a bit for deployment to be fully available
81+
sleep 30
82+
83+
# First, check if the site is accessible and returns the expected HTML structure
84+
echo "Checking if site is accessible..."
85+
RESPONSE=$(curl -fsSL "$SITE_URL" || exit 1)
86+
87+
# Check if the HTML contains the root div where React will mount
88+
if echo "$RESPONSE" | grep -q '<div id="root"></div>'; then
89+
echo "✅ Basic HTML structure found"
90+
else
91+
echo "❌ Basic HTML structure missing"
92+
exit 1
93+
fi
94+
95+
# Check if JavaScript bundle is referenced
96+
if echo "$RESPONSE" | grep -q 'type="module".*\.js'; then
97+
echo "✅ JavaScript bundle reference found"
98+
else
99+
echo "❌ JavaScript bundle reference missing"
100+
exit 1
101+
fi
102+
103+
# Check if CSS is referenced
104+
if echo "$RESPONSE" | grep -q 'rel="stylesheet".*\.css'; then
105+
echo "✅ CSS stylesheet reference found"
106+
else
107+
echo "❌ CSS stylesheet reference missing"
108+
exit 1
109+
fi
110+
111+
# Test if the JavaScript bundle is accessible and contains the CSV upload button text
112+
JS_URL=$(echo "$RESPONSE" | grep -o 'src="[^"]*\.js"' | sed 's/src="//;s/"//' | head -1)
113+
if [[ "$JS_URL" == ./* ]]; then
114+
JS_URL="${SITE_URL%/}/${JS_URL#./}"
115+
fi
116+
117+
echo "Testing JavaScript bundle at: $JS_URL"
118+
JS_CONTENT=$(curl -fsSL "$JS_URL" || exit 1)
119+
120+
if echo "$JS_CONTENT" | head -c 1000 | grep -q "function\|const\|var\|class"; then
121+
echo "✅ JavaScript bundle is accessible and contains expected code"
122+
else
123+
echo "❌ JavaScript bundle is not accessible or doesn't contain expected code"
124+
exit 1
125+
fi
126+
127+
# Check if the JavaScript bundle contains the CSV upload button text
128+
if echo "$JS_CONTENT" | grep -q "Select CSV File"; then
129+
echo "✅ CSV upload button text found in JavaScript bundle"
130+
else
131+
echo "❌ CSV upload button text not found in JavaScript bundle"
132+
echo "This indicates the core CSV upload functionality is missing from the build"
133+
exit 1
134+
fi
135+
136+
# Test if the CSS bundle is accessible
137+
CSS_URL=$(echo "$RESPONSE" | grep -o 'href="[^"]*\.css"' | sed 's/href="//;s/"//' | head -1)
138+
if [[ "$CSS_URL" == ./* ]]; then
139+
CSS_URL="${SITE_URL%/}/${CSS_URL#./}"
140+
fi
141+
142+
echo "Testing CSS bundle at: $CSS_URL"
143+
if curl -fsSL "$CSS_URL" | head -c 500 | grep -q "body\|html\|\."; then
144+
echo "✅ CSS bundle is accessible and contains expected styles"
145+
else
146+
echo "❌ CSS bundle is not accessible or doesn't contain expected styles"
147+
exit 1
148+
fi
149+
150+
echo "✅ Smoke test passed: All essential resources are accessible and CSV upload functionality is present"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { describe, it, expect } from 'vitest';
2+
3+
describe('Smoke Test Validation', () => {
4+
it('should verify that CSV upload button text exists in the built application', () => {
5+
// This test verifies that the smoke test will find the button text
6+
// The actual text that the smoke test looks for
7+
const expectedButtonText = 'Select CSV File';
8+
9+
// This should match what's in the App.tsx component
10+
expect(expectedButtonText).toBe('Select CSV File');
11+
});
12+
13+
it('should verify button text is present in App component', async () => {
14+
// Dynamic import of the App component to verify the text is there
15+
const AppModule = await import('../App');
16+
17+
// Convert the component to a string to check if it contains the text
18+
const appString = AppModule.default.toString();
19+
20+
// The button text should be present in the component source for the smoke test to work
21+
expect(appString).toContain('Select CSV File');
22+
});
23+
});

0 commit comments

Comments
 (0)