How to use focused method in Cypress

Best JavaScript code snippet using cypress

Slideshow.js

Source:Slideshow.js Github

copy

Full Screen

...366 event.preventDefault();367 this._pendingFocusedItem = focusedSlide368 this.props.onFocused();369 }370 onUnfocused(event) {371 if (this.state.focusedSlide === undefined)372 return;373 if (event)374 event.preventDefault();375 this.props.onUnfocused();376 }377 setFocusedSlide(focusedSlide, immediately, event) {378 const 379 {380 focusedRolloutEnabled,381 isFocusedRollout,382 } = this.props,383 {384 focusedSlide : currentFocusedSlide,385 } = this.state,386 pendingFocusedSlide = this._throttleSetFocusedSlide ? this._pendingFocusedSlide : currentFocusedSlide,387 isDisplayingRollout = focusedRolloutEnabled && currentFocusedSlide !== undefined && isFocusedRollout388 if (immediately) {389 if (event)...

Full Screen

Full Screen

browser_tabfocus.js

Source:browser_tabfocus.js Github

copy

Full Screen

1/*2 * This test checks that focus is adjusted properly when switching tabs.3 */4/* eslint-env mozilla/frame-script */5var testPage1 = "<html id='html1'><body id='body1'><button id='button1'>Tab 1</button></body></html>";6var testPage2 = "<html id='html2'><body id='body2'><button id='button2'>Tab 2</button></body></html>";7var testPage3 = "<html id='html3'><body id='body3'><button id='button3'>Tab 3</button></body></html>";8const fm = Services.focus;9function EventStore() {10 this["main-window"] = [];11 this.window1 = [];12 this.window2 = [];13}14EventStore.prototype = {15 "push": function(event) {16 if (event.indexOf("1") > -1) {17 this.window1.push(event);18 } else if (event.indexOf("2") > -1) {19 this.window2.push(event);20 } else {21 this["main-window"].push(event);22 }23 }24}25var tab1 = null;26var tab2 = null;27var browser1 = null;28var browser2 = null;29var _lastfocus;30var _lastfocuswindow = null;31var actualEvents = new EventStore();32var expectedEvents = new EventStore();33var currentTestName = "";34var _expectedElement = null;35var _expectedWindow = null;36var currentPromiseResolver = null;37function getFocusedElementForBrowser(browser, dontCheckExtraFocus = false) {38 if (gMultiProcessBrowser) {39 return new Promise((resolve, reject) => {40 window.messageManager.addMessageListener("Browser:GetCurrentFocus", function getCurrentFocus(message) {41 window.messageManager.removeMessageListener("Browser:GetCurrentFocus", getCurrentFocus);42 resolve(message.data.details);43 });44 // The dontCheckExtraFocus flag is used to indicate not to check some45 // additional focus related properties. This is needed as both URLs are46 // loaded using the same child process and share focus managers.47 browser.messageManager.sendAsyncMessage("Browser:GetFocusedElement",48 { dontCheckExtraFocus });49 });50 }51 var focusedWindow = {};52 var node = fm.getFocusedElementForWindow(browser.contentWindow, false, focusedWindow);53 return "Focus is " + (node ? node.id : "<none>");54}55function focusInChild() {56 var contentFM = Components.classes["@mozilla.org/focus-manager;1"].57 getService(Components.interfaces.nsIFocusManager);58 function getWindowDocId(target) {59 return (String(target.location).indexOf("1") >= 0) ? "window1" : "window2";60 }61 function eventListener(event) {62 // Stop the shim code from seeing this event process.63 event.stopImmediatePropagation();64 var id;65 if (event.target instanceof Components.interfaces.nsIDOMWindow)66 id = getWindowDocId(event.originalTarget) + "-window";67 else if (event.target instanceof Components.interfaces.nsIDOMDocument)68 id = getWindowDocId(event.originalTarget) + "-document";69 else70 id = event.originalTarget.id;71 sendSyncMessage("Browser:FocusChanged", { details: event.type + ": " + id });72 }73 addEventListener("focus", eventListener, true);74 addEventListener("blur", eventListener, true);75 addMessageListener("Browser:ChangeFocus", function changeFocus(message) {76 content.document.getElementById(message.data.id)[message.data.type]();77 });78 addMessageListener("Browser:GetFocusedElement", function getFocusedElement(message) {79 var focusedWindow = {};80 var node = contentFM.getFocusedElementForWindow(content, false, focusedWindow);81 var details = "Focus is " + (node ? node.id : "<none>");82 /* Check focus manager properties. Add an error onto the string if they are83 not what is expected which will cause matching to fail in the parent process. */84 let doc = content.document;85 if (!message.data.dontCheckExtraFocus) {86 if (contentFM.focusedElement != node) {87 details += "<ERROR: focusedElement doesn't match>";88 }89 if (contentFM.focusedWindow && contentFM.focusedWindow != content) {90 details += "<ERROR: focusedWindow doesn't match>";91 }92 if ((contentFM.focusedWindow == content) != doc.hasFocus()) {93 details += "<ERROR: child hasFocus() is not correct>";94 }95 if ((contentFM.focusedElement && doc.activeElement != contentFM.focusedElement) ||96 (!contentFM.focusedElement && doc.activeElement != doc.body)) {97 details += "<ERROR: child activeElement is not correct>";98 }99 }100 sendSyncMessage("Browser:GetCurrentFocus", { details });101 });102}103function focusElementInChild(elementid, type) {104 let browser = (elementid.indexOf("1") >= 0) ? browser1 : browser2;105 if (gMultiProcessBrowser) {106 browser.messageManager.sendAsyncMessage("Browser:ChangeFocus",107 { id: elementid, type });108 } else {109 browser.contentDocument.getElementById(elementid)[type]();110 }111}112add_task(async function() {113 tab1 = BrowserTestUtils.addTab(gBrowser);114 browser1 = gBrowser.getBrowserForTab(tab1);115 tab2 = BrowserTestUtils.addTab(gBrowser);116 browser2 = gBrowser.getBrowserForTab(tab2);117 await promiseTabLoadEvent(tab1, "data:text/html," + escape(testPage1));118 await promiseTabLoadEvent(tab2, "data:text/html," + escape(testPage2));119 var childFocusScript = "data:,(" + escape(focusInChild.toString()) + ")();";120 browser1.messageManager.loadFrameScript(childFocusScript, true);121 browser2.messageManager.loadFrameScript(childFocusScript, true);122 gURLBar.focus();123 await SimpleTest.promiseFocus();124 if (gMultiProcessBrowser) {125 window.messageManager.addMessageListener("Browser:FocusChanged", message => {126 actualEvents.push(message.data.details);127 compareFocusResults();128 });129 }130 _lastfocus = "urlbar";131 _lastfocuswindow = "main-window";132 window.addEventListener("focus", _browser_tabfocus_test_eventOccured, true);133 window.addEventListener("blur", _browser_tabfocus_test_eventOccured, true);134 // make sure that the focus initially starts out blank135 var focusedWindow = {};136 let focused = await getFocusedElementForBrowser(browser1);137 is(focused, "Focus is <none>", "initial focus in tab 1");138 focused = await getFocusedElementForBrowser(browser2);139 is(focused, "Focus is <none>", "initial focus in tab 2");140 is(document.activeElement, gURLBar.inputField, "focus after loading two tabs");141 await expectFocusShiftAfterTabSwitch(tab2, "window2", null, true,142 "after tab change, focus in new tab");143 focused = await getFocusedElementForBrowser(browser2);144 is(focused, "Focus is <none>", "focusedElement after tab change, focus in new tab");145 // switching tabs when nothing in the new tab is focused146 // should focus the browser147 await expectFocusShiftAfterTabSwitch(tab1, "window1", null, true,148 "after tab change, focus in original tab");149 focused = await getFocusedElementForBrowser(browser1);150 is(focused, "Focus is <none>", "focusedElement after tab change, focus in original tab");151 // focusing a button in the current tab should focus it152 await expectFocusShift(() => focusElementInChild("button1", "focus"),153 "window1", "button1", true,154 "after button focused");155 focused = await getFocusedElementForBrowser(browser1);156 is(focused, "Focus is button1", "focusedElement in first browser after button focused");157 // focusing a button in a background tab should not change the actual158 // focus, but should set the focus that would be in that background tab to159 // that button.160 await expectFocusShift(() => focusElementInChild("button2", "focus"),161 "window1", "button1", false,162 "after button focus in unfocused tab");163 focused = await getFocusedElementForBrowser(browser1, false);164 is(focused, "Focus is button1", "focusedElement in first browser after button focus in unfocused tab");165 focused = await getFocusedElementForBrowser(browser2, true);166 is(focused, "Focus is button2", "focusedElement in second browser after button focus in unfocused tab");167 // switching tabs should now make the button in the other tab focused168 await expectFocusShiftAfterTabSwitch(tab2, "window2", "button2", true,169 "after tab change with button focused");170 // blurring an element in a background tab should not change the active171 // focus, but should clear the focus in that tab.172 await expectFocusShift(() => focusElementInChild("button1", "blur"),173 "window2", "button2", false,174 "focusedWindow after blur in unfocused tab");175 focused = await getFocusedElementForBrowser(browser1, true);176 is(focused, "Focus is <none>", "focusedElement in first browser after focus in unfocused tab");177 focused = await getFocusedElementForBrowser(browser2, false);178 is(focused, "Focus is button2", "focusedElement in second browser after focus in unfocused tab");179 // When focus is in the tab bar, it should be retained there180 await expectFocusShift(() => gBrowser.selectedTab.focus(),181 "main-window", "tab2", true,182 "focusing tab element");183 await expectFocusShiftAfterTabSwitch(tab1, "main-window", "tab1", true,184 "tab change when selected tab element was focused");185 let switchWaiter;186 if (gMultiProcessBrowser) {187 switchWaiter = new Promise((resolve, reject) => {188 gBrowser.addEventListener("TabSwitchDone", function() {189 executeSoon(resolve);190 }, {once: true});191 });192 }193 await expectFocusShiftAfterTabSwitch(tab2, "main-window", "tab2", true,194 "another tab change when selected tab element was focused");195 // When this a remote browser, wait for the paint on the second browser so that196 // any post tab-switching stuff has time to complete before blurring the tab.197 // Otherwise, the _adjustFocusAfterTabSwitch in tabbrowser gets confused and198 // isn't sure what tab is really focused.199 if (gMultiProcessBrowser) {200 await switchWaiter;201 }202 await expectFocusShift(() => gBrowser.selectedTab.blur(),203 "main-window", null, true,204 "blurring tab element");205 // focusing the url field should switch active focus away from the browser but206 // not clear what would be the focus in the browser207 focusElementInChild("button1", "focus");208 await expectFocusShift(() => gURLBar.focus(),209 "main-window", "urlbar", true,210 "focusedWindow after url field focused");211 focused = await getFocusedElementForBrowser(browser1, true);212 is(focused, "Focus is button1", "focusedElement after url field focused, first browser");213 focused = await getFocusedElementForBrowser(browser2, true);214 is(focused, "Focus is button2", "focusedElement after url field focused, second browser");215 await expectFocusShift(() => gURLBar.blur(),216 "main-window", null, true,217 "blurring url field");218 // when a chrome element is focused, switching tabs to a tab with a button219 // with the current focus should focus the button220 await expectFocusShiftAfterTabSwitch(tab1, "window1", "button1", true,221 "after tab change, focus in url field, button focused in new tab");222 focused = await getFocusedElementForBrowser(browser1, false);223 is(focused, "Focus is button1", "after switch tab, focus in unfocused tab, first browser");224 focused = await getFocusedElementForBrowser(browser2, true);225 is(focused, "Focus is button2", "after switch tab, focus in unfocused tab, second browser");226 // blurring an element in the current tab should clear the active focus227 await expectFocusShift(() => focusElementInChild("button1", "blur"),228 "window1", null, true,229 "after blur in focused tab");230 focused = await getFocusedElementForBrowser(browser1, false);231 is(focused, "Focus is <none>", "focusedWindow after blur in focused tab, child");232 focusedWindow = {};233 is(fm.getFocusedElementForWindow(window, false, focusedWindow), browser1, "focusedElement after blur in focused tab, parent");234 // blurring an non-focused url field should have no effect235 await expectFocusShift(() => gURLBar.blur(),236 "window1", null, false,237 "after blur in unfocused url field");238 focusedWindow = {};239 is(fm.getFocusedElementForWindow(window, false, focusedWindow), browser1, "focusedElement after blur in unfocused url field");240 // switch focus to a tab with a currently focused element241 await expectFocusShiftAfterTabSwitch(tab2, "window2", "button2", true,242 "after switch from unfocused to focused tab");243 focused = await getFocusedElementForBrowser(browser2, true);244 is(focused, "Focus is button2", "focusedElement after switch from unfocused to focused tab");245 // clearing focus on the chrome window should switch the focus to the246 // chrome window247 await expectFocusShift(() => fm.clearFocus(window),248 "main-window", null, true,249 "after switch to chrome with no focused element");250 focusedWindow = {};251 is(fm.getFocusedElementForWindow(window, false, focusedWindow), null, "focusedElement after switch to chrome with no focused element");252 // switch focus to another tab when neither have an active focus253 await expectFocusShiftAfterTabSwitch(tab1, "window1", null, true,254 "focusedWindow after tab switch from no focus to no focus");255 focused = await getFocusedElementForBrowser(browser1, false);256 is(focused, "Focus is <none>", "after tab switch from no focus to no focus, first browser");257 focused = await getFocusedElementForBrowser(browser2, true);258 is(focused, "Focus is button2", "after tab switch from no focus to no focus, second browser");259 // next, check whether navigating forward, focusing the urlbar and then260 // navigating back maintains the focus in the urlbar.261 await expectFocusShift(() => focusElementInChild("button1", "focus"),262 "window1", "button1", true,263 "focus button");264 await promiseTabLoadEvent(tab1, "data:text/html," + escape(testPage3));265 // now go back again266 gURLBar.focus();267 await new Promise((resolve, reject) => {268 window.addEventListener("pageshow", function(event) {269 resolve();270 }, {capture: true, once: true});271 document.getElementById("Browser:Back").doCommand();272 });273 is(window.document.activeElement, gURLBar.inputField, "urlbar still focused after navigating back");274 // Document navigation with F6 does not yet work in mutli-process browsers.275 if (!gMultiProcessBrowser) {276 gURLBar.focus();277 actualEvents = new EventStore();278 _lastfocus = "urlbar";279 _lastfocuswindow = "main-window";280 await expectFocusShift(() => EventUtils.synthesizeKey("VK_F6", { }),281 "window1", "html1",282 true, "switch document forward with f6");283 EventUtils.synthesizeKey("VK_F6", { });284 is(fm.focusedWindow, window, "switch document forward again with f6");285 browser1.style.MozUserFocus = "ignore";286 browser1.clientWidth;287 EventUtils.synthesizeKey("VK_F6", { });288 is(fm.focusedWindow, window, "switch document forward again with f6 when browser non-focusable");289 browser1.style.MozUserFocus = "normal";290 browser1.clientWidth;291 }292 window.removeEventListener("focus", _browser_tabfocus_test_eventOccured, true);293 window.removeEventListener("blur", _browser_tabfocus_test_eventOccured, true);294 gBrowser.removeCurrentTab();295 gBrowser.removeCurrentTab();296 finish();297});298function _browser_tabfocus_test_eventOccured(event) {299 function getWindowDocId(target) {300 if (target == browser1.contentWindow || target == browser1.contentDocument) {301 return "window1";302 }303 if (target == browser2.contentWindow || target == browser2.contentDocument) {304 return "window2";305 }306 return "main-window";307 }308 var id;309 if (event.target instanceof Window)310 id = getWindowDocId(event.originalTarget) + "-window";311 else if (event.target instanceof Document)312 id = getWindowDocId(event.originalTarget) + "-document";313 else if (event.target.id == "urlbar" && event.originalTarget.localName == "input")314 id = "urlbar";315 else if (event.originalTarget.localName == "browser")316 id = (event.originalTarget == browser1) ? "browser1" : "browser2";317 else if (event.originalTarget.localName == "tab")318 id = (event.originalTarget == tab1) ? "tab1" : "tab2";319 else320 id = event.originalTarget.id;321 actualEvents.push(event.type + ": " + id);322 compareFocusResults();323}324function getId(element) {325 if (!element) {326 return null;327 }328 if (element.localName == "browser") {329 return element == browser1 ? "browser1" : "browser2";330 }331 if (element.localName == "tab") {332 return element == tab1 ? "tab1" : "tab2";333 }334 return (element.localName == "input") ? "urlbar" : element.id;335}336function compareFocusResults() {337 if (!currentPromiseResolver)338 return;339 let winIds = ["main-window", "window1", "window2"];340 for (let winId of winIds) {341 if (actualEvents[winId].length < expectedEvents[winId].length)342 return;343 }344 for (let winId of winIds) {345 for (let e = 0; e < expectedEvents.length; e++) {346 is(actualEvents[winId][e], expectedEvents[winId][e], currentTestName + " events [event " + e + "]");347 }348 actualEvents[winId] = [];349 }350 // Use executeSoon as this will be called during a focus/blur event handler351 executeSoon(() => {352 let matchWindow = window;353 if (gMultiProcessBrowser) {354 is(_expectedWindow, "main-window", "main-window is always expected");355 } else if (_expectedWindow != "main-window") {356 matchWindow = (_expectedWindow == "window1" ? browser1.contentWindow : browser2.contentWindow);357 }358 var focusedElement = fm.focusedElement;359 is(getId(focusedElement), _expectedElement, currentTestName + " focusedElement");360 is(fm.focusedWindow, matchWindow, currentTestName + " focusedWindow");361 var focusedWindow = {};362 is(getId(fm.getFocusedElementForWindow(matchWindow, false, focusedWindow)),363 _expectedElement, currentTestName + " getFocusedElementForWindow");364 is(focusedWindow.value, matchWindow, currentTestName + " getFocusedElementForWindow frame");365 is(matchWindow.document.hasFocus(), true, currentTestName + " hasFocus");366 var expectedActive = _expectedElement;367 if (!expectedActive) {368 expectedActive = matchWindow.document instanceof XULDocument ?369 "main-window" : getId(matchWindow.document.body);370 }371 is(getId(matchWindow.document.activeElement), expectedActive, currentTestName + " activeElement");372 currentPromiseResolver();373 currentPromiseResolver = null;374 });375}376async function expectFocusShiftAfterTabSwitch(tab, expectedWindow, expectedElement, focusChanged, testid) {377 let tabSwitchPromise = null;378 await expectFocusShift(() => { tabSwitchPromise = BrowserTestUtils.switchTab(gBrowser, tab) },379 expectedWindow, expectedElement, focusChanged, testid)380 await tabSwitchPromise;381}382function expectFocusShift(callback, expectedWindow, expectedElement, focusChanged, testid) {383 currentPromiseResolver = null;384 currentTestName = testid;385 expectedEvents = new EventStore();386 if (focusChanged) {387 _expectedElement = expectedElement;388 _expectedWindow = expectedWindow;389 // When the content is in a child process, the expected element in the chrome window390 // will always be the urlbar or a browser element.391 if (gMultiProcessBrowser) {392 if (_expectedWindow == "window1") {393 _expectedElement = "browser1";394 } else if (_expectedWindow == "window2") {395 _expectedElement = "browser2";396 }397 _expectedWindow = "main-window";398 }399 if (gMultiProcessBrowser && _lastfocuswindow != "main-window" &&400 _lastfocuswindow != expectedWindow) {401 let browserid = _lastfocuswindow == "window1" ? "browser1" : "browser2";402 expectedEvents.push("blur: " + browserid);403 }404 var newElementIsFocused = (expectedElement && !expectedElement.startsWith("html"));405 if (newElementIsFocused && gMultiProcessBrowser &&406 _lastfocuswindow != "main-window" &&407 expectedWindow == "main-window") {408 // When switching from a child to a chrome element, the focus on the element will arrive first.409 expectedEvents.push("focus: " + expectedElement);410 newElementIsFocused = false;411 }412 if (_lastfocus && _lastfocus != _expectedElement)413 expectedEvents.push("blur: " + _lastfocus);414 if (_lastfocuswindow &&415 _lastfocuswindow != expectedWindow) {416 if (!gMultiProcessBrowser || _lastfocuswindow != "main-window") {417 expectedEvents.push("blur: " + _lastfocuswindow + "-document");418 expectedEvents.push("blur: " + _lastfocuswindow + "-window");419 }420 }421 if (expectedWindow && _lastfocuswindow != expectedWindow) {422 if (gMultiProcessBrowser && expectedWindow != "main-window") {423 let browserid = expectedWindow == "window1" ? "browser1" : "browser2";424 expectedEvents.push("focus: " + browserid);425 }426 if (!gMultiProcessBrowser || expectedWindow != "main-window") {427 expectedEvents.push("focus: " + expectedWindow + "-document");428 expectedEvents.push("focus: " + expectedWindow + "-window");429 }430 }431 if (newElementIsFocused) {432 expectedEvents.push("focus: " + expectedElement);433 }434 _lastfocus = expectedElement;435 _lastfocuswindow = expectedWindow;436 }437 return new Promise((resolve, reject) => {438 currentPromiseResolver = resolve;439 callback();440 // No events are expected, so resolve the promise immediately.441 if (expectedEvents["main-window"].length + expectedEvents.window1.length + expectedEvents.window2.length == 0) {442 currentPromiseResolver();443 currentPromiseResolver = null;444 }445 });...

Full Screen

Full Screen

browser_dbg_variables-view-accessibility.js

Source:browser_dbg_variables-view-accessibility.js Github

copy

Full Screen

1/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */2/* vim: set ft=javascript ts=2 et sw=2 tw=80: */3/* Any copyright is dedicated to the Public Domain.4 * http://creativecommons.org/publicdomain/zero/1.0/ */5/**6 * Make sure that the variables view is keyboard accessible.7 */8var gTab, gPanel, gDebugger;9var gVariablesView;10function test() {11 initDebugger().then(([aTab,, aPanel]) => {12 gTab = aTab;13 gPanel = aPanel;14 gDebugger = gPanel.panelWin;15 gVariablesView = gDebugger.DebuggerView.Variables;16 performTest().catch(aError => {17 ok(false, "Got an error: " + aError.message + "\n" + aError.stack);18 });19 });20}21function performTest() {22 let arr = [23 42,24 true,25 "nasu",26 undefined,27 null,28 [0, 1, 2],29 { prop1: 9, prop2: 8 }30 ];31 let obj = {32 p0: 42,33 p1: true,34 p2: "nasu",35 p3: undefined,36 p4: null,37 p5: [3, 4, 5],38 p6: { prop1: 7, prop2: 6 },39 get p7() { return arr; },40 set p8(value) { arr[0] = value; }41 };42 let test = {43 someProp0: 42,44 someProp1: true,45 someProp2: "nasu",46 someProp3: undefined,47 someProp4: null,48 someProp5: arr,49 someProp6: obj,50 get someProp7() { return arr; },51 set someProp7(value) { arr[0] = value; }52 };53 gVariablesView.eval = function () {};54 gVariablesView.switch = function () {};55 gVariablesView.delete = function () {};56 gVariablesView.rawObject = test;57 gVariablesView.scrollPageSize = 5;58 return Task.spawn(function* () {59 yield waitForTick();60 // Part 0: Test generic focus methods on the variables view.61 gVariablesView.focusFirstVisibleItem();62 is(gVariablesView.getFocusedItem().name, "someProp0",63 "The 'someProp0' item should be focused.");64 gVariablesView.focusNextItem();65 is(gVariablesView.getFocusedItem().name, "someProp1",66 "The 'someProp1' item should be focused.");67 gVariablesView.focusPrevItem();68 is(gVariablesView.getFocusedItem().name, "someProp0",69 "The 'someProp0' item should be focused.");70 // Part 1: Make sure that UP/DOWN keys don't scroll the variables view.71 yield synthesizeKeyAndWaitForTick("VK_DOWN", {});72 is(gVariablesView._parent.scrollTop, 0,73 "The 'variables' view shouldn't scroll when pressing the DOWN key.");74 yield synthesizeKeyAndWaitForTick("VK_UP", {});75 is(gVariablesView._parent.scrollTop, 0,76 "The 'variables' view shouldn't scroll when pressing the UP key.");77 // Part 2: Make sure that RETURN/ESCAPE toggle input elements.78 yield synthesizeKeyAndWaitForElement("VK_RETURN", {}, ".element-value-input", true);79 yield synthesizeKeyAndWaitForElement("VK_ESCAPE", {}, ".element-value-input", false);80 yield synthesizeKeyAndWaitForElement("VK_RETURN", { shiftKey: true }, ".element-name-input", true);81 yield synthesizeKeyAndWaitForElement("VK_ESCAPE", {}, ".element-name-input", false);82 // Part 3: Test simple navigation.83 EventUtils.sendKey("DOWN", gDebugger);84 is(gVariablesView.getFocusedItem().name, "someProp1",85 "The 'someProp1' item should be focused.");86 EventUtils.sendKey("UP", gDebugger);87 is(gVariablesView.getFocusedItem().name, "someProp0",88 "The 'someProp0' item should be focused.");89 EventUtils.sendKey("PAGE_DOWN", gDebugger);90 is(gVariablesView.getFocusedItem().name, "someProp5",91 "The 'someProp5' item should be focused.");92 EventUtils.sendKey("PAGE_UP", gDebugger);93 is(gVariablesView.getFocusedItem().name, "someProp0",94 "The 'someProp0' item should be focused.");95 EventUtils.sendKey("END", gDebugger);96 is(gVariablesView.getFocusedItem().name, "__proto__",97 "The '__proto__' item should be focused.");98 EventUtils.sendKey("HOME", gDebugger);99 is(gVariablesView.getFocusedItem().name, "someProp0",100 "The 'someProp0' item should be focused.");101 // Part 4: Test if pressing the same navigation key twice works as expected.102 EventUtils.sendKey("DOWN", gDebugger);103 is(gVariablesView.getFocusedItem().name, "someProp1",104 "The 'someProp1' item should be focused.");105 EventUtils.sendKey("DOWN", gDebugger);106 is(gVariablesView.getFocusedItem().name, "someProp2",107 "The 'someProp2' item should be focused.");108 EventUtils.sendKey("UP", gDebugger);109 is(gVariablesView.getFocusedItem().name, "someProp1",110 "The 'someProp1' item should be focused.");111 EventUtils.sendKey("UP", gDebugger);112 is(gVariablesView.getFocusedItem().name, "someProp0",113 "The 'someProp0' item should be focused.");114 EventUtils.sendKey("PAGE_DOWN", gDebugger);115 is(gVariablesView.getFocusedItem().name, "someProp5",116 "The 'someProp5' item should be focused.");117 EventUtils.sendKey("PAGE_DOWN", gDebugger);118 is(gVariablesView.getFocusedItem().name, "__proto__",119 "The '__proto__' item should be focused.");120 EventUtils.sendKey("PAGE_UP", gDebugger);121 is(gVariablesView.getFocusedItem().name, "someProp5",122 "The 'someProp5' item should be focused.");123 EventUtils.sendKey("PAGE_UP", gDebugger);124 is(gVariablesView.getFocusedItem().name, "someProp0",125 "The 'someProp0' item should be focused.");126 // Part 5: Test that HOME/PAGE_UP/PAGE_DOWN are symmetrical.127 EventUtils.sendKey("HOME", gDebugger);128 is(gVariablesView.getFocusedItem().name, "someProp0",129 "The 'someProp0' item should be focused.");130 EventUtils.sendKey("HOME", gDebugger);131 is(gVariablesView.getFocusedItem().name, "someProp0",132 "The 'someProp0' item should be focused.");133 EventUtils.sendKey("PAGE_UP", gDebugger);134 is(gVariablesView.getFocusedItem().name, "someProp0",135 "The 'someProp0' item should be focused.");136 EventUtils.sendKey("HOME", gDebugger);137 is(gVariablesView.getFocusedItem().name, "someProp0",138 "The 'someProp0' item should be focused.");139 EventUtils.sendKey("END", gDebugger);140 is(gVariablesView.getFocusedItem().name, "__proto__",141 "The '__proto__' item should be focused.");142 EventUtils.sendKey("END", gDebugger);143 is(gVariablesView.getFocusedItem().name, "__proto__",144 "The '__proto__' item should be focused.");145 EventUtils.sendKey("PAGE_DOWN", gDebugger);146 is(gVariablesView.getFocusedItem().name, "__proto__",147 "The '__proto__' item should be focused.");148 EventUtils.sendKey("END", gDebugger);149 is(gVariablesView.getFocusedItem().name, "__proto__",150 "The '__proto__' item should be focused.");151 // Part 6: Test that focus doesn't leave the variables view.152 EventUtils.sendKey("PAGE_UP", gDebugger);153 is(gVariablesView.getFocusedItem().name, "someProp5",154 "The 'someProp5' item should be focused.");155 EventUtils.sendKey("PAGE_UP", gDebugger);156 is(gVariablesView.getFocusedItem().name, "someProp0",157 "The 'someProp0' item should be focused.");158 EventUtils.sendKey("UP", gDebugger);159 is(gVariablesView.getFocusedItem().name, "someProp0",160 "The 'someProp0' item should be focused.");161 EventUtils.sendKey("UP", gDebugger);162 is(gVariablesView.getFocusedItem().name, "someProp0",163 "The 'someProp0' item should be focused.");164 EventUtils.sendKey("PAGE_DOWN", gDebugger);165 is(gVariablesView.getFocusedItem().name, "someProp5",166 "The 'someProp5' item should be focused.");167 EventUtils.sendKey("PAGE_DOWN", gDebugger);168 is(gVariablesView.getFocusedItem().name, "__proto__",169 "The '__proto__' item should be focused.");170 EventUtils.sendKey("PAGE_DOWN", gDebugger);171 is(gVariablesView.getFocusedItem().name, "__proto__",172 "The '__proto__' item should be focused.");173 EventUtils.sendKey("PAGE_DOWN", gDebugger);174 is(gVariablesView.getFocusedItem().name, "__proto__",175 "The '__proto__' item should be focused.");176 // Part 7: Test that random offsets don't occur in tandem with HOME/END.177 EventUtils.sendKey("HOME", gDebugger);178 is(gVariablesView.getFocusedItem().name, "someProp0",179 "The 'someProp0' item should be focused.");180 EventUtils.sendKey("DOWN", gDebugger);181 is(gVariablesView.getFocusedItem().name, "someProp1",182 "The 'someProp1' item should be focused.");183 EventUtils.sendKey("END", gDebugger);184 is(gVariablesView.getFocusedItem().name, "__proto__",185 "The '__proto__' item should be focused.");186 EventUtils.sendKey("DOWN", gDebugger);187 is(gVariablesView.getFocusedItem().name, "__proto__",188 "The '__proto__' item should be focused.");189 // Part 8: Test that the RIGHT key expands elements as intended.190 EventUtils.sendKey("PAGE_UP", gDebugger);191 is(gVariablesView.getFocusedItem().name, "someProp5",192 "The 'someProp5' item should be focused.");193 is(gVariablesView.getFocusedItem().expanded, false,194 "The 'someProp5' item should not be expanded yet.");195 yield synthesizeKeyAndWaitForTick("VK_RIGHT", {});196 is(gVariablesView.getFocusedItem().name, "someProp5",197 "The 'someProp5' item should be focused.");198 is(gVariablesView.getFocusedItem().expanded, true,199 "The 'someProp5' item should now be expanded.");200 is(gVariablesView.getFocusedItem()._store.size, 9,201 "There should be 9 properties in the selected variable.");202 is(gVariablesView.getFocusedItem()._enumItems.length, 7,203 "There should be 7 enumerable properties in the selected variable.");204 is(gVariablesView.getFocusedItem()._nonEnumItems.length, 2,205 "There should be 2 non-enumerable properties in the selected variable.");206 yield waitForChildNodes(gVariablesView.getFocusedItem()._enum, 7);207 yield waitForChildNodes(gVariablesView.getFocusedItem()._nonenum, 2);208 EventUtils.sendKey("RIGHT", gDebugger);209 is(gVariablesView.getFocusedItem().name, "0",210 "The '0' item should be focused.");211 EventUtils.sendKey("RIGHT", gDebugger);212 is(gVariablesView.getFocusedItem().name, "0",213 "The '0' item should still be focused.");214 EventUtils.sendKey("PAGE_DOWN", gDebugger);215 is(gVariablesView.getFocusedItem().name, "5",216 "The '5' item should be focused.");217 is(gVariablesView.getFocusedItem().expanded, false,218 "The '5' item should not be expanded yet.");219 yield synthesizeKeyAndWaitForTick("VK_RIGHT", {});220 is(gVariablesView.getFocusedItem().name, "5",221 "The '5' item should be focused.");222 is(gVariablesView.getFocusedItem().expanded, true,223 "The '5' item should now be expanded.");224 is(gVariablesView.getFocusedItem()._store.size, 5,225 "There should be 5 properties in the selected variable.");226 is(gVariablesView.getFocusedItem()._enumItems.length, 3,227 "There should be 3 enumerable properties in the selected variable.");228 is(gVariablesView.getFocusedItem()._nonEnumItems.length, 2,229 "There should be 2 non-enumerable properties in the selected variable.");230 yield waitForChildNodes(gVariablesView.getFocusedItem()._enum, 3);231 yield waitForChildNodes(gVariablesView.getFocusedItem()._nonenum, 2);232 EventUtils.sendKey("RIGHT", gDebugger);233 is(gVariablesView.getFocusedItem().name, "0",234 "The '0' item should be focused.");235 EventUtils.sendKey("RIGHT", gDebugger);236 is(gVariablesView.getFocusedItem().name, "0",237 "The '0' item should still be focused.");238 EventUtils.sendKey("PAGE_DOWN", gDebugger);239 is(gVariablesView.getFocusedItem().name, "6",240 "The '6' item should be focused.");241 is(gVariablesView.getFocusedItem().expanded, false,242 "The '6' item should not be expanded yet.");243 yield synthesizeKeyAndWaitForTick("VK_RIGHT", {});244 is(gVariablesView.getFocusedItem().name, "6",245 "The '6' item should be focused.");246 is(gVariablesView.getFocusedItem().expanded, true,247 "The '6' item should now be expanded.");248 is(gVariablesView.getFocusedItem()._store.size, 3,249 "There should be 3 properties in the selected variable.");250 is(gVariablesView.getFocusedItem()._enumItems.length, 2,251 "There should be 2 enumerable properties in the selected variable.");252 is(gVariablesView.getFocusedItem()._nonEnumItems.length, 1,253 "There should be 1 non-enumerable properties in the selected variable.");254 yield waitForChildNodes(gVariablesView.getFocusedItem()._enum, 2);255 yield waitForChildNodes(gVariablesView.getFocusedItem()._nonenum, 1);256 EventUtils.sendKey("RIGHT", gDebugger);257 is(gVariablesView.getFocusedItem().name, "prop1",258 "The 'prop1' item should be focused.");259 EventUtils.sendKey("RIGHT", gDebugger);260 is(gVariablesView.getFocusedItem().name, "prop1",261 "The 'prop1' item should still be focused.");262 EventUtils.sendKey("PAGE_DOWN", gDebugger);263 is(gVariablesView.getFocusedItem().name, "someProp6",264 "The 'someProp6' item should be focused.");265 is(gVariablesView.getFocusedItem().expanded, false,266 "The 'someProp6' item should not be expanded yet.");267 // Part 9: Test that the RIGHT key collapses elements as intended.268 EventUtils.sendKey("LEFT", gDebugger);269 is(gVariablesView.getFocusedItem().name, "someProp6",270 "The 'someProp6' item should be focused.");271 EventUtils.sendKey("UP", gDebugger);272 is(gVariablesView.getFocusedItem().name, "__proto__",273 "The '__proto__' item should be focused.");274 EventUtils.sendKey("LEFT", gDebugger);275 is(gVariablesView.getFocusedItem().name, "someProp5",276 "The 'someProp5' item should be focused.");277 is(gVariablesView.getFocusedItem().expanded, true,278 "The '6' item should still be expanded.");279 EventUtils.sendKey("LEFT", gDebugger);280 is(gVariablesView.getFocusedItem().name, "someProp5",281 "The 'someProp5' item should still be focused.");282 is(gVariablesView.getFocusedItem().expanded, false,283 "The '6' item should still not be expanded anymore.");284 EventUtils.sendKey("LEFT", gDebugger);285 is(gVariablesView.getFocusedItem().name, "someProp5",286 "The 'someProp5' item should still be focused.");287 // Part 9: Test continuous navigation.288 EventUtils.sendKey("UP", gDebugger);289 is(gVariablesView.getFocusedItem().name, "someProp4",290 "The 'someProp4' item should be focused.");291 EventUtils.sendKey("UP", gDebugger);292 is(gVariablesView.getFocusedItem().name, "someProp3",293 "The 'someProp3' item should be focused.");294 EventUtils.sendKey("UP", gDebugger);295 is(gVariablesView.getFocusedItem().name, "someProp2",296 "The 'someProp2' item should be focused.");297 EventUtils.sendKey("UP", gDebugger);298 is(gVariablesView.getFocusedItem().name, "someProp1",299 "The 'someProp1' item should be focused.");300 EventUtils.sendKey("UP", gDebugger);301 is(gVariablesView.getFocusedItem().name, "someProp0",302 "The 'someProp0' item should be focused.");303 EventUtils.sendKey("PAGE_UP", gDebugger);304 is(gVariablesView.getFocusedItem().name, "someProp0",305 "The 'someProp0' item should be focused.");306 EventUtils.sendKey("PAGE_DOWN", gDebugger);307 is(gVariablesView.getFocusedItem().name, "someProp5",308 "The 'someProp5' item should be focused.");309 EventUtils.sendKey("DOWN", gDebugger);310 is(gVariablesView.getFocusedItem().name, "someProp6",311 "The 'someProp6' item should be focused.");312 EventUtils.sendKey("DOWN", gDebugger);313 is(gVariablesView.getFocusedItem().name, "someProp7",314 "The 'someProp7' item should be focused.");315 EventUtils.sendKey("DOWN", gDebugger);316 is(gVariablesView.getFocusedItem().name, "get",317 "The 'get' item should be focused.");318 EventUtils.sendKey("DOWN", gDebugger);319 is(gVariablesView.getFocusedItem().name, "set",320 "The 'set' item should be focused.");321 EventUtils.sendKey("DOWN", gDebugger);322 is(gVariablesView.getFocusedItem().name, "__proto__",323 "The '__proto__' item should be focused.");324 // Part 10: Test that BACKSPACE deletes items in the variables view.325 EventUtils.sendKey("BACK_SPACE", gDebugger);326 is(gVariablesView.getFocusedItem().name, "__proto__",327 "The '__proto__' variable should still be focused.");328 is(gVariablesView.getFocusedItem().value, "[object Object]",329 "The '__proto__' variable should not have an empty value.");330 is(gVariablesView.getFocusedItem().visible, false,331 "The '__proto__' variable should be hidden.");332 EventUtils.sendKey("UP", gDebugger);333 is(gVariablesView.getFocusedItem().name, "set",334 "The 'set' item should be focused.");335 is(gVariablesView.getFocusedItem().value, "[object Object]",336 "The 'set' item should not have an empty value.");337 is(gVariablesView.getFocusedItem().visible, true,338 "The 'set' item should be visible.");339 EventUtils.sendKey("BACK_SPACE", gDebugger);340 is(gVariablesView.getFocusedItem().name, "set",341 "The 'set' item should still be focused.");342 is(gVariablesView.getFocusedItem().value, "[object Object]",343 "The 'set' item should not have an empty value.");344 is(gVariablesView.getFocusedItem().visible, true,345 "The 'set' item should be visible.");346 is(gVariablesView.getFocusedItem().twisty, false,347 "The 'set' item should be disabled and have a hidden twisty.");348 EventUtils.sendKey("UP", gDebugger);349 is(gVariablesView.getFocusedItem().name, "get",350 "The 'get' item should be focused.");351 is(gVariablesView.getFocusedItem().value, "[object Object]",352 "The 'get' item should not have an empty value.");353 is(gVariablesView.getFocusedItem().visible, true,354 "The 'get' item should be visible.");355 EventUtils.sendKey("BACK_SPACE", gDebugger);356 is(gVariablesView.getFocusedItem().name, "get",357 "The 'get' item should still be focused.");358 is(gVariablesView.getFocusedItem().value, "[object Object]",359 "The 'get' item should not have an empty value.");360 is(gVariablesView.getFocusedItem().visible, true,361 "The 'get' item should be visible.");362 is(gVariablesView.getFocusedItem().twisty, false,363 "The 'get' item should be disabled and have a hidden twisty.");364 EventUtils.sendKey("UP", gDebugger);365 is(gVariablesView.getFocusedItem().name, "someProp7",366 "The 'someProp7' item should be focused.");367 is(gVariablesView.getFocusedItem().value, undefined,368 "The 'someProp7' variable should have an empty value.");369 is(gVariablesView.getFocusedItem().visible, true,370 "The 'someProp7' variable should be visible.");371 EventUtils.sendKey("BACK_SPACE", gDebugger);372 is(gVariablesView.getFocusedItem().name, "someProp7",373 "The 'someProp7' variable should still be focused.");374 is(gVariablesView.getFocusedItem().value, undefined,375 "The 'someProp7' variable should have an empty value.");376 is(gVariablesView.getFocusedItem().visible, false,377 "The 'someProp7' variable should be hidden.");378 // Part 11: Test that Ctrl-C copies the current item to the system clipboard379 gVariablesView.focusFirstVisibleItem();380 let copied = promise.defer();381 let expectedValue = gVariablesView.getFocusedItem().name382 + gVariablesView.getFocusedItem().separatorStr383 + gVariablesView.getFocusedItem().value;384 waitForClipboard(expectedValue, function setup() {385 EventUtils.synthesizeKey("C", { metaKey: true }, gDebugger);386 }, copied.resolve, copied.reject387 );388 try {389 yield copied.promise;390 ok(true,391 "Ctrl-C copied the selected item to the clipboard.");392 } catch (e) {393 ok(false,394 "Ctrl-C didn't copy the selected item to the clipboard.");395 }396 yield closeDebuggerAndFinish(gPanel);397 });398}399registerCleanupFunction(function () {400 gTab = null;401 gPanel = null;402 gDebugger = null;403 gVariablesView = null;404});405function synthesizeKeyAndWaitForElement(aKey, aModifiers, aSelector, aExistence) {406 EventUtils.synthesizeKey(aKey, aModifiers, gDebugger);407 return waitForElement(aSelector, aExistence);408}409function synthesizeKeyAndWaitForTick(aKey, aModifiers) {410 EventUtils.synthesizeKey(aKey, aModifiers, gDebugger);411 return waitForTick();412}413function waitForElement(aSelector, aExistence) {414 return waitForPredicate(() => {415 return !!gVariablesView._list.querySelector(aSelector) == aExistence;416 });417}418function waitForChildNodes(aTarget, aCount) {419 return waitForPredicate(() => {420 return aTarget.childNodes.length == aCount;421 });422}423function waitForPredicate(aPredicate, aInterval = 10) {424 let deferred = promise.defer();425 // Poll every few milliseconds until the element is retrieved.426 let count = 0;427 let intervalID = window.setInterval(() => {428 // Make sure we don't wait for too long.429 if (++count > 1000) {430 deferred.reject("Timed out while polling for the element.");431 window.clearInterval(intervalID);432 return;433 }434 // Check if the predicate condition is fulfilled.435 if (!aPredicate()) {436 return;437 }438 // We got the element, it's safe to callback.439 window.clearInterval(intervalID);440 deferred.resolve();441 }, aInterval);442 return deferred.promise;...

Full Screen

Full Screen

date-time-picker.js

Source:date-time-picker.js Github

copy

Full Screen

1import dayjs from 'dayjs/esm/index'2import customParseFormat from 'dayjs/plugin/customParseFormat'3import localeData from 'dayjs/plugin/localeData'4dayjs.extend(customParseFormat)5dayjs.extend(localeData)6window.dayjs = dayjs7export default (Alpine) => {8 Alpine.data('dateTimePickerFormComponent', ({9 displayFormat,10 firstDayOfWeek,11 format,12 isAutofocused,13 locale,14 maxDate,15 minDate,16 state,17 }) => {18 dayjs.locale(locale)19 return {20 daysInFocusedMonth: [],21 displayText: '',22 emptyDaysInFocusedMonth: [],23 focusedDate: null,24 focusedMonth: null,25 focusedYear: null,26 hours: null,27 maxDate,28 minDate,29 minutes: null,30 open: false,31 seconds: null,32 state,33 init: function () {34 this.maxDate = dayjs(this.maxDate)35 if (! this.maxDate.isValid()) this.maxDate = null36 this.minDate = dayjs(this.minDate)37 if (! this.minDate.isValid()) this.minDate = null38 let date = this.getSelectedDate() ?? dayjs()39 if (this.maxDate !== null && date.isAfter(this.maxDate)) date = null40 if (this.minDate !== null && date.isBefore(this.minDate)) date = null41 this.hour = date.hour()42 this.minute = date.minute()43 this.second = date.second()44 this.setDisplayText()45 if (isAutofocused) this.openPicker()46 this.$watch('focusedMonth', () => {47 this.focusedMonth = +this.focusedMonth48 if (this.focusedDate.month() === this.focusedMonth) return49 this.focusedDate = this.focusedDate.set('month', this.focusedMonth)50 })51 this.$watch('focusedYear', () => {52 this.focusedYear = Number.isInteger(+this.focusedYear) ? +this.focusedYear : dayjs().year()53 if (this.focusedDate.year() === this.focusedYear) return54 this.focusedDate = this.focusedDate.set('year', this.focusedYear)55 })56 this.$watch('focusedDate', () => {57 this.focusedMonth = this.focusedDate.month()58 this.focusedYear = this.focusedDate.year()59 this.setupDaysGrid()60 this.$nextTick(() => {61 this.evaluatePosition()62 })63 })64 this.$watch('hour', () => {65 let hour = +this.hour66 if (! Number.isInteger(hour)) {67 this.hour = dayjs().hour()68 } else if (hour > 23) {69 this.hour = 070 } else if (hour < 0) {71 this.hour = 2372 } else {73 this.hour = hour74 }75 let date = this.getSelectedDate()76 if (date === null) return77 this.setState(date.set('hour', this.hour))78 })79 this.$watch('minute', () => {80 let minute = +this.minute81 if (! Number.isInteger(minute)) {82 this.minute = dayjs().minute()83 } else if (minute > 59) {84 this.minute = 085 } else if (minute < 0) {86 this.minute = 5987 } else {88 this.minute = minute89 }90 let date = this.getSelectedDate()91 if (date === null) return92 this.setState(date.set('minute', this.minute))93 })94 this.$watch('second', () => {95 let second = +this.second96 if (! Number.isInteger(second)) {97 this.second = dayjs().second()98 } else if (second > 59) {99 this.second = 0100 } else if (second < 0) {101 this.second = 59102 } else {103 this.second = second104 }105 let date = this.getSelectedDate()106 if (date === null) return107 this.setState(date.set('second', this.second))108 })109 this.$watch('state', () => {110 let date = this.getSelectedDate() ?? dayjs()111 if (this.maxDate !== null && date.isAfter(this.maxDate)) date = null112 if (this.minDate !== null && date.isBefore(this.minDate)) date = null113 this.hour = date.hour()114 this.minute = date.minute()115 this.second = date.second()116 this.setDisplayText()117 })118 },119 clearState: function () {120 this.setState(null)121 this.closePicker()122 },123 closePicker: function () {124 this.open = false125 },126 dateIsDisabled: function (date) {127 if (this.maxDate && date.isAfter(this.maxDate)) return true128 if (this.minDate && date.isBefore(this.minDate)) return true129 return false130 },131 dayIsDisabled: function (day) {132 return this.dateIsDisabled(this.focusedDate.date(day))133 },134 dayIsSelected: function (day) {135 let selectedDate = this.getSelectedDate()136 if (selectedDate === null) return false137 return selectedDate.date() === day &&138 selectedDate.month() === this.focusedDate.month() &&139 selectedDate.year() === this.focusedDate.year()140 },141 dayIsToday: function (day) {142 let date = dayjs()143 return date.date() === day &&144 date.month() === this.focusedDate.month() &&145 date.year() === this.focusedDate.year()146 },147 evaluatePosition: function () {148 let availableHeight = window.innerHeight - this.$refs.button.offsetHeight149 let element = this.$refs.button150 while (element) {151 availableHeight -= element.offsetTop152 element = element.offsetParent153 }154 if (this.$refs.picker.offsetHeight <= availableHeight) {155 this.$refs.picker.style.bottom = 'auto'156 return157 }158 this.$refs.picker.style.bottom = `${this.$refs.button.offsetHeight}px`159 },160 focusPreviousDay: function () {161 this.focusedDate = this.focusedDate.subtract(1, 'day')162 },163 focusPreviousWeek: function () {164 this.focusedDate = this.focusedDate.subtract(1, 'week')165 },166 focusNextDay: function () {167 this.focusedDate = this.focusedDate.add(1, 'day')168 },169 focusNextWeek: function () {170 this.focusedDate = this.focusedDate.add(1, 'week')171 },172 getDayLabels: function () {173 const labels = dayjs.weekdaysShort()174 if (firstDayOfWeek === 0) {175 return labels176 }177 return [178 ...labels.slice(firstDayOfWeek),179 ...labels.slice(0, firstDayOfWeek),180 ]181 },182 getSelectedDate: function () {183 let date = dayjs(this.state, format)184 if (! date.isValid()) return null185 return date186 },187 openPicker: function () {188 this.focusedDate = this.getSelectedDate() ?? dayjs()189 this.setupDaysGrid()190 this.open = true191 this.$nextTick(() => {192 this.evaluatePosition()193 })194 },195 selectDate: function (day = null) {196 if (day) this.setFocusedDay(day)197 this.setState(this.focusedDate)198 },199 setDisplayText: function () {200 this.displayText = this.getSelectedDate() ? this.getSelectedDate().format(displayFormat) : ''201 },202 setupDaysGrid: function () {203 this.emptyDaysInFocusedMonth = Array.from({204 length: this.focusedDate.date(8 - firstDayOfWeek).day(),205 }, (_, i) => i + 1)206 this.daysInFocusedMonth = Array.from({207 length: this.focusedDate.daysInMonth(),208 }, (_, i) => i + 1)209 },210 setFocusedDay: function (day) {211 this.focusedDate = this.focusedDate.date(day)212 },213 setState: function (date) {214 if (date === null) {215 this.state = null216 this.setDisplayText()217 return218 } else {219 if (this.dateIsDisabled(date)) return220 }221 this.state = date222 .set('hour', this.hour)223 .set('minute', this.minute)224 .set('second', this.second)225 .format(format)226 this.setDisplayText()227 },228 togglePickerVisibility: function () {229 if (this.open) {230 this.closePicker()231 return232 }233 this.openPicker()234 },235 }236 })...

Full Screen

Full Screen

app.js

Source:app.js Github

copy

Full Screen

1(function(){2 let MenuTpl =3 '<div id="menu_{{_namespace}}_{{_name}}" class="menu{{#align}} align-{{align}}{{/align}}">' +4 '<div class="head"><span>{{{title}}}</span></div>' +5 '<div class="menu-items">' + 6 '{{#elements}}' +7 '<div class="menu-item {{#selected}}selected{{/selected}}">' +8 '{{{label}}}{{#isSlider}} : &lt;{{{sliderLabel}}}&gt;{{/isSlider}}' +9 '</div>' +10 '{{/elements}}' +11 '</div>'+12 '</div>' +13 '</div>'14 ;15 window.ESX_MENU = {};16 ESX_MENU.ResourceName = 'esx_menu_default';17 ESX_MENU.opened = {};18 ESX_MENU.focus = [];19 ESX_MENU.pos = {};20 ESX_MENU.open = function(namespace, name, data) {21 if (typeof ESX_MENU.opened[namespace] == 'undefined') {22 ESX_MENU.opened[namespace] = {};23 }24 if (typeof ESX_MENU.opened[namespace][name] != 'undefined') {25 ESX_MENU.close(namespace, name);26 }27 if (typeof ESX_MENU.pos[namespace] == 'undefined') {28 ESX_MENU.pos[namespace] = {};29 }30 for (let i=0; i<data.elements.length; i++) {31 if (typeof data.elements[i].type == 'undefined') {32 data.elements[i].type = 'default';33 }34 }35 data._index = ESX_MENU.focus.length;36 data._namespace = namespace;37 data._name = name;38 for (let i=0; i<data.elements.length; i++) {39 data.elements[i]._namespace = namespace;40 data.elements[i]._name = name;41 }42 ESX_MENU.opened[namespace][name] = data;43 ESX_MENU.pos [namespace][name] = 0;44 for (let i=0; i<data.elements.length; i++) {45 if (data.elements[i].selected) {46 ESX_MENU.pos[namespace][name] = i;47 } else {48 data.elements[i].selected = false;49 }50 }51 ESX_MENU.focus.push({52 namespace: namespace,53 name : name54 });55 56 ESX_MENU.render();57 $('#menu_' + namespace + '_' + name).find('.menu-item.selected')[0].scrollIntoView();58 };59 ESX_MENU.close = function(namespace, name) {60 61 delete ESX_MENU.opened[namespace][name];62 for (let i=0; i<ESX_MENU.focus.length; i++) {63 if (ESX_MENU.focus[i].namespace == namespace && ESX_MENU.focus[i].name == name) {64 ESX_MENU.focus.splice(i, 1);65 break;66 }67 }68 ESX_MENU.render();69 };70 ESX_MENU.render = function() {71 let menuContainer = document.getElementById('menus');72 let focused = ESX_MENU.getFocused();73 menuContainer.innerHTML = '';74 $(menuContainer).hide();75 for (let namespace in ESX_MENU.opened) {76 for (let name in ESX_MENU.opened[namespace]) {77 let menuData = ESX_MENU.opened[namespace][name];78 let view = JSON.parse(JSON.stringify(menuData));79 for (let i=0; i<menuData.elements.length; i++) {80 let element = view.elements[i];81 switch (element.type) {82 case 'default' : break;83 case 'slider' : {84 element.isSlider = true;85 element.sliderLabel = (typeof element.options == 'undefined') ? element.value : element.options[element.value];86 break;87 }88 default : break;89 }90 if (i == ESX_MENU.pos[namespace][name]) {91 element.selected = true;92 }93 }94 let menu = $(Mustache.render(MenuTpl, view))[0];95 $(menu).hide();96 menuContainer.appendChild(menu);97 }98 }99 if (typeof focused != 'undefined') {100 $('#menu_' + focused.namespace + '_' + focused.name).show();101 }102 $(menuContainer).show();103 };104 ESX_MENU.submit = function(namespace, name, data) {105 $.post('http://' + ESX_MENU.ResourceName + '/menu_submit', JSON.stringify({106 _namespace: namespace,107 _name : name,108 current : data,109 elements : ESX_MENU.opened[namespace][name].elements110 }));111 };112 ESX_MENU.cancel = function(namespace, name) {113 $.post('http://' + ESX_MENU.ResourceName + '/menu_cancel', JSON.stringify({114 _namespace: namespace,115 _name : name116 }));117 };118 ESX_MENU.change = function(namespace, name, data) {119 $.post('http://' + ESX_MENU.ResourceName + '/menu_change', JSON.stringify({120 _namespace: namespace,121 _name : name,122 current : data,123 elements : ESX_MENU.opened[namespace][name].elements124 }));125 };126 ESX_MENU.getFocused = function() {127 return ESX_MENU.focus[ESX_MENU.focus.length - 1];128 };129 window.onData = (data) => {130 switch (data.action) {131 case 'openMenu': {132 ESX_MENU.open(data.namespace, data.name, data.data);133 break;134 }135 case 'closeMenu': {136 ESX_MENU.close(data.namespace, data.name);137 break;138 }139 case 'controlPressed': {140 switch (data.control) {141 case 'ENTER': {142 let focused = ESX_MENU.getFocused();143 if (typeof focused != 'undefined') {144 let menu = ESX_MENU.opened[focused.namespace][focused.name];145 let pos = ESX_MENU.pos[focused.namespace][focused.name];146 let elem = menu.elements[pos];147 if (menu.elements.length > 0) {148 ESX_MENU.submit(focused.namespace, focused.name, elem);149 }150 }151 break;152 }153 case 'BACKSPACE': {154 let focused = ESX_MENU.getFocused();155 if (typeof focused != 'undefined') {156 ESX_MENU.cancel(focused.namespace, focused.name);157 }158 break;159 }160 case 'TOP': {161 let focused = ESX_MENU.getFocused();162 if (typeof focused != 'undefined') {163 let menu = ESX_MENU.opened[focused.namespace][focused.name];164 let pos = ESX_MENU.pos[focused.namespace][focused.name];165 if (pos > 0) {166 ESX_MENU.pos[focused.namespace][focused.name]--;167 } else {168 ESX_MENU.pos[focused.namespace][focused.name] = menu.elements.length - 1;169 }170 let elem = menu.elements[ESX_MENU.pos[focused.namespace][focused.name]];171 for (let i=0; i<menu.elements.length; i++) {172 if (i == ESX_MENU.pos[focused.namespace][focused.name]) {173 menu.elements[i].selected = true;174 } else {175 menu.elements[i].selected = false;176 }177 }178 ESX_MENU.change(focused.namespace, focused.name, elem);179 ESX_MENU.render();180 $('#menu_' + focused.namespace + '_' + focused.name).find('.menu-item.selected')[0].scrollIntoView();181 }182 break;183 }184 case 'DOWN' : {185 let focused = ESX_MENU.getFocused();186 if (typeof focused != 'undefined') {187 let menu = ESX_MENU.opened[focused.namespace][focused.name];188 let pos = ESX_MENU.pos[focused.namespace][focused.name];189 let length = menu.elements.length;190 if (pos < length - 1) {191 ESX_MENU.pos[focused.namespace][focused.name]++;192 } else {193 ESX_MENU.pos[focused.namespace][focused.name] = 0;194 }195 let elem = menu.elements[ESX_MENU.pos[focused.namespace][focused.name]];196 for (let i=0; i<menu.elements.length; i++) {197 if (i == ESX_MENU.pos[focused.namespace][focused.name]) {198 menu.elements[i].selected = true;199 } else {200 menu.elements[i].selected = false;201 }202 }203 ESX_MENU.change(focused.namespace, focused.name, elem);204 ESX_MENU.render();205 $('#menu_' + focused.namespace + '_' + focused.name).find('.menu-item.selected')[0].scrollIntoView();206 }207 break;208 }209 case 'LEFT' : {210 let focused = ESX_MENU.getFocused();211 if (typeof focused != 'undefined') {212 let menu = ESX_MENU.opened[focused.namespace][focused.name];213 let pos = ESX_MENU.pos[focused.namespace][focused.name];214 let elem = menu.elements[pos];215 switch(elem.type) {216 case 'default': break;217 case 'slider': {218 let min = (typeof elem.min == 'undefined') ? 0 : elem.min;219 if (elem.value > min) {220 elem.value--;221 ESX_MENU.change(focused.namespace, focused.name, elem);222 }223 ESX_MENU.render();224 break;225 }226 default: break;227 }228 $('#menu_' + focused.namespace + '_' + focused.name).find('.menu-item.selected')[0].scrollIntoView();229 }230 break;231 }232 case 'RIGHT' : {233 let focused = ESX_MENU.getFocused();234 if (typeof focused != 'undefined') {235 let menu = ESX_MENU.opened[focused.namespace][focused.name];236 let pos = ESX_MENU.pos[focused.namespace][focused.name];237 let elem = menu.elements[pos];238 switch(elem.type) {239 case 'default': break;240 case 'slider': {241 if (typeof elem.options != 'undefined' && elem.value < elem.options.length - 1) {242 elem.value++;243 ESX_MENU.change(focused.namespace, focused.name, elem);244 }245 if (typeof elem.max != 'undefined' && elem.value < elem.max) {246 elem.value++;247 ESX_MENU.change(focused.namespace, focused.name, elem);248 }249 ESX_MENU.render();250 break;251 }252 default: break;253 }254 $('#menu_' + focused.namespace + '_' + focused.name).find('.menu-item.selected')[0].scrollIntoView();255 }256 break;257 }258 default : break;259 }260 break;261 }262 }263 };264 window.onload = function(e){265 window.addEventListener('message', (event) => {266 onData(event.data);267 });268 };...

Full Screen

Full Screen

companyReducers.js

Source:companyReducers.js Github

copy

Full Screen

1import { companyConstants } from '../constants';2export const companyReducers = (state = {3 pages: [4 'dispatch',5 'customer',6 'carrier',7 'load board',8 'invoice'9 ],10 selectedPageIndex: -1,11 mainCompanyScreenFocused: true,12 dispatchScreenFocused: false,13 customerScreenFocused: false,14 carrierScreenFocused: false,15 loadBoardScreenFocused: false,16 invoiceScreenFocused: false,17}, action) => {18 switch (action.type) {19 case companyConstants.SET_PAGES:20 state = {21 ...state,22 pages: action.payload23 }24 break;25 case companyConstants.SET_SELECTED_PAGE_INDEX:26 state = {27 ...state,28 selectedPageIndex: action.payload29 }30 break;31 case companyConstants.SET_MAIN_COMPANY_SCREEN_FOCUSED:32 state = {33 ...state,34 mainCompanyScreenFocused: action.payload,35 dispatchScreenFocused: action.payload ? false : state.dispatchScreenFocused,36 customerScreenFocused: action.payload ? false : state.customerScreenFocused,37 carrierScreenFocused: action.payload ? false : state.carrierScreenFocused,38 loadBoardScreenFocused: action.payload ? false : state.loadBoardScreenFocused,39 invoiceScreenFocused: action.payload ? false : state.invoiceScreenFocused,40 }41 break;42 case companyConstants.SET_DISPATCH_SCREEN_FOCUSED:43 state = {44 ...state,45 dispatchScreenFocused: action.payload,46 mainCompanyScreenFocused: action.payload ? false : state.mainCompanyScreenFocused,47 customerScreenFocused: action.payload ? false : state.customerScreenFocused,48 carrierScreenFocused: action.payload ? false : state.carrierScreenFocused,49 loadBoardScreenFocused: action.payload ? false : state.loadBoardScreenFocused,50 invoiceScreenFocused: action.payload ? false : state.invoiceScreenFocused,51 }52 break;53 case companyConstants.SET_CUSTOMER_SCREEN_FOCUSED:54 state = {55 ...state,56 customerScreenFocused: action.payload,57 mainCompanyScreenFocused: action.payload ? false : state.mainCompanyScreenFocused,58 dispatchScreenFocused: action.payload ? false : state.dispatchScreenFocused,59 carrierScreenFocused: action.payload ? false : state.carrierScreenFocused,60 loadBoardScreenFocused: action.payload ? false : state.loadBoardScreenFocused,61 invoiceScreenFocused: action.payload ? false : state.invoiceScreenFocused,62 }63 break;64 case companyConstants.SET_CARRIER_SCREEN_FOCUSED:65 state = {66 ...state,67 carrierScreenFocused: action.payload,68 mainCompanyScreenFocused: action.payload ? false : state.mainCompanyScreenFocused,69 dispatchScreenFocused: action.payload ? false : state.dispatchScreenFocused,70 customerScreenFocused: action.payload ? false : state.customerScreenFocused,71 loadBoardScreenFocused: action.payload ? false : state.loadBoardScreenFocused,72 invoiceScreenFocused: action.payload ? false : state.invoiceScreenFocused,73 }74 break;75 case companyConstants.SET_LOAD_BOARD_SCREEN_FOCUSED:76 state = {77 ...state,78 loadBoardScreenFocused: action.payload,79 mainCompanyScreenFocused: action.payload ? false : state.mainCompanyScreenFocused,80 dispatchScreenFocused: action.payload ? false : state.dispatchScreenFocused,81 customerScreenFocused: action.payload ? false : state.customerScreenFocused,82 carrierScreenFocused: action.payload ? false : state.carrierScreenFocused,83 invoiceScreenFocused: action.payload ? false : state.invoiceScreenFocused,84 }85 break;86 case companyConstants.SET_INVOICE_SCREEN_FOCUSED:87 state = {88 ...state,89 invoiceScreenFocused: action.payload,90 mainCompanyScreenFocused: action.payload ? false : state.mainCompanyScreenFocused,91 dispatchScreenFocused: action.payload ? false : state.dispatchScreenFocused,92 customerScreenFocused: action.payload ? false : state.customerScreenFocused,93 carrierScreenFocused: action.payload ? false : state.carrierScreenFocused,94 loadBoardScreenFocused: action.payload ? false : state.loadBoardScreenFocused,95 }96 break;97 default:98 break;99 }100 return state;...

Full Screen

Full Screen

adminReducers.js

Source:adminReducers.js Github

copy

Full Screen

1import { adminConstants } from '../constants';2export const adminReducers = (state = {3 pages: [ 4 'admin customer',5 'admin carrier',6 'reports',7 'setup company'8 ],9 selectedPageIndex: -1,10 mainAdminScreenFocused: true, 11 customerScreenFocused: false,12 carrierScreenFocused: false,13 reportsScreenFocused: false,14 setupCompanyScreenFocused: false,15}, action) => {16 switch (action.type) {17 case adminConstants.SET_PAGES:18 state = {19 ...state,20 pages: action.payload21 }22 break;23 case adminConstants.SET_SELECTED_PAGE_INDEX:24 state = {25 ...state,26 selectedPageIndex: action.payload27 }28 break;29 case adminConstants.SET_MAIN_ADMIN_SCREEN_FOCUSED:30 state = {31 ...state,32 mainAdminScreenFocused: action.payload, 33 customerScreenFocused: action.payload ? false : state.customerScreenFocused,34 carrierScreenFocused: action.payload ? false : state.carrierScreenFocused,35 reportsScreenFocused: action.payload ? false : state.reportsScreenFocused,36 setupCompanyScreenFocused: action.payload ? false : state.setupCompanyScreenFocused,37 }38 break; 39 case adminConstants.SET_CUSTOMER_SCREEN_FOCUSED:40 state = {41 ...state,42 customerScreenFocused: action.payload,43 mainAdminScreenFocused: action.payload ? false : state.mainAdminScreenFocused, 44 carrierScreenFocused: action.payload ? false : state.carrierScreenFocused,45 reportsScreenFocused: action.payload ? false : state.reportsScreenFocused,46 setupCompanyScreenFocused: action.payload ? false : state.setupCompanyScreenFocused,47 }48 break;49 case adminConstants.SET_CARRIER_SCREEN_FOCUSED:50 state = {51 ...state,52 carrierScreenFocused: action.payload,53 mainAdminScreenFocused: action.payload ? false : state.mainAdminScreenFocused, 54 customerScreenFocused: action.payload ? false : state.customerScreenFocused,55 reportsScreenFocused: action.payload ? false : state.reportsScreenFocused,56 setupCompanyScreenFocused: action.payload ? false : state.setupCompanyScreenFocused,57 }58 break;59 case adminConstants.SET_REPORTS_SCREEN_FOCUSED:60 state = {61 ...state,62 reportsScreenFocused: action.payload,63 mainAdminScreenFocused: action.payload ? false : state.mainAdminScreenFocused, 64 customerScreenFocused: action.payload ? false : state.customerScreenFocused,65 carrierScreenFocused: action.payload ? false : state.carrierScreenFocused,66 setupCompanyScreenFocused: action.payload ? false : state.setupCompanyScreenFocused,67 }68 break;69 case adminConstants.SET_SETUP_COMPANY_SCREEN_FOCUSED:70 state = {71 ...state,72 setupCompanyScreenFocused: action.payload,73 mainAdminScreenFocused: action.payload ? false : state.mainAdminScreenFocused, 74 customerScreenFocused: action.payload ? false : state.customerScreenFocused,75 carrierScreenFocused: action.payload ? false : state.carrierScreenFocused,76 reportsScreenFocused: action.payload ? false : state.reportsScreenFocused,77 }78 break;79 default:80 break;81 }82 return state;...

Full Screen

Full Screen

focused.jsx

Source:focused.jsx Github

copy

Full Screen

1import * as style from "./style/focusedStyle";2import FocusedTitle from "./focusedTitle"3import FocusedHistory from "./focusedHistory";4import FocusedProfile from "./focusedProfile"5//Extends Main6export default function Focused({focused, setFocused, locationHierarchy, rawData, profileChanges}) {7 try {8 //Disables focused for LAS and DID items as they have no individual profiles//9 if (!focused[0] || focused[1] === "las" || focused[1] === "did") return <div></div>10 11 let focusedItem = rawData[focused[1]].filter(x => x.profile === focused[0])[0]12 let profileHistory = profileChanges.filter(x => focusedItem.pkid === x.pkid)[0]13 return (14 <div style={style.container}>15 <FocusedTitle16 style = {style}17 setFocused = {setFocused} 18 focusedItem = {focusedItem} 19 locationHierarchy = {locationHierarchy}/>20 21 <FocusedProfile22 style = {style}23 focusedItem = {focusedItem}/>24 25 <FocusedHistory style={style} profileHistory={profileHistory}/>26 </div>27 )28 } catch { // Catches non-existent item if removed from api while focused //29 return <div></div>30 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', () => {2 it('Does not do much!', () => {3 cy.pause()4 cy.contains('type').click()5 cy.url().should('include', '/commands/actions')6 cy.get('.action-email')7 .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1it('focused', () => {2 cy.get('.action-focus').focus()3 .should('have.class', 'focus')4 .prev().should('have.attr', 'style', 'color: orange;')5})6it('blur', () => {7 cy.get('.action-blur').type('About to blur').blur()8 .should('have.class', 'error')9 .prev().should('have.attr', 'style', 'color: red;')10})11it('clear', () => {12 cy.get('.action-clear').type('Clear this text')13 .should('have.value', 'Clear this text')14 .clear()15 .should('have.value', '')16})17it('submit', () => {18 cy.get('.action-form')19 .find('[type="text"]').type('HALFOFF')20 cy.get('.action-form').submit()21 .next().should('contain', 'Your form has been submitted!')22})23it('click', () => {24 cy.get('.action-btn').click()

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Cypress', () => {2 it('is awesome', () => {3 cy.focused()4 .should('have.class', 'home-list')5 .prev()6 .should('have.class', 'banner')7 })8})9describe('Cypress', () => {10 it('is awesome', () => {11 cy.focused()12 .should('have.class', 'home-list')13 .prev()14 .should('have.class', 'banner')15 })16})17describe('Cypress', () => {18 it('is awesome', () => {19 cy.focused()20 .should('have.class', 'home-list')21 .prev()22 .should('have.class', 'banner')23 })24})25describe('Cypress', () => {26 it('is awesome', () => {27 cy.focused()28 .should('have.class', 'home-list')29 .prev()30 .should('have.class', 'banner')31 })32})33describe('Cypress', () => {34 it('is awesome', () => {35 cy.focused()36 .should('have.class', 'home-list')37 .prev()38 .should('have.class', 'banner')39 })40})41describe('Cypress', () => {42 it('is awesome', () => {43 cy.focused()44 .should('have.class', 'home-list')45 .prev()46 .should('have.class', 'banner')47 })48})49describe('Cypress', () =>

Full Screen

Using AI Code Generation

copy

Full Screen

1it('should focus on the correct element', () => {2 cy.focused().should('have.class', 'action-email')3 cy.get('.action-focus').focus()4 .should('have.class', 'focus')5 .prev().should('have.attr', 'style', 'color: orange;')6})7it('should blur off the element', () => {8 cy.get('.action-blur').type('About to blur').blur()9 .should('have.class', 'error')10 .prev().should('have.attr', 'style', 'color: red;')11})12it('should clear an input or textarea element', () => {13 cy.get('.action-clear').type('Clear this text')14 .should('have.value', 'Clear this text')15 .clear()16 .should('have.value', '')17})18it('should submit a form', () => {19 cy.get('[type="text"]').type('HALFOFF')20 cy.get('[type="checkbox"]').check()21 cy.get('[type="submit"]').click()22 cy.get('#yourCode').should('contain', 'Your form has been submitted!')23})24it('should type into a DOM element', () => {25 cy.get('.action-email')26 .type('

Full Screen

Using AI Code Generation

copy

Full Screen

1it('should focus on the input', () => {2 cy.visit('/')3 cy.focused()4 .should('have.class', 'new-todo')5})6Cypress.Commands.add('focused', { prevSubject: 'optional' }, (subject, options) => {7 .wrap(subject, options)8 .focused()9})

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('test', () => {2 it('should work', () => {3 cy.get('a').contains('type').focus()4 })5})6cy.focused().should('have.attr', 'id', 'search')7cy.focused().should('have.id', 'search')8cy.focused().should('have.attr', 'id', 'search').should('have.id', 'search')9cy.focused().should('have.attr', 'id', 'search').should('have.attr', 'id', 'search')

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress automation tests on LambdaTest cloud grid

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

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful