Fix import status regression from appload 404 + tighten upgrade tests

- itemImport: check response.ok in fetchAppDetails so a genuine 404
  (from the appload return-type fix) is reported as 'Failed to find app
  id' instead of being parsed as a successful import; applied to the
  source and the committed compiled bundle.
- phpunit.xml: point the schema URL at 12.5 to match the installed
  PHPUnit 12.5.x.
- ColorHelpersTest: exercise the get_brightness() non-hex stripping the
  test name promised (interior separators), which the prior assertion
  never covered.
This commit is contained in:
KodeStar
2026-07-09 09:28:53 +01:00
parent 13642d59d9
commit 6f932918aa
4 changed files with 20 additions and 2 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true" cacheDirectory=".phpunit.cache">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.5/phpunit.xsd" bootstrap="vendor/autoload.php" colors="true" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
+3
View File
@@ -4484,6 +4484,9 @@ var fetchAppDetails = function fetchAppDetails(appId) {
app: appId
})
}).then(function (response) {
if (!response.ok) {
return Promise.reject(new Error("Failed to find app id: ".concat(appId)));
}
return response.json();
});
};
+10 -1
View File
@@ -92,7 +92,16 @@ const fetchAppDetails = (appId) => {
"Content-Type": "application/json",
},
body: JSON.stringify({ app: appId }),
}).then((response) => response.json());
}).then((response) => {
// A missing app now returns a genuine 404 (see ItemController::appload).
// fetch() does not reject on 4xx, so surface it as a rejection here to
// keep importItems reporting "Failed to find app id" rather than treating
// the {"error":...} body as a successful import.
if (!response.ok) {
return Promise.reject(new Error(`Failed to find app id: ${appId}`));
}
return response.json();
});
};
/**
+6
View File
@@ -35,6 +35,12 @@ class ColorHelpersTest extends TestCase
{
// A value without the leading # must decode identically.
$this->assertEqualsWithDelta(255, get_brightness('ffffff'), 0.0001);
// Interior non-hex separators (the "other non-hex" in the name) must be
// stripped before decoding, so these normalise to ffffff. If the
// preg_replace were dropped these would decode to a different value.
$this->assertEqualsWithDelta(255, get_brightness('#ff:ff:ff'), 0.0001);
$this->assertEqualsWithDelta(255, get_brightness('ff-ff-ff'), 0.0001);
}
public function test_get_brightness_weights_channels_per_luma_formula(): void