Skip to content
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

tests(ui): add unit testing boilerplate and first tests #12047

Merged
merged 58 commits into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from 56 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
3826777
feat(unit): first attempt at setting up cct unit testing
Evertvdw Oct 21, 2021
ba2970b
Add image snapshot plugin
Evertvdw Oct 24, 2021
ba337c4
Move test/cypress folder to root of `ui`
Evertvdw Oct 24, 2021
19c0534
Update test syntax and eslint fix
Evertvdw Oct 24, 2021
7fd483b
chore(testing): Add tests for QAvatar
Evertvdw Oct 31, 2021
0eb31ea
fix(linting): make eslint validate and autofix js in .vue files
Evertvdw Oct 31, 2021
829d646
feat(testing): autocomplete custom commands in spec files
Evertvdw Oct 31, 2021
4620420
chore(testing): add first test of QMenu
Evertvdw Oct 31, 2021
511eae4
(chore): remove this eslint file as it is not used
Evertvdw Nov 6, 2021
a226097
(chore): add expect to globals so eslint does not complain
Evertvdw Nov 6, 2021
172fb7e
(testing): add tests for behavior of QMenu
Evertvdw Nov 6, 2021
320ea30
(chore): Add readme
Evertvdw Nov 6, 2021
2b7e7ad
(chore): undo changes to babel.config.js
Evertvdw Nov 6, 2021
d385090
(chore): extends cypress eslint plugin
Evertvdw Nov 6, 2021
4694ecc
(chore): refactor to move tests into __tests__ folder
Evertvdw Nov 6, 2021
3f72cbf
(testing): add more tests for Menu positioning
Evertvdw Nov 7, 2021
07af846
(chore): add list of components prioritized
Evertvdw Nov 8, 2021
15c65b9
Update README.md
Evertvdw Nov 8, 2021
994000f
(testing): add tests for transition and style of QMenu
Evertvdw Nov 10, 2021
bc1de40
(testing): Add Event tests
mett-development Nov 12, 2021
1690082
(testing): Update command types
Evertvdw Nov 15, 2021
72cb89d
(testing): Add method testss for QMenu
Evertvdw Nov 15, 2021
89e13ff
(testing): QMenu tests finished
Evertvdw Nov 18, 2021
6bc91c4
(chore): update readme
Evertvdw Nov 18, 2021
8f15636
(testing): First tests for QSelect
Evertvdw Nov 18, 2021
66a7ea4
fix(testing): add commands file to include AE commands typings
Evertvdw Nov 29, 2021
f33d9af
chore(testing): use AE for unit tests, clean up obsolete code
Evertvdw Nov 29, 2021
12b9201
chore(testing): Images were oddly sized, regenerate them
Evertvdw Nov 29, 2021
63d949e
chore(testing): use Cypress.vueWrapper instead of .vue() command
Evertvdw Nov 29, 2021
c39ce9b
testing(feat): test first content properties of select API
Evertvdw Dec 8, 2021
8b64971
testing(fix): fix autocompletion within spec files
Evertvdw Dec 8, 2021
d135ced
feat(testing): create a helper function to setup test boilerplate
Evertvdw Dec 15, 2021
6778ea7
chore: create separate tests for composables
Evertvdw Dec 15, 2021
b4826ab
fix: remove console.log used for testing
Evertvdw Dec 22, 2021
db3f321
feat: add additional tests for QSelect
Evertvdw Dec 22, 2021
ca3d3cf
feat(testing): Add isNotActionable command
Evertvdw Dec 22, 2021
59d6835
feat(testing): finish tests for props section `Options` of API
Evertvdw Dec 22, 2021
e5afe35
feat(testing): add boilerplate for slots
Evertvdw Dec 22, 2021
ad09c81
chore(testing): update AE to use cypress 9.2, update image snapshots
Evertvdw Dec 23, 2021
c6e93f4
chore(testing): refactor QMenu, split composable props
Evertvdw Dec 27, 2021
284f21a
feat(testing): WIP QSelect selection props, add slots to wrapper
Evertvdw Dec 27, 2021
f01d50b
chore(testing): Remove unused imports
Evertvdw Dec 27, 2021
391aa1d
chore(testing): do not check for null #11754
Evertvdw Dec 27, 2021
b4da5e2
feat(testing): add eslint plugin to show .only as error
Evertvdw Dec 27, 2021
f1abd81
feat(testing): finish Selection and Style sections of QSelect
Evertvdw Dec 27, 2021
577f75b
feat(testing): slot tests for QSelect
Evertvdw Jan 2, 2022
9582720
feat(testing): add tests for the events of QSelect
Evertvdw Jan 2, 2022
68a4792
chore(testing): refactor QAvatar tests
Evertvdw Jan 10, 2022
ac5b0c2
chore(testing): refactor QBadge to use API scaffolded tests
Evertvdw Jan 10, 2022
c53d701
feat(testing): add tests for Methods QSelect
Evertvdw Jan 14, 2022
57de1b7
feat(testing): cover edge cases for create-spec
Evertvdw Jan 14, 2022
2a2a9fd
chore(testing): create boilerplate for all components on shortlist
Evertvdw Jan 14, 2022
e0702ed
review: import plugin using ES syntax
Evertvdw Jan 17, 2022
c8ce424
review: add documentation for create-spec helper
Evertvdw Jan 17, 2022
c262865
chore(ui/test): adapt to latest release
IlCallo Jan 26, 2022
a678b01
chore: use eslint VSCode extension as formatter
IlCallo Jan 26, 2022
3ac10a1
fix: revert VSCode settings to prevent format fighting
Evertvdw Jan 27, 2022
47d51eb
chore(testing): remove image-snapshots, not working with `run-ct`.
Evertvdw Jan 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"johnsoncodehk.volar"
],
}
14 changes: 11 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
{
"eslint.workingDirectories": [
"./docs",
"./ui"
"eslint.format.enable": true,
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.formatOnSave": true,
"eslint.workingDirectories": ["./docs", "./ui"],
"editor.tabSize": 2,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.validate": [
"javascript",
"vue",
]
}
15 changes: 12 additions & 3 deletions ui/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,26 @@ module.exports = {
sourceType: 'module'
},
env: {
browser: true
browser: true,
mocha: true
},
extends: [
// https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention
// consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules.
'plugin:vue/vue3-essential',
'plugin:cypress/recommended',
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
'standard'
],
// required to lint *.vue files
plugins: [
'vue'
'vue',
'no-only-tests'
],
globals: {
cordova: true,
cy: true,
expect: true,
__statics: true,
__QUASAR_VERSION__: true,
__QUASAR_SSR__: true,
Expand Down Expand Up @@ -76,6 +81,10 @@ module.exports = {
'vue/object-curly-spacing': 'off',
'vue/script-indent': 'off',
'vue/no-v-model-argument': 'off',
'vue/require-explicit-emits': 'off'
'vue/require-explicit-emits': 'off',

// Testing
'cypress/no-unnecessary-waiting': 'off',
'no-only-tests/no-only-tests': 'error'
}
}
1 change: 1 addition & 0 deletions ui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ cordova
debug.log
package-lock.json
.vscode
__diff_output__
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions ui/dev/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"fixturesFolder": "../test/cypress/fixtures",
"screenshotsFolder": "../test/cypress/screenshots",
"videosFolder": "../test/cypress/videos",
"component": {
"componentFolder": "../src",
"testFiles": "**/*.spec.js",
"pluginsFile": "../test/cypress/plugins/unit.js",
"supportFile": "../test/cypress/support/unit.js"
}
}
15 changes: 13 additions & 2 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
"build": "node build/script.build.js",
"test": "yarn lint && yarn build",
"lint": "eslint --ext .js,.vue src dev",
"lint-fix": "eslint --ext .js,.vue src dev --fix"
"lint-fix": "eslint --ext .js,.vue src dev --fix",
"test:unit": "cd ./dev && cypress open-ct && cd ..",
"test:unit:ci": "cd ./dev && cypress run-ct && cd ..",
"test:create": "node ./test/cypress/helpers/create-spec.js -c"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -64,15 +67,19 @@
"@babel/eslint-parser": "^7.13.14",
"@quasar/app": "^3.0.0",
"@quasar/extras": "^1.12.0",
"@quasar/quasar-app-extension-testing-e2e-cypress": "^4.0.1",
"@rollup/plugin-node-resolve": "^11.2.1",
"@rollup/plugin-replace": "^2.3.3",
"babel-preset-es2015-rollup": "^3.0.0",
"cli-highlight": "^2.1.11",
"cypress-image-snapshot": "^4.0.1",
"diff": "^5.0.0",
"eslint": "^7.4.0",
"eslint-config-standard": "^16.0.2",
"eslint-friendly-formatter": "^4.0.1",
"eslint-plugin-cypress": "^2.12.1",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-no-only-tests": "^2.6.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-vue": "^7.0.0",
Expand All @@ -81,13 +88,17 @@
"json-beautify": "^1.1.1",
"module-alias": "^2.2.2",
"prettier": "^2.4.1",
"quasar": "^2.1.9",
"recast": "^0.18.5",
"rimraf": "^3.0.1",
"rollup": "^2.34.0",
"rollup-plugin-typescript2": "^0.29.0",
"table": "^6.0.4",
"tslib": "^2.0.3",
"uglify-es": "^3.3.9"
"uglify-es": "^3.3.9",
"vue": "^3.0.0",
"vue-router": "^4.0.0",
"yargs": "^17.3.0"
},
"vetur": {
"tags": "dist/vetur/quasar-tags.json",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
133 changes: 133 additions & 0 deletions ui/src/components/avatar/__tests__/QAvatar.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import { mount } from '@cypress/vue'
import QAvatar from '../QAvatar'

const snapshotOptions = { customSnapshotsDir: '../src/components/avatar/__tests__' }

describe('Avatar API', () => {
describe('Props', () => {
describe('Category: content', () => {
describe('(prop): icon', () => {
it('should render an icon', () => {
const icon = 'bug_report'
mount(QAvatar, {
props: {
icon,
color: 'grey'
}
})

cy.get('.q-avatar')
.get('.q-icon')
.should('have.text', `${ icon }`)

// Waiting because it can be flaky with the import of the material-icons css file in support.js if done to early
cy.get('.q-avatar')
.wait(500)
.matchImageSnapshot(snapshotOptions)
})
})
})

describe('Category: style', () => {
describe('(prop): font-size', () => {
it('should set the font-size', () => {
const size = '40px'
// Doing em/rem units here does not work
// Cypress looks at actual computed values in the browser
const fontSize = '32px'
mount(QAvatar, {
props: {
size,
fontSize,
color: 'grey'
}
})

cy.get('.q-avatar')
.should('have.css', 'font-size', size)
// Match image snapshot cannot be chained directly before a .should
.matchImageSnapshot(snapshotOptions)
.get('.q-avatar__content')
.should('have.css', 'font-size', fontSize)
})
})

describe('(prop): color', () => {
it('should set a background color', () => {
const color = 'red'
mount(QAvatar, {
props: {
color
}
})

cy.get('.q-avatar')
.should('have.class', `bg-${ color }`)
.matchImageSnapshot(snapshotOptions)
})
})

describe('(prop): text-color', () => {
it('should set a text color', () => {
const textColor = 'red'
mount(QAvatar, {
props: {
textColor
}
})

cy.get('.q-avatar')
.should('have.class', `text-${ textColor }`)
.matchImageSnapshot(snapshotOptions)
})
})

describe('(prop): square', () => {
it('should create a square avatar', () => {
mount(QAvatar, {
props: {
square: true,
color: 'grey'
}
})

cy.get('.q-avatar')
.should('have.class', 'q-avatar--square')
.matchImageSnapshot(snapshotOptions)
})
})

describe('(prop): rounded', () => {
it('should create a rounded avatar', () => {
mount(QAvatar, {
props: {
rounded: true,
color: 'grey'
}
})

cy.get('.q-avatar')
.should('have.class', 'rounded-borders')
.matchImageSnapshot(snapshotOptions)
})
})
})
})

describe('Slots', () => {
describe('(slot): default', () => {
it('render the text in the default slot', () => {
const text = 'QQ'
mount(QAvatar, {
slots: {
// Using only a string here results in an error, this is a workaround
default: () => text
}
})

cy.get('.q-avatar')
.should('have.text', text)
})
})
})
})
74 changes: 74 additions & 0 deletions ui/src/components/badge/__tests__/QBadge.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// import { mount } from '@cypress/vue'
// import QBadge from '../QBadge'

// const snapshotOptions = { customSnapshotsDir: '../src/components/badge/__tests__' }

describe('Badge API', () => {
describe('Props', () => {
describe('Category: content', () => {
describe('(prop): floating', () => {
it.skip(' ', () => {
//
})
})

describe('(prop): multi-line', () => {
it.skip(' ', () => {
//
})
})

describe('(prop): label', () => {
it.skip(' ', () => {
//
})
})

describe('(prop): align', () => {
it.skip(' ', () => {
//
})
})
})

describe('Category: style', () => {
describe('(prop): color', () => {
it.skip(' ', () => {
//
})
})

describe('(prop): text-color', () => {
it.skip(' ', () => {
//
})
})

describe('(prop): transparent', () => {
it.skip(' ', () => {
//
})
})

describe('(prop): outline', () => {
it.skip(' ', () => {
//
})
})

describe('(prop): rounded', () => {
it.skip(' ', () => {
//
})
})
})
})

describe('Slots', () => {
describe('(slot): default', () => {
it.skip(' ', () => {
//
})
})
})
})
55 changes: 55 additions & 0 deletions ui/src/components/btn/__tests__/QBtn.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
describe('Btn API', () => {
describe('Props', () => {
describe('Category: behavior', () => {
describe('(prop): percentage', () => {
it.skip(' ', () => {
//
})
})

describe('(prop): dark-percentage', () => {
it.skip(' ', () => {
//
})
})
})

describe('Category: style', () => {
describe('(prop): round', () => {
it.skip(' ', () => {
//
})
})
})
})

describe('Slots', () => {
describe('(slot): default', () => {
it.skip(' ', () => {
//
})
})

describe('(slot): loading', () => {
it.skip(' ', () => {
//
})
})
})

describe('Events', () => {
describe('(event): click', () => {
it.skip(' ', () => {
//
})
})
})

describe('Methods', () => {
describe('(method): click', () => {
it.skip(' ', () => {
//
})
})
})
})
Loading