From 4012180cecd582d7aa1444585cad58a84eb2617c Mon Sep 17 00:00:00 2001 From: otsegelnyk Date: Tue, 29 Sep 2026 12:24:58 +0300 Subject: [PATCH 1/2] Fix sorting and filtering tests that passed without verifying anything Sorting (search + profile): - getDates used the label `Date "created"` (literal quotes, carried over from the Python suite), which matches nothing, so every created-date sort check compared an empty list. Use the real card labels; mixed-type All tabs read both "Date created" and "Date registered". - Dates were read right after picking a sort option, while the list is still empty. applySort now waits for the index-card-search response with the matching `sort` param before reading. - assertSorting requires at least two dates and getDates rejects unparseable ones, so an empty or broken read fails instead of passing. - Tabs with fewer than two results skip visibly instead of passing. - Users tab cards show no dates, so those two tests now check that each sort option sends the matching SHARE sort request. - Profile preprints tab used the "registered" label; its cards show "Date created". Filtering: - Resource type: select the option by exact name and check the filter chip. The card check is limited to the first card's "Resource type:" line. Registration cards don't show a resource type, so there it relies on the chip and the result count. Previously it picked whichever option came first and looked for any "Registration" text, which every badge on that tab already matches. - All-tab resource type: every card's type badge must match, instead of any one Preprint card being visible, which is already true unfiltered. - Creator / users institution: every result card must contain the value; the old "visible somewhere" check passed on the unfiltered page. - Clearing: compare the filtered count to the option's count, not the unfiltered total. Sort and clearing tests switch tabs through openTab, which waits for the tab's own search response. Otherwise they could read the previous tab's result count. Co-Authored-By: Claude Opus 5.5 --- src/pages/BasePage.ts | 27 +++++-- src/pages/SearchPage.ts | 152 ++++++++++++++++++++++++++++++++-------- tests/profile.spec.ts | 36 +++++----- tests/search.spec.ts | 58 +++++++++------ 4 files changed, 196 insertions(+), 77 deletions(-) diff --git a/src/pages/BasePage.ts b/src/pages/BasePage.ts index a1bbd34..aea42a4 100644 --- a/src/pages/BasePage.ts +++ b/src/pages/BasePage.ts @@ -46,15 +46,32 @@ export abstract class BasePage { } - async getDates(labelText: string): Promise { - const texts = await this.page - .locator('p', { hasText: `${labelText}:` }) - .allInnerTexts(); - return texts.map((text) => new Date(text.replace(`${labelText}: `, '').trim())); + /** + * Reads every "