diff --git a/.ci/config-test.inc.php b/.ci/config-test.inc.php index d7bb8039b..2cba28441 100644 --- a/.ci/config-test.inc.php +++ b/.ci/config-test.inc.php @@ -20,6 +20,11 @@ $config['support_url'] = 'http://support.url'; // Plugins with tests -$config['plugins'] = ['archive', 'markasjunk', 'zipdownload']; +$config['plugins'] = [ + 'archive', + 'attachment_reminder', + 'markasjunk', + 'zipdownload' +]; $config['archive_mbox'] = 'Archive'; diff --git a/.ci/install.sh b/.ci/install.sh index dc22059f9..c07ba5294 100755 --- a/.ci/install.sh +++ b/.ci/install.sh @@ -12,7 +12,7 @@ cd $DIR/.. cp composer.json-dist composer.json # Add laravel/dusk for Browser tests -if [ "$BROWSER_TESTS" = 1 ]; then composer require "laravel/dusk:~5.7.0" --no-update; fi +if [ "$BROWSER_TESTS" = 1 ]; then composer require "laravel/dusk:~5.9.1" --no-update; fi # Remove qr-code as it requires php-gd which is not always available on Travis # and we don't really need it for tests diff --git a/plugins/attachment_reminder/tests/Browser/PluginTest.php b/plugins/attachment_reminder/tests/Browser/PluginTest.php new file mode 100644 index 000000000..cd4f3cd0a --- /dev/null +++ b/plugins/attachment_reminder/tests/Browser/PluginTest.php @@ -0,0 +1,94 @@ +browse(function ($browser) { + $browser->go('settings', 'preferences'); + + $browser->click('#sections-table tr.compose'); + + $browser->withinFrame('#preferences-frame', function ($browser) { + if (!$browser->isPhone()) { + $browser->waitFor('.formbuttons button.submit'); + } + + // Main Options fieldset + $browser->with('form.propform fieldset.main', function ($browser) { + $browser->assertSeeIn('label[for=rcmfd_attachment_reminder]', 'Remind about forgotten attachments') + ->assertCheckboxState('_attachment_reminder', false) + ->setCheckboxState('_attachment_reminder', true); + }); + + // Submit form + if (!$browser->isPhone()) { + $browser->click('.formbuttons button.submit'); + } + }); + + if ($browser->isPhone()) { + $browser->click('#layout-content .footer a.submit'); + } + + $browser->waitForMessage('confirmation', 'Successfully saved'); + + // Verify if every option has been updated + $browser->withinFrame('#preferences-frame', function ($browser) { + $browser->assertCheckboxState('_attachment_reminder', true); + }); + }); + } + + /** + * Test Mail Compose page + * + * @depends testPreferences + */ + public function testMailCompose() + { + $this->browse(function ($browser) { + $send_btn = $browser->isPhone() ? '.buttons a.send' : '.formbuttons button.send'; + + $browser->go('mail', 'compose'); + + $browser->waitFor('#compose_to') + ->type('#compose_to input', 'test@domain.tld') + ->type('#compose-subject', 'subject') + ->type('#composebody', 'File attached') + ->click($send_btn); + + // Expect a dialog, Click "Attach a file" button + $browser->with(new Dialog(), function ($browser) { + $browser->assertDialogTitle('Missing attachment?') + ->assertDialogContent('Did you forget to attach a file?') + ->assertButton('mainaction.attach', 'Attach a file') + ->assertButton('send', 'Send') + ->clickButton('mainaction.attach'); + }); + + // Click the Send button again + $browser->click($send_btn); + + // Expect the dialog again, click Send button (in the dialog) + $browser->with(new Dialog(), function ($browser) { + $browser->assertDialogTitle('Missing attachment?') + ->clickButton('send'); + }); + + $browser->waitForMessage('confirmation', 'Message sent successfully.'); + }); + } +}