[DON'T MERGE - POC] IBX-11739: Added playwright tests for Trash - #1947
[DON'T MERGE - POC] IBX-11739: Added playwright tests for Trash#1947pawlakadrian wants to merge 10 commits into
Conversation
| on: | ||
| push: | ||
| branches: | ||
| - main |
There was a problem hiding this comment.
Good catch — removed.
| export class ContentManagementPage extends AdminUiPage { | ||
| readonly udw: UniversalDiscoveryWidget; | ||
|
|
||
| constructor(page: Page) { |
There was a problem hiding this comment.
I would add all css locators to the constructor, so they can be reused and code looks cleaner.
On the other hand - sometimes getBy locators are used, is it possible to switch completely to getBy locators? Copilot suggests something like:
Element | Preferred locator
Button | getByRole()
Link | getByRole()
Checkbox | getByRole()
Text field | getByLabel()
Image | getByAltText()
Static text | getByText()
Custom component | getByTestId()
Loading spinner | CSS
Overlay | CSS
Toast | CSS or getByTestId()
Animation | CSS
There was a problem hiding this comment.
Done. Locators are now hoisted to readonly fields / factory methods so each selector is defined once, and switched to getByRole/getByText
There was a problem hiding this comment.
This page file seems like a mix of different pages and components in Behat notation and some code overlaps with https://github.com/ibexa/cohesivo-playwright/blob/5.0/src/pages/admin/AdminUiPage.ts - .ie https://github.com/ibexa/cohesivo-playwright/blob/5b13038a8e17b0b0e01c99d9d67b765f9e69ff12/src/pages/admin/AdminUiPage.ts#L22 and https://github.com/ibexa/admin-ui/pull/1947/changes#diff-46711842a811d22853c02fa9e2fee52d5502bf751dcae9f71e6994d45139d23eR87 do the same thing.
My recommendation is to scrap https://github.com/ibexa/cohesivo-playwright/blob/5.0/src/pages/admin/AdminUiPage.ts (leave maybe login stuff in ibexa/cohesivo-playwright as login stuff is also implemented in ibexa/behat) and to break this file into proper pages (as in behat admin-ui pages https://github.com/ibexa/admin-ui/tree/6.0/src/lib/Behat/Page).
There was a problem hiding this comment.
Refactored. Extracted the context-menu logic into a shared ContextMenu component in cohesivo-playwright
There was a problem hiding this comment.
What is ContextMenu equivalent in Behat? If we plan to build PW automation by converting tests from behat to PW we should stick to existing names.
| this.udw = new UniversalDiscoveryWidget(page); | ||
| } | ||
|
|
||
| async open(): Promise<void> { |
There was a problem hiding this comment.
Navigation between tabs should be done in specific page/component.
|
|
||
| async searchInTrash(query: string): Promise<void> { | ||
| const url = this.page.url().split('?')[0]; | ||
| await this.page.goto(`${url}?trash_search[content_name]=${encodeURIComponent(query)}`); |
There was a problem hiding this comment.
Does this code work the same as in behat? Is seems like it bypasses UI interaction by using page.goto()
In behat it looked like:
$this->trashSearch->submitSearchText($searchQuery); $this->trashSearch->confirmSearch();
so, add text to the input -> click search.
There was a problem hiding this comment.
Changed to navigation via UI already to make sure every step it's working fine.
23a2792 to
a005d77
Compare
|
| this.udw = new UniversalDiscoveryWidget(page); | ||
| this.contentActionsMenu = new ContentActionsMenu(page); | ||
|
|
||
| this.firstRow = page.locator('.ibexa-table__row').first(); |
There was a problem hiding this comment.
The empty-state row uses the same class as data rows (empty_table_body_row.html.twig:1: ), so this matches on an empty table too.
Verified on a live instance: right after emptyTrash(), with "Trash is empty…" on screen, .ibexa-table__row still counts 1 — and an extra assertNotEmpty() placed after emptyTrash() passes, i.e. it and assertEmpty() both succeed on the same state.
So in "Trash can be emptied" only the post-condition is tested; the precondition would pass even if "Send to trash" did nothing.
| this.firstRow = page.locator('.ibexa-table__row').first(); | |
| this.firstRow = page.locator('.ibexa-table__body .ibexa-table__row').filter({hasNot:page.locator('.ibexa-table__empty-table-cell') }).first(); |
| }); | ||
|
|
||
| test.afterAll(async () => { | ||
| await api.deleteContent(trashTestContentId); |
There was a problem hiding this comment.
Teardown runs even when beforeAll fails. Hit this locally: createFolder() didn't
return within the 30s hook timeout (slow APP_ENV=dev instance), so
trashTestContentId stayed undefined and got interpolated into the URL:
DELETE /api/ibexa/v2/content/objects/undefined → no route → HTTP 500 → full dev stack
trace in the response, burying the real error ("beforeAll" hook timeout of 30000ms exceeded).
| await api.deleteContent(trashTestContentId); | |
| if (api && trashTestContentId) { | |
| await api.deleteContent(trashTestContentId); | |
| } |




Related PRs:
Description:
Sets up Playwright testing for the admin-ui package using the shared cohesivo-playwright library.
For QA:
Documentation: