Skip to content

Commit ceb0838

Browse files
committed
add ci unit and e2e
1 parent cb42487 commit ceb0838

File tree

26 files changed

+430
-32
lines changed

26 files changed

+430
-32
lines changed

.github/workflows/ci-e2e.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: E2e testing
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ $default-branch ]
7+
pull_request:
8+
branches: [ $default-branch ]
9+
10+
jobs:
11+
cypress:
12+
defaults:
13+
run:
14+
working-directory: dashboard
15+
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 15
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
22+
- run: npm install
23+
24+
- run: npm run build
25+
env:
26+
NODE_ENV: production
27+
28+
- name: Run project locally
29+
run: |
30+
npm install serve
31+
$(npm bin)/serve dist -s -p 8080 &
32+
33+
- name: Run tests
34+
uses: cypress-io/github-action@v2
35+
with:
36+
working-directory: dashboard
37+
browser: chrome
38+
headless: true

.github/workflows/ci-unit.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Unit testing
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ $default-branch ]
7+
pull_request:
8+
branches: [ $default-branch ]
9+
10+
defaults:
11+
run:
12+
working-directory: dashboard
13+
14+
jobs:
15+
jest:
16+
runs-on: ubuntu-latest
17+
18+
strategy:
19+
matrix:
20+
node-version: [13.x]
21+
22+
steps:
23+
- uses: actions/checkout@v2
24+
- name: Use Node.js ${{ matrix.node-version }}
25+
uses: actions/setup-node@v1
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
- run: npm install
29+
- run: npm run test:unit --if-present

backend/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
.now
1+
.now
2+
.vercel

dashboard/.eslintrc.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ module.exports = {
1717
overrides: [
1818
{
1919
files: [
20-
'**/__tests__/*.{j,t}s?(x)',
21-
'**/tests/unit/**/*.spec.{j,t}s?(x)'
20+
'**/*.spec.js'
2221
],
2322
env: {
2423
jest: true

dashboard/jest.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
module.exports = {
22
preset: '@vue/cli-plugin-unit-jest',
3+
testMatch: [
4+
'**/*.spec.js'
5+
],
36
transform: {
47
'^.+\\.vue$': 'vue-jest'
58
}

dashboard/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"@vue/cli-service": "~4.5.0",
3333
"@vue/compiler-sfc": "^3.0.0",
3434
"@vue/eslint-config-standard": "^5.1.2",
35-
"@vue/test-utils": "^2.0.0-0",
35+
"@vue/test-utils": "^2.0.0-beta.14",
3636
"babel-eslint": "^10.1.0",
3737
"eslint": "^6.7.2",
3838
"eslint-plugin-import": "^2.20.2",
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { shallowMount } from '@vue/test-utils'
2+
import HeaderLogged from '.'
3+
import { routes } from '../../router'
4+
5+
import { createRouter, createWebHistory } from 'vue-router'
6+
7+
const router = createRouter({
8+
history: createWebHistory('/'),
9+
routes
10+
})
11+
12+
const mockStore = { currentUser: {} }
13+
jest.mock('../../hooks/useStore', () => {
14+
return () => {
15+
return mockStore
16+
}
17+
})
18+
19+
describe('<HeaderLogged />', () => {
20+
it('should render header logged correctly', async () => {
21+
router.push('/')
22+
await router.isReady()
23+
const wrapper = shallowMount(HeaderLogged, {
24+
global: {
25+
plugins: [router]
26+
}
27+
})
28+
29+
expect(wrapper.html()).toMatchSnapshot()
30+
})
31+
32+
it('should render 3 dots when there\'s not user logged', async () => {
33+
router.push('/')
34+
await router.isReady()
35+
const wrapper = shallowMount(HeaderLogged, {
36+
global: {
37+
plugins: [router]
38+
}
39+
})
40+
41+
const buttonLogout = wrapper.find('#logout-button')
42+
expect(buttonLogout.text()).toBe('...')
43+
})
44+
45+
it('should render user anem when there\'s user logged', async () => {
46+
router.push('/')
47+
await router.isReady()
48+
mockStore.currentUser.name = 'Igor'
49+
const wrapper = shallowMount(HeaderLogged, {
50+
global: {
51+
plugins: [router]
52+
}
53+
})
54+
55+
const buttonLogout = wrapper.find('#logout-button')
56+
expect(buttonLogout.text()).toBe('Igor (sair)')
57+
})
58+
})
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`<HeaderLogged /> should render header logged correctly 1`] = `
4+
<div class="flex items-center justify-between w-4/5 max-w-6xl py-10">
5+
<div class="w-28 lg:w-36"><img class="w-full" alt="logo"></div>
6+
<div class="flex">
7+
<ul class="flex list-none">
8+
<li class="px-6 py-2 mr-2 font-bold text-white rounded-full cursor-pointer focus:outline-none"> Credenciais </li>
9+
<li class="px-6 py-2 mr-2 font-bold text-white rounded-full cursor-pointer focus:outline-none"> Feedbacks </li>
10+
<li id="logout-button" class="px-6 py-2 font-bold bg-white rounded-full cursor-pointer text-brand-main focus:outline-none">...</li>
11+
</ul>
12+
</div>
13+
</div>
14+
`;

dashboard/src/components/HeaderLogged/index.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
Feedbacks
2020
</li>
2121
<li
22+
id="logout-button"
2223
@click="handleLogout"
2324
class="px-6 py-2 font-bold bg-white rounded-full cursor-pointer text-brand-main focus:outline-none"
2425
>

dashboard/src/components/ModalCreateAccount/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="flex justify-between">
2+
<div class="flex justify-between" id="modal-create-account">
33
<h1 class="text-4xl font-black text-gray-800">
44
Crie uma conta
55
</h1>

0 commit comments

Comments
 (0)