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

Automating tests on opened PRs #13432

Merged
merged 18 commits into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
65 changes: 65 additions & 0 deletions .github/workflows/tests-on-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: UI Tests

on:
pull_request:
types: [opened, edited, synchronize ]
branches:
- 'dev'
paths:
- 'ui/**'

jobs:
tests:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
browser: [chrome, firefox]

name: Tests on ${{ matrix.browser }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 14

- name: Install dependencies
run: cd ./ui && npm i

- name: Run tests in ${{ matrix.browser }} browser
uses: cypress-io/github-action@v2
with:
browser: ${{ matrix.browser }}
command: npm run test:component:ci
working-directory: ui
tag: ${{ github.event_name }} # Tag will be either "push" or "pull_request"
group: Tests in ${{ matrix.browser }} browser
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} # Dashboard record key as an environment variable
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # To allow accurately detecting a build vs a re-run build
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }} # Either PR title or default information

- name: Add workflow summary
env:
SUMMARY: |
Hi @${{ github.event.pull_request.user.login }} and thanks for the contribution! 👏

We've detected file changes inside the `ui` folder, so that triggered our Cypress component tests.
run: echo "$SUMMARY" >> $GITHUB_STEP_SUMMARY
if: always()

- name: Output failure message
env:
FAILURE: ":bangbang: Seems like some of the tests are failing. Please amend 'em for someone from the team to be able to review it."
run: echo "$FAILURE" >> $GITHUB_STEP_SUMMARY
if: failure() || cancelled()

- name: Output success message
env:
SUCCESS: ":white_check_mark: Seems like all the tests passed successfully, so your PR is ready to be reviewed!"
run: echo "$SUCCESS" >> $GITHUB_STEP_SUMMARY
if: success()
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ Hi! We are really excited that you are interested in contributing to Quasar 👏
- If you are resolving a special issue, add `(fix: #xxxx[,#xxx])` (#xxxx is the issue id) in your PR title for a better release log, e.g. `fix: update entities encoding/decoding (fix #3899)`.
- Provide detailed description of the bug in the PR. A live demo is preferred.

- Cypress e2e tests will run every time there is a code change in any file of the `ui` folder.

## Development Setup

You will need [Node.js](http://nodejs.org) **version 12.22.1+** along [Yarn](https://yarnpkg.com/) or [NPM](https://docs.npmjs.com/getting-started/installing-node). Read `package.json` and take notice of the scripts you can use.
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<a href="https://forum.quasar.dev" target="_blank"><img src="https://img.shields.io/badge/community-forum-brightgreen.svg"></a>
[![https://good-labs.github.io/greater-good-affirmation/assets/images/badge.svg](https://good-labs.github.io/greater-good-affirmation/assets/images/badge.svg)](https://good-labs.github.io/greater-good-affirmation)

[![UI Tests](https://github.com/quasarframework/quasar/actions/workflows/tests-on-pr.yml/badge.svg?branch=dev)](https://github.com/quasarframework/quasar/actions/workflows/tests-on-pr.yml)

Please submit a PR to https://github.com/quasarframework/quasar-awesome with your website/app/Quasar tutorial/video etc. Thank you!

## Supporting Quasar
Expand Down
1 change: 1 addition & 0 deletions ui/dev/cypress.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"projectId": "5zr217",
"fixturesFolder": "../test/cypress/fixtures",
"screenshotsFolder": "../test/cypress/screenshots",
"pluginsFile": "../test/cypress/plugins/index.js",
Expand Down
2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"lint": "eslint --ext .js,.vue src dev",
"lint-fix": "eslint --ext .js,.vue src dev --fix",
"test:component": "cd ./dev && cypress open-ct && cd ..",
"test:component:ci": "cd ./dev && cypress run-ct && cd ..",
"test:component:ci": "cd ./dev && cypress run-ct --record --parallel && cd ..",
"test:create": "node ./test/cypress/helpers/create-spec.js -c"
},
"repository": {
Expand Down
46 changes: 23 additions & 23 deletions ui/src/components/menu/__tests__/QMenu.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('Menu API', () => {
describe('(prop): touch-position', () => {
it('should show menu at the position of the click', () => {
mount(WrapperOne, {
attrs: {
props: {
'touch-position': true
}
})
Expand Down Expand Up @@ -71,7 +71,7 @@ describe('Menu API', () => {

it('should not close the menu when clicking outside the menu when persistent', () => {
mount(WrapperOne, {
attrs: {
props: {
persistent: true
}
})
Expand All @@ -89,7 +89,7 @@ describe('Menu API', () => {

it('should not close the menu when hitting the escape key when persistent', () => {
mount(WrapperOne, {
attrs: {
props: {
persistent: true
}
})
Expand Down Expand Up @@ -129,7 +129,7 @@ describe('Menu API', () => {

it('should close the menu when clicking a menu child without v-close-popup when auto-close is true', () => {
mount(WrapperOne, {
attrs: {
props: {
'auto-close': true
}
})
Expand Down Expand Up @@ -174,7 +174,7 @@ describe('Menu API', () => {

it('should not switch focus back to parent element when closing if no-refocus is true', () => {
mount(WrapperOne, {
attrs: {
props: {
'no-refocus': true
}
})
Expand Down Expand Up @@ -208,7 +208,7 @@ describe('Menu API', () => {

it('should no switch focus to the menu when opening with no-focus is true', () => {
mount(WrapperOne, {
attrs: {
props: {
'no-focus': true
}
})
Expand All @@ -226,7 +226,7 @@ describe('Menu API', () => {
describe('(prop): fit', () => {
it('should show a menu that matches the full with of the target when fit is supplied', () => {
mount(WrapperOne, {
attrs: {
props: {
target: '.other-target',
fit: true
}
Expand All @@ -245,7 +245,7 @@ describe('Menu API', () => {

it('should show a menu that not matches the full with of the target when fit is false', () => {
mount(WrapperOne, {
attrs: {
props: {
target: '.other-target',
fit: false
}
Expand All @@ -266,7 +266,7 @@ describe('Menu API', () => {
describe('(prop): cover', () => {
it('should show a menu that overlays the target when using cover', () => {
mount(WrapperOne, {
attrs: {
props: {
cover: true
}
})
Expand All @@ -279,7 +279,7 @@ describe('Menu API', () => {

it('should show a menu that overlays the target when using cover', () => {
mount(WrapperOne, {
attrs: {
props: {
cover: true,
target: '.other-target'
}
Expand All @@ -293,7 +293,7 @@ describe('Menu API', () => {

it('should ignore self property when using cover', () => {
mount(WrapperOne, {
attrs: {
props: {
cover: true,
self: 'center right',
target: '.other-target'
Expand Down Expand Up @@ -328,7 +328,7 @@ describe('Menu API', () => {
horizontalSelf.forEach((hS) => {
it(`should position Anchor(${ vA } ${ hA }) & Self(${ vS } ${ hS }) correctly`, () => {
mount(WrapperOne, {
attrs: {
props: {
anchor: `${ vA } ${ hA }`,
self: `${ vS } ${ hS }`
}
Expand Down Expand Up @@ -357,7 +357,7 @@ describe('Menu API', () => {
verticalSelf.forEach((vS) => {
it(`should offset vertical position Anchor(${ vA } left) & Self(${ vS } left) correctly`, () => {
mount(WrapperOne, {
attrs: {
props: {
anchor: `${ vA } left`,
self: `${ vS } left`,
offset: [ 0, 20 ]
Expand All @@ -378,7 +378,7 @@ describe('Menu API', () => {
horizontalSelf.forEach((hS) => {
it(`should offset horizontal position Anchor(top ${ hA }) & Self(top ${ hS }) correctly`, () => {
mount(WrapperOne, {
attrs: {
props: {
anchor: `top ${ hA }`,
self: `top ${ hS }`,
offset: [ 20, 0 ]
Expand All @@ -399,7 +399,7 @@ describe('Menu API', () => {
describe('(prop): dark', () => {
it('should set the --q-dark color as background and white text color', () => {
mount(WrapperOne, {
attrs: {
props: {
dark: true
}
})
Expand All @@ -414,7 +414,7 @@ describe('Menu API', () => {
describe('(prop): square', () => {
it('should not have border-radius when using this prop', () => {
mount(WrapperOne, {
attrs: {
props: {
square: true
}
})
Expand All @@ -429,7 +429,7 @@ describe('Menu API', () => {
it('should specify a max-height when setting this prop', () => {
const maxHeight = '30px'
mount(WrapperOne, {
attrs: {
props: {
maxHeight
}
})
Expand All @@ -444,7 +444,7 @@ describe('Menu API', () => {
it('should specify a max-width when setting this prop', () => {
const maxWidth = '30px'
mount(WrapperOne, {
attrs: {
props: {
maxWidth
}
})
Expand All @@ -470,7 +470,7 @@ describe('Menu API', () => {
it('should emit @escape-key event when escape key is pressed', () => {
const fn = cy.stub()
mount(WrapperOne, {
attrs: {
props: {
onEscapeKey: fn
}
})
Expand All @@ -493,7 +493,7 @@ describe('Menu API', () => {
it('should not emit @escape-key event when menu is persistent', () => {
const fn = cy.stub()
mount(WrapperOne, {
attrs: {
props: {
onEscapeKey: fn,
persistent: true
}
Expand All @@ -520,7 +520,7 @@ describe('Menu API', () => {
describe('(method): updatePosition', () => {
it('should reposition the menu when it is no longer in correct position', () => {
mount(WrapperTwo, {
attrs: {
props: {
anchor: 'bottom left',
self: 'bottom left'
}
Expand Down Expand Up @@ -564,7 +564,7 @@ describe('Menu API', () => {
describe('(method): focus', () => {
it('should focus the menu', () => {
mount(WrapperOne, {
attrs: {
props: {
'no-focus': true
}
})
Expand All @@ -586,7 +586,7 @@ describe('Menu API', () => {

it('should focus the autofocus element inside the menu', () => {
mount(WrapperTwo, {
attrs: {
props: {
'no-focus': true
}
})
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/select/QSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default createComponent({

emits: [
...useFieldEmits,
'add', 'remove', 'input-value',
'add', 'remove', 'input-value', 'new-value',
'keyup', 'keypress', 'keydown',
'filter-abort'
],
Expand Down
Loading