How to use del method in Testcafe

Best JavaScript code snippet using testcafe

Run Testcafe automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

backspace.js

Source: backspace.js Github

copy
1/* bender-tags: editor */
2/* bender-ckeditor-plugins: list,toolbar,table,format */
3
4bender.editor = {
5	config: {
6		enterMode: CKEDITOR.ENTER_P
7	}
8};
9
10var BACKSPACE = 8,
11	DEL = 46;
12
13var tests = {
14	assertBackspace: function( name, key, keyModifiers, assertFn ) {
15		var bot = this.editorBot;
16		bender.tools.testInputOut( name, function( source, expected ) {
17			bot.setHtmlWithSelection( source );
18
19			bot.editor.editable().fire( 'keydown', new CKEDITOR.dom.event( {
20				keyCode: key,
21				ctrlKey: keyModifiers & CKEDITOR.CTRL,
22				shiftKey: keyModifiers & CKEDITOR.SHIFT
23			} ) );
24
25			assert.isInnerHtmlMatching( bender.tools.compatHtml( expected ), bender.tools.selection.getWithHtml( bot.editor ), {
26				compareSelection: true,
27				normalizeSelection: true
28			}, name );
29
30			if ( typeof assertFn === 'function' ) {
31				assertFn( bot.editor );
32			}
33		}, false );
34	}
35};
36
37// Start of https://dev.ckeditor.com/ticket/8248
38addTests( 'test backspace join list items', 'join_list1', BACKSPACE );
39addTests( 'test backspace join list items', 'join_list2', BACKSPACE );
40addTests( 'test backspace join list items', 'join_list3', BACKSPACE );
41addTests( 'test backspace join list items', 'join_list4', BACKSPACE );
42addTests( 'test backspace join list items', 'join_list5', BACKSPACE );
43addTests( 'test backspace join list items', 'join_list6', BACKSPACE );
44addTests( 'test backspace join list items', 'join_list7', BACKSPACE );
45addTests( 'test backspace join list items', 'join_list8', BACKSPACE );
46addTests( 'test backspace join list items', 'join_list9', BACKSPACE );
47addTests( 'test backspace join list items', 'join_list10', BACKSPACE );
48addTests( 'test backspace join list items', 'join_list11', BACKSPACE );
49addTests( 'test backspace join list items', 'join_list15', BACKSPACE, undefined, assertNotNestedAnchors );
50addTests( 'test backspace join list items', 'join_list16', BACKSPACE, undefined, assertNotNestedAnchors );
51addTests( 'test backspace join list items', 'join_list17', BACKSPACE );
52addTests( 'test backspace join list items', 'join_list18', BACKSPACE );
53
54function assertNotNestedAnchors( editor ) {
55	assert.isNull( editor.editable().findOne( 'a a' ) );
56}
57
58addTests( 'test backspace outdent list item', 'outdent_list', BACKSPACE );
59addTests( 'test backspace outdent list item', 'outdent_list2', BACKSPACE );
60addTests( 'test backspace outdent list item', 'outdent_list3', BACKSPACE );
61addTests( 'test backspace outdent list item', 'outdent_list4', BACKSPACE );
62addTests( 'test backspace outdent list item', 'outdent_list5', BACKSPACE );
63addTests( 'test backspace outdent list item', 'outdent_list6', BACKSPACE );
64
65addTests( 'test backspace NOT outdent list item', 'no_outdent_list', BACKSPACE );
66addTests( 'test backspace NOT outdent list item', 'no_outdent_list2', BACKSPACE );
67
68addTests( 'test del join list items', 'join_list1_del', DEL );
69addTests( 'test del join list items', 'join_list2_del', DEL );
70addTests( 'test del join list items', 'join_list3_del', DEL );
71addTests( 'test del join list items', 'join_list4_del', DEL );
72addTests( 'test del join list items', 'join_list5_del', DEL );
73addTests( 'test del join list items', 'join_list6_del', DEL );
74addTests( 'test del join list items', 'join_list7_del', DEL );
75addTests( 'test del join list items', 'join_list8_del', DEL );
76addTests( 'test del join list items', 'join_list9_del', DEL );
77addTests( 'test del join list items', 'join_list10_del', DEL );
78addTests( 'test del join list items', 'join_list11_del', DEL );
79addTests( 'test del join list items', 'join_list12_del', DEL );
80addTests( 'test del join list items', 'join_list13_del', DEL );
81addTests( 'test del join list items', 'join_list14_del', DEL );
82addTests( 'test del join list items', 'join_list15_del', DEL, undefined, assertNotNestedAnchors );
83addTests( 'test del join list items', 'join_list16_del', DEL, undefined, assertNotNestedAnchors );
84addTests( 'test del join list items', 'join_list17_del', DEL );
85addTests( 'test del join list items', 'join_list18_del', DEL );
86addTests( 'test del join list items', 'join_list19_del', DEL );
87addTests( 'test del join list items', 'join_list20_del', DEL );
88addTests( 'test del join list items', 'join_list21_del', DEL );
89
90addTests( 'test del join with next list item', 'merge_next_list', DEL );
91addTests( 'test del join with next list item', 'merge_next_list2', DEL );
92addTests( 'test del join with next list item', 'merge_next_list3', DEL );
93addTests( 'test del join with next list item', 'merge_next_list4', DEL );
94
95// On IE8 this test fails due to https://dev.ckeditor.com/ticket/13098.
96if ( !CKEDITOR.env.ie || CKEDITOR.env.version > 8 ) {
97	addTests( 'test del join with next list item', 'merge_next_list5', DEL );
98}
99
100addTests( 'test del remove empty block', 'remove_empty_block', DEL );
101addTests( 'test del remove empty block', 'remove_empty_block2', DEL );
102
103addTests( 'test del do nothing', 'del_no_action', DEL );
104addTests( 'test del do nothing', 'del_no_action2', DEL );
105
106// Make sure that the modifiers are ignored.
107// https://dev.ckeditor.com/ticket/11861#comment:13
108addTests( 'test backspace join list items - CTRL', 'join_list1', BACKSPACE, CKEDITOR.CTRL );
109addTests( 'test backspace outdent list item - SHIFT', 'outdent_list', BACKSPACE, CKEDITOR.SHIFT );
110addTests( 'test del join list items - CTRL', 'join_list1_del', DEL, CKEDITOR.CTRL );
111addTests( 'test del join with next list item - SHIFT', 'merge_next_list', DEL, CKEDITOR.SHIFT );
112
113function addTests( title, source, key, keyModifiers, assertFn ) {
114	tests[ title + ' (' + source + ')' ] = function() {
115		this.assertBackspace( source, key, keyModifiers, assertFn );
116	};
117}
118
119bender.test( tests );
120
Full Screen

system.js

Source: system.js Github

copy
1import React from "react";
2import Head from "next/head";
3import { Tabs, TabList, TabPanels, Tab, TabPanel } from "@chakra-ui/react";
4import Layout from "../templates/Private/Layout";
5import Help from "../views/system/Help";
6import Branch from "../views/system/Branch";
7import Category from "../views/system/Category";
8import Department from "../views/system/Department";
9import Marketing from "../views/system/Marketing";
10import SubCategory from "../views/system/SubCategory";
11import Leave from "../views/system/Leave";
12import Director from "../views/system/Director";
13
14function system(props) {
15  const { access } = props;
16  const leaveAdd = access && access.leave && access.leave.add;
17  const leaveView = access && access.leave && access.leave.view;
18  const leaveDel = access && access.leave && access.leave.del;
19
20  const catAdd = access && access.category && access.category.add;
21  const catView = access && access.category && access.category.view;
22  const catDel = access && access.category && access.category.del;
23
24  const deptAdd = access && access.department && access.department.add;
25  const deptView = access && access.department && access.department.view;
26  const deptDel = access && access.department && access.department.del;
27
28  const dirAdd = access && access.director && access.director.add;
29  const dirView = access && access.director && access.director.view;
30  const dirDel = access && access.director && access.director.del;
31
32  const branchAdd = access && access.branch && access.branch.add;
33  const branchView = access && access.branch && access.branch.view;
34  const branchDel = access && access.branch && access.branch.del;
35
36  let company = access && access.company && access.company.manage;
37
38  let totalLeave = leaveAdd || leaveView || leaveDel;
39
40  let totalBranch = branchAdd || branchView || branchDel;
41
42  let totalCategory = catAdd || catView || catDel;
43
44  let totalDept = deptAdd || deptView || deptDel;
45
46  let totalDir = dirAdd || dirView || dirDel;
47
48  // {"asset":{"add":true,"view":false,"del":false,"modify":false},"branch":{"add":true,"view":true,"del":false},"category":{"add":true,"view":false,"del":false},"company":{"manage":true},"department":{"ad…
49  return (
50    <>
51      <Head>
52        <title>Physio First | System</title>
53      </Head>
54      <Layout>
55        <Tabs>
56          <TabList>
57            <Tab>Help</Tab>
58            {totalBranch || totalCategory || totalDept ? (
59              <>
60                <Tab>Branch</Tab>
61                <Tab>Category</Tab>
62                <Tab>Department</Tab>
63                <Tab>Executives</Tab>
64                <Tab>Marketing</Tab>
65                <Tab>SubCategory</Tab>
66                <Tab>Vacation</Tab>
67              </>
68            ) : null}
69          </TabList>
70          <TabPanels>
71            <TabPanel>
72              <Help />
73            </TabPanel>
74            <TabPanel>
75              <Branch
76                pageAccess={totalBranch}
77                canAdd={branchAdd}
78                canView={branchView}
79                canDel={branchDel}
80              />
81            </TabPanel>
82            <TabPanel>
83              <Category
84                pageAccess={totalCategory}
85                canAdd={catAdd}
86                canView={catView}
87                canDel={catDel}
88              />
89            </TabPanel>
90            <TabPanel>
91              <Department
92                pageAccess={totalDept}
93                canAdd={deptAdd}
94                canView={deptView}
95                canDel={deptDel}
96              />
97            </TabPanel>
98            <TabPanel>
99              <Director
100                pageAccess={totalDir}
101                canAdd={dirAdd}
102                canView={dirView}
103                canDel={dirDel}
104              />
105            </TabPanel>
106            <TabPanel>
107              <Marketing />
108            </TabPanel>
109            <TabPanel>
110              <SubCategory
111                pageAccess={totalCategory}
112                canAdd={catAdd}
113                canView={catView}
114                canDel={catDel}
115              />
116            </TabPanel>
117            <TabPanel>
118              <Leave
119                pageAccess={totalLeave}
120                canAdd={leaveAdd}
121                canView={leaveView}
122                canDel={leaveDel}
123              />
124            </TabPanel>
125          </TabPanels>
126        </Tabs>
127      </Layout>
128    </>
129  );
130}
131
132export default system;
133
Full Screen

tagsView.js

Source: tagsView.js Github

copy
1const tagsView = {
2  state: {
3    visitedViews: [],
4    cachedViews: []
5  },
6  mutations: {
7    ADD_VISITED_VIEW: (state, view) => {
8      if (state.visitedViews.some(v => v.path === view.path)) return
9      state.visitedViews.push(
10        Object.assign({}, view, {
11          title: view.meta.title || 'no-name'
12        })
13      )
14    },
15    ADD_CACHED_VIEW: (state, view) => {
16      if (state.cachedViews.includes(view.name)) return
17      if (!view.meta.noCache) {
18        state.cachedViews.push(view.name)
19      }
20    },
21
22    DEL_VISITED_VIEW: (state, view) => {
23      for (const [i, v] of state.visitedViews.entries()) {
24        if (v.path === view.path) {
25          state.visitedViews.splice(i, 1)
26          break
27        }
28      }
29    },
30    DEL_CACHED_VIEW: (state, view) => {
31      for (const i of state.cachedViews) {
32        if (i === view.name) {
33          const index = state.cachedViews.indexOf(i)
34          state.cachedViews.splice(index, 1)
35          break
36        }
37      }
38    },
39
40    DEL_OTHERS_VISITED_VIEWS: (state, view) => {
41      for (const [i, v] of state.visitedViews.entries()) {
42        if (v.path === view.path) {
43          state.visitedViews = state.visitedViews.slice(i, i + 1)
44          break
45        }
46      }
47    },
48    DEL_OTHERS_CACHED_VIEWS: (state, view) => {
49      for (const i of state.cachedViews) {
50        if (i === view.name) {
51          const index = state.cachedViews.indexOf(i)
52          state.cachedViews = state.cachedViews.slice(index, index + 1)
53          break
54        }
55      }
56    },
57
58    DEL_ALL_VISITED_VIEWS: state => {
59      state.visitedViews = []
60    },
61    DEL_ALL_CACHED_VIEWS: state => {
62      state.cachedViews = []
63    },
64
65    UPDATE_VISITED_VIEW: (state, view) => {
66      for (let v of state.visitedViews) {
67        if (v.path === view.path) {
68          v = Object.assign(v, view)
69          break
70        }
71      }
72    }
73
74  },
75  actions: {
76    addView({ dispatch }, view) {
77      dispatch('addVisitedView', view)
78      dispatch('addCachedView', view)
79    },
80    addVisitedView({ commit }, view) {
81      commit('ADD_VISITED_VIEW', view)
82    },
83    addCachedView({ commit }, view) {
84      commit('ADD_CACHED_VIEW', view)
85    },
86
87    delView({ dispatch, state }, view) {
88      return new Promise(resolve => {
89        dispatch('delVisitedView', view)
90        dispatch('delCachedView', view)
91        resolve({
92          visitedViews: [...state.visitedViews],
93          cachedViews: [...state.cachedViews]
94        })
95      })
96    },
97    delVisitedView({ commit, state }, view) {
98      return new Promise(resolve => {
99        commit('DEL_VISITED_VIEW', view)
100        resolve([...state.visitedViews])
101      })
102    },
103    delCachedView({ commit, state }, view) {
104      return new Promise(resolve => {
105        commit('DEL_CACHED_VIEW', view)
106        resolve([...state.cachedViews])
107      })
108    },
109
110    delOthersViews({ dispatch, state }, view) {
111      return new Promise(resolve => {
112        dispatch('delOthersVisitedViews', view)
113        dispatch('delOthersCachedViews', view)
114        resolve({
115          visitedViews: [...state.visitedViews],
116          cachedViews: [...state.cachedViews]
117        })
118      })
119    },
120    delOthersVisitedViews({ commit, state }, view) {
121      return new Promise(resolve => {
122        commit('DEL_OTHERS_VISITED_VIEWS', view)
123        resolve([...state.visitedViews])
124      })
125    },
126    delOthersCachedViews({ commit, state }, view) {
127      return new Promise(resolve => {
128        commit('DEL_OTHERS_CACHED_VIEWS', view)
129        resolve([...state.cachedViews])
130      })
131    },
132
133    delAllViews({ dispatch, state }, view) {
134      return new Promise(resolve => {
135        dispatch('delAllVisitedViews', view)
136        dispatch('delAllCachedViews', view)
137        resolve({
138          visitedViews: [...state.visitedViews],
139          cachedViews: [...state.cachedViews]
140        })
141      })
142    },
143    delAllVisitedViews({ commit, state }) {
144      return new Promise(resolve => {
145        commit('DEL_ALL_VISITED_VIEWS')
146        resolve([...state.visitedViews])
147      })
148    },
149    delAllCachedViews({ commit, state }) {
150      return new Promise(resolve => {
151        commit('DEL_ALL_CACHED_VIEWS')
152        resolve([...state.cachedViews])
153      })
154    },
155
156    updateVisitedView({ commit }, view) {
157      commit('UPDATE_VISITED_VIEW', view)
158    }
159  }
160}
161
162export default tagsView
163
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run JavaScript Tests on LambdaTest Cloud Grid

Execute automation tests with Testcafe on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)