Skip to content

Commit

Permalink
test(debug): Test hiding/showing debug panel
Browse files Browse the repository at this point in the history
  • Loading branch information
delucis committed Aug 26, 2021
1 parent 06bc747 commit 5903e12
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/client/debug/ai/AI.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script>
export let client;
export let clientManager;
export let ToggleVisibility;
import { MAKE_MOVE } from '../../../core/action-types';
import Hotkey from '../main/Hotkey.svelte';
Expand Down
1 change: 1 addition & 0 deletions src/client/debug/info/Info.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script>
export let client;
export let clientManager;
export let ToggleVisibility;
import Item from './Item.svelte';
</script>
Expand Down
31 changes: 31 additions & 0 deletions src/client/debug/tests/debug.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,37 @@ test('switching panels', async () => {
client.stop();
});

test('visibility toggle', async () => {
const client = Client({ game: {} });
client.start();

// Visibility toggle button & debug panel are rendered
const hideButton = screen.getByTitle('Hide Debug Panel');
expect(hideButton).toBeInTheDocument();
expect(screen.getByRole('heading', { name: 'Controls' })).toBeInTheDocument();

// Hide debug panel
await fireEvent.click(hideButton);
await waitFor(() => expect(hideButton).not.toBeInTheDocument());

// Show button is rendered & debug panel is not.
const showButton = screen.getByTitle('Show Debug Panel');
expect(showButton).toBeInTheDocument();
expect(
screen.queryByRole('heading', { name: 'Controls' })
).not.toBeInTheDocument();

// Show debug panel
await fireEvent.click(showButton);
await waitFor(() => expect(showButton).not.toBeInTheDocument());

// Hide button & debug panel are rendered.
expect(screen.getByTitle('Hide Debug Panel')).toBeInTheDocument();
expect(screen.getByRole('heading', { name: 'Controls' })).toBeInTheDocument();

client.stop();
});

describe('multiple clients', () => {
const client0 = Client({
game: { name: 'game1' },
Expand Down

0 comments on commit 5903e12

Please sign in to comment.