@jjlmoya/utils-performing-arts 1.1.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 (117) hide show
  1. package/.github/workflows/npm-publish.yml +40 -0
  2. package/.gitignore +6 -0
  3. package/.stylelintrc.json +98 -0
  4. package/astro.config.mjs +19 -0
  5. package/eslint.config.js +201 -0
  6. package/package.json +79 -0
  7. package/prompts/create_tool.md +98 -0
  8. package/prompts/i18n/de.md +16 -0
  9. package/prompts/i18n/en.md +16 -0
  10. package/prompts/i18n/es.md +16 -0
  11. package/prompts/i18n/fr.md +16 -0
  12. package/prompts/i18n/id.md +16 -0
  13. package/prompts/i18n/it.md +16 -0
  14. package/prompts/i18n/ja.md +16 -0
  15. package/prompts/i18n/ko.md +16 -0
  16. package/prompts/i18n/nl.md +16 -0
  17. package/prompts/i18n/pl.md +16 -0
  18. package/prompts/i18n/pt.md +16 -0
  19. package/prompts/i18n/ru.md +16 -0
  20. package/prompts/i18n/sv.md +16 -0
  21. package/prompts/i18n/tr.md +16 -0
  22. package/prompts/i18n/zh.md +16 -0
  23. package/prompts/seo.md +58 -0
  24. package/prompts/translations/french.md +33 -0
  25. package/scripts/postinstall.mjs +27 -0
  26. package/src/category/PerformingArtsCategorySEO.astro +9 -0
  27. package/src/category/i18n/de.ts +27 -0
  28. package/src/category/i18n/en.ts +27 -0
  29. package/src/category/i18n/es.ts +27 -0
  30. package/src/category/i18n/fr.ts +27 -0
  31. package/src/category/i18n/id.ts +27 -0
  32. package/src/category/i18n/it.ts +27 -0
  33. package/src/category/i18n/ja.ts +27 -0
  34. package/src/category/i18n/ko.ts +27 -0
  35. package/src/category/i18n/nl.ts +27 -0
  36. package/src/category/i18n/pl.ts +27 -0
  37. package/src/category/i18n/pt.ts +27 -0
  38. package/src/category/i18n/ru.ts +27 -0
  39. package/src/category/i18n/sv.ts +27 -0
  40. package/src/category/i18n/tr.ts +27 -0
  41. package/src/category/i18n/zh.ts +27 -0
  42. package/src/category/index.ts +10 -0
  43. package/src/components/PreviewNavSidebar.astro +116 -0
  44. package/src/components/PreviewToolbar.astro +143 -0
  45. package/src/data.ts +10 -0
  46. package/src/entries.ts +3 -0
  47. package/src/env.d.ts +5 -0
  48. package/src/index.ts +20 -0
  49. package/src/layouts/PreviewLayout.astro +118 -0
  50. package/src/pages/[locale]/[slug].astro +165 -0
  51. package/src/pages/[locale].astro +251 -0
  52. package/src/pages/index.astro +4 -0
  53. package/src/tests/bibliography_wellformed_export.test.ts +46 -0
  54. package/src/tests/category_seo_quality.test.ts +74 -0
  55. package/src/tests/diacritics_density.test.ts +118 -0
  56. package/src/tests/faq_count.test.ts +18 -0
  57. package/src/tests/i18n_coverage.test.ts +34 -0
  58. package/src/tests/inverted_punctuation.test.ts +84 -0
  59. package/src/tests/locale_completeness.test.ts +23 -0
  60. package/src/tests/mocks/astro_mock.js +2 -0
  61. package/src/tests/no_em_dash.test.ts +47 -0
  62. package/src/tests/no_en_dash.test.ts +70 -0
  63. package/src/tests/no_h1_in_components.test.ts +48 -0
  64. package/src/tests/pagespeed_best_practices.test.ts +198 -0
  65. package/src/tests/qa-test-helpers.ts +32 -0
  66. package/src/tests/qa_bibliography_links.test.ts +43 -0
  67. package/src/tests/qa_claim_evidence.test.ts +69 -0
  68. package/src/tests/qa_logic_reference_coverage.test.ts +46 -0
  69. package/src/tests/qa_runtime_i18n.test.ts +100 -0
  70. package/src/tests/schemas_fulfillment.test.ts +23 -0
  71. package/src/tests/script_density.test.ts +94 -0
  72. package/src/tests/seo_length.test.ts +22 -0
  73. package/src/tests/seo_parity.test.ts +60 -0
  74. package/src/tests/seo_translation_completeness.test.ts +69 -0
  75. package/src/tests/seo_wellformed_export.test.ts +65 -0
  76. package/src/tests/shared-test-helpers.ts +56 -0
  77. package/src/tests/slug_language_code_format.test.ts +23 -0
  78. package/src/tests/slug_uniqueness.test.ts +81 -0
  79. package/src/tests/spanish_leakage.test.ts +175 -0
  80. package/src/tests/title_quality.test.ts +55 -0
  81. package/src/tests/tool_exports.test.ts +34 -0
  82. package/src/tests/tool_validation.test.ts +16 -0
  83. package/src/tests/translation_copy.test.ts +115 -0
  84. package/src/tool/rehearsal-call-sheet-planner/bibliography.astro +6 -0
  85. package/src/tool/rehearsal-call-sheet-planner/bibliography.ts +12 -0
  86. package/src/tool/rehearsal-call-sheet-planner/component.astro +74 -0
  87. package/src/tool/rehearsal-call-sheet-planner/controller.ts +98 -0
  88. package/src/tool/rehearsal-call-sheet-planner/dom-views.ts +86 -0
  89. package/src/tool/rehearsal-call-sheet-planner/entry.ts +27 -0
  90. package/src/tool/rehearsal-call-sheet-planner/evaluator.ts +27 -0
  91. package/src/tool/rehearsal-call-sheet-planner/i18n/de.ts +60 -0
  92. package/src/tool/rehearsal-call-sheet-planner/i18n/en.ts +158 -0
  93. package/src/tool/rehearsal-call-sheet-planner/i18n/es.ts +60 -0
  94. package/src/tool/rehearsal-call-sheet-planner/i18n/fr.ts +60 -0
  95. package/src/tool/rehearsal-call-sheet-planner/i18n/id.ts +47 -0
  96. package/src/tool/rehearsal-call-sheet-planner/i18n/it.ts +47 -0
  97. package/src/tool/rehearsal-call-sheet-planner/i18n/ja.ts +47 -0
  98. package/src/tool/rehearsal-call-sheet-planner/i18n/ko.ts +47 -0
  99. package/src/tool/rehearsal-call-sheet-planner/i18n/nl.ts +47 -0
  100. package/src/tool/rehearsal-call-sheet-planner/i18n/pl.ts +47 -0
  101. package/src/tool/rehearsal-call-sheet-planner/i18n/pt.ts +47 -0
  102. package/src/tool/rehearsal-call-sheet-planner/i18n/ru.ts +48 -0
  103. package/src/tool/rehearsal-call-sheet-planner/i18n/sv.ts +48 -0
  104. package/src/tool/rehearsal-call-sheet-planner/i18n/tr.ts +48 -0
  105. package/src/tool/rehearsal-call-sheet-planner/i18n/zh.ts +48 -0
  106. package/src/tool/rehearsal-call-sheet-planner/index.ts +11 -0
  107. package/src/tool/rehearsal-call-sheet-planner/logic.test.ts +68 -0
  108. package/src/tool/rehearsal-call-sheet-planner/logic.ts +229 -0
  109. package/src/tool/rehearsal-call-sheet-planner/rehearsal-call-sheet-planner.css +593 -0
  110. package/src/tool/rehearsal-call-sheet-planner/seo.astro +16 -0
  111. package/src/tool/rehearsal-call-sheet-planner/storage.ts +33 -0
  112. package/src/tool/rehearsal-call-sheet-planner/types.ts +84 -0
  113. package/src/tool/rehearsal-call-sheet-planner/ui.ts +70 -0
  114. package/src/tools.ts +8 -0
  115. package/src/types.ts +68 -0
  116. package/tsconfig.json +15 -0
  117. package/vitest.config.ts +20 -0
@@ -0,0 +1,165 @@
1
+ ---
2
+ import PreviewLayout from "../../layouts/PreviewLayout.astro";
3
+ import PreviewNavSidebar from "../../components/PreviewNavSidebar.astro";
4
+ import { ALL_TOOLS } from "../../index";
5
+ import {
6
+ UtilityHeader,
7
+ FAQSection,
8
+ Bibliography,
9
+ SEORenderer,
10
+ } from "@jjlmoya/utils-shared";
11
+ import type { KnownLocale, ToolLocaleContent } from "../../types";
12
+ import type { RehearsalCallSheetUI } from "../../tool/rehearsal-call-sheet-planner/ui";
13
+ import type RehearsalCallSheetComponent from "../../tool/rehearsal-call-sheet-planner/component.astro";
14
+ import type { UtilitySEOContent } from "@jjlmoya/utils-shared";
15
+
16
+ export async function getStaticPaths() {
17
+ const paths = [];
18
+
19
+ for (const { entry, Component: lazyComp } of ALL_TOOLS) {
20
+ const { default: Component } = await (lazyComp as () => Promise<{ default: unknown }>)();
21
+ const localeEntries = Object.entries(entry.i18n) as [
22
+ KnownLocale,
23
+ () => Promise<ToolLocaleContent>,
24
+ ][];
25
+ const localeContents = await Promise.all(
26
+ localeEntries.map(async ([locale, loader]) => ({
27
+ locale,
28
+ content: await loader(),
29
+ })),
30
+ );
31
+
32
+ const localeUrls = Object.fromEntries(
33
+ localeContents.map(({ locale, content }) => [
34
+ locale,
35
+ `/${locale}/${content.slug}`,
36
+ ]),
37
+ ) as Partial<Record<KnownLocale, string>>;
38
+
39
+ const firstLoader = entry.i18n.en ?? Object.values(entry.i18n)[0];
40
+ const englishSlug = firstLoader ? (await firstLoader()).slug : entry.id;
41
+
42
+ for (const { locale, content } of localeContents) {
43
+ const allToolsNav = (
44
+ await Promise.all(
45
+ ALL_TOOLS.map(async ({ entry: navEntry }) => {
46
+ const loader = navEntry.i18n[locale] ?? navEntry.i18n.en;
47
+ if (!loader) return null;
48
+ const navContent = await loader();
49
+ return {
50
+ id: navEntry.id,
51
+ title: navContent.title,
52
+ href: `/${locale}/${navContent.slug}`,
53
+ isActive: navEntry.id === entry.id,
54
+ };
55
+ }),
56
+ )
57
+ ).filter(Boolean) as NavItem[];
58
+ paths.push({
59
+ params: { locale, slug: content.slug },
60
+ props: { Component, locale, content, localeUrls, allToolsNav, englishSlug },
61
+ });
62
+ }
63
+ }
64
+
65
+ return paths;
66
+ }
67
+
68
+ interface NavItem {
69
+ id: string;
70
+ title: string;
71
+ href: string;
72
+ isActive?: boolean;
73
+ }
74
+
75
+ type PageProps = {
76
+ Component: unknown;
77
+ locale: KnownLocale;
78
+ content: ToolLocaleContent;
79
+ localeUrls: Partial<Record<KnownLocale, string>>;
80
+ allToolsNav: NavItem[];
81
+ englishSlug: string;
82
+ };
83
+
84
+ const { Component, locale, content, localeUrls, allToolsNav, englishSlug } = Astro.props as PageProps;
85
+
86
+ const cssFiles = import.meta.glob<{ default: string }>("../../tool/*/*.css", { query: "?raw", import: "default" });
87
+ const cssKey = Object.keys(cssFiles).find((k) => k.endsWith(`/${englishSlug}.css`));
88
+ const cssLoader = cssKey ? cssFiles[cssKey] : undefined;
89
+ const toolCss = cssLoader ? await cssLoader() as unknown as string : "";
90
+
91
+ const seoContent: UtilitySEOContent = { locale, sections: content.seo ?? [] };
92
+
93
+ const words = content.title.split(" ");
94
+ const titleHighlight = words[0] || "";
95
+ const titleBase = words.slice(1).join(" ") || "";
96
+ const RenderedComponent = Component as typeof RehearsalCallSheetComponent;
97
+ ---
98
+
99
+ <PreviewLayout
100
+ title={content.title}
101
+ currentLocale={locale}
102
+ localeUrls={localeUrls}
103
+ hasSidebar={true}
104
+ >
105
+ <PreviewNavSidebar
106
+ slot="sidebar"
107
+ categoryTitle="Tools"
108
+ tools={allToolsNav}
109
+ />
110
+ <Fragment slot="head">
111
+ {toolCss ? <Fragment set:html={`<style is:inline>${toolCss}</style>`} /> : null}
112
+ {
113
+ ( content.schemas ?? []).map((schema: unknown) => (
114
+ <script
115
+ is:inline
116
+ type="application/ld+json"
117
+ set:html={JSON.stringify(schema)}
118
+ />
119
+ ))
120
+ }
121
+ </Fragment>
122
+
123
+ <div class="tool-page">
124
+ <UtilityHeader
125
+ titleHighlight={titleHighlight}
126
+ titleBase={titleBase}
127
+ description={content.description}
128
+ />
129
+
130
+ <section class="section-tool">
131
+ <RenderedComponent ui={content.ui as RehearsalCallSheetUI} />
132
+ </section>
133
+
134
+ <section class="section-seo">
135
+ <SEORenderer content={seoContent} />
136
+ </section>
137
+
138
+ <section class="section-faq">
139
+ <FAQSection items={content.faq} />
140
+ </section>
141
+
142
+ <section class="section-bibliography">
143
+ <Bibliography links={content.bibliography} />
144
+ </section>
145
+ </div>
146
+ </PreviewLayout>
147
+
148
+ <style>
149
+ .tool-page {
150
+ display: flex;
151
+ flex-direction: column;
152
+ gap: 2rem;
153
+ }
154
+ .section-tool {
155
+ max-width: 1200px;
156
+ margin: 0 auto;
157
+ width: 100%;
158
+ }
159
+ .section-seo,
160
+ .section-faq,
161
+ .section-bibliography {
162
+ padding-top: 2rem;
163
+ border-top: 1px solid var(--border-color);
164
+ }
165
+ </style>
@@ -0,0 +1,251 @@
1
+ ---
2
+ import PreviewLayout from '../layouts/PreviewLayout.astro';
3
+ import PreviewNavSidebar from '../components/PreviewNavSidebar.astro';
4
+ import { performingArtsCategory, ALL_TOOLS } from '../index';
5
+ import { Icon } from 'astro-icon/components';
6
+ import type { KnownLocale, ToolLocaleContent } from '../types';
7
+
8
+ export async function getStaticPaths() {
9
+ const locales = ['en'] as KnownLocale[];
10
+ return locales.map(locale => ({ params: { locale } }));
11
+ }
12
+
13
+ const { locale: currentLocale } = Astro.params as { locale: KnownLocale };
14
+
15
+ const categoryContent = await performingArtsCategory.i18n[currentLocale]!();
16
+
17
+ const tools = ALL_TOOLS || [];
18
+
19
+ const toolsWithContent = tools.length > 0
20
+ ? await Promise.all(
21
+ tools.map(async ({ entry, Component }) => {
22
+ const languages = Object.keys(entry.i18n);
23
+ const localeEntries = await Promise.all(
24
+ languages.map(async (l) => {
25
+ const content = await entry.i18n[l as KnownLocale]!();
26
+ return [l, content];
27
+ })
28
+ );
29
+
30
+ const localeContents = Object.fromEntries(localeEntries) as Record<string, ToolLocaleContent<Record<string, string>>>;
31
+
32
+ const currentLocaleContent = localeContents[currentLocale] || localeContents['en'] || localeContents['es'];
33
+ const availableLocales: Record<string, string> = {};
34
+
35
+ for (const l of languages) {
36
+ const lCont = localeContents[l];
37
+ if (lCont) {
38
+ availableLocales[l] = `/${l}/${lCont.slug}`;
39
+ }
40
+ }
41
+
42
+ return { entry, Component, locale: currentLocaleContent, availableLocales };
43
+ })
44
+ )
45
+ : [];
46
+ ---
47
+
48
+ <PreviewLayout
49
+ title={categoryContent.title}
50
+ currentLocale={currentLocale}
51
+ hasSidebar={true}
52
+ >
53
+ <PreviewNavSidebar
54
+ slot="sidebar"
55
+ categoryTitle={categoryContent.title}
56
+ tools={toolsWithContent.map(({ entry, locale, availableLocales }) => {
57
+ const href = availableLocales[currentLocale] || (locale ? `/${currentLocale}/${locale.slug}` : '#');
58
+ return {
59
+ id: entry.id,
60
+ title: locale?.title || entry.id,
61
+ href: href,
62
+ };
63
+ })}
64
+ />
65
+ <div class="dashboard">
66
+ <header class="preview-header">
67
+ <span class="badge">preview · @jjlmoya/utils-performing-arts</span>
68
+ <h1>{categoryContent.title}</h1>
69
+ <p>{categoryContent.description}</p>
70
+ </header>
71
+
72
+ <div class="tool-list">
73
+ {toolsWithContent?.map(({ entry, locale, availableLocales }) => (
74
+ <article class="tool-card">
75
+ <a href={availableLocales?.[currentLocale] || (locale ? `/${currentLocale}/${locale.slug}` : '#')} class="tool-card-link">
76
+ <div class="tool-icons">
77
+ <div class="icon-wrapper bg">
78
+ <Icon name={entry.icons.bg} />
79
+ </div>
80
+ <div class="icon-wrapper fg">
81
+ <Icon name={entry.icons.fg} />
82
+ </div>
83
+ </div>
84
+ <div class="tool-card-content">
85
+ <h2 class="tool-title">{locale?.title}</h2>
86
+ <p class="tool-description">{locale?.description}</p>
87
+ </div>
88
+ <div class="tool-card-meta">
89
+ <span class="tool-id">{entry.id}</span>
90
+ </div>
91
+ </a>
92
+
93
+ {availableLocales && Object.keys(availableLocales).length > 1 && (
94
+ <div class="tool-locales">
95
+ {Object.entries(availableLocales).map(([l, url]) => (
96
+ <a href={url} class="locale-badge" title={`Ver en ${l.toUpperCase()}`} class:list={{ active: l === currentLocale }}>
97
+ {l.toUpperCase()}
98
+ </a>
99
+ ))}
100
+ </div>
101
+ )}
102
+ </article>
103
+ ))}
104
+ </div>
105
+ </div>
106
+ </PreviewLayout>
107
+
108
+ <style>
109
+ .dashboard {
110
+ display: flex;
111
+ flex-direction: column;
112
+ gap: 5rem;
113
+ }
114
+ .preview-header {
115
+ text-align: center;
116
+ padding-bottom: 3rem;
117
+ border-bottom: 1px solid var(--border-color);
118
+ }
119
+ .badge {
120
+ display: inline-block;
121
+ padding: 0.25rem 0.75rem;
122
+ background: var(--accent);
123
+ border-radius: 99px;
124
+ font-size: 0.7rem;
125
+ font-weight: 800;
126
+ margin-bottom: 1.5rem;
127
+ color: var(--text-base);
128
+ letter-spacing: 0.05em;
129
+ }
130
+ h1 {
131
+ font-size: clamp(2rem, 6vw, 3.5rem);
132
+ font-weight: 900;
133
+ margin: 0 0 1rem;
134
+ background: linear-gradient(to bottom, var(--text-base), var(--text-muted));
135
+ -webkit-background-clip: text;
136
+ -webkit-text-fill-color: transparent;
137
+ background-clip: text;
138
+ }
139
+ .preview-header p {
140
+ color: var(--text-muted);
141
+ font-size: 1.1rem;
142
+ margin: 0;
143
+ }
144
+ .tool-list {
145
+ display: grid;
146
+ grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
147
+ gap: 2rem;
148
+ }
149
+ .tool-card {
150
+ display: flex;
151
+ flex-direction: column;
152
+ gap: 1rem;
153
+ }
154
+ .tool-card-link {
155
+ flex: 1;
156
+ display: flex;
157
+ flex-direction: column;
158
+ padding: 1.5rem;
159
+ background: var(--bg-surface);
160
+ border: 1px solid var(--border-color);
161
+ border-radius: 0.75rem;
162
+ text-decoration: none;
163
+ transition: all 0.2s ease;
164
+ }
165
+ .tool-card-link:hover {
166
+ border-color: var(--accent);
167
+ background: rgba(244, 63, 94, 0.05);
168
+ transform: translateY(-2px);
169
+ }
170
+ .tool-icons {
171
+ display: flex;
172
+ align-items: center;
173
+ gap: 1rem;
174
+ margin-bottom: 1.25rem;
175
+ }
176
+ .icon-wrapper {
177
+ display: flex;
178
+ align-items: center;
179
+ justify-content: center;
180
+ width: 3rem;
181
+ height: 3rem;
182
+ border-radius: 0.5rem;
183
+ font-size: 1.5rem;
184
+ }
185
+ .icon-wrapper.bg {
186
+ background: var(--accent);
187
+ color: var(--text-base);
188
+ }
189
+ .icon-wrapper.fg {
190
+ background: var(--bg-page);
191
+ border: 1px solid var(--border-color);
192
+ color: var(--accent);
193
+ }
194
+ .tool-card-content {
195
+ flex: 1;
196
+ display: flex;
197
+ flex-direction: column;
198
+ }
199
+ .tool-title {
200
+ font-size: 1.25rem;
201
+ font-weight: 700;
202
+ margin: 0 0 0.5rem;
203
+ color: var(--text-base);
204
+ }
205
+ .tool-description {
206
+ font-size: 0.9375rem;
207
+ color: var(--text-muted);
208
+ line-height: 1.5;
209
+ margin: 0;
210
+ }
211
+ .tool-card-meta {
212
+ padding-top: 1rem;
213
+ border-top: 1px solid var(--border-color);
214
+ margin-top: 1.5rem;
215
+ }
216
+ .tool-id {
217
+ display: inline-block;
218
+ font-size: 0.7rem;
219
+ background: var(--bg-page);
220
+ border: 1px solid var(--border-color);
221
+ padding: 0.35rem 0.75rem;
222
+ border-radius: 0.4rem;
223
+ color: var(--accent);
224
+ font-weight: 600;
225
+ }
226
+ .tool-locales {
227
+ display: flex;
228
+ gap: 0.5rem;
229
+ flex-wrap: wrap;
230
+ }
231
+ .locale-badge {
232
+ display: inline-block;
233
+ padding: 0.4rem 0.85rem;
234
+ background: var(--bg-page);
235
+ border: 1px solid var(--border-color);
236
+ border-radius: 0.4rem;
237
+ color: var(--text-muted);
238
+ text-decoration: none;
239
+ font-size: 0.75rem;
240
+ font-weight: 600;
241
+ text-transform: uppercase;
242
+ letter-spacing: 0.05em;
243
+ transition: all 0.15s ease;
244
+ }
245
+ .locale-badge:hover,
246
+ .locale-badge.active {
247
+ color: var(--accent);
248
+ border-color: var(--accent);
249
+ background: rgba(244, 63, 94, 0.1);
250
+ }
251
+ </style>
@@ -0,0 +1,4 @@
1
+ ---
2
+ ---
3
+ <meta http-equiv="refresh" content="0;url=/es" />
4
+
@@ -0,0 +1,46 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { readdirSync, readFileSync, existsSync } from 'fs';
3
+ import { join, relative } from 'path';
4
+
5
+ function findBibliographyAstroFiles(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(...findBibliographyAstroFiles(fullPath));
14
+ } else if (entry.isFile() && entry.name === 'bibliography.astro') {
15
+ files.push(fullPath);
16
+ }
17
+ }
18
+
19
+ return files;
20
+ }
21
+
22
+ const toolDir = join(process.cwd(), 'src', 'tool');
23
+ const bibliographyFiles = findBibliographyAstroFiles(toolDir);
24
+
25
+ describe('Bibliography Component Wellformed Export', () => {
26
+ it('found tool bibliography.astro components', () => {
27
+ expect(bibliographyFiles.length).toBeGreaterThan(0);
28
+ });
29
+
30
+ bibliographyFiles.forEach((file) => {
31
+ const relativePath = relative(process.cwd(), file);
32
+
33
+ it(`${relativePath} should use SharedBibliography from @jjlmoya/utils-shared`, () => {
34
+ const content = readFileSync(file, 'utf-8');
35
+
36
+ const usesSharedComponent =
37
+ content.includes('@jjlmoya/utils-shared') &&
38
+ (content.includes('Bibliography') || content.includes('SharedBibliography'));
39
+
40
+ expect(
41
+ usesSharedComponent,
42
+ `File "${relativePath}" does not use the standard Bibliography component from @jjlmoya/utils-shared, resulting in unstyled or raw bibliography output.`,
43
+ ).toBe(true);
44
+ });
45
+ });
46
+ });
@@ -0,0 +1,74 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import type { CategoryLocaleContent } from '../types';
3
+
4
+ const EXPECTED_LOCALES = [
5
+ 'de', 'en', 'es', 'fr', 'id', 'it', 'ja', 'ko', 'nl', 'pl', 'pt', 'ru', 'sv', 'tr', 'zh',
6
+ ] as const;
7
+ const COMPACT_LOCALES = new Set(['ja', 'ko', 'zh']);
8
+
9
+ const localeModules = import.meta.glob('../category/i18n/*.ts', { eager: true }) as Record<
10
+ string,
11
+ { content: CategoryLocaleContent }
12
+ >;
13
+
14
+ function textFrom(value: unknown): string {
15
+ if (typeof value === 'string') return value.replace(/<[^>]*>/g, ' ');
16
+ if (Array.isArray(value)) return value.map(textFrom).join(' ');
17
+ if (value && typeof value === 'object') return Object.values(value).map(textFrom).join(' ');
18
+ return '';
19
+ }
20
+
21
+ const STRONG_CLAIM = /\b(?:garantiz\w*|guarante\w*|validat(?:ed)|valid(?:ated|ado|ada|ados|adas|ée|ées)|actualizad\w*)\b/iu;
22
+
23
+ function getContents(): Map<string, CategoryLocaleContent> {
24
+ return new Map(
25
+ Object.entries(localeModules).map(([file, module]) => [file.match(/\/([a-z]{2})\.ts$/u)?.[1] ?? file, module.content]),
26
+ );
27
+ }
28
+
29
+ function validateContent(locale: string, content: CategoryLocaleContent): string[] {
30
+ const failures: string[] = [];
31
+ const check = (condition: boolean, message: string) => { if (!condition) failures.push(`${locale}: ${message}`); };
32
+ const minimumTitleLength = COMPACT_LOCALES.has(locale) ? 4 : 12;
33
+ const minimumDescriptionLength = COMPACT_LOCALES.has(locale) ? 20 : 60;
34
+ check(content.title.trim().length >= minimumTitleLength && content.title.trim().length <= 70, 'title must use a useful 4/12–70 character length');
35
+ check(content.description.trim().length >= minimumDescriptionLength && content.description.trim().length <= 180, 'description must use a useful 20/60–180 character length');
36
+ check(content.seo.length >= 2, 'SEO needs at least two sections');
37
+ check(content.seo.some((section) => section.type === 'paragraph'), 'SEO needs visible explanatory copy');
38
+
39
+ const seoText = textFrom(content.seo).replace(/\s+/g, ' ').trim();
40
+ const minimumSeoLength = COMPACT_LOCALES.has(locale) ? 120 : 240;
41
+ check(seoText.length >= minimumSeoLength, 'SEO copy must contain the minimum visible copy for its script');
42
+ check(content.seo.filter((section) => section.type === 'title').length >= 1, 'SEO needs a section heading');
43
+ check(!/[�]/u.test(seoText), 'SEO contains replacement characters');
44
+ check(!/ {2,}/u.test(seoText), 'SEO contains duplicated whitespace');
45
+ check(!STRONG_CLAIM.test(seoText), 'SEO contains an unsupported strong claim');
46
+
47
+ check(content.slug.trim().length > 0 && /^[a-z0-9-]+$/u.test(content.slug), 'slug must be a non-empty URL-safe value');
48
+ return failures;
49
+ }
50
+
51
+ describe('Category SEO quality contract', () => {
52
+ it('has one content file for every configured locale', () => {
53
+ const contents = getContents();
54
+ expect([...contents.keys()].sort()).toEqual([...EXPECTED_LOCALES].sort());
55
+ });
56
+
57
+ it('keeps metadata, SEO structure and copy quality above the minimum in every locale', () => {
58
+ const contents = getContents();
59
+ const english = contents.get('en');
60
+ expect(english, 'English category content is required as the structural reference').toBeDefined();
61
+
62
+ const failures = EXPECTED_LOCALES.flatMap((locale) => {
63
+ const content = contents.get(locale);
64
+ return content ? validateContent(locale, content) : [];
65
+ });
66
+
67
+ for (const locale of EXPECTED_LOCALES) {
68
+ const content = contents.get(locale);
69
+ if (!content) failures.push(`${locale}: category content is missing`);
70
+ }
71
+
72
+ expect(failures, 'category SEO quality failures').toEqual([]);
73
+ }, 30000);
74
+ });
@@ -0,0 +1,118 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { ALL_TOOLS } from '../tools';
3
+
4
+ type LocaleWithDiacritics = keyof typeof DIACRITIC_RULES;
5
+
6
+ const DIACRITIC_RULES = {
7
+ de: {
8
+ language: 'German',
9
+ expectedCharacters: 'ä ö ü ß',
10
+ characters: /[äöüÄÖÜß]/g,
11
+ minPerThousandLetters: 0.1,
12
+ },
13
+ es: {
14
+ language: 'Spanish',
15
+ expectedCharacters: 'á é í ó ú ü ñ',
16
+ characters: /[áéíóúüñÁÉÍÓÚÜÑ]/g,
17
+ minPerThousandLetters: 0.1,
18
+ },
19
+ fr: {
20
+ language: 'French',
21
+ expectedCharacters: 'à â æ ç é è ê ë î ï ô œ ù û ü ÿ',
22
+ characters: /[àâæçéèêëîïôœùûüÿÀÂÆÇÉÈÊËÎÏÔŒÙÛÜŸ]/g,
23
+ minPerThousandLetters: 0.1,
24
+ },
25
+ it: {
26
+ language: 'Italian',
27
+ expectedCharacters: 'à è é ì í î ò ó ù ú',
28
+ characters: /[àèéìíîòóùúÀÈÉÌÍÎÒÓÙÚ]/g,
29
+ minPerThousandLetters: 0.1,
30
+ },
31
+ pl: {
32
+ language: 'Polish',
33
+ expectedCharacters: 'ą ć ę ł ń ó ś ź ż',
34
+ characters: /[ąćęłńóśźżĄĆĘŁŃÓŚŹŻ]/g,
35
+ minPerThousandLetters: 0.1,
36
+ },
37
+ pt: {
38
+ language: 'Portuguese',
39
+ expectedCharacters: 'á â ã à ç é ê í ó ô õ ú ü',
40
+ characters: /[áâãàçéêíóôõúüÁÂÃÀÇÉÊÍÓÔÕÚÜ]/g,
41
+ minPerThousandLetters: 0.1,
42
+ },
43
+ sv: {
44
+ language: 'Swedish',
45
+ expectedCharacters: 'å ä ö',
46
+ characters: /[åäöÅÄÖ]/g,
47
+ minPerThousandLetters: 0.1,
48
+ },
49
+ tr: {
50
+ language: 'Turkish',
51
+ expectedCharacters: 'ç ğ ı İ ö ş ü',
52
+ characters: /[çğıöşüÇĞİÖŞÜ]/g,
53
+ minPerThousandLetters: 0.1,
54
+ },
55
+ } as const;
56
+
57
+ const LETTERS = /\p{L}/gu;
58
+ const TRANSLATABLE_KEYS = ['title', 'description', 'ui', 'seo', 'faq', 'howTo'] as const;
59
+
60
+ function collectStrings(value: unknown): string[] {
61
+ if (typeof value === 'string') return [value];
62
+ if (!value || typeof value !== 'object') return [];
63
+ if (Array.isArray(value)) return value.flatMap(collectStrings);
64
+ return Object.values(value).flatMap(collectStrings);
65
+ }
66
+
67
+ function normalizeText(value: unknown): string {
68
+ return collectStrings(value).join(' ').normalize('NFC');
69
+ }
70
+
71
+ function translatableContent(content: Record<string, unknown>) {
72
+ return TRANSLATABLE_KEYS.map((key) => content[key]);
73
+ }
74
+
75
+ function letterCount(text: string): number {
76
+ return text.match(LETTERS)?.length ?? 0;
77
+ }
78
+
79
+ function diacriticCount(text: string, locale: LocaleWithDiacritics): number {
80
+ return text.match(DIACRITIC_RULES[locale].characters)?.length ?? 0;
81
+ }
82
+
83
+ function diacriticsPerThousandLetters(text: string, locale: LocaleWithDiacritics): number {
84
+ const letters = letterCount(text);
85
+ if (letters === 0) return 0;
86
+ return diacriticCount(text, locale) / letters * 1000;
87
+ }
88
+
89
+ describe('Diacritics density validation', () => {
90
+ ALL_TOOLS.forEach((tool) => {
91
+ describe(`Tool: ${tool.entry.id}`, () => {
92
+ Object.keys(DIACRITIC_RULES).forEach((locale) => {
93
+ it(`${locale} keeps the expected accent and special-letter set`, async () => {
94
+ const typedLocale = locale as LocaleWithDiacritics;
95
+ const loader = tool.entry.i18n[typedLocale];
96
+ if (!loader) return;
97
+
98
+ const content = await loader();
99
+ const text = normalizeText(translatableContent(content as unknown as Record<string, unknown>));
100
+ const rule = DIACRITIC_RULES[typedLocale];
101
+ const letters = letterCount(text);
102
+ const matches = diacriticCount(text, typedLocale);
103
+ const density = diacriticsPerThousandLetters(text, typedLocale);
104
+
105
+ expect(
106
+ density,
107
+ [
108
+ `Possible spelling or encoding issue detected in ${tool.entry.id}/${typedLocale} (${rule.language}).`,
109
+ `The text has ${matches} special characters (${density.toFixed(2)} per 1000 letters, ${letters} letters analyzed).`,
110
+ `This locale should include some of these characters: ${rule.expectedCharacters}.`,
111
+ 'If the count is 0 or near 0, accents, tildes, or special letters were probably stripped by encoding or normalization.',
112
+ ].join(' '),
113
+ ).toBeGreaterThanOrEqual(rule.minPerThousandLetters);
114
+ });
115
+ });
116
+ });
117
+ });
118
+ });
@@ -0,0 +1,18 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import type * as DATA from '../data';
3
+
4
+ const TOOLS: typeof DATA.performingArtsCategory[] = [];
5
+
6
+ describe('FAQ Content Validation', () => {
7
+ TOOLS.forEach((entry) => {
8
+ describe(`Tool: ${entry.icon}`, () => {
9
+ it('placeholder', () => {
10
+ expect(true).toBe(true);
11
+ });
12
+ });
13
+ });
14
+
15
+ it('no tools registered yet', () => {
16
+ expect(TOOLS.length).toBe(0);
17
+ });
18
+ });