|
17 | 17 | import time |
18 | 18 | import json |
19 | 19 | import requests |
20 | | -from playwright.sync_api import Keyboard, Mouse |
| 20 | +from playwright.sync_api import Keyboard, Mouse, expect |
21 | 21 |
|
22 | 22 |
|
23 | 23 | class LuteTestClient: # pylint: disable=too-many-public-methods |
@@ -159,9 +159,11 @@ def get_book_table_content(self): |
159 | 159 | # - "last opened" date is a hassle to check |
160 | 160 | # - "actions" is just "..." |
161 | 161 | ret = "; ".join(rowtext[:-2]).strip() |
| 162 | + # Hacky cleanup ok for tests. |
| 163 | + ret = ret.replace("\u200B", "").replace("\n", "").replace("\\n", "") |
162 | 164 | content.append(ret) |
163 | 165 |
|
164 | | - return "\n".join(content) |
| 166 | + return "\n".join([c for c in content if c.strip() != ""]).strip() |
165 | 167 |
|
166 | 168 | def get_book_page_start_dates(self): |
167 | 169 | "get content from sql check" |
@@ -219,9 +221,17 @@ def _fill_tagify_field(self, frame, fieldid, text): |
219 | 221 | if span is None: |
220 | 222 | raise RuntimeError(f"unable to find {fieldid}") |
221 | 223 |
|
222 | | - # Focus the span and type text |
| 224 | + # Focus the span and type text. Various timing hacks added to |
| 225 | + # ensure that tagify wires things up correctly in response to |
| 226 | + # clicks ... hacky, but fixed errors during ci runs. |
| 227 | + expect(span).to_be_visible() |
| 228 | + expect(span).to_be_enabled() |
223 | 229 | span.click() |
224 | | - span.type(text) |
| 230 | + time.sleep(0.1) |
| 231 | + expect(span).to_be_focused() |
| 232 | + time.sleep(0.1) |
| 233 | + span.fill(text) |
| 234 | + time.sleep(0.1) |
225 | 235 | span.press("Enter") |
226 | 236 | time.sleep(0.3) |
227 | 237 |
|
@@ -320,6 +330,7 @@ def get_term_table_content(self): |
320 | 330 |
|
321 | 331 | def _delimited_tags(td): |
322 | 332 | """Get the cleaned tags.""" |
| 333 | + # print(f"GOT RAW TAGS = {td.inner_text()}", flush=True) |
323 | 334 | tags = [t.strip() for t in td.inner_text().split("\n")] |
324 | 335 | tags = [t for t in tags if t not in ["", "\u200B"]] |
325 | 336 | return ", ".join(tags) |
@@ -353,11 +364,17 @@ def _delimited_tags(td): |
353 | 364 | ) |
354 | 365 | rowtext.append(selected_text) |
355 | 366 |
|
| 367 | + # Hacky cleanup, ok for tests. |
| 368 | + # print(f"RAW ROWTEXT = {rowtext}", flush=True) |
| 369 | + rowtext = [ |
| 370 | + r.replace("\u200B", "").replace("\n", "").replace("\\n", "") |
| 371 | + for r in rowtext |
| 372 | + ] |
356 | 373 | rowval = "; ".join(rowtext).strip() |
357 | | - cleaned_rowval = rowval.replace("\u200B", "") |
358 | | - rowstring.append(cleaned_rowval) |
| 374 | + rowstring.append(rowval) |
359 | 375 |
|
360 | | - return "\n".join(rowstring) |
| 376 | + # print(f"RAW ROWSTRINGs = {rowstring}", flush=True) |
| 377 | + return "\n".join([r for r in rowstring if r.strip() != ""]).strip() |
361 | 378 |
|
362 | 379 | ################################3 |
363 | 380 | # Reading/rendering |
|
0 commit comments