From 7cd373f4faffaef28451ed39131402a13936f62c Mon Sep 17 00:00:00 2001 From: buddh4 Date: Thu, 26 Jul 2018 17:14:51 +0200 Subject: [PATCH] Fixed tour humhub:ready listener not removed Added tour acceptance tests --- .../humhub/modules/tour/tests/codeception.yml | 24 ++++ .../tour/tests/codeception/_bootstrap.php | 49 ++++++++ .../tour/tests/codeception/_output/.gitignore | 4 + .../codeception/_support/AcceptanceTester.php | 26 ++++ .../codeception/_support/FunctionalTester.php | 26 ++++ .../tests/codeception/_support/UnitTester.php | 26 ++++ .../tests/codeception/acceptance.suite.yml | 21 ++++ .../tests/codeception/acceptance/TourCest.php | 114 ++++++++++++++++++ .../codeception/acceptance/_bootstrap.php | 6 + .../tests/codeception/config/functional.php | 3 + .../tour/tests/codeception/config/unit.php | 3 + .../tests/codeception/functional.suite.yml | 18 +++ .../codeception/functional/_bootstrap.php | 6 + .../tour/tests/codeception/unit.suite.yml | 14 +++ .../tests/codeception/unit/_bootstrap.php | 6 + .../modules/tour/tests/config/common.php | 5 + .../modules/tour/tests/config/functional.php | 5 + .../humhub/modules/tour/tests/config/test.php | 5 + .../humhub/modules/tour/tests/config/unit.php | 5 + .../widgets/views/guide_administration.php | 2 +- .../tour/widgets/views/guide_interface.php | 2 +- .../tour/widgets/views/guide_profile.php | 2 +- .../tour/widgets/views/guide_spaces.php | 2 +- .../tests/codeception/config/functional.php | 2 +- 24 files changed, 371 insertions(+), 5 deletions(-) create mode 100644 protected/humhub/modules/tour/tests/codeception.yml create mode 100644 protected/humhub/modules/tour/tests/codeception/_bootstrap.php create mode 100644 protected/humhub/modules/tour/tests/codeception/_output/.gitignore create mode 100644 protected/humhub/modules/tour/tests/codeception/_support/AcceptanceTester.php create mode 100644 protected/humhub/modules/tour/tests/codeception/_support/FunctionalTester.php create mode 100644 protected/humhub/modules/tour/tests/codeception/_support/UnitTester.php create mode 100644 protected/humhub/modules/tour/tests/codeception/acceptance.suite.yml create mode 100644 protected/humhub/modules/tour/tests/codeception/acceptance/TourCest.php create mode 100644 protected/humhub/modules/tour/tests/codeception/acceptance/_bootstrap.php create mode 100644 protected/humhub/modules/tour/tests/codeception/config/functional.php create mode 100644 protected/humhub/modules/tour/tests/codeception/config/unit.php create mode 100644 protected/humhub/modules/tour/tests/codeception/functional.suite.yml create mode 100644 protected/humhub/modules/tour/tests/codeception/functional/_bootstrap.php create mode 100644 protected/humhub/modules/tour/tests/codeception/unit.suite.yml create mode 100644 protected/humhub/modules/tour/tests/codeception/unit/_bootstrap.php create mode 100644 protected/humhub/modules/tour/tests/config/common.php create mode 100644 protected/humhub/modules/tour/tests/config/functional.php create mode 100644 protected/humhub/modules/tour/tests/config/test.php create mode 100644 protected/humhub/modules/tour/tests/config/unit.php diff --git a/protected/humhub/modules/tour/tests/codeception.yml b/protected/humhub/modules/tour/tests/codeception.yml new file mode 100644 index 0000000000..ac000bef7c --- /dev/null +++ b/protected/humhub/modules/tour/tests/codeception.yml @@ -0,0 +1,24 @@ +actor: Tester +namespace: tour +settings: + bootstrap: _bootstrap.php + suite_class: \PHPUnit_Framework_TestSuite + colors: true + shuffle: false + memory_limit: 1024M + log: true + + # This value controls whether PHPUnit attempts to backup global variables + # See https://phpunit.de/manual/current/en/appendixes.annotations.html#appendixes.annotations.backupGlobals + backup_globals: true +paths: + tests: codeception + log: codeception/_output + data: codeception/_data + helpers: codeception/_support + envs: ../../../tests/config/env +config: + # the entry script URL (with host info) for functional and acceptance tests + # PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL + test_entry_url: http://localhost:8080/index-test.php + \ No newline at end of file diff --git a/protected/humhub/modules/tour/tests/codeception/_bootstrap.php b/protected/humhub/modules/tour/tests/codeception/_bootstrap.php new file mode 100644 index 0000000000..080172d42a --- /dev/null +++ b/protected/humhub/modules/tour/tests/codeception/_bootstrap.php @@ -0,0 +1,49 @@ + 0) { + \Codeception\Configuration::append(['environment' => $env]); + + + $envCfgFile = dirname(__DIR__) . '/config/env/test.' . $env[0][0] . '.php'; + + if (file_exists($envCfgFile)) { + $cfg = array_merge(require_once(__DIR__ . '/../config/test.php'), require_once($envCfgFile)); + } +} + +// If no environment is set we have to load the default config +if (!isset($cfg)) { + $cfg = require_once(__DIR__ . '/../config/test.php'); +} + +// If no humhub_root is given we assume our module is in the a root to be in /protected/humhub/modules//tests/codeception directory +$cfg['humhub_root'] = isset($cfg['humhub_root']) ? $cfg['humhub_root'] : dirname(__DIR__) . '/../../../../..'; + + +// Load default test bootstrap +require_once($cfg['humhub_root'] . '/protected/humhub/tests/codeception/_bootstrap.php'); + +// Overwrite the default test alias +Yii::setAlias('@tests', dirname(__DIR__)); +Yii::setAlias('@env', '@tests/config/env'); +Yii::setAlias('@root', $cfg['humhub_root']); +Yii::setAlias('@humhubTests', $cfg['humhub_root'] . '/protected/humhub/tests'); + +// Load all supporting test classes needed for test execution +\Codeception\Util\Autoload::addNamespace('', Yii::getAlias('@humhubTests/codeception/_support')); +\Codeception\Util\Autoload::addNamespace('tests\codeception\fixtures', Yii::getAlias('@humhubTests/codeception/fixtures')); +\Codeception\Util\Autoload::addNamespace('', Yii::getAlias('@humhubTests/codeception/_pages')); +if(isset($cfg['modules'])) { + \Codeception\Configuration::append(['humhub_modules' => $cfg['modules']]); +} + +if(isset($cfg['fixtures'])) { + \Codeception\Configuration::append(['fixtures' => $cfg['fixtures']]); +} +?> \ No newline at end of file diff --git a/protected/humhub/modules/tour/tests/codeception/_output/.gitignore b/protected/humhub/modules/tour/tests/codeception/_output/.gitignore new file mode 100644 index 0000000000..86d0cb2726 --- /dev/null +++ b/protected/humhub/modules/tour/tests/codeception/_output/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore \ No newline at end of file diff --git a/protected/humhub/modules/tour/tests/codeception/_support/AcceptanceTester.php b/protected/humhub/modules/tour/tests/codeception/_support/AcceptanceTester.php new file mode 100644 index 0000000000..1c90f779ca --- /dev/null +++ b/protected/humhub/modules/tour/tests/codeception/_support/AcceptanceTester.php @@ -0,0 +1,26 @@ +amAdmin(); + $I->amOnDashboard(); + + $I->dontSeeElement('#getting-started-panel'); + + $I->amOnRoute(['/admin/setting/basic']); + + $I->see('Show introduction tour for new users'); + $I->click('.field-basicsettingsform-tour label'); + + $I->click('Save'); + $I->seeSuccess(); + + $I->amOnDashboard(); + $I->waitForText('You are the first user here', null, '#globalModal'); + $I->click('Save and close', '#globalModal'); + + $I->waitForElementVisible('#getting-started-panel'); + $I->see('Guide: Administration (Modules)', '#getting-started-panel'); + + $I->wait(1); + $I->click('Guide: Overview'); + + $I->waitForElementVisible('.popover.tour'); + $I->see('Dashboard', '.popover.tour'); + $I->click('Next', '.popover.tour'); + + $I->waitForText('Notifications', null, '.popover.tour'); + $I->click('Next', '.popover.tour'); + + $I->waitForText('Account Menu', null,'.popover.tour'); + $I->click('Next', '.popover.tour'); + + $I->waitForText('Space Menu', null, '.popover.tour'); + $I->click('Start space guide', '.popover.tour'); + + $I->wait(2); + + $I->waitForText('Once you have joined or created a new space', null, '.popover.tour'); + $I->click('Next', '.popover.tour'); + + $I->waitForText('Space navigation menu', null, '.popover.tour'); + $I->click('Next', '.popover.tour'); + + $I->waitForText('Space preferences', null, '.popover.tour'); + $I->click('Next', '.popover.tour'); + + $I->waitForText('Writing posts', null, '.popover.tour'); + $I->click('Next', '.popover.tour'); + + $I->waitForText('Yours, and other users\' posts will appear here.', null, '.popover.tour'); + $I->click('Next', '.popover.tour'); + + $I->waitForText('Most recent activities', null, '.popover.tour'); + $I->click('Next', '.popover.tour'); + + $I->waitForText('Space members', null, '.popover.tour'); + $I->click('Next', '.popover.tour'); + + $I->waitForText('Yay! You\'re done.', null, '.popover.tour'); + $I->click('Profile Guide', '.popover.tour'); + + $I->waitForText('User profile', null, '.popover.tour'); + $I->click('Next', '.popover.tour'); + + $I->waitForText('Profile photo', null, '.popover.tour'); + $I->click('Next', '.popover.tour'); + + $I->waitForText('Edit account', null, '.popover.tour'); + $I->click('Next', '.popover.tour'); + + $I->waitForText('Profile menu', null, '.popover.tour'); + $I->click('Next', '.popover.tour'); + + $I->waitForText('Profile stream', null, '.popover.tour'); + $I->click('Next', '.popover.tour'); + + $I->waitForText('Hurray! You\'re done!', null, '.popover.tour'); + $I->click('Administration (Modules)', '.popover.tour'); + + $I->waitForText('As an admin, you can manage the whole platform from here', null, '.popover.tour'); + $I->click('Next', '.popover.tour'); + + $I->waitForText('Modules', null, '.popover.tour'); + $I->click('Next', '.popover.tour'); + + $I->waitForText('Hurray! That\'s all for now.', null, '.popover.tour'); + $I->click('End guide', '.popover.tour'); + + $I->amUser1(true); + $I->amOnDashboard(); + $I->seeElement('#getting-started-panel'); + $I->dontSee('Guide: Administration (Modules)', '#getting-started-panel'); + } +} diff --git a/protected/humhub/modules/tour/tests/codeception/acceptance/_bootstrap.php b/protected/humhub/modules/tour/tests/codeception/acceptance/_bootstrap.php new file mode 100644 index 0000000000..9e54876dce --- /dev/null +++ b/protected/humhub/modules/tour/tests/codeception/acceptance/_bootstrap.php @@ -0,0 +1,6 @@ + ['default'] +]; diff --git a/protected/humhub/modules/tour/tests/config/unit.php b/protected/humhub/modules/tour/tests/config/unit.php new file mode 100644 index 0000000000..ae7fa3f7ef --- /dev/null +++ b/protected/humhub/modules/tour/tests/config/unit.php @@ -0,0 +1,5 @@ +context->loadResources($this); ?>