-
Notifications
You must be signed in to change notification settings - Fork 0
Migration2 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SahzodDev
wants to merge
9
commits into
master
Choose a base branch
from
migration2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Migration2 #2
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
43cc966
migrated all the tests to rtl.
5364887
migrations for pull request.
00fa768
containerization implemented.
d1037ed
implemented the yml file for ci pipeline.
260feac
created the yml file for ci pipeline.
608fe48
Update main.yml
SahzodDev 5d06396
commit message
179eede
Update main.yml
SahzodDev ca619f4
Created snapshot and added custom for getByTestId
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,4 @@ | ||
| node_modules | ||
| npm-debug.log | ||
| Dockerfile | ||
| .dockerignore |
This file contains hidden or 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 @@ | ||
| SKIP_PREFLIGHT_CHECK=true |
This file contains hidden or 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,45 @@ | ||
| name: Migration Branch Workflow | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - migration | ||
| pull_request: | ||
| branches: | ||
| - migration | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v2 | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v2 | ||
| with: | ||
| node-version: '16' | ||
|
|
||
| - name: Install dependencies | ||
| run: yarn install | ||
|
|
||
| - name: Run unit tests | ||
| run: yarn test | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v1 | ||
|
|
||
| - name: Log in to Docker Hub | ||
| uses: docker/login-action@v1 | ||
| with: | ||
| username: ${{ secrets.DOCKER_USERNAME }} | ||
| password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
|
||
| - name: Build and push Docker image | ||
| if: success() # Only run this step if the tests pass | ||
| uses: docker/build-push-action@v2 | ||
| with: | ||
| context: . | ||
| push: true | ||
| tags: ${{ secrets.DOCKER_USERNAME }}/migration-enzyme-to-rtl:latest |
This file contains hidden or 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,20 @@ | ||
| # Use the official Node.js image from the Docker Hub and specify the version | ||
| FROM node:16.20.1 | ||
|
|
||
| # Create and set the working directory inside the container | ||
| WORKDIR /usr/src/app | ||
|
|
||
| # Copy the package.json and package-lock.json (or yarn.lock) files | ||
| COPY package*.json ./ | ||
|
|
||
| # Install the project dependencies | ||
| RUN yarn install | ||
|
|
||
| # Copy the rest of the project files | ||
| COPY . . | ||
|
|
||
| # Expose the port the app runs on (change this if your app uses a different port) | ||
| EXPOSE 3000 | ||
|
|
||
| # Command to run the application | ||
| CMD ["yarn", "start"] |
This file contains hidden or 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
28 changes: 28 additions & 0 deletions
28
src/tests/__snapshots__/react-testing-library.test.tsx.snap
This file contains hidden or 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,28 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`React Testing Library do: create snapshot of mounted component 1`] = ` | ||
| <DocumentFragment> | ||
| <div | ||
| class="App" | ||
| > | ||
| <div | ||
| class="button-style" | ||
| data-test-target="button-element" | ||
| > | ||
| Click me! | ||
| </div> | ||
| <label | ||
| class="toggle-style" | ||
| for="toggle-id" | ||
| > | ||
| <input | ||
| checked="" | ||
| data-test-target="toggle-element" | ||
| id="toggle-id" | ||
| type="checkbox" | ||
| /> | ||
| Toggle me! | ||
| </label> | ||
| </div> | ||
| </DocumentFragment> | ||
| `; |
This file contains hidden or 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,34 +1,114 @@ | ||
| import React from 'react'; | ||
| import { fireEvent, logRoles } from '@testing-library/react'; | ||
| import { render, screen } from '@testing-library/react'; | ||
| import { App } from '../components/app'; | ||
| import { Toggle, ToggleProps } from '../components/toggle/toggle'; | ||
| import { Button, ButtonProps } from '../components/button/button'; | ||
|
|
||
| describe('React Testing Library do:', () => { | ||
|
|
||
| test('create snapshot of mounted component', () => { | ||
| throw new Error('Not migrated yet'); | ||
| // render app as a doc fragment | ||
| const {asFragment} = render(<App />); | ||
|
|
||
| // check the snapshot | ||
| expect(asFragment()).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| test('find child by component', () => { | ||
| throw new Error('Not migrated yet'); | ||
| // render App | ||
| render(<App />); | ||
|
|
||
|
|
||
| // find the component | ||
| const childElement = screen.getByText(/click/i); | ||
|
|
||
| // check if it exists | ||
| expect(childElement).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('find child by attribute', () => { | ||
| throw new Error('Not migrated yet'); | ||
| // render App | ||
| render(<App/>); | ||
|
|
||
| // find the component | ||
| const childElement = screen.getByTestId("button-element"); | ||
|
|
||
| // check if it exists | ||
| expect(childElement).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('find child by class name', () => { | ||
| throw new Error('Not migrated yet'); | ||
| // render component | ||
| const props: ToggleProps = { | ||
| initialState: true, | ||
| title: 'Dummy toggle title', | ||
| onChange: () => null, | ||
| }; | ||
| const {container} = render(<Toggle {...props} />); | ||
|
|
||
|
|
||
| // find the component | ||
| const input = container.querySelector('.toggle-style'); | ||
|
|
||
| // check if it exists | ||
| expect(input).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('get child attribute', () => { | ||
| throw new Error('Not migrated yet'); | ||
| // render app | ||
| render(<App/>); | ||
|
|
||
| // find the component and it's attribute | ||
| const input = screen.getByTestId("toggle-element"); | ||
|
|
||
| // simulate input | ||
| fireEvent.click(input); | ||
|
|
||
| // check the attribute value | ||
| expect(input).not.toBeChecked(); // since the initial state of the checkbox is checked, im asserting wether or not it is unchecked. | ||
| }); | ||
|
|
||
| test('set component property', () => { | ||
| throw new Error('Not migrated yet'); | ||
| // create a dummy button | ||
| const props: ButtonProps = { | ||
| title: "Dummy button title", | ||
| isDisabled: false, | ||
| onClick: jest.fn(), | ||
| } | ||
|
|
||
| // render and disable the button | ||
| const {rerender} = render(<Button {...props}/>); | ||
| rerender(<Button {...props} isDisabled={true} />) | ||
|
|
||
| // find the button | ||
| const button = screen.getByText(/dummy/i); | ||
|
|
||
| // simulate a click | ||
| fireEvent.click(button); | ||
|
|
||
| // check if the button is clickable | ||
| expect(props.onClick).toBeCalledTimes(0); | ||
| }); | ||
|
|
||
| test('callback test', () => { | ||
| throw new Error('Not migrated yet'); | ||
| // create a dummy button | ||
| const props: ButtonProps = { | ||
| title: "Dummy button props", | ||
| isDisabled: false, | ||
| onClick: jest.fn(), | ||
| } | ||
|
|
||
| // render the button | ||
| render(<Button {...props}/>); | ||
|
|
||
| // find the button | ||
| const button = screen.getByText(/dummy/i); | ||
|
|
||
| // simulate a click | ||
| fireEvent.click(button); | ||
|
|
||
| // check if the button is clicked | ||
| expect(props.onClick).toBeCalledTimes(1); | ||
| }); | ||
| }); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.