Skip to content

Tests #26

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

Merged
merged 94 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
d55d9fa
remove empty block
webdevnerdstuff Nov 9, 2024
fca1df5
Adding cypress tests
webdevnerdstuff Nov 9, 2024
af26e04
adding and testing test stuff
webdevnerdstuff Nov 10, 2024
e6419b9
fix merging
webdevnerdstuff Nov 11, 2024
ff60895
adding cypress and testing
webdevnerdstuff Nov 11, 2024
ce120ac
remove logs
webdevnerdstuff Nov 11, 2024
2365685
adding in data-cy and fixing validation issue with checkbox/radio/switch
webdevnerdstuff Nov 12, 2024
4f42350
update ignore
webdevnerdstuff Nov 12, 2024
8f23dd8
added getDataCy command
webdevnerdstuff Nov 12, 2024
49774bd
* adjust sumaryColumns to work with global config
webdevnerdstuff Nov 12, 2024
30b0929
change isReview to isSummary
webdevnerdstuff Nov 12, 2024
a70c70e
change isReview to isSummary
webdevnerdstuff Nov 12, 2024
8899359
change default theme to dark
webdevnerdstuff Nov 12, 2024
d4f35f2
change isReview to isSummary
webdevnerdstuff Nov 12, 2024
1479814
change dataCy to getDataCy
webdevnerdstuff Nov 12, 2024
22562d5
adjust sumaryColumns to work with global config
webdevnerdstuff Nov 12, 2024
032aae2
adding a bunch of tests and stuff
webdevnerdstuff Nov 12, 2024
823034c
add inheritattrs false
webdevnerdstuff Nov 12, 2024
b4bda14
writing more tests
webdevnerdstuff Nov 13, 2024
946f4f0
add cypress alias
webdevnerdstuff Nov 14, 2024
53918e0
add min/max height
webdevnerdstuff Nov 14, 2024
e0bdfa5
adding more tests for buttons field
webdevnerdstuff Nov 14, 2024
8cf421b
add cypress spec
webdevnerdstuff Nov 16, 2024
4dfcc9d
adding and roganizing tests
webdevnerdstuff Nov 16, 2024
70f92d0
added file
webdevnerdstuff Nov 16, 2024
33b3003
update config
webdevnerdstuff Nov 16, 2024
9a35e9c
add commands
webdevnerdstuff Nov 16, 2024
77ddc7a
adding and updating configs
webdevnerdstuff Nov 16, 2024
0aa94f1
updating and adding scripts
webdevnerdstuff Nov 16, 2024
2352e12
cleanup
webdevnerdstuff Nov 16, 2024
039237e
update config
webdevnerdstuff Nov 16, 2024
a8b6ed4
adding more data
webdevnerdstuff Nov 16, 2024
2ec1aa9
stuff
webdevnerdstuff Nov 16, 2024
b846861
types
webdevnerdstuff Nov 16, 2024
876097a
updating stuff
webdevnerdstuff Nov 16, 2024
8fd174e
update
webdevnerdstuff Nov 16, 2024
3069c56
type
webdevnerdstuff Nov 16, 2024
1a023cb
trying to shut up error
webdevnerdstuff Nov 16, 2024
9289d16
adding this but not sure it's doing anything or needed
webdevnerdstuff Nov 16, 2024
7b71b1c
add actions
webdevnerdstuff Nov 18, 2024
e55d92f
actions test
webdevnerdstuff Nov 18, 2024
08fec57
test`
webdevnerdstuff Nov 18, 2024
e8ab04c
test
webdevnerdstuff Nov 18, 2024
eed69ac
change npm
webdevnerdstuff Nov 18, 2024
4ff623e
test
webdevnerdstuff Nov 18, 2024
19e095c
test
webdevnerdstuff Nov 18, 2024
572a08d
add temp files and cypress
webdevnerdstuff Nov 18, 2024
9945994
update
webdevnerdstuff Nov 18, 2024
d641d33
empty line
webdevnerdstuff Nov 18, 2024
061737a
removed unused package
webdevnerdstuff Nov 18, 2024
e13eed7
update packages
webdevnerdstuff Nov 18, 2024
04915dc
adjust config
webdevnerdstuff Nov 18, 2024
af18475
removing package
webdevnerdstuff Nov 18, 2024
d33d071
build
webdevnerdstuff Nov 18, 2024
98dd0b8
revert changes
webdevnerdstuff Nov 18, 2024
0e8a93a
fix rootdir
webdevnerdstuff Nov 18, 2024
9d416d4
fixing build stuff and tsconfig stuff... hopefully
webdevnerdstuff Nov 19, 2024
7a7a452
removed extends
webdevnerdstuff Nov 19, 2024
4cf0cb4
test
webdevnerdstuff Nov 19, 2024
e3a7ea9
test
webdevnerdstuff Nov 19, 2024
32e9ad4
test
webdevnerdstuff Nov 19, 2024
55b9e56
test
webdevnerdstuff Nov 19, 2024
ccdc209
test
webdevnerdstuff Nov 19, 2024
d801c23
test
webdevnerdstuff Nov 19, 2024
c1aa23c
test
webdevnerdstuff Nov 19, 2024
87d8f35
Merge branch 'tests-configs' into tests
webdevnerdstuff Nov 19, 2024
8346294
adding converted test
webdevnerdstuff Nov 19, 2024
dd9c413
updating tests
webdevnerdstuff Nov 19, 2024
78418e4
adding more tests
webdevnerdstuff Nov 19, 2024
85b65e6
add cypress-real-events
webdevnerdstuff Nov 20, 2024
5f7bdf5
add data-cy to hidden input
webdevnerdstuff Nov 20, 2024
aa355ba
add check for date field to change input type to text
webdevnerdstuff Nov 20, 2024
e423745
add more tests
webdevnerdstuff Nov 20, 2024
317ac8e
add alias
webdevnerdstuff Nov 22, 2024
89fb1f7
updating types
webdevnerdstuff Nov 22, 2024
f808fcf
adding commands for nav examples
webdevnerdstuff Nov 22, 2024
3e88ca6
add nav data
webdevnerdstuff Nov 22, 2024
3739056
add jumpahead
webdevnerdstuff Nov 22, 2024
8189fcd
working on navigation stuff
webdevnerdstuff Nov 22, 2024
962e66d
add helper
webdevnerdstuff Nov 22, 2024
b7e7f4a
add jumpahead
webdevnerdstuff Nov 22, 2024
6e57721
adding navigation tests
webdevnerdstuff Nov 22, 2024
aa43ccd
cleanup
webdevnerdstuff Nov 22, 2024
c8f9aa9
change tests kept in memory to reduce memory crashing issues
webdevnerdstuff Nov 22, 2024
ea12a79
optimizing a little bit
webdevnerdstuff Nov 22, 2024
82d74cf
changed back title used for testing
webdevnerdstuff Nov 22, 2024
eadd8f4
moving some logic to composable
webdevnerdstuff Nov 22, 2024
8de27ce
stuff
webdevnerdstuff Nov 22, 2024
f479fcd
remove config
webdevnerdstuff Nov 23, 2024
5f46aa4
reworking form so the validation works with the header items navigation
webdevnerdstuff Nov 23, 2024
6d7a301
fixing buttons field after updates to useform
webdevnerdstuff Nov 25, 2024
633329f
updating fields to use useField
webdevnerdstuff Nov 25, 2024
af7d25e
updating slot component and adding tests
webdevnerdstuff Nov 26, 2024
d2f7147
testing action
webdevnerdstuff Nov 26, 2024
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
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2
indent_style = space

[*.{js,ts,mts,vue}]
indent_size = 2
Expand Down
58 changes: 58 additions & 0 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Cypress Tests with Dependency and Artifact Caching

on:
push:
pull_request:

jobs:
install:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Install dependencies
run: pnpm install

- name: Build application
run: pnpm build

- name: Save build folder
uses: actions/upload-artifact@v4
with:
name: build
if-no-files-found: error
path: ./dist

cypress-run:
runs-on: ubuntu-22.04
needs: install
steps:
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Checkout
uses: actions/checkout@v4

- name: Download the build folder
uses: actions/download-artifact@v4
with:
name: build
path: ./dist

- name: Install dependencies
run: pnpm install

- name: Cypress run
uses: cypress-io/github-action@v6
with:
start: pnpm cy:run
component: true
browser: chrome
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,11 @@ dist-ssr

src/plugin/**/*.bk.*

# Temp files and directories
*__TEMP.*
*__TEMP/

# Cypress
cypress/downloads
cypress/screenshots
cypress/videos
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh

npx lint-staged && npm run test:build
# npx lint-staged && npm run test:build
npx lint-staged
3 changes: 0 additions & 3 deletions .husky/prepare-commit-msg

This file was deleted.

26 changes: 26 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { defineConfig } from 'cypress';
import customViteConfig from './vite.cypress.config';

export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
config.env = {
...process.env,
...config.env,
};
return config;
},
specPattern: './src/**/*.spec.cy.{js,jsx,ts,tsx}',
},

component: {
devServer: {
bundler: 'vite',
framework: 'vue',
viteConfig: customViteConfig,
},
specPattern: './src/**/*.cy.{js,jsx,ts,tsx}',
viewportHeight: 800,
viewportWidth: 1920,
},
});
5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
7 changes: 7 additions & 0 deletions cypress/plugins/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const path = require('path');
const { startDevServer } = require('@cypress/vite-dev-server');

module.exports = (on, config) => {
config.env.tsconfigPath = path.resolve(__dirname, '../../tsconfig.cypress.json'); // Adjust the path as needed
return config;
};
37 changes: 37 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
12 changes: 12 additions & 0 deletions cypress/support/component-index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Components App</title>
</head>
<body>
<div data-cy-root></div>
</body>
</html>
184 changes: 184 additions & 0 deletions cypress/support/component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
import './commands';
import AppTemplate from '../templates/App.vue';
import vuetify from "../../src/plugins/vuetify";
import { h } from "vue";
import { mount } from 'cypress/vue';
import VStepperForm from '../../src/plugin/VStepperForm.vue';
import * as DATA from '../templates/testData';
import type { Component } from 'vue';
import "cypress-real-events";


// declare global {
// namespace Cypress {
// interface Chainable {
// baseIconClass(icon: string): string;
// getBaseStepperElements(excluded: string[]): Chainable;
// getDataCy(value: string): Chainable<JQuery<HTMLElement>>;
// mount: typeof mount;
// mountComponent(options: any): Chainable;
// }
// }
// }

Cypress.Commands.add('mount', (component: Component, options: any = {}) => {
// Ensure global settings are defined
options.global = options.global || {};
options.global.stubs = options.global.stubs || {};
options.global.stubs['transition'] = false;
options.global.components = options.global.components || {};
options.global.plugins = options.global.plugins || [vuetify];

// Process slots to ensure they are functions
const slots = options.slots
? Object.fromEntries(
Object.entries(options.slots).map(([key, value]) => [
key,
// Convert strings or other non-function values into functions
typeof value === 'function'
? value
: () => (typeof value === 'string' ? h('div', value) : h(value as any)),
])
)
: {};

// Mount AppTemplate as the root and render `component` inside it
return mount(AppTemplate, {
...options,
slots: {
// Render the main component in the default slot of AppTemplate
default: () => h(component, options.props, slots),
},
}) as Cypress.Chainable;
});


Cypress.Commands.add('getDataCy', (name: string) => {
return cy.get(`[data-cy="${name}"]`);
});

const answers = {
buttonField: null,
};

const buttonField = DATA.buttonFieldOptions;

const fieldDefault = {
label: 'Button Field Question',
name: 'buttonField',
options: buttonField.options.basic,
type: 'buttons' as const,
};

const globalOptions = {
validateOn: 'blur',
};

interface MountComponentOptions {
modelValue?: Record<string, any>;
field?: Partial<typeof fieldDefault>;
globalProps?: Record<string, any>;
stepperProps?: Record<string, any>;
}

Cypress.Commands.add('mountComponent', (options: MountComponentOptions = {}) => {
const { modelValue = {}, field = {}, globalProps = {}, stepperProps = {} } = options;

const localModelValue = { ...answers, ...modelValue };

return cy.then(() => {
cy.mount(VStepperForm as any, {
props: {
modelValue: localModelValue,
pages: [{ fields: [{ ...fieldDefault, ...field, }], }],
onSubmit: stepperProps.onSubmit ?? undefined,
validationSchema: stepperProps.validationSchema ?? undefined,
...stepperProps,
},
global: { provide: { globalOptions: { ...globalOptions, ...globalProps }, }, },
}).as('wrapper');
});
});


Cypress.Commands.add('getBaseStepperElements', (excluded = []) => {
// Stepper Form //
cy.get('[data-cy="vsf-stepper-form"]').as('stepperForm');
cy.get('@stepperForm')
.should('exist')
.and('be.visible');

// Stepper Header //
cy.getDataCy('vsf-stepper-header').as('stepperHeader');
cy.get('@stepperHeader')
.should('exist')
.and('be.visible');

cy.get('@stepperHeader')
.find('.v-stepper-item')
.as('stepperHeaderItems');

// Application Wrap //
cy.get('.v-application__wrap').as('appWrap');

// Submit Button //
if (!excluded.includes('buttonsField')) {
cy.getDataCy('vsf-submit-button')
.should('exist')
.and('be.visible');

// Field Group and Buttons //
cy.getDataCy('vsf-field-group-buttonField').as('fieldGroup');
cy.getDataCy('vsf-field-group-buttonField').find('button').as('fieldButtons');
}
});

cy.baseIconClass = (icon: string) => {
return icon.replace(/^mdi:/, '');
};



// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Navigation //
Cypress.Commands.add('navigationMountComponent', (options = {}) => {
const { editable = true, jumpAhead = true, pages, validationSchema = undefined } = options || {};
const answers = DATA.navigationTest.answers;

cy.mount(VStepperForm as any, {
props: {
answers,
editable,
jumpAhead,
modelValue: answers,
pages,
validationSchema,
},
global: DATA.navigationTest.global,
});
});

Cypress.Commands.add('navigationGetButtons', () => {
cy.getBaseStepperElements(['buttonsField']);
cy.getDataCy('vsf-next-button').as('nextButton');
cy.getDataCy('vsf-previous-button').as('previousButton');
});

Cypress.Commands.add('checkedEnabledDisabledHeaderItems', ({ enabled, disabled, pages }) => {
pages.forEach((_, index) => {
if (enabled.includes(index)) {
cy.get('@stepperHeaderItems')
.eq(index)
.should('be.enabled');
}

if (disabled.includes(index)) {
cy.get('@stepperHeaderItems')
.eq(index)
.should('be.disabled');
}
});
});

cy.cloneArray = (array: any[]): any[] => {
return JSON.parse(JSON.stringify(array));
};
20 changes: 20 additions & 0 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/e2e.ts is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************

// Import commands.js using ES2015 syntax:
import './commands'

// Alternatively you can use CommonJS syntax:
// require('./commands')
Loading