Skip to content
Prev Previous commit
Next Next commit
feat: Add context and test steps for activity in sharing
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Mar 25, 2025
commit 140aba1f16a10a9823d628981a35472d55428114
30 changes: 30 additions & 0 deletions build/integration/features/bootstrap/Activity.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

use Behat\Gherkin\Node\TableNode;
use PHPUnit\Framework\Assert;

trait Activity {
use BasicStructure;

/**
* @Then last activity should be
* @param TableNode $activity
*/
public function lastActivityIs(TableNode $activity): void {
$this->sendRequestForJSON('GET', '/apps/activity/api/v2/activity');
$this->theHTTPStatusCodeShouldBe('200');
$data = json_decode($this->response->getBody()->getContents(), true);
$activities = $data['ocs']['data'];
$lastActivity = array_pop($activities);
foreach ($activity->getRowsHash() as $key => $value) {
Assert::assertEquals($value, $lastActivity[$key]);
}
}
}
4 changes: 2 additions & 2 deletions build/integration/features/bootstrap/BasicStructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ protected function sendRequestForJSON(string $verb, string $url, $body = null, a
$options = [];
if ($this->currentUser === 'admin') {
$options['auth'] = ['admin', 'admin'];
} elseif (strpos($this->currentUser, 'guest') !== 0) {
$options['auth'] = [$this->currentUser, self::TEST_PASSWORD];
} elseif (strpos($this->currentUser, 'anonymous') !== 0) {
$options['auth'] = [$this->currentUser, $this->regularUser];
}
if ($body instanceof TableNode) {
$fd = $body->getRowsHash();
Expand Down
1 change: 1 addition & 0 deletions build/integration/features/bootstrap/SharingContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class SharingContext implements Context, SnippetAcceptingContext {
use Trashbin;
use AppConfiguration;
use CommandLine;
use Activity;

protected function resetAppConfigs() {
$this->deleteServerConfig('core', 'shareapi_default_permissions');
Expand Down
14 changes: 12 additions & 2 deletions build/integration/sharing_features/sharing-activity.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Feature: sharing
| notify_setting_batchtime | 0 |
| activity_digest | 0 |

Scenario: Creating a new mail share
Scenario: Creating a new mail share and check activity
Given dummy mail server is listening
And As an "user0"
When creating a share with
Expand All @@ -24,8 +24,13 @@ Feature: sharing
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And last share can be downloaded
Then last activity should be
| app | files_sharing |
| type | public_links |
| object_type | files |
| object_name | /welcome.txt |

Scenario: Creating a new public share
Scenario: Creating a new public share and check activity
Given user "user0" exists
And As an "user0"
When creating a share with
Expand All @@ -34,3 +39,8 @@ Feature: sharing
Then the OCS status code should be "100"
And the HTTP status code should be "200"
And last link share can be downloaded
Then last activity should be
| app | files_sharing |
| type | public_links |
| object_type | files |
| object_name | /welcome.txt |