diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-10-23 16:44:09 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-10-23 16:44:20 +0200 |
commit | b6981dcecb0fb80b3b519af70f2c29329fe2c2b0 (patch) | |
tree | a0042912470bd4be6e84ccf0e176fa1afb9b1781 /tests | |
parent | 26ca7a0e2f86cb76726073f2d73fd5cb8a1e09d9 (diff) | |
parent | 39338aaa676168b0a53c3a1f6d5363569f303361 (diff) | |
download | nextcloud-server-b6981dcecb0fb80b3b519af70f2c29329fe2c2b0.tar.gz nextcloud-server-b6981dcecb0fb80b3b519af70f2c29329fe2c2b0.zip |
Merge branch 'master' of https://github.com/nextcloud/server into gridview-table
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/acceptance/features/app-files.feature | 72 | ||||
-rw-r--r-- | tests/acceptance/features/bootstrap/FileListContext.php | 16 | ||||
-rw-r--r-- | tests/karma.config.js | 1 | ||||
-rw-r--r-- | tests/lib/AppFramework/Http/EmptyContentSecurityPolicyTest.php | 15 | ||||
-rw-r--r-- | tests/lib/AvatarTest.php | 6 | ||||
-rw-r--r-- | tests/lib/BackgroundJob/QueuedJobTest.php | 52 | ||||
-rw-r--r-- | tests/lib/BackgroundJob/TimedJobTest.php | 113 | ||||
-rw-r--r-- | tests/lib/Collaboration/Collaborators/LookupPluginTest.php | 99 | ||||
-rw-r--r-- | tests/ui-regression/package.json | 2 |
9 files changed, 294 insertions, 82 deletions
diff --git a/tests/acceptance/features/app-files.feature b/tests/acceptance/features/app-files.feature index 00f09900d3e..3bded3fef11 100644 --- a/tests/acceptance/features/app-files.feature +++ b/tests/acceptance/features/app-files.feature @@ -31,6 +31,78 @@ Feature: app-files When I open the details view for "welcome.txt" Then I see that the details view is open + Scenario: show recent files + Given I am logged in + And I create a new folder named "Folder just created" + When I open the "Recent" section + Then I see that the current section is "Recent" + Then I see that the file list contains a file named "Folder just created" + + Scenario: show recent files for a second time + Given I am logged in + And I open the "Recent" section + And I see that the current section is "Recent" + And I open the "All files" section + And I see that the current section is "All files" + And I create a new folder named "Folder just created" + When I open the "Recent" section + Then I see that the current section is "Recent" + Then I see that the file list contains a file named "Folder just created" + + Scenario: show favorites + Given I am logged in + And I mark "welcome.txt" as favorite + When I open the "Favorites" section + Then I see that the current section is "Favorites" + Then I see that the file list contains a file named "welcome.txt" + + Scenario: show favorites for a second time + Given I am logged in + And I open the "Favorites" section + And I see that the current section is "Favorites" + And I open the "All files" section + And I see that the current section is "All files" + And I mark "welcome.txt" as favorite + When I open the "Favorites" section + Then I see that the current section is "Favorites" + Then I see that the file list contains a file named "welcome.txt" + + Scenario: show shares + Given I am logged in + And I share the link for "welcome.txt" + When I open the "Shares" section + Then I see that the current section is "Shares" + Then I see that the file list contains a file named "welcome.txt" + + Scenario: show shares for a second time + Given I am logged in + And I open the "Shares" section + And I see that the current section is "Shares" + And I open the "All files" section + And I see that the current section is "All files" + And I share the link for "welcome.txt" + When I open the "Shares" section + Then I see that the current section is "Shares" + Then I see that the file list contains a file named "welcome.txt" + + Scenario: show deleted files + Given I am logged in + And I delete "welcome.txt" + When I open the "Deleted files" section + Then I see that the current section is "Deleted files" + Then I see that the file list contains a file named "welcome.txt" + + Scenario: show deleted files for a second time + Given I am logged in + And I open the "Deleted files" section + And I see that the current section is "Deleted files" + And I open the "All files" section + And I see that the current section is "All files" + And I delete "welcome.txt" + When I open the "Deleted files" section + Then I see that the current section is "Deleted files" + Then I see that the file list contains a file named "welcome.txt" + Scenario: rename a file with the details view open Given I am logged in And I open the details view for "welcome.txt" diff --git a/tests/acceptance/features/bootstrap/FileListContext.php b/tests/acceptance/features/bootstrap/FileListContext.php index bc225e3f9b1..6a39d7a999f 100644 --- a/tests/acceptance/features/bootstrap/FileListContext.php +++ b/tests/acceptance/features/bootstrap/FileListContext.php @@ -255,6 +255,13 @@ class FileListContext implements Context, ActorAwareInterface { } /** + * @return Locator + */ + public static function deleteMenuItem() { + return self::fileActionsMenuItemFor("Delete"); + } + + /** * @Given I create a new folder named :folderName */ public function iCreateANewFolderNamed($folderName) { @@ -323,6 +330,15 @@ class FileListContext implements Context, ActorAwareInterface { } /** + * @When I delete :fileName + */ + public function iDelete($fileName) { + $this->actor->find(self::fileActionsMenuButtonForFile($this->fileListAncestor, $fileName), 10)->click(); + + $this->actor->find(self::deleteMenuItem(), 2)->click(); + } + + /** * @Then I see that the file list is eventually loaded */ public function iSeeThatTheFileListIsEventuallyLoaded() { diff --git a/tests/karma.config.js b/tests/karma.config.js index fe5b7a79d18..fc49056e177 100644 --- a/tests/karma.config.js +++ b/tests/karma.config.js @@ -67,6 +67,7 @@ module.exports = function(config) { // only test these files, others are not ready and mess // up with the global namespace/classes/state 'apps/files_external/js/app.js', + 'apps/files_external/js/templates.js', 'apps/files_external/js/mountsfilelist.js', 'apps/files_external/js/settings.js', 'apps/files_external/js/statusmanager.js' diff --git a/tests/lib/AppFramework/Http/EmptyContentSecurityPolicyTest.php b/tests/lib/AppFramework/Http/EmptyContentSecurityPolicyTest.php index 7c30df730d3..7e86903892f 100644 --- a/tests/lib/AppFramework/Http/EmptyContentSecurityPolicyTest.php +++ b/tests/lib/AppFramework/Http/EmptyContentSecurityPolicyTest.php @@ -451,4 +451,19 @@ class EmptyContentSecurityPolicyTest extends \Test\TestCase { $this->contentSecurityPolicy->addAllowedScriptDomain("'self'"); $this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy()); } + + public function testGetPolicyWithReportUri() { + $expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';report-uri https://my-report-uri.com"; + + $this->contentSecurityPolicy->addReportTo("https://my-report-uri.com"); + $this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy()); + } + + public function testGetPolicyWithMultipleReportUri() { + $expectedPolicy = "default-src 'none';base-uri 'none';manifest-src 'self';report-uri https://my-report-uri.com https://my-other-report-uri.com"; + + $this->contentSecurityPolicy->addReportTo("https://my-report-uri.com"); + $this->contentSecurityPolicy->addReportTo("https://my-other-report-uri.com"); + $this->assertSame($expectedPolicy, $this->contentSecurityPolicy->buildPolicy()); + } } diff --git a/tests/lib/AvatarTest.php b/tests/lib/AvatarTest.php index 759dd385564..c8c9d3b8317 100644 --- a/tests/lib/AvatarTest.php +++ b/tests/lib/AvatarTest.php @@ -48,7 +48,7 @@ class AvatarTest extends \Test\TestCase { $this->createMock(ILogger::class), $this->config ); - + // abcdefghi is a convenient name that our algorithm convert to our nextcloud blue 0082c9 $this->user->method('getDisplayName')->willReturn('abcdefghi'); } @@ -231,11 +231,11 @@ class AvatarTest extends \Test\TestCase { public function testGenerateSvgAvatar() { $avatar = $this->invokePrivate($this->avatar, 'getAvatarVector', [64]); - + $svg = '<?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg width="64" height="64" version="1.1" viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg"> <rect width="100%" height="100%" fill="#0082c9"></rect> - <text x="50%" y="350" style="font-weight:600;font-size:278px;font-family:\'Open Sans\';text-anchor:middle;fill:#fff">A</text> + <text x="50%" y="350" style="font-weight:normal;font-size:279px;font-family:\'Nunito\';text-anchor:middle;fill:#fff">A</text> </svg>'; $this->assertEquals($avatar, $svg); } diff --git a/tests/lib/BackgroundJob/QueuedJobTest.php b/tests/lib/BackgroundJob/QueuedJobTest.php index a3e9cc296a0..73b245f93a5 100644 --- a/tests/lib/BackgroundJob/QueuedJobTest.php +++ b/tests/lib/BackgroundJob/QueuedJobTest.php @@ -8,18 +8,24 @@ namespace Test\BackgroundJob; +use OCP\AppFramework\Utility\ITimeFactory; + class TestQueuedJob extends \OC\BackgroundJob\QueuedJob { - private $testCase; + public $ran = false; - /** - * @param QueuedJobTest $testCase - */ - public function __construct($testCase) { - $this->testCase = $testCase; + + public function run($argument) { + $this->ran = true; } +} + + +class TestQueuedJobNew extends \OCP\BackgroundJob\QueuedJob { + public $ran = false; + public function run($argument) { - $this->testCase->markRun(); + $this->ran = true; } } @@ -28,29 +34,29 @@ class QueuedJobTest extends \Test\TestCase { * @var DummyJobList $jobList */ private $jobList; - /** - * @var \OC\BackgroundJob\TimedJob $job - */ - private $job; - - private $jobRun = false; - - public function markRun() { - $this->jobRun = true; - } protected function setup() { parent::setUp(); $this->jobList = new DummyJobList(); - $this->job = new TestQueuedJob($this); - $this->jobList->add($this->job); - $this->jobRun = false; } public function testJobShouldBeRemoved() { - $this->assertTrue($this->jobList->has($this->job, null)); - $this->job->execute($this->jobList); - $this->assertTrue($this->jobRun); + $job = new TestQueuedJob(); + $this->jobList->add($job); + + $this->assertTrue($this->jobList->has($job, null)); + $job->execute($this->jobList); + $this->assertTrue($job->ran); + } + + public function testJobShouldBeRemovedNew() { + $job = new TestQueuedJobNew(\OC::$server->query(ITimeFactory::class)); + $job->setId(42); + $this->jobList->add($job); + + $this->assertTrue($this->jobList->has($job, null)); + $job->execute($this->jobList); + $this->assertTrue($job->ran); } } diff --git a/tests/lib/BackgroundJob/TimedJobTest.php b/tests/lib/BackgroundJob/TimedJobTest.php index 5652a5c9901..e684ad8c1e6 100644 --- a/tests/lib/BackgroundJob/TimedJobTest.php +++ b/tests/lib/BackgroundJob/TimedJobTest.php @@ -8,65 +8,110 @@ namespace Test\BackgroundJob; +use OCP\AppFramework\Utility\ITimeFactory; + class TestTimedJob extends \OC\BackgroundJob\TimedJob { - private $testCase; + /** @var bool */ + public $ran = false; - /** - * @param TimedJobTest $testCase - */ - public function __construct($testCase) { + public function __construct() { $this->setInterval(10); - $this->testCase = $testCase; } public function run($argument) { - $this->testCase->markRun(); + $this->ran = true; } } -class TimedJobTest extends \Test\TestCase { - /** - * @var DummyJobList $jobList - */ - private $jobList; - /** - * @var \OC\BackgroundJob\TimedJob $job - */ - private $job; +class TestTimedJobNew extends \OCP\BackgroundJob\TimedJob { + /** @var bool */ + public $ran = false; - private $jobRun = false; + public function __construct(ITimeFactory $timeFactory) { + parent::__construct($timeFactory); + $this->setInterval(10); + } - public function markRun() { - $this->jobRun = true; + public function run($argument) { + $this->ran = true; } +} + +class TimedJobTest extends \Test\TestCase { + /** @var DummyJobList $jobList */ + private $jobList; + + /** @var ITimeFactory */ + private $time; protected function setup() { parent::setUp(); $this->jobList = new DummyJobList(); - $this->job = new TestTimedJob($this); - $this->jobList->add($this->job); - $this->jobRun = false; + $this->time = \OC::$server->query(ITimeFactory::class); } public function testShouldRunAfterInterval() { - $this->job->setLastRun(time() - 12); - $this->job->execute($this->jobList); - $this->assertTrue($this->jobRun); + $job = new TestTimedJob(); + $this->jobList->add($job); + + $job->setLastRun(time() - 12); + $job->execute($this->jobList); + $this->assertTrue($job->ran); } public function testShouldNotRunWithinInterval() { - $this->job->setLastRun(time() - 5); - $this->job->execute($this->jobList); - $this->assertFalse($this->jobRun); + $job = new TestTimedJob(); + $this->jobList->add($job); + + $job->setLastRun(time() - 5); + $job->execute($this->jobList); + $this->assertFalse($job->ran); } public function testShouldNotTwice() { - $this->job->setLastRun(time() - 15); - $this->job->execute($this->jobList); - $this->assertTrue($this->jobRun); - $this->jobRun = false; - $this->job->execute($this->jobList); - $this->assertFalse($this->jobRun); + $job = new TestTimedJob(); + $this->jobList->add($job); + + $job->setLastRun(time() - 15); + $job->execute($this->jobList); + $this->assertTrue($job->ran); + $job->ran = false; + $job->execute($this->jobList); + $this->assertFalse($job->ran); + } + + + public function testShouldRunAfterIntervalNew() { + $job = new TestTimedJobNew($this->time); + $job->setId(42); + $this->jobList->add($job); + + $job->setLastRun(time() - 12); + $job->execute($this->jobList); + $this->assertTrue($job->ran); + } + + public function testShouldNotRunWithinIntervalNew() { + $job = new TestTimedJobNew($this->time); + $job->setId(42); + $this->jobList->add($job); + + $job->setLastRun(time() - 5); + $job->execute($this->jobList); + $this->assertFalse($job->ran); + } + + public function testShouldNotTwiceNew() { + $job = new TestTimedJobNew($this->time); + $job->setId(42); + $this->jobList->add($job); + + $job->setLastRun(time() - 15); + $job->execute($this->jobList); + $this->assertTrue($job->ran); + $job->ran = false; + $job->execute($this->jobList); + $this->assertFalse($job->ran); } } diff --git a/tests/lib/Collaboration/Collaborators/LookupPluginTest.php b/tests/lib/Collaboration/Collaborators/LookupPluginTest.php index 9019176d246..98e4adf2a7c 100644 --- a/tests/lib/Collaboration/Collaborators/LookupPluginTest.php +++ b/tests/lib/Collaboration/Collaborators/LookupPluginTest.php @@ -70,7 +70,7 @@ class LookupPluginTest extends TestCase { $this->userSession->expects($this->any())->method('getUser') ->willReturn($user); $this->cloudIdManager->expects($this->any())->method('resolveCloudId') - ->willReturnCallback(function($cloudId) { + ->willReturnCallback(function ($cloudId) { if ($cloudId === 'user@myNextcloud.net') { return new CloudId('user@myNextcloud.net', 'user', 'myNextcloud.net'); } @@ -87,6 +87,58 @@ class LookupPluginTest extends TestCase { ); } + public function testSearchNoLookupServerURI() { + $this->config->expects($this->once()) + ->method('getAppValue') + ->with('files_sharing', 'lookupServerEnabled', 'no') + ->willReturn('yes'); + $this->config->expects($this->at(0)) + ->method('getSystemValue') + ->with('gs.enabled', false) + ->willReturn(false); + + $this->config->expects($this->at(2)) + ->method('getSystemValue') + ->with('has_internet_connection', true) + ->willReturn(true); + $this->config->expects($this->at(3)) + ->method('getSystemValue') + ->with('lookup_server', 'https://lookup.nextcloud.com') + ->willReturn(''); + + $this->clientService->expects($this->never()) + ->method('newClient'); + + /** @var ISearchResult|\PHPUnit_Framework_MockObject_MockObject $searchResult */ + $searchResult = $this->createMock(ISearchResult::class); + + $this->plugin->search('foobar', 10, 0, $searchResult); + } + + public function testSearchNoInternet() { + $this->config->expects($this->once()) + ->method('getAppValue') + ->with('files_sharing', 'lookupServerEnabled', 'no') + ->willReturn('yes'); + $this->config->expects($this->at(0)) + ->method('getSystemValue') + ->with('gs.enabled', false) + ->willReturn(false); + + $this->config->expects($this->at(2)) + ->method('getSystemValue') + ->with('has_internet_connection', true) + ->willReturn(false); + + $this->clientService->expects($this->never()) + ->method('newClient'); + + /** @var ISearchResult|\PHPUnit_Framework_MockObject_MockObject $searchResult */ + $searchResult = $this->createMock(ISearchResult::class); + + $this->plugin->search('foobar', 10, 0, $searchResult); + } + /** * @dataProvider searchDataProvider * @param array $searchParams @@ -108,8 +160,13 @@ class LookupPluginTest extends TestCase { ->method('getSystemValue') ->with('gs.enabled', false) ->willReturn(false); + $this->config->expects($this->at(2)) ->method('getSystemValue') + ->with('has_internet_connection', true) + ->willReturn(true); + $this->config->expects($this->at(3)) + ->method('getSystemValue') ->with('lookup_server', 'https://lookup.nextcloud.com') ->willReturn($searchParams['server']); @@ -121,7 +178,7 @@ class LookupPluginTest extends TestCase { $client = $this->createMock(IClient::class); $client->expects($this->once()) ->method('get') - ->willReturnCallback(function($url) use ($searchParams, $response) { + ->willReturnCallback(function ($url) use ($searchParams, $response) { $this->assertSame(strpos($url, $searchParams['server'] . '/users?search='), 0); $this->assertNotFalse(strpos($url, urlencode($searchParams['search']))); return $response; @@ -138,8 +195,6 @@ class LookupPluginTest extends TestCase { $searchResult ); - - $this->assertFalse($moreResults); } @@ -171,6 +226,10 @@ class LookupPluginTest extends TestCase { $this->config->expects($this->at(2)) ->method('getSystemValue') + ->with('has_internet_connection', true) + ->willReturn(true); + $this->config->expects($this->at(3)) + ->method('getSystemValue') ->with('lookup_server', 'https://lookup.nextcloud.com') ->willReturn($searchParams['server']); @@ -201,8 +260,6 @@ class LookupPluginTest extends TestCase { $searchResult ); - - $this->assertFalse($moreResults); } @@ -237,9 +294,9 @@ class LookupPluginTest extends TestCase { 'offset' => 0, 'server' => 'https://lookup.example.io', 'resultBody' => [ - [ 'federationId' => $fedIDs[0] ], - [ 'federationId' => $fedIDs[1] ], - [ 'federationId' => $fedIDs[2] ], + ['federationId' => $fedIDs[0]], + ['federationId' => $fedIDs[1]], + ['federationId' => $fedIDs[2]], ], 'expectedResult' => [ [ @@ -276,9 +333,9 @@ class LookupPluginTest extends TestCase { 'offset' => 0, 'server' => 'https://lookup.example.io', 'resultBody' => [ - [ 'federationId' => $fedIDs[0] ], - [ 'federationId' => $fedIDs[1] ], - [ 'federationId' => $fedIDs[2] ], + ['federationId' => $fedIDs[0]], + ['federationId' => $fedIDs[1]], + ['federationId' => $fedIDs[2]], ], 'expectedResult' => [ [ @@ -315,9 +372,9 @@ class LookupPluginTest extends TestCase { 'offset' => 0, 'server' => 'https://lookup.example.io', 'resultBody' => [ - [ 'federationId' => $fedIDs[0] ], - [ 'federationId' => $fedIDs[1] ], - [ 'federationId' => $fedIDs[2] ], + ['federationId' => $fedIDs[0]], + ['federationId' => $fedIDs[1]], + ['federationId' => $fedIDs[2]], ], 'expectedResult' => [ [ @@ -354,9 +411,9 @@ class LookupPluginTest extends TestCase { 'offset' => 0, 'server' => 'https://lookup.example.io', 'resultBody' => [ - [ 'federationId' => $fedIDs[0] ], - [ 'federationId' => $fedIDs[1] ], - [ 'federationId' => $fedIDs[2] ], + ['federationId' => $fedIDs[0]], + ['federationId' => $fedIDs[1]], + ['federationId' => $fedIDs[2]], ], 'expectedResult' => [ [ @@ -405,9 +462,9 @@ class LookupPluginTest extends TestCase { 'offset' => 0, 'server' => 'https://lookup.example.io', 'resultBody' => [ - [ 'federationId' => $fedIDs[0] ], - [ 'federationId' => $fedIDs[1] ], - [ 'federationId' => $fedIDs[2] ], + ['federationId' => $fedIDs[0]], + ['federationId' => $fedIDs[1]], + ['federationId' => $fedIDs[2]], ], 'expectedResult' => [ [ diff --git a/tests/ui-regression/package.json b/tests/ui-regression/package.json index 8ab4cf530f2..cc94d34e398 100644 --- a/tests/ui-regression/package.json +++ b/tests/ui-regression/package.json @@ -15,7 +15,7 @@ "pixelmatch": "^4.0.2", "png-js": "^0.1.1", "pngjs2": "^2.0.0", - "polyserve": "^0.23.0", + "polyserve": "^0.27.13", "puppeteer": "^1.6.1" } } |