How to use createCursor method in Playwright Internal

Best JavaScript code snippet using playwright-internal

PokemonTeamScene.js

Source:PokemonTeamScene.js Github

copy

Full Screen

...161 strokeThickness: 1.2,162 })163 .setDepth(12);164 // cursor165 this.createCursor(120, 280, "normal");166 this.currentSelectedPokemonIndex = 0;167 }168 createPokemonInfo(index, y) {169 // pokemon icon170 this[`pokemonIcon${index}`] = this.add171 .image(330, y + 30, `pokemon-icon-${index + 1}`)172 .setScale(4)173 .setDepth(13);174 //名字175 this[`pokemonName${index}`] = this.add176 .text(177 370,178 y + 15,179 this.pokemonTeamList[index].zh_Hant_name ||180 this.pokemonTeamList[index].name,181 {182 font: "28px monospace",183 color: "#fff",184 }185 )186 .setDepth(13)187 .setShadow(3, 1, "#000", 2, true, true);188 //等級189 this[`pokemonLevel${index}`] = this.add190 .text(380, y + 40, `Lv${this.pokemonTeamList[index].level}`, {191 font: "30px monospace",192 color: "#fff",193 })194 .setDepth(13)195 .setShadow(3.5, 1, "#000", 2, true, true);196 // HP197 this[`pokemonHp${index}`] = this.add198 .image(550, y + 25, "hp-bar-container")199 .setDepth(13);200 this[`pokemonHpBar${index}`] = this.add201 .image(545, y + 24, "hp-bar")202 .setOrigin(0)203 .setScale(1.2)204 .setDepth(13);205 this[`pokemonHpBar${index}`].displayWidth =206 147 *207 (this.pokemonTeamList[index].currentHp /208 this.pokemonTeamList[index].maxHp);209 this[`pokemonHpBarText${index}`] = this.add210 .text(211 600,212 y + 40,213 `${Math.floor(this.pokemonTeamList[index].currentHp)}/${214 this.pokemonTeamList[index].maxHp215 }`,216 {217 font: "30px monospace",218 color: "#fff",219 }220 )221 .setDepth(13)222 .setShadow(3.5, 1, "#000", 2, true, true);223 }224 createCursor(x, y, type) {225 if (type === "normal") {226 this.hand = this.add227 .image(x, y, "hand-up")228 .setDepth(14)229 .setDisplaySize(80, 80);230 this.tweens.add({231 targets: this.hand,232 y: y + 5,233 yoyo: true,234 duration: 300,235 repeat: -1,236 ease: "Sine.easeInOut",237 });238 }239 if (type === "switch") {240 this.switchHand = this.add241 .image(x, y, "hand-up")242 .setDepth(14)243 .setDisplaySize(80, 80);244 this.tweens.add({245 targets: this.switchHand,246 y: y + 5,247 yoyo: true,248 duration: 300,249 repeat: -1,250 ease: "Sine.easeInOut",251 });252 }253 }254 updateSelected() {255 // up256 if (257 Phaser.Input.Keyboard.JustDown(this.cursors.up) ||258 Phaser.Input.Keyboard.JustDown(this.keyW)259 ) {260 if (261 (this.currentSelectedPokemonIndex === 0 && !this.isSwitchPokemon) ||262 (this.currentSelectedPokemonIndex === 1 && !this.isSwitchPokemon)263 ) {264 return;265 }266 if (this.currentSelectedPokemonIndex === 2 && !this.isSwitchPokemon) {267 this.hand.destroy();268 this.createCursor(700, 120, "normal");269 this.currentSelectedPokemonIndex = 1;270 return;271 }272 if (this.switchPokemonIndex === 2 && this.isSwitchPokemon) {273 if (this.switchHand) this.switchHand.destroy();274 this.createCursor(650, 120, "switch");275 this.switchPokemonIndex = 1;276 this.switchPokemonSprite = this[`pokemonIcon1`].texture.key;277 return;278 }279 if (this.currentSelectedPokemonIndex === 3 && !this.isSwitchPokemon) {280 this.hand.destroy();281 this.createCursor(700, 210, "normal");282 this.currentSelectedPokemonIndex = 2;283 return;284 }285 if (this.switchPokemonIndex === 3 && this.isSwitchPokemon) {286 if (this.switchHand) this.switchHand.destroy();287 this.createCursor(650, 210, "switch");288 this.switchPokemonIndex = 2;289 this.switchPokemonSprite = this[`pokemonIcon2`].texture.key;290 return;291 }292 if (this.currentSelectedPokemonIndex === 4 && !this.isSwitchPokemon) {293 this.hand.destroy();294 this.createCursor(700, 300, "normal");295 this.currentSelectedPokemonIndex = 3;296 return;297 }298 if (this.switchPokemonIndex === 4 && this.isSwitchPokemon) {299 if (this.switchHand) this.switchHand.destroy();300 this.createCursor(650, 300, "switch");301 this.switchPokemonIndex = 3;302 this.switchPokemonSprite = this[`pokemonIcon3`].texture.key;303 return;304 }305 if (this.currentSelectedPokemonIndex === 5 && !this.isSwitchPokemon) {306 this.hand.destroy();307 this.createCursor(700, 390, "normal");308 this.currentSelectedPokemonIndex = 4;309 return;310 }311 if (this.switchPokemonIndex === 5 && this.isSwitchPokemon) {312 if (this.switchHand) this.switchHand.destroy();313 this.createCursor(650, 390, "switch");314 this.switchPokemonIndex = 4;315 this.switchPokemonSprite = this[`pokemonIcon4`].texture.key;316 return;317 }318 if (this.currentSelectedPokemonIndex === -1 && !this.isSwitchPokemon) {319 this.hand.destroy();320 this.createCursor(700, 480, "normal");321 this.currentSelectedPokemonIndex = 5;322 return;323 }324 }325 // down326 if (327 Phaser.Input.Keyboard.JustDown(this.cursors.down) ||328 Phaser.Input.Keyboard.JustDown(this.keyS)329 ) {330 if (331 (this.currentSelectedPokemonIndex === 0 && !this.isSwitchPokemon) ||332 (this.currentSelectedPokemonIndex === -1 && !this.isSwitchPokemon)333 ) {334 return;335 }336 if (this.currentSelectedPokemonIndex === 1 && !this.isSwitchPokemon) {337 this.hand.destroy();338 this.createCursor(700, 210, "normal");339 this.currentSelectedPokemonIndex = 2;340 return;341 }342 if (this.switchPokemonIndex === 1 && this.isSwitchPokemon) {343 if (this.switchHand) this.switchHand.destroy();344 this.createCursor(650, 210, "switch");345 this.switchPokemonIndex = 2;346 this.switchPokemonSprite = this[`pokemonIcon2`].texture.key;347 return;348 }349 if (this.currentSelectedPokemonIndex === 2 && !this.isSwitchPokemon) {350 this.hand.destroy();351 this.createCursor(700, 300, "normal");352 this.currentSelectedPokemonIndex = 3;353 return;354 }355 if (this.switchPokemonIndex === 2 && this.isSwitchPokemon) {356 if (this.switchHand) this.switchHand.destroy();357 this.createCursor(650, 300, "switch");358 this.switchPokemonIndex = 3;359 this.switchPokemonSprite = this[`pokemonIcon3`].texture.key;360 return;361 }362 if (this.currentSelectedPokemonIndex === 3 && !this.isSwitchPokemon) {363 this.hand.destroy();364 this.createCursor(700, 390, "normal");365 this.currentSelectedPokemonIndex = 4;366 return;367 }368 if (this.switchPokemonIndex === 3 && this.isSwitchPokemon) {369 if (this.switchHand) this.switchHand.destroy();370 this.createCursor(650, 390, "switch");371 this.switchPokemonIndex = 4;372 this.switchPokemonSprite = this[`pokemonIcon4`].texture.key;373 return;374 }375 if (this.currentSelectedPokemonIndex === 4 && !this.isSwitchPokemon) {376 this.hand.destroy();377 this.createCursor(700, 480, "normal");378 this.currentSelectedPokemonIndex = 5;379 return;380 }381 if (this.switchPokemonIndex === 4 && this.isSwitchPokemon) {382 if (this.switchHand) this.switchHand.destroy();383 this.createCursor(650, 480, "switch");384 this.switchPokemonIndex = 5;385 this.switchPokemonSprite = this[`pokemonIcon5`].texture.key;386 return;387 }388 if (this.currentSelectedPokemonIndex === 5 && !this.isSwitchPokemon) {389 this.hand.destroy();390 this.createCursor(700, 570, "normal");391 this.currentSelectedPokemonIndex = -1;392 return;393 }394 }395 // right396 if (397 Phaser.Input.Keyboard.JustDown(this.cursors.right) ||398 Phaser.Input.Keyboard.JustDown(this.keyD)399 ) {400 if (this.currentSelectedPokemonIndex !== 0 && !this.isSwitchPokemon)401 return;402 if (!this.isSwitchPokemon) {403 this.hand.destroy();404 this.createCursor(700, 120, "normal");405 this.currentSelectedPokemonIndex = 1;406 } else {407 if (this.switchHand) this.switchHand.destroy();408 this.createCursor(650, 120, "switch");409 this.switchPokemonSprite = this[`pokemonIcon1`].texture.key;410 this.switchPokemonIndex = 1;411 }412 }413 // left414 if (415 Phaser.Input.Keyboard.JustDown(this.cursors.left) ||416 Phaser.Input.Keyboard.JustDown(this.keyA)417 ) {418 if (this.currentSelectedPokemonIndex === 0 && !this.isSwitchPokemon)419 return;420 if (!this.isSwitchPokemon) {421 this.hand.destroy();422 this.createCursor(120, 280, "normal");423 this.currentSelectedPokemonIndex = 0;424 } else {425 if (this.switchHand) this.switchHand.destroy();426 this.createCursor(180, 280, "switch");427 this.switchPokemonSprite = this.currentUsePokemonIcon.texture.key;428 this.switchPokemonIndex = 0;429 }430 }431 // enter/space432 if (433 Phaser.Input.Keyboard.JustDown(this.keySpace) ||434 Phaser.Input.Keyboard.JustDown(this.keyEnter)435 ) {436 if (this.currentSelectedPokemonIndex === -1) {437 this.endEditPokemonTeam();438 return;439 }440 this.isSwitchPokemon = true;441 if (this.currentSelectedPokemonIndex === 0 && !this.switchHand) {442 this.createCursor(180, 280, "switch");443 // find current selected pokemon image index444 // this.currentUsePokemonIcon.texture.key445 // this.switchPokemonSprite = this.currentUsePokemonIcon.texture.key;446 this.switchPokemonIndex = 0;447 return;448 }449 if (this.currentSelectedPokemonIndex === 1 && !this.switchHand) {450 this.createCursor(650, 120, "switch");451 // this.switchPokemonSprite = this[`pokemonIcon1`].texture.key;452 this.switchPokemonIndex = 1;453 return;454 }455 if (this.currentSelectedPokemonIndex === 2 && !this.switchHand) {456 this.createCursor(650, 210, "switch");457 // this.switchPokemonSprite = this[`pokemonIcon2`].texture.key;458 this.switchPokemonIndex = 2;459 return;460 }461 if (this.currentSelectedPokemonIndex === 3 && !this.switchHand) {462 this.createCursor(650, 300, "switch");463 // this.switchPokemonSprite = this[`pokemonIcon3`].texture.key;464 this.switchPokemonIndex = 3;465 return;466 }467 if (this.currentSelectedPokemonIndex === 4 && !this.switchHand) {468 this.createCursor(650, 390, "switch");469 // this.switchPokemonSprite = this[`pokemonIcon4`].texture.key;470 this.switchPokemonIndex = 4;471 return;472 }473 if (this.currentSelectedPokemonIndex === 5 && !this.switchHand) {474 this.createCursor(650, 480, "switch");475 // this.switchPokemonSprite = this[`pokemonIcon5`].texture.key;476 this.switchPokemonIndex = 5;477 return;478 }479 //確定更換隊伍順序480 this.sortPokemonTeam(481 this.currentSelectedPokemonIndex,482 this.switchPokemonIndex483 );484 }485 //關閉選單486 if (Phaser.Input.Keyboard.JustDown(this.keyEsc)) {487 if (!this.isSwitchPokemon) {488 this.endEditPokemonTeam();...

Full Screen

Full Screen

magazineNew.js

Source:magazineNew.js Github

copy

Full Screen

...50 for (let i = 0; i < pages.length ; i++) {51 n = n + i * k;52 k = k * -1;53 cursor.getCell(1 + 50 * i, 1).value = (pages[n].number + 1) * 2 - 154 renderLeftAside(cursor.createCursor(5 + 50 * i, 1), pages[n])55 renderLeftPage(cursor.createCursor(1 + 50 * i, 3), pages[n])56 }57}58function renderLeftAside(cursor, page) {59 // merges60 new Array(61 [1, 1, 2, 1],62 [1, 2, 2, 2]63 ).forEach(pos => {64 cursor.mergeCells(pos[0], pos[1], pos[2], pos[3])65 })66 new Array(67 3, 11, 19, 27, 3568 ).forEach(pos => {69 cursor.mergeCells(pos, 1, pos + 7, 1)70 cursor.mergeCells(pos, 2, pos + 7, 2)71 })72 //font73 cursor.getArea(1, 1, 1, 2).forEach(cell => {74 cell.font = {75 size: 1076 }77 })78 cursor.getArea(3, 1, 42, 2).forEach(cell => {79 cell.font = {80 size: 1481 }82 })83 //alignment84 cursor.getCell(1, 1).alignment = {85 wrapText: true,86 vertical: 'middle',87 horizontal: 'center'88 }89 cursor.getCell(1, 2).alignment = {90 wrapText: true,91 vertical: 'middle',92 horizontal: 'center'93 }94 cursor.getArea(3, 1, 42, 2).forEach(cell => {95 cell.alignment = {96 vertical: 'middle',97 horizontal: 'center',98 textRotation: 9099 };100 })101 //borders102 cursor.setBordersOnArea('medium', 1, 1, 42, 2)103 fillInfoLeftAside(cursor.createCursor(), page)104}105function fillInfoLeftAside(cursor, page) {106 cursor.getCell(1, 1).value = '№ марш.'107 cursor.getCell(1, 2).value = '№ вых.'108 page.buses.forEach((bus, i) => {109 const way = bus.way110 const route = way?.route111 cursor.getCell(3 + i * 8, 1).font = { size: 14, bold: true }112 cursor.getCell(3 + i * 8, 2).font = { size: 14, bold: true }113 cursor.getCell(3 + i * 8, 1).value = route?.num || ''114 cursor.getCell(3 + i * 8, 2).value = way?.num || ''115 })116}117function renderLeftPage(cursor, page, isEmpty) {118 cursor.setRowHeight(new Array(50).fill(18.75))119 if (isEmpty) {120 return121 }122 cursor.getArea(1, 1, 50, 17).forEach(cell => {123 cell.alignment = {124 vertical: 'middle',125 horizontal: 'center'126 }127 })128 renderLeftHeader(cursor.createCursor(5, 1), page.weekdays)129 for (let i = 0; i < 5; i++) {130 renderLeftBus(cursor.createCursor(7 + i * 8, 1), page.buses[i])131 }132}133function renderLeftHeader(cursor, weekdays = []) {134 // merges135 new Array(136 [1, 1, 2, 1],137 [1, 2, 2, 2],138 [1, 3, 2, 3],139 [1, 4, 2, 4],140 [1, 5, 1, 17]141 ).forEach(pos => {142 cursor.mergeCells(pos[0], pos[1], pos[2], pos[3])143 })144 //font145 cursor.getArea(1, 1, 2, 17).forEach(cell => {146 cell.font = {147 size: 10148 }149 })150 //alignment151 cursor.getCell(1, 1).alignment.wrapText = true152 cursor.getCell(1, 3).alignment.wrapText = true153 //borders154 cursor.setBordersOnArea('medium', 1, 1, 2, 16)155 // content156 new Array(157 { pos: [1, 1], text: '№ автоб.' },158 { pos: [1, 2], text: 'Фамилия' },159 { pos: [1, 3], text: 'Таб. номер' },160 { pos: [1, 4], text: 'Роспись' },161 { pos: [1, 5], text: 'Календарные' },162 ).forEach(({ pos, text }) => {163 cursor.getCell(pos[0], pos[1]).value = text164 })165 new Array(12).fill(1).map((_, i) => i + 1).forEach(i => {166 const cell = cursor.getCell(2, 4 + i)167 cell.value = i168 if (weekdays.includes(i.toString())) {169 cursor.createCursor(2, 4 + i)170 .getArea(1, 1, 41, 1)171 .forEach(cell => {172 cell.fill = {173 type: 'pattern',174 pattern:'solid',175 fgColor:{argb:'FFbfbfbf'}176 }177 })178 }179 })180}181function renderLeftBus(cursor, bus) {182 cursor.mergeCells(1, 1, 8, 1)183 cursor.getArea(1, 2, 8, 2).forEach(cell => {184 cell.alignment = {185 vertical: 'middle',186 horizontal: 'left'187 }188 })189 //font190 cursor.getArea(1, 1, 8, 17).forEach(cell => {191 cell.font = {192 size: 14193 }194 })195 //alignment196 cursor.getCell(1, 1).alignment.textRotation = 90197 //borders198 cursor.setBordersOnArea('thin', 1, 1, 8, 16)199 new Array(16, 4, 3, 2, 1).forEach(c => {200 cursor.setBordersAroundArea('medium', 1, 1, 8, c)201 })202 if (bus) {203 fillBusInfo(cursor.createCursor(), bus)204 }205}206function fillBusInfo(cursor, bus) {207 cursor.getCell(1, 1).font = { size: 14, bold: true }208 cursor.getCell(1, 1).value = bus.num209 const positions = getDriverPositionsByCount(bus.drivers.length)210 positions.forEach((pos, i) => {211 fillLeftDriverInfo(cursor.createCursor(pos, 2), bus.drivers[i])212 })213}214function fillLeftDriverInfo(cursor, driver) {215 // alignment216 cursor.getArea(1, 1, 8, 2).forEach(cell => {217 cell.alignment.horizontal = 'center'218 cell.alignment.horizontal = 'center'219 })220 // font221 cursor.getCell(1, 1).font = { size: 14, bold: true }222 cursor.getCell(5, 1).font = { size: 14, bold: true }223 cursor.getCell(4, 1).font = { size: 10 }224 cursor.getCell(8, 1).font = { size: 10 }225 cursor.getCell(2, 2).font = { size: 14, bold: true }226 // content227 const [lastname, firstname, middlename] = driver.fullname.split(' ')228 cursor.getCell(1, 1).value = lastname || ''229 cursor.getCell(2, 1).value = firstname || ''230 cursor.getCell(3, 1).value = middlename || ''231 let graphicName = driver.graphic?.name || ''232 if (graphicName) {233 graphicName = `${graphicName} (${graphicName[0]}раб. / ${graphicName[1]}вых.)`234 }235 cursor.getCell(4, 1).value = graphicName236 cursor.getCell(1, 2).value = driver.num.slice(0, 4)237 cursor.getCell(2, 2).value = driver.num.slice(4)238 for (let i = 0; i < 12; i++) {239 cursor.getCell(1, i + 4).value = driver.statuses[i].value240 }241}242function renderRightWS(cursor, pages) {243 let k = 1;244 let n = Math.floor(pages.length / 2);245 for (let i = 0; i < pages.length ; i++) {246 n = n + i * k;247 k = k * -1;248 renderRightPage(cursor.createCursor(1 + 50 * i, 20), pages[n])249 }250}251function renderRightPage(cursor, page, isEmpty = false) {252 cursor.setRowHeight(new Array(50).fill(18.75))253 if (isEmpty) {254 return255 }256 renderRightHeader(cursor.createCursor(5, 1), page.weekdays)257 for (let i = 0; i < 5; i++) {258 renderRightBus(cursor.createCursor(7 + i * 8, 1), page.buses[i])259 }260 cursor.getCell(1,24).value = (page.number + 1) * 2261}262function renderRightHeader(cursor, weekdays = []) {263 cursor.getArea(1, 1, 2, 24).forEach(cell => {264 cell.alignment = {265 vertical: 'middle',266 horizontal: 'center'267 }268 })269 // content270 new Array(271 { pos: [1, 1], text: 'числа месяца' },272 { pos: [1, 21], text: 'Режим работы' },273 ).forEach(({ pos, text }) => {274 cursor.getCell(pos[0], pos[1]).value = text275 })276 new Array(19).fill(1).map((_, i) => i + 13).forEach(i => {277 const cell = cursor.getCell(2, i - 11)278 cell.value = i279 if (weekdays.includes(i.toString())) {280 cursor.createCursor(2, i - 11)281 .getArea(1, 1, 41, 1)282 .forEach(cell => {283 cell.fill = {284 type: 'pattern',285 pattern:'solid',286 fgColor:{argb:'FFbfbfbf'}287 }288 })289 }290 })291 // merges292 new Array(293 [1, 1, 1, 20],294 [1, 21, 2, 24]295 ).forEach(pos => {296 cursor.mergeCells(pos[0], pos[1], pos[2], pos[3])297 })298 //font299 cursor.getArea(1, 1, 2, 24).forEach(cell => {300 cell.font = {301 size: 10302 }303 })304 //borders305 cursor.setBordersOnArea('medium', 1, 2, 2, 24)306}307function renderRightBus(cursor, bus) {308 cursor.getArea(1, 1, 8, 20).forEach(cell => {309 cell.alignment = {310 vertical: 'middle',311 horizontal: 'center'312 }313 })314 // merges315 new Array(316 [1, 21, 1, 23],317 [2, 21, 2, 24],318 [4, 21, 4, 23],319 [5, 21, 5, 23],320 [6, 21, 6, 23],321 [7, 21, 7, 24]322 ).forEach(pos => {323 cursor.mergeCells(pos[0], pos[1], pos[2], pos[3])324 })325 //borders326 cursor.setBordersOnArea('thin', 1, 2, 8, 20)327 new Array(24, 20).forEach(c => {328 cursor.setBordersAroundArea('medium', 1, 2, 8, c)329 })330 //content331 cursor.getCell(1, 21).value = 'Выход:'332 cursor.getCell(2, 21).value = 'Продолжительность работы'333 cursor.getCell(3, 21).value = '1 смена:'334 cursor.getCell(3, 23).value = '2 смена:'335 cursor.getCell(4, 21).value = 'Выезд из парка:'336 cursor.getCell(5, 21).value = 'Время смены:'337 cursor.getCell(6, 21).value = 'Окончание работы:'338 cursor.getCell(7, 21).value = 'Время обеда'339 cursor.getCell(8, 21).value = '1 смена:'340 cursor.getCell(8, 23).value = '2 смена:'341 if (bus) {342 const positions = getDriverPositionsByCount(bus.drivers.length)343 positions.forEach((pos, i) => {344 fillRightDriverInfo(cursor.createCursor(pos, 2), bus.drivers[i])345 })346 if (bus.way) {347 fillWayInfo(cursor.createCursor(1, 21), bus.way)348 }349 }350}351function fillRightDriverInfo(cursor, driver) {352 for (let i = 12; i < driver.statuses.length; i++) {353 cursor.getCell(1, i - 11).value = driver.statuses[i].value354 }355}356function fillWayInfo(cursor, way) {357 cursor.getCell(1, 4).value = way.num358 if (way.times) {359 cursor.getCell(3, 2).value = way.times.durationFirstSmene360 cursor.getCell(3, 4).value = way.times.durationSecondSmene361 cursor.getCell(4, 4).value = way.times.outPark...

Full Screen

Full Screen

NodeService.spec.js

Source:NodeService.spec.js Github

copy

Full Screen

...20 node, editor, $el: element,21 };22 return new NodeService(vm);23}24function createCursor(x, y) {25 return {26 clientX: x,27 clientY: y,28 };29}30describe('onLeftHalf', () => {31 it('returns true when the cursor is on the left hand of element', () => {32 const nodeService = createNodeService();33 const cursor = createCursor(250, 300);34 const onLeftHalf = nodeService.onLeftHalf(cursor);35 expect(onLeftHalf).toBe(true);36 });37 it('returns false when the cursor is not on the left hand of element', () => {38 const nodeService = createNodeService();39 const cursor = createCursor(301, 300);40 const onLeftHalf = nodeService.onLeftHalf(cursor);41 expect(onLeftHalf).toBe(false);42 });43});44describe('onTopHalf', () => {45 it('returns true when the cursor is on the top half of element', () => {46 const nodeService = createNodeService();47 const cursor = createCursor(300, 250);48 const onTopHalf = nodeService.onTopHalf(cursor);49 expect(onTopHalf).toBe(true);50 });51 it('returns false when the cursor is not on the top half of element', () => {52 const nodeService = createNodeService();53 const cursor = createCursor(300, 301);54 const onTopHalf = nodeService.onTopHalf(cursor);55 expect(onTopHalf).toBe(false);56 });57});58describe('onEdge', () => {59 it('returns true when the cursor is on the edge of element', () => {60 const nodeService = createNodeService();61 const cursor = createCursor(205, 300);62 const onEdge = nodeService.onEdge(cursor, 5);63 expect(onEdge).toBe(true);64 });65 it('returns false when the cursor is not on the edge of element', () => {66 const nodeService = createNodeService();67 const cursor = createCursor(210, 210);68 const onEdge = nodeService.onEdge(cursor, 5);69 expect(onEdge).toBe(false);70 });71});72describe('handleCanvasDragOver', () => {73 it('calls handleElementDragOver() when the cursor is on the edge of element', () => {74 const nodeService = createNodeService();75 nodeService.onEdge = () => true;76 nodeService.handleElementDragOver = jest.fn();77 const cursor = createCursor(210, 210);78 nodeService.handleCanvasDragOver(cursor);79 expect(nodeService.handleElementDragOver.mock.calls.length).toBe(1);80 });81 it('calls pointInside() when the cursor is not on the edge of element and not on the top half of element', () => {82 const nodeService = createNodeService();83 nodeService.onEdge = () => false;84 nodeService.onTopHalf = () => false;85 nodeService.getEditor().indicator.pointInside = jest.fn();86 const cursor = createCursor(210, 210);87 nodeService.handleCanvasDragOver(cursor);88 expect(nodeService.getEditor().indicator.pointInside.mock.calls.length).toBe(1);89 });90 it('calls pointInsideTop() when the cursor is not on the edge of element and on the top half of element', () => {91 const nodeService = createNodeService();92 nodeService.onEdge = () => false;93 nodeService.onTopHalf = () => true;94 nodeService.getEditor().indicator.pointInsideTop = jest.fn();95 const cursor = createCursor(210, 210);96 nodeService.handleCanvasDragOver(cursor);97 expect(nodeService.getEditor().indicator.pointInsideTop.mock.calls.length).toBe(1);98 });99});100describe('handleElementDragOver', () => {101 it('calls pointBefore() when the cursor is on the left hand of element', () => {102 const nodeService = createNodeService();103 nodeService.onLeftHalf = () => true;104 nodeService.getEditor().indicator.pointBefore = jest.fn();105 const cursor = createCursor(210, 210);106 nodeService.handleElementDragOver(cursor);107 expect(nodeService.getEditor().indicator.pointBefore.mock.calls.length).toBe(1);108 });109 it('calls pointAfter() when the cursor is not on the left hand of element', () => {110 const nodeService = createNodeService();111 nodeService.onLeftHalf = () => false;112 nodeService.getEditor().indicator.pointAfter = jest.fn();113 const cursor = createCursor(210, 210);114 nodeService.handleElementDragOver(cursor);115 expect(nodeService.getEditor().indicator.pointAfter.mock.calls.length).toBe(1);116 });117});118describe('handleElementDrop', () => {119 it('calls insertBefore() when the cursor is on the left hand of element and the target node is allow to be inserted', () => {120 const nodeService = createNodeService();121 nodeService.onLeftHalf = () => true;122 nodeService.getEditor().draggedNode.canBeSibling = () => true;123 nodeService.getEditor().draggedNode.insertBefore = jest.fn();124 const cursor = createCursor(210, 210);125 nodeService.handleElementDrop(cursor);126 expect(nodeService.getEditor().draggedNode.insertBefore.mock.calls.length).toBe(1);127 });128 it('does not call insertBefore() when the cursor is on the left hand of element and the target node is not allow to be inserted', () => {129 const nodeService = createNodeService();130 nodeService.onLeftHalf = () => true;131 nodeService.getEditor().draggedNode.canBeSibling = () => false;132 nodeService.getEditor().draggedNode.insertBefore = jest.fn();133 const cursor = createCursor(210, 210);134 nodeService.handleElementDrop(cursor);135 expect(nodeService.getEditor().draggedNode.insertBefore.mock.calls.length).toBe(0);136 });137 it('calls insertAfter() when the cursor is not on the left hand of element and the target node is allow to be inserted', () => {138 const nodeService = createNodeService();139 nodeService.onLeftHalf = () => false;140 nodeService.getEditor().draggedNode.canBeSibling = () => true;141 nodeService.getEditor().draggedNode.insertAfter = jest.fn();142 const cursor = createCursor(210, 210);143 nodeService.handleElementDrop(cursor);144 expect(nodeService.getEditor().draggedNode.insertAfter.mock.calls.length).toBe(1);145 });146 it('does not call insertAfter() when the cursor is not on the left hand of element and the target node is not allow to be inserted', () => {147 const nodeService = createNodeService();148 nodeService.onLeftHalf = () => false;149 nodeService.getEditor().draggedNode.canBeSibling = () => false;150 nodeService.getEditor().draggedNode.insertAfter = jest.fn();151 const cursor = createCursor(210, 210);152 nodeService.handleElementDrop(cursor);153 expect(nodeService.getEditor().draggedNode.insertAfter.mock.calls.length).toBe(0);154 });155});156describe('handleCanvasDrop', () => {157 it('calls append() when the cursor is not on the edge of element and not on the top half of element and the current node is droppable', () => {158 const nodeService = createNodeService();159 nodeService.onEdge = () => false;160 nodeService.onTopHalf = () => false;161 nodeService.getCurrentNode().isDroppable = () => true;162 nodeService.getCurrentNode().append = jest.fn();163 const cursor = createCursor(210, 210);164 nodeService.handleCanvasDrop(cursor);165 expect(nodeService.getCurrentNode().append.mock.calls.length).toBe(1);166 });167 it('calls prepend() when the cursor is not on the edge of element and on the top half of element and the current node is droppable', () => {168 const nodeService = createNodeService();169 nodeService.onEdge = () => false;170 nodeService.onTopHalf = () => true;171 nodeService.getCurrentNode().isDroppable = () => true;172 nodeService.getCurrentNode().prepend = jest.fn();173 const cursor = createCursor(210, 210);174 nodeService.handleCanvasDrop(cursor);175 expect(nodeService.getCurrentNode().prepend.mock.calls.length).toBe(1);176 });177 it('does nothing when the cursor is not on the edge of element and the current node is not droppable', () => {178 const nodeService = createNodeService();179 nodeService.onEdge = () => false;180 nodeService.getCurrentNode().isDroppable = () => false;181 nodeService.getCurrentNode().append = jest.fn();182 nodeService.getCurrentNode().prepend = jest.fn();183 const cursor = createCursor(210, 210);184 nodeService.handleCanvasDrop(cursor);185 expect(nodeService.getCurrentNode().append.mock.calls.length).toBe(0);186 expect(nodeService.getCurrentNode().prepend.mock.calls.length).toBe(0);187 });188 it('calls handleElementDrop() when the cursor is on the edge of element', () => {189 const nodeService = createNodeService();190 nodeService.onEdge = () => true;191 nodeService.handleElementDrop = jest.fn();192 const cursor = createCursor(210, 210);193 nodeService.handleCanvasDrop(cursor);194 expect(nodeService.handleElementDrop.mock.calls.length).toBe(1);195 });...

Full Screen

Full Screen

test-editor-client.js

Source:test-editor-client.js Github

copy

Full Screen

...13 'enihcam': { name: 'Tim', selection: { ranges: [{ anchor: 0, head: 0 }, { anchor: 2, head: 4 }] } },14 'baia': { name: 'Jan', selection: { ranges: [{ anchor: 6, head: 7 }] } }15 }16 t.context.serverAdapter = new ServerConnectorMock()17 t.context.editorAdapter = new EditorAdapterMock(t.context.initialDoc, Selection.createCursor(11))18 t.context.editorClient = new EditorClient(t.context.revision, t.context.clients, t.context.serverAdapter, t.context.editorAdapter)19 _t = t20})21const setSelection = (str) => {22 _t.context.editorAdapter.value = str23 _t.context.editorAdapter.selection = Selection.createCursor(str.length)24}25const insertAndDelete = (str, retain = _t.context.editorAdapter.getValue().length - 1) => {26 _t.context.editorAdapter.trigger('change',27 new TextOperation().retain(retain).insert(str),28 new TextOperation().retain(retain).delete(str.length)29 )30}31test('register undo and redo functions', (t) => {32 const editorAdapter = t.context.editorAdapter33 t.truthy(typeof editorAdapter.undo === 'function')34 t.truthy(typeof editorAdapter.redo === 'function')35})36test('simulated editing session', (t) => {37 // Let's say, we are Nina and we're editing a document together with Tim and Jan38 // Firstly, we get informed one of them has replaced the lower case 'd' with a capital 'D'39 const serverAdapter = t.context.serverAdapter40 const editorAdapter = t.context.editorAdapter41 const editorClient = t.context.editorClient42 const assertOutstanding = (ratain, str) => {43 t.truthy(editorClient.state.outstanding.equals(new TextOperation().retain(ratain).insert(str)))44 }45 const assertBuffer = (ratain, str) => {46 t.truthy(editorClient.state.buffer.equals(new TextOperation().retain(ratain).insert(str)))47 }48 serverAdapter.trigger('operation', [6, -1, 'D', 4])49 t.deepEqual(editorAdapter.getValue(), 'lorem Dolor')50 t.truthy(editorClient.state instanceof Synchronized)51 t.deepEqual(editorClient.revision, 2)52 // We append a single white space to the document53 setSelection('lorem Dolor ')54 insertAndDelete(' ')55 editorAdapter.trigger('selectionChange')56 t.truthy(editorClient.state instanceof AwaitingConfirm)57 t.deepEqual(serverAdapter.sentRevision, 2)58 assertOutstanding(11, ' ')59 t.deepEqual(serverAdapter.sentOperation, [11, ' '])60 t.truthy(serverAdapter.sentSelectionWithOperation.equals(Selection.createCursor(12)))61 t.deepEqual(serverAdapter.sentSelection, Selection.createCursor())62 // Someone inserts an extra white space between "lorem" and "Dolor"63 serverAdapter.trigger('operation', [5, ' ', 6])64 t.deepEqual(editorAdapter.getValue(), 'lorem Dolor ')65 t.deepEqual(editorClient.revision, 3)66 t.truthy(editorClient.state instanceof AwaitingConfirm)67 assertOutstanding(12, ' ')68 // Our cursor moved one char to the right because of that insertion. That69 // info should have been sent.70 t.truthy(editorAdapter.selection.equals(Selection.createCursor(13)))71 t.truthy(serverAdapter.sentSelection.equals(Selection.createCursor(13)))72 // We append "S" at the end73 setSelection('lorem Dolor S')74 insertAndDelete('S')75 editorAdapter.trigger('selectionChange')76 // This operation should have been buffered77 t.truthy(editorClient.state instanceof AwaitingWithBuffer)78 t.deepEqual(serverAdapter.sentRevision, 2) // last revision79 t.deepEqual(serverAdapter.sentOperation, [11, ' ']) // last operation80 t.truthy(serverAdapter.sentSelection.equals(Selection.createCursor(13)))81 // We continue with the letters "it"82 setSelection('lorem Dolor Sit')83 insertAndDelete('i', 14)84 editorAdapter.selection = Selection.createCursor(16)85 editorAdapter.trigger('selectionChange')86 insertAndDelete('t', 15)87 editorAdapter.trigger('selectionChange')88 t.truthy(serverAdapter.sentSelection.equals(Selection.createCursor(13)))89 t.deepEqual(serverAdapter.sentRevision, 2) // last revision90 t.deepEqual(serverAdapter.sentOperation, [11, ' ']) // last operation91 assertOutstanding(12, ' ')92 assertBuffer(13, 'Sit')93 // Someone inserts "Ipsum" between "lorem" and "Dolor"94 serverAdapter.trigger('operation', [6, 'Ipsum', 6])95 t.deepEqual(editorClient.revision, 4)96 t.deepEqual(editorAdapter.getValue(), 'lorem Ipsum Dolor Sit')97 t.truthy(editorClient.state instanceof AwaitingWithBuffer)98 assertOutstanding(17, ' ')99 assertBuffer(18, 'Sit')100 // Our cursor should have been shifted by that operation to position 21101 t.truthy(editorAdapter.selection.equals(Selection.createCursor(21)))102 // We get an acknowledgement for our first sent operation from the server!103 serverAdapter.trigger('ack')104 t.deepEqual(serverAdapter.sentRevision, 5)105 t.deepEqual(serverAdapter.sentOperation, [18, 'Sit'])106 t.deepEqual(editorClient.revision, 5)107 t.truthy(editorClient.state instanceof AwaitingConfirm)108 assertOutstanding(18, 'Sit')109 // We switch to another program. The browser window and the editor lose their110 // focus.111 editorAdapter.trigger('blur')112 t.deepEqual(serverAdapter.sentSelection, Selection.createCursor())113 // The operation that was sent a few moments ago gets acknowledged right away114 serverAdapter.trigger('ack')115 t.deepEqual(editorClient.revision, 6)116 t.deepEqual(serverAdapter.sentRevision, 5)117 t.truthy(editorClient.state instanceof Synchronized)118 t.deepEqual(editorAdapter.getValue(), 'lorem Ipsum Dolor Sit')119})120test('user handling', (t) => {121 const editorClient = t.context.editorClient122 const editorAdapter = t.context.editorAdapter123 const serverAdapter = t.context.serverAdapter124 const mockClient1 = {125 clientId: 'enihcam',126 color: editorAdapter.otherSelections[0].color,127 selection: new Selection([new Range(0, 0), new Range(2, 4)])128 }129 const mockClient2 = {130 clientId: 'baia',131 color: editorAdapter.otherSelections[1].color,132 selection: new Selection([new Range(6, 7)])133 }134 t.deepEqual(editorAdapter.otherSelections, [135 mockClient1, mockClient2136 ])137 // We insert an extra space between "lorem" and "dolor"138 setSelection('lorem dolor')139 editorAdapter.trigger('change',140 new TextOperation().retain(5).insert(' ').retain(6),141 new TextOperation().retain(5)['delete'](1).retain(6)142 )143 editorAdapter.trigger('selectionChange')144 // Jan selects some text that spans the position of our insertion145 serverAdapter.trigger('selection', 'baia', { ranges: [{ anchor: 4, head: 7 }] })146 mockClient2.selection = new Selection([new Range(4, 8)])147 t.deepEqual(editorAdapter.otherSelections, [148 mockClient1,149 mockClient2150 ])151 // Tim's editor loses focus152 serverAdapter.trigger('selection', 'enihcam', null)153 mockClient2.color = editorAdapter.otherSelections[0].color154 t.deepEqual(editorAdapter.otherSelections, [155 mockClient2156 ])157 // Tim closes his browser158 t.deepEqual(Object.keys(editorClient.clients).length, 2)159 serverAdapter.trigger('client_left', 'enihcam')160 t.deepEqual(Object.keys(editorClient.clients).length, 1)161 // A new user joins!162 serverAdapter.trigger('set_name', 'emit-remmus', 'Nina')163 t.deepEqual(Object.keys(editorClient.clients).length, 2)164 t.deepEqual(editorClient.clients['emit-remmus'].name, 'Nina')165 // We get an update consisting of the state of all connected users:166 // Tim rejoined, Jan left, Nina updated her cursor167 serverAdapter.trigger('clients', {168 'enihcam': { name: 'Tim', selection: null },169 'emit-remmus': { name: 'Nina', selection: { ranges: [{ anchor: 0, head: 0 }] } }170 })171 t.deepEqual(Object.keys(editorClient.clients).length, 2)172 t.deepEqual(editorClient.clients['emit-remmus'].name, 'Nina')173 t.deepEqual(editorClient.clients['enihcam'].name, 'Tim')174 t.deepEqual(editorAdapter.otherSelections, [175 {176 clientId: 'emit-remmus',177 color: editorAdapter.otherSelections[0].color,178 // because of our insertion, the selection spans one more character179 selection: Selection.createCursor(0)180 }181 ])...

Full Screen

Full Screen

magazine.js

Source:magazine.js Github

copy

Full Screen

...40 return await wb.xlsx.writeBuffer()41}42function renderLeftWS(cursor, pages) {43 cursor.setColumnWidth([10, 29, 12, 10].concat(new Array(13).fill(4)))44 renderLeftPage(cursor.createCursor(), null, true)45 for (let i = 0; i < pages.length ; i++) {46 renderLeftPage(cursor.createCursor(51 + 50 * (pages.length - i - 1), 1), pages[i])47 }48}49function renderLeftPage(cursor, page, isEmpty) {50 cursor.setRowHeight(new Array(50).fill(18.75))51 if (isEmpty) {52 return53 }54 cursor.getArea(1, 1, 50, 17).forEach(cell => {55 cell.alignment = {56 vertical: 'middle',57 horizontal: 'center'58 }59 })60 renderLeftHeader(cursor.createCursor(5, 1))61 for (let i = 0; i < 5; i++) {62 renderLeftBus(cursor.createCursor(7 + i * 8, 1), page.buses[i])63 }64 cursor.getCell(1,1).value = page.number + 165}66function renderLeftHeader(cursor) {67 // merges68 new Array(69 [1, 1, 2, 1],70 [1, 2, 2, 2],71 [1, 3, 2, 3],72 [1, 4, 2, 4],73 [1, 5, 1, 17]74 ).forEach(pos => {75 cursor.mergeCells(pos[0], pos[1], pos[2], pos[3])76 })77 //font78 cursor.getArea(1, 1, 2, 17).forEach(cell => {79 cell.font = {80 size: 1281 }82 })83 //alignment84 cursor.getCell(1, 1).alignment.wrapText = true85 cursor.getCell(1, 3).alignment.wrapText = true86 //borders87 cursor.setBordersOnArea('medium', 1, 1, 2, 16)88 // content89 new Array(90 { pos: [1, 1], text: '№ автоб.' },91 { pos: [1, 2], text: 'Фамилия' },92 { pos: [1, 3], text: 'Таб. номер' },93 { pos: [1, 4], text: 'Роспись' },94 { pos: [1, 5], text: 'Календарные' },95 ).forEach(({ pos, text }) => {96 cursor.getCell(pos[0], pos[1]).value = text97 })98 new Array(12).fill(1).map((_, i) => i + 1).forEach(i => {99 cursor.getCell(2, 4 + i).value = i100 })101}102function renderLeftBus(cursor, bus) {103 cursor.mergeCells(1, 1, 8, 1)104 cursor.getArea(1, 2, 8, 2).forEach(cell => {105 cell.alignment = {106 vertical: 'middle',107 horizontal: 'left'108 }109 })110 //font111 cursor.getArea(1, 1, 8, 17).forEach(cell => {112 cell.font = {113 size: 14114 }115 })116 //alignment117 cursor.getCell(1, 1).alignment.textRotation = 90118 //borders119 cursor.setBordersOnArea('thin', 1, 1, 8, 16)120 new Array(16, 4, 3, 2, 1).forEach(c => {121 cursor.setBordersAroundArea('medium', 1, 1, 8, c)122 })123 if (bus) {124 fillBusInfo(cursor.createCursor(), bus)125 }126}127function fillBusInfo(cursor, bus) {128 cursor.getCell(1, 1).value = bus.num129 const positions = getDriverPositionsByCount(bus.drivers.length)130 console.log(bus.drivers.length)131 positions.forEach((pos, i) => {132 fillLeftDriverInfo(cursor.createCursor(pos, 2), bus.drivers[i])133 })134}135function fillLeftDriverInfo(cursor, driver) {136 cursor.getCell(1, 1).value = driver.name137 cursor.getCell(1, 2).value = driver.num.slice(3)138 for (let i = 0; i < 12; i++) {139 cursor.getCell(1, i + 4).value = driver.statuses[i].value140 }141}142function renderRightWS(cursor, pages) {143 cursor.setColumnWidth(new Array(20).fill(4).concat([8, 8, 8, 8]))144 renderRightPage(cursor.createCursor(), null, true)145 for (let i = 0; i < pages.length; i++) {146 renderRightPage(cursor.createCursor(51 + 50 * i, 1), pages[i])147 }148}149function renderRightPage(cursor, page, isEmpty = false) {150 cursor.setRowHeight(new Array(50).fill(18.75))151 if (isEmpty) {152 return153 }154 renderRightHeader(cursor.createCursor(5, 1))155 for (let i = 0; i < 5; i++) {156 renderRightBus(cursor.createCursor(7 + i * 8, 1), page.buses[i])157 }158 cursor.getCell(1,24).value = page.number + 1159}160function renderRightHeader(cursor) {161 cursor.getArea(1, 1, 2, 24).forEach(cell => {162 cell.alignment = {163 vertical: 'middle',164 horizontal: 'center'165 }166 })167 // content168 new Array(169 { pos: [1, 1], text: 'числа месяца' },170 { pos: [1, 21], text: 'Режим работы' },171 ).forEach(({ pos, text }) => {172 cursor.getCell(pos[0], pos[1]).value = text173 })174 new Array(19).fill(1).map((_, i) => i + 13).forEach(i => {175 cursor.getCell(2, i - 11).value = i176 })177 // merges178 new Array(179 [1, 1, 1, 20],180 [1, 21, 2, 24]181 ).forEach(pos => {182 cursor.mergeCells(pos[0], pos[1], pos[2], pos[3])183 })184 //font185 cursor.getArea(1, 1, 2, 24).forEach(cell => {186 cell.font = {187 size: 12188 }189 })190 //borders191 cursor.setBordersOnArea('medium', 1, 2, 2, 24)192}193function renderRightBus(cursor, bus) {194 cursor.getArea(1, 1, 8, 20).forEach(cell => {195 cell.alignment = {196 vertical: 'middle',197 horizontal: 'center'198 }199 })200 // merges201 new Array(202 [1, 21, 1, 23],203 [2, 21, 2, 24],204 [4, 21, 4, 23],205 [5, 21, 5, 23],206 [6, 21, 6, 23],207 [7, 21, 7, 24]208 ).forEach(pos => {209 cursor.mergeCells(pos[0], pos[1], pos[2], pos[3])210 })211 //borders212 cursor.setBordersOnArea('thin', 1, 2, 8, 20)213 new Array(24, 20).forEach(c => {214 cursor.setBordersAroundArea('medium', 1, 2, 8, c)215 })216 //content217 cursor.getCell(1, 21).value = 'Выход:'218 cursor.getCell(2, 21).value = 'Продолжительность работы'219 cursor.getCell(3, 21).value = '1 смена:'220 cursor.getCell(3, 23).value = '2 смена:'221 cursor.getCell(4, 21).value = 'Выезд из парка:'222 cursor.getCell(5, 21).value = 'Время смены:'223 cursor.getCell(6, 21).value = 'Окончание работы:'224 cursor.getCell(7, 21).value = 'Время обеда'225 cursor.getCell(8, 21).value = '1 смена:'226 cursor.getCell(8, 23).value = '2 смена:'227 if (bus) {228 const positions = getDriverPositionsByCount(bus.drivers.length)229 positions.forEach((pos, i) => {230 fillRightDriverInfo(cursor.createCursor(pos, 2), bus.drivers[i])231 })232 if (bus.way) {233 fillWayInfo(cursor.createCursor(1, 21), bus.way)234 }235 }236}237function fillRightDriverInfo(cursor, driver) {238 for (let i = 12; i < driver.statuses.length; i++) {239 cursor.getCell(1, i - 11).value = driver.statuses[i].value240 }241}242function fillWayInfo(cursor, way) {243 cursor.getCell(1, 4).value = way.num244 if (way.times) {245 cursor.getCell(3, 2).value = way.times.durationFirstSmene246 cursor.getCell(3, 4).value = way.times.durationSecondSmene247 cursor.getCell(4, 4).value = way.times.outPark...

Full Screen

Full Screen

schema.test.js

Source:schema.test.js Github

copy

Full Screen

...80 test('previousPage is true when past first record', async () => {81 const variables = {82 organizationId: organization.id,83 first: 5,84 after: createCursor(projects[1], 'createdAt'),85 };86 const result = await runQuery(query, user, variables);87 expect(result.data.projects.totalCount).toBe(20);88 expect(result.data.projects.pageInfo.hasPreviousPage).toBe(true);89 expect(result.data.projects.pageInfo.hasNextPage).toBe(true);90 });91 test('nextPage is false when there are no more records', async () => {92 const variables = {93 organizationId: organization.id,94 first: 5,95 after: createCursor(projects[14], 'createdAt'),96 };97 const result = await runQuery(query, user, variables);98 expect(result.data.projects.totalCount).toBe(20);99 expect(result.data.projects.pageInfo.hasPreviousPage).toBe(true);100 expect(result.data.projects.pageInfo.hasNextPage).toBe(false);101 });102 test('after cursor returns the next record', async () => {103 const variables = {104 organizationId: organization.id,105 first: 1,106 after: createCursor(projects[1], 'createdAt'),107 };108 const result = await runQuery(query, user, variables);109 expect(result.data.projects.edges[0].node.id).toBe(projects[2].id);110 expect(result.data.projects.edges[0].cursor).toBe(111 createCursor(projects[2], 'createdAt'),112 );113 });114 test('before cursor returns the previous record', async () => {115 const variables = {116 organizationId: organization.id,117 first: 1,118 before: createCursor(projects[1], 'createdAt'),119 };120 const result = await runQuery(query, user, variables);121 expect(result.data.projects.edges[0].node.id).toBe(projects[0].id);122 expect(result.data.projects.edges[0].cursor).toBe(123 createCursor(projects[0], 'createdAt'),124 );125 });126 test('last will return the previous record', async () => {127 const variables = {128 organizationId: organization.id,129 last: 5,130 before: createCursor(projects[19], 'createdAt'),131 };132 const result = await runQuery(query, user, variables);133 expect(result.data.projects.edges[0].cursor).toBe(134 createCursor(projects[14], 'createdAt'),135 );136 expect(result.data.projects.edges.map(e => e.node)).toEqual(137 projects.slice(14, 19).map(({ id, name }) => ({ id, name })),138 );139 });140 test('cannot use a negative value for first', async () => {141 const variables = {142 organizationId: organization.id,143 first: -1,144 };145 const result = await runQuery(query, user, variables);146 expect(result.errors[0].message).toBe('first field must be greater than 0');147 });148 test('cannot use a negative value for last', async () => {...

Full Screen

Full Screen

8193c972f72cdded6bdf7eabbb9a61639b21f8ReactFiberHostContext.js

Source:8193c972f72cdded6bdf7eabbb9a61639b21f8ReactFiberHostContext.js Github

copy

Full Screen

...7var invariant = require('fbjs/lib/invariant');8module.exports = function (config) {9 var getChildHostContext = config.getChildHostContext,10 getRootHostContext = config.getRootHostContext;11 var contextStackCursor = createCursor(null);12 var contextFiberStackCursor = createCursor(null);13 var rootInstanceStackCursor = createCursor(null);14 function getRootHostContainer() {15 var rootInstance = rootInstanceStackCursor.current;16 invariant(rootInstance !== null, 'Expected root container to exist. This error is likely caused by a ' + 'bug in React. Please file an issue.');17 return rootInstance;18 }19 function pushHostContainer(fiber, nextRootInstance) {20 push(rootInstanceStackCursor, nextRootInstance, fiber);21 var nextRootContext = getRootHostContext(nextRootInstance);22 push(contextFiberStackCursor, fiber, fiber);23 push(contextStackCursor, nextRootContext, fiber);24 }25 function popHostContainer(fiber) {26 pop(contextStackCursor, fiber);27 pop(contextFiberStackCursor, fiber);...

Full Screen

Full Screen

cursor.js

Source:cursor.js Github

copy

Full Screen

1class cursorSet{2 constructor(color,width){3 this.color = color;4 this.width = width;5 this.createCursor();6 console.log("XD")7 }8 changeColor(color) {9 this.color = color;10 this.createCursor();11 }12 changeWidth(width){13 this.width = parseInt(width) + 2;14 this.createCursor();15 }16 createCursor(){17 var cursor = document.createElement('canvas');18 var ctx = cursor.getContext('2d');19 cursor.width = 30;20 cursor.height = 30;21 ctx.beginPath();22 ctx.arc(12, 12, this.width/2, 0, 2 * Math.PI);23 ctx.strokeStyle = this.color;24 ctx.stroke();25 ctx.fillStyle = this.color;26 ctx.fill();27 var element = document.getElementById("container");28 element.style.cursor = 'url(' + cursor.toDataURL() + ') 11 11, auto';29 }30}

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.click('input[name="q"]');7 await page.keyboard.type('playwright');8 await page.keyboard.press('Enter');9 const cursor = await page._internal.createCursor({x: 100, y: 100});10 await cursor.down();11 await cursor.move(200, 200);12 await cursor.up();13 await browser.close();14})();15const { chromium } = require('playwright');16(async () => {17 const browser = await chromium.launch();18 const context = await browser.newContext();19 const page = await context.newPage();20 await page.click('input[name="q"]');21 await page.keyboard.type('playwright');22 await page.keyboard.press('Enter');23 const cursor = await page._internal.createCursor({x: 100, y: 100});24 await cursor.down();25 await cursor.move(200, 200);26 await cursor.up();27 await browser.close();28})();29const { chromium } = require('playwright');30(async () => {31 const browser = await chromium.launch();32 const context = await browser.newContext();33 const page = await context.newPage();34 await page.click('input[name="q"]');35 await page.keyboard.type('playwright');36 await page.keyboard.press('Enter');37 const cursor = await page._internal.createCursor({x: 100, y: 100});38 await cursor.down();39 await cursor.move(200, 200);40 await cursor.up();41 await browser.close();42})();43const { chromium } = require('playwright');44(async () => {45 const browser = await chromium.launch();46 const context = await browser.newContext();47 const page = await context.newPage();48 await page.click('input[name="q"]');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 const cursor = await page.createCursor();7 await cursor.move(0, 100);8 await cursor.down();9 await cursor.up();10 await cursor.click();11 await browser.close();12})();13const { chromium } = require('playwright');14(async () => {15 const browser = await chromium.launch();16 const context = await browser.newContext();17 const page = await context.newPage();18 const cursor = await page.createCursor();19 await cursor.move(0, 100);20 await cursor.down();21 await cursor.up();22 await cursor.click();23 await browser.close();24})();25const { chromium } = require('playwright');26(async () => {27 const browser = await chromium.launch();28 const context = await browser.newContext();29 const page = await context.newPage();30 const cursor = await page.createCursor();31 await cursor.move(0, 100);32 await cursor.down();33 await cursor.up();34 await cursor.click();35 await browser.close();36})();37const { chromium } = require('playwright');38(async () => {39 const browser = await chromium.launch();40 const context = await browser.newContext();41 const page = await context.newPage();42 const cursor = await page.createCursor();43 await cursor.move(0, 100);44 await cursor.down();45 await cursor.up();46 await cursor.click();47 await browser.close();48})();49const { chromium } = require('playwright');50(async () => {51 const browser = await chromium.launch();52 const context = await browser.newContext();53 const page = await context.newPage();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch({headless: false});4 const context = await browser.newContext();5 const page = await context.newPage();6 const cursor = await page._delegate.createCursor();7 cursor.down();8 cursor.up();9 cursor.left();10 cursor.right();11 cursor.click();12 cursor.doubleClick();13 cursor.click({button: 'right'});14 cursor.click({clickCount: 2});15 cursor.click({delay: 1000});16 cursor.click({position: {x: 10, y: 10}});17 cursor.click({steps: 5});18 cursor.down();19 cursor.up();20 cursor.move({x: 10, y: 10});21 cursor.move({x: 10, y: 10}, {steps: 5});22 cursor.press('Shift');23 cursor.press('Shift', {delay: 1000});24 cursor.type('Hello World');25 cursor.type('Hello World', {delay: 1000});26 cursor.up();27 await browser.close();28})();29const { chromium } = require('playwright');30(async () => {31 const browser = await chromium.launch({headless: false});32 const context = await browser.newContext();33 const page = await context.newPage();34 const keyboard = await page._delegate.createKeyboard();35 keyboard.down('Shift');36 keyboard.up('Shift');37 keyboard.insertText('Hello World');38 keyboard.type('Hello World');39 await browser.close();40})();41const { chromium } = require('playwright');42(async () => {43 const browser = await chromium.launch({headless: false});44 const context = await browser.newContext();45 const page = await context.newPage();46 const mouse = await page._delegate.createMouse();47 mouse.click(100, 200);48 mouse.click(100, 200, {button: 'right'});49 mouse.click(100, 200, {clickCount: 2});50 mouse.click(100, 200, {delay:

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch({4 });5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.click('text=Get started');8 await page.click('text=Show me the code');9 await page.click('text=Close');10 const cursor = await page.createCursor();11 await cursor.move(100, 100);12 await cursor.down();13 await cursor.up();14 await cursor.click();15 await cursor.move(200, 200);16 await cursor.click();17 await cursor.move(300, 300);18 await cursor.click();19 await cursor.move(400, 400);20 await cursor.click();21 await cursor.move(500, 500);22 await cursor.click();23 await cursor.move(600, 600);24 await cursor.click();25 await cursor.move(700, 700);26 await cursor.click();27 await cursor.move(800, 800);28 await cursor.click();29 await cursor.move(900, 900);30 await cursor.click();31 await cursor.move(1000, 1000);32 await cursor.click();33 await cursor.move(1100, 1100);34 await cursor.click();35 await cursor.move(1200, 1200);36 await cursor.click();37 await cursor.move(1300, 1300);38 await cursor.click();39 await cursor.move(1400, 1400);40 await cursor.click();41 await cursor.move(1500, 1500);42 await cursor.click();43 await cursor.move(1600, 1600);44 await cursor.click();45 await cursor.move(1700, 1700);46 await cursor.click();47 await cursor.move(1800, 1800);48 await cursor.click();49 await cursor.move(1900, 1900);50 await cursor.click();51 await cursor.move(2000, 2000);52 await cursor.click();53 await cursor.move(2100, 2100);54 await cursor.click();55 await cursor.move(2200, 2200);56 await cursor.click();57 await cursor.move(2300, 2300);58 await cursor.click();59 await cursor.move(2400, 2400);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 const cursor = await page.createCursor();7 await page.mouse.move(100, 100);8 await page.mouse.down();9 await page.mouse.move(200, 200);10 await page.mouse.up();11 await page.mouse.move(300, 300);12 await page.mouse.down();13 await page.mouse.move(400, 400);14 await page.mouse.up();15 await page.mouse.move(500, 500);16 await page.mouse.down();17 await page.mouse.move(600, 600);18 await page.mouse.up();19 await page.mouse.move(700, 700);20 await page.mouse.down();21 await page.mouse.move(800, 800);22 await page.mouse.up();23 await page.mouse.move(900, 900);24 await page.mouse.down();25 await page.mouse.move(1000, 1000);26 await page.mouse.up();27 await page.mouse.move(1100, 1100);28 await page.mouse.down();29 await page.mouse.move(1200, 1200);30 await page.mouse.up();31 await page.mouse.move(1300, 1300);32 await page.mouse.down();33 await page.mouse.move(1400, 1400);34 await page.mouse.up();35 await page.mouse.move(1500, 1500);36 await page.mouse.down();37 await page.mouse.move(1600, 1600);38 await page.mouse.up();39 await page.mouse.move(1700, 1700);40 await page.mouse.down();41 await page.mouse.move(1800, 1800);42 await page.mouse.up();43 await page.mouse.move(1900, 1900);44 await page.mouse.down();45 await page.mouse.move(2000, 2000);46 await page.mouse.up();47 await page.mouse.move(2100, 2100);48 await page.mouse.down();49 await page.mouse.move(2200, 2200);50 await page.mouse.up();51 await page.mouse.move(2300, 2300);52 await page.mouse.down();53 await page.mouse.move(2400, 2400

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const page = await browser.newPage();5 await page.waitForSelector('text=Hello, world!');6 const cursor = await page.createCursor();7 await cursor.down();

Full Screen

Using AI Code Generation

copy

Full Screen

1import { chromium, webkit, firefox } from 'playwright';2import { createCursor } from 'playwright/lib/cursor';3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const cursor = createCursor(page);8 await cursor.move(100, 100);9 await cursor.down();10 await cursor.move(200, 200);11 await cursor.up();12 await browser.close();13})();14import { chromium, webkit, firefox } from 'playwright';15import { createCursor } from 'playwright/lib/cursor';16(async () => {17 const browser = await chromium.launch();18 const context = await browser.newContext();19 const page = await context.newPage();20 const cursor = createCursor(page);21 await cursor.move(100, 100);22 await cursor.down();23 await cursor.move(200, 200);24 await cursor.up();25 await cursor.dragAndDrop({ x: 200, y: 200 }, { x: 100, y: 100 });26 await browser.close();27})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2const { createCursor } = require('playwright/lib/cjs/server/cursor');3const path = require('path');4const main = async () => {5 const browser = await chromium.launch();6 const page = await browser.newPage();7 const cursor = createCursor(page);8 await cursor.move(100, 100);9 await cursor.down();10 await cursor.up();11 await cursor.move(200, 200);12 await cursor.down();13 await cursor.up();14 await cursor.move(300, 300);15 await cursor.down();16 await cursor.up();17 await cursor.move(400, 400);18 await cursor.down();19 await cursor.up();20 await cursor.move(500, 500);21 await cursor.down();22 await cursor.up();23 await cursor.move(600, 600);24 await cursor.down();25 await cursor.up();26 await cursor.move(700, 700);27 await cursor.down();28 await cursor.up();29 await cursor.move(800, 800);30 await cursor.down();31 await cursor.up();32 await cursor.move(900, 900);33 await cursor.down();34 await cursor.up();35 await cursor.move(1000, 1000);36 await cursor.down();37 await cursor.up();38 await cursor.move(1100, 1100);39 await cursor.down();40 await cursor.up();41 await cursor.move(1200, 1200);42 await cursor.down();43 await cursor.up();44 await cursor.move(1300, 1300);45 await cursor.down();46 await cursor.up();47 await cursor.move(1400, 1400);48 await cursor.down();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.waitForSelector('.w3-container');7 const element = await page.$('.w3-container');8 const cursor = await element.createCursor();9 await cursor.move(0, 0);10 await cursor.down();11 await cursor.move(100, 0);12 await cursor.up();13 await cursor.move(100, 0);14 await cursor.down();15 await cursor.move(0, 0);16 await cursor.up();17 await cursor.move(0, 0);18 await cursor.down();19 await cursor.move(100, 0);20 await cursor.up();21 await cursor.move(100, 0);22 await cursor.down();23 await cursor.move(0, 0);24 await cursor.up();25 await cursor.move(0, 0);26 await cursor.down();27 await cursor.move(100, 0);28 await cursor.up();29 await cursor.move(100, 0);30 await cursor.down();31 await cursor.move(0, 0);32 await cursor.up();33 await cursor.move(0, 0);34 await cursor.down();35 await cursor.move(100, 0);36 await cursor.up();37 await cursor.move(100, 0);38 await cursor.down();39 await cursor.move(0, 0);40 await cursor.up();41 await cursor.move(0, 0);42 await cursor.down();43 await cursor.move(100, 0);44 await cursor.up();45 await cursor.move(100, 0);46 await cursor.down();47 await cursor.move(0, 0);48 await cursor.up();49 await cursor.move(0, 0);50 await cursor.down();51 await cursor.move(100, 0);52 await cursor.up();53 await cursor.move(100, 0);54 await cursor.down();55 await cursor.move(0, 0);56 await cursor.up();57 await cursor.move(0, 0);58 await cursor.down();59 await cursor.move(100, 0);60 await cursor.up();61 await cursor.move(

Full Screen

Using AI Code Generation

copy

Full Screen

1const cursor = await page.createCursor();2await cursor.click(100, 100);3await cursor.down();4await cursor.move(200, 200);5await cursor.up();6await cursor.doubleclick(100, 100);7await cursor.type('Hello World');8await cursor.press('Enter');9await cursor.selectText(100, 100, 200, 200);10await cursor.selectPosition(100, 100, 200, 200);11await cursor.selectPosition(100, 100);12await cursor.selectWord(100, 100);13await cursor.selectLine(100, 100);14await cursor.selectParagraph(100, 100);15await cursor.selectBlock(100, 100);16await cursor.selectElement(100, 100);17await cursor.selectElements(100, 100);18await cursor.selectElementByContent('Hello World');19await cursor.selectElementsByContent('Hello World');20await cursor.selectElementBySelector('div');21await cursor.selectElementsBySelector('div');22await cursor.selectElementByPoint(100, 100);23await cursor.selectElementsByPoint(100, 100);24await cursor.selectElementByFrame('frame');25await cursor.selectElementsByFrame('frame');26await cursor.selectElementByFrameElement('frame');27await cursor.selectElementsByFrameElement('frame');28await cursor.selectElementByFrameName('frame');29await cursor.selectElementsByFrameName('frame');30await cursor.selectElementByFrameTitle('frame');31await cursor.selectElementsByFrameTitle('frame');32await cursor.selectElementByFrameContent('frame');33await cursor.selectElementsByFrameContent('frame');34await cursor.click(100, 100);35await cursor.down();36await cursor.move(200, 200);37await cursor.up();38await cursor.doubleclick(100, 100);39await cursor.type('Hello World');40await cursor.press('Enter');41await cursor.selectText(100, 100, 200, 200);42await cursor.selectPosition(100, 100, 200, 200);43await cursor.selectPosition(100, 100);44await cursor.selectWord(100, 100);45await cursor.selectLine(100, 100);

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal 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