feat: add config API and update ApkList to use configured tabs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
import React from 'react';
|
||||
import { render, screen, fireEvent } from '@testing-library/react';
|
||||
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
||||
import ApkList from '../ApkList';
|
||||
import useSWR from 'swr';
|
||||
|
||||
jest.mock('swr');
|
||||
|
||||
// Mock fetch for config API
|
||||
const mockFetch = jest.fn();
|
||||
global.fetch = mockFetch;
|
||||
|
||||
describe('ApkList', () => {
|
||||
const mockApks = [
|
||||
{
|
||||
@@ -39,20 +43,34 @@ describe('ApkList', () => {
|
||||
isLoading: false,
|
||||
error: null,
|
||||
});
|
||||
// Mock config API response
|
||||
mockFetch.mockResolvedValue({
|
||||
json: () => Promise.resolve({ tabs: ['dev', 'sandbox'] }),
|
||||
});
|
||||
});
|
||||
|
||||
it('should render all 4 tabs', () => {
|
||||
render(<ApkList project="FT" version="0_42" commitId="" />);
|
||||
|
||||
expect(screen.getByText(/dev/)).toBeInTheDocument();
|
||||
expect(screen.getByText(/product/)).toBeInTheDocument();
|
||||
expect(screen.getByText(/sandbox/)).toBeInTheDocument();
|
||||
expect(screen.getByText(/other/)).toBeInTheDocument();
|
||||
afterEach(() => {
|
||||
mockFetch.mockClear();
|
||||
});
|
||||
|
||||
it('should switch tabs correctly', () => {
|
||||
it('should render all 4 tabs', async () => {
|
||||
render(<ApkList project="FT" version="0_42" commitId="" />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText(/dev/)).toBeInTheDocument();
|
||||
expect(screen.getByText(/product/)).toBeInTheDocument();
|
||||
expect(screen.getByText(/sandbox/)).toBeInTheDocument();
|
||||
expect(screen.getByText(/other/)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it('should switch tabs correctly', async () => {
|
||||
render(<ApkList project="FT" version="0_42" commitId="" />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText(/dev/)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
const devTab = screen.getByText(/dev/);
|
||||
fireEvent.click(devTab);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user