How to use updateProperties method in Playwright Internal

Best JavaScript code snippet using playwright-internal

scene.js

Source:scene.js Github

copy

Full Screen

...98 get() {99 return moreInfo.size;100 },101 set(val) {102 updateProperties(this.id, { width: val.x, height: val.y });103 }104 },105 opacity: {106 get() {107 return result.opacity;108 },109 set(val) {110 updateProperties(this.id, { opacity: val });111 }112 },113 blendMode: {114 get() {115 return result.blendMode;116 },117 set(val) {118 updateProperties(this.id, { blendMode: val });119 }120 },121 isMask: {122 get() {123 return result.mask;124 },125 set(val) {126 updateProperties(this.id, { mask: val });127 }128 },129 effects: {130 get() {131 return result.effects;132 },133 set(val) {134 updateProperties(this.id, { effects: val });135 }136 },137 constraints: {138 get() {139 return { horizontal: result.horizontalConstraint, vertical: result.verticalConstraint };140 },141 set(val) {142 updateProperties(this.id, {143 horizontalConstraint: val.horizontal,144 verticalConstraint: val.vertical145 });146 }147 },148 x: {149 get() {150 return result.x;151 },152 set(val) {153 updateProperties(this.id, { x: val });154 }155 },156 y: {157 get() {158 return result.y;159 },160 set(val) {161 updateProperties(this.id, { y: val });162 }163 },164 width: {165 get() {166 return result.width;167 },168 set(val) {169 updateProperties(this.id, { width: val });170 }171 },172 height: {173 get() {174 return result.height;175 },176 set(val) {177 updateProperties(this.id, { height: val });178 }179 },180 exportSettings: {181 get() {182 return result.exportSettings;183 },184 set(val) {185 updateProperties(this.id, { exportSettings: val });186 }187 }188 });189 if (result.inheritFillStyleID && Object.keys(result.inheritFillStyleID)[0] !== '__mixed__') {190 Object.defineProperty(newNode, 'fillStyleId', {191 get() {192 if (result.inheritFillStyleID.sessionID === 4294967295) return '';193 else return result.inheritFillStyleKey;194 },195 set(val) {196 const styles = Object.values(App._state.library.published.styles)197 .map(org => Object.values(org))198 .flat()199 .map(team => Object.values(team))200 .flat()201 .concat(Object.values(App._state.library.local.styles));202 const style = styles.find(style => style.key === val);203 if (style.canvas_url) {204 var xhr = new XMLHttpRequest();205 xhr.open('GET', style.canvas_url);206 xhr.responseType = 'arraybuffer';207 xhr.onload = () => {208 const localGUID = App.sendMessage(209 'getOrCreateSubscribedStyleNodeId',210 {211 styleKey: style.key,212 fileKey: style.file_key,213 editingFileKey: App._state.editingFileKey,214 versionHash: style.content_hash215 },216 new Uint8Array(xhr.response)217 ).args.localGUID.split(':');218 updateProperties(this.id, { inheritFillStyleID: { sessionID: localGUID[0], localID: localGUID[1] } });219 };220 xhr.send();221 } else {222 const localGUID = style.node_id.split(':');223 updateProperties(this.id, { inheritFillStyleID: { sessionID: localGUID[0], localID: localGUID[1] } });224 }225 }226 });227 }228 if (229 result.inheritFillStyleIDForStroke &&230 Object.keys(result.inheritFillStyleIDForStroke)[0] !== '__mixed__' &&231 result.inheritFillStyleIDForStroke.sessionID !== 4294967295232 ) {233 Object.defineProperty(newNode, 'strokeStyleId', {234 get() {235 return result.inheritFillStyleKeyForStroke;236 },237 set(val) {238 const styles = Object.values(App._state.library.published.styles)239 .map(org => Object.values(org))240 .flat()241 .map(team => Object.values(team))242 .flat()243 .concat(Object.values(App._state.library.local.styles));244 const style = styles.find(style => style.key === val);245 if (style.canvas_url) {246 var xhr = new XMLHttpRequest();247 xhr.open('GET', style.canvas_url);248 xhr.responseType = 'arraybuffer';249 xhr.onload = () => {250 const localGUID = App.sendMessage(251 'getOrCreateSubscribedStyleNodeId',252 {253 styleKey: style.key,254 fileKey: style.file_key,255 editingFileKey: App._state.editingFileKey,256 versionHash: style.content_hash257 },258 new Uint8Array(xhr.response)259 ).args.localGUID.split(':');260 updateProperties(this.id, {261 inheritFillStyleIDForStroke: { sessionID: localGUID[0], localID: localGUID[1] }262 });263 };264 xhr.send();265 } else {266 const localGUID = style.node_id.split(':');267 updateProperties(this.id, {268 inheritFillStyleIDForStroke: { sessionID: localGUID[0], localID: localGUID[1] }269 });270 }271 }272 });273 }274 if (275 result.inheritFillStyleIDForBackground &&276 Object.keys(result.inheritFillStyleIDForBackground)[0] !== '__mixed__' &&277 result.inheritFillStyleIDForBackground.sessionID !== 4294967295278 ) {279 Object.defineProperty(newNode, 'backgroundStyleId', {280 get() {281 return result.inheritFillStyleKeyForBackground;282 },283 set(val) {284 const styles = Object.values(App._state.library.published.styles)285 .map(org => Object.values(org))286 .flat()287 .map(team => Object.values(team))288 .flat()289 .concat(Object.values(App._state.library.local.styles));290 const style = styles.find(style => style.key === val);291 if (style.canvas_url) {292 var xhr = new XMLHttpRequest();293 xhr.open('GET', style.canvas_url);294 xhr.responseType = 'arraybuffer';295 xhr.onload = () => {296 const localGUID = App.sendMessage(297 'getOrCreateSubscribedStyleNodeId',298 {299 styleKey: style.key,300 fileKey: style.file_key,301 editingFileKey: App._state.editingFileKey,302 versionHash: style.content_hash303 },304 new Uint8Array(xhr.response)305 ).args.localGUID.split(':');306 updateProperties(this.id, {307 inheritFillStyleIDForBackground: { sessionID: localGUID[0], localID: localGUID[1] }308 });309 };310 xhr.send();311 } else {312 const localGUID = style.node_id.split(':');313 updateProperties(this.id, {314 inheritFillStyleIDForBackground: { sessionID: localGUID[0], localID: localGUID[1] }315 });316 }317 }318 });319 }320 if (result.inheritEffectStyleID && Object.keys(result.inheritEffectStyleID)[0] !== '__mixed__') {321 Object.defineProperty(newNode, 'effectStyleId', {322 get() {323 if (result.inheritEffectStyleID.sessionID === 4294967295) return '';324 else return result.inheritEffectStyleKey;325 },326 set(val) {327 const styles = Object.values(App._state.library.published.styles)328 .map(org => Object.values(org))329 .flat()330 .map(team => Object.values(team))331 .flat()332 .concat(Object.values(App._state.library.local.styles));333 const style = styles.find(style => style.key === val);334 if (style.canvas_url) {335 var xhr = new XMLHttpRequest();336 xhr.open('GET', style.canvas_url);337 xhr.responseType = 'arraybuffer';338 xhr.onload = () => {339 const localGUID = App.sendMessage(340 'getOrCreateSubscribedStyleNodeId',341 {342 styleKey: style.key,343 fileKey: style.file_key,344 editingFileKey: App._state.editingFileKey,345 versionHash: style.content_hash346 },347 new Uint8Array(xhr.response)348 ).args.localGUID.split(':');349 updateProperties(this.id, {350 inheritEffectStyleID: { sessionID: localGUID[0], localID: localGUID[1] }351 });352 };353 xhr.send();354 } else {355 const localGUID = style.node_id.split(':');356 updateProperties(this.id, { inheritEffectStyleID: { sessionID: localGUID[0], localID: localGUID[1] } });357 }358 }359 });360 }361 if (result.inheritGridStyleID && Object.keys(result.inheritGridStyleID)[0] !== '__mixed__') {362 Object.defineProperty(newNode, 'gridStyleId', {363 get() {364 if (result.inheritGridStyleID.sessionID === 4294967295) return '';365 else return result.inheritGridStyleKey;366 },367 set(val) {368 const styles = Object.values(App._state.library.published.styles)369 .map(org => Object.values(org))370 .flat()371 .map(team => Object.values(team))372 .flat()373 .concat(Object.values(App._state.library.local.styles));374 const style = styles.find(style => style.key === val);375 if (style.canvas_url) {376 var xhr = new XMLHttpRequest();377 xhr.open('GET', style.canvas_url);378 xhr.responseType = 'arraybuffer';379 xhr.onload = () => {380 const localGUID = App.sendMessage(381 'getOrCreateSubscribedStyleNodeId',382 {383 styleKey: style.key,384 fileKey: style.file_key,385 editingFileKey: App._state.editingFileKey,386 versionHash: style.content_hash387 },388 new Uint8Array(xhr.response)389 ).args.localGUID.split(':');390 updateProperties(this.id, {391 inheritGridStyleID: { sessionID: localGUID[0], localID: localGUID[1] }392 });393 };394 xhr.send();395 } else {396 const localGUID = style.node_id.split(':');397 updateProperties(this.id, { inheritGridStyleID: { sessionID: localGUID[0], localID: localGUID[1] } });398 }399 }400 });401 }402 if (newNode.type !== 'FRAME' || newNode.type !== 'INSTANCE') {403 Object.defineProperties(newNode, {404 fills: {405 get() {406 return result.fillPaints;407 },408 set(val) {409 updateProperties(this.id, { fillPaints: val });410 }411 },412 strokes: {413 get() {414 return result.fillPaints;415 },416 set(val) {417 updateProperties(this.id, { fillPaints: val });418 }419 },420 strokeWeight: {421 get() {422 return result.strokeWeight;423 },424 set(val) {425 updateProperties(this.id, { strokeWeight: val });426 }427 },428 strokeAlign: {429 get() {430 return result.strokeAlign;431 },432 set(val) {433 updateProperties(this.id, { strokeAlign: val });434 }435 },436 strokeCap: {437 get() {438 return result.strokeCap;439 },440 set(val) {441 updateProperties(this.id, { strokeCap: val });442 }443 },444 strokeJoin: {445 get() {446 return result.strokeJoin;447 },448 set(val) {449 updateProperties(this.id, { strokeJoin: val });450 }451 },452 dashPattern: {453 get() {454 return result.dashPattern;455 },456 set(val) {457 updateProperties(this.id, { dashPattern: val });458 }459 }460 });461 }462 if (newNode.type === 'FRAME' || newNode.type === 'INSTANCE' || newNode.type === 'SYMBOL') {463 Object.defineProperties(newNode, {464 backgrounds: {465 get() {466 return result.backgroundPaints;467 },468 set(val) {469 updateProperties(this.id, { backgroundPaints: val });470 }471 },472 layoutGrids: {473 get() {474 return result.layoutGrids;475 },476 set(val) {477 updateProperties(this.id, { layoutGrids: val });478 }479 },480 clipsContent: {481 get() {482 return !result.frameMaskDisabled;483 },484 set(val) {485 updateProperties(this.id, { frameMaskDisabled: !val });486 }487 }488 });489 }490 if (491 newNode.type === 'BOOLEAN_OPERATION' ||492 newNode.type === 'VECTOR' ||493 newNode.type === 'STAR' ||494 newNode.type === 'REGULAR_POLYGON' ||495 newNode.type === 'RECTANGLE'496 ) {497 Object.defineProperties(newNode, {498 cornerRadius: {499 get() {500 return result.cornerRadius;501 },502 set(val) {503 updateProperties(this.id, { cornerRadius: val });504 }505 },506 cornerSmoothing: {507 get() {508 return result.cornerSmoothing;509 },510 set(val) {511 updateProperties(this.id, { cornerSmoothing: val });512 }513 }514 });515 }516 switch (newNode.type) {517 case 'STAR':518 Object.defineProperties(newNode, {519 pointCount: {520 get() {521 return result.count;522 },523 set(val) {524 updateProperties(this.id, { count: val });525 }526 },527 starInnerRadius: {528 get() {529 return result.starInnerScale;530 },531 set(val) {532 updateProperties(this.id, { starInnerScale: val });533 }534 }535 });536 break;537 case 'ELLIPSE':538 Object.defineProperty(newNode, 'arcData', {539 get() {540 return {541 startingAngle: result.arcStart,542 endingAngle: result.arcSweep,543 innerRadius: result.arcRadius544 };545 },546 set(val) {547 updateProperties(this.id, {548 arcStart: val.startingAngle,549 arcSweep: val.endingAngle,550 arcRadius: val.innerRadius551 });552 }553 });554 break;555 case 'REGULAR_POLYGON':556 Object.defineProperty(newNode, 'pointCount', {557 get() {558 return result.count;559 },560 set(val) {561 updateProperties(this.id, { count: val });562 }563 });564 break;565 case 'RECTANGLE':566 Object.defineProperties(newNode, {567 rectangleBottomLeftCornerRadius: {568 get() {569 return result.rectangleBottomLeftCornerRadius;570 },571 set(val) {572 updateProperties(this.id, { rectangleBottomLeftCornerRadius: val });573 }574 },575 rectangleBottomRightCornerRadius: {576 get() {577 return result.rectangleBottomRightCornerRadius;578 },579 set(val) {580 updateProperties(this.id, { rectangleBottomRightCornerRadius: val });581 }582 },583 rectangleTopLeftCornerRadius: {584 get() {585 return result.rectangleTopLeftCornerRadius;586 },587 set(val) {588 updateProperties(this.id, { rectangleTopLeftCornerRadius: val });589 }590 },591 rectangleTopRightCornerRadius: {592 get() {593 return result.rectangleTopRightCornerRadius;594 },595 set(val) {596 updateProperties(this.id, { rectangleTopRightCornerRadius: val });597 }598 },599 rectangleCornerRadiiIndependent: {600 get() {601 return result.rectangleCornerRadiiIndependent;602 },603 set(val) {604 updateProperties(this.id, { rectangleCornerRadiiIndependent: val });605 }606 }607 });608 break;609 case 'TEXT':610 Object.defineProperties(newNode, {611 fontSize: {612 get() {613 return result.fontSize;614 },615 set(val) {616 updateProperties(this.id, { fontSize: val });617 }618 },619 textAlignHorizontal: {620 get() {621 return result.textAlignHorizontal;622 },623 set(val) {624 updateProperties(this.id, { textAlignHorizontal: val });625 }626 },627 textAlignVertical: {628 get() {629 return result.textAlignVertical;630 },631 set(val) {632 updateProperties(this.id, { textAlignVertical: val });633 }634 },635 textDecoration: {636 get() {637 return result.textDecoration;638 },639 set(val) {640 updateProperties(this.id, { textDecoration: val });641 }642 },643 textAutoResize: {644 get() {645 return result.textAutoResize;646 },647 set(val) {648 updateProperties(this.id, { textAutoResize: val });649 }650 },651 fontName: {652 get() {653 return result.fontName;654 },655 set(val) {656 updateProperties(this.id, { fontName: val });657 }658 },659 letterSpacing: {660 get() {661 return result.letterSpacing;662 },663 set(val) {664 updateProperties(this.id, { letterSpacing: val });665 }666 },667 lineHeight: {668 get() {669 return result.lineHeight;670 },671 set(val) {672 updateProperties(this.id, { lineHeight: val });673 }674 },675 paragraphIndent: {676 get() {677 return result.paragraphIndent;678 },679 set(val) {680 updateProperties(this.id, { paragraphIndent: val });681 }682 },683 paragraphSpacing: {684 get() {685 return result.paragraphSpacing;686 },687 set(val) {688 updateProperties(this.id, { paragraphSpacing: val });689 }690 },691 textCase: {692 get() {693 return result.textCase;694 },695 set(val) {696 updateProperties(this.id, { textCase: val });697 }698 }699 });700 if (result.inheritTextStyleID && Object.keys(result.inheritTextStyleID)[0] !== '__mixed__') {701 Object.defineProperty(newNode, 'textStyleId', {702 get() {703 if (result.inheritTextStyleID.sessionID === 4294967295) return '';704 else return result.inheritTextStyleKey;705 },706 set(val) {707 const styles = Object.values(App._state.library.published.styles)708 .map(org => Object.values(org))709 .flat()710 .map(team => Object.values(team))711 .flat()712 .concat(Object.values(App._state.library.local.styles));713 const style = styles.find(style => style.key === val);714 if (style.canvas_url) {715 var xhr = new XMLHttpRequest();716 xhr.open('GET', style.canvas_url);717 xhr.responseType = 'arraybuffer';718 xhr.onload = () => {719 const localGUID = App.sendMessage(720 'getOrCreateSubscribedStyleNodeId',721 {722 styleKey: style.key,723 fileKey: style.file_key,724 editingFileKey: App._state.editingFileKey,725 versionHash: style.content_hash726 },727 new Uint8Array(xhr.response)728 ).args.localGUID.split(':');729 updateProperties(this.id, {730 inheritTextStyleID: { sessionID: localGUID[0], localID: localGUID[1] }731 });732 };733 xhr.send();734 } else {735 const localGUID = style.node_id.split(':');736 updateProperties(this.id, {737 inheritTextStyleID: { sessionID: localGUID[0], localID: localGUID[1] }738 });739 }740 }741 });742 }743 }744 return newNode;745 }746 };747 }748 if (sceneNode.type === 'BOOLEAN_OPERATION') {749 newNode.booleanOperation = sceneNode.booleanOperation;750 }751 if (newNode.children) {752 newNode.findAll = callback => findAll(newNode, callback);753 newNode.findOne = callback => findOne(newNode, callback);754 }755 if (newNode.type !== 'CANVAS')756 newNode.resize = (width, height) => {757 updateProperties(newNode.id, { width: width, height: height });758 };759 newNode.exportAsync = async settings => {760 const selectedNodes = Object.keys(App._state.mirror.sceneGraphSelection);761 if (selectedNodes.length !== 1 || (selectedNodes.length === 1 && newNode.id !== selectedNodes[0])) {762 App.sendMessage('clearSelection');763 await until(() => window.App._state.mirror.selectionProperties.visible === null);764 App.sendMessage('addToSelection', { nodeIds: [newNode.id] });765 await until(() => window.App._state.mirror.selectionProperties.visible !== null);766 }767 const nodeWithProperties = await newNode.getProperties();768 const originalExportSettings = nodeWithProperties.exportSettings;769 const newExportSettings = settings770 ? [settings]771 : [...

Full Screen

Full Screen

buildbug.js

Source:buildbug.js Github

copy

Full Screen

...153 var nodePackage = nodejs.findNodePackage(154 buildProject.getProperty("deploybug.packageJson.name"),155 buildProject.getProperty("deploybug.packageJson.version")156 );157 task.updateProperties({158 sourceRoot: nodePackage.getBuildPath()159 });160 }161 }),162 targetTask('packNodePackage', {163 properties: {164 packageName: buildProject.getProperty("deploybug.packageJson.name"),165 packageVersion: buildProject.getProperty("deploybug.packageJson.version")166 }167 }),168 targetTask('startNodeModuleTests', {169 init: function(task, buildProject, properties) {170 var packedNodePackage = nodejs.findPackedNodePackage(171 buildProject.getProperty("deploybug.packageJson.name"),172 buildProject.getProperty("deploybug.packageJson.version")173 );174 task.updateProperties({175 modulePath: packedNodePackage.getFilePath()176 });177 }178 }),179 targetTask("s3PutFile", {180 init: function(task, buildProject, properties) {181 var packedNodePackage = nodejs.findPackedNodePackage(buildProject.getProperty("deploybug.packageJson.name"),182 buildProject.getProperty("deploybug.packageJson.version"));183 task.updateProperties({184 file: packedNodePackage.getFilePath(),185 options: {186 acl: 'public-read'187 }188 });189 },190 properties: {191 bucket: buildProject.getProperty("local-bucket")192 }193 })194 ]),195 series([196 targetTask('createNodePackage', {197 properties: {198 packageJson: buildProject.getProperty("deploybugserver.packageJson"),199 sourcePaths: buildProject.getProperty("deploybugserver.sourcePaths"),200 scriptPaths: buildProject.getProperty("deploybugserver.scriptPaths"),201 testPaths: buildProject.getProperty("deploybugserver.testPaths"),202 binPaths: buildProject.getProperty("deploybugserver.binPaths")203 }204 }),205 targetTask('generateBugPackRegistry', {206 init: function(task, buildProject, properties) {207 var nodePackage = nodejs.findNodePackage(208 buildProject.getProperty("deploybugserver.packageJson.name"),209 buildProject.getProperty("deploybugserver.packageJson.version")210 );211 task.updateProperties({212 sourceRoot: nodePackage.getBuildPath()213 });214 }215 }),216 targetTask('packNodePackage', {217 properties: {218 packageName: buildProject.getProperty("deploybugserver.packageJson.name"),219 packageVersion: buildProject.getProperty("deploybugserver.packageJson.version")220 }221 }),222 targetTask('startNodeModuleTests', {223 init: function(task, buildProject, properties) {224 var packedNodePackage = nodejs.findPackedNodePackage(225 buildProject.getProperty("deploybugserver.packageJson.name"),226 buildProject.getProperty("deploybugserver.packageJson.version")227 );228 task.updateProperties({229 modulePath: packedNodePackage.getFilePath()230 });231 }232 }),233 targetTask("s3PutFile", {234 init: function(task, buildProject, properties) {235 var packedNodePackage = nodejs.findPackedNodePackage(buildProject.getProperty("deploybugserver.packageJson.name"),236 buildProject.getProperty("deploybugserver.packageJson.version"));237 task.updateProperties({238 file: packedNodePackage.getFilePath(),239 options: {240 acl: 'public-read'241 }242 });243 },244 properties: {245 bucket: buildProject.getProperty("local-bucket")246 }247 })248 ]),249 series([250 targetTask('createNodePackage', {251 properties: {252 packageJson: buildProject.getProperty("deploybugnode.packageJson"),253 sourcePaths: buildProject.getProperty("deploybugnode.sourcePaths"),254 scriptPaths: buildProject.getProperty("deploybugnode.scriptPaths"),255 testPaths: buildProject.getProperty("deploybugnode.testPaths"),256 binPaths: buildProject.getProperty("deploybugnode.binPaths")257 }258 }),259 targetTask('generateBugPackRegistry', {260 init: function(task, buildProject, properties) {261 var nodePackage = nodejs.findNodePackage(262 buildProject.getProperty("deploybugnode.packageJson.name"),263 buildProject.getProperty("deploybugnode.packageJson.version")264 );265 task.updateProperties({266 sourceRoot: nodePackage.getBuildPath()267 });268 }269 }),270 targetTask('packNodePackage', {271 properties: {272 packageName: buildProject.getProperty("deploybugnode.packageJson.name"),273 packageVersion: buildProject.getProperty("deploybugnode.packageJson.version")274 }275 }),276 targetTask('startNodeModuleTests', {277 init: function(task, buildProject, properties) {278 var packedNodePackage = nodejs.findPackedNodePackage(279 buildProject.getProperty("deploybugnode.packageJson.name"),280 buildProject.getProperty("deploybugnode.packageJson.version")281 );282 task.updateProperties({283 modulePath: packedNodePackage.getFilePath()284 });285 }286 }),287 targetTask("s3PutFile", {288 init: function(task, buildProject, properties) {289 var packedNodePackage = nodejs.findPackedNodePackage(buildProject.getProperty("deploybugnode.packageJson.name"),290 buildProject.getProperty("deploybugnode.packageJson.version"));291 task.updateProperties({292 file: packedNodePackage.getFilePath(),293 options: {294 ACL: 'public-read'295 }296 });297 },298 properties: {299 bucket: buildProject.getProperty("local-bucket")300 }301 })302 ])303 ])304 ])305).makeDefault();306// Prod Flow307//-------------------------------------------------------------------------------308buildTarget('prod').buildFlow(309 series([310 // TODO BRN: This "clean" task is temporary until we're not modifying the build so much. This also ensures that311 // old source files are removed. We should figure out a better way of doing that.312 targetTask('clean'),313 parallel([314 series([315 targetTask('createNodePackage', {316 properties: {317 packageJson: buildProject.getProperty("deploybug.packageJson"),318 sourcePaths: buildProject.getProperty("deploybug.sourcePaths"),319 scriptPaths: buildProject.getProperty("deploybug.scriptPaths"),320 testPaths: buildProject.getProperty("deploybug.testPaths"),321 binPaths: buildProject.getProperty("deploybug.binPaths")322 }323 }),324 targetTask('generateBugPackRegistry', {325 init: function(task, buildProject, properties) {326 var nodePackage = nodejs.findNodePackage(327 buildProject.getProperty("deploybug.packageJson.name"),328 buildProject.getProperty("deploybug.packageJson.version")329 );330 task.updateProperties({331 sourceRoot: nodePackage.getBuildPath()332 });333 }334 }),335 targetTask('packNodePackage', {336 properties: {337 packageName: buildProject.getProperty("deploybug.packageJson.name"),338 packageVersion: buildProject.getProperty("deploybug.packageJson.version")339 }340 }),341 targetTask('startNodeModuleTests', {342 init: function(task, buildProject, properties) {343 var packedNodePackage = nodejs.findPackedNodePackage(344 buildProject.getProperty("deploybug.packageJson.name"),345 buildProject.getProperty("deploybug.packageJson.version")346 );347 task.updateProperties({348 modulePath: packedNodePackage.getFilePath()349 });350 }351 }),352 targetTask("s3PutFile", {353 init: function(task, buildProject, properties) {354 var packedNodePackage = nodejs.findPackedNodePackage(buildProject.getProperty("deploybug.packageJson.name"),355 buildProject.getProperty("deploybug.packageJson.version"));356 task.updateProperties({357 file: packedNodePackage.getFilePath(),358 options: {359 acl: 'public-read'360 }361 });362 },363 properties: {364 bucket: "airbug"365 }366 })367 ]),368 series([369 targetTask('createNodePackage', {370 properties: {371 packageJson: buildProject.getProperty("deploybugserver.packageJson"),372 sourcePaths: buildProject.getProperty("deploybugserver.sourcePaths"),373 scriptPaths: buildProject.getProperty("deploybugserver.scriptPaths"),374 testPaths: buildProject.getProperty("deploybugserver.testPaths"),375 binPaths: buildProject.getProperty("deploybugserver.binPaths")376 }377 }),378 targetTask('generateBugPackRegistry', {379 init: function(task, buildProject, properties) {380 var nodePackage = nodejs.findNodePackage(381 buildProject.getProperty("deploybugserver.packageJson.name"),382 buildProject.getProperty("deploybugserver.packageJson.version")383 );384 task.updateProperties({385 sourceRoot: nodePackage.getBuildPath()386 });387 }388 }),389 targetTask('packNodePackage', {390 properties: {391 packageName: buildProject.getProperty("deploybugserver.packageJson.name"),392 packageVersion: buildProject.getProperty("deploybugserver.packageJson.version")393 }394 }),395 targetTask('startNodeModuleTests', {396 init: function(task, buildProject, properties) {397 var packedNodePackage = nodejs.findPackedNodePackage(398 buildProject.getProperty("deploybugserver.packageJson.name"),399 buildProject.getProperty("deploybugserver.packageJson.version")400 );401 task.updateProperties({402 modulePath: packedNodePackage.getFilePath()403 });404 }405 }),406 targetTask("s3PutFile", {407 init: function(task, buildProject, properties) {408 var packedNodePackage = nodejs.findPackedNodePackage(buildProject.getProperty("deploybugserver.packageJson.name"),409 buildProject.getProperty("deploybugserver.packageJson.version"));410 task.updateProperties({411 file: packedNodePackage.getFilePath(),412 options: {413 acl: 'public-read'414 }415 });416 },417 properties: {418 bucket: "airbug"419 }420 })421 ]),422 series([423 targetTask('createNodePackage', {424 properties: {425 packageJson: buildProject.getProperty("deploybugnode.packageJson"),426 sourcePaths: buildProject.getProperty("deploybugnode.sourcePaths"),427 scriptPaths: buildProject.getProperty("deploybugnode.scriptPaths"),428 testPaths: buildProject.getProperty("deploybugnode.testPaths"),429 binPaths: buildProject.getProperty("deploybugnode.binPaths")430 }431 }),432 targetTask('generateBugPackRegistry', {433 init: function(task, buildProject, properties) {434 var nodePackage = nodejs.findNodePackage(435 buildProject.getProperty("deploybugnode.packageJson.name"),436 buildProject.getProperty("deploybugnode.packageJson.version")437 );438 task.updateProperties({439 sourceRoot: nodePackage.getBuildPath()440 });441 }442 }),443 targetTask('packNodePackage', {444 properties: {445 packageName: buildProject.getProperty("deploybugnode.packageJson.name"),446 packageVersion: buildProject.getProperty("deploybugnode.packageJson.version")447 }448 }),449 targetTask('startNodeModuleTests', {450 init: function(task, buildProject, properties) {451 var packedNodePackage = nodejs.findPackedNodePackage(452 buildProject.getProperty("deploybugnode.packageJson.name"),453 buildProject.getProperty("deploybugnode.packageJson.version")454 );455 task.updateProperties({456 modulePath: packedNodePackage.getFilePath()457 });458 }459 }),460 targetTask("s3PutFile", {461 init: function(task, buildProject, properties) {462 var packedNodePackage = nodejs.findPackedNodePackage(buildProject.getProperty("deploybugnode.packageJson.name"),463 buildProject.getProperty("deploybugnode.packageJson.version"));464 task.updateProperties({465 file: packedNodePackage.getFilePath(),466 options: {467 ACL: 'public-read'468 }469 });470 },471 properties: {472 bucket: "airbug"473 }474 })475 ])476 ])477 ])478);

Full Screen

Full Screen

UpdatePropertiesSpec.js

Source:UpdatePropertiesSpec.js Github

copy

Full Screen

...25 'bpmn:MultiInstanceLoopCharacteristics'26 );27 var taskShape = elementRegistry.get('ServiceTask_1');28 // when29 modeling.updateProperties(taskShape, {30 loopCharacteristics: loopCharacteristics31 });32 // then33 expect(34 taskShape.businessObject.loopCharacteristics35 ).to.eql(loopCharacteristics);36 // task shape got updated37 expect(updatedElements).to.include(taskShape);38 }39 ));40 it('unsetting default flow', inject(function(elementRegistry, modeling) {41 // given42 var gatewayShape = elementRegistry.get('ExclusiveGateway_1');43 // when44 modeling.updateProperties(gatewayShape, { 'default': undefined });45 // then46 expect(gatewayShape.businessObject['default']).not.to.exist;47 // flow got updated, too48 expect(updatedElements).to.include(elementRegistry.get('SequenceFlow_1'));49 }));50 it('updating default flow', inject(function(elementRegistry, modeling) {51 // given52 var gatewayShape = elementRegistry.get('ExclusiveGateway_1'),53 newDefaultFlowConnection = elementRegistry.get('SequenceFlow_2'),54 newDefaultFlow = newDefaultFlowConnection.businessObject;55 // when56 modeling.updateProperties(gatewayShape, { 'default': newDefaultFlow });57 // then58 expect(gatewayShape.businessObject['default']).to.eql(newDefaultFlow);59 // flow got updated, too60 expect(updatedElements).to.include(newDefaultFlowConnection);61 }));62 it('should keep unchanged default flow untouched', inject(63 function(elementRegistry, modeling) {64 // given65 var gatewayShape = elementRegistry.get('ExclusiveGateway_1'),66 sequenceFlow = elementRegistry.get('SequenceFlow_2'),67 taskShape = elementRegistry.get('Task_1');68 // when69 modeling.reconnectStart(70 sequenceFlow,71 taskShape,72 {73 x: taskShape.x + taskShape.width,74 y: taskShape.y + taskShape.height / 275 }76 );77 // then78 expect(gatewayShape.businessObject.default).to.exist;79 }80 ));81 it('updating conditional flow on source replace', inject(82 function(bpmnReplace, elementRegistry) {83 // given84 var conditionalFlow = elementRegistry.get('SequenceFlow_3'),85 conditionalBo = conditionalFlow.businessObject,86 serviceTask = elementRegistry.get('ServiceTask_1');87 var conditionExpression = conditionalBo.conditionExpression;88 var userTaskData = {89 type: 'bpmn:UserTask'90 };91 // when92 bpmnReplace.replaceElement(serviceTask, userTaskData);93 // then94 expect(conditionalBo.conditionExpression).to.eql(conditionExpression);95 }96 ));97 it('updating conditional flow on target replace', inject(98 function(bpmnReplace, elementRegistry) {99 // given100 var conditionalFlow = elementRegistry.get('SequenceFlow_3'),101 conditionalBo = conditionalFlow.businessObject,102 endEvent = elementRegistry.get('EndEvent_1');103 var conditionExpression = conditionalBo.conditionExpression;104 var messageEndEventData = {105 type: 'bpmn:EndEvent',106 eventDefinitionType: 'bpmn:MessageEventDefinition'107 };108 // when109 bpmnReplace.replaceElement(endEvent, messageEndEventData);110 // then111 expect(conditionalBo.conditionExpression).to.eql(conditionExpression);112 }113 ));114 it('updating name', inject(function(elementRegistry, modeling) {115 // given116 var flowConnection = elementRegistry.get('SequenceFlow_1');117 // when118 modeling.updateProperties(flowConnection, { name: 'FOO BAR' });119 // then120 expect(flowConnection.businessObject.name).to.equal('FOO BAR');121 // flow label got updated, too122 expect(updatedElements).to.include(flowConnection.label);123 }));124 it('unsetting name', inject(function(elementRegistry, modeling) {125 // given126 var flowConnection = elementRegistry.get('SequenceFlow_3');127 // when128 modeling.updateProperties(flowConnection, { name: undefined });129 // then130 expect(flowConnection.businessObject.name).not.to.exist;131 }));132 it('updating id', inject(function(elementRegistry, modeling) {133 // given134 var flowConnection = elementRegistry.get('SequenceFlow_1'),135 flowBo = flowConnection.businessObject;136 var ids = flowBo.$model.ids;137 // when138 modeling.updateProperties(flowConnection, { id: 'FOO_BAR' });139 // then140 expect(ids.assigned('FOO_BAR')).to.eql(flowBo);141 expect(ids.assigned('SequenceFlow_1')).to.be.false;142 expect(flowBo.id).to.equal('FOO_BAR');143 expect(flowConnection.id).to.equal('FOO_BAR');144 }));145 it('updating extension elements', inject(146 function(elementRegistry, modeling) {147 // given148 var flowConnection = elementRegistry.get('SequenceFlow_1'),149 flowBo = flowConnection.businessObject;150 // when151 modeling.updateProperties(flowConnection, {152 'xmlns:foo': 'http://foo',153 'foo:customAttr': 'FOO'154 });155 // then156 expect(flowBo.get('xmlns:foo')).to.equal('http://foo');157 expect(flowBo.get('foo:customAttr')).to.equal('FOO');158 }159 ));160 it('setting di properties', inject(function(elementRegistry, modeling) {161 // given162 var flowConnection = elementRegistry.get('SequenceFlow_1'),163 flowBo = flowConnection.businessObject;164 // when165 modeling.updateProperties(flowConnection, {166 di: {167 fill: 'FUCHSIA'168 }169 });170 // then171 expect(flowBo.di.fill).to.equal('FUCHSIA');172 expect(flowBo.get('di')).not.to.exist;173 }));174 it('unsetting di properties', inject(function(elementRegistry, modeling) {175 // given176 var flowConnection = elementRegistry.get('SequenceFlow_1');177 modeling.updateProperties(flowConnection, { di: { fill: 'FUCHSIA' } });178 // when179 modeling.updateProperties(flowConnection, { di: { fill: undefined } });180 // then181 expect(flowConnection.businessObject.di.fill).not.to.exist;182 }));183 });184 describe('should undo', function() {185 it('setting loop characteristics', inject(186 function(elementRegistry, modeling, commandStack, moddle) {187 // given188 var loopCharactersistics = moddle.create('bpmn:MultiInstanceLoopCharacteristics');189 var taskShape = elementRegistry.get('ServiceTask_1');190 // when191 modeling.updateProperties(taskShape, { loopCharacteristics: loopCharactersistics });192 commandStack.undo();193 // then194 expect(taskShape.businessObject.loopCharactersistics).not.to.exist;195 }196 ));197 it('unsetting default flow', inject(198 function(elementRegistry, commandStack, modeling) {199 // given200 var gatewayShape = elementRegistry.get('ExclusiveGateway_1'),201 gatewayBo = gatewayShape.businessObject,202 oldDefaultBo = gatewayShape.businessObject['default'],203 oldDefaultConnection = elementRegistry.get(oldDefaultBo.id);204 // when205 modeling.updateProperties(gatewayShape, {206 'default': undefined207 });208 commandStack.undo();209 // then210 expect(gatewayBo['default']).to.eql(oldDefaultBo);211 // flow got updated, too212 expect(updatedElements).to.include(oldDefaultConnection);213 }214 ));215 it('updating default flow', inject(216 function(elementRegistry, commandStack, modeling) {217 // given218 var gatewayShape = elementRegistry.get('ExclusiveGateway_1'),219 gatewayBo = gatewayShape.businessObject,220 newDefaultFlowConnection = elementRegistry.get('SequenceFlow_2'),221 newDefaultFlow = newDefaultFlowConnection.businessObject,222 oldDefaultFlowConnection = elementRegistry.get('SequenceFlow_1'),223 oldDefaultFlow = oldDefaultFlowConnection.businessObject;224 // when225 modeling.updateProperties(gatewayShape, {226 'default': newDefaultFlow227 });228 commandStack.undo();229 // then230 expect(gatewayBo['default']).to.eql(oldDefaultFlow);231 // flow got updated, too232 expect(updatedElements).to.include(newDefaultFlowConnection);233 expect(updatedElements).to.include(oldDefaultFlowConnection);234 }235 ));236 it('updating name', inject(237 function(elementRegistry, commandStack, modeling) {238 // given239 var flowConnection = elementRegistry.get('SequenceFlow_1');240 // when241 modeling.updateProperties(flowConnection, { name: 'FOO BAR' });242 commandStack.undo();243 // then244 expect(flowConnection.businessObject.name).to.equal('default');245 // flow got updated, too246 expect(updatedElements).to.include(flowConnection.label);247 }248 ));249 it('unsetting name', inject(250 function(elementRegistry, commandStack, modeling) {251 // given252 var flowConnection = elementRegistry.get('SequenceFlow_3');253 modeling.updateProperties(flowConnection, { name: undefined });254 // when255 commandStack.undo();256 // then257 expect(flowConnection.businessObject.name).to.equal('conditional');258 }259 ));260 it('updating id', inject(function(elementRegistry, commandStack, modeling) {261 // given262 var flowConnection = elementRegistry.get('SequenceFlow_1'),263 flowBo = flowConnection.businessObject;264 var ids = flowBo.$model.ids;265 // when266 modeling.updateProperties(flowConnection, { id: 'FOO_BAR' });267 commandStack.undo();268 // then269 expect(ids.assigned('FOO_BAR')).to.be.false;270 expect(ids.assigned('SequenceFlow_1')).to.eql(flowBo);271 expect(flowConnection.id).to.equal('SequenceFlow_1');272 expect(flowBo.id).to.equal('SequenceFlow_1');273 }));274 it('updating extension elements', inject(275 function(elementRegistry, commandStack, modeling) {276 // given277 var flowConnection = elementRegistry.get('SequenceFlow_1'),278 flowBo = flowConnection.businessObject;279 modeling.updateProperties(flowConnection, {280 'xmlns:foo': 'http://foo',281 'foo:customAttr': 'FOO'282 });283 // when284 commandStack.undo();285 // then286 expect(flowBo.get('xmlns:foo')).not.to.exist;287 expect(flowBo.get('foo:customAttr')).not.to.exist;288 }289 ));290 });291 describe('should redo', function() {292 it('setting loop characteristics', inject(293 function(elementRegistry, modeling, commandStack, moddle) {294 // given295 var loopCharacteristics = moddle.create(296 'bpmn:MultiInstanceLoopCharacteristics'297 );298 var taskShape = elementRegistry.get('ServiceTask_1'),299 taskBo = taskShape.businessObject;300 // when301 modeling.updateProperties(taskShape, {302 loopCharacteristics: loopCharacteristics303 });304 commandStack.undo();305 commandStack.redo();306 // then307 expect(taskBo.loopCharacteristics).to.eql(loopCharacteristics);308 }309 ));310 it('updating default flow', inject(311 function(elementRegistry, commandStack, modeling) {312 // given313 var gatewayShape = elementRegistry.get('ExclusiveGateway_1');314 // when315 modeling.updateProperties(gatewayShape, { 'default': undefined });316 commandStack.undo();317 commandStack.redo();318 // then319 expect(gatewayShape.businessObject['default']).not.to.exist;320 // flow got updated, too321 expect(updatedElements).to.include(322 elementRegistry.get('SequenceFlow_1')323 );324 }325 ));326 it('updating name', inject(327 function(elementRegistry, commandStack, modeling) {328 // given329 var flowConnection = elementRegistry.get('SequenceFlow_1');330 // when331 modeling.updateProperties(flowConnection, { name: 'FOO BAR' });332 commandStack.undo();333 commandStack.redo();334 // then335 expect(flowConnection.businessObject.name).to.equal('FOO BAR');336 // flow got updated, too337 expect(updatedElements).to.include(flowConnection.label);338 }339 ));340 it('unsetting name', inject(341 function(elementRegistry, commandStack, modeling) {342 // given343 var flowConnection = elementRegistry.get('SequenceFlow_3');344 modeling.updateProperties(flowConnection, { name: undefined });345 // when346 commandStack.undo();347 commandStack.redo();348 // then349 expect(flowConnection.businessObject.name).not.to.exist;350 }351 ));352 });353 describe('unwrap diagram elements', function() {354 it('updating default flow with connection', inject(355 function(elementRegistry, modeling) {356 // given357 var gatewayShape = elementRegistry.get('ExclusiveGateway_1'),358 newDefaultFlowConnection = elementRegistry.get('SequenceFlow_2');359 // when360 modeling.updateProperties(gatewayShape, {361 'default': newDefaultFlowConnection362 });363 // then364 expect(gatewayShape.businessObject['default']).to.eql(365 newDefaultFlowConnection.businessObject366 );367 // flow got updated, too368 expect(updatedElements).to.include(newDefaultFlowConnection);369 }370 ));371 });372 describe('error handling', function() {373 it('should ignore unchanged id', inject(374 function(elementRegistry, modeling) {375 // given376 var flowConnection = elementRegistry.get('SequenceFlow_1'),377 flowBo = flowConnection.businessObject;378 var ids = flowBo.$model.ids;379 // when380 modeling.updateProperties(flowConnection, { id: 'SequenceFlow_1' });381 // then382 expect(ids.assigned('SequenceFlow_1')).to.eql(flowBo);383 expect(flowBo.id).to.equal('SequenceFlow_1');384 }385 ));386 it('should ignore setting color on root', inject(387 function(canvas, modeling) {388 // given389 var rootElement = canvas.getRootElement();390 // when391 modeling.updateProperties(rootElement, {392 di: {393 fill: 'fuchsia'394 }395 });396 // then397 expect(rootElement.di).not.to.exist;398 }399 ));400 });...

Full Screen

Full Screen

rooms.js

Source:rooms.js Github

copy

Full Screen

1function BaseRoom(title, type, hp) {2 this.title = title;3 this.type = type;4 this.hp = hp;5 this.maxHp = this.hp;6 this.level = 0;7 this.crew = [];8 this.upgradesPerLevel = [];9}10function BaseEnergyConsumerRoom(demand) {11 this.energyDemand = demand;12 this.energy = 0;13}14BaseEnergyConsumerRoom.updateProperties = function(ship) {15 if (this.hp == 0) {16 ship.freeEnergy += this.energy;17 this.energy = 0;18 }19}20function BaseActionRoom(reloadRate) {21 this.lastProgressUpdateAt = 0;22 this.progress = 0;23 this.maxReloadRate = reloadRate;24 this.reloadRate = 0;25 this.resetTimers = function() {26 let now = Date.now();27 if (this.lastProgressUpdateAt !== undefined) {28 this.lastProgressUpdateAt = now;29 }30 }31}32BaseActionRoom.updateProperties = function(ship) {33 this.reloadRate = Math.round(this.maxReloadRate*this.energy/this.energyDemand);34}35function BaseWeaponRoom(damage) {36 this.maxDamage = damage;37 this.damage = 0;38 this.targetId = -1;39}40BaseWeaponRoom.updateProperties = function(ship) {41 this.damage = Math.round(this.maxDamage*(this.hp/this.maxHp));42 if (this.hp > 0 && this.damage == 0) {43 this.damage = 1;44 }45}46function LaserRoom() {47 BaseRoom.call(this, "Laser", WEAPON_CLASS, HP_UNIT);48 BaseEnergyConsumerRoom.call(this, 3);49 BaseActionRoom.call(this, 5);50 BaseWeaponRoom.call(this, HP_UNIT);51 this.upgradesPerLevel = [52 new Upgrade(100, 100, {maxReloadRate: 1}),53 new Upgrade(300, 300, {maxHp: HP_UNIT}),54 new Upgrade(600, 150, {maxReloadRate: 1}),55 ];56 this.upgrade = this.upgradesPerLevel[this.level];57}58function MinigunRoom() {59 BaseRoom.call(this, "Minigun", WEAPON_CLASS, HP_UNIT);60 BaseEnergyConsumerRoom.call(this, 2);61 BaseActionRoom.call(this, 10);62 BaseWeaponRoom.call(this, 2);63 this.upgradesPerLevel = [64 new Upgrade(100, 100, {maxDamage: 1}),65 new Upgrade(300, 300, {maxHp: HP_UNIT}),66 new Upgrade(600, 150, {maxDamage: 1}),67 ];68 this.upgrade = this.upgradesPerLevel[this.level];69}70function ShieldRoom() {71 BaseRoom.call(this, "Shield", SHIELD_CLASS, HP_UNIT);72 BaseEnergyConsumerRoom.call(this, 3);73 BaseActionRoom.call(this, 5);74 this.maxMaxShield = HP_UNIT;75 this.upgradesPerLevel = [76 new Upgrade(100, 1000, {maxMaxShield: 1}),77 new Upgrade(200, 2000, {maxReloadRate: 1}),78 new Upgrade(500, 3500, {maxHp: HP_UNIT}),79 ];80 this.upgrade = this.upgradesPerLevel[this.level];81 // Fight specific82 this.maxShield = 0;83 this.shield = 0;84 this.curShield = 0;85}86function ReactorRoom() {87 BaseRoom.call(this, "Reactor", ENERGY_PROVIDER_CLASS, HP_UNIT);88 this.maxEnergySupply = 3;89 this.upgradesPerLevel = [90 new Upgrade(100, 200, {maxEnergySupply: 1}),91 new Upgrade(300, 150, {maxHp: HP_UNIT}),92 new Upgrade(200, 400, {maxEnergySupply: 1}),93 new Upgrade(400, 800, {maxEnergySupply: 1}),94 new Upgrade(1000, 300, {maxHp: HP_UNIT}),95 ];96 this.upgrade = this.upgradesPerLevel[this.level];97 // Fight specific98 this.energySupply = 0;99}100function OxygenRoom() {101 BaseRoom.call(this, "Oxygen Generator", OXYGEN_CLASS, HP_UNIT);102 BaseEnergyConsumerRoom.call(this, 2);103 this.maxCapacity = 1;104 this.crew = [105 new CrewMember()106 ];107 // Fight specific108 this.capacity = 0;109}110LaserRoom.prototype.updateProperties = function(ship) {111 BaseEnergyConsumerRoom.updateProperties.call(this, ship);112 BaseActionRoom.updateProperties.call(this, ship);113 BaseWeaponRoom.updateProperties.call(this, ship);114}115MinigunRoom.prototype.updateProperties = function(ship) {116 BaseEnergyConsumerRoom.updateProperties.call(this, ship);117 BaseActionRoom.updateProperties.call(this, ship);118 BaseWeaponRoom.updateProperties.call(this, ship);119}120ShieldRoom.prototype.updateProperties = function(ship) {121 BaseEnergyConsumerRoom.updateProperties.call(this, ship);122 BaseActionRoom.updateProperties.call(this, ship);123 if (this.hp == 0) {124 this.curShield = 0;125 }126 this.maxShield = Math.round(this.maxMaxShield*(this.hp/this.maxHp));127 if (this.curShield > this.maxShield) {128 this.curShield = this.maxShield;129 }130}131ReactorRoom.prototype.updateProperties = function(ship) {132 let before = this.energySupply;133 this.energySupply = Math.round(this.maxEnergySupply*(this.hp/this.maxHp));134 ship.freeEnergy += this.energySupply - before;135}136OxygenRoom.prototype.updateProperties = function(ship) {137 this.capacity = Math.round(this.maxCapacity*(this.hp/this.maxHp));138}139function createRoom(title) {140 let r;141 switch (title) {142 case 'Minigun':143 r = new MinigunRoom();144 break;145 case 'Laser':146 r = new LaserRoom();147 break;148 case 'Reactor':149 r = new ReactorRoom();150 break;151 case 'Shield':152 r = new ShieldRoom();153 break;154 case 'Oxygen Generator':155 r = new OxygenRoom();156 break;157 }158 return r;159}160function loadRoomFrom(data) {161 var room = createRoom(data.title);162 for (key in data) {163 if (typeof data[key] !== 'object') {164 room[key] = data[key];165 }166 }167 room.crew = [];168 for (i in data.crew) {169 room.crew.push(CrewMember.loadFrom(data.crew[i]));170 }171 room.upgradesPerLevel = [];172 for (i in data.upgradesPerLevel) {173 let upgrade = data.upgradesPerLevel[i];174 room.upgradesPerLevel.push(Upgrade.loadFrom(upgrade)); 175 }176 room.upgrade = room.upgradesPerLevel[room.level];177 if (room.loadFrom !== undefined) {178 room.loadFrom(data);179 }180 return room;...

Full Screen

Full Screen

agile_task_helper.js

Source:agile_task_helper.js Github

copy

Full Screen

1// Evelyn: Your personal assistant, project manager and calendar2// Copyright (C) 2017 Gregory Jensen3//4// This program is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.8//9// This program is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.13//14// You should have received a copy of the GNU General Public License15// along with this program. If not, see <http://www.gnu.org/licenses/>.16var httpHelper = require('../chai_http_request_helper');17var serverErrorHelper = require('../server_error_helper.js')18var _ = require('lodash');19module.exports = {20 createTask: createTask,21 lookupTask: lookupTask,22 lookupBacklog: lookupBacklog,23 updateTask: updateTask24};25function createTask(token, projectId, taskRef, otherProperties) {26 return httpHelper.post('/agile/task/create', {27 Token: token,28 ProjectId: projectId,29 Title: "title_" + taskRef,30 Description: "description_" + taskRef,31 OriginalEstimate: _.get(otherProperties, 'originalEstimate', '1h'),32 })33 .then(serverErrorHelper.newResponseHandler());34}35function lookupTask(token, projectId, taskId) {36 return httpHelper.post('/agile/task/lookup', {37 Token: token,38 ProjectId: projectId,39 TaskId: taskId40 })41 .then(serverErrorHelper.newResponseHandler());42}43function lookupBacklog(token, projectId) {44 return httpHelper.post('/agile/task/lookup/backlog', {45 Token: token,46 ProjectId: projectId47 })48 .then(serverErrorHelper.newResponseHandler());49}50function updateTask(token, projectId, taskId, updateProperties) {51 var payload = {52 Token: token,53 ProjectId: projectId,54 TaskId: taskId55 };56 if (_.has(updateProperties, 'title')) {57 payload.Title = updateProperties.title;58 }59 if (_.has(updateProperties, 'description')) {60 payload.Description = updateProperties.description;61 }62 if (_.has(updateProperties, 'originalEstimate')) {63 payload.OriginalEstimate = updateProperties.originalEstimate;64 }65 if (_.has(updateProperties, 'assignToUserId')) {66 payload.AssignToUserId = updateProperties.assignToUserId;67 }68 return httpHelper.post('/agile/task/update', payload)69 .then(serverErrorHelper.newResponseHandler());...

Full Screen

Full Screen

ui.js

Source:ui.js Github

copy

Full Screen

1libx.ui.setIcon = function (path) {2 if (!path)3 path = libx.utils.getExtensionURL("$libxicon$");4 chrome.browserAction.setIcon({ path: path });5};6libx.ui.tabs = {7 create: function (createData) {8 chrome.tabs.create(createData);9 },10 11 update: function (tabId, updateProperties, callback) {12 chrome.tabs.update(tabId, updateProperties, callback);13 },14 15 getSelected: function (callback) {16 // http://developer.chrome.com/extensions/tabs.html#method-query17 // http://developer.chrome.com/extensions/whats_new.html#1618 chrome.tabs.query({'active': true, 'currentWindow': true}, function (tabs) {19 callback(tabs[0]);20 });21 },22 23 sendMessage: function (tabId, request, callback) {24 chrome.tabs.sendMessage(tabId, request, callback);25 }26 27};28libx.ui.windows = {29 create: function (createData) {30 chrome.windows.create(createData);31 }32};33function getVisibilityPattern(visible) {34 if (visible)35 return ["http://*/*", "https://*/*"];36 return ["http://do.not.show.this.item/"];37}38libx.ui.ContextMenu = libx.core.Class.create( libx.ui.ContextMenu,39{40 initialize: function () {41 chrome.contextMenus.removeAll();42 this.parent();43 },44 45 addItem: function (item) {46 var contexts = item.contexts;47 var id = chrome.contextMenus.create({48 type: "normal",49 title: item.title,50 contexts: contexts,51 onclick: function (info) {52 item.onclick(info);53 },54 documentUrlPatterns: getVisibilityPattern(item.visible)55 });56 this.registerItem(id, item);57 },58 59 update: function (itemId, updateProperties) {60 61 // Google Chrome currently has no option to set item visibility, so62 // changing the document url pattern works around this63 if (updateProperties.visible != null) {64 updateProperties.documentUrlPatterns = getVisibilityPattern(updateProperties.visible);65 delete updateProperties.visible;66 }67 chrome.contextMenus.update(itemId, updateProperties);68 69 } ...

Full Screen

Full Screen

updateProperties.js

Source:updateProperties.js Github

copy

Full Screen

...28 height: 121,29 };30 });31 it('should update properties with a map', () => {32 const update = updateProperties(element, { x: 21, y: 22 });33 expect(update).toStrictEqual({ x: 21, y: 22 });34 });35 it('should update properties with a function', () => {36 const update = updateProperties(element, ({ x, y }) => ({37 x: x + 1,38 y: y + 1,39 }));40 expect(update).toStrictEqual({ x: 12, y: 13 });41 });42 it('should tolerate null/undefined', () => {43 expect(updateProperties(element, null)).toStrictEqual({});44 expect(updateProperties(element, undefined)).toStrictEqual({});45 expect(updateProperties(element, () => null)).toStrictEqual({});46 expect(updateProperties(element, () => undefined)).toStrictEqual({});47 });48 it('should remove "multi" values', () => {49 expect(50 updateProperties(element, { x: MULTIPLE_VALUE, y: 1 })51 ).toStrictEqual({ y: 1 });52 });53 it('should keep intermediary "empty" values', () => {54 expect(updateProperties(element, { x: '', y: 1 })).toStrictEqual({55 x: '',56 y: 1,57 });58 });59 it('should remove final "empty" values', () => {60 expect(updateProperties(element, { x: '', y: 1 }, true)).toStrictEqual({61 y: 1,62 });63 });...

Full Screen

Full Screen

Properties.js

Source:Properties.js Github

copy

Full Screen

1import React from 'react';2import PropTypes from 'prop-types';3import { bindActionCreators } from 'redux';4import { connect } from 'react-redux';5import { Header, Menu, Segment } from 'semantic-ui-react';6import { actions, selectors } from '../../../../redux/modules/collections';7import * as shapes from '../../../shapes';8import UpdateCollectionPropertiesForm from '../../../shared/Forms/Collection/UpdateCollectionPropertiesForm';9const Properties = (props) => {10 const {11 collection, wip, err, updateProperties12 } = props;13 return (14 <div>15 <Menu attached borderless size="large">16 <Menu.Item header>17 <Header content="Extra properties" size="medium" color="blue" />18 </Menu.Item>19 </Menu>20 <Segment attached>21 <UpdateCollectionPropertiesForm22 collection={collection}23 wip={wip}24 err={err}25 update={updateProperties}26 />27 </Segment>28 </div>29 );30};31Properties.propTypes = {32 collection: shapes.Collection,33 wip: PropTypes.bool,34 err: shapes.Error,35 updateProperties: PropTypes.func.isRequired,36};37Properties.defaultProps = {38 collection: null,39 wip: false,40 err: null,41};42const mapState = state => ({43 wip: selectors.getWIP(state.collections, 'updateProperties'),44 err: selectors.getError(state.collections, 'updateProperties'),45});46function mapDispatch(dispatch) {47 return bindActionCreators({ updateProperties: actions.updateProperties }, dispatch);48}...

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.updateProperties('window', {7 });8 await page.evaluate(() => {9 console.log(window.test);10 });11 await browser.close();12})();

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.updateProperties('window', {myProperty: 'myValue'});7 await browser.close();8})();9const {chromium} = require('playwright');10(async () => {11 const browser = await chromium.launch();12 const context = await browser.newContext();13 const page = await context.newPage();14 console.log(await page.evaluate(() => window.myProperty));15 await browser.close();16})();

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.updateProperties({ viewportSize: { width: 500, height: 500 } });7 await page.screenshot({ path: `example.png` });8 await browser.close();9})();

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.updateProperties('window', {7 });8 await page.evaluate(() => {9 });10 await browser.close();11})();12const { chromium } = require('playwright');13(async () => {14 const browser = await chromium.launch();15 const context = await browser.newContext();16 const page = await context.newPage();17 await page.updateProperties('window', {18 });19 await page.evaluate(() => {20 });21 await browser.close();22})();

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.updateProperties({7 userAgent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36'8 });9 await browser.close();10})();

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.updateProperties({viewportSize: {width: 1000, height: 600}});7 await page.screenshot({path: 'screenshot.png'});8 await browser.close();9})();10const {chromium} = require('playwright');11(async () => {12 const browser = await chromium.launch();13 const context = await browser.newContext();14 const page = await context.newPage();15 await page.updateProperties({viewportSize: {width: 1000, height: 600}});16 await page.screenshot({path: 'screenshot.png'});17 await browser.close();18})();19const {chromium} = require('playwright');20(async () => {21 const browser = await chromium.launch();22 const context = await browser.newContext();23 const page = await context.newPage();24 await page.updateProperties({viewportSize: {width: 1000, height: 600}});25 await page.screenshot({path: 'screenshot.png'});26 await browser.close();27})();28const {chromium} = require('playwright');29(async () => {30 const browser = await chromium.launch();31 const context = await browser.newContext();32 const page = await context.newPage();33 await page.updateProperties({viewportSize: {width: 1000, height: 600}});34 await page.screenshot({path: 'screenshot.png'});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();

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 await context.updateProperties({ viewport: { width: 100, height: 100 } });6 const page = await context.newPage();7 await page.screenshot({ path: 'example.png' });8 await browser.close();9})();10 at processTicksAndRejections (internal/process/task_queues.js:93:5)11 at processTicksAndRejections (internal/process/task_queues.js:93:5

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 await context.updateProperties({6 recordHar: { path: 'har.json' },7 recordVideo: { dir: 'videos' },8 recordTrace: { name: 'trace' },9 });10 const page = await context.newPage();11 await browser.close();12})();13const { chromium } = require('playwright');14(async () => {15 const browser = await chromium.launch();16 const context = await browser.newContext();17 await context.updateProperties({18 recordHar: { path: 'har.json' },19 recordVideo: { dir: 'videos' },20 recordTrace: { name: 'trace' },21 });22 const page = await context.newPage();23 await browser.close();24})();25const { chromium } = require('playwright');26(async () => {27 const browser = await chromium.launch();28 const context = await browser.newContext();29 await context.updateProperties({30 recordHar: { path: 'har.json' },31 recordVideo: { dir: 'videos' },32 recordTrace: { name: 'trace' },33 });34 const page = await context.newPage();35 await browser.close();36})();37const { chromium } = require('playwright');38(async () => {39 const browser = await chromium.launch();40 const context = await browser.newContext();41 await context.updateProperties({42 recordHar: { path: 'har.json' },43 recordVideo: { dir: 'videos' },44 recordTrace: { name: 'trace' },45 });46 const page = await context.newPage();47 await browser.close();48})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const page = await browser.newPage();2await page.updateProperties({3 'request': {4 'headers': {5 }6 }7});8const context = await browser.newContext();9await context.updateProperties({10 'request': {11 'headers': {12 }13});14const page = await context.newPage();15await browser.updateProperties({16 'request': {17 'headers': {18 }19});20const context = await browser.newContext();21const page = await context.newPage();

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