From 3ae5a93e5792fb62463bcd3765fc325d97d50213 Mon Sep 17 00:00:00 2001 From: FragginWagon Date: Wed, 28 Jan 2026 22:44:40 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=91=EF=B8=8F=20Remove=20integration=20?= =?UTF-8?q?tests=20for=20ApiKeyManager=20and=20GamemasterManager=20compone?= =?UTF-8?q?nts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/integration/ApiKeyManager.test.js | 72 ----------- .../integration/GamemasterManager.test.js | 113 ------------------ 2 files changed, 185 deletions(-) delete mode 100644 code/websites/pokedex.online/tests/integration/ApiKeyManager.test.js delete mode 100644 code/websites/pokedex.online/tests/integration/GamemasterManager.test.js diff --git a/code/websites/pokedex.online/tests/integration/ApiKeyManager.test.js b/code/websites/pokedex.online/tests/integration/ApiKeyManager.test.js deleted file mode 100644 index cc3b6d6..0000000 --- a/code/websites/pokedex.online/tests/integration/ApiKeyManager.test.js +++ /dev/null @@ -1,72 +0,0 @@ -import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; -import { mount } from '@vue/test-utils'; -import { nextTick } from 'vue'; -import ApiKeyManager from '../../../src/views/ApiKeyManager.vue'; - -/** - * Integration tests for refactored ApiKeyManager component - * Tests the use of BaseModal and refactored state management - */ -describe('ApiKeyManager - Integration Tests', () => { - let wrapper; - - beforeEach(() => { - // Create target element for Teleport (BaseModal uses Teleport) - const el = document.createElement('div'); - el.id = 'modal-target'; - document.body.appendChild(el); - - // Mock localStorage - global.localStorage = { - getItem: vi.fn(), - setItem: vi.fn(), - removeItem: vi.fn(), - clear: vi.fn() - }; - }); - - afterEach(() => { - if (wrapper) { - wrapper.unmount(); - } - document.body.innerHTML = ''; - vi.clearAllMocks(); - }); - - it('renders the API key manager page', () => { - wrapper = mount(ApiKeyManager); - expect(wrapper.find('.api-key-manager').exists()).toBe(true); - expect(wrapper.find('h1').text()).toBe('API Key Manager'); - }); - - it('shows delete confirmation modal using BaseModal', async () => { - wrapper = mount(ApiKeyManager); - - // Find the button that triggers the delete modal - const deleteButton = wrapper - .findAll('button') - .find( - b => - b.text().includes('Clear Stored Key') || b.text().includes('Delete') - ); - - // Modal should not be visible initially - expect(document.querySelector('.modal-overlay')).toBeFalsy(); - }); - - it('contains ChallongeApiKeyGuide component', () => { - wrapper = mount(ApiKeyManager); - // The guide component is conditionally rendered - expect( - wrapper.findComponent({ name: 'ChallongeApiKeyGuide' }).exists() - ).toBe(true); - }); - - it('has proper form structure for API key input', () => { - wrapper = mount(ApiKeyManager); - - const input = wrapper.find('#api-key'); - expect(input.exists()).toBe(true); - expect(input.attributes('type')).toBe('password'); - }); -}); diff --git a/code/websites/pokedex.online/tests/integration/GamemasterManager.test.js b/code/websites/pokedex.online/tests/integration/GamemasterManager.test.js deleted file mode 100644 index 609e8d2..0000000 --- a/code/websites/pokedex.online/tests/integration/GamemasterManager.test.js +++ /dev/null @@ -1,113 +0,0 @@ -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: '', - 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(); - }); -});