Public Access
Fixing frontend coverage.
Tests / Build and Push CICD Image (push) Successful in 46m49s
Tests / YAML Syntax Check (push) Successful in 7m40s
Tests / TOML Syntax Check (push) Successful in 53s
Tests / Mixed Line Ending Check (push) Successful in 54s
Tests / TOML Formatting Check (push) Successful in 52s
Tests / Ruff Linting (push) Successful in 55s
Tests / Trailing Whitespace Check (push) Successful in 9m41s
Tests / Pyright Type Check (push) Successful in 1m9s
Tests / No Docstring Types Check (push) Successful in 57s
Tests / ESLint Check (push) Successful in 1m6s
Tests / Prettier Format Check (push) Successful in 1m14s
Tests / TypeScript Type Check (push) Successful in 1m12s
Tests / Backend Tests (push) Successful in 1m3s
Tests / TSDoc Lint Check (push) Successful in 1m37s
Tests / Frontend Tests (push) Successful in 1m23s
Tests / Backend Doctests (push) Successful in 1m7s
Tests / End of File Check (push) Successful in 13m53s
Tests / Integration Tests (push) Successful in 6m23s
Tests / End-to-End Tests (push) Has been cancelled
Tests / Ruff Format Check (push) Successful in 59s
Tests / Darglint Docstring Check (push) Successful in 1m16s
Tests / Build and Push CICD Image (push) Successful in 46m49s
Tests / YAML Syntax Check (push) Successful in 7m40s
Tests / TOML Syntax Check (push) Successful in 53s
Tests / Mixed Line Ending Check (push) Successful in 54s
Tests / TOML Formatting Check (push) Successful in 52s
Tests / Ruff Linting (push) Successful in 55s
Tests / Trailing Whitespace Check (push) Successful in 9m41s
Tests / Pyright Type Check (push) Successful in 1m9s
Tests / No Docstring Types Check (push) Successful in 57s
Tests / ESLint Check (push) Successful in 1m6s
Tests / Prettier Format Check (push) Successful in 1m14s
Tests / TypeScript Type Check (push) Successful in 1m12s
Tests / Backend Tests (push) Successful in 1m3s
Tests / TSDoc Lint Check (push) Successful in 1m37s
Tests / Frontend Tests (push) Successful in 1m23s
Tests / Backend Doctests (push) Successful in 1m7s
Tests / End of File Check (push) Successful in 13m53s
Tests / Integration Tests (push) Successful in 6m23s
Tests / End-to-End Tests (push) Has been cancelled
Tests / Ruff Format Check (push) Successful in 59s
Tests / Darglint Docstring Check (push) Successful in 1m16s
Signed-off-by: Cliff Hill <xlorep@darkhelm.org>
This commit is contained in:
@@ -0,0 +1,40 @@
|
|||||||
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||||
|
|
||||||
|
// Mock Vue's createApp
|
||||||
|
const mockMount = vi.fn();
|
||||||
|
const mockApp = {
|
||||||
|
mount: mockMount,
|
||||||
|
};
|
||||||
|
const mockCreateApp = vi.fn(() => mockApp);
|
||||||
|
|
||||||
|
// Mock the App component
|
||||||
|
const mockAppComponent = {};
|
||||||
|
|
||||||
|
vi.mock('vue', () => ({
|
||||||
|
createApp: mockCreateApp,
|
||||||
|
}));
|
||||||
|
|
||||||
|
vi.mock('./App.vue', () => ({
|
||||||
|
default: mockAppComponent,
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('main.ts', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
vi.clearAllMocks();
|
||||||
|
// Clear the module cache to ensure fresh imports
|
||||||
|
vi.resetModules();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create Vue app and mount to #app', async () => {
|
||||||
|
// Import the module after setting up mocks
|
||||||
|
await import('./main');
|
||||||
|
|
||||||
|
// Verify createApp was called with the App component
|
||||||
|
expect(mockCreateApp).toHaveBeenCalledWith(mockAppComponent);
|
||||||
|
expect(mockCreateApp).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
|
// Verify mount was called with #app selector
|
||||||
|
expect(mockMount).toHaveBeenCalledWith('#app');
|
||||||
|
expect(mockMount).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,144 @@
|
|||||||
|
import { describe, it, expect } from 'vitest';
|
||||||
|
import { PlaylistSchema, UserSchema, type Playlist, type User } from './validation';
|
||||||
|
|
||||||
|
describe('PlaylistSchema', () => {
|
||||||
|
it('should validate a valid playlist', () => {
|
||||||
|
const validPlaylist = {
|
||||||
|
id: '123e4567-e89b-12d3-a456-426614174000',
|
||||||
|
name: 'My Playlist',
|
||||||
|
description: 'A great playlist',
|
||||||
|
tracks: ['track1', 'track2'],
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = PlaylistSchema.parse(validPlaylist);
|
||||||
|
expect(result).toEqual(validPlaylist);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should validate playlist with minimal required fields', () => {
|
||||||
|
const minimalPlaylist = {
|
||||||
|
id: '123e4567-e89b-12d3-a456-426614174000',
|
||||||
|
name: 'My Playlist',
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = PlaylistSchema.parse(minimalPlaylist);
|
||||||
|
expect(result).toEqual({
|
||||||
|
id: '123e4567-e89b-12d3-a456-426614174000',
|
||||||
|
name: 'My Playlist',
|
||||||
|
description: undefined,
|
||||||
|
tracks: [],
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should reject playlist with invalid UUID', () => {
|
||||||
|
const invalidPlaylist = {
|
||||||
|
id: 'invalid-uuid',
|
||||||
|
name: 'My Playlist',
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(() => PlaylistSchema.parse(invalidPlaylist)).toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should reject playlist with empty name', () => {
|
||||||
|
const invalidPlaylist = {
|
||||||
|
id: '123e4567-e89b-12d3-a456-426614174000',
|
||||||
|
name: '',
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(() => PlaylistSchema.parse(invalidPlaylist)).toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('UserSchema', () => {
|
||||||
|
it('should validate a valid user', () => {
|
||||||
|
const validUser = {
|
||||||
|
id: 123,
|
||||||
|
username: 'testuser',
|
||||||
|
email: 'test@example.com',
|
||||||
|
preferences: {
|
||||||
|
theme: 'dark' as const,
|
||||||
|
notifications: false,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = UserSchema.parse(validUser);
|
||||||
|
expect(result).toEqual(validUser);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should validate user with default preferences', () => {
|
||||||
|
const minimalUser = {
|
||||||
|
id: 123,
|
||||||
|
username: 'testuser',
|
||||||
|
email: 'test@example.com',
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = UserSchema.parse(minimalUser);
|
||||||
|
expect(result).toEqual({
|
||||||
|
id: 123,
|
||||||
|
username: 'testuser',
|
||||||
|
email: 'test@example.com',
|
||||||
|
preferences: {
|
||||||
|
theme: 'light',
|
||||||
|
notifications: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should reject user with invalid email', () => {
|
||||||
|
const invalidUser = {
|
||||||
|
id: 123,
|
||||||
|
username: 'testuser',
|
||||||
|
email: 'invalid-email',
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(() => UserSchema.parse(invalidUser)).toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should reject user with empty username', () => {
|
||||||
|
const invalidUser = {
|
||||||
|
id: 123,
|
||||||
|
username: '',
|
||||||
|
email: 'test@example.com',
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(() => UserSchema.parse(invalidUser)).toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should reject user with invalid theme', () => {
|
||||||
|
const invalidUser = {
|
||||||
|
id: 123,
|
||||||
|
username: 'testuser',
|
||||||
|
email: 'test@example.com',
|
||||||
|
preferences: {
|
||||||
|
theme: 'invalid' as any,
|
||||||
|
notifications: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(() => UserSchema.parse(invalidUser)).toThrow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Type exports', () => {
|
||||||
|
it('should export correct TypeScript types', () => {
|
||||||
|
// Type-only test - compilation is the validation
|
||||||
|
const playlist: Playlist = {
|
||||||
|
id: '123e4567-e89b-12d3-a456-426614174000',
|
||||||
|
name: 'Test',
|
||||||
|
description: 'Test description',
|
||||||
|
tracks: ['track1'],
|
||||||
|
};
|
||||||
|
|
||||||
|
const user: User = {
|
||||||
|
id: 1,
|
||||||
|
username: 'test',
|
||||||
|
email: 'test@example.com',
|
||||||
|
preferences: {
|
||||||
|
theme: 'light',
|
||||||
|
notifications: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(playlist.id).toBeDefined();
|
||||||
|
expect(user.username).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user