Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions src/frontend/src/components/FreeAndOpenSourceAside.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,30 @@
/**
* This aside component displays a localized "Free & Open Source" message.
*/
const aspireQuotes = [
'Aspire is the cloud-native app model for .NET.',
'Aspire is orchestration for your distributed app stack.',
'Aspire is local-first developer tooling for cloud-native apps.',
'Aspire is built for observable, production-ready app development.',
'Aspire is open source from app model to deployment artifacts.',
];
---

<div class="free-open-source-aside">
<p class="aside-title">{Astro.locals.t('landing.freeAndOSS')}</p>
<p>
{Astro.locals.t('landing.aspirePromise')}
</p>
<p data-random-aspire-quote aria-live="polite">{aspireQuotes[0]}</p>
</div>

<script is:inline define:vars={{ aspireQuotes }}>
const quotes = aspireQuotes;
const quoteElement = document.querySelector('[data-random-aspire-quote]');

if (quoteElement instanceof HTMLElement) {
const quoteIndex = Math.floor(Math.random() * quotes.length);
quoteElement.textContent = quotes[quoteIndex];
}
</script>

<style>
.aside-title {
margin-bottom: 1rem;
Expand Down
13 changes: 11 additions & 2 deletions src/frontend/tests/unit/custom-components.vitest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,9 @@ const basicRenderCases: BasicRenderCase[] = [
includes: ['data-lang-name="TypeScript"', 'data-lang-name="C#"', 'And more...'],
},
{
name: 'FreeAndOpenSourceAside renders translated copy',
name: 'FreeAndOpenSourceAside renders localized title',
Component: FreeAndOpenSourceAside,
includes: ['landing.freeAndOSS', 'landing.aspirePromise'],
includes: ['landing.freeAndOSS'],
},
{
name: 'OsAwareTabs renders shell tabs and sync key script',
Expand Down Expand Up @@ -642,6 +642,15 @@ describe('custom Astro component render coverage', () => {
});
}

it('renders the quote randomization script and quote pool', async () => {
const html = normalizeHtml(await renderComponent(FreeAndOpenSourceAside));

expect(html).toContain('data-random-aspire-quote');
expect(html).toContain('Math.floor(Math.random() * quotes.length)');
expect(html).toContain('Aspire is the cloud-native app model for .NET.');
expect(html).toContain('Aspire is open source from app model to deployment artifacts.');
});

it('filters GitHubRepoStats by repository name when multiple stats are provided', async () => {
const html = normalizeHtml(
await renderComponent(GitHubRepoStats, {
Expand Down