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