-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/devel' into devel
- Loading branch information
Showing
14 changed files
with
537 additions
and
61 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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* CloudBeaver - Cloud Database Manager | ||
* Copyright (C) 2020-2024 DBeaver Corp and others | ||
* | ||
* Licensed under the Apache License, Version 2.0. | ||
* you may not use this file except in compliance with the License. | ||
*/ | ||
import { waitFor } from '@testing-library/react'; | ||
|
||
import { createApp, renderInApp } from '@cloudbeaver/tests-runner'; | ||
|
||
import { Cell } from './Cell'; | ||
|
||
const app = createApp(); | ||
|
||
describe('Cell', () => { | ||
it('should render children correctly', async () => { | ||
const { getByText } = renderInApp(<Cell>Test Children</Cell>, app); | ||
const text = await waitFor(() => getByText('Test Children')); | ||
|
||
expect(text).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render before element correctly', async () => { | ||
const { getByText } = renderInApp(<Cell before={<span>Before Element</span>}>Test Children</Cell>, app); | ||
|
||
const beforeText = await waitFor(() => getByText('Before Element')); | ||
expect(beforeText).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render after element correctly', async () => { | ||
const { getByText } = renderInApp(<Cell after={<span>After Element</span>}>Test Children</Cell>, app); | ||
|
||
const afterText = await waitFor(() => getByText('After Element')); | ||
expect(afterText).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render after and before elements correctly', async () => { | ||
const { getByText } = renderInApp( | ||
<Cell before={<span>Before Element</span>} after={<span>After Element</span>}> | ||
Test Children | ||
</Cell>, | ||
app, | ||
); | ||
|
||
const afterText = await waitFor(() => getByText('After Element')); | ||
const beforeText = await waitFor(() => getByText('Before Element')); | ||
|
||
expect(beforeText).toBeInTheDocument(); | ||
expect(afterText).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render description element correctly', async () => { | ||
const { getByText } = renderInApp(<Cell description={<span>Description Element</span>}>Test Children</Cell>, app); | ||
|
||
const description = await waitFor(() => getByText('Description Element')); | ||
expect(description).toBeInTheDocument(); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* CloudBeaver - Cloud Database Manager | ||
* Copyright (C) 2020-2024 DBeaver Corp and others | ||
* | ||
* Licensed under the Apache License, Version 2.0. | ||
* you may not use this file except in compliance with the License. | ||
*/ | ||
import { fireEvent, queryByAttribute, waitFor } from '@testing-library/react'; | ||
|
||
import { createApp, renderInApp } from '@cloudbeaver/tests-runner'; | ||
|
||
import { Link } from './Link'; | ||
|
||
const app = createApp(); | ||
|
||
describe('Link', () => { | ||
it('should render link and children correctly', async () => { | ||
const { getByText } = renderInApp(<Link href="#">Test Link</Link>, app); | ||
const linkElement = await waitFor(() => getByText('Test Link')); | ||
|
||
expect(linkElement.tagName).toBe('A'); | ||
expect(linkElement).toBeInTheDocument(); | ||
}); | ||
|
||
it('should display the indicator icon when indicator is true', async () => { | ||
const { container } = renderInApp( | ||
<Link href="#" indicator> | ||
Test Link | ||
</Link>, | ||
app, | ||
); | ||
|
||
const icon = await waitFor(() => queryByAttribute('href', container, /external-link/i)); | ||
expect(icon).toBeInTheDocument(); | ||
}); | ||
|
||
it('should apply the className correctly', async () => { | ||
const { getByText } = renderInApp( | ||
<Link href="#" className="custom-class"> | ||
Test Link | ||
</Link>, | ||
app, | ||
); | ||
|
||
const linkContainer = await waitFor(() => getByText('Test Link').closest('div')); | ||
expect(linkContainer).toHaveClass('custom-class'); | ||
}); | ||
|
||
it('should handle onClick event', async () => { | ||
const handleClick = jest.fn(); | ||
const { getByText } = renderInApp( | ||
<Link href="#" onClick={handleClick}> | ||
Test Link | ||
</Link>, | ||
app, | ||
); | ||
|
||
const linkElement = await waitFor(() => getByText('Test Link')); | ||
fireEvent.click(linkElement); | ||
|
||
expect(handleClick).toHaveBeenCalled(); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* CloudBeaver - Cloud Database Manager | ||
* Copyright (C) 2020-2024 DBeaver Corp and others | ||
* | ||
* Licensed under the Apache License, Version 2.0. | ||
* you may not use this file except in compliance with the License. | ||
*/ | ||
import { fireEvent, queryByAttribute, waitFor } from '@testing-library/react'; | ||
|
||
import { coreDialogsManifest } from '@cloudbeaver/core-dialogs'; | ||
import { ENotificationType } from '@cloudbeaver/core-events'; | ||
import { coreLocalizationManifest } from '@cloudbeaver/core-localization'; | ||
import { createApp, renderInApp } from '@cloudbeaver/tests-runner'; | ||
|
||
import { StatusMessage } from './StatusMessage'; | ||
|
||
const app = createApp(coreLocalizationManifest, coreDialogsManifest); | ||
|
||
describe('StatusMessage', () => { | ||
it('should display an error icon and message when type is error', async () => { | ||
const message = 'test_error'; | ||
const { container, getByTitle } = renderInApp(<StatusMessage message={message} type={ENotificationType.Error} />, app); | ||
const title = await waitFor(() => getByTitle(message)); | ||
const icon = await waitFor(() => queryByAttribute('src', container, /error/i)); | ||
|
||
expect(title).toBeInTheDocument(); | ||
expect(icon).toBeInTheDocument(); | ||
}); | ||
|
||
it('should display a success icon and message when type is success', async () => { | ||
const message = 'test_success'; | ||
const { container, getByTitle } = renderInApp(<StatusMessage message={message} type={ENotificationType.Success} />, app); | ||
const title = await waitFor(() => getByTitle(message)); | ||
const icon = await waitFor(() => queryByAttribute('src', container, /success/i)); | ||
|
||
expect(title).toBeInTheDocument(); | ||
expect(icon).toBeInTheDocument(); | ||
}); | ||
|
||
it('should display an error message when no message is provided', async () => { | ||
const { getByText } = renderInApp(<StatusMessage exception={new Error('Test error')} />, app); | ||
const message = await waitFor(() => getByText('Test error')); | ||
|
||
expect(message).toBeInTheDocument(); | ||
}); | ||
|
||
it('should call onShowDetails when link is clicked', async () => { | ||
const onShowDetails = jest.fn(); | ||
const message = 'test_message_with_details'; | ||
const { getByText } = renderInApp(<StatusMessage message={message} onShowDetails={onShowDetails} />, app); | ||
const link = await waitFor(() => getByText(message)); | ||
|
||
fireEvent.click(link); | ||
expect(onShowDetails).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should display multiple messages joined by comma', async () => { | ||
const messages = ['message_one', 'message_two']; | ||
const { getByText } = renderInApp(<StatusMessage message={messages} />, app); | ||
const message = await waitFor(() => getByText('message_one, message_two')); | ||
|
||
expect(message).toBeInTheDocument(); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* CloudBeaver - Cloud Database Manager | ||
* Copyright (C) 2020-2024 DBeaver Corp and others | ||
* | ||
* Licensed under the Apache License, Version 2.0. | ||
* you may not use this file except in compliance with the License. | ||
*/ | ||
import { waitFor } from '@testing-library/react'; | ||
|
||
import { createApp, renderInApp } from '@cloudbeaver/tests-runner'; | ||
|
||
import { Text } from './Text'; | ||
|
||
const app = createApp(); | ||
|
||
describe('Text Component', () => { | ||
it('renders children correctly', async () => { | ||
const { getByText } = renderInApp(<Text>Hello World</Text>, app); | ||
const text = await waitFor(() => getByText('Hello World')); | ||
expect(text).toBeInTheDocument(); | ||
}); | ||
|
||
it('applies custom className', () => { | ||
const { container } = renderInApp(<Text className="custom-class">Hello World</Text>, app); | ||
expect(container.getElementsByClassName('custom-class')).toHaveLength(1); | ||
}); | ||
|
||
it('passes HTML attributes correctly', () => { | ||
const { container } = renderInApp( | ||
<Text id="custom-id" data-testid="custom-testid"> | ||
Hello World | ||
</Text>, | ||
app, | ||
); | ||
|
||
const div = container.firstChild; | ||
expect(div).toHaveAttribute('id', 'custom-id'); | ||
expect(div).toHaveAttribute('data-testid', 'custom-testid'); | ||
}); | ||
}); |
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
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* CloudBeaver - Cloud Database Manager | ||
* Copyright (C) 2020-2024 DBeaver Corp and others | ||
* | ||
* Licensed under the Apache License, Version 2.0. | ||
* you may not use this file except in compliance with the License. | ||
*/ | ||
import { waitFor } from '@testing-library/react'; | ||
|
||
import { createApp, renderInApp } from '@cloudbeaver/tests-runner'; | ||
|
||
import { TextPlaceholder } from './TextPlaceholder'; | ||
|
||
const app = createApp(); | ||
|
||
describe('TextPlaceholder Component', () => { | ||
it('renders children correctly', async () => { | ||
const { getByText } = renderInApp(<TextPlaceholder>Hello World</TextPlaceholder>, app); | ||
const text = await waitFor(() => getByText('Hello World')); | ||
expect(text).toBeInTheDocument(); | ||
}); | ||
|
||
it('applies custom className', () => { | ||
const { container } = renderInApp(<TextPlaceholder className="custom-class">Hello World</TextPlaceholder>, app); | ||
expect(container.getElementsByClassName('custom-class')).toHaveLength(1); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* CloudBeaver - Cloud Database Manager | ||
* Copyright (C) 2020-2024 DBeaver Corp and others | ||
* | ||
* Licensed under the Apache License, Version 2.0. | ||
* you may not use this file except in compliance with the License. | ||
*/ | ||
import { queryByAttribute, waitFor } from '@testing-library/react'; | ||
|
||
import { createApp, renderInApp } from '@cloudbeaver/tests-runner'; | ||
|
||
import { TimerIcon } from './TimerIcon'; | ||
|
||
const app = createApp(); | ||
|
||
describe('TimerIcon', () => { | ||
it('renders correctly with state "play" and interval 30', async () => { | ||
const { getByText, container } = renderInApp(<TimerIcon state="play" interval={30} />, app); | ||
const text = await waitFor(() => getByText('30')); | ||
const name = await waitFor(() => queryByAttribute('href', container, '/icons/timer-play_m.svg#root')); | ||
|
||
expect(name).toBeInTheDocument(); | ||
expect(text).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders correctly with state "stop" and interval 60', async () => { | ||
const { getByText, container } = renderInApp(<TimerIcon state="stop" interval={60} />, app); | ||
const text = await waitFor(() => getByText('60')); | ||
const name = await waitFor(() => queryByAttribute('href', container, '/icons/timer-stop_m.svg#root')); | ||
|
||
expect(name).toBeInTheDocument(); | ||
expect(text).toBeInTheDocument(); | ||
}); | ||
|
||
it('passes HTML attributes correctly', () => { | ||
const { container } = renderInApp(<TimerIcon state="play" interval={30} id="custom-id" data-testid="custom-testid" />, app); | ||
|
||
const div = container.firstChild; | ||
expect(div).toHaveAttribute('id', 'custom-id'); | ||
expect(div).toHaveAttribute('data-testid', 'custom-testid'); | ||
}); | ||
}); |
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
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.