-
-
+ className="flex flex-col self-stretch items-stretch grow h-[calc(100vh-160px)]"
+ data-testid="main"
+ >
+
+
+
+
+
+ {isDocsOpen ? (
+
+ {schemaLoading ? (
+
Loading...
+ ) : (
+
+ )}
+
+ ) : null}
+ {isUrlOpen ? (
+
+ ) : null}
+
+
+
+
+
+
+
+
+
+
+
+
+
- {isEditorOpen && (
-
-
-
- )}
-
+
+
+ {isEditorOpen && (
+
+
+
+ )}
+
- )
-}
+ );
+};
-export default Main
\ No newline at end of file
+export default Main;
diff --git a/src/styles/globals.css b/src/styles/globals.css
index 1989de4..291e487 100644
--- a/src/styles/globals.css
+++ b/src/styles/globals.css
@@ -2,7 +2,6 @@
@tailwind components;
@tailwind utilities;
-
@layer base {
:root {
--background: 0 0% 100%;
@@ -50,7 +49,6 @@
}
}
-
@layer base {
* {
@apply border-border;
@@ -61,15 +59,15 @@
}
@layer components {
#__next {
- @apply h-full bg-red-500;
+ @apply h-full bg-red-500;
}
html,
body {
- @apply h-full;
+ @apply h-full;
}
}
input {
-
width: 100%;
- min-width: 100%; }
\ No newline at end of file
+ min-width: 100%;
+}
diff --git a/src/test/EndpointEditor.test.tsx b/src/test/EndpointEditor.test.tsx
deleted file mode 100644
index 90d4080..0000000
--- a/src/test/EndpointEditor.test.tsx
+++ /dev/null
@@ -1,26 +0,0 @@
-
-import { render, screen } from '@testing-library/react';
-import '@testing-library/jest-dom';
-import EndpointEditor from '@/components/EndpointEditor/EndpointEditor';
-import store from '@/lib/store/store';
-import { Provider } from 'react-redux';
-
-describe('Endpoint editor tests: ', () => {
- test('Footer exists', () => {
- render(
-
-
-
- );
- const endpointEditor = screen.getByTestId('endpoint');
- expect(endpointEditor).toBeInTheDocument();
- });
-
- test('Footer renders correctly', () => {
- render(
-
- );
- const button = screen.getAllByTestId('button');
- expect(button).toBeInTheDocument;
- });
-});
diff --git a/src/test/endpoint.test.tsx b/src/test/endpoint.test.tsx
new file mode 100644
index 0000000..83a8959
--- /dev/null
+++ b/src/test/endpoint.test.tsx
@@ -0,0 +1,43 @@
+import React from 'react';
+import { render, screen, fireEvent } from '@testing-library/react';
+import { Provider } from 'react-redux';
+import EndpointEditor from '@/components/EndpointEditor/EndpointEditor';
+import store from '@/lib/store/store';
+import '@testing-library/jest-dom';
+
+describe('EndpointEditor', () => {
+ test('renders endpoint editor correctly', () => {
+ render(
+
+
+
+ );
+
+ const button = screen.getByTestId('button');
+ fireEvent.click(button);
+ const input = screen.getByTestId('input');
+ expect(input).toBeInTheDocument();
+ });
+
+ test('saves changes correctly', () => {
+ render(
+
+
+
+ );
+
+ const editButton = screen.getByTestId('button');
+ fireEvent.click(editButton);
+
+ const input = screen.getByTestId('input');
+ fireEvent.change(input, { target: { value: 'https://test.test' } });
+
+ const saveButton = screen.getByTestId('button');
+ fireEvent.click(saveButton);
+
+ expect(store.getState().data.apiUrl).toBe('https://test.test');
+
+ const editedInput = screen.queryByTestId('input');
+ expect(editedInput).toBeNull();
+ });
+});
diff --git a/src/test/errorboundary.test.tsx b/src/test/errorboundary.test.tsx
new file mode 100644
index 0000000..e60cf88
--- /dev/null
+++ b/src/test/errorboundary.test.tsx
@@ -0,0 +1,35 @@
+import React from 'react';
+import { render, screen } from '@testing-library/react';
+import ErrorBoundary from '@/components/ErrorBoundary/ErrorBoundary';
+import '@testing-library/jest-dom';
+
+const ErrorThrowingComponent = ({ error }: { error: Error }) => {
+ throw error;
+};
+
+describe('ErrorBoundary', () => {
+ test('renders children when there is no error', () => {
+ render(
+
+ Test Child
+
+ );
+
+ expect(screen.getByText('Test Child')).toBeInTheDocument();
+ });
+
+ test('renders error message and reload button on error', () => {
+ const error = new Error('Test error');
+
+ render(
+
+
+
+ );
+
+ expect(
+ screen.getByText('Oops... something went wrong...')
+ ).toBeInTheDocument();
+ expect(screen.getByText('Reload app')).toBeInTheDocument();
+ });
+});
diff --git a/src/test/main.test.tsx b/src/test/main.test.tsx
index 9034cdf..bf5a347 100644
--- a/src/test/main.test.tsx
+++ b/src/test/main.test.tsx
@@ -1,5 +1,4 @@
-
-import { render, screen } from '@testing-library/react';
+import { render, screen, fireEvent } from '@testing-library/react';
import '@testing-library/jest-dom';
import Main from '@/pages/main';
import store from '@/lib/store/store';
@@ -9,22 +8,37 @@ jest.mock('next/router', () => require('next-router-mock'));
describe('Main tests: ', () => {
test('Main exists', () => {
render(
-
-
-
-
-
- );
+
+
+
+ );
const main = screen.getByTestId('main');
expect(main).toBeInTheDocument();
});
test('Main renders correctly', () => {
- render(
-
+ render(
+
- );
+
+ );
const sections = screen.getAllByTestId('section');
expect(sections).toHaveLength(4);
});
+
+ test('Toggle Docs and URL buttons', () => {
+ render(
+
+
+
+ );
+
+ const docsButton = screen.getByTestId('docs-button');
+ const urlButton = screen.getByTestId('url-button');
+
+ fireEvent.click(docsButton);
+ expect(screen.getByTestId('docs-container')).toBeInTheDocument();
+ fireEvent.click(urlButton);
+ expect(screen.getByText('URL')).toBeInTheDocument();
+ });
});
diff --git a/src/test/prettifier.test.tsx b/src/test/prettifier.test.tsx
index 343e63a..876df32 100644
--- a/src/test/prettifier.test.tsx
+++ b/src/test/prettifier.test.tsx
@@ -1,5 +1,4 @@
-import { prettifyText } from "@/lib/utils";
-
+import { prettifyText } from '@/lib/utils';
const text1 = '{hgfjhg : { fjhgkdh: ghjhgj } ,djfhg :fhgkdj}';
const text2 = `{
@@ -9,7 +8,7 @@ const text2 = `{
djfhg: fhgkdj
}`;
const text3 = `{
- field(arg: "value") {
+ field(arg: "value"){
subField
}
}`;