-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
188 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,26 @@ | ||
// import { screen } from '@testing-library/react'; | ||
import { screen } from '@testing-library/react'; | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
// import renderWithRouter from '@/test/helpers/RenderWithRouter'; | ||
// import MainPage from '@pages/MainPage/MainPage'; | ||
import renderWithRouter from '@/test/helpers/RenderWithRouter'; | ||
import MainPage from '@pages/MainPage/MainPage'; | ||
|
||
describe('Editor tools', () => { | ||
// it('should render the editor tools', () => { | ||
// renderWithRouter(<MainPage />); | ||
it('should render the editor tools', () => { | ||
renderWithRouter(<MainPage />); | ||
|
||
// expect(screen.getByTestId('editor-tools-variables')).toBeInTheDocument(); | ||
// expect(screen.getByTestId('editor-tools-headers')).toBeInTheDocument(); | ||
// expect(screen.getByTestId('editor-tools-tabs')).toBeInTheDocument(); | ||
// expect(screen.getByTestId('editor-tools-expand')).toBeInTheDocument(); | ||
// }); | ||
expect(screen.getByTestId('editor-tools-variables')).toBeInTheDocument(); | ||
expect(screen.getByTestId('editor-tools-headers')).toBeInTheDocument(); | ||
expect(screen.getByTestId('editor-tools-tabs')).toBeInTheDocument(); | ||
expect(screen.getByTestId('editor-tools-expand')).toBeInTheDocument(); | ||
}); | ||
|
||
// it('should change the tabs', async () => { | ||
// renderWithRouter(<MainPage />); | ||
it('should change the tabs', async () => { | ||
renderWithRouter(<MainPage />); | ||
|
||
// const editorToolsTabs = screen.getByTestId('editor-tools-tabs'); | ||
// Object.defineProperty(editorToolsTabs, 'activeTabIndex', { value: 0 }); | ||
const editorToolsTabs = screen.getByTestId('editor-tools-tabs'); | ||
Object.defineProperty(editorToolsTabs, 'activeTabIndex', { value: 0 }); | ||
|
||
// expect(screen.getByTestId('editor-tools-variables')).toHaveAttribute('active', 'true'); | ||
// expect(screen.getByTestId('editor-tools-headers')).toHaveAttribute('active', 'true'); | ||
// }); | ||
it('fake', () => { | ||
expect(1).toBe(1); | ||
expect(screen.getByTestId('editor-tools-variables')).toHaveAttribute('active', 'true'); | ||
expect(screen.getByTestId('editor-tools-headers')).toHaveAttribute('active', 'true'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,55 @@ | ||
// import { screen } from '@testing-library/react'; | ||
// import userEvent from '@testing-library/user-event'; | ||
// import { afterEach, describe, expect, it, vi } from 'vitest'; | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
// import renderWithRouter from '@/test/helpers/RenderWithRouter'; | ||
// import * as useEditorUrlState from '@components/Editor/lib/hooks/useEditorUrlState'; | ||
// import MainPage from '@pages/MainPage/MainPage'; | ||
// import * as useUrl from '@shared/lib/hooks/useUrl'; | ||
|
||
// const mockWriteText = vi.fn(); | ||
// const mockEditorText = 'test text'; | ||
// const mockedUseEditorUrlState = vi.spyOn(useEditorUrlState, 'default'); | ||
// const mockedReadUrl = vi.spyOn(useUrl, 'default'); | ||
|
||
// Object.assign(navigator, { | ||
// clipboard: { | ||
// writeText: mockWriteText, | ||
// }, | ||
// }); | ||
import { screen } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { afterEach, describe, expect, it, vi } from 'vitest'; | ||
|
||
import renderWithRouter from '@/test/helpers/RenderWithRouter'; | ||
import * as useEditorUrlState from '@components/Editor/lib/hooks/useEditorUrlState'; | ||
import MainPage from '@pages/MainPage/MainPage'; | ||
import * as useUrl from '@shared/lib/hooks/useUrl'; | ||
|
||
const mockWriteText = vi.fn(); | ||
const mockEditorText = 'test text'; | ||
const mockedUseEditorUrlState = vi.spyOn(useEditorUrlState, 'default'); | ||
const mockedReadUrl = vi.spyOn(useUrl, 'default'); | ||
|
||
Object.assign(navigator, { | ||
clipboard: { | ||
writeText: mockWriteText, | ||
}, | ||
}); | ||
|
||
// const mockedClipboard = vi.spyOn(navigator.clipboard, 'writeText'); | ||
const mockedClipboard = vi.spyOn(navigator.clipboard, 'writeText'); | ||
|
||
describe('Request editor', () => { | ||
// afterEach(() => { | ||
// vi.clearAllMocks(); | ||
// }); | ||
afterEach(() => { | ||
vi.clearAllMocks(); | ||
}); | ||
|
||
// it('should render the request editor', () => { | ||
// renderWithRouter(<MainPage />); | ||
it('should render the request editor', () => { | ||
renderWithRouter(<MainPage />); | ||
|
||
// const controls = screen.getByTestId('controls'); | ||
// const editor = screen.getByTestId('editor-request'); | ||
const controls = screen.getByTestId('controls'); | ||
const editor = screen.getByTestId('editor-request'); | ||
|
||
// expect(controls).toBeInTheDocument(); | ||
// expect(editor).toBeInTheDocument(); | ||
// }); | ||
expect(controls).toBeInTheDocument(); | ||
expect(editor).toBeInTheDocument(); | ||
}); | ||
|
||
// it('should copy the entered text', async () => { | ||
// mockedUseEditorUrlState.mockReturnValue([mockEditorText, vi.fn()]); | ||
// mockedReadUrl.mockReturnValue({ | ||
// readUrl: () => mockEditorText, | ||
// setUrl: () => {}, | ||
// }); | ||
it('should copy the entered text', async () => { | ||
mockedUseEditorUrlState.mockReturnValue([mockEditorText, vi.fn()]); | ||
mockedReadUrl.mockReturnValue({ | ||
readUrl: () => mockEditorText, | ||
setUrl: () => {}, | ||
}); | ||
|
||
// renderWithRouter(<MainPage />); | ||
renderWithRouter(<MainPage />); | ||
|
||
// const copyText = screen.getByTestId('copy-text'); | ||
const copyText = screen.getByTestId('copy-text'); | ||
|
||
// expect(copyText).toBeInTheDocument(); | ||
expect(copyText).toBeInTheDocument(); | ||
|
||
// await userEvent.click(copyText); | ||
await userEvent.click(copyText); | ||
|
||
// expect(mockedClipboard).toHaveBeenCalledWith(mockEditorText); | ||
// }); | ||
it('fake', () => { | ||
expect(1).toBe(1); | ||
expect(mockedClipboard).toHaveBeenCalledWith(mockEditorText); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,46 @@ | ||
// import { act, fireEvent, render, screen, waitForElementToBeRemoved } from '@testing-library/react'; | ||
import { act, fireEvent, render, screen, waitForElementToBeRemoved } from '@testing-library/react'; | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
// import App from '@/app/App'; | ||
import App from '@/app/App'; | ||
|
||
describe('Testing for docs component', () => { | ||
// it('Should render docs components after clicking on show docs btn', async () => { | ||
// render(<App />); | ||
// const showDocsBtn = screen.getByText('show docs'); | ||
// expect(screen.queryByTestId('overlay')).toBeNull(); | ||
// expect(screen.queryByText('Docs')).toBeNull(); | ||
// expect(screen.queryByText('A GraphQL schema provides a root type for each kind of operation')).toBeNull(); | ||
// await act(async () => { | ||
// fireEvent.click(showDocsBtn); | ||
// }); | ||
// expect(await screen.findByTestId('overlay')).toBeInTheDocument(); | ||
// expect(await screen.findByText('Docs')).toBeInTheDocument(); | ||
// expect( | ||
// await screen.findByText('A GraphQL schema provides a root type for each kind of operation.'), | ||
// ).toBeInTheDocument(); | ||
// }); | ||
// it('Should close docs section after clicking on overlay', async () => { | ||
// render(<App />); | ||
// const showDocsBtn = screen.getByText('show docs'); | ||
// expect(screen.queryByTestId('overlay')).toBeNull(); | ||
// expect(screen.queryByText('Docs')).toBeNull(); | ||
// expect(screen.queryByText('A GraphQL schema provides a root type for each kind of operation')).toBeNull(); | ||
// await act(async () => { | ||
// fireEvent.click(showDocsBtn); | ||
// }); | ||
// const overlay = await screen.findByTestId('overlay'); | ||
// expect(overlay).toBeInTheDocument(); | ||
// expect(await screen.findByText('Docs')).toBeInTheDocument(); | ||
// expect( | ||
// await screen.findByText('A GraphQL schema provides a root type for each kind of operation.'), | ||
// ).toBeInTheDocument(); | ||
// await act(async () => { | ||
// fireEvent.click(overlay); | ||
// }); | ||
// waitForElementToBeRemoved(() => { | ||
// expect(overlay).toBeNull(); | ||
// expect(screen.queryByText('Docs')).toBeNull(); | ||
// expect(screen.queryByText('A GraphQL schema provides a root type for each kind of operation.')).toBeNull(); | ||
// }).catch(() => {}); | ||
// }); | ||
it('fake', () => { | ||
expect(1).toBe(1); | ||
it('Should render docs components after clicking on show docs btn', async () => { | ||
render(<App />); | ||
const showDocsBtn = screen.getByText('show docs'); | ||
expect(screen.queryByTestId('overlay')).toBeNull(); | ||
expect(screen.queryByText('Docs')).toBeNull(); | ||
expect(screen.queryByText('A GraphQL schema provides a root type for each kind of operation')).toBeNull(); | ||
await act(async () => { | ||
fireEvent.click(showDocsBtn); | ||
}); | ||
expect(await screen.findByTestId('overlay')).toBeInTheDocument(); | ||
expect(await screen.findByText('Docs')).toBeInTheDocument(); | ||
expect( | ||
await screen.findByText('A GraphQL schema provides a root type for each kind of operation.'), | ||
).toBeInTheDocument(); | ||
}); | ||
it('Should close docs section after clicking on overlay', async () => { | ||
render(<App />); | ||
const showDocsBtn = screen.getByText('show docs'); | ||
expect(screen.queryByTestId('overlay')).toBeNull(); | ||
expect(screen.queryByText('Docs')).toBeNull(); | ||
expect(screen.queryByText('A GraphQL schema provides a root type for each kind of operation')).toBeNull(); | ||
await act(async () => { | ||
fireEvent.click(showDocsBtn); | ||
}); | ||
const overlay = await screen.findByTestId('overlay'); | ||
expect(overlay).toBeInTheDocument(); | ||
expect(await screen.findByText('Docs')).toBeInTheDocument(); | ||
expect( | ||
await screen.findByText('A GraphQL schema provides a root type for each kind of operation.'), | ||
).toBeInTheDocument(); | ||
await act(async () => { | ||
fireEvent.click(overlay); | ||
}); | ||
waitForElementToBeRemoved(() => { | ||
expect(overlay).toBeNull(); | ||
expect(screen.queryByText('Docs')).toBeNull(); | ||
expect(screen.queryByText('A GraphQL schema provides a root type for each kind of operation.')).toBeNull(); | ||
}).catch(() => {}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,59 @@ | ||
// import { act, fireEvent, render, screen } from '@testing-library/react'; | ||
import { act, fireEvent, render, screen } from '@testing-library/react'; | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
// import App from '@/app/App'; | ||
import App from '@/app/App'; | ||
|
||
describe('Testing for docs component', () => { | ||
// it('Should navigate and display info about proper info about root type after cliking on that type', async () => { | ||
// render(<App />); | ||
// const showDocsBtn = screen.getByText('show docs'); | ||
// await act(async () => { | ||
// fireEvent.click(showDocsBtn); | ||
// }); | ||
// const RootTypeLink = await screen.findByText('Root'); | ||
// await act(async () => { | ||
// fireEvent.click(RootTypeLink); | ||
// }); | ||
// expect(await screen.findByText('Fields:')).toBeInTheDocument(); | ||
// }); | ||
// it('Should navigate and display info about proper info about root type after cliking on that type and all following clicked types as well as navigating back', async () => { | ||
// render(<App />); | ||
// const showDocsBtn = screen.getByText('show docs'); | ||
// await act(async () => { | ||
// fireEvent.click(showDocsBtn); | ||
// }); | ||
// const RootTypeLink = await screen.findByText('Root'); | ||
// await act(async () => { | ||
// fireEvent.click(RootTypeLink); | ||
// }); | ||
// expect(await screen.findByText('Fields:')).toBeInTheDocument(); | ||
// const filmsLink = await screen.findByText('Film'); | ||
// expect(filmsLink).toBeInTheDocument(); | ||
// await act(async () => { | ||
// fireEvent.click(filmsLink); | ||
// }); | ||
// expect(await screen.findByText('Implements:')).toBeInTheDocument(); | ||
// const nodeTypeLink = await screen.findByText('Node'); | ||
// expect(nodeTypeLink).toBeInTheDocument(); | ||
// await act(async () => { | ||
// fireEvent.click(nodeTypeLink); | ||
// }); | ||
// expect(await screen.findByText('Implementations')).toBeInTheDocument(); | ||
// const backToFilmBtn = await screen.findByRole('button', { name: 'Film' }); | ||
// await act(async () => { | ||
// fireEvent.click(backToFilmBtn); | ||
// }); | ||
// const backToRootBtn = await screen.findByRole('button', { name: 'Root' }); | ||
// await act(async () => { | ||
// fireEvent.click(backToRootBtn); | ||
// }); | ||
// const backToDocsBtn = await screen.findByRole('button', { name: 'Docs' }); | ||
// await act(async () => { | ||
// fireEvent.click(backToDocsBtn); | ||
// }); | ||
// expect(await screen.findByText('Docs')).toBeInTheDocument(); | ||
// expect( | ||
// await screen.findByText('A GraphQL schema provides a root type for each kind of operation.'), | ||
// ).toBeInTheDocument(); | ||
// }); | ||
it('fake', () => { | ||
expect(1).toBe(1); | ||
it('Should navigate and display info about proper info about root type after cliking on that type', async () => { | ||
render(<App />); | ||
const showDocsBtn = screen.getByText('show docs'); | ||
await act(async () => { | ||
fireEvent.click(showDocsBtn); | ||
}); | ||
const RootTypeLink = await screen.findByText('Root'); | ||
await act(async () => { | ||
fireEvent.click(RootTypeLink); | ||
}); | ||
expect(await screen.findByText('Fields:')).toBeInTheDocument(); | ||
}); | ||
it('Should navigate and display info about proper info about root type after cliking on that type and all following clicked types as well as navigating back', async () => { | ||
render(<App />); | ||
const showDocsBtn = screen.getByText('show docs'); | ||
await act(async () => { | ||
fireEvent.click(showDocsBtn); | ||
}); | ||
const RootTypeLink = await screen.findByText('Root'); | ||
await act(async () => { | ||
fireEvent.click(RootTypeLink); | ||
}); | ||
expect(await screen.findByText('Fields:')).toBeInTheDocument(); | ||
const filmsLink = await screen.findByText('Film'); | ||
expect(filmsLink).toBeInTheDocument(); | ||
await act(async () => { | ||
fireEvent.click(filmsLink); | ||
}); | ||
expect(await screen.findByText('Implements:')).toBeInTheDocument(); | ||
const nodeTypeLink = await screen.findByText('Node'); | ||
expect(nodeTypeLink).toBeInTheDocument(); | ||
await act(async () => { | ||
fireEvent.click(nodeTypeLink); | ||
}); | ||
expect(await screen.findByText('Implementations')).toBeInTheDocument(); | ||
const backToFilmBtn = await screen.findByRole('button', { name: 'Film' }); | ||
await act(async () => { | ||
fireEvent.click(backToFilmBtn); | ||
}); | ||
const backToRootBtn = await screen.findByRole('button', { name: 'Root' }); | ||
await act(async () => { | ||
fireEvent.click(backToRootBtn); | ||
}); | ||
const backToDocsBtn = await screen.findByRole('button', { name: 'Docs' }); | ||
await act(async () => { | ||
fireEvent.click(backToDocsBtn); | ||
}); | ||
expect(await screen.findByText('Docs')).toBeInTheDocument(); | ||
expect( | ||
await screen.findByText('A GraphQL schema provides a root type for each kind of operation.'), | ||
).toBeInTheDocument(); | ||
}); | ||
}); |
Oops, something went wrong.