|
11 | 11 | $response->assertSee('Payments', false); |
12 | 12 | }); |
13 | 13 |
|
| 14 | +it('discovers available versions correctly', function () { |
| 15 | + // Set up supported locales |
| 16 | + config(['pertuk.supported_locales' => ['en', 'ckb']]); |
| 17 | + |
| 18 | + // Create versioned directories |
| 19 | + $this->createTestMarkdownFile('test.md', '# Test', '', 'en', 'v1.0'); |
| 20 | + $this->createTestMarkdownFile('test.md', '# Test', '', 'ckb', 'v2.0'); |
| 21 | + |
| 22 | + $versions = \Xoshbin\Pertuk\Services\DocumentationService::getAvailableVersions(); |
| 23 | + |
| 24 | + expect($versions)->toBeArray(); |
| 25 | + expect($versions)->toContain('v1.0'); |
| 26 | + expect($versions)->toContain('v2.0'); |
| 27 | + expect($versions[0])->toBe('v2.0'); // Latest first |
| 28 | +}); |
| 29 | + |
14 | 30 | it('renders a doc page with TOC and breadcrumbs', function () { |
15 | 31 | // Create a test document with multiple headings for TOC |
16 | 32 | $content = "---\ntitle: Receipt and Payment Vouchers\norder: 2\n---\n\n# Receipt and Payment Vouchers\n\n## Overview\n\nThis section covers vouchers.\n\n### Types of Vouchers\n\nDifferent types available.\n\n```php\n\$voucher = new Voucher();\n```\n\n## Processing\n\nHow to process vouchers."; |
|
82 | 98 | expect($data)->toHaveCount(1); |
83 | 99 | expect($data[0])->toHaveKeys(['id', 'slug', 'title', 'heading', 'content', 'anchor']); |
84 | 100 | }); |
| 101 | + |
| 102 | +it('shows versioned documentation search index', function () { |
| 103 | + // Create a test document in a versioned directory |
| 104 | + $this->createTestMarkdownFile('test-v1.md', "# V1 Document\n\n## Subheading\n\nContent", '', 'en', 'v1'); |
| 105 | + |
| 106 | + // Attempt to access versioned search index via route |
| 107 | + $response = $this->get('/docs/v1/en/index.json'); |
| 108 | + |
| 109 | + $response->assertStatus(200); |
| 110 | + $response->assertJsonFragment(['slug' => 'test-v1']); |
| 111 | +}); |
| 112 | + |
| 113 | +it('renders search input with dynamic data attributes', function () { |
| 114 | + // Set up test doc |
| 115 | + $this->createTestMarkdownFile('welcome.md', '# Welcome'); |
| 116 | + |
| 117 | + // Get a page with the header |
| 118 | + $response = $this->get('/docs/en/welcome'); |
| 119 | + $response->assertOk(); |
| 120 | + |
| 121 | + $indexUrl = route('pertuk.docs.search.json', ['locale' => 'en']); |
| 122 | + $baseUrl = url('/docs/en'); |
| 123 | + |
| 124 | + $response->assertSee('data-index-url="'.$indexUrl.'"', false); |
| 125 | + $response->assertSee('data-base-url="'.$baseUrl.'"', false); |
| 126 | +}); |
| 127 | + |
| 128 | +it('renders versioned search input with dynamic data attributes', function () { |
| 129 | + // Set up versioned test doc |
| 130 | + $this->createTestMarkdownFile('v10-welcome.md', '# V10 Welcome', '', 'en', 'v10.0'); |
| 131 | + |
| 132 | + // Get a versioned page |
| 133 | + $response = $this->get('/docs/v10.0/en/v10-welcome'); |
| 134 | + $response->assertOk(); |
| 135 | + |
| 136 | + $indexUrl = route('pertuk.docs.version.search.json', ['version' => 'v10.0', 'locale' => 'en']); |
| 137 | + $baseUrl = url('/docs/v10.0/en'); |
| 138 | + |
| 139 | + $response->assertSee('data-index-url="'.$indexUrl.'"', false); |
| 140 | + $response->assertSee('data-base-url="'.$baseUrl.'"', false); |
| 141 | +}); |
0 commit comments