@@ -18,17 +18,9 @@ async def verify() -> bool:
1818 page = await context .new_page ()
1919
2020 try :
21- # Navigate to the main page
22- await page .goto ("http://35.247.158.69:9999/" , wait_until = "networkidle" )
23-
24- # Take a screenshot to verify the page is accessible
25- screenshot_dir = Path (__file__ ).parent
26- screenshot_path = (
27- screenshot_dir
28- / f"verify_homepage_{ datetime .now ().strftime ('%Y%m%d_%H%M%S' )} .png"
29- )
30- await page .screenshot (path = str (screenshot_path ), full_page = True )
31- print (f"Screenshot saved to: { screenshot_path } " , file = sys .stderr )
21+ # Step 1: Check if account can be logged in
22+ print ("Step 1: Verifying account login..." , file = sys .stderr )
23+ await page .goto ("http://34.143.228.182:9999/" , wait_until = "networkidle" )
3224
3325 # Check if already logged in
3426 user_button = page .locator ('button:has-text("RoutineTracker2025")' )
@@ -51,169 +43,102 @@ async def verify() -> bool:
5143 # Check if login successful
5244 user_button = page .locator ('button:has-text("RoutineTracker2025")' )
5345 if not await user_button .count ():
54- print ("Error: Login failed for RoutineTracker2025" , file = sys .stderr )
46+ print ("Error: Account login failed for RoutineTracker2025" , file = sys .stderr )
5547 return False
5648
57- print ("Successfully logged in as RoutineTracker2025" , file = sys .stderr )
58-
59- # Take a screenshot after successful login
60- screenshot_path = (
61- screenshot_dir
62- / f"verify_after_login_{ datetime .now ().strftime ('%Y%m%d_%H%M%S' )} .png"
63- )
64- await page .screenshot (path = str (screenshot_path ), full_page = True )
65- print (
66- f"Screenshot after login saved to: { screenshot_path } " ,
67- file = sys .stderr ,
68- )
49+ print ("✓ Account login successful" , file = sys .stderr )
50+ else :
51+ print ("✓ Already logged in as RoutineTracker2025" , file = sys .stderr )
6952
70- # Navigate to user submissions page to check for the post
53+ # Step 2: Check if the post exists in LifeProTips forum with correct content
54+ print ("Step 2: Verifying post in LifeProTips forum..." , file = sys .stderr )
7155 await page .goto (
72- "http://35.247.158.69:9999/user/RoutineTracker2025/submissions" ,
73- wait_until = "networkidle" ,
74- )
75-
76- # Check if the post with the exact title exists
77- expected_title = (
78- "My 5-Step Morning Routine That Increased My Productivity by 200%"
79- )
80- post_title_link = page .locator (f'h1 a:has-text("{ expected_title } ")' )
81- if not await post_title_link .count ():
82- print (
83- f"Error: Post with title '{ expected_title } ' not found in user submissions" ,
84- file = sys .stderr ,
85- )
86- return False
87-
88- print ("User submission verified successfully" , file = sys .stderr )
89-
90- # Navigate to LifeProTips forum
91- await page .goto (
92- "http://35.247.158.69:9999/f/LifeProTips" , wait_until = "networkidle"
56+ "http://34.143.228.182:9999/f/LifeProTips" , wait_until = "networkidle"
9357 )
9458
9559 # Check for the created post
96- post_title = (
97- "My 5-Step Morning Routine That Increased My Productivity by 200%"
98- )
99- post_link = page .locator (f'a:has-text("{ post_title } ")' )
60+ expected_title = "My 5-Step Morning Routine That Increased My Productivity by 200%"
61+ post_link = page .locator (f'a:has-text("{ expected_title } ")' )
62+
10063 if not await post_link .count ():
101- print (
102- f"Error: Post with title '{ post_title } ' not found" , file = sys .stderr
103- )
64+ print (f"Error: Post with title '{ expected_title } ' not found in LifeProTips forum" , file = sys .stderr )
10465 return False
10566
10667 # Click on the post to verify content
10768 await post_link .click ()
10869 await page .wait_for_load_state ("networkidle" )
10970
110- # Verify post content
111- expected_content = """After years of struggling with mornings, I discovered these 5 steps:"" "
71+ # Verify post content - this should be the content from the most upvoted comment of the calendar post
72+ expected_content = "As a college student, having a visible reminder of the assignments I have and when they are due is super helpful for me. It also just feels good to erase them from the board once they are completed. "
11273
11374 # Check if the content exists in the page
11475 content_found = False
115- paragraphs = await page .locator ("article p" ).all ()
116- for p in paragraphs :
117- text = await p .text_content ()
118- if text and expected_content in text :
119- content_found = True
120- break
76+ article_content = await page .locator ("article" ).text_content ()
77+ if article_content and expected_content in article_content :
78+ content_found = True
12179
12280 if not content_found :
123- print (
124- "Error: Post content does not match expected content" ,
125- file = sys .stderr ,
126- )
81+ print (f"Error: Post content does not match expected content" , file = sys .stderr )
82+ print (f"Expected: { expected_content } " , file = sys .stderr )
12783 return False
12884
129- # Navigate back to LifeProTips to check upvoted posts
130- await page .goto (
131- "http://35.247.158.69:9999/f/LifeProTips" , wait_until = "networkidle"
132- )
85+ print ("✓ Post found in LifeProTips with correct title and content" , file = sys .stderr )
13386
134- # Define expected upvote counts after upvoting
135- # Note: In the test environment, all upvoted posts show "1"
136- expected_upvotes = {
137- "calendar" : {
138- "title" : "Use your calendar as your to-do list" ,
139- "expected_count" : "1" , # After upvoting, shows 1
140- "comments" : "179 comments" ,
141- },
142- "stovetop" : {
143- "title" : "clean your stovetop after using the oven" ,
144- "expected_count" : "1" , # After upvoting, shows 1
145- },
146- }
147-
148- # Check all posts for upvotes
87+ # Step 3: Check upvotes via search
88+ print ("Step 3: Verifying upvotes on posts..." , file = sys .stderr )
89+
90+ # Check first post upvote
91+ search_url1 = "http://34.143.228.182:9999/search?q=LPT%3A+Use+your+calendar+as+your+to-do+list.+Assigning+dedicated+time+to+tasks+increases+the+likelyhood+of+you+acting+upon+it."
92+ await page .goto (search_url1 , wait_until = "networkidle" )
93+
94+ # Find the post and check its upvote count
14995 posts = await page .locator ("article" ).all ()
150- verification_results = {}
151-
152- for post_key , post_info in expected_upvotes .items ():
153- found = False
154- for post in posts :
155- title_elem = post .locator ("h1 a" )
156- if await title_elem .count ():
157- title = await title_elem .text_content ()
158- if post_info ["title" ] in title :
159- # For calendar post, also verify comments
160- if post_key == "calendar" :
161- comments = post .locator (
162- f'text="{ post_info ["comments" ]} "'
163- )
164- if not await comments .count ():
165- continue
166-
167- # Get upvote count - look for the vote count element
168- # Try multiple selectors for vote count
169- vote_count = None
170-
171- # Try 1: Look for span with class vote__net-score
172- vote_count_elem = post .locator ("span.vote__net-score" )
173- if await vote_count_elem .count ():
174- vote_count = await vote_count_elem .text_content ()
175- else :
176- # Try 2: Look for generic element in the vote area
177- vote_generic = post .locator (
178- ".submission__vote generic"
179- ).nth (1 )
180- if await vote_generic .count ():
181- vote_count = await vote_generic .text_content ()
182-
183- if vote_count :
184- vote_count = vote_count .strip ()
185-
186- if vote_count == post_info ["expected_count" ]:
187- verification_results [post_key ] = True
188- print (
189- f"✓ { post_key } post upvoted successfully (count: { vote_count } )"
190- )
191- else :
192- print (
193- f"Error: { post_key } post has { vote_count } upvotes, expected exactly { post_info ['expected_count' ]} " ,
194- file = sys .stderr ,
195- )
196- return False
197- else :
198- print (
199- f"Error: Could not find vote count for { post_key } post" ,
200- file = sys .stderr ,
201- )
202- return False
203-
204- found = True
205- break
206-
207- if not found :
208- print (f"Error: { post_key } post not found" , file = sys .stderr )
209- return False
96+ calendar_upvoted = False
97+
98+ for post in posts :
99+ title_elem = post .locator ("h1 a" )
100+ if await title_elem .count ():
101+ title = await title_elem .text_content ()
102+ if "Use your calendar as your to-do list" in title :
103+ # Check upvote count
104+ vote_count_elem = post .locator ("span.vote__net-score" )
105+ if await vote_count_elem .count ():
106+ vote_count = await vote_count_elem .text_content ()
107+ if vote_count and vote_count .strip () == "1" :
108+ calendar_upvoted = True
109+ print ("✓ Calendar post upvoted (count: 1)" , file = sys .stderr )
110+ break
111+
112+ if not calendar_upvoted :
113+ print ("Error: Calendar post not upvoted or upvote count is not 1" , file = sys .stderr )
114+ return False
210115
211- # Verify all posts were upvoted
212- if len (verification_results ) != 2 or not all (verification_results .values ()):
213- print ("Error: Not all posts were upvoted correctly" , file = sys .stderr )
116+ # Check second post upvote
117+ search_url2 = "http://34.143.228.182:9999/search?q=LPT%3A+clean+your+stovetop+after+using+the+oven.+The+heat+loosens+grime+for+easy+removal"
118+ await page .goto (search_url2 , wait_until = "networkidle" )
119+
120+ posts = await page .locator ("article" ).all ()
121+ stovetop_upvoted = False
122+
123+ for post in posts :
124+ title_elem = post .locator ("h1 a" )
125+ if await title_elem .count ():
126+ title = await title_elem .text_content ()
127+ if "clean your stovetop after using the oven" in title :
128+ # Check upvote count
129+ vote_count_elem = post .locator ("span.vote__net-score" )
130+ if await vote_count_elem .count ():
131+ vote_count = await vote_count_elem .text_content ()
132+ if vote_count and vote_count .strip () == "1" :
133+ stovetop_upvoted = True
134+ print ("✓ Stovetop post upvoted (count: 1)" , file = sys .stderr )
135+ break
136+
137+ if not stovetop_upvoted :
138+ print ("Error: Stovetop post not upvoted or upvote count is not 1" , file = sys .stderr )
214139 return False
215140
216- print ("Success: Daily routine tracking setup completed successfully. " )
141+ print ("Success: All verification steps passed! " )
217142 return True
218143
219144 except PlaywrightTimeoutError as e :
0 commit comments