Skip to content

Commit

Permalink
CI: Fix flushVisibleEntries Acceptance Test (#1044)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasnorre authored Mar 11, 2024
1 parent f515e8b commit c2c702c
Show file tree
Hide file tree
Showing 7 changed files with 1,072 additions and 1,423 deletions.
1 change: 1 addition & 0 deletions .devbox/.ddev/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ hooks:
- exec: /var/www/html/bin/typo3 cache:flush
- exec: /var/www/html/bin/typo3 cache:warmup
- exec: /var/www/html/bin/typo3 backend:unlock
- exec: mkdir -p /var/www/html/var/lock
omit_containers: [ dba, ddev-ssh-agent ]
webimage_extra_packages: [ cron ]
use_dns_when_possible: true
Expand Down
3 changes: 0 additions & 3 deletions .devbox/.ddev/docker-compose.selenium.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# To execute this docker-compose yml file use `docker-compose -f docker-compose-v3-beta-channel.yml up`
# Add the `-d` flag at the end for detached execution
# To stop the execution, hit Ctrl+C, and then `docker-compose -f docker-compose-v3-beta-channel.yml down`
version: "3"
services:
chrome:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/Acceptance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
sed -i "s|$FROM_PATH|$TO_PATH|g" .ddev/docker-compose.volume.yaml
ddev restart
rm -rf vendor composer.lock
ddev composer require typo3/cms-core=${{ matrix.typo3 }}
ddev composer require typo3/cms-core=${{ matrix.typo3 }} tomasnorre/crawler=dev-$BRANCH_NAME
ddev exec sudo apt remove -y php${{ matrix.php }}-uploadprogress
ddev exec bin/typo3 backend:lock
ddev exec bin/typo3 extension:setup
Expand Down
383 changes: 210 additions & 173 deletions Resources/Private/Templates/Backend/ShowLog.html

Large diffs are not rendered by default.

31 changes: 20 additions & 11 deletions Tests/Acceptance/BackendModule/BackendModuleCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* The TYPO3 project - inspiring people to share!
*/

use AOE\Crawler\Tests\Acceptance\Support\Helper\ModalDialog;
use AOE\Crawler\Tests\Acceptance\Support\Helper\PageTree;
use AOE\Crawler\Tests\Acceptance\Support\Step\Acceptance\Admin;
use Step\Acceptance\BackendModule;
Expand Down Expand Up @@ -196,30 +197,38 @@ public function crawlerUrlsContinueAndShowLogCheckDepthDropdown(
$I->waitForText('https://crawler-devbox.ddev.site/access-restricted-page', 10);
}

public function flushVisibleEntries(BackendModule $I, Admin $adminStep, PageTree $pageTree): void
{
public function flushVisibleEntries(
BackendModule $I,
Admin $adminStep,
PageTree $pageTree,
ModalDialog $modalDialog
): void {
// Will test twice, but done to avoid duplicate code
$this->crawlerUrlsContinueAndShowLogCheckDepthDropdown($I, $adminStep, $pageTree);
$I->click('Flush entire queue');
$I->switchToMainFrame();
$I->seeInPopup('Are you sure?');
$I->click('OK');
$I->switchToContentFrame();
$I->wait(3);
$modalDialog->canSeeDialog();
$modalDialog->clickButtonInDialog('OK');
$I->wait(1);
$I->canSeeNumberOfElements('a.refreshLink', 0);
$this->crawlerUrlsContinueAndShowLogCheckDepthDropdown($I, $adminStep, $pageTree);
$I->canSeeNumberOfElements('a.refreshLink', 9);
$I->selectOption('logDisplay', 'Finished');
$I->selectOption('displayLog', 'Finished');
$I->canSeeNumberOfElements('a.refreshLink', 0);
$I->click('Flush visible entries');
$I->acceptPopup();
$I->wait(3);
$I->selectOption('logDisplay', 'All');
$modalDialog->canSeeDialog();
$modalDialog->clickButtonInDialog('OK');
$I->wait(1);
$I->switchToContentFrame();
$I->selectOption('displayLog', 'All');
$I->canSeeNumberOfElements('a.refreshLink', 9);
$I->selectOption('logDisplay', 'Pending');
$I->selectOption('displayLog', 'Pending');
$I->click('Flush visible entries');
$I->acceptPopup();
$I->wait(3);
$modalDialog->canSeeDialog();
$modalDialog->clickButtonInDialog('OK');
$I->wait(1);
$I->canSeeNumberOfElements('a.refreshLink', 0);
}

Expand Down
86 changes: 86 additions & 0 deletions Tests/Acceptance/Support/Helper/ModalDialog.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php

declare(strict_types=1);

/*
* (c) 2024- Tomas Norre Mikkelsen <[email protected]>
*
* This file is part of the TYPO3 Crawler Extension.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

/**
* This is copied from
* https://github.com/TYPO3/typo3/blob/main/typo3/sysext/core/Tests/Acceptance/Support/Helper/ModalDialog.php
*/

namespace AOE\Crawler\Tests\Acceptance\Support\Helper;

use AcceptanceTester;
use TYPO3\TestingFramework\Core\Acceptance\Helper\AbstractModalDialog;

final class ModalDialog extends AbstractModalDialog
{
/**
* Selector for a visible modal window
* Adapted for Boostrap 5
*
* @var string
*/
public static $openedModalSelector = '.modal.show';

/**
* Selector for the container in the modal where the buttons are located
* Adapted for Boostrap 5
*
* @var string
*/
public static $openedModalButtonContainerSelector = '.modal.show .modal-footer';

/**
* @var AcceptanceTester
*/
protected $tester;

/**
* Inject our core AcceptanceTester actor into ModalDialog
*/
public function __construct(AcceptanceTester $I)
{
$this->tester = $I;
}

/**
* Perform a click on a link or a button, given by a locator.
*
* @param string $buttonLinkLocator the button title
* @see \Codeception\Module\WebDriver::click()
*/
public function clickButtonInDialog(string $buttonLinkLocator): void
{
$I = $this->tester;
$this->canSeeDialog();
$I->click($buttonLinkLocator, self::$openedModalButtonContainerSelector);
$I->waitForElementNotVisible(self::$openedModalSelector);
}

/**
* Check if modal dialog is visible in top frame
*/
public function canSeeDialog(): void
{
$I = $this->tester;
$I->switchToIFrame();
$I->waitForElement(self::$openedModalSelector);
// I will wait two seconds to prevent failing tests
$I->wait(2);
}
}
Loading

0 comments on commit c2c702c

Please sign in to comment.