Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix e2e tests, show tab title if customized by user
Browse files Browse the repository at this point in the history
kinow committed Jan 14, 2024
1 parent 63372d0 commit bee914a
Showing 12 changed files with 8,510 additions and 5,175 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ jobs:
uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 14
node-version: 20
- name: Cache node modules
uses: actions/cache@v3
with:
@@ -57,7 +57,7 @@ jobs:
run: yarn install
- name: e2e
run: |
yarn run test:e2e --headless --mode development
VITE_COVERAGE=1 yarn run test:e2e --headless
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
Binary file added .yarn/install-state.gz
Binary file not shown.
893 changes: 893 additions & 0 deletions .yarn/releases/yarn-4.0.2.cjs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.0.2.cjs
19 changes: 15 additions & 4 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
const { defineConfig } = require('cypress')
const {defineConfig} = require('cypress')
const vitePreprocessor = require('cypress-vite')
const path = require('path')

module.exports = defineConfig({
fixturesFolder: 'tests/e2e/fixtures',
screenshotsFolder: 'tests/e2e/screenshots',
videosFolder: 'tests/e2e/videos',
video: false,
env: {
codeCoverage: {
exclude: 'cypress/**/*.*',
}
},
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
baseUrl: 'http://localhost:8080',
setupNodeEvents(on, config) {
return require('./tests/e2e/plugins/index.js')(on, config)
on('file:preprocessor', vitePreprocessor({
configFile: path.resolve(__dirname, './vite.config.js'),
mode: 'development',
}))
require('@cypress/code-coverage/task')(on, config)
return config
},
specPattern: 'tests/e2e/specs/**/*.cy.{js,jsx,ts,tsx}',
supportFile: 'tests/e2e/support/index.js',
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
"description": "A Vue component that integrates with Lumino",
"author": "Bruno P. Kinoshita <brunodepaulak@yahoo.com.br> (https://twitter.com/kinow)",
"version": "1.2.0-SNAPSHOT",
"private": false,
"license": "Apache-2.0",
"homepage": "https://github.com/tupilabs/vue-lumino/",
"main": "./dist/vue-lumino.common.js",
@@ -23,7 +22,7 @@
"build": "vite build",
"lint": "eslint --ext .js,.vue --ignore-path .gitignore --fix src",
"test:unit": "vitest run ./tests/unit",
"test:e2e": "cypress run $@",
"test:e2e": "concurrently --names 'SERVER,CLIENT' --prefix-colors 'yellow,blue' --success 'first' --kill-others 'yarn run dev' 'yarn wait-on http://localhost:8080/index.html && cypress run --e2e $@'",
"coverage:unit": "vitest run --coverage"
},
"dependencies": {
@@ -33,14 +32,15 @@
"vue": "^3.3.6"
},
"devDependencies": {
"@cypress/code-coverage": "^3.12.4",
"@cypress/code-coverage": "^3.12.18",
"@cypress/vue": "^6.0.0",
"@vitejs/plugin-vue": "^4.4.0",
"@vitest/coverage-v8": "^1.0.2",
"@vitest/coverage-istanbul": "^1.2.0",
"@vitest/coverage-v8": "^1.0.2",
"@vue/compiler-sfc": "^3.3.6",
"@vue/eslint-config-standard": "^8.0.1",
"@vue/test-utils": "^2.4.1",
"concurrently": "^8.2.2",
"cypress": "^13.3.2",
"cypress-vite": "^1.4.2",
"eslint": "^7.12.0",
@@ -55,13 +55,15 @@
"sinon": "^17.0.0",
"vite": "^4.5.1",
"vite-plugin-istanbul": "^5.0.0",
"vitest": "^1.2.0"
"vitest": "^1.2.0",
"wait-on": "^7.0.1"
},
"keywords": [
"component",
"lumino",
"tabs",
"widgets",
"vue"
]
],
"packageManager": "yarn@4.0.2"
}
5 changes: 5 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -54,11 +54,13 @@ NOTE: Used for example/documentation only. Not intended to be used by users of t
v-for="id of helloWorldWidgets"
:id="id"
:key="id"
:ref="id"
/>
<ColoredCircle
v-for="id of coloredCircleWidgets"
:id="id"
:key="id"
:ref="id"
:color="'red'"
:tab-title="`${id}`"
/>
@@ -95,6 +97,9 @@ export default {
return {
// the widgets added to the view
/**
* This dictionary holds the component ID as key,
* and the component type as value (string).
*
* @type {
* Object.<string, string>
* }
9 changes: 6 additions & 3 deletions src/components/Lumino.vue
Original file line number Diff line number Diff line change
@@ -139,9 +139,12 @@ export default {
if (newVal instanceof Array) {
for (const id of newVal) {
if (oldVal !== undefined && !(oldVal.includes(id))) {
// TODO: const tabTitleProp = this.$props.tabTitleProp
// const name = newChild.$attrs[tabTitleProp] ? newChild.$attrs[tabTitleProp] : newChild.$options.name
this.addWidget(id, id)
this.$nextTick(() => {
const tabTitleProp = this.$props.tabTitleProp
const component = Array.isArray(this.$parent.$refs[id]) ? this.$parent.$refs[id][0] : this.$parent.$refs[id]
const name = component.$attrs[tabTitleProp] ? component.$attrs[tabTitleProp] : component.$options.name
this.addWidget(id, name)
})
}
}
this.$nextTick(() => {
28 changes: 0 additions & 28 deletions tests/e2e/plugins/index.js

This file was deleted.

4 changes: 2 additions & 2 deletions tests/e2e/specs/lumino.cy.js
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ describe('Lumino component', () => {
.should('be.visible')
// SVG element is used only in the ColoredCircle component
cy.get('svg')
.should('not.be.visible')
.should('not.exist')
cy
.get('#add-colored-circle-widget-button')
.click()
@@ -78,7 +78,7 @@ describe('Lumino component', () => {
.should('be.visible')
// SVG element is used only in the ColoredCircle component
cy.get('svg')
.should('not.be.visible')
.should('not.exist')

cy
.get('#add-colored-circle-widget-button')
5 changes: 3 additions & 2 deletions vite.config.js
Original file line number Diff line number Diff line change
@@ -33,8 +33,9 @@ export default defineConfig({
"coverage",
],
extension: [".js", ".jsx", ".ts", ".vue"],
requireEnv: true,
cypress: true
requireEnv: false,
cypress: true,
forceBuildInstrument: true
}),
],
resolve: {
12,701 changes: 7,573 additions & 5,128 deletions yarn.lock

Large diffs are not rendered by default.

0 comments on commit bee914a

Please sign in to comment.