-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from techeer-sv/develop
배포처리
- Loading branch information
Showing
21 changed files
with
2,210 additions
and
89 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,28 @@ | ||
name: DEPLOY | ||
on: | ||
push: | ||
branches: | ||
- master | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ap-northeast-2 | ||
|
||
- name: Build and Deploy | ||
run: | | ||
yarn install | ||
yarn build | ||
yarn ci-deploy | ||
- name: Invalidate CloudFront cache | ||
run: | | ||
aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" |
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,31 @@ | ||
# 워크 플로우의 이름 설정 | ||
name: TEST | ||
|
||
# 워크 플로우의 트리거 설정 (develop브랜치에 대한 push,pr에 대해 처리한다) | ||
on: | ||
push: | ||
branches: [develop] | ||
pull_request: | ||
branches: [develop] | ||
|
||
# 워크 플로우에서 실행될 작업 정의 | ||
jobs: | ||
build: | ||
name: jest test | ||
# 작업을 실행할 운영체제 설정 | ||
runs-on: ubuntu-latest | ||
|
||
# 병렬 실행 전략 설정 (Node사용) | ||
strategy: | ||
matrix: | ||
node-version: [16.x] | ||
|
||
steps: | ||
# 각 단계 설정 | ||
- uses: actions/checkout@v2 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- run: yarn install | ||
- run: yarn test |
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,16 @@ | ||
export default { | ||
testEnvironment: 'jest-environment-jsdom', | ||
transform: { | ||
'^.+\\.tsx?$': 'ts-jest', | ||
'.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$': | ||
'jest-transform-stub', | ||
}, | ||
moduleNameMapper: { | ||
'^.+\\.svg$': 'jest-svg-transformer', | ||
'^@/(.*)$': '<rootDir>/src/$1', | ||
'.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': | ||
'identity-obj-proxy', | ||
'\\.(css|less|scss)$': 'identity-obj-proxy', | ||
}, | ||
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'], | ||
}; |
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 @@ | ||
import '@testing-library/jest-dom/extend-expect'; |
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.
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,116 @@ | ||
import { | ||
render, | ||
fireEvent, | ||
screen, | ||
waitFor, | ||
act, | ||
} from '@testing-library/react'; | ||
import { BrowserRouter } from 'react-router-dom'; | ||
import Navbar from '.'; | ||
import { QueryClient, QueryClientProvider } from 'react-query'; | ||
|
||
import { rest } from 'msw'; | ||
import { setupServer } from 'msw/node'; | ||
import { RecoilRoot } from 'recoil'; | ||
|
||
jest.mock('react-router-dom', () => ({ | ||
...jest.requireActual('react-router-dom'), | ||
Link: ({ to, children }: any) => ( | ||
<div data-testid="mock-link" data-to={to}> | ||
{children} | ||
</div> | ||
), | ||
})); | ||
|
||
const server = setupServer( | ||
rest.get('http://test/api/v1/user/nickname', (_, res, ctx) => { | ||
return res(ctx.status(200), ctx.json({ nickname: 'testName' })); | ||
}), | ||
); | ||
|
||
beforeAll(() => { | ||
server.listen(); | ||
jest.spyOn(console, 'error').mockImplementation(() => {}); | ||
}); | ||
afterEach(() => server.resetHandlers()); | ||
afterAll(() => { | ||
server.close(); | ||
}); | ||
|
||
describe('Navbar 컴포넌트', () => { | ||
const queryClient = new QueryClient({ | ||
defaultOptions: { | ||
queries: { | ||
retry: false, | ||
}, | ||
}, | ||
}); | ||
|
||
beforeEach(() => { | ||
render( | ||
<BrowserRouter> | ||
<RecoilRoot> | ||
<QueryClientProvider client={queryClient}> | ||
<Navbar /> | ||
</QueryClientProvider> | ||
</RecoilRoot> | ||
</BrowserRouter>, | ||
); | ||
}); | ||
|
||
afterEach(() => { | ||
localStorage.clear(); | ||
}); | ||
|
||
describe('1. 로그인 상태일 때', () => { | ||
beforeEach(() => { | ||
localStorage.setItem('accessToken', 'testToken'); | ||
|
||
render( | ||
<BrowserRouter> | ||
<RecoilRoot> | ||
<QueryClientProvider client={queryClient}> | ||
<Navbar /> | ||
</QueryClientProvider> | ||
</RecoilRoot> | ||
</BrowserRouter>, | ||
); | ||
}); | ||
|
||
it('1.1 사용자 닉네임을 화면에 표시한다.', async () => { | ||
await waitFor(() => { | ||
expect(screen.getByText('testName')).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
it('1.2 로그아웃 버튼을 화면에 표시한다.', () => { | ||
const logoutButton = screen.getByText('logout'); | ||
expect(logoutButton).toBeInTheDocument(); | ||
}); | ||
|
||
it('1.3 로그아웃 버튼을 클릭하면 스토리지값을 초기화한다.', () => { | ||
const logoutButton = screen.getByText('logout'); | ||
fireEvent.click(logoutButton); | ||
expect(localStorage.getItem('accessToken')).toBeNull(); | ||
}); | ||
}); | ||
|
||
describe('2. 로그인 상태가 아닐 때', () => { | ||
it('2.1 회원가입과 로그인 버튼을 화면에 표현한다.', async () => { | ||
const loginButton = screen.getByText('SignIn'); | ||
expect(loginButton).toBeInTheDocument(); | ||
|
||
const signUpButton = screen.getByText('SignUp'); | ||
expect(signUpButton).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
it('로고 클릭 시 루트 경로(/)로 이동한다.', async () => { | ||
const links = screen.getAllByTestId('mock-link'); | ||
const logo = links.find((link) => link.getAttribute('data-to') === '/'); | ||
|
||
fireEvent.click(logo); | ||
|
||
expect(logo).toHaveAttribute('data-to', '/'); | ||
}); | ||
}); |
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
Oops, something went wrong.