Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.x] Honour front matter navigation groups set in front matter regardless of subdirectory setting #1704

Merged
merged 20 commits into from
Apr 30, 2024
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
c0ada2c
Update navigation data factory to return explicitly set group
caendesilva Apr 29, 2024
569892a
Revert "Update navigation data factory to return explicitly set group"
caendesilva Apr 29, 2024
7416aae
Update unit test to cover explicit group configurations
caendesilva Apr 29, 2024
f612126
Add helper to check if group is explicitly set in front matter
caendesilva Apr 29, 2024
0a5e529
Enable dropdowns when explicitly set in front matter
caendesilva Apr 29, 2024
87c3e19
Add clarifying parentheses
caendesilva Apr 29, 2024
9dda19f
Add condition to exclude documentation page from state check
caendesilva Apr 29, 2024
a3fc702
Introduce private state cache to fix idempotency issue
caendesilva Apr 29, 2024
7b312f5
Make helper private
caendesilva Apr 29, 2024
aa262a6
Add clarifying parentheses
caendesilva Apr 29, 2024
917dcb3
Generate tests with ChatGPT
caendesilva Apr 29, 2024
37d0ccb
Clean up generated tests
caendesilva Apr 29, 2024
ee7e8a6
Update RELEASE_NOTES.md
caendesilva Apr 30, 2024
3d2d696
Merge pull request #1703 from hydephp/enable-dropdowns-when-set-in-fr…
caendesilva Apr 30, 2024
e666371
Merge branch 'master' into 2.x-dev
caendesilva Apr 30, 2024
da080b8
Fix test method order
caendesilva Apr 30, 2024
b92841e
Use new helper
caendesilva Apr 30, 2024
eb81e60
Remove tests for methods not present in v2
caendesilva Apr 30, 2024
b330ff5
Merge helper method into new code location
caendesilva Apr 30, 2024
3ed0453
Revert "Merge helper method into new code location"
caendesilva Apr 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions packages/framework/tests/Unit/NavigationDataFactoryUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,36 @@ public function testSearchForHiddenInConfigsSelectsCorrectConfigurationBasedOnPa
$this->assertFalse($factory->makeHidden());
}

public function testMakeGroupUsesFrontMatterGroupIfSet()
{
$frontMatter = new FrontMatter(['navigation.group' => 'Test Group']);
$coreDataObject = new CoreDataObject($frontMatter, new Markdown(), MarkdownPage::class, 'test.md', '', '', '');
$factory = new NavigationConfigTestClass($coreDataObject);

$this->assertSame('Test Group', $factory->makeGroup());
}

public function testMakeGroupUsesFrontMatterGroupIfSetRegardlessOfSubdirectoryConfiguration()
{
self::mockConfig(['hyde.navigation.subdirectories' => 'hidden']);

$frontMatter = new FrontMatter(['navigation.group' => 'Test Group']);
$coreDataObject = new CoreDataObject($frontMatter, new Markdown(), MarkdownPage::class, 'test.md', '', '', '');
$factory = new NavigationConfigTestClass($coreDataObject);

$this->assertSame('Test Group', $factory->makeGroup());
}

public function testMakeGroupDefaultsToNullIfFrontMatterGroupNotSetAndSubdirectoriesNotUsed()
{
self::mockConfig(['hyde.navigation.subdirectories' => 'hidden']);

$coreDataObject = new CoreDataObject(new FrontMatter(), new Markdown(), MarkdownPage::class, 'test.md', '', '', '');
$factory = new NavigationConfigTestClass($coreDataObject);

$this->assertNull($factory->makeGroup());
}

protected function makeCoreDataObject(string $identifier = '', string $routeKey = '', string $pageClass = MarkdownPage::class): CoreDataObject
{
return new CoreDataObject(new FrontMatter(), new Markdown(), $pageClass, $identifier, '', '', $routeKey);
Expand Down Expand Up @@ -264,4 +294,9 @@ public function makeHidden(): bool
{
return parent::makeHidden();
}

public function makeGroup(): ?string
{
return parent::makeGroup();
}
}