🎨 Reformat test code for improved readability and consistency
This commit is contained in:
@@ -43,9 +43,12 @@ describe('ApiKeyManager - Integration Tests', () => {
|
|||||||
wrapper = mount(ApiKeyManager);
|
wrapper = mount(ApiKeyManager);
|
||||||
|
|
||||||
// Find the button that triggers the delete modal
|
// Find the button that triggers the delete modal
|
||||||
const deleteButton = wrapper.findAll('button').find(b =>
|
const deleteButton = wrapper
|
||||||
b.text().includes('Clear Stored Key') || b.text().includes('Delete')
|
.findAll('button')
|
||||||
);
|
.find(
|
||||||
|
b =>
|
||||||
|
b.text().includes('Clear Stored Key') || b.text().includes('Delete')
|
||||||
|
);
|
||||||
|
|
||||||
// Modal should not be visible initially
|
// Modal should not be visible initially
|
||||||
expect(document.querySelector('.modal-overlay')).toBeFalsy();
|
expect(document.querySelector('.modal-overlay')).toBeFalsy();
|
||||||
@@ -54,7 +57,9 @@ describe('ApiKeyManager - Integration Tests', () => {
|
|||||||
it('contains ChallongeApiKeyGuide component', () => {
|
it('contains ChallongeApiKeyGuide component', () => {
|
||||||
wrapper = mount(ApiKeyManager);
|
wrapper = mount(ApiKeyManager);
|
||||||
// The guide component is conditionally rendered
|
// The guide component is conditionally rendered
|
||||||
expect(wrapper.findComponent({ name: 'ChallongeApiKeyGuide' }).exists()).toBe(true);
|
expect(
|
||||||
|
wrapper.findComponent({ name: 'ChallongeApiKeyGuide' }).exists()
|
||||||
|
).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has proper form structure for API key input', () => {
|
it('has proper form structure for API key input', () => {
|
||||||
|
|||||||
@@ -0,0 +1,113 @@
|
|||||||
|
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||||
|
import { mount } from '@vue/test-utils';
|
||||||
|
import GamemasterManager from '../../../src/views/GamemasterManager.vue';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Integration tests for refactored GamemasterManager component
|
||||||
|
* Tests useAsyncState composable and api-client integration
|
||||||
|
*/
|
||||||
|
describe('GamemasterManager - Integration Tests', () => {
|
||||||
|
let wrapper;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
// Mock fetch globally
|
||||||
|
global.fetch = vi.fn();
|
||||||
|
|
||||||
|
// Mock router-link component
|
||||||
|
vi.stubGlobal('RouterLink', {
|
||||||
|
name: 'RouterLink',
|
||||||
|
template: '<a><slot /></a>',
|
||||||
|
props: ['to']
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
if (wrapper) {
|
||||||
|
wrapper.unmount();
|
||||||
|
}
|
||||||
|
vi.clearAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('renders the gamemaster manager page', () => {
|
||||||
|
wrapper = mount(GamemasterManager, {
|
||||||
|
global: {
|
||||||
|
stubs: {
|
||||||
|
RouterLink: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper.find('.gamemaster-manager').exists()).toBe(true);
|
||||||
|
expect(wrapper.find('h1').text()).toBe('Gamemaster Manager');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('has three main sections', () => {
|
||||||
|
wrapper = mount(GamemasterManager, {
|
||||||
|
global: {
|
||||||
|
stubs: {
|
||||||
|
RouterLink: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const sections = wrapper.findAll('.section');
|
||||||
|
// At least 3 sections: fetch, break up, save to server
|
||||||
|
expect(sections.length).toBeGreaterThanOrEqual(3);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('has fetch button with loading state', async () => {
|
||||||
|
wrapper = mount(GamemasterManager, {
|
||||||
|
global: {
|
||||||
|
stubs: {
|
||||||
|
RouterLink: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const buttons = wrapper.findAll('button');
|
||||||
|
const fetchButton = buttons.find(b => b.text().includes('Fetch'));
|
||||||
|
|
||||||
|
expect(fetchButton).toBeDefined();
|
||||||
|
expect(fetchButton.attributes('disabled')).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('displays description text', () => {
|
||||||
|
wrapper = mount(GamemasterManager, {
|
||||||
|
global: {
|
||||||
|
stubs: {
|
||||||
|
RouterLink: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const description = wrapper.find('.description');
|
||||||
|
expect(description.text()).toContain('PokeMiners');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('uses useAsyncState pattern for loading states', async () => {
|
||||||
|
wrapper = mount(GamemasterManager, {
|
||||||
|
global: {
|
||||||
|
stubs: {
|
||||||
|
RouterLink: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Component should have computed loading property
|
||||||
|
expect(wrapper.vm.loading).toBeDefined();
|
||||||
|
expect(typeof wrapper.vm.loading).toBe('boolean');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('uses computed error property for error handling', () => {
|
||||||
|
wrapper = mount(GamemasterManager, {
|
||||||
|
global: {
|
||||||
|
stubs: {
|
||||||
|
RouterLink: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Component should have computed error property
|
||||||
|
expect(wrapper.vm.error).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user