char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Aleksander Grygierui: ESLint config updates (#27700)f1357e499

char/aliceai-t5-moe
4.2 KiB139 linesraw
1<script lang="ts" module>
2	import { AI_TUTORIAL_MD } from './fixtures/ai-tutorial.js';
3	import { API_DOCS_MD } from './fixtures/api-docs.js';
4	import { BLOG_POST_MD } from './fixtures/blog-post.js';
5	import { DATA_ANALYSIS_MD } from './fixtures/data-analysis.js';
6	import { EMPTY_MD } from './fixtures/empty.js';
7	import { MATH_FORMULAS_MD } from './fixtures/math-formulas.js';
8	import { README_MD } from './fixtures/readme.js';
9	import { defineMeta } from '@storybook/addon-svelte-csf';
10	import { MarkdownContent } from '$lib/components/app';
11	import { expect } from 'storybook/test';
12
13	const { Story } = defineMeta({
14		component: MarkdownContent,
15		parameters: {
16			layout: 'centered'
17		},
18		title: 'Components/MarkdownContent'
19	});
20</script>
21
22<Story args={{ class: 'max-w-[56rem] w-[calc(100vw-2rem)]', content: EMPTY_MD }} name="Empty" />
23
24<Story
25	args={{ class: 'max-w-[56rem] w-[calc(100vw-2rem)]', content: AI_TUTORIAL_MD }}
26	name="AI Tutorial"
27/>
28
29<Story
30	args={{ class: 'max-w-[56rem] w-[calc(100vw-2rem)]', content: API_DOCS_MD }}
31	name="API Documentation"
32/>
33
34<Story
35	args={{ class: 'max-w-[56rem] w-[calc(100vw-2rem)]', content: BLOG_POST_MD }}
36	name="Technical Blog"
37/>
38
39<Story
40	args={{ class: 'max-w-[56rem] w-[calc(100vw-2rem)]', content: DATA_ANALYSIS_MD }}
41	name="Data Analysis"
42/>
43
44<Story
45	args={{ class: 'max-w-[56rem] w-[calc(100vw-2rem)]', content: README_MD }}
46	name="README file"
47/>
48
49<Story
50	args={{ class: 'max-w-[56rem] w-[calc(100vw-2rem)]', content: MATH_FORMULAS_MD }}
51	name="Math Formulas"
52/>
53
54<Story
55	args={{
56		class: 'max-w-[56rem] w-[calc(100vw-2rem)]',
57		content: `# URL Links Test
58
59Here are some example URLs that should open in new tabs:
60
61- [Hugging Face Homepage](https://huggingface.co)
62- [GitHub Repository](https://github.com/ggml-org/llama.cpp)
63- [OpenAI Website](https://openai.com)
64- [Google Search](https://www.google.com)
65
66You can also test inline links like https://example.com or https://docs.python.org.
67
68All links should have \`target="_blank"\` and \`rel="noopener noreferrer"\` attributes for security.`
69	}}
70	name="URL Links"
71	play={async (context) => {
72		const { canvasElement } = context;
73
74		// Wait for component to render
75		await new Promise((resolve) => setTimeout(resolve, 100));
76
77		// Find all links in the rendered content
78		const links = (canvasElement as HTMLElement).querySelectorAll(
79			'a[href]'
80		) as NodeListOf<HTMLAnchorElement>;
81		const linkList = Array.from(links) as HTMLAnchorElement[];
82
83		// Test that we have the expected number of links
84		expect(links.length).toBeGreaterThan(0);
85
86		// Test each link for proper attributes
87		links.forEach((link: HTMLAnchorElement) => {
88			const href = link.getAttribute('href');
89
90			// Test that external links have proper security attributes
91			if (href && (href.startsWith('http://') || href.startsWith('https://'))) {
92				expect(link.getAttribute('target')).toBe('_blank');
93				expect(link.getAttribute('rel')).toBe('noopener noreferrer');
94			}
95		});
96
97		// Test specific links exist
98		const hugginFaceLink = linkList.find(
99			(link) => link.getAttribute('href') === 'https://huggingface.co'
100		);
101
102		expect(hugginFaceLink).toBeTruthy();
103		expect(hugginFaceLink?.textContent).toBe('Hugging Face Homepage');
104
105		const githubLink = linkList.find(
106			(link) => link.getAttribute('href') === 'https://github.com/ggml-org/llama.cpp'
107		);
108
109		expect(githubLink).toBeTruthy();
110		expect(githubLink?.textContent).toBe('GitHub Repository');
111
112		const openaiLink = linkList.find((link) => link.getAttribute('href') === 'https://openai.com');
113
114		expect(openaiLink).toBeTruthy();
115		expect(openaiLink?.textContent).toBe('OpenAI Website');
116
117		const googleLink = linkList.find(
118			(link) => link.getAttribute('href') === 'https://www.google.com'
119		);
120
121		expect(googleLink).toBeTruthy();
122		expect(googleLink?.textContent).toBe('Google Search');
123
124		// Test inline links (auto-linked URLs)
125		const exampleLink = linkList.find(
126			(link) => link.getAttribute('href') === 'https://example.com'
127		);
128
129		expect(exampleLink).toBeTruthy();
130
131		const pythonDocsLink = linkList.find(
132			(link) => link.getAttribute('href') === 'https://docs.python.org'
133		);
134
135		expect(pythonDocsLink).toBeTruthy();
136
137		console.log(`✅ URL Links test passed - Found ${links.length} links with proper attributes`);
138	}}
139/>