Skip to content

Commit

Permalink
test: wait after share creation request
Browse files Browse the repository at this point in the history
  • Loading branch information
saw-jan committed Nov 26, 2024
1 parent 47f0e51 commit e83f17e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
9 changes: 9 additions & 0 deletions tests/acceptance/TestHelpers/GraphHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ private static function getRequestHeaders(): array {
];
}

/**
* @param string $url
*
* @return bool
*/
public static function isShareRequest(string $url): bool {
return \str_ends_with($url, '/invite');
}

/**
*
* @return string
Expand Down
19 changes: 14 additions & 5 deletions tests/acceptance/TestHelpers/WebDavHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ public static function isDAVRequest(string $url): bool {
/**
* @return void
*/
public static function waitForAsyncPropagation(): void {
usleep(self::asyncPropagationDelay() * 1000);
public static function waitForAsyncPropagation(int $extraWait): void {
$delay = self::asyncPropagationDelay() + $extraWait;
usleep($delay * 1000);
}

/**
Expand All @@ -116,14 +117,22 @@ public static function waitForAsyncPropagation(): void {
* @return void
*/
public static function waitAsyncPropagationAfterRequest(string $url, string $method, int $statusCode): void {
$methods = ["POST", "PUT", "MKCOL", "MOVE", "COPY", "DELETE"];
$longerWaitMethods = ["MKCOL", "MOVE", "COPY", "DELETE"];
$methods = \array_merge($longerWaitMethods, ["POST", "PUT"]);

if (WebdavHelper::isDAVRequest($url)
if ((WebdavHelper::isDAVRequest($url) || GraphHelper::isShareRequest($url))
&& \str_starts_with($url, OcisHelper::getServerUrl())
&& \in_array($method, $methods)
&& $statusCode < 300
) {
self::waitForAsyncPropagation();
$extraWait = 0;
if (\in_array($method, $longerWaitMethods)) {
// folder related requests require more time
// wait longer for these methods
// increase wait by 300ms
$extraWait = 300;
}
self::waitForAsyncPropagation($extraWait);
}
}

Expand Down

0 comments on commit e83f17e

Please sign in to comment.