Skip to content

Commit

Permalink
Acceptance test
Browse files Browse the repository at this point in the history
  • Loading branch information
yurabakhtin committed Apr 24, 2024
1 parent f39b6a1 commit 2261f52
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
46 changes: 46 additions & 0 deletions tests/codeception/acceptance/TextEditorCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,51 @@ class TextEditorCest
{
public function testTextEditor(AcceptanceTester $I)
{
$I->amAdmin();

$I->amOnPage('/text-editor/config');
$I->waitForText('Text editor');
$I->click('#configform-allownewfiles');
$I->click('Save');
$I->seeSuccess();

$I->amOnSpace1();
$I->click('#contentForm_message');
$I->click('.contentForm_options .btn-group .dropdown-toggle');
$I->waitForText('Create file (Text, Log, XML)');
$I->click('Create file (Text, Log, XML)');
$I->waitForText('Create file');
$I->fillField('#createfile-filename', 'Test file name.tst');
$I->click('Save');

$I->waitForText('Edit file: Test file name.tst');
$I->fillField('#fileupdate-newfilecontent', 'test');
$I->executeJS('document.querySelectorAll("div.CodeMirror")[0].CodeMirror.setValue("Test\r\nLine 2")');
$I->click('Save');
$I->seeSuccess();
$I->fillField('#contentFormBody .humhub-ui-richtext[contenteditable]', 'Post with test text file.');
$I->click('Submit');

$I->waitForText('Post with test text file.', null, '.wall-entry');
$I->see('Test file name.tst - 12 B', '.wall-entry .file-preview-content');
$I->click('Test file name.tst');
$I->waitForText('Open file');
$I->click('View');
$I->waitForText('View file: Test file name.tst');
$I->see("Test\r\nLine 2");
$I->click('Close');

$I->click('Test file name.tst');
$I->waitForText('Open file');
$I->click('Edit with Text editor');
$I->waitForText('Edit file: Test file name.tst');
$I->executeJS('document.querySelectorAll("div.CodeMirror")[0].CodeMirror.setValue("1st Line\r\nSecond Line")');
$I->click('Save');
$I->seeSuccess();
$I->click('Test file name.tst');
$I->waitForText('Open file');
$I->click('View');
$I->waitForText('View file: Test file name.tst');
$I->see("1st Line\r\nSecond Line");
}
}
4 changes: 3 additions & 1 deletion tests/codeception/unit/TextEditorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

namespace text_editor;

use humhub\modules\file\models\File;
use humhub\modules\text_editor\models\CreateFile;
use humhub\modules\text_editor\models\forms\ConfigForm;
use humhub\modules\text_editor\Module;
Expand All @@ -32,11 +31,14 @@ public function testTextEditor()
$createFile->fileName = 'test.any';
$testFile = $createFile->save();

$this->assertEquals('text/plain', $testFile->mime_type);
$this->assertTrue($module->isSupportedType($testFile));
$this->assertTrue($module->canView($testFile));
$this->assertTrue($module->canEdit($testFile));

$testFile->mime_type = 'image/jpeg';

$this->assertFalse($module->isSupportedType($testFile));
$this->assertFalse($module->canView($testFile));
$this->assertFalse($module->canEdit($testFile));
}
Expand Down

0 comments on commit 2261f52

Please sign in to comment.