• Stars
    star
    153
  • Rank 243,368 (Top 5 %)
  • Language
    JavaScript
  • License
    GNU General Publi...
  • Created almost 6 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A cypress child command for drag'n'drop support.

cypress-drag-drop

A Cypress child command for drag'n'drop support.

Setup

Install using npm:

npm install --save-dev @4tw/cypress-drag-drop

or yarn

yarn add --dev @4tw/cypress-drag-drop

Before Cypress is loaded (usually in your commands.js) put the following line:

require('@4tw/cypress-drag-drop')

Or, if you are using ES module syntax:

import '@4tw/cypress-drag-drop'

This will register the drag and move command.

If you're using TypeScript, put the following configuration in a tsconfig.json

{
  "compilerOptions": {
    "types": ["cypress", "@4tw/cypress-drag-drop"]
  }
}

Usage

drag

The drag command is a child command. The command only accepts elements. As the drop target simply pass a selector as a string.

In your Cypress spec use the command as follows:

describe('Dragtest', () => {
  it('should dragndrop', () => {
    cy.visit('/yourpage')

    cy.get('.sourceitem').drag('.targetitem')
  })
})

Pass the options as an object in the second paramteter.

describe('Dragtest', () => {
  it('should dragndrop', () => {
    cy.visit('/yourpage')

    cy.get('.sourceitem').drag('.targetitem', options)
  })
})

During the drag and drop interaction, two elements are involved. The source element being dragged and the drop target. In order to decide what options should either be applied to the source or the target, the options object can be divided in source and target. Options that are not specific to the source or target are applied to both the source and the target.

cy.get('.sourceitem').drag('.target', {
  source: { x: 100, y: 100 }, // applies to the element being dragged
  target: { position: 'left' }, // applies to the drop target
  force: true, // applied to both the source and target element
})

The options are directly passed to Cypress' trigger command. So, all options from https://docs.cypress.io/api/commands/trigger#Arguments are possible.

Check command outcome

The drag command is able to tell wether the drag attempt was successful or not. So, the command will yield true when the drag attempt was successful and false otherwise:

cy.get('.sourceitem').drag('.target').then((success) => {
  assert.isTrue(success)
})

Or you might also want to check that the element is not draggable:

cy.get('.sourceitem').drag('.target').then((success) => {
  assert.isFalse(success)
})

move

The move command is a child command. The command only accepts elements. Define deltaX and deltaY as an object parameter to move the element in x- and y-position relative to the element's current position.

In your Cypress spec use the command as follows:

describe('Movetest', () => {
  it('should move', () => {
    cy.visit('/yourpage')

    cy.get('.sourceitem').move({ deltaX: 100, deltaY: 100 })
  })
})

The command accepts all options from https://docs.cypress.io/api/commands/trigger#Arguments except position, x and y because they have no effect, since the command makes use of clientX and clientY internally.

describe('Movetest', () => {
  it('should move', () => {
    cy.visit('/yourpage')

    cy.get('.sourceitem').move({ deltaX: 100, deltaY: 100, ...options })
  })
})

Development

The plugin itself is implemented in the index.js file.

Testing

The tests can be run using Cypress:

yarn test

The test fixtures are under src/examples/. Using the setExample Cypress command the fixture is loaded and ready to run tests on. The first attribute in the setExample command is the name of the fixture which needs to be the filename of the component.

cy.setExample('NameOfTheComponent')

Release

Release a new version of this package:

yarn run release

Changelog

Have a look at the Changelog

More Repositories

1

docxcompose

Append/Concatenate .docx documents
Python
78
star
2

opengever.core

OneGov GEVER core package
Python
10
star
3

ftw.calendar

JavaScript
7
star
4

ftw.upgrade

An upgrade control panel and upgrade helpers for plone upgrades.
Python
6
star
5

ftw.testbrowser

A testing browser for Plone.
Python
5
star
6

ftw.table

Table generator utility for use within zope.
Python
5
star
7

grafana-telegraf-dashboard

5
star
8

ftw.solr

Solr integration for Plone
Python
5
star
9

ftw.book

Produce books with Plone and export them in a high quality PDF.
Python
5
star
10

ftw.publisher.sender

Staging and publishing addon for Plone contents.
Python
5
star
11

vue-cli-plugin-cypress-django

Bridge between django, vue and cypress for full stack integration tests.
JavaScript
4
star
12

weasyprint-docker

A dockerized web service for creating PDFs from HTML using WeasyPrint
Python
4
star
13

ftw-buildouts

Buildout base configurations for development and testing.
Python
4
star
14

ftw.simplelayout

SimpleLayout provides block based content pages
JavaScript
4
star
15

ftw.publisher.core

Staging and publishing addon for Plone contents.
Python
4
star
16

ftw.tika

This product integrates Apache Tika for full text indexing with Plone.
Python
4
star
17

ftw.builder

Builder pattern for creating Plone objects in tests
Python
3
star
18

ftw.inflator

Plone site setup wizard with content creation and bundle system for predefined configurations.
Python
3
star
19

simplelayout.base

Simplelayout is an easy to use plone package for creating content pages
Python
3
star
20

collective.hashtags

Allows to tag objects by hashtags in richtext-fields
Python
3
star
21

ftw.participation

Invite other users (registered or unregistered) to a context in plone.
Python
3
star
22

msgconvert-docker

Shell
3
star
23

ftw.tabbedview

A generic tabbed view for plone content types.
Python
3
star
24

ftw.usermanagement

An advanced view for managing users in plone.
Python
3
star
25

ftw.pdfgenerator

A library for generating PDF representations of Plone objects with LaTeX.
Python
3
star
26

ftw.manager

Toolset for developing and releasing python eggs for Plone
Python
3
star
27

ftw.mail

Python
3
star
28

ftw.lawgiver

Generate Plone workflows by simply describing them in a human readable language.
Python
3
star
29

ftw.footballchallenge

A online football bet game based on plone.
Python
3
star
30

ftw.mobilenavigation

Ajax navigation for mobile use.
Python
3
star
31

ftw.crawler

Crawl sites, extract text and metadata, index it in Solr
Python
3
star
32

ftw.billboard

Simple market place addon for plone.
Python
3
star
33

ftw.globalstatusmessage

Python
3
star
34

ftw.workspace

A project folder for plone.
Python
3
star
35

ftw.meeting

A meeting content type for plone
Python
3
star
36

userstories-material

Python
2
star
37

ftw.publisher.example

Example workflow integration for ftw.publisher's staging and publishing system.
Python
2
star
38

ftw.contentpage

Python
2
star
39

ftw.notification.base

Send notifications when editing a plone content.
Python
2
star
40

ftw.avatar

Better default user avatars for Plone
Python
2
star
41

ftw.maintenanceserver

A maintenance HTTP server, serving a static directory.
Python
2
star
42

ftw.bridge.proxy

A pyramid based proxy application for proxying requests between plone instances.
Python
2
star
43

izug.basetheme

JavaScript
2
star
44

ftw.contenttemplates

Create content objects from templates.
Python
2
star
45

ftw.calendarwidget

A plone widget for archetypes using the jQuery UI calendar widget.
Python
2
star
46

django-git-deployment

Tutorial and files for deploying Django projects with git
Shell
2
star
47

ftw.recipe.translations

Python
2
star
48

ftw.publisher.receiver

Staging and publishing addon for Plone contents.
Python
2
star
49

ftw.shop

A general purpose web shop product for Plone
Python
2
star
50

ftwbook.graphicblock

A ftw.book addon for including PDF graphics in a book.
Python
2
star
51

ftw.task

A simple task content type for Plone.
Python
2
star
52

ftw.blog

A Blog for Plone
Python
2
star
53

ftw.tooltip

dynamic and static tooltips based on jquerytools tooltip
Python
2
star
54

ui

4teamwork specific UI components for vuetify.
Vue
2
star
55

ftw.publisher-example-buildout

Example buildout, installing the example publisher package.
Python
2
star
56

ftw.zipexport

Zip Export for Plone
Python
2
star
57

collective.deletepermission

Implements a new permission "Delete portal content" for Plone.
Python
2
star
58

ftw.recipe.deployment

A zc.buildout recipe for Plone deployments which configures various unix system services.
Python
2
star
59

collective.pfg.sqladapter

A PloneFormGen adapter that saves form input data in a SQL database
Python
2
star
60

vue-drop-zone

A vue component for drag'n'drop upload using uppy.io
JavaScript
2
star
61

ftw.notification.email

Send edit-notifications by email.
Python
1
star
62

opengever.ogds.models

SQLAlchemy models for OpenGever Directory Service
Python
1
star
63

egov.contactdirectory

A contact / membership directory.
Python
1
star
64

django-utils

A collection of utils used in our Django based web applications
Python
1
star
65

collective.js.extjs

ExtJS integration for Plone.
Python
1
star
66

vue-cli-plugin-pdfjs-viewer

JavaScript
1
star
67

ftw.statusmap

A review state site map for plone.
Python
1
star
68

ftw.dashboard.dragndrop

ftw.dashboard.dragndrop adds dragndrop functionality to the dashboard
Python
1
star
69

ftw.deploy

Tooling and scripts for git push based deployment at 4teamwork.
Python
1
star
70

ftw.caldav

CalDAV implementation for Plone.
Python
1
star
71

ftw.bridge.client

Python
1
star
72

ftw.subsite

Adds a Subsite functionality to Plone.
Python
1
star
73

ftw.contentmenu

A replacement for plone.app.contentmenu.
Python
1
star
74

gever-buildouts

General buildouts to include for deploying a GEVER product.
1
star
75

ftw.chameleon

Enhance Chameleon templating engine integration into Plone
Python
1
star
76

ftw.colorbox

An image gallery for Plone using ColorBox
JavaScript
1
star
77

ftw.mopage

Provides moPage integration for Plone.
Python
1
star
78

ftw.poodle

A product to make polls to find out when to have a meeting.
Python
1
star
79

ftw.wfreport

Create Plone workflow reports as PDF.
Python
1
star
80

ftw.dashboard.portlets.postit

Postit portlet for the dashboard
Python
1
star
81

ftw.favorite

ftw.favorite provides a favorite content type for plone.
Python
1
star
82

ftw.sendmail

Python
1
star
83

ftw.keywordwidget

z3c form keyword widget using select2
Python
1
star
84

ftw.dictstorage

Provides a layer for storing key / value paires.
Python
1
star
85

ftw.contacts

Provides a contact-contenttype
Python
1
star
86

plonetheme.blueberry

Blueberry, a Plone 4 theme
HTML
1
star
87

ftw.redirector

Plone addon for managing redirects
Python
1
star
88

ftw.dropdownmenu

A dropdown menu for Plone
Python
1
star
89

ftw.datepicker

JavaScript
1
star
90

ftw.raven

Plone addon for sentry
Python
1
star
91

ftw.referencewidget

A referencebrowser widget
JavaScript
1
star
92

ftw.theming

Python
1
star
93

sablon-docker

A dockerized webservice for creating Microsoft Word documents from templates
Python
1
star
94

ftw.showroom

JavaScript
1
star
95

errbit-python

errbit client for python
Python
1
star
96

ftw.file

A file content type for gov usecases
Python
1
star
97

ftw.keywordoverlay

Puts a nice overlay over Archetypes' default keywordwidget for plone.
JavaScript
1
star
98

ftw.activity

An activity feed for Plone.
Python
1
star
99

ftw.testing

Provides some testing helpers and an advanced MockTestCase.
Python
1
star
100

ftw.tagging

Tagging add-on for Plone
Python
1
star