@jjlmoya/utils-pets 1.21.0 → 1.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/package.json +2 -2
  2. package/src/category/i18n/de.ts +1 -1
  3. package/src/category/i18n/en.ts +2 -2
  4. package/src/category/i18n/es.ts +1 -1
  5. package/src/category/i18n/fr.ts +1 -1
  6. package/src/category/i18n/pt.ts +1 -1
  7. package/src/category/i18n/tr.ts +1 -1
  8. package/src/category/index.ts +28 -27
  9. package/src/entries.ts +16 -13
  10. package/src/index.ts +1 -0
  11. package/src/tests/bibliography_wellformed_export.test.ts +46 -0
  12. package/src/tests/category_seo_quality.test.ts +74 -0
  13. package/src/tests/faq_count.test.ts +22 -22
  14. package/src/tests/i18n_coverage.test.ts +5 -2
  15. package/src/tests/locale_completeness.test.ts +31 -31
  16. package/src/tests/no_h1_in_components.test.ts +1 -1
  17. package/src/tests/pet_logic.test.ts +49 -0
  18. package/src/tests/qa-test-helpers.ts +32 -0
  19. package/src/tests/qa_bibliography_links.test.ts +40 -0
  20. package/src/tests/qa_claim_evidence.test.ts +69 -0
  21. package/src/tests/qa_logic_reference_coverage.test.ts +46 -0
  22. package/src/tests/qa_runtime_i18n.test.ts +100 -0
  23. package/src/tests/seo_length.test.ts +54 -54
  24. package/src/tests/seo_parity.test.ts +2 -2
  25. package/src/tests/seo_wellformed_export.test.ts +65 -0
  26. package/src/tests/spanish_leakage.test.ts +175 -175
  27. package/src/tests/tool_validation.test.ts +139 -139
  28. package/src/tool/petAge/component.astro +3 -3
  29. package/src/tool/petAge/i18n/de.ts +184 -184
  30. package/src/tool/petAge/i18n/en.ts +184 -184
  31. package/src/tool/petAge/i18n/es.ts +184 -184
  32. package/src/tool/petAge/i18n/fr.ts +184 -184
  33. package/src/tool/petAge/i18n/id.ts +184 -184
  34. package/src/tool/petAge/i18n/it.ts +184 -184
  35. package/src/tool/petAge/i18n/ja.ts +184 -184
  36. package/src/tool/petAge/i18n/ko.ts +184 -184
  37. package/src/tool/petAge/i18n/nl.ts +184 -184
  38. package/src/tool/petAge/i18n/pl.ts +184 -184
  39. package/src/tool/petAge/i18n/pt.ts +184 -184
  40. package/src/tool/petAge/i18n/ru.ts +184 -184
  41. package/src/tool/petAge/i18n/sv.ts +184 -184
  42. package/src/tool/petAge/i18n/tr.ts +185 -185
  43. package/src/tool/petAge/i18n/zh.ts +184 -184
  44. package/src/tool/petAge/seo.astro +15 -15
  45. package/src/tool/petCarrierCrateSizePlanner/bibliography.astro +6 -0
  46. package/src/tool/petCarrierCrateSizePlanner/bibliography.ts +12 -0
  47. package/src/tool/petCarrierCrateSizePlanner/component.astro +89 -0
  48. package/src/tool/petCarrierCrateSizePlanner/controller.ts +128 -0
  49. package/src/tool/petCarrierCrateSizePlanner/dom-views.ts +96 -0
  50. package/src/tool/petCarrierCrateSizePlanner/entry.ts +27 -0
  51. package/src/tool/petCarrierCrateSizePlanner/evaluator.ts +14 -0
  52. package/src/tool/petCarrierCrateSizePlanner/i18n/de.ts +171 -0
  53. package/src/tool/petCarrierCrateSizePlanner/i18n/en.ts +171 -0
  54. package/src/tool/petCarrierCrateSizePlanner/i18n/es.ts +171 -0
  55. package/src/tool/petCarrierCrateSizePlanner/i18n/fr.ts +171 -0
  56. package/src/tool/petCarrierCrateSizePlanner/i18n/id.ts +171 -0
  57. package/src/tool/petCarrierCrateSizePlanner/i18n/it.ts +171 -0
  58. package/src/tool/petCarrierCrateSizePlanner/i18n/ja.ts +171 -0
  59. package/src/tool/petCarrierCrateSizePlanner/i18n/ko.ts +171 -0
  60. package/src/tool/petCarrierCrateSizePlanner/i18n/nl.ts +171 -0
  61. package/src/tool/petCarrierCrateSizePlanner/i18n/pl.ts +171 -0
  62. package/src/tool/petCarrierCrateSizePlanner/i18n/pt.ts +171 -0
  63. package/src/tool/petCarrierCrateSizePlanner/i18n/ru.ts +171 -0
  64. package/src/tool/petCarrierCrateSizePlanner/i18n/sv.ts +171 -0
  65. package/src/tool/petCarrierCrateSizePlanner/i18n/tr.ts +171 -0
  66. package/src/tool/petCarrierCrateSizePlanner/i18n/zh.ts +171 -0
  67. package/src/tool/petCarrierCrateSizePlanner/index.ts +12 -0
  68. package/src/tool/petCarrierCrateSizePlanner/logic.test.ts +49 -0
  69. package/src/tool/petCarrierCrateSizePlanner/logic.ts +77 -0
  70. package/src/tool/petCarrierCrateSizePlanner/pet-carrier-crate-size-planner.css +639 -0
  71. package/src/tool/petCarrierCrateSizePlanner/seo.astro +14 -0
  72. package/src/tool/petCarrierCrateSizePlanner/storage.ts +31 -0
  73. package/src/tool/petCarrierCrateSizePlanner/ui.ts +59 -0
  74. package/src/tool/petGestation/i18n/de.ts +0 -2
  75. package/src/tool/petGestation/i18n/en.ts +0 -2
  76. package/src/tool/petGestation/i18n/es.ts +0 -2
  77. package/src/tool/petGestation/i18n/fr.ts +0 -2
  78. package/src/tool/petGestation/i18n/id.ts +0 -2
  79. package/src/tool/petGestation/i18n/it.ts +0 -2
  80. package/src/tool/petGestation/i18n/ja.ts +0 -2
  81. package/src/tool/petGestation/i18n/ko.ts +0 -2
  82. package/src/tool/petGestation/i18n/nl.ts +0 -2
  83. package/src/tool/petGestation/i18n/pl.ts +0 -2
  84. package/src/tool/petGestation/i18n/pt.ts +0 -2
  85. package/src/tool/petGestation/i18n/ru.ts +0 -2
  86. package/src/tool/petGestation/i18n/sv.ts +0 -2
  87. package/src/tool/petGestation/i18n/tr.ts +0 -2
  88. package/src/tool/petGestation/i18n/zh.ts +0 -2
  89. package/src/tool/petGestation/ui.ts +0 -2
  90. package/src/tool/petRation/i18n/de.ts +181 -181
  91. package/src/tool/petRation/i18n/en.ts +181 -181
  92. package/src/tool/petRation/i18n/es.ts +181 -181
  93. package/src/tool/petRation/i18n/fr.ts +181 -181
  94. package/src/tool/petRation/i18n/id.ts +181 -181
  95. package/src/tool/petRation/i18n/it.ts +181 -181
  96. package/src/tool/petRation/i18n/ja.ts +181 -181
  97. package/src/tool/petRation/i18n/ko.ts +181 -181
  98. package/src/tool/petRation/i18n/nl.ts +181 -181
  99. package/src/tool/petRation/i18n/pl.ts +181 -181
  100. package/src/tool/petRation/i18n/pt.ts +181 -181
  101. package/src/tool/petRation/i18n/ru.ts +181 -181
  102. package/src/tool/petRation/i18n/sv.ts +181 -181
  103. package/src/tool/petRation/i18n/tr.ts +181 -181
  104. package/src/tool/petRation/i18n/zh.ts +181 -181
  105. package/src/tool/petRation/seo.astro +15 -15
  106. package/src/tool/petToxicity/i18n/de.ts +0 -2
  107. package/src/tool/petToxicity/i18n/en.ts +0 -2
  108. package/src/tool/petToxicity/i18n/es.ts +2 -4
  109. package/src/tool/petToxicity/i18n/fr.ts +0 -2
  110. package/src/tool/petToxicity/i18n/id.ts +0 -2
  111. package/src/tool/petToxicity/i18n/it.ts +0 -2
  112. package/src/tool/petToxicity/i18n/ja.ts +0 -2
  113. package/src/tool/petToxicity/i18n/ko.ts +0 -2
  114. package/src/tool/petToxicity/i18n/nl.ts +0 -2
  115. package/src/tool/petToxicity/i18n/pl.ts +0 -2
  116. package/src/tool/petToxicity/i18n/pt.ts +0 -2
  117. package/src/tool/petToxicity/i18n/ru.ts +0 -2
  118. package/src/tool/petToxicity/i18n/sv.ts +0 -2
  119. package/src/tool/petToxicity/i18n/tr.ts +0 -2
  120. package/src/tool/petToxicity/i18n/zh.ts +0 -2
  121. package/src/tool/petToxicity/ui.ts +0 -2
  122. package/src/tool/petWaterIntake/i18n/de.ts +0 -15
  123. package/src/tool/petWaterIntake/i18n/en.ts +0 -15
  124. package/src/tool/petWaterIntake/i18n/es.ts +2 -17
  125. package/src/tool/petWaterIntake/i18n/fr.ts +0 -15
  126. package/src/tool/petWaterIntake/i18n/id.ts +0 -15
  127. package/src/tool/petWaterIntake/i18n/it.ts +0 -15
  128. package/src/tool/petWaterIntake/i18n/ja.ts +0 -15
  129. package/src/tool/petWaterIntake/i18n/ko.ts +0 -15
  130. package/src/tool/petWaterIntake/i18n/nl.ts +0 -15
  131. package/src/tool/petWaterIntake/i18n/pl.ts +0 -15
  132. package/src/tool/petWaterIntake/i18n/pt.ts +0 -15
  133. package/src/tool/petWaterIntake/i18n/ru.ts +0 -15
  134. package/src/tool/petWaterIntake/i18n/sv.ts +0 -15
  135. package/src/tool/petWaterIntake/i18n/tr.ts +0 -15
  136. package/src/tool/petWaterIntake/i18n/zh.ts +0 -15
  137. package/src/tool/petWaterIntake/ui.ts +0 -15
  138. package/src/tools.ts +22 -19
@@ -0,0 +1,69 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { existsSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ import { displayPath, listToolDirectories, read } from './qa-test-helpers';
5
+
6
+ const evidenceClaims = [
7
+ /\bofficial algorithm\b/i,
8
+ /\balgoritmo oficial\b/i,
9
+ /\b(?:records|data|rates|tables) updated(?:\s+(?:to|through)\s+20\d{2})?\b/i,
10
+ /\b(?:registros|datos|tasas|tablas) actualizad[oa]s?(?:\s+(?:a|hasta)\s+20\d{2})?\b/i,
11
+ /\b(?:validated|verified) (?:method|algorithm|calculation)\b/i,
12
+ /\b(?:método|algoritmo|cálculo) (?:validado|verificado)\b/i,
13
+ /\b(?:guarantees|ensures)\b/i,
14
+ /\bgarantiza\b/i,
15
+ /\bofficial (?:data|rate|calculation)\b/i,
16
+ /\b(?:datos|tasa|cálculo) oficial(?:es)?\b/i,
17
+ ];
18
+
19
+ const requiredEvidenceFields = [
20
+ 'reviewedAt',
21
+ 'methodology',
22
+ 'sources',
23
+ 'referenceCases',
24
+ 'limitations',
25
+ ];
26
+
27
+ describe('QA: strong factual claims are traceable', () => {
28
+ it('requires machine-readable validation evidence beside tools making strong claims', () => {
29
+ const failures: string[] = [];
30
+
31
+ for (const directory of listToolDirectories()) {
32
+ const localePaths = ['en', 'es']
33
+ .map((locale) => join(directory, 'i18n', `${locale}.ts`))
34
+ .filter(existsSync);
35
+ const claims = localePaths.flatMap((path) => {
36
+ const source = read(path);
37
+ return evidenceClaims
38
+ .filter((pattern) => pattern.test(source))
39
+ .map((pattern) => `${displayPath(path)} matches ${pattern.source}`);
40
+ });
41
+ if (claims.length === 0) continue;
42
+
43
+ const evidencePath = join(directory, 'validation.ts');
44
+ if (!existsSync(evidencePath)) {
45
+ failures.push(`${displayPath(evidencePath)} missing; claims: ${claims.join(' | ')}`);
46
+ continue;
47
+ }
48
+
49
+ const evidence = read(evidencePath);
50
+ const missingFields = requiredEvidenceFields.filter(
51
+ (field) => !new RegExp(`\\b${field}\\s*:`).test(evidence),
52
+ );
53
+ if (missingFields.length > 0) {
54
+ failures.push(`${displayPath(evidencePath)} missing fields: ${missingFields.join(', ')}`);
55
+ }
56
+ }
57
+
58
+ expect(
59
+ failures,
60
+ [
61
+ 'Claims such as official, validated, guaranteed or updated need inspectable evidence.',
62
+ 'Add validation.ts with reviewedAt, methodology, sources, referenceCases and limitations,',
63
+ 'or weaken/remove the unsupported claim.',
64
+ ...failures,
65
+ ].join('\n'),
66
+ ).toEqual([]);
67
+ });
68
+ });
69
+
@@ -0,0 +1,46 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { basename, join } from 'node:path';
3
+ import { existsSync } from 'node:fs';
4
+ import {
5
+ displayPath,
6
+ findFiles,
7
+ listToolDirectories,
8
+ read,
9
+ repositoryRoot,
10
+ } from './qa-test-helpers';
11
+
12
+ function hasDedicatedLogicTest(toolDirectory: string): boolean {
13
+ const localCandidates = [
14
+ join(toolDirectory, 'logic.test.ts'),
15
+ join(toolDirectory, 'logic.spec.ts'),
16
+ join(toolDirectory, '__tests__', 'logic.test.ts'),
17
+ join(toolDirectory, '__tests__', 'logic.spec.ts'),
18
+ ];
19
+ if (localCandidates.some(existsSync)) return true;
20
+
21
+ const toolName = basename(toolDirectory);
22
+ const centralTests = findFiles(join(repositoryRoot, 'src', 'tests'), ['.test.ts', '.spec.ts']);
23
+ return centralTests.some((testPath) => {
24
+ const source = read(testPath).replace(/\\/g, '/');
25
+ return source.includes(`/tool/${toolName}/logic`) || source.includes(`../tool/${toolName}/logic`);
26
+ });
27
+ }
28
+
29
+ describe('QA: calculation logic has reference tests', () => {
30
+ it('gives every public calculator logic module its own behavioral test suite', () => {
31
+ const failures = listToolDirectories()
32
+ .filter((directory) => existsSync(join(directory, 'logic.ts')))
33
+ .filter((directory) => !hasDedicatedLogicTest(directory))
34
+ .map((directory) => `${displayPath(join(directory, 'logic.ts'))} -> no test imports this module`);
35
+
36
+ expect(
37
+ failures,
38
+ [
39
+ 'Add behavioral tests through each logic module public API.',
40
+ 'At minimum cover a documented reference case, boundaries, invalid input and invariants.',
41
+ ...failures,
42
+ ].join('\n'),
43
+ ).toEqual([]);
44
+ });
45
+ });
46
+
@@ -0,0 +1,100 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { basename, join } from 'node:path';
3
+ import { existsSync } from 'node:fs';
4
+ import {
5
+ displayPath,
6
+ findFiles,
7
+ listToolDirectories,
8
+ read,
9
+ repositoryRoot,
10
+ } from './qa-test-helpers';
11
+
12
+ interface VisibleLiteral {
13
+ line: number;
14
+ value: string;
15
+ }
16
+
17
+ const domTextAssignment = /\.(?:innerText|textContent|innerHTML)\s*=/;
18
+ const quotedLiteral = /(['"`])((?:\\.|(?!\1).)*)\1/g;
19
+
20
+ function visibleWords(value: string): string {
21
+ return value
22
+ .replace(/\$\{[^}]*\}/g, ' ')
23
+ .replace(/<[^>]+>/g, ' ')
24
+ .replace(/&[a-z]+;/gi, ' ')
25
+ .replace(/[\d\p{P}\p{S}_]+/gu, ' ')
26
+ .replace(/\s+/g, ' ')
27
+ .trim();
28
+ }
29
+
30
+ function isTechnicalLiteral(value: string): boolean {
31
+ return ['.', '#', '['].some((prefix) => value.startsWith(prefix))
32
+ || /^data-[a-z0-9-]+$/i.test(value);
33
+ }
34
+
35
+ function hardcodedVisibleLiterals(source: string): VisibleLiteral[] {
36
+ const failures: VisibleLiteral[] = [];
37
+
38
+ source.split(/\r?\n/).forEach((line, index) => {
39
+ if (!domTextAssignment.test(line)) return;
40
+
41
+ const assignment = line.slice(line.search(domTextAssignment));
42
+ for (const match of assignment.matchAll(quotedLiteral)) {
43
+ const value = match[2];
44
+ if (!value || isTechnicalLiteral(value)) continue;
45
+ const words = visibleWords(value);
46
+ if (words && /\p{L}/u.test(words)) {
47
+ failures.push({ line: index + 1, value });
48
+ }
49
+ }
50
+ });
51
+
52
+ return failures;
53
+ }
54
+
55
+ function runtimeSources(toolDirectory: string): string {
56
+ return findFiles(toolDirectory, ['.astro', '.ts', '.js'])
57
+ .filter((path) => !path.includes(`${join(toolDirectory, 'i18n')}`))
58
+ .filter((path) => basename(path) !== 'ui.ts')
59
+ .map(read)
60
+ .join('\n');
61
+ }
62
+
63
+ describe('QA: runtime copy is localized', () => {
64
+ const componentFiles = findFiles(join(repositoryRoot, 'src', 'tool'), ['.astro']);
65
+
66
+ it('does not write user-facing string literals directly into the DOM', () => {
67
+ const failures = componentFiles.flatMap((path) =>
68
+ hardcodedVisibleLiterals(read(path)).map(
69
+ ({ line, value }) => `${displayPath(path)}:${line} -> ${JSON.stringify(value)}`,
70
+ ),
71
+ );
72
+
73
+ expect(
74
+ failures,
75
+ `Move visible browser copy to the tool UI locale contract:\n${failures.join('\n')}`,
76
+ ).toEqual([]);
77
+ });
78
+
79
+ it('uses every string declared by each UI locale contract', () => {
80
+ const failures: string[] = [];
81
+
82
+ for (const directory of listToolDirectories()) {
83
+ const uiPath = join(directory, 'ui.ts');
84
+ if (!existsSync(uiPath)) continue;
85
+
86
+ const keys = Array.from(read(uiPath).matchAll(/^\s*(\w+)\??:\s*string\s*;/gm), (match) => match[1]);
87
+ const runtime = runtimeSources(directory);
88
+ const unused = keys.filter((key) => !new RegExp(`\\b${key}\\b`).test(runtime));
89
+
90
+ if (unused.length > 0) {
91
+ failures.push(`${displayPath(uiPath)} -> unused: ${unused.join(', ')}`);
92
+ }
93
+ }
94
+
95
+ expect(
96
+ failures,
97
+ `Unused locale keys are dead copy or may mean the browser bypasses translations:\n${failures.join('\n')}`,
98
+ ).toEqual([]);
99
+ });
100
+ });
@@ -1,54 +1,54 @@
1
- import { describe, it, expect } from 'vitest';
2
- import * as DATA from '../data';
3
-
4
- const ENTRIES = [
5
- { id: 'petAge', i18n: DATA.petAge.i18n },
6
- { id: 'petRation', i18n: DATA.petRation.i18n },
7
- { id: 'petsCategory', i18n: DATA.petsCategory.i18n },
8
- ];
9
-
10
- describe('SEO Content Length Validation', () => {
11
- ENTRIES.forEach((entry) => {
12
- describe(`Tool: ${entry.id}`, () => {
13
- Object.keys(entry.i18n).forEach((locale) => {
14
- it(`${locale}: SEO section should contain between 400 and 900 words`, async () => {
15
- const loader = (entry.i18n as any)[locale];
16
- const content = await loader();
17
- if (!content.seo) return;
18
-
19
- let combinedText = '';
20
- content.seo.forEach((section: any) => {
21
- if (section.text) combinedText += section.text + ' ';
22
- if (section.html) combinedText += section.html + ' ';
23
- if (section.title) combinedText += section.title + ' ';
24
- if (section.items) {
25
- section.items.forEach((item: any) => {
26
- if (typeof item === 'string') combinedText += item + ' ';
27
- else {
28
- if (item.label) combinedText += item.label + ' ';
29
- if (item.value) combinedText += item.value + ' ';
30
- if (item.term) combinedText += item.term + ' ';
31
- if (item.definition) combinedText += item.definition + ' ';
32
- if (item.pro) combinedText += item.pro + ' ';
33
- if (item.con) combinedText += item.con + ' ';
34
- }
35
- });
36
- }
37
- if (section.headers) combinedText += section.headers.join(' ') + ' ';
38
- if (section.rows) {
39
- section.rows.forEach((row: string[]) => {
40
- combinedText += row.join(' ') + ' ';
41
- });
42
- }
43
- });
44
-
45
- const cleanText = combinedText.replace(/<[^>]*>?/gm, ' ').trim();
46
- const words = cleanText.split(/\s+/).filter((w: string) => w.length > 0);
47
-
48
- expect(words.length, `Tool ${entry.id} (${locale}) has ${words.length} words. Target: 400-900.`).toBeGreaterThanOrEqual(400);
49
- expect(words.length, `Tool ${entry.id} (${locale}) has ${words.length} words. Target: 400-900.`).toBeLessThanOrEqual(900);
50
- });
51
- });
52
- });
53
- });
54
- });
1
+ import { describe, it, expect } from 'vitest';
2
+ import * as DATA from '../data';
3
+
4
+ const ENTRIES = [
5
+ { id: 'petAge', i18n: DATA.petAge.i18n },
6
+ { id: 'petRation', i18n: DATA.petRation.i18n },
7
+ { id: 'petsCategory', i18n: DATA.petsCategory.i18n },
8
+ ];
9
+
10
+ describe('SEO Content Length Validation', () => {
11
+ ENTRIES.forEach((entry) => {
12
+ describe(`Tool: ${entry.id}`, () => {
13
+ Object.keys(entry.i18n).forEach((locale) => {
14
+ it(`${locale}: SEO section should contain between 400 and 900 words`, async () => {
15
+ const loader = (entry.i18n as any)[locale];
16
+ const content = await loader();
17
+ if (!content.seo) return;
18
+
19
+ let combinedText = '';
20
+ content.seo.forEach((section: any) => {
21
+ if (section.text) combinedText += section.text + ' ';
22
+ if (section.html) combinedText += section.html + ' ';
23
+ if (section.title) combinedText += section.title + ' ';
24
+ if (section.items) {
25
+ section.items.forEach((item: any) => {
26
+ if (typeof item === 'string') combinedText += item + ' ';
27
+ else {
28
+ if (item.label) combinedText += item.label + ' ';
29
+ if (item.value) combinedText += item.value + ' ';
30
+ if (item.term) combinedText += item.term + ' ';
31
+ if (item.definition) combinedText += item.definition + ' ';
32
+ if (item.pro) combinedText += item.pro + ' ';
33
+ if (item.con) combinedText += item.con + ' ';
34
+ }
35
+ });
36
+ }
37
+ if (section.headers) combinedText += section.headers.join(' ') + ' ';
38
+ if (section.rows) {
39
+ section.rows.forEach((row: string[]) => {
40
+ combinedText += row.join(' ') + ' ';
41
+ });
42
+ }
43
+ });
44
+
45
+ const cleanText = combinedText.replace(/<[^>]*>?/gm, ' ').trim();
46
+ const words = cleanText.split(/\s+/).filter((w: string) => w.length > 0);
47
+
48
+ expect(words.length, `Tool ${entry.id} (${locale}) has ${words.length} words. Target: 400-900.`).toBeGreaterThanOrEqual(400);
49
+ expect(words.length, `Tool ${entry.id} (${locale}) has ${words.length} words. Target: 400-900.`).toBeLessThanOrEqual(900);
50
+ });
51
+ });
52
+ });
53
+ });
54
+ });
@@ -27,7 +27,7 @@ async function verifyLocaleParity(
27
27
  expect(
28
28
  locSeoCount,
29
29
  `Locale ${loc} SEO sections count (${locSeoCount}) must match EN (${expected.seo})`,
30
- ).toBe(expected.seo);
30
+ ).toBeGreaterThanOrEqual(expected.seo);
31
31
  expect(
32
32
  locFaqCount,
33
33
  `Locale ${loc} FAQ items count (${locFaqCount}) must match EN (${expected.faq})`,
@@ -41,7 +41,7 @@ async function verifyLocaleParity(
41
41
  describe('SEO & i18n Structural Parity Suite', () => {
42
42
  ALL_ENTRIES.forEach((entry) => {
43
43
  describe(`Tool: ${entry.id}`, () => {
44
- it('all 15 locales should have identical SEO section counts and types as English', async () => {
44
+ it('all 15 locales should provide at least the complete English SEO section set', async () => {
45
45
  const enContent = await entry.i18n.en?.();
46
46
  expect(enContent).toBeDefined();
47
47
  const expected: ExpectedCounts = {
@@ -0,0 +1,65 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { readdirSync, readFileSync, existsSync } from 'fs';
3
+ import { join, relative } from 'path';
4
+
5
+ function findSeoAstroFiles(dir: string): string[] {
6
+ const files: string[] = [];
7
+ if (!existsSync(dir)) return files;
8
+ const entries = readdirSync(dir, { withFileTypes: true });
9
+
10
+ for (const entry of entries) {
11
+ const fullPath = join(dir, entry.name);
12
+ if (entry.isDirectory()) {
13
+ files.push(...findSeoAstroFiles(fullPath));
14
+ } else if (entry.isFile() && entry.name === 'seo.astro') {
15
+ files.push(fullPath);
16
+ }
17
+ }
18
+
19
+ return files;
20
+ }
21
+
22
+ const toolDir = join(process.cwd(), 'src', 'tool');
23
+ const seoFiles = findSeoAstroFiles(toolDir);
24
+
25
+ describe('SEO Component Wellformed Export', () => {
26
+ it('found tool seo.astro components', () => {
27
+ expect(seoFiles.length).toBeGreaterThan(0);
28
+ });
29
+
30
+ seoFiles.forEach((file) => {
31
+ const relativePath = relative(process.cwd(), file);
32
+
33
+ it(`${relativePath} should dynamically load SEO sections and use SEORenderer`, () => {
34
+ const content = readFileSync(file, 'utf-8');
35
+
36
+ const usesSeoRenderer =
37
+ content.includes('@jjlmoya/utils-shared') &&
38
+ (content.includes('SEORenderer') || content.includes('SEOArticle'));
39
+
40
+ const acquiresDynamicContent =
41
+ content.includes('.i18n') ||
42
+ content.includes('loader') ||
43
+ content.includes('await loader') ||
44
+ content.includes('.seo');
45
+
46
+ const isBrokenPattern =
47
+ /sections\s*=\s*\[\s*\]/.test(content) && !acquiresDynamicContent;
48
+
49
+ expect(
50
+ usesSeoRenderer,
51
+ `File "${relativePath}" does not import or use SEORenderer from @jjlmoya/utils-shared.`,
52
+ ).toBe(true);
53
+
54
+ expect(
55
+ isBrokenPattern,
56
+ `File "${relativePath}" relies on a static sections=[] prop default without fetching content from entry.i18n, resulting in empty SEO text on consumers.`,
57
+ ).toBe(false);
58
+
59
+ expect(
60
+ acquiresDynamicContent,
61
+ `File "${relativePath}" does not fetch dynamic i18n content for SEO rendering.`,
62
+ ).toBe(true);
63
+ });
64
+ });
65
+ });