Skip to content

Commit

Permalink
fix comments and the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
helios2003 committed Jan 9, 2025
1 parent 81aefb3 commit ddb33d5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
12 changes: 7 additions & 5 deletions apps/playground-web/components/Shell/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import '@testing-library/jest-dom';
import { render, screen } from '@testing-library/react';
import { getAllByTestId, render, screen } from '@testing-library/react';

Check warning on line 2 in apps/playground-web/components/Shell/__tests__/index.test.tsx

View workflow job for this annotation

GitHub Actions / Build and Test

'getAllByTestId' is defined but never used
import userEvent from '@testing-library/user-event';
import Shell from '../Shell';

Expand Down Expand Up @@ -55,13 +55,15 @@ describe('Shell Component', () => {
});

it('should throw error when user types blocklisted command', async () => {
const { cliInputElement, user, getByTestId } = setupTest();
const { cliInputElement, user, getAllByTestId } = setupTest();

await user.type(cliInputElement, 'EXEC{enter}');
const terminalOutputElement = getByTestId('terminal-output');
expect(terminalOutputElement).toHaveTextContent(
"(error) ERR unknown command 'EXEC'",
const terminalOutputElements = getAllByTestId('terminal-output');

const errorElement = terminalOutputElements.find((element) =>
element.textContent?.includes("(error) ERR unknown command 'EXEC'"),
);
expect(errorElement).toBeDefined();
});

it('should navigate through command history', async () => {
Expand Down
4 changes: 2 additions & 2 deletions apps/playground-web/shared/utils/shellUtils.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// src/shared/utils/shellUtils.ts

import { executeShellCommandOnServer } from '@/lib/api';
import { CommandHandler, InvalidCommandHandler } from '@/types';
import { CommandHandler, BlockedCommandHandler } from '@/types';
import { handleResult } from '@/shared/utils/commonUtils';

export const handleBlockedCommand = async ({
command,
setOutput,
}: InvalidCommandHandler) => {
}: BlockedCommandHandler) => {
const newOutput = `dice > ${command}`;
setOutput((prevOutput: any) => [

Check warning on line 12 in apps/playground-web/shared/utils/shellUtils.ts

View workflow job for this annotation

GitHub Actions / Build and Test

Unexpected any. Specify a different type
...prevOutput,
Expand Down
2 changes: 1 addition & 1 deletion apps/playground-web/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface CommandHandler {
onCommandExecuted: (commandsLeft: number, cleanupTimeLeft: number) => void;
}

export interface InvalidCommandHandler {
export interface BlockedCommandHandler {
command: string;
setOutput: React.Dispatch<React.SetStateAction<string[]>>;
}

0 comments on commit ddb33d5

Please sign in to comment.