feat: demo mode + demo end-to-end tests
- built-in mock Gitea backend (src/core/demo): repositories, issues, comments, reactions, labels/milestones, pulls, files, diff, reviews, inline comments, releases, notifications, activity, Actions runs/jobs/logs/artifacts/workflows, repo settings, orgs/teams/packages/credentials/admin, and benign writes - session wires demoFetch for the demo instance; welcome screen 'Try the demo' - demo E2E (16 tests over the real endpoint layer) + UI render E2E; minimal reanimated jest mock; README demo-mode section
This commit is contained in:
1 parent
fbefa0d345
commit
1ee0f95b3f
10 files changed
+943
-5
No files matched your search
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* UI-level demo E2E: render real screens against the demo backend and assert
|
||||
* that remote data reaches the interface.
|
||||
*/
|
||||
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||
import { render, screen, waitFor } from '@testing-library/react-native';
|
||||
|
||||
import { AppThemeProvider } from '@/theme/theme-provider';
|
||||
import { useAccountsStore } from '@/core/accounts/accounts-store';
|
||||
import { DEMO_BASE_URL, DEMO_TOKEN } from '@/core/demo';
|
||||
import { RepositoryListScreen } from '@/features/repositories/screens/repository-list-screen';
|
||||
import { RepoOverviewScreen } from '@/features/repository/screens/repo-overview-screen';
|
||||
|
||||
function seedDemoSession() {
|
||||
useAccountsStore.setState({
|
||||
hydrated: true,
|
||||
instances: [{ id: 'demo-inst', baseUrl: DEMO_BASE_URL, label: 'Demo', addedAt: 0, version: '1.22.0' }],
|
||||
accounts: [
|
||||
{ id: 'demo-acct', instanceId: 'demo-inst', login: 'octocat', fullName: 'Octo Cat', addedAt: 0 },
|
||||
],
|
||||
activeAccountId: 'demo-acct',
|
||||
tokens: { 'demo-acct': DEMO_TOKEN },
|
||||
});
|
||||
}
|
||||
|
||||
function renderScreen(node: React.ReactElement) {
|
||||
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
|
||||
return render(
|
||||
<AppThemeProvider>
|
||||
<QueryClientProvider client={client}>{node}</QueryClientProvider>
|
||||
</AppThemeProvider>,
|
||||
);
|
||||
}
|
||||
|
||||
const navigation = {
|
||||
navigate: jest.fn(),
|
||||
setParams: jest.fn(),
|
||||
goBack: jest.fn(),
|
||||
push: jest.fn(),
|
||||
} as never;
|
||||
|
||||
const route = { key: 'k', name: 'test', params: undefined } as never;
|
||||
|
||||
describe('demo UI', () => {
|
||||
beforeEach(() => {
|
||||
seedDemoSession();
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it('renders the demo repository list', async () => {
|
||||
renderScreen(<RepositoryListScreen navigation={navigation} route={route} />);
|
||||
await waitFor(() => expect(screen.getByText('hello-world')).toBeTruthy());
|
||||
});
|
||||
|
||||
it('renders the demo repository overview', async () => {
|
||||
renderScreen(
|
||||
<RepoOverviewScreen
|
||||
navigation={navigation}
|
||||
route={{ key: 'k', name: 'RepoOverview', params: { owner: 'octocat', name: 'hello-world' } } as never}
|
||||
/>,
|
||||
);
|
||||
// Repository name and default-branch badge prove the detail query resolved.
|
||||
await waitFor(() => expect(screen.getAllByText('hello-world').length).toBeGreaterThan(0));
|
||||
await waitFor(() => expect(screen.getAllByText('main').length).toBeGreaterThan(0));
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user