Skip to content

Commit

Permalink
Testing: Fixed issues during pre-release testing
Browse files Browse the repository at this point in the history
- Updated locale list
- Fixed new name sorting not being case insensitive
- Updated license test to account for changed deps
  • Loading branch information
ssddanbrown committed Feb 26, 2025
1 parent 6211d6b commit 13dae24
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/Sorting/SortSetOperationComparisons.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ class SortSetOperationComparisons
{
public static function nameAsc(Entity $a, Entity $b): int
{
return $a->name <=> $b->name;
return strtolower($a->name) <=> strtolower($b->name);
}

public static function nameDesc(Entity $a, Entity $b): int
{
return $b->name <=> $a->name;
return strtolower($b->name) <=> strtolower($a->name);
}

public static function nameNumericAsc(Entity $a, Entity $b): int
Expand Down
1 change: 1 addition & 0 deletions app/Translation/LocaleManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class LocaleManager
'ja' => 'ja',
'ka' => 'ka_GE',
'ko' => 'ko_KR',
'ku' => 'ku_TR',
'lt' => 'lt_LT',
'lv' => 'lv_LV',
'nb' => 'nb_NO',
Expand Down
2 changes: 1 addition & 1 deletion tests/Meta/LicensesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function test_licenses_endpoint()
$resp->assertSee('Licenses');
$resp->assertSee('PHP Library Licenses');
$resp->assertSee('Dan Brown and the BookStack project contributors');
$resp->assertSee('doctrine/dbal');
$resp->assertSee('league/commonmark');
$resp->assertSee('@codemirror/lang-html');
}

Expand Down
34 changes: 34 additions & 0 deletions tests/Sorting/SortRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,40 @@ public function test_auto_book_sort_does_not_touch_timestamps()
$this->assertNotEquals($oldPriority, $chapter->priority);
}

public function test_name_alphabetical_ordering()
{
$book = Book::factory()->create();
$rule = SortRule::factory()->create(['sequence' => 'name_asc']);
$book->sort_rule_id = $rule->id;
$book->save();
$this->permissions->regenerateForEntity($book);

$namesToAdd = [
"Beans",
"bread",
"Milk",
"pizza",
"Tomato",
];

$reverseNamesToAdd = array_reverse($namesToAdd);
foreach ($reverseNamesToAdd as $name) {
$this->actingAsApiEditor()->post("/api/pages", [
'book_id' => $book->id,
'name' => $name,
'markdown' => 'Hello'
]);
}

foreach ($namesToAdd as $index => $name) {
$this->assertDatabaseHas('pages', [
'book_id' => $book->id,
'name' => $name,
'priority' => $index + 1,
]);
}
}

public function test_name_numeric_ordering()
{
$book = Book::factory()->create();
Expand Down

0 comments on commit 13dae24

Please sign in to comment.