@@ -357,6 +357,63 @@ function tiaViteAliasResults(): array
357357 return $cache = ['roots' => $roots, 'aliases' => $aliases];
358358}
359359
360+ function tiaViteCasingFixtures(): array
361+ {
362+ return [
363+ 'exact' => ['resources/js/pages', true],
364+ 'wrong leaf' => ['resources/js/Pages', false],
365+ 'wrong parent' => ['Resources/js/pages', false],
366+ 'absent' => ['assets/js/pages', false],
367+ ];
368+ }
369+
370+ function tiaViteCasingResults(): array
371+ {
372+ static $cache = null;
373+ if ($cache !== null) {
374+ return $cache;
375+ }
376+
377+ $root = sys_get_temp_dir().'/pest-tia-vite-casing-'.bin2hex(random_bytes(6));
378+ mkdir($root.'/resources/js/pages', 0755, true);
379+ file_put_contents($root.'/resources/js/pages/Dashboard.vue', "<template>ok</template>\n");
380+
381+ $helper = str_replace('\\', '/', tiaViteHelperPath());
382+ $normalized = str_replace('\\', '/', $root);
383+
384+ $payload = [];
385+ foreach (tiaViteCasingFixtures() as $name => [$candidate]) {
386+ $payload[] = ['name' => $name, 'candidate' => $candidate];
387+ }
388+
389+ $inputFile = tempnam(sys_get_temp_dir(), 'tia-vite-casing-');
390+ file_put_contents($inputFile, json_encode($payload));
391+ $input = str_replace('\\', '/', $inputFile);
392+
393+ $script = <<<JS
394+ import { matchesDiskCasing } from '{$helper}'
395+ import { readFileSync } from 'node:fs'
396+ const cases = JSON.parse(readFileSync('{$input}', 'utf8'))
397+ const out = {}
398+ for (const c of cases) out[c.name] = await matchesDiskCasing('{$normalized}', c.candidate)
399+ process.stdout.write(JSON.stringify(out))
400+ JS;
401+
402+ $process = new Process(['node', '--input-type=module', '-e', $script]);
403+ $process->mustRun();
404+
405+ $results = json_decode($process->getOutput(), true, flags: JSON_THROW_ON_ERROR);
406+
407+ @unlink($inputFile);
408+ @unlink($root.'/resources/js/pages/Dashboard.vue');
409+ @rmdir($root.'/resources/js/pages');
410+ @rmdir($root.'/resources/js');
411+ @rmdir($root.'/resources');
412+ @rmdir($root);
413+
414+ return $cache = $results;
415+ }
416+
360417beforeEach(function (): void {
361418 if ((new ExecutableFinder)->find('node') === null) {
362419 $this->markTestSkipped('node is not available.');
@@ -409,3 +466,9 @@ function tiaViteAliasResults(): array
409466
410467 expect($results['aliases'][$name])->toEqual($expected);
411468})->with(array_keys(tiaViteAliasFixtures()));
469+
470+ it('accepts a page directory candidate only when it matches the casing on disk', function (string $name): void {
471+ [, $expected] = tiaViteCasingFixtures()[$name];
472+
473+ expect(tiaViteCasingResults()[$name])->toBe($expected);
474+ })->with(array_keys(tiaViteCasingFixtures()));
0 commit comments