Skip to content

Commit

Permalink
Fix acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yurabakhtin committed Feb 22, 2022
1 parent 375f85b commit 5f723c1
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 45 deletions.
2 changes: 1 addition & 1 deletion tests/codeception/_support/AcceptanceTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function createEventToday($title = 'My Test Entry', $description = 'My Te
}

if($save) {
$this->click('Save', '#globalModal');
$this->click('Next', '#globalModal');
$this->wait(1);
}
}
Expand Down
44 changes: 25 additions & 19 deletions tests/codeception/acceptance/CreateSpaceEntryCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,13 @@ public function testInstallAndCreatEntry(AcceptanceTester $I)


$I->amGoingTo('Save my new calendar entry');
$I->click('Save', '#globalModal');
$I->click('Next', '#globalModal');
$I->expectTo('see my event loaded into my modal');
$I->waitForText('My Test Entry',null, '#globalModal');
$I->waitForText('Close',null, '#globalModal');

$I->click('Close', '#globalModal');
$I->waitForText('Next',null, '#globalModal');
$I->click('Next', '#globalModal');
$I->waitForText('Save',null, '#globalModal');
$I->click('Save', '#globalModal');

$I->wait(1);

Expand Down Expand Up @@ -93,14 +94,18 @@ public function testAddAll(AcceptanceTester $I)

$I->fillField('CalendarEntry[title]', 'New Test Event');

$I->click('Participation', '#globalModal');
$I->waitForElementVisible('[for="calendarentryform-forcejoin"]', null, '#globalModal');
$I->click('[for="calendarentryform-forcejoin"]');
$I->click('Next', '#globalModal');
$I->waitForText('Participants', null, '#globalModal');
$I->click('Next', '#globalModal');
$I->waitForElementVisible('[for="calendarentryparticipationform-forcejoin"]', null, '#globalModal');
$I->click('[for="calendarentryparticipationform-forcejoin"]');
$I->click('Save', '#globalModal');
$I->seeSuccess();

$I->expect('All space members to be attending');
$I->click('New Test Event');
$I->waitForText('2 attending', null,'#globalModal');
$I->click('Close', '#globalModal');
$I->amOnSpace(1, '/calendar/view/index');

$I->wantToTest('Adding a new space member and using then using the add all members again');

Expand All @@ -113,19 +118,20 @@ public function testAddAll(AcceptanceTester $I)
$I->click('[for="inviteform-withoutinvite"]');
$I->click('Send', '#globalModal');

$I->waitForElementNotVisible('#globalModal', 30);
$I->amOnSpace(1, '/calendar/view/index');

$I->waitForElementVisible('.fc-event');
$I->jsClick('.fc-event');

$I->waitForText('New Test Event',null, '#globalModal');
$I->click('Edit', '#globalModal .modal-footer');
$I->click('Invite', '#globalModal .modal-footer');

$I->waitForText('Edit event', null, '#globalModal');
$I->click('Participation', '#globalModal');
$I->waitForElementVisible('[for="calendarentryform-forcejoin"]', null, '#globalModal');
$I->click('[for="calendarentryform-forcejoin"]');
$I->waitForText('Event Participants', null, '#globalModal');
$I->waitForElementVisible('[for="calendarentryparticipationform-forcejoin"]', null, '#globalModal');
$I->click('[for="calendarentryparticipationform-forcejoin"]');
$I->click('Save', '#globalModal');
$I->seeSuccess();
$I->click('New Test Event');

$memberCount = Membership::getSpaceMembersQuery(Space::findOne(['id' => 1]))->count();

Expand All @@ -136,9 +142,6 @@ public function testAddAll(AcceptanceTester $I)
$I->jsClick('[data-action-click="toggleClose"]');
$I->wait(5);

$I->click('Close', '#globalModal');
$I->wait(5);

$I->amUser1(true);

$I->expectTo('see the add and cancel notification');
Expand All @@ -159,8 +162,11 @@ public function testAddAll(AcceptanceTester $I)
$I->click('.fc-today');

$I->waitForText('Create event', null, '#globalModal');
$I->click('Participation', '#globalModal');
$I->fillField('CalendarEntry[title]', 'User Test Event 2');
$I->click('Next', '#globalModal');
$I->waitForText('Participants', null, '#globalModal');
$I->click('Next', '#globalModal');
$I->wait(1);
$I->dontSeeElement('[for="calendarentryform-forcejoin"]');
$I->dontSeeElement('[for="calendarentryparticipationform-forcejoin"]');
}
}
2 changes: 1 addition & 1 deletion tests/codeception/acceptance/GlobalCalendarCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function testGlobalCalendarCreateEntry(AcceptanceTester $I)
$I->waitForText('Create event', null, '#globalModal');
$I->fillField('CalendarEntry[title]', 'My Test Profile Entry');
$I->fillField('#calendarentry-description .humhub-ui-richtext', 'My Test Profile Entry Description');
$I->click('Save', '#globalModal');
$I->click('Next', '#globalModal');

//$I->waitForText('Close', null, '#globalModal');
//$I->click('Close', '#globalModal');
Expand Down
26 changes: 14 additions & 12 deletions tests/codeception/acceptance/GlobalGuestCalendarCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ public function testGlobalGuestViewProtectedSpace(AcceptanceTester $I)

$I->amOnSpace1('/calendar/view');
$I->createEventToday('Public Event', 'Public Event Description', null, null, false);
$I->click('[for="calendarentryform-is_public"]');
$I->click('Save', '#globalModal');
$I->jsClick('#calendarentryform-is_public');
$I->click('Next', '#globalModal');

$I->waitForText('Public Event',null, '.fc-event-container');
$I->click('Close', '#globalModal');
$I->click('Next', '#globalModal');
$I->click('Save', '#globalModal');

$I->wait(1);

Expand All @@ -41,9 +42,10 @@ public function testGlobalGuestViewProtectedSpace(AcceptanceTester $I)
$I->wait(1);

$I->createEventToday('Private Event', 'Private Event Description');
$I->waitForText('Private Event', null,'#globalModal');
$I->wait(1);
$I->click('Close', '#globalModal');
$I->waitForText('Next',null, '#globalModal');
$I->click('Next', '#globalModal');
$I->click('Save', '#globalModal');
$I->seeSuccess();

$I->wait(1);

Expand All @@ -67,12 +69,13 @@ public function testGlobalGuestViewPublicSpace(AcceptanceTester $I)

$I->amOnSpace2('/calendar/view');
$I->createEventToday('Public Event', 'Public Event Description', null, null, false);
$I->click('[for="calendarentryform-is_public"]');
$I->click('Save', '#globalModal');
$I->jsClick('#calendarentryform-is_public');
$I->click('Next', '#globalModal');

$I->waitForText('Public Event',null, '.fc-event-container');
$I->wait(1);
$I->click('Close', '#globalModal');
$I->click('Next', '#globalModal');
$I->click('Save', '#globalModal');

$I->wait(1);

Expand All @@ -82,9 +85,8 @@ public function testGlobalGuestViewPublicSpace(AcceptanceTester $I)
$I->wait(1);

$I->createEventToday('Private Event', 'Private Event Description');
$I->waitForText('Private Event', null,'#globalModal');
$I->wait(1);
$I->click('Close', '#globalModal');
$I->click('Next', '#globalModal');
$I->click('Save', '#globalModal');

$I->wait(1);

Expand Down
17 changes: 10 additions & 7 deletions tests/codeception/acceptance/ParticipationCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function testInstallAndCreatEntry(AcceptanceTester $I)
$I->amGoingTo('create a new space event with');
$I->amOnSpace1('/calendar/view');
$I->createEventToday('Participant Event', 'Participant Description', null, null, false);
$I->click('.tab-participation');
$I->click('Next', '#globalModal');
$I->waitForText('Maximum number of participants');

$I->selectOption('#calendarentry-participation_mode', 2);
Expand All @@ -41,34 +41,37 @@ public function testInstallAndCreatEntry(AcceptanceTester $I)

$I->click('[type="submit"]');
$I->wait(1);
$I->click('Participant Event');
$I->waitForText('Participant Description',null,'#globalModal');
$I->dontSee('Attend', '#globalModal button');
$I->dontSee('Maybe', '#globalModal button');
$I->dontSee('Decline', '#globalModal button');

$I->click('.btn-primary', '#globalModal');
$I->waitForText('Edit event',null, '#globalModal');
$I->click('.tab-participation');
$I->click('Invite', '#globalModal');
$I->waitForText('Event Participants',null, '#globalModal');

$I->selectOption('#calendarentry-participation_mode', 2);

$I->fillField('#calendarentry-max_participants', 1);
$I->fillField('#calendarentry-participant_info .humhub-ui-richtext', 'My Test Event');

$I->click('[type="submit"]');
$I->seeSuccess();
$I->click('Participant Event');
$I->waitForText('Participant Description',null, '#globalModal');
$I->see('Attend', '#globalModal button');
$I->see('Maybe', '#globalModal button');
$I->see('Decline', '#globalModal button');

$I->click('.btn-primary', '#globalModal');
$I->waitForText('Edit event',null, '#globalModal');
$I->click('Invite', '#globalModal');
$I->waitForText('Event Participants',null, '#globalModal');
$I->click('.tab-participation');
$I->click('[for="calendarentry-allow_decline"]', '#globalModal');
$I->click('[for="calendarentry-allow_maybe"]', '#globalModal');
$I->click('[type="submit"]');
$I->wait(1);

$I->click('Participant Event');
$I->waitForText('Participant Description',null, '#globalModal');
$I->see('Attend', '#globalModal button');
$I->dontSee('Maybe', '#globalModal button');
Expand All @@ -77,7 +80,7 @@ public function testInstallAndCreatEntry(AcceptanceTester $I)
$I->click('Attend', '#globalModal');
$I->waitForText('1 attending', null, '#globalModal');
$I->click('1 attending', '#globalModal');
$I->waitForText('Attending users', null, '#globalModal');
$I->waitForText('Event Participants', null, '#globalModal');
$I->see('Admin Tester', '#globalModal');
}
}
6 changes: 4 additions & 2 deletions tests/codeception/acceptance/SettingsCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ public function testInstallAndCreatEntry(AcceptanceTester $I)

$I->amOnSpace1('/calendar/view');
$I->createEventToday('Setting Event','Setting Description',null,null,false);
$I->click('.tab-participation');
$I->click('Next', '#globalModal');

$I->waitForText('Event Participants',null, '#globalModal');
$I->seeInField('#calendarentry-participation_mode', 0);
$I->dontSeeElement('.participationOnly');

Expand All @@ -50,7 +51,8 @@ public function testInstallAndCreatEntry(AcceptanceTester $I)

$I->amOnSpace1('/calendar/view');
$I->createEventToday('Setting Event','Setting Description',null,null,false);
$I->click('.tab-participation');
$I->click('Next', '#globalModal');
$I->waitForText('Event Participants',null, '#globalModal');
$I->seeInField('#calendarentry-participation_mode', 2);
$I->seeElement('.participationOnly');
$I->dontSeeCheckboxIsChecked('#calendarentry-allow_decline');
Expand Down
7 changes: 4 additions & 3 deletions views/common/_settings_participation.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

use humhub\components\View;
use humhub\modules\calendar\models\forms\CalendarEntryForm;
use humhub\modules\calendar\assets\ParticipationFormAssets;
use humhub\modules\calendar\models\forms\CalendarEntryParticipationForm;
use humhub\modules\calendar\models\participation\ParticipationSettings;
use humhub\widgets\Button;
use yii\web\View;

/* @var $this View */
/* @var $participationSettings ParticipationSettings */
Expand All @@ -13,9 +13,10 @@
? Yii::t('CalendarModule.config', 'Here you can configure default settings for new calendar events. These settings can be overwritten on space/profile level.')
: Yii::t('CalendarModule.config', 'Here you can configure default settings for new calendar events.') ;

ParticipationFormAssets::register($this);
?>

<div class="panel-body" data-ui-widget="calendar.Form">
<div class="panel-body" data-ui-widget="calendar.participation.Form">
<h4>
<?= Yii::t('CalendarModule.config', 'Default participation settings'); ?>
<?php if ($participationSettings->showResetButton()) : ?>
Expand Down

0 comments on commit 5f723c1

Please sign in to comment.