Skip to content
Merged
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
5 changes: 1 addition & 4 deletions src/app.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
declare const __COMMIT_HASH__: string;

declare global {
const __COMMIT_HASH__: string;
const __APP_VERSION__: string;

namespace App {
// interface Error {}
Expand Down
8 changes: 5 additions & 3 deletions src/lib/components/footer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@

<footer class={cn('w-full p-4 text-center', klass)} {...props}>
<Text>
<Link href="https://dottmp.dev/">© {copyrightYear} dottmp</Link> | Commit: {__COMMIT_HASH__} |<Link
<Link href="https://dottmp.dev/">© {copyrightYear} dottmp</Link> |<Link
class="ml-2"
href="https://github.com/dottmp/10xprivacy"
variant="primary">GitHub repo</Link
href="https://github.com/dottmp/10xprivacy/releases/tag/v{__APP_VERSION__}"
variant="primary">v{__APP_VERSION__}</Link
> |<Link class="ml-2" href="https://github.com/dottmp/10xprivacy" variant="primary"
>GitHub repo</Link
> |<Link
class="ml-2"
href="https://github.com/dottmp/10xprivacy/blob/main/LICENSE"
Expand Down
22 changes: 22 additions & 0 deletions src/lib/components/footer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { describe, expect, it } from 'vitest';

import Footer from './footer.svelte';

function getVersionLink() {
return screen.getByRole('link', { name: `v${__APP_VERSION__}` });
}

describe('Footer component', () => {
it('GitHub repo link has correct href', () => {
render(Footer);
Expand All @@ -21,4 +25,22 @@ describe('Footer component', () => {
'https://github.com/dottmp/10xprivacy/blob/main/LICENSE'
);
});

it('version link displays current app version', () => {
render(Footer);

const versionLink = getVersionLink();

expect(versionLink).toBeInTheDocument();
});

it('version link points to correct GitHub release page', () => {
render(Footer);

const versionLink = getVersionLink();

expect(versionLink.getAttribute('href')).toBe(
`https://github.com/dottmp/10xprivacy/releases/tag/v${__APP_VERSION__}`
);
});
});
12 changes: 2 additions & 10 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
import { execSync } from 'child_process';

import { sveltekit } from '@sveltejs/kit/vite';
import tailwindcss from '@tailwindcss/vite';
import { svelteTesting } from '@testing-library/svelte/vite';
import { defineConfig } from 'vitest/config';

const commitHash = (() => {
try {
return execSync('git rev-parse --short HEAD').toString().trim();
} catch {
return 'unknown';
}
})();
import { version } from './package.json';

export default defineConfig({
// TODO: Fix this Plugin types from vite and vitest/config are incompatible
// eslint-disable-next-line @typescript-eslint/no-explicit-any
plugins: [tailwindcss(), sveltekit(), svelteTesting() as any],
define: {
__COMMIT_HASH__: JSON.stringify(commitHash)
__APP_VERSION__: JSON.stringify(version)
},
test: {
environment: 'jsdom',
Expand Down
Loading