Review main Merged

85744[TASK] Stabilize FileClipboardCest by checking for content-iframe reload

Ayke Halder CR +2 V +2 Easy +10 −0 updated 09/15/24, 03:20

Commit message

This makes FileClipboardCest check if the content-iframe is reloaded
before clicking on a button to open a dropdown-menu.

Before this change the button click and opening of the dropdown-menu
did sporadically happen in the old iframe-content - and before the
iframe-reload.
As soon as the iframe reloads, the popup-menu is closed again. The
subsequent click on a dropdown-menu-entry therefore fails.

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
    • Garvin Hicking +1
    • Christian Kuhn +1
  • Verified V +2 Done
    • Stefan Bürk +2
    • Garvin Hicking +1
    • Christian Kuhn +1
    • core-ci +1 CI

Issues 3

Files 1

Review log 1419

  1. Ayke Halder uploaded patch set 1 08/23/24, 09:21

  2. core-ci voted on patch set 1 V +1 08/23/24, 09:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/64056

  3. Ayke Halder updated the commit message in patch set 2 V +1 08/23/24, 09:38

  4. core-ci voted on patch set 2 V -1 08/23/24, 09:47 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/64058

  5. Ayke Halder rebased onto patch set 3 V -1 08/23/24, 10:03

  6. core-ci voted on patch set 3 V +1 08/23/24, 10:08 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/64061

  7. Andreas Kienast commented on patch set 3 08/23/24, 11:10

    FileClipboardCest.php:80

    Instead of doing a hard-coded `wait()`, can we use `waitForElementNotVisible()` instead? IMO this should be true for a short period.
  8. Ayke Halder commented on patch set 3 08/23/24, 13:04

    FileClipboardCest.php:80 Reply

    I'm not sure if `waitForElementNotVisible()` really checks continously or only checks periodically. https://github.com/Codeception/module-webdriver/blob/ef0ea8044eb01dc1e830df27fe431e71440a462f/src/Codeception/Module/WebDriver.php#L2624-L2641 ```php public function waitForElementNotVisible($element, int $timeout = 10): void { $condition = WebDriverExpectedCondition::invisibilityOfElementLocated($this->getLocator($element)); $this->webDriver->wait($timeout)->until($condition); } ``` The time window to get the non-visible element is really small: after http-response with new html code is received, the browser trashes the old html-document and displays the newly received document. The actual change of url/document is triggered by: https://github.com/TYPO3/typo3/blob/82eb6bcb0709a8bf94a098e03ea72f9b2f984bbd/Build/Sources/TypeScript/backend/clipboard-panel.ts#L227-L234 ```js private reloadModule (): void { if (this.returnUrl) { this.ownerDocument.location.href = this.returnUrl; } else { this.ownerDocument.location.reload(); } } } ``` ---- Nevertheless let's try our luck here and go for `waitForElementNotVisible()`.
  9. Ayke Halder commented on patch set 3 08/23/24, 13:22

    IMO it only works with hard-coded `wait()` here.

    FileClipboardCest.php:80 Reply

    This fails: ```php $I->amGoingTo('add multiple elements to clipboard'); $I->wait(1); $I->waitForElementVisible('.t3js-multi-record-selection-check-actions-toggle'); $I->click('Clipboard #1 (multi-selection mode)'); // Click reloads iframe: wait for iframe to be reloaded before going on. $I->waitForElementNotVisible('.t3js-multi-record-selection-check-actions-toggle'); $I->waitForElementVisible('.t3js-multi-record-selection-check-actions-toggle'); $I->click('.t3js-multi-record-selection-check-actions-toggle'); ``` ``` There was 1 error: 1) FileClipboardCest: See add remove multiple records Test Acceptance/Application/FileList/FileClipboardCest.php:seeAddRemoveMultipleRecords [Facebook\WebDriver\Exception\TimeoutException] Scenario Steps: 14. $I->waitForElementNotVisible(".t3js-multi-record-selection-check-actions-toggle") at Acceptance/Application/FileList/FileClipboardCest.php:82 13. $I->click("Clipboard #1 (multi-selection mode)") at Acceptance/Application/FileList/FileClipboardCest.php:80 12. $I->waitForElementVisible(".t3js-multi-record-selection-check-actions-toggle") at Acceptance/Application/FileList/FileClipboardCest.php:79 11. $I->wait(1) at Acceptance/Application/FileList/FileClipboardCest.php:77 10. // I am going to add multiple elements to clipboard ``` So the element is already non-visible in my local environment. **Conclusion:** IMO it only works with hard-coded `wait()` here.
  10. Ayke Halder uploaded patch set 4 V +1 08/23/24, 15:56

  11. core-ci voted on patch set 4 V +1 08/23/24, 16:02 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/64089

  12. Ayke Halder commented on patch set 4 08/23/24, 16:13

    Make this work without a hard-coded `wait()`.

    FileClipboardCest.php:80 Reply

    I might have found a hacky way to make this work without a hard-coded `wait()`. ```php // Flag current iframe content as old. $I->waitForJS('return document.cestIsOldPage = true;'); // Click reloads iframe. $I->click('Clipboard #1 (multi-selection mode)'); // Check that the iframe does not have the old content anymore. $I->waitForJS('return !("cestIsOldPage" in document);'); // Wait for 'Clipboard #1' as it is one of the last activated elements on page. $I->waitForText('Clipboard #1 (multi-selection mode)'); ```
  13. core-ci commented on patch set 4 08/23/24, 19:29 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/64101

  14. Christian Kuhn voted on patch set 4 CR +1 V +1 09/09/24, 14:11

  15. Stefan Bürk voted on patch set 4 CR +1 V +1 09/09/24, 14:53

  16. Garvin Hicking commented on patch set 4 CR +1 V +1 09/12/24, 16:27

    what could possibl
  17. Stefan Bürk commented on patch set 4 09/15/24, 00:33

    Reply

    ...e go wrong ?
  18. Stefan Bürk voted on patch set 4 CR +2 V +2 09/15/24, 03:20

  19. Stefan Bürk merged patch set 5 09/15/24, 03:20