-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests for all the components
- Loading branch information
Showing
28 changed files
with
444 additions
and
93 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,6 +1,7 @@ | ||
# Known Issues | ||
|
||
If you encountered issue with `npm install` exited with the following | ||
|
||
``` | ||
[4949 ms] Start: Run in container: /bin/sh -c npm install | ||
npm notice | ||
|
@@ -10,11 +11,14 @@ npm notice Run npm install -g [email protected] to update! | |
npm notice | ||
[121068 ms] postCreateCommand failed with exit code 1. Skipping any further user-provided commands. | ||
``` | ||
|
||
you are most probably behind a proxy / corporate network. To resolve this issue: | ||
|
||
1. Open in a new browser tab `https://registry.npmjs.org/` | ||
2. Follow [here](https://www.howtogeek.com/292076/how-do-you-view-ssl-certificate-details-in-google-chrome/) to get Root CA and click on `Export` to extract certificate content | ||
3. Copy and paste the content inside `root_ca.crt` that should be created under `.devcontainer/` | ||
4. add the following env variable to map Root CA into the container | ||
|
||
```json | ||
[...] | ||
"remoteEnv": { | ||
|
@@ -23,9 +27,10 @@ you are most probably behind a proxy / corporate network. To resolve this issue: | |
}, | ||
[...] | ||
``` | ||
5. In VS Code `cmd/ctrl` + `shift` + `p` and select the **Dev Containers: Rebuild and Reopen in container** command to rebuild and open container. | ||
|
||
5. In VS Code `cmd/ctrl` + `shift` + `p` and select the **Dev Containers: Rebuild and Reopen in container** command to rebuild and open container. | ||
|
||
References: | ||
|
||
- [Issue with self signed certificates when installing extensions](https://github.com/microsoft/vscode-remote-release/issues/2987) | ||
- [Self signed SSL Certificate support for DevContainers](https://github.com/microsoft/vscode-remote-release/issues/6092) |
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,6 +1,8 @@ | ||
node_modules | ||
.storybook/public | ||
.storybook/static | ||
storybook-static | ||
coverage | ||
.coverage | ||
lib | ||
build | ||
|
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 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,19 @@ | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
import { composeStories } from '@storybook/react'; | ||
import * as DemoStories from './demo.stories'; | ||
|
||
const { Default } = composeStories(DemoStories); | ||
|
||
test('renders Calendar component with default args', async () => { | ||
render(<Default />); | ||
expect(await screen.findByText('month')).toBeVisible(); | ||
expect(await screen.findByText('week')).toBeVisible(); | ||
expect(await screen.findByText('day')).toBeVisible(); | ||
expect(await screen.findByText('Heading')).toBeVisible(); | ||
const dayEl = screen.getByText('day'); | ||
expect(dayEl).not.toBeNull(); | ||
fireEvent.click(dayEl); | ||
const weekEl = await screen.findByText('week'); | ||
expect(weekEl).not.toBeNull(); | ||
fireEvent.click(weekEl); | ||
}); |
11 changes: 11 additions & 0 deletions
11
src/components/Pega_Extensions_CaseReference/demo.test.tsx
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,11 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import { composeStories } from '@storybook/react'; | ||
import * as DemoStories from './demo.stories'; | ||
|
||
const { Default } = composeStories(DemoStories); | ||
|
||
test('renders Case Reference component with default args', async () => { | ||
render(<Default />); | ||
const linkEl = screen.getByText('C-123'); | ||
expect(linkEl).not.toBeNull(); | ||
}); |
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,25 @@ | ||
import { render, screen, fireEvent, act } from '@testing-library/react'; | ||
import { composeStories } from '@storybook/react'; | ||
import * as DemoStories from './demo.stories'; | ||
|
||
const { Default } = composeStories(DemoStories); | ||
|
||
jest.setTimeout(10000); | ||
|
||
test('renders ChatGenAI widget with default args', async () => { | ||
jest.spyOn(window, 'alert').mockImplementation(() => {}); | ||
render(<Default />); | ||
const txtEl = screen.getByTestId(':text-area:control'); | ||
expect(txtEl).not.toBeNull(); | ||
const BtnEl = screen.getByLabelText('Send'); | ||
expect(BtnEl).not.toBeNull(); | ||
// eslint-disable-next-line testing-library/no-unnecessary-act | ||
act(() => { | ||
fireEvent.click(BtnEl); | ||
}); | ||
expect(await screen.findByLabelText('GenAI Assistant is typing')).toBeVisible(); | ||
await new Promise(r => { | ||
setTimeout(r, 2000); | ||
}); | ||
expect(await screen.findByText(/Thanks for asking/i)).toBeVisible(); | ||
}); |
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
18 changes: 18 additions & 0 deletions
18
src/components/Pega_Extensions_CompareTableLayout/demo.test.tsx
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,18 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import { composeStories } from '@storybook/react'; | ||
import * as DemoStories from './demo.stories'; | ||
|
||
const { Default, FinancialReport, RadioButton } = composeStories(DemoStories); | ||
|
||
test('renders CompareTable component with default args', async () => { | ||
render(<Default />); | ||
expect(await screen.findByText('Heading')).toBeVisible(); | ||
const linkEl = screen.getByText('MacBook Air'); | ||
expect(linkEl).not.toBeNull(); | ||
|
||
render(<FinancialReport />); | ||
expect(await screen.findByText('Financial report')).toBeVisible(); | ||
|
||
render(<RadioButton />); | ||
expect(await screen.findByText('Radio-button')).toBeVisible(); | ||
}); |
Oops, something went wrong.