Skip to content

Commit a7481dc

Browse files
committed
Add cypress
1 parent 0f8b22a commit a7481dc

File tree

12 files changed

+34385
-32228
lines changed

12 files changed

+34385
-32228
lines changed

package-lock.json

Lines changed: 34235 additions & 32228 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
]
5555
},
5656
"devDependencies": {
57+
"@4tw/cypress-drag-drop": "^2.1.0",
5758
"@types/lodash": "^4.14.178",
5859
"@typescript-eslint/eslint-plugin": "^5.23.0",
5960
"@typescript-eslint/parser": "^5.23.0",

packages/editor-pro/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,7 @@ vendor
9494
!webpack.config.js
9595
!public
9696
!tsconfig.dev.json
97+
!cypress
98+
!cypress.config.ts
9799

98100
.DS_STORE

packages/editor-pro/.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ tsconfig.json
66
tsconfig.dev.json
77
webpack.config.js
88
webpack-stats.json
9+
cypress
10+
cypress.config.ts

packages/editor-pro/cypress.config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { defineConfig } from 'cypress';
2+
3+
export default defineConfig({
4+
component: {
5+
devServer: {
6+
framework: 'react',
7+
bundler: 'webpack',
8+
},
9+
},
10+
});
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React from 'react';
2+
3+
import { componentMapper } from '@data-driven-forms/mui-component-mapper';
4+
5+
import Editor from '../../src/editor';
6+
import propertiesFields from '../../src/editor/properties-fields';
7+
8+
import { AnyObject } from '../../src/types';
9+
10+
const componentInitialProps: AnyObject = {
11+
'dual-list-select': {
12+
options: []
13+
},
14+
'sub-form': {
15+
title: 'Sub form',
16+
fields: []
17+
},
18+
'field-array': {
19+
fields: []
20+
},
21+
wizard: {
22+
fields: [{ name: 'step-1', fields: [] }]
23+
},
24+
tabs: {
25+
fields: []
26+
}
27+
};
28+
29+
const fields = propertiesFields({ componentMapper });
30+
31+
describe('ProEditor', () => {
32+
it('can drag a new component', () => {
33+
cy.mount(<Editor fields={fields} componentMapper={componentMapper} componentInitialProps={componentInitialProps} />);
34+
cy.contains('text field').drag('.[style="display: flex; border: 1px dotted rgba(71, 77, 102, 0.5); min-height: 150px; background-color: rgb(249, 250, 252); padding: 4px; margin-left: 4px; flex-grow: 1; margin-right: 4px;"] > div');
35+
});
36+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "[email protected]",
4+
"body": "Fixtures are a great way to mock data for responses to routes"
5+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/// <reference types="cypress" />
2+
// ***********************************************
3+
// This example commands.ts shows you how to
4+
// create various custom commands and overwrite
5+
// existing commands.
6+
//
7+
// For more comprehensive examples of custom
8+
// commands please read more here:
9+
// https://on.cypress.io/custom-commands
10+
// ***********************************************
11+
//
12+
//
13+
// -- This is a parent command --
14+
// Cypress.Commands.add('login', (email, password) => { ... })
15+
//
16+
//
17+
// -- This is a child command --
18+
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
19+
//
20+
//
21+
// -- This is a dual command --
22+
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
23+
//
24+
//
25+
// -- This will overwrite an existing command --
26+
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
27+
//
28+
// declare global {
29+
// namespace Cypress {
30+
// interface Chainable {
31+
// login(email: string, password: string): Chainable<void>
32+
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
33+
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
34+
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
35+
// }
36+
// }
37+
// }
38+
39+
import '@4tw/cypress-drag-drop';
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
7+
<title>Components App</title>
8+
</head>
9+
<body>
10+
<div data-cy-root></div>
11+
</body>
12+
</html>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// ***********************************************************
2+
// This example support/component.ts is processed and
3+
// loaded automatically before your test files.
4+
//
5+
// This is a great place to put global configuration and
6+
// behavior that modifies Cypress.
7+
//
8+
// You can change the location of this file or turn off
9+
// automatically serving support files with the
10+
// 'supportFile' configuration option.
11+
//
12+
// You can read more here:
13+
// https://on.cypress.io/configuration
14+
// ***********************************************************
15+
16+
// Import commands.js using ES2015 syntax:
17+
import './commands';
18+
19+
// Alternatively you can use CommonJS syntax:
20+
// require('./commands')
21+
22+
import { mount } from 'cypress/react';
23+
24+
// Augment the Cypress namespace to include type definitions for
25+
// your custom command.
26+
// Alternatively, can be defined in cypress/support/component.d.ts
27+
// with a <reference path="./component" /> at the top of your spec.
28+
declare global {
29+
namespace Cypress {
30+
interface Chainable {
31+
mount: typeof mount
32+
}
33+
}
34+
}
35+
36+
Cypress.Commands.add('mount', mount);
37+
38+
// Example use:
39+
// cy.mount(<MyComponent />)

0 commit comments

Comments
 (0)