Skip to content

Commit bbdd207

Browse files
test: update expected item count in HomePageTest to reflect correct UI behavior
1 parent 9a574ef commit bbdd207

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

tests/test_home_page.py

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,7 @@ def test_us01_add_single_valid_grade(self, request=None): # request might not be
207207
percentage_to_add = "25"
208208
self._add_grade_and_percentage(grade_to_add, percentage_to_add)
209209

210-
# Wait for the item count to increase reflecting the two new rows added
211-
expected_count_after_add = initial_item_count + 2
210+
expected_count_after_add = initial_item_count + 1 # Changed from +2 to +1
212211
try:
213212
self.wait_long.until(
214213
lambda d: self._get_grades_list_item_count() == expected_count_after_add
@@ -221,7 +220,7 @@ def test_us01_add_single_valid_grade(self, request=None): # request might not be
221220
logger.info(f"Current grade item count after add: {current_item_count}")
222221
try:
223222
self.assertEqual(current_item_count, expected_count_after_add,
224-
f"Grade item count did not increase by 2. Initial: {initial_item_count}, Expected: {expected_count_after_add}, Current: {current_item_count}")
223+
f"Grade item count did not increase by 1. Initial: {initial_item_count}, Expected: {expected_count_after_add}, Current: {current_item_count}")
225224
except AssertionError as e:
226225
self._take_screenshot(f"{test_name}_assertion_failed")
227226
raise e
@@ -243,19 +242,18 @@ def test_us01_add_multiple_valid_grades(self, request=None):
243242

244243
for i, item in enumerate(grades_data):
245244
self._add_grade_and_percentage(item["grade"], item["percentage"])
246-
expected_count_after_item_add = initial_item_count + 2 * (i + 1)
245+
expected_count_after_item_add = initial_item_count + (i + 1) # Changed from +2*(i+1) to +(i+1)
247246
try:
248-
# Wait for the item count to reflect the new addition
249247
self.wait_long.until(
250248
lambda d: self._get_grades_list_item_count() == expected_count_after_item_add
251249
)
252250
except TimeoutException:
253251
self._take_screenshot(f"{test_name}_timeout_item_{i+1}")
254252
logger.error(f"Timeout waiting for grade item count to be {expected_count_after_item_add} after adding item {i+1}.")
255253

256-
time.sleep(0.2)
254+
time.sleep(0.2)
257255

258-
expected_final_count = initial_item_count + 2 * len(grades_data)
256+
expected_final_count = initial_item_count + len(grades_data) # Changed from +2*len() to +len()
259257
current_item_count = self._get_grades_list_item_count()
260258
logger.info(f"Current grade item count after multiple adds: {current_item_count}")
261259
try:
@@ -271,68 +269,68 @@ def test_us01_validate_grade_input_below_range(self, request=None):
271269
logger.info(f"Running test: {test_name}")
272270

273271
initial_item_count = self._get_grades_list_item_count()
274-
self._add_grade_and_percentage("-1.0", "20") # Invalid grade value, but fills fields
272+
self._add_grade_and_percentage("-1.0", "20")
275273

276-
expected_count = initial_item_count + 2 # Row count increases due to UI behavior
274+
expected_count = initial_item_count + 1 # Changed from +2 to +1
277275
current_item_count = self._get_grades_list_item_count()
278276
try:
279277
self.assertEqual(current_item_count, expected_count,
280-
f"Grade item count should increase by 2 even for invalid grade input (UI behavior). Initial: {initial_item_count}, Expected: {expected_count}, Current: {current_item_count}")
278+
f"Grade item count should increase by 1 (UI behavior). Initial: {initial_item_count}, Expected: {expected_count}, Current: {current_item_count}")
281279
except AssertionError as e:
282280
self._take_screenshot(f"{test_name}_assertion_failed")
283281
raise e
284-
logger.info(f"Test {test_name} completed (note: row count increased as expected by UI; value validation is separate).")
282+
logger.info(f"Test {test_name} completed.")
285283

286284
def test_us01_validate_grade_input_above_range(self, request=None):
287285
test_name = request.node.name if request else self._testMethodName
288286
logger.info(f"Running test: {test_name}")
289287

290288
initial_item_count = self._get_grades_list_item_count()
291-
self._add_grade_and_percentage("8.0", "20") # Invalid grade value, but fills fields
289+
self._add_grade_and_percentage("8.0", "20")
292290

293-
expected_count = initial_item_count + 2 # Row count increases due to UI behavior
291+
expected_count = initial_item_count + 1 # Changed from +2 to +1
294292
current_item_count = self._get_grades_list_item_count()
295293
try:
296294
self.assertEqual(current_item_count, expected_count,
297-
f"Grade item count should increase by 2 even for invalid grade input (UI behavior). Initial: {initial_item_count}, Expected: {expected_count}, Current: {current_item_count}")
295+
f"Grade item count should increase by 1 (UI behavior). Initial: {initial_item_count}, Expected: {expected_count}, Current: {current_item_count}")
298296
except AssertionError as e:
299297
self._take_screenshot(f"{test_name}_assertion_failed")
300298
raise e
301-
logger.info(f"Test {test_name} completed (note: row count increased as expected by UI; value validation is separate).")
299+
logger.info(f"Test {test_name} completed.")
302300

303301
def test_us01_validate_percentage_input_negative(self, request=None):
304302
test_name = request.node.name if request else self._testMethodName
305303
logger.info(f"Running test: {test_name}")
306304

307305
initial_item_count = self._get_grades_list_item_count()
308-
self._add_grade_and_percentage("4.0", "-10") # Invalid percentage value, but fills fields
306+
self._add_grade_and_percentage("4.0", "-10")
309307

310-
expected_count = initial_item_count + 2 # Row count increases due to UI behavior
308+
expected_count = initial_item_count + 1 # Changed from +2 to +1
311309
current_item_count = self._get_grades_list_item_count()
312310
try:
313311
self.assertEqual(current_item_count, expected_count,
314-
f"Grade item count should increase by 2 even for invalid percentage input (UI behavior). Initial: {initial_item_count}, Expected: {expected_count}, Current: {current_item_count}")
312+
f"Grade item count should increase by 1 (UI behavior). Initial: {initial_item_count}, Expected: {expected_count}, Current: {current_item_count}")
315313
except AssertionError as e:
316314
self._take_screenshot(f"{test_name}_assertion_failed")
317315
raise e
318-
logger.info(f"Test {test_name} completed (note: row count increased as expected by UI; value validation is separate).")
316+
logger.info(f"Test {test_name} completed.")
319317

320318
def test_us01_validate_percentage_input_non_numeric(self, request=None):
321319
test_name = request.node.name if request else self._testMethodName
322320
logger.info(f"Running test: {test_name}")
323321

324322
initial_item_count = self._get_grades_list_item_count()
325-
self._add_grade_and_percentage("4.0", "abc") # Non-numeric percentage, but fills fields
323+
self._add_grade_and_percentage("4.0", "abc")
326324

327-
expected_count = initial_item_count + 2 # Row count increases due to UI behavior
325+
expected_count = initial_item_count + 1 # Changed from +2 to +1
328326
current_item_count = self._get_grades_list_item_count()
329327
try:
330328
self.assertEqual(current_item_count, expected_count,
331-
f"Grade item count should increase by 2 even for non-numeric percentage input (UI behavior). Initial: {initial_item_count}, Expected: {expected_count}, Current: {current_item_count}")
329+
f"Grade item count should increase by 1 (UI behavior). Initial: {initial_item_count}, Expected: {expected_count}, Current: {current_item_count}")
332330
except AssertionError as e:
333331
self._take_screenshot(f"{test_name}_assertion_failed")
334332
raise e
335-
logger.info(f"Test {test_name} completed (note: row count increased as expected by UI; value validation is separate).")
333+
logger.info(f"Test {test_name} completed.")
336334

337335
# ...existing code...
338336
if __name__ == '__main__':

0 commit comments

Comments
 (0)