mirror of
https://github.com/owncloud/ocis
synced 2026-04-25 17:25:21 +02:00
feat: [OCISDEV-744] core-api-test
This commit is contained in:
@@ -4063,10 +4063,46 @@ trait WebDav {
|
||||
* @throws Exception
|
||||
*/
|
||||
public function theDownloadedPreviewContentShouldMatchWithFixturesPreviewContentFor(string $filename): void {
|
||||
$expectedPreview = \file_get_contents(__DIR__ . "/../fixtures/" . $filename);
|
||||
$fixturePath = __DIR__ . "/../fixtures/" . $filename;
|
||||
$fixtureImg = \imagecreatefromstring(\file_get_contents($fixturePath));
|
||||
Assert::assertNotFalse($fixtureImg, "Could not decode fixture image $filename");
|
||||
|
||||
$this->getResponse()->getBody()->rewind();
|
||||
$responseBodyContent = $this->getResponse()->getBody()->getContents();
|
||||
Assert::assertEquals($expectedPreview, $responseBodyContent);
|
||||
$responseImg = \imagecreatefromstring($responseBodyContent);
|
||||
Assert::assertNotFalse($responseImg, "Downloaded preview is not a valid image");
|
||||
|
||||
$w = \imagesx($fixtureImg);
|
||||
$h = \imagesy($fixtureImg);
|
||||
Assert::assertEquals($w, \imagesx($responseImg), "Image width mismatch for fixture $filename");
|
||||
Assert::assertEquals($h, \imagesy($responseImg), "Image height mismatch for fixture $filename");
|
||||
|
||||
$tolerance = 12; // per-channel tolerance for libvips version differences
|
||||
$maxDiff = 0;
|
||||
for ($x = 0; $x < $w; $x++) {
|
||||
for ($y = 0; $y < $h; $y++) {
|
||||
$fc = \imagecolorat($fixtureImg, $x, $y);
|
||||
$rc = \imagecolorat($responseImg, $x, $y);
|
||||
$maxDiff = \max(
|
||||
$maxDiff,
|
||||
\abs(($fc >> 16 & 0xFF) - ($rc >> 16 & 0xFF)),
|
||||
\abs(($fc >> 8 & 0xFF) - ($rc >> 8 & 0xFF)),
|
||||
\abs(($fc & 0xFF) - ($rc & 0xFF)),
|
||||
);
|
||||
}
|
||||
}
|
||||
$rw = \imagesx($responseImg);
|
||||
$rh = \imagesy($responseImg);
|
||||
echo " [preview-fixture] $filename: fixture={$w}x{$h} response={$rw}x{$rh} maxPixelDiff=$maxDiff\n";
|
||||
|
||||
Assert::assertLessThanOrEqual(
|
||||
$tolerance,
|
||||
$maxDiff,
|
||||
"Preview pixel values differ by more than $tolerance from fixture $filename (max diff: $maxDiff)",
|
||||
);
|
||||
|
||||
\imagedestroy($fixtureImg);
|
||||
\imagedestroy($responseImg);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -355,6 +355,8 @@ def main() -> int:
|
||||
|
||||
# generate IDP web assets (required for IDP service to start; matches drone ci-node-generate)
|
||||
run(["make", "-C", str(repo_root / "services/idp"), "ci-node-generate"])
|
||||
# download web UI assets (required for robots.txt and other static assets; no pnpm needed)
|
||||
run(["make", "-C", str(repo_root / "services/web"), "ci-node-generate"])
|
||||
|
||||
# build (ENABLE_VIPS=true when libvips-dev is installed, matching drone)
|
||||
build_env = {}
|
||||
@@ -646,13 +648,15 @@ def main() -> int:
|
||||
p = Path(ef_override)
|
||||
base_failures = p if p.is_absolute() else repo_root / p
|
||||
|
||||
# merge expected-failures-without-remotephp.md (drone does this)
|
||||
# merge expected-failures-without-remotephp.md only when not using remote.php
|
||||
# (mirrors drone.star: "" if run_with_remote_php else "cat ...without-remotephp.md >> ...")
|
||||
tmp = tempfile.NamedTemporaryFile(mode="w", suffix=".md", delete=False)
|
||||
tmp.write(base_failures.read_text())
|
||||
without_rphp = repo_root / "tests/acceptance/expected-failures-without-remotephp.md"
|
||||
if without_rphp.exists():
|
||||
tmp.write("\n")
|
||||
tmp.write(without_rphp.read_text())
|
||||
if os.environ.get("WITH_REMOTE_PHP", "false").lower() != "true":
|
||||
without_rphp = repo_root / "tests/acceptance/expected-failures-without-remotephp.md"
|
||||
if without_rphp.exists():
|
||||
tmp.write("\n")
|
||||
tmp.write(without_rphp.read_text())
|
||||
tmp.close()
|
||||
|
||||
# run tests
|
||||
|
||||
Reference in New Issue
Block a user