Browse Source

feat: Add context and test steps for activity in sharing

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/51458/head
Côme Chilliet 8 months ago
committed by Côme Chilliet
parent
commit
140aba1f16
  1. 30
      build/integration/features/bootstrap/Activity.php
  2. 4
      build/integration/features/bootstrap/BasicStructure.php
  3. 1
      build/integration/features/bootstrap/SharingContext.php
  4. 14
      build/integration/sharing_features/sharing-activity.feature

30
build/integration/features/bootstrap/Activity.php

@ -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
build/integration/features/bootstrap/BasicStructure.php

@ -192,8 +192,8 @@ trait BasicStructure {
$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();

1
build/integration/features/bootstrap/SharingContext.php

@ -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');

14
build/integration/sharing_features/sharing-activity.feature

@ -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
@ -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
@ -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 |
Loading…
Cancel
Save