-
Notifications
You must be signed in to change notification settings - Fork 0
β‘ Bolt: Optimize Section5 background image #59
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 all commits
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 | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,70 @@ | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| import time | ||||||||||||||||||||||||||||||||||
| import requests | ||||||||||||||||||||||||||||||||||
| from playwright.sync_api import sync_playwright, expect | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| def wait_for_server(url, timeout=120): | ||||||||||||||||||||||||||||||||||
| start_time = time.time() | ||||||||||||||||||||||||||||||||||
| print(f"Waiting for {url} to be responsive...") | ||||||||||||||||||||||||||||||||||
| while time.time() - start_time < timeout: | ||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||
| response = requests.get(url) | ||||||||||||||||||||||||||||||||||
|
Contributor
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. The
Suggested change
|
||||||||||||||||||||||||||||||||||
| if response.status_code == 200: | ||||||||||||||||||||||||||||||||||
| print("Server is ready!") | ||||||||||||||||||||||||||||||||||
| return True | ||||||||||||||||||||||||||||||||||
| except requests.exceptions.ConnectionError: | ||||||||||||||||||||||||||||||||||
| pass | ||||||||||||||||||||||||||||||||||
| except Exception as e: | ||||||||||||||||||||||||||||||||||
| print(f"Error checking server: {e}") | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+11
to
+18
Contributor
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. π§© Analysis chainπ Script executed: find . -name "verify_section5.py" -type fRepository: anyulled/devbcn-nextjs Length of output: 86 π Script executed: cat -n verify_section5.pyRepository: anyulled/devbcn-nextjs Length of output: 2954 π Script executed: #!/bin/bash
# Quick verification: check if there are other requests calls without timeout in this file
rg -n 'requests\.' verify_section5.pyRepository: anyulled/devbcn-nextjs Length of output: 164 Add timeout to request and narrow exception handling. Line 11 can block indefinitely without a timeout parameter on Suggested patch- response = requests.get(url)
+ response = requests.get(url, timeout=5)
if response.status_code == 200:
print("Server is ready!")
return True
except requests.exceptions.ConnectionError:
pass
- except Exception as e:
+ except requests.exceptions.RequestException as e:
print(f"Error checking server: {e}")π Committable suggestion
Suggested change
π§° Toolsπͺ Ruff (0.15.2)[error] 11-11: Probable use of (S113) [warning] 17-17: Do not catch blind exception: (BLE001) π€ Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
| time.sleep(1) | ||||||||||||||||||||||||||||||||||
| print("Server failed to start within timeout.") | ||||||||||||||||||||||||||||||||||
| return False | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| def verify_section5(): | ||||||||||||||||||||||||||||||||||
| url = "http://localhost:3000/2026" | ||||||||||||||||||||||||||||||||||
| if not wait_for_server(url): | ||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+25
to
+26
Contributor
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. Fail with non-zero exit code when verification fails. Right now, failed checks only log and return, so CI can report success even when the verification fails. Suggested patch+import sys
@@
-def verify_section5():
+def verify_section5() -> bool:
@@
- if not wait_for_server(url):
- return
+ if not wait_for_server(url):
+ return False
@@
- if bg_image.count() > 0:
+ if bg_image.count() > 0:
print("Background image found!")
expect(bg_image.first).to_be_visible()
@@
section = page.locator(".team8-section-rea").first
section.screenshot(path="verification_section5.png")
print("Screenshot saved to verification_section5.png")
+ browser.close()
+ return True
else:
print("Background image NOT found!")
# Take screenshot of the whole page for debugging
page.screenshot(path="verification_failure.png")
-
- browser.close()
+ browser.close()
+ return False
@@
if __name__ == "__main__":
- verify_section5()
+ raise SystemExit(0 if verify_section5() else 1)Also applies to: 62-66, 69-70 π€ Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| with sync_playwright() as p: | ||||||||||||||||||||||||||||||||||
| browser = p.chromium.launch(headless=True) | ||||||||||||||||||||||||||||||||||
| page = browser.new_page() | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| print(f"Navigating to {url}") | ||||||||||||||||||||||||||||||||||
| page.goto(url) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Wait for the section to be visible | ||||||||||||||||||||||||||||||||||
| print("Waiting for 'Meet Our Speakers' section...") | ||||||||||||||||||||||||||||||||||
| # Scroll down to ensure images load | ||||||||||||||||||||||||||||||||||
| page.evaluate("window.scrollTo(0, document.body.scrollHeight)") | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Locate the section header | ||||||||||||||||||||||||||||||||||
| header = page.get_by_text("Meet Our Speakers").first | ||||||||||||||||||||||||||||||||||
| header.scroll_into_view_if_needed() | ||||||||||||||||||||||||||||||||||
| expect(header).to_be_visible() | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| print("Found section header. Checking background image...") | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Locate the background image by src | ||||||||||||||||||||||||||||||||||
| # Since it's optimized, src will contain `_next/image` and `url` param containing the original path | ||||||||||||||||||||||||||||||||||
| # Use partial match on src attribute | ||||||||||||||||||||||||||||||||||
| bg_image = page.locator('img[src*="header-bg20.png"]') | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Check if the image is visible | ||||||||||||||||||||||||||||||||||
| if bg_image.count() > 0: | ||||||||||||||||||||||||||||||||||
| print("Background image found!") | ||||||||||||||||||||||||||||||||||
| expect(bg_image.first).to_be_visible() | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| # Take screenshot of the section | ||||||||||||||||||||||||||||||||||
| # Find the section container | ||||||||||||||||||||||||||||||||||
| section = page.locator(".team8-section-rea").first | ||||||||||||||||||||||||||||||||||
| section.screenshot(path="verification_section5.png") | ||||||||||||||||||||||||||||||||||
| print("Screenshot saved to verification_section5.png") | ||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||
| print("Background image NOT found!") | ||||||||||||||||||||||||||||||||||
| # Take screenshot of the whole page for debugging | ||||||||||||||||||||||||||||||||||
| page.screenshot(path="verification_failure.png") | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| browser.close() | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| if __name__ == "__main__": | ||||||||||||||||||||||||||||||||||
| verify_section5() | ||||||||||||||||||||||||||||||||||
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.
Using
z-index: -1can be brittle as it places the image behind its parent element. If the parent element ever gets a background color, the image will be hidden. A more robust approach is to establish a new stacking context for the content, placing it explicitly on top of the image without relying on a negativez-index.