mirror of
https://github.com/nextcloud/tables.git
synced 2025-08-16 15:17:20 +00:00
ci(integration): tests against context updates
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
@ -244,3 +244,94 @@ Feature: APIv2
|
||||
Then the reported status is "404"
|
||||
When user "participant1-v2" attempts to fetch Context "NON-EXISTENT"
|
||||
Then the reported status is "404"
|
||||
|
||||
@api2 @contexts @contexts-update
|
||||
Scenario: Update an owned context
|
||||
Given table "Table 1 via api v2" with emoji "👋" exists for user "participant1-v2" as "t1" via v2
|
||||
And table "Table 2 via api v2" with emoji "📸" exists for user "participant1-v2" as "t2" via v2
|
||||
And user "participant1-v2" creates the Context "c1" with name "Enchanting Guitar" with icon "tennis" and description "Lorem ipsum dolor etc pp" and nodes:
|
||||
| alias | type | permissions |
|
||||
| t1 | table | read,created,update |
|
||||
When user "participant1-v2" updates Context "c1" by setting
|
||||
| property | value |
|
||||
| name | Psychedelic Drawer |
|
||||
| iconName | thermostat |
|
||||
| description | Roll With the Punches |
|
||||
Then the reported status is "200"
|
||||
When user "participant1-v2" fetches Context "c1"
|
||||
Then known Context "c1" has "name" set to "Psychedelic Drawer"
|
||||
And known Context "c1" has "icon" set to "thermostat"
|
||||
And known Context "c1" has "description" set to "Roll With the Punches"
|
||||
|
||||
@api2 @contexts @contexts-update
|
||||
Scenario: Update an inaccessible context
|
||||
Given table "Table 1 via api v2" with emoji "👋" exists for user "participant1-v2" as "t1" via v2
|
||||
And table "Table 2 via api v2" with emoji "📸" exists for user "participant1-v2" as "t2" via v2
|
||||
And user "participant1-v2" creates the Context "c1" with name "Enchanting Guitar" with icon "tennis" and description "Lorem ipsum dolor etc pp" and nodes:
|
||||
| alias | type | permissions |
|
||||
| t1 | table | read,created,update |
|
||||
When user "participant2-v2" updates Context "c1" by setting
|
||||
| property | value |
|
||||
| name | Psychedelic Drawer |
|
||||
| iconName | thermostat |
|
||||
| description | Roll With the Punches |
|
||||
Then the reported status is "404"
|
||||
When user "participant1-v2" fetches Context "c1"
|
||||
Then known Context "c1" has "name" set to "Enchanting Guitar"
|
||||
And known Context "c1" has "icon" set to "tennis"
|
||||
And known Context "c1" has "description" set to "Lorem ipsum dolor etc pp"
|
||||
|
||||
@api2 @contexts @contexts-update
|
||||
Scenario: Add a table to an owned context
|
||||
Given table "Table 1 via api v2" with emoji "👋" exists for user "participant1-v2" as "t1" via v2
|
||||
And table "Table 2 via api v2" with emoji "📸" exists for user "participant1-v2" as "t2" via v2
|
||||
And user "participant1-v2" creates the Context "c1" with name "Enchanting Guitar" with icon "tennis" and description "Lorem ipsum dolor etc pp" and nodes:
|
||||
| alias | type | permissions |
|
||||
| t1 | table | read,create,update |
|
||||
When user "participant1-v2" updates the nodes of the Context "c1" to
|
||||
| alias | type | permissions |
|
||||
| t1 | table | read,create,update |
|
||||
| t2 | table | read |
|
||||
Then the reported status is "200"
|
||||
When user "participant1-v2" fetches Context "c1"
|
||||
Then the fetched Context "c1" has following data:
|
||||
| field | value |
|
||||
| node | table:t1:read,create,update |
|
||||
| node | table:t2:read |
|
||||
|
||||
@api2 @contexts @contexts-update
|
||||
Scenario: Add a table to an inaccessible context
|
||||
Given table "Table 1 via api v2" with emoji "👋" exists for user "participant1-v2" as "t1" via v2
|
||||
And table "Table 2 via api v2" with emoji "📸" exists for user "participant2-v2" as "t2" via v2
|
||||
And user "participant1-v2" creates the Context "c1" with name "Enchanting Guitar" with icon "tennis" and description "Lorem ipsum dolor etc pp" and nodes:
|
||||
| alias | type | permissions |
|
||||
| t1 | table | read,create,update |
|
||||
When user "participant2-v2" updates the nodes of the Context "c1" to
|
||||
| alias | type | permissions |
|
||||
| t1 | table | read,create |
|
||||
| t2 | table | read |
|
||||
Then the reported status is "404"
|
||||
When user "participant1-v2" fetches Context "c1"
|
||||
Then the fetched Context "c1" has following data:
|
||||
| field | value |
|
||||
| node | table:t1:read,create,update |
|
||||
|
||||
@api2 @contexts @contexts-update
|
||||
Scenario: Add an inaccessible table to an owned context
|
||||
Given table "Table 1 via api v2" with emoji "👋" exists for user "participant1-v2" as "t1" via v2
|
||||
And table "Table 2 via api v2" with emoji "📸" exists for user "participant2-v2" as "t2" via v2
|
||||
And user "participant1-v2" creates the Context "c1" with name "Enchanting Guitar" with icon "tennis" and description "Lorem ipsum dolor etc pp" and nodes:
|
||||
| alias | type | permissions |
|
||||
| t1 | table | read,created,update |
|
||||
When user "participant1-v2" updates the nodes of the Context "c1" to
|
||||
| alias | type | permissions |
|
||||
| t1 | table | read,create,update |
|
||||
| t2 | table | read |
|
||||
Then the reported status is "200"
|
||||
When user "participant1-v2" fetches Context "c1"
|
||||
Then the fetched Context "c1" has following data:
|
||||
| field | value |
|
||||
| node | table:t1:read,create,update |
|
||||
And the fetched Context "c1" does not contain following data:
|
||||
| field | value |
|
||||
| node | table:t2:read |
|
||||
|
@ -1869,7 +1869,7 @@ class FeatureContext implements Context {
|
||||
$permissions = $this->humanReadablePermissionToInt($strPermission);
|
||||
$found = false;
|
||||
foreach ($actualData['nodes'] as $actualNodeData) {
|
||||
$found |= ($actualNodeData['node_id'] === $nodeId
|
||||
$found = $found || ($actualNodeData['node_id'] === $nodeId
|
||||
&& $actualNodeData['node_type'] === $nodeType
|
||||
&& $actualNodeData['permissions'] === $permissions);
|
||||
}
|
||||
@ -1879,7 +1879,7 @@ class FeatureContext implements Context {
|
||||
[$pageType, $contentNodesCount] = explode(':', $value);
|
||||
$found = false;
|
||||
foreach ($actualData['pages'] as $actualPageData) {
|
||||
$found |= ($actualPageData['type'] === $pageType
|
||||
$found = $found || ($actualPageData['type'] === $pageType
|
||||
&& count($actualPageData['content']) === (int)$contentNodesCount);
|
||||
}
|
||||
Assert::assertTrue($found);
|
||||
@ -1888,6 +1888,46 @@ class FeatureContext implements Context {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Given the fetched Context :contextAlias does not contain following data:
|
||||
*/
|
||||
public function theFetchedContextDoesNotContainFollowingData(string $contextAlias, TableNode $expectedData) {
|
||||
$actualData = $this->collectionManager->getByAlias('context', $contextAlias);
|
||||
|
||||
foreach ($expectedData as $field => $value) {
|
||||
switch ($field) {
|
||||
case "name":
|
||||
Assert::assertNotEquals($value, $actualData['name']);
|
||||
break;
|
||||
case "icon":
|
||||
Assert::assertNotEquals($value, $actualData['iconName']);
|
||||
break;
|
||||
case "node":
|
||||
[$strType, $alias, $strPermission] = explode(':', $value);
|
||||
$nodeType = $strType === 'table' ? 0 : 1;
|
||||
$nodeId = $nodeType === 0 ? $this->tableIds[$alias] : $this->viewIds[$alias];
|
||||
$permissions = $this->humanReadablePermissionToInt($strPermission);
|
||||
$found = false;
|
||||
foreach ($actualData['nodes'] as $actualNodeData) {
|
||||
$found = $found || ($actualNodeData['node_id'] === $nodeId
|
||||
&& $actualNodeData['node_type'] === $nodeType
|
||||
&& $actualNodeData['permissions'] === $permissions);
|
||||
}
|
||||
Assert::assertFalse($found);
|
||||
break;
|
||||
case "page":
|
||||
[$pageType, $contentNodesCount] = explode(':', $value);
|
||||
$found = false;
|
||||
foreach ($actualData['pages'] as $actualPageData) {
|
||||
$found = $found || ($actualPageData['type'] === $pageType
|
||||
&& count($actualPageData['content']) === (int)$contentNodesCount);
|
||||
}
|
||||
Assert::assertFalse($found);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @When user :user attempts to fetch Context :contextAlias
|
||||
*/
|
||||
@ -2062,4 +2102,42 @@ class FeatureContext implements Context {
|
||||
Assert::assertTrue($exceptionCaught);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When user :user updates Context :contextAlias by setting
|
||||
*/
|
||||
public function userUpdatesContextBySetting(string $user, string $contextAlias, TableNode $updatedProperties) {
|
||||
$this->setCurrentUser($user);
|
||||
$context = $this->collectionManager->getByAlias('context', $contextAlias);
|
||||
|
||||
$this->sendOcsRequest(
|
||||
'PUT',
|
||||
sprintf('/apps/tables/api/2/contexts/%d', $context['id']),
|
||||
$updatedProperties
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When user :user updates the nodes of the Context :contextAlias to
|
||||
*/
|
||||
public function userUpdatesNodesOfContext(string $user, string $contextAlias, TableNode $updatedNodes) {
|
||||
$this->setCurrentUser($user);
|
||||
$context = $this->collectionManager->getByAlias('context', $contextAlias);
|
||||
$nodes = [];
|
||||
|
||||
foreach ($updatedNodes as $row) {
|
||||
$permissions = $this->humanReadablePermissionToInt($row['permissions']);
|
||||
$nodes[] = [
|
||||
'id' => $row['type'] === 'table' ? $this->tableIds[$row['alias']] : $this->viewIds[$row['alias']],
|
||||
'type' => $row['type'] === 'table' ? 0 : 1,
|
||||
'permissions' => $permissions,
|
||||
];
|
||||
}
|
||||
|
||||
$this->sendOcsRequest(
|
||||
'PUT',
|
||||
sprintf('/apps/tables/api/2/contexts/%d', $context['id']),
|
||||
['nodes' => $nodes]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user