Best JavaScript code snippet using wpt
Record.class.js
Source:Record.class.js
1/**2 * Fired, when the field's value changes: local record (`child`) now references the `collection_owner`3 * @event Lava.data.field.Record#added_child4 * @type {Object}5 * @property {Lava.data.Record} collection_owner New referenced record6 * @property {Lava.data.Record} child Referencing record from local module7 */8/**9 * Fired, when the field's value changes: local record (`child`) no longer references the `collection_owner`10 * @event Lava.data.field.Record#removed_child11 * @type {Object}12 * @property {Lava.data.Record} collection_owner Old referenced record13 * @property {Lava.data.Record} child Referencing record from local module14 */15Lava.define(16'Lava.data.field.Record',17/**18 * References a record (usually from another module).19 * Also maintains collections of records, grouped by this field (used by mirror Collection field)20 * and synchronizes it's state with accompanying ForeignKey field21 *22 * @lends Lava.data.field.Record#23 * @extends Lava.data.field.Abstract24 */25{26 Extends: 'Lava.data.field.Abstract',27 /**28 * This class is instance of a Record field29 * @type {boolean}30 * @const31 */32 isRecordField: true,33 /**34 * Owner module for the records of this field35 * @type {Lava.data.Module}36 */37 _referenced_module: null,38 /**39 * Records, grouped by this field. Serves as a helper for mirror Collection field.40 * Key is GUID of the foreign record, value is collection of records from local module41 * @type {Object.<string, Array.<Lava.data.Record>>}42 */43 _collections_by_foreign_guid: {},44 /**45 * Name of accompanying {@link Lava.data.field.ForeignKey} field from local module. Example: 'parent_id'46 * @type {string}47 */48 _foreign_key_field_name: null,49 /**50 * Local field with ID of the record in external module51 * @type {Lava.data.field.ForeignKey}52 */53 _foreign_key_field: null,54 /**55 * Listener for {@link Lava.data.field.Abstract#event:changed} in `_foreign_key_field`56 * @type {_tListener}57 */58 _foreign_key_changed_listener: null,59 /**60 * The {@link Lava.data.field.Id} field in external module61 * @type {Lava.data.field.Abstract}62 */63 _external_id_field: null,64 /**65 * The listener for external ID creation event ({@link Lava.data.field.Abstract#event:changed} in `_external_id_field` field)66 * @type {_tListener}67 */68 _external_id_changed_listener: null,69 /**70 * Listener for {@link Lava.data.Module#event:records_loaded} in external module71 * @type {_tListener}72 */73 _external_records_loaded_listener: null,74 /**75 * The foreign ID value, when there is no referenced record76 * @const77 */78 EMPTY_FOREIGN_ID: 0,79 _is_nullable: true,80 /**81 * @param module82 * @param name83 * @param {_cRecordField} config84 * @param module_storage85 */86 init: function(module, name, config, module_storage) {87 this.Abstract$init(module, name, config, module_storage);88 this._referenced_module = (config.module == 'this') ? module : module.getApp().getModule(config.module);89 },90 onModuleFieldsCreated: function(default_properties) {91 if (this._config.foreign_key_field) {92 if (Lava.schema.DEBUG && !this._referenced_module.hasField('id')) Lava.t("field/Record: the referenced module must have an ID field");93 this._foreign_key_field_name = this._config.foreign_key_field;94 this._foreign_key_field = this._module.getField(this._foreign_key_field_name);95 if (Lava.schema.DEBUG && !this._foreign_key_field.isForeignKey) Lava.t();96 this._foreign_key_changed_listener = this._foreign_key_field.on('changed', this._onForeignKeyChanged, this);97 this._external_id_field = this._referenced_module.getField('id');98 this._external_id_changed_listener = this._external_id_field.on('changed', this._onExternalIdCreated, this);99 this._external_records_loaded_listener = this._referenced_module.on('records_loaded', this._onReferencedModuleRecordsLoaded, this);100 }101 // this field stores the referenced record102 default_properties[this._name] = null;103 },104 /**105 * There may be local records that reference external records, which are not yet loaded (by ForeignKey).106 * This field is <kw>null</kw> for them.107 * When referenced records are loaded - local records must update this field with the newly loaded instances108 * @param {Lava.data.Module} module109 * @param {Lava.data.Module#event:records_loaded} event_args110 */111 _onReferencedModuleRecordsLoaded: function(module, event_args) {112 var records = event_args.records,113 count = records.length,114 i = 0,115 local_records,116 local_count,117 local_index,118 local_record;119 for (; i < count; i++) {120 local_records = this._foreign_key_field.getCollection(records[i].get('id'));121 // these records belong to this module and have this field null.122 // Now, as the foreign record is loaded - the field can be updated.123 for (local_count = local_records.length, local_index = 0; local_index < local_count; local_index++) {124 local_record = local_records[local_index];125 this._properties_by_guid[local_record.guid][this._name] = records[i];126 this._fireFieldChangedEvents(local_record);127 }128 }129 },130 /**131 * A record was saved to the database and assigned an id. Need to assign foreign keys for local records132 * @param {Lava.data.field.Id} foreign_module_id_field133 * @param {Lava.data.field.Abstract#event:changed} event_args134 */135 _onExternalIdCreated: function(foreign_module_id_field, event_args) {136 var referenced_record = event_args.record, // record belongs to foreign module137 new_referenced_id = referenced_record.get('id'),138 collection,139 i = 0,140 count;141 if (referenced_record.guid in this._collections_by_foreign_guid) {142 collection = this._collections_by_foreign_guid[referenced_record.guid];143 // Set the value of foreign ID field in all local records that reference this foreign record.144 // Situation: there is a new record, which was created in the browser, and some records that reference it145 // (either new or loaded from database). It's new, so there are no records on server that reference it.146 if (this._foreign_key_field) {147 Lava.suspendListener(this._foreign_key_changed_listener);148 for (count = collection.length; i < count; i++) {149 collection[i].set(this._foreign_key_field_name, new_referenced_id);150 }151 Lava.resumeListener(this._foreign_key_changed_listener);152 }153 }154 },155 /**156 * Fires, when local record's foreign id field is assigned a new value.157 * Example:158 * ```javascript159 * record.set('category_id', 123); // 'record' is from local module, 123 - id of foreign record160 * ```161 * @param {Lava.data.field.ForeignKey} foreign_key_field162 * @param {Lava.data.field.Abstract#event:changed} event_args163 */164 _onForeignKeyChanged: function(foreign_key_field, event_args) {165 var record = event_args.record, // record belongs to this module166 properties = this._properties_by_guid[record.guid];167 if (properties[this._name] != null) {168 // remove old record from collection169 this._unregisterRecord(record, properties[this._name]);170 }171 if (properties[this._foreign_key_field_name]) {172 this._registerByReferencedId(record, properties, properties[this._foreign_key_field_name]);173 } else {174 properties[this._name] = null;175 }176 this._fireFieldChangedEvents(record);177 },178 isValidValue: function(new_record) {179 return (180 (new_record === null && this._is_nullable)181 || (typeof(new_record) != 'undefined'182 && new_record.isRecord183 && new_record.getModule() === this._referenced_module)184 );185 },186 getInvalidReason: function(value) {187 var reason = this.Abstract$getInvalidReason(value);188 if (!reason) {189 if (!value.isRecord) {190 reason = "Value is not record";191 } else if (value.getModule() === this._referenced_module) {192 reason = "Value is from different module than this field refers to";193 }194 }195 return reason;196 },197 initNewRecord: function(record, properties) {198 if (this._foreign_key_field && properties[this._foreign_key_field_name]) {199 this._registerByReferencedId(record, properties, properties[this._foreign_key_field_name]);200 }201 },202 'import': function(record, properties, raw_properties) {203 var foreign_id;204 if (this._foreign_key_field) {205 // if foreign id is in import - then it will replace the default value (if foreign kay has default)206 foreign_id = raw_properties[this._foreign_key_field_name] || properties[this._foreign_key_field_name];207 if (foreign_id) {208 this._registerByReferencedId(record, properties, foreign_id);209 }210 }211 },212 /**213 * Update value of this field in local `record` and add the record to field's internal collections214 * @param {Lava.data.Record} record The local record215 * @param {Object} properties The properties of local record216 * @param {string} referenced_record_id The id of foreign record, which it belongs to217 */218 _registerByReferencedId: function(record, properties, referenced_record_id) {219 properties[this._name] = this._referenced_module.getRecordById(referenced_record_id) || null;220 if (properties[this._name]) {221 this._registerRecord(record, properties[this._name]);222 }223 },224 'export': function(record, destination_object) {225 },226 getValue: function(record, properties) {227 return properties[this._name];228 },229 setValue: function(record, properties, new_ref_record) {230 if (Lava.schema.data.VALIDATE_VALUES && !this.isValidValue(new_ref_record))231 Lava.t("Field/Record: assigned value is not valid. Reason: " + this.getInvalidReason(new_ref_record));232 if (properties[this._name] != null) {233 // remove from the old record's collection234 this._unregisterRecord(record, properties[this._name]);235 }236 properties[this._name] = new_ref_record;237 if (new_ref_record != null) {238 this._registerRecord(record, new_ref_record)239 }240 if (this._foreign_key_field) {241 Lava.suspendListener(this._foreign_key_changed_listener);242 if (new_ref_record != null) {243 // if this module has foreign_key_field then foreign module must have an ID column244 record.set(this._foreign_key_field_name, new_ref_record.get('id'));245 } else {246 record.set(this._foreign_key_field_name, this.EMPTY_FOREIGN_ID);247 }248 Lava.resumeListener(this._foreign_key_changed_listener);249 }250 this._fireFieldChangedEvents(record);251 },252 /**253 * Remove `local_record` from field's internal collection referenced by `referenced_record`254 * @param {Lava.data.Record} local_record255 * @param {Lava.data.Record} referenced_record256 */257 _unregisterRecord: function(local_record, referenced_record) {258 if (!Firestorm.Array.exclude(this._collections_by_foreign_guid[referenced_record.guid], local_record)) Lava.t();259 this._fire('removed_child', {260 collection_owner: referenced_record,261 child: local_record262 });263 },264 /**265 * Add `local_record` to field's internal collection of records from local module, referenced by `referenced_record`266 * @param {Lava.data.Record} local_record267 * @param {Lava.data.Record} referenced_record The collection owner268 */269 _registerRecord: function(local_record, referenced_record) {270 var referenced_guid = referenced_record.guid;271 if (referenced_guid in this._collections_by_foreign_guid) {272 if (Lava.schema.DEBUG && this._collections_by_foreign_guid[referenced_guid].indexOf(local_record) != -1)273 Lava.t("Duplicate record");274 this._collections_by_foreign_guid[referenced_guid].push(local_record);275 } else {276 this._collections_by_foreign_guid[referenced_guid] = [local_record];277 }278 this._fire('added_child', {279 collection_owner: referenced_record,280 child: local_record281 });282 },283 /**284 * API for {@link Lava.data.field.Collection} field. Get all local records, which reference `referenced_record`285 * @param {Lava.data.Record} referenced_record The collection's owner record from referenced module286 * @returns {Array} All records287 */288 getCollection: function(referenced_record) {289 return (referenced_record.guid in this._collections_by_foreign_guid)290 ? this._collections_by_foreign_guid[referenced_record.guid].slice()291 : []; // fast operation: array of objects292 },293 /**294 * API for {@link Lava.data.field.Collection} field. Get count of local records, which reference the `referenced_record`295 * @param {Lava.data.Record} referenced_record The collection's owner record from referenced module296 * @returns {Number}297 */298 getCollectionCount: function(referenced_record) {299 var collection = this._collections_by_foreign_guid[referenced_record.guid];300 return collection ? collection.length : 0;301 },302 /**303 * Get `_referenced_module`304 * @returns {Lava.data.Module}305 */306 getReferencedModule: function() {307 return this._referenced_module;308 },309 /**310 * Get field's value equivalent for comparison311 * @param {Lava.data.Record} record312 * @returns {string}313 */314 _getComparisonValue: function(record) {315 if (Lava.schema.DEBUG && !(record.guid in this._properties_by_guid)) Lava.t("isLess: record does not belong to this module");316 var ref_record_a = this._properties_by_guid[record.guid][this._name];317 // must return undefined, cause comparison against nulls behaves differently318 return ref_record_a ? ref_record_a.get('id') : void 0;319 },320 isLess: function(record_a, record_b) {321 return this._getComparisonValue(record_a) < this._getComparisonValue(record_b);322 },323 isEqual: function(record_a, record_b) {324 return this._getComparisonValue(record_a) == this._getComparisonValue(record_b);325 },326 destroy: function() {327 if (this._config.foreign_key_field) {328 this._foreign_key_field.removeListener(this._foreign_key_changed_listener);329 this._external_id_field.removeListener(this._external_id_changed_listener);330 }331 this._referenced_module.removeListener(this._external_records_loaded_listener);332 this._referenced_module333 = this._collections_by_foreign_guid334 = this._foreign_key_field335 = this._external_id_field336 = null;337 this.Abstract$destroy();338 }...
offline-table-sync.svc.spec.js
Source:offline-table-sync.svc.spec.js
1describe('OfflineTableSync factory sync', function() {2 'use strict';3 var originalTimeout;4 var $rootScope;5 var $q;6 var OfflineTableSync;7 var OfflineTableMock;8 // Mock storage so we can bypass authentication.9 function storageMock() {10 var storage = { expires_at: new Date().getTime() + 100000 };11 return {12 setItem: function(key, value) {13 storage[key] = value || '';14 },15 getItem: function(key) {16 return key in storage ? storage[key] : null;17 },18 removeItem: function(key) {19 delete storage[key];20 },21 get length() {22 return Object.keys(storage).length;23 },24 key: function(i) {25 var keys = Object.keys(storage);26 return keys[i] || null;27 }28 };29 }30 window.__defineGetter__('localStorage', function() {31 return storageMock();32 });33 var runSync = function(offlineTable, updatesData) {34 return OfflineTableSync.sync(offlineTable, {35 updatesData: updatesData,36 dryRun: true,37 fetchUpdates: function() {38 return $q.resolve(updatesData);39 }40 });41 };42 beforeEach(module('mermaid.libs', 'mermaid.libs.mocks'));43 beforeEach(inject(function(44 $injector,45 _OfflineTableSync_,46 _OfflineTableMock_47 ) {48 originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;49 jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;50 $q = $injector.get('$q');51 $rootScope = $injector.get('$rootScope').$new();52 OfflineTableSync = _OfflineTableSync_;53 OfflineTableMock = _OfflineTableMock_;54 }));55 afterEach(function() {56 jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;57 });58 it('should exist', function() {59 expect(OfflineTableSync).toBeDefined();60 });61 it('[ADD - LOCAL] if local_record does NOT exist', function(done) {62 var updatesData = {63 removed: [],64 modified: [],65 added: [66 {67 updated_on: '2019-02-19T00:00:00.00Z',68 id: '2'69 }70 ]71 };72 var mockTable = new OfflineTableMock('').setMockData([]);73 runSync(mockTable, updatesData)74 .then(function(result) {75 expect(result['2'].action).toEqual(OfflineTableSync.LOCAL_CREATE);76 })77 .finally(done);78 $rootScope.$apply();79 });80 it('[UPDATE - LOCAL] if local_record `$$synced: true` AND `local_record.updated_on` is older than `updated_record.updated_on`', function(done) {81 var updatesData = {82 removed: [],83 modified: [84 {85 updated_on: '2019-02-19T00:00:00.00Z',86 id: '2'87 }88 ],89 added: []90 };91 var mockTable = new OfflineTableMock('').setMockData([92 {93 $$synced: true,94 $$deleted: false,95 updated_on: '2019-02-18T00:00:00.00Z',96 id: '2'97 }98 ]);99 runSync(mockTable, updatesData)100 .then(function(result) {101 expect(result['2'].action).toEqual(OfflineTableSync.LOCAL_PUT);102 })103 .finally(done);104 $rootScope.$apply();105 });106 it('[IGNORE] if local_record `$$synced: true` AND `local_record.updated_on` is equal to `updated_record.updated_on`', function(done) {107 var updatesData = {108 removed: [],109 modified: [110 {111 updated_on: '2019-02-19T00:00:00.00Z',112 id: '2'113 }114 ],115 added: []116 };117 var mockTable = new OfflineTableMock('').setMockData([118 {119 $$synced: true,120 $$deleted: false,121 updated_on: '2019-02-19T00:00:00.00Z',122 id: '2'123 }124 ]);125 runSync(mockTable, updatesData)126 .then(function(result) {127 expect(result['2']).toBeUndefined();128 })129 .catch(function(err) {130 console.log('err', err);131 })132 .finally(done);133 $rootScope.$apply();134 });135 it('[UPDATE - REMOTE] if local_record `$$synced: false` AND `local_record.updated_on` is newer than `updated_record.updated_on`', function(done) {136 var updatesData = {137 removed: [],138 modified: [139 {140 updated_on: '2019-02-19T00:00:00.00Z',141 id: '2'142 }143 ],144 added: []145 };146 var mockTable = new OfflineTableMock('').setMockData([147 {148 $$synced: false,149 $$deleted: false,150 updated_on: '2019-02-20T00:00:00.00Z',151 id: '2'152 }153 ]);154 runSync(mockTable, updatesData)155 .then(function(result) {156 expect(result['2'].action).toEqual(OfflineTableSync.REMOTE_PUT);157 })158 .catch(function(err) {159 console.log('err', err);160 })161 .finally(done);162 $rootScope.$apply();163 });164 it('[UPDATE - REMOTE] if local_record `$$synced: false` AND `local_record.updated_on` is older than `updated_record.updated_on`', function(done) {165 var updatesData = {166 removed: [],167 modified: [168 {169 updated_on: '2019-02-19T00:00:00.00Z',170 id: '2'171 }172 ],173 added: []174 };175 var mockTable = new OfflineTableMock('').setMockData([176 {177 $$synced: false,178 $$deleted: false,179 updated_on: '2019-02-18T00:00:00.00Z',180 id: '2'181 }182 ]);183 runSync(mockTable, updatesData)184 .then(function(result) {185 expect(result['2'].action).toEqual(OfflineTableSync.REMOTE_PUT);186 })187 .catch(function(err) {188 console.log('err', err);189 })190 .finally(done);191 $rootScope.$apply();192 });193 it('[UPDATE - REMOTE] if local_record `$$synced: false` AND `local_record.updated_on` is equal to `updated_record.updated_on`', function(done) {194 var updatesData = {195 removed: [],196 modified: [197 {198 updated_on: '2019-02-19T00:00:00.00Z',199 id: '2'200 }201 ],202 added: []203 };204 var mockTable = new OfflineTableMock('').setMockData([205 {206 $$synced: false,207 $$deleted: false,208 updated_on: '2019-02-19T00:00:00.00Z',209 id: '2'210 }211 ]);212 runSync(mockTable, updatesData)213 .then(function(result) {214 expect(result['2'].action).toEqual(OfflineTableSync.REMOTE_PUT);215 })216 .catch(function(err) {217 console.log('err', err);218 })219 .finally(done);220 $rootScope.$apply();221 });222 it('[UPDATE - REMOTE] if local_record `$$synced: true` AND `local_record.updated_on` is newer than `updated_record.updated_on`', function(done) {223 var updatesData = {224 removed: [],225 modified: [226 {227 updated_on: '2019-02-19T00:00:00.00Z',228 id: '2'229 }230 ],231 added: []232 };233 var mockTable = new OfflineTableMock('').setMockData([234 {235 $$synced: true,236 $$deleted: false,237 updated_on: '2019-02-20T00:00:00.00Z',238 id: '2'239 }240 ]);241 runSync(mockTable, updatesData)242 .then(function(result) {243 expect(result['2'].action).toEqual(OfflineTableSync.REMOTE_PUT);244 })245 .catch(function(err) {246 console.log('err', err);247 })248 .finally(done);249 $rootScope.$apply();250 });251 it('[DELETE - LOCAL] if local_record `$$synced: true` AND `local_record.updated_on` is older than OR equal to `deleted_record.created_on`', function(done) {252 var updatesData = {253 removed: [254 {255 timestamp: '2019-02-20T00:00:00.00Z',256 id: '2'257 },258 {259 timestamp: '2019-02-21T00:00:00.00Z',260 id: '3'261 }262 ],263 modified: [],264 added: []265 };266 var mockTable = new OfflineTableMock('').setMockData([267 {268 $$synced: true,269 $$deleted: false,270 updated_on: '2019-02-20T00:00:00.00Z',271 id: '2'272 },273 {274 $$synced: true,275 $$deleted: false,276 updated_on: '2019-02-20T00:00:00.00Z',277 id: '3'278 }279 ]);280 runSync(mockTable, updatesData)281 .then(function(result) {282 expect(result['2'].action).toEqual(OfflineTableSync.LOCAL_DELETE);283 expect(result['3'].action).toEqual(OfflineTableSync.LOCAL_DELETE);284 })285 .catch(function(err) {286 console.log('err', err);287 })288 .finally(done);289 $rootScope.$apply();290 });291 it('[DELETE - LOCAL] if local_record `$$synced: false` AND `$$deleted: true` and deleted_record exists.', function(done) {292 var updatesData = {293 removed: [294 {295 timestamp: '2019-02-18T00:00:00.00Z',296 id: '2'297 }298 ],299 modified: [],300 added: []301 };302 var mockTable = new OfflineTableMock('').setMockData([303 {304 $$synced: false,305 $$deleted: true,306 updated_on: '2019-02-20T00:00:00.00Z',307 id: '2'308 }309 ]);310 runSync(mockTable, updatesData)311 .then(function(result) {312 expect(result['2'].action).toEqual(OfflineTableSync.LOCAL_DELETE);313 })314 .catch(function(err) {315 console.log('err', err);316 })317 .finally(done);318 $rootScope.$apply();319 });320 it('[IGNORE] if local_record `$$synced: true` AND `local_record.updated_on` is newer than `deleted_record.created_on`', function(done) {321 var updatesData = {322 removed: [323 {324 timestamp: '2019-02-18T00:00:00.00Z',325 id: '2'326 }327 ],328 modified: [],329 added: []330 };331 var mockTable = new OfflineTableMock('').setMockData([332 {333 $$synced: true,334 $$deleted: false,335 updated_on: '2019-02-20T00:00:00.00Z',336 id: '2'337 }338 ]);339 runSync(mockTable, updatesData)340 .then(function(result) {341 expect(result['2']).toBeUndefined();342 })343 .catch(function(err) {344 console.log('err', err);345 })346 .finally(done);347 $rootScope.$apply();348 });349 it('[CREATE - REMOTE] if local_record `$$synced: false` AND `$$deleted: false` and deleted_record exists.', function(done) {350 var updatesData = {351 removed: [352 {353 timestamp: '2019-02-20T00:00:00.00Z',354 id: '2'355 }356 ],357 modified: [],358 added: []359 };360 var mockTable = new OfflineTableMock('').setMockData([361 {362 $$synced: false,363 $$deleted: false,364 updated_on: '2019-02-20T00:00:00.00Z',365 id: '2'366 }367 ]);368 runSync(mockTable, updatesData)369 .then(function(result) {370 expect(result['2'].action).toEqual(OfflineTableSync.REMOTE_CREATE);371 })372 .catch(function(err) {373 console.log('err', err);374 })375 .finally(done);376 $rootScope.$apply();377 });...
index.js
Source:index.js
1import Vue from 'vue'2import Router from 'vue-router'3import main from '@/views/main'4import xunjian from '@/views/xunjian'5import add_record from '@/views/xunjian/add_record'6import shoudong_list from '@/views/xunjian/shoudong_list'7import shoudong_detail from '@/views/xunjian/shoudong_detail'8import zidong_list from '@/views/xunjian/zidong_list'9import zidong_detail from '@/views/xunjian/zidong_detail'10import local_record from '@/views/xunjian/local_record'11import shoudong_record_list_item_detail from '@/views/xunjian/shoudong_record_list_item_detail'12import shoudong_record_list_items_list from '@/views/xunjian/shoudong_record_list_items_list'13import guzhang from '@/views/guzhang'14import gz_detail from '@/views/guzhang/gz_detail'15import wode from '@/views/wode'16import test from '@/views/wode/testpage.vue'17import warning from '@/views/wode/warning.vue'18import login from '@/views/login'19import passwd from '@/views/login/alterpasswd'20Vue.use(Router)21export default new Router({22 // mode: 'history',23 routes: [24 {25 path: "/",26 name: "def",27 redirect: {name: "main"}28 },29 {30 path: "/login",31 name: "login",32 component: login33 },34 {35 path: '/',36 name: 'main',37 component: main,38 children: [39 {40 path: '',41 name: 'def',42 component: guzhang,43 },44 {45 path: 'guzhang',46 name: 'guzhang',47 component: guzhang,48 },49 {50 path: 'wode',51 name: 'wode',52 component: wode,53 },54 {55 path: 'xunjian',56 name: 'xunjian',57 component: xunjian,58 },59 {60 path: 'add_record',61 name: 'add_record',62 component: add_record,63 },64 {65 path: 'gz_detail',66 name: 'gz_detail',67 component: gz_detail,68 },69 {70 path: 'shoudong_list',71 name: 'shoudong_list',72 component: shoudong_list,73 },74 {75 path: 'shoudong_detail',76 name: 'shoudong_detail',77 component: shoudong_detail,78 },79 {80 path: 'zidong_list',81 name: 'zidong_list',82 component: zidong_list,83 },84 {85 path: 'zidong_detail',86 name: 'zidong_detail',87 component: zidong_detail,88 },89 {90 path: 'local_record',91 name: 'local_record',92 component: local_record,93 },94 {95 path: 'shoudong_record_list_item_detail',96 name: 'shoudong_record_list_item_detail',97 component: shoudong_record_list_item_detail,98 },99 {100 path: 'shoudong_record_list_items_list',101 name: 'shoudong_record_list_items_list',102 component: shoudong_record_list_items_list,103 },104 {105 path: 'test',106 name: 'test',107 component: test,108 },109 {110 path: 'warning',111 name: 'warning',112 component: warning,113 },114 ]115 }116 ]...
Using AI Code Generation
1var wpt = require('webpagetest');2var test = new wpt('API_KEY');3var options = {4 videoParams: {5 }6};7test.runTest(url, options, function(err, data) {8 if (err) {9 console.log(err);10 } else {11 console.log(data);12 test.getTestResults(data.data.testId, function(err, data) {13 if (err) {14 console.log(err);15 } else {16 console.log(data);17 }18 });19 }20});21### runTest(url, options, cb)22### testStatus(testId, cb)23### getTestResults(testId, cb)24### getLocations(cb)25### getTesters(cb)26### getTestersAtLocation(location, cb)27### getTestersAtLocations(locations, cb)28### getLocationsForTesters(testers, cb)29### getTestersAtLocation(location, cb)30### getTestersAtLocations(locations, cb)
Using AI Code Generation
1var wpt = require('wpt');2 if (err) throw err;3 console.log(data);4});5var wpt = require('wpt');6 if (err) throw err;7 console.log(data);8});9var wpt = require('wpt');10 if (err) throw err;11 console.log(data);12});13var wpt = require('wpt');14 if (err) throw err;15 console.log(data);16});17var wpt = require('wpt');18 if (err) throw err;19 console.log(data);20});21var wpt = require('wpt');22 if (err) throw err;23 console.log(data);24});25var wpt = require('wpt');26 if (err) throw err;27 console.log(data);28});29var wpt = require('wpt');30 if (err) throw err;31 console.log(data);32});33var wpt = require('wpt');
Using AI Code Generation
1var wpt = require('wpt-api');2var wpt = new WebPageTest('www.webpagetest.org', 'A.3b3c3d3e3f3g3h3i3j3k3l3m3n3o3p3q3r3s3t3u3v3w3x3y3z3');3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});9var wpt = require('wpt-api');10var wpt = new WebPageTest('www.webpagetest.org', 'A.3b3c3d3e3f3g3h3i3j3k3l3m3n3o3p3q3r3s3t3u3v3w3x3y3z3');11 if (err) {12 console.log(err);13 } else {14 console.log(data);15 }16});17var wpt = require('wpt-api');18var wpt = new WebPageTest('www.webpagetest.org', 'A.3b3c3d3e3f3g3h3i3j3k3l3m3n3o3p3q3r3s3t3u3v3w3x3y3z3');19 if (err) {20 console.log(err);21 } else {22 console.log(data);23 }24});25var wpt = require('wpt-api');26var wpt = new WebPageTest('www.webpagetest
Using AI Code Generation
1var wpt = require('node-wpt');2var webdriver = require('selenium-webdriver'),3until = webdriver.until;4var driver = new webdriver.Builder()5.forBrowser('chrome')6.build();7driver.wait(until.titleIs('Google'), 10000);8 if (err) {9 throw err;10 }11 console.log(data.data.testId);12 console.log(data.data.summary);13 console.log(data);14});15driver.quit();16wpt.upload('test', 'test', function(err, data) {17 if (err) {18 throw err;19 }20 console.log(data);21});
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!