diff --git a/.gitignore b/.gitignore index bb631a0971..b89c0e745f 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,10 @@ tmp/ log.txt *.log +## Build +/dist +montage.min.js + ## jsdoc /doc diff --git a/.jshintignore b/.jshintignore index f3bb5771d4..fdadfade24 100644 --- a/.jshintignore +++ b/.jshintignore @@ -3,3 +3,6 @@ **/test/spec/** **/report/** **/tools/** +montage.min.js +montage2.js +webpack.config.js \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index b6c851687e..59e432bb34 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,17 @@ language: node_js node_js: - "4" -# - "8" + - "6" + - "8" script: npm run $COMMAND env: - COMMAND=lint + - COMMAND=build - COMMAND=test - COMMAND=test:karma-travis #- COMMAND=integration MONTAGE_VERSION=. MOP_VERSION=0.13 #- COMMAND=integration MONTAGE_VERSION=. MOP_VERSION=latest - - COMMAND=integration MONTAGE_VERSION=. MOP_VERSION="#master" + - COMMAND=integration MONTAGE_VERSION=#commonjs MOP_VERSION="#commonjs" before_install: - "npm set legacy-bundling=true" - export CHROME_BIN=chromium-browser diff --git a/composer/press-composer.info/sample/index.html b/composer/press-composer.info/sample/index.html index 300157f913..d27881b1b8 100644 --- a/composer/press-composer.info/sample/index.html +++ b/composer/press-composer.info/sample/index.html @@ -4,7 +4,7 @@ Press Composer Sample - + + + + + + + diff --git a/test/spec/data/authorization-manager-panel.js b/test/spec/data/authorization-manager-panel.js new file mode 100644 index 0000000000..5f2189d6f0 --- /dev/null +++ b/test/spec/data/authorization-manager-panel.js @@ -0,0 +1,63 @@ +var AuthorizationManager = require("montage/data/service/authorization-manager").AuthorizationManager, + defaultAuthorizationManager = require("montage/data/service/authorization-manager").defaultAuthorizationManager, + AuthorizationManagerPanel = require("montage/ui/authorization-manager-panel.reel").AuthorizationManagerPanel, + AuthorizationPanel = require("spec/data/ui/authorization/authorization-panel.reel").AuthorizationPanel, + Authorization = require("spec/data/logic/authorization/authorization").Authorization; + + +describe("An AuthorizationManagerPanel", function () { + var managerPanel; + beforeAll(function () { + managerPanel = new AuthorizationManagerPanel(); + defaultAuthorizationManager.authorizationManagerPanel = managerPanel; + }); + + it("can be created", function () { + expect(new AuthorizationManagerPanel()).toBeDefined(); + }); + + it ("can authorize with panel", function (done) { + var panel = new AuthorizationPanel(), + promise = managerPanel.authorizeWithPanel(panel); + + expect(managerPanel.panels.indexOf(panel) !== -1).toBe(true); + expect(managerPanel._authorizationPromiseByPanel.has(panel)).toBe(true); + promise.then(function (value) { + expect(value).toBeDefined(); + expect(managerPanel.panels.length).toBe(0); + expect(managerPanel._authorizationPromiseByPanel.size).toBe(0); + done(); + }); + panel.approveAuthorization(); + }); + + it ("can reject authorization with panel", function (done) { + var panel = new AuthorizationPanel(), + promise = managerPanel.authorizeWithPanel(panel), + isError = true; + + + expect(managerPanel.panels.indexOf(panel) !== -1).toBe(true); + expect(managerPanel._authorizationPromiseByPanel.has(panel)).toBe(true); + promise.then(function (value) { + //Should not be called + isError = false; + }).catch(function (e) { + expect(managerPanel.panels.length).toBe(0); + expect(managerPanel._authorizationPromiseByPanel.size).toBe(0); + }).finally(function () { + expect(isError).toBe(true); + done(); + }); + panel.rejectAuthorization(); + }); + + xit("can authorize with modal", function () { + //TODO + }); + + xit("can reject authorization with modal", function () { + //TODO + }); + +}); diff --git a/test/spec/data/authorization-manager.js b/test/spec/data/authorization-manager.js new file mode 100644 index 0000000000..923449e706 --- /dev/null +++ b/test/spec/data/authorization-manager.js @@ -0,0 +1,338 @@ +var AuthorizationManager = require("montage/data/service/authorization-manager").AuthorizationManager, + Authorization = require("spec/data/logic/authorization/authorization").Authorization, + AuthorizationService = require("spec/data/logic/authorization/authorization-service").AuthorizationService, + AuthorizationServiceB = require("spec/data/logic/authorization/authorization-service-b").AuthorizationServiceB, + NoneService = require("spec/data/logic/authorization/none-service").NoneService, + OnDemandService = require("spec/data/logic/authorization/on-demand-service").OnDemandService, + OnFirstFetchService = require("spec/data/logic/authorization/on-first-fetch-service").OnFirstFetchService, + UpFrontService = require("spec/data/logic/authorization/up-front-service").UpFrontService, + Map = require("collections/map"); + + +describe("An Authorization Manager", function () { + + var authorizationManager, authorizationService; + beforeEach(function () { + authorizationManager = new AuthorizationManager(); + authorizationService = new AuthorizationService(); + authorizationServiceB = new AuthorizationServiceB(); + authorizationManager.registerAuthorizationService(authorizationService); + authorizationManager.registerAuthorizationService(authorizationServiceB); + }); + + it("can be created", function () { + expect(authorizationManager).toBeDefined(); + expect(authorizationManager._providersByModuleID instanceof Map).toBeTruthy(); + expect(authorizationManager._panelsByModuleID instanceof Map).toBeTruthy(); + }); + + + + + describe("can skip authorization", function () { + + it("for service with AuthorizationPolicy.NONE", function (done) { + var service = new NoneService(); + + authorizationManager.authorizeService(service).then(function (result) { + expect(result).toBeNull(); + done(); + }); + }); + + it("for service with AuthorizationPolicy.ON_DEMAND without failure", function (done) { + var service = new OnDemandService(); + + authorizationManager.authorizeService(service).then(function (result) { + expect(result).toBeNull(); + done(); + }); + }); + }); + + describe("can authorize individual service", function () { + it("with AuthorizationPolicy.ON_FIRST_FETCH", function (done) { + var service = new OnFirstFetchService(); + + + authorizationService.resolve(); + authorizationManager.authorizeService(service).then(function (result) { + expect(Array.isArray(result)).toBeTruthy(); + expect(result[0] instanceof Authorization).toBeTruthy(); + done(); + }); + + }); + + it("with AuthorizationPolicy.ON_DEMAND with failure", function (done) { + var service = new OnDemandService() + authorizationService.resolve(); + authorizationManager.authorizeService(service, true).then(function (result) { + expect(Array.isArray(result)).toBeTruthy(); + expect(result[0] instanceof Authorization).toBeTruthy(); + done(); + }); + + }); + + it("with AuthorizationPolicy.UP_FRONT", function (done) { + var service = new UpFrontService(); + authorizationService.resolve(); + authorizationManager.authorizeService(service).then(function (result) { + expect(Array.isArray(result)).toBeTruthy(); + expect(result[0] instanceof Authorization).toBeTruthy(); + done(); + }); + + + }); + + describe("after authorization expiration", function () { + //TODO + }); + + describe("after failed authorization", function () { + + it("with single authorization service", function (done) { + var service = new OnFirstFetchService(), + didFail = false, + authorizations; + + authorizationService.reject(); + authorizationManager.authorizeService(service).catch(function (e) { + didFail = true; + }).finally(function () { + expect(didFail).toBe(true); + authorizations = authorizationManager._authorizationsForDataService(service); + expect(authorizations.length).toBe(0); + authorizationService.reset(); + authorizationService.resolve(); + return authorizationManager.authorizeService(service).then(function (result) { + expect(Array.isArray(result)).toBeTruthy(); + expect(result[0] instanceof Authorization).toBeTruthy(); + authorizations = authorizationManager._authorizationsForDataService(service); + expect(authorizations.length).toBe(1); + done(); + }); + }) + }); + }); + + + + it("with all of multiple authorization services", function (done) { + var service = new OnFirstFetchService(), + authorizations; + + + service.authorizationServices = [ + "spec/data/logic/authorization/authorization-service", + "spec/data/logic/authorization/authorization-service-b", + ]; + + authorizationService.resolve(); + authorizationServiceB.resolve(); + authorizationManager.authorizeService(service).then(function (result) { + expect(Array.isArray(result)).toBeTruthy(); + expect(result[0] instanceof Authorization).toBeTruthy(); + expect(result[1] instanceof Authorization).toBeTruthy(); + authorizations = authorizationManager._authorizationsForDataService(service); + expect(authorizations.length).toBe(2); + done(); + }); + }); + + xit("with one of multiple authorization services", function (done) { + var service = new OnFirstFetchService(), + authorizations; + + + service.authorizationServices = [ + "spec/data/logic/authorization/authorization-service", + "spec/data/logic/authorization/authorization-service-b", + ]; + + authorizationService.resolve(); + authorizationManager.authorizeService(service).then(function (result) { + expect(Array.isArray(result)).toBeTruthy(); + expect(result[0] instanceof Authorization).toBeTruthy(); + authorizations = authorizationManager._authorizationsForDataService(service); + expect(authorizations.length).toBe(1); + done(); + }); + }); + }); + + + describe("can authorize multiple data services", function () { + + // Array of descriptions of DataServices with a particular AuthorizationPolicy. + // Each of the descriptions has the following structure + // + // constructor: Constructor function to create the DataService + // name: Human Readable name of the AuthorizationPolicy of this dataService + // didFailResult: Boolean stating whether a result is expected after a preceding auth failure + // initialResult: Boolean stating whether a result is expected the first time Authorization is requested + // + // + var serviceDescriptors = [ + { + constructor: OnDemandService, + name: "OnDemand", + didFailResult: true, + initialResult: false + }, + { + constructor: OnFirstFetchService, + name: "OnFirstFetch", + didFailResult: true, + initialResult: true + }, + { + constructor: NoneService, + name: "None", + didFailResult: false, + initialResult: false + }, + { + constructor: UpFrontService, + name: "UpFront", + didFailResult: true, + initialResult: true + } + ]; + + function testServiceDescriptorWithServiceDescriptorAtIndex(descriptor, index) { + index = index === undefined ? 0 : index; + return compareAuthorizations(descriptor, serviceDescriptors[index], false, false).then(function () { + return compareAuthorizations(descriptor, serviceDescriptors[index], true, false); + }).then(function () { + return compareAuthorizations(descriptor, serviceDescriptors[index], false, true); + }).then(function () { + return compareAuthorizations(descriptor, serviceDescriptors[index], true, true); + }); + } + + function compareAuthorizations(descriptorA, descriptorB, didFailA, didFailB) { + authorizationManager = new AuthorizationManager(); + authorizationService = new AuthorizationService(); + authorizationManager.registerAuthorizationService(authorizationService); + authorizationService.resolve(); + return testService(descriptorA, didFailA).then(function (result) { + return testService(descriptorB, didFailB, result && result[0]); + }).then(function (result) { + // console.log("***********************"); + return null; + }); + } + + function testService(descriptor, didFail, authorization) { + var service = new descriptor.constructor(); + return authorizationManager.authorizeService(service, didFail).then(function (result) { + var authorizationExisted = !!authorization, + shouldHaveResult = didFail ? descriptor.didFailResult : (descriptor.initialResult || authorizationExisted); + if (shouldHaveResult) { + expect(Array.isArray(result)).toBeTruthy(); + expect(result[0] instanceof Authorization).toBeTruthy(); + if (authorization) { + expect(result[0]).toBe(authorization); + } + } else { + expect(result).toBeNull(); + } + // console.log(descriptor.name, (didFail ? "Fail" : "Initial"), result && result[0]); + return result; + }); + } + + + + describe("with same authorization service", function () { + + + it ("with OnDemand Policy First", function(done) { + var onDemandServiceDescriptor = serviceDescriptors[0]; + testServiceDescriptorWithServiceDescriptorAtIndex(onDemandServiceDescriptor).then(function () { + done(); + }); + }); + + it ("with OnFirstFetch Policy First", function(done) { + var firstFetchServiceDescriptor = serviceDescriptors[1]; + testServiceDescriptorWithServiceDescriptorAtIndex(firstFetchServiceDescriptor).then(function () { + done(); + }); + }); + + it ("with None Policy First", function(done) { + var noneServiceDescriptor = serviceDescriptors[2]; + testServiceDescriptorWithServiceDescriptorAtIndex(noneServiceDescriptor).then(function () { + done(); + }); + }); + + it ("with UpFront Policy First", function(done) { + var upFrontServiceDescriptor = serviceDescriptors[3]; + testServiceDescriptorWithServiceDescriptorAtIndex(upFrontServiceDescriptor).then(function () { + done(); + }); + }); + + }); + + + describe("with different authorization services", function () { + //TODO + }); + + + describe("after authorization expiration", function () { + //TODO + }); + }); + + describe("can logout", function () { + + it("with single authorization service", function (done) { + var service = new OnFirstFetchService(); + authorizationService.resolve(); + authorizationManager.authorizeService(service).then(function (result) { + expect(Array.isArray(result)).toBeTruthy(); + expect(result[0] instanceof Authorization).toBeTruthy(); + expect(authorizationManager._authorizationsForDataService(service).length).toBe(1); + authorizationManager.clearAuthorizationForService(service); + expect(authorizationManager._authorizationsForDataService(service).length).toBe(0); + done(); + }); + + }); + + it("for multiple data-services", function (done) { + var serviceA = new OnFirstFetchService(), + serviceB = new OnDemandService(), + authorization; + authorizationService.resolve(); + authorizationManager.authorizeService(serviceA).then(function (result) { + expect(Array.isArray(result)).toBeTruthy(); + expect(result[0] instanceof Authorization).toBeTruthy(); + authorization = result[0]; + expect(authorizationManager._authorizationsForDataService(serviceA).length).toBe(1); + return authorizationManager.authorizeService(serviceB); + }).then(function (result) { + expect(Array.isArray(result)).toBeTruthy(); + expect(result[0] instanceof Authorization).toBeTruthy(); + expect(result[0]).toBe(authorization); + authorizationManager.clearAuthorizationForService(serviceA); + expect(authorizationManager._authorizationsForDataService(serviceA).length).toBe(0); + return authorizationManager.authorizeService(serviceB); + }).then(function (result) { + expect(result).toBe(null); + expect(authorizationManager._authorizationsForDataService(serviceB).length).toBe(0); + done(); + }); + + }); + }); + + +}); diff --git a/test/spec/data/core-integration.js b/test/spec/data/core-integration.js new file mode 100644 index 0000000000..c0ee8ae98f --- /dev/null +++ b/test/spec/data/core-integration.js @@ -0,0 +1,11 @@ +var Deserializer = require("montage/core/serialization/deserializer/montage-deserializer").MontageDeserializer, + serialization = require("spec/data/logic/service/montage-data.mjson"); + + +describe("Core Integration", function() { + + it("Main Datareel is deserialized", function () { + var service = application.service; + expect(service).toBeDefined(); + }); +}); diff --git a/test/spec/data/data-stream.js b/test/spec/data/data-stream.js index f822602487..9150c611c7 100644 --- a/test/spec/data/data-stream.js +++ b/test/spec/data/data-stream.js @@ -1,5 +1,7 @@ var DataStream = require("montage/data/service/data-stream").DataStream, - Montage = require("montage").Montage; + DataQuery = require("montage/data/model/data-query").DataQuery, + Montage = require("montage").Montage, + ObjectDescriptor = require("montage/core/meta/object-descriptor").ObjectDescriptor; describe("A DataStream", function() { @@ -23,7 +25,20 @@ describe("A DataStream", function() { } it("can be created", function () { + var type = new ObjectDescriptor(), + query = DataQuery.withTypeAndCriteria(type, {}), + stream; expect(new DataStream()).toBeDefined(); + + stream = DataStream.withTypeOrSelector(type); + expect(stream).toBeDefined(); + expect(stream.query).toBeDefined(); + expect(stream.query.type).toBe(type); + + stream = DataStream.withTypeOrSelector(query); + expect(stream).toBeDefined(); + expect(stream.query).toBe(query); + expect(stream.query.type).toBe(type); }); it("has a an initially empty data array", function () { diff --git a/test/spec/data/expression-data-mapping.js b/test/spec/data/expression-data-mapping.js index 0dc515ff86..43f238a0cf 100644 --- a/test/spec/data/expression-data-mapping.js +++ b/test/spec/data/expression-data-mapping.js @@ -6,6 +6,7 @@ var ExpressionDataMapping = require("montage/data/service/expression-data-mappin ModuleObjectDescriptor = require("montage/core/meta/module-object-descriptor").ModuleObjectDescriptor, ModuleReference = require("montage/core/module-reference").ModuleReference, PlotSummaryService = require("spec/data/logic/service/plot-summary-service").PlotSummaryService, + PropService = require("spec/data/logic/service/prop-service").PropService, Promise = require("montage/core/promise").Promise, PropertyDescriptor = require("montage/core/meta/property-descriptor").PropertyDescriptor, RawDataService = require("montage/data/service/raw-data-service").RawDataService, @@ -16,7 +17,8 @@ var ExpressionDataMapping = require("montage/data/service/expression-data-mappin var Movie = require("spec/data/logic/model/movie").Movie, Category = require("spec/data/logic/model/category").Category, Country = require("spec/data/logic/model/country").Country, - ActionMovie = require("spec/data/logic/model/action-movie").ActionMovie; + ActionMovie = require("spec/data/logic/model/action-movie").ActionMovie, + Prop = require("spec/data/logic/model/prop").Prop; describe("An Expression Data Mapping", function() { @@ -46,14 +48,18 @@ describe("An Expression Data Mapping", function() { actionMovieMapping, actionMovieModuleReference, actionMovieObjectDescriptor, - actionMovieRawDataTypeMapping, plotSummaryModuleReference, plotSummaryObjectDescriptor, plotSummaryPropertyDescriptor, registrationPromise, schemaBudgetPropertyDescriptor, schemaIsFeaturedPropertyDescriptor, - schemaReleaseDatePropertyDescriptor, + propModuleReference, + propObjectDescriptor, + propMoviePropertyDescriptor, + propsPropertyDescriptor, + propConverter, + propService, @@ -118,10 +124,23 @@ describe("An Expression Data Mapping", function() { plotSummaryModuleReference = new ModuleReference().initWithIdAndRequire("spec/data/logic/model/plot-summary", require); plotSummaryObjectDescriptor = new ModuleObjectDescriptor().initWithModuleAndExportName(plotSummaryModuleReference, "PlotSummary"); plotSummaryObjectDescriptor.addPropertyDescriptor(new PropertyDescriptor().initWithNameObjectDescriptorAndCardinality("summary", plotSummaryObjectDescriptor, 1)); + plotSummaryObjectDescriptor.addPropertyDescriptor(new PropertyDescriptor().initWithNameObjectDescriptorAndCardinality("movie", movieObjectDescriptor, 1)); plotSummaryPropertyDescriptor = new PropertyDescriptor().initWithNameObjectDescriptorAndCardinality("plotSummary", movieObjectDescriptor, 1); plotSummaryPropertyDescriptor.valueDescriptor = plotSummaryObjectDescriptor; movieObjectDescriptor.addPropertyDescriptor(plotSummaryPropertyDescriptor); + propService = new PropService(); + propModuleReference = new ModuleReference().initWithIdAndRequire("spec/data/logic/model/prop", require); + propObjectDescriptor = new ModuleObjectDescriptor().initWithModuleAndExportName(propModuleReference, "Prop"); + propObjectDescriptor.addPropertyDescriptor(new PropertyDescriptor().initWithNameObjectDescriptorAndCardinality("name", null)); + propMoviePropertyDescriptor = new PropertyDescriptor().initWithNameObjectDescriptorAndCardinality("movie", movieObjectDescriptor, -1); + propMoviePropertyDescriptor.valueDescriptor = propObjectDescriptor; + propObjectDescriptor.addPropertyDescriptor(propMoviePropertyDescriptor); + propsPropertyDescriptor = new PropertyDescriptor().initWithNameObjectDescriptorAndCardinality("props", movieObjectDescriptor, Infinity); + propsPropertyDescriptor.valueDescriptor = propObjectDescriptor; + propsPropertyDescriptor.inversePropertyName = "movie"; + movieObjectDescriptor.addPropertyDescriptor(propsPropertyDescriptor); + schemaBudgetPropertyDescriptor = new PropertyDescriptor().initWithNameObjectDescriptorAndCardinality("budget", movieSchema, 1); movieSchema.addPropertyDescriptor(schemaBudgetPropertyDescriptor); @@ -156,7 +175,14 @@ describe("An Expression Data Mapping", function() { summaryConverter.service = plotSummaryService; movieMapping.addObjectMappingRule("plotSummary", { "<-": "{movie_id: id}", - converter: summaryConverter + converter: summaryConverter, + inversePropertyName: "movie" + }); + propConverter = new RawPropertyValueToObjectConverter().initWithConvertExpression("category_id == $"); + propConverter.service = propService; + movieMapping.addObjectMappingRule("props", { + "<-": "{}", + converter: propConverter }); movieMapping.addRawDataMappingRule("category_id", {"<-": "category.id"}); movieMapping.addObjectMappingRule("releaseDate", { @@ -202,7 +228,8 @@ describe("An Expression Data Mapping", function() { mainService.registerChildService(movieService, [movieObjectDescriptor, actionMovieObjectDescriptor]), mainService.registerChildService(categoryService, categoryObjectDescriptor), mainService.registerChildService(countryService, countryObjectDescriptor), - mainService.registerChildService(plotSummaryService, plotSummaryObjectDescriptor) + mainService.registerChildService(plotSummaryService, plotSummaryObjectDescriptor), + mainService.registerChildService(propService, propObjectDescriptor) ]); it("properly registers the object descriptor type to the mapping object in a service", function (done) { @@ -214,7 +241,7 @@ describe("An Expression Data Mapping", function() { }); it("can create the correct number of mapping rules", function () { - expect(movieMapping.objectMappingRules.size).toBe(7); + expect(movieMapping.objectMappingRules.size).toBe(8); expect(movieMapping.rawDataMappingRules.size).toBe(7); }); @@ -272,6 +299,51 @@ describe("An Expression Data Mapping", function() { }); }); + it("can map inverse in mapping for fetch with updateObjectProperties", function (done) { + var movie = mainService.createDataObject(movieObjectDescriptor), + data = { + name: "Star Wars", + category_id: 1, + budget: "14000000.00", + is_featured: "true", + release_date: "05/25/1977", + fcc_rating: "pg", + country_id: 1 + }; + + return actionMovieMapping.mapRawDataToObject(data, movie).then(function () { + //Properties defined in parent descriptor + return mainService.updateObjectProperties(movie, "plotSummary"); + }).then(function () { + expect(movie.plotSummary).toBeDefined(); + expect(movie.plotSummary.movie).toBe(movie); + done(); + }); + }); + + it("can map inverse on propertyDescriptor for fetch with updateObjectProperties", function (done) { + var movie = mainService.createDataObject(movieObjectDescriptor), + data = { + name: "Star Wars", + category_id: 1, + budget: "14000000.00", + is_featured: "true", + release_date: "05/25/1977", + fcc_rating: "pg", + country_id: 1 + }; + + return movieMapping.mapRawDataToObject(data, movie).then(function () { + //Properties defined in parent descriptor + return mainService.updateObjectProperties(movie, "props"); + }).then(function () { + expect(movie.props).toBeDefined(); + expect(Array.isArray(movie.props)).toBe(true); + expect(movie.props[0].movie).toBe(movie); + done(); + }); + }); + it("can automatically convert raw data to the correct type", function (done) { var movie = {}, data = { diff --git a/test/spec/data/logic/authorization/authorization-service-b.js b/test/spec/data/logic/authorization/authorization-service-b.js new file mode 100644 index 0000000000..a8e8847c33 --- /dev/null +++ b/test/spec/data/logic/authorization/authorization-service-b.js @@ -0,0 +1,67 @@ +var DataService = require("montage/data/service/data-service").DataService, + Authorization = require("spec/data/logic/authorization/authorization").Authorization, + Promise = require("montage/core/promise").Promise; + + + +exports.AuthorizationServiceB = DataService.specialize( /** @lends AuthorizationServiceB.prototype */ { + + authorization: { + get: function () { + if (!this._authorization) { + this._authorization = new Authorization(); + this._authorization.isServiceB = true; + } + return this._authorization; + } + }, + + authorize: { + value: function () { + return this.promiseDescriptor.value; + } + }, + + reset: { + value: function () { + this._promiseDescriptor = this._makePromiseDescriptor(); + } + }, + + _makePromiseDescriptor: { + value: function () { + var descriptor = {}; + descriptor.value = new Promise(function (resolve, reject) { + descriptor.resolve = resolve; + descriptor.reject = reject; + }); + return descriptor; + } + }, + + + promiseDescriptor: { + get: function () { + var self = this, + descriptor; + if (!this._promiseDescriptor) { + this._promiseDescriptor = this._makePromiseDescriptor(); + } + return this._promiseDescriptor; + } + }, + + resolve: { + value: function () { + this.promiseDescriptor.resolve(this.authorization); + } + }, + + reject: { + value: function () { + this.promiseDescriptor.reject(new Error("Test AuthService Rejection")); + } + } + + +}); diff --git a/test/spec/data/logic/authorization/authorization-service-with-panel.js b/test/spec/data/logic/authorization/authorization-service-with-panel.js new file mode 100644 index 0000000000..75c2ba39e5 --- /dev/null +++ b/test/spec/data/logic/authorization/authorization-service-with-panel.js @@ -0,0 +1,30 @@ +var DataService = require("montage/data/service/data-service").DataService, + Authorization = require("spec/data/logic/authorization/authorization").Authorization, + Promise = require("montage/core/promise").Promise; + + + +exports.AuthorizationServiceWithPanel = DataService.specialize( /** @lends AuthorizationServiceWithPanel.prototype */ { + + authorization: { + get: function () { + if (!this._authorization) { + this._authorization = new Authorization(); + } + return this._authorization; + } + }, + + authorize: { + value: function () { + // return Promise.resolve(this.authorization); + return null; + } + }, + + + authorizationPanel: { + value: "spec/data/ui/authorization/authorization-panel.reel" + } + +}); diff --git a/test/spec/data/logic/authorization/authorization-service.js b/test/spec/data/logic/authorization/authorization-service.js new file mode 100644 index 0000000000..1a4d4bb4fa --- /dev/null +++ b/test/spec/data/logic/authorization/authorization-service.js @@ -0,0 +1,66 @@ +var DataService = require("montage/data/service/data-service").DataService, + Authorization = require("spec/data/logic/authorization/authorization").Authorization, + Promise = require("montage/core/promise").Promise; + + + +exports.AuthorizationService = DataService.specialize( /** @lends AuthorizationService.prototype */ { + + authorization: { + get: function () { + if (!this._authorization) { + this._authorization = new Authorization(); + } + return this._authorization; + } + }, + + authorize: { + value: function () { + return this.promiseDescriptor.value; + } + }, + + reset: { + value: function () { + this._promiseDescriptor = this._makePromiseDescriptor(); + } + }, + + _makePromiseDescriptor: { + value: function () { + var descriptor = {}; + descriptor.value = new Promise(function (resolve, reject) { + descriptor.resolve = resolve; + descriptor.reject = reject; + }); + return descriptor; + } + }, + + + promiseDescriptor: { + get: function () { + var self = this, + descriptor; + if (!this._promiseDescriptor) { + this._promiseDescriptor = this._makePromiseDescriptor(); + } + return this._promiseDescriptor; + } + }, + + resolve: { + value: function () { + this.promiseDescriptor.resolve(this.authorization); + } + }, + + reject: { + value: function () { + this.promiseDescriptor.reject(new Error("Test AuthService Rejection")); + } + } + + +}); diff --git a/test/spec/data/logic/authorization/authorization.js b/test/spec/data/logic/authorization/authorization.js new file mode 100644 index 0000000000..4bfccbb5ed --- /dev/null +++ b/test/spec/data/logic/authorization/authorization.js @@ -0,0 +1,8 @@ +var Montage = require("montage").Montage; + +exports.Authorization = Montage.specialize(/** @lends Montage.prototype */ { + + //TODO + + +}); \ No newline at end of file diff --git a/test/spec/data/logic/authorization/none-service.js b/test/spec/data/logic/authorization/none-service.js new file mode 100644 index 0000000000..e642dcf439 --- /dev/null +++ b/test/spec/data/logic/authorization/none-service.js @@ -0,0 +1,16 @@ +var RawDataService = require("montage/data/service/raw-data-service").RawDataService, + AuthorizationPolicy = require("montage/data/service/authorization-policy").AuthorizationPolicy; + +exports.NoneService = RawDataService.specialize(/** @lends NoneService.prototype */ { + + authorizationPolicy: { + value: AuthorizationPolicy.NONE + }, + + fetchRawData: { + value: function (stream) { + stream.dataDone(); + } + } + +}); \ No newline at end of file diff --git a/test/spec/data/logic/authorization/on-demand-service.js b/test/spec/data/logic/authorization/on-demand-service.js new file mode 100644 index 0000000000..0a08462016 --- /dev/null +++ b/test/spec/data/logic/authorization/on-demand-service.js @@ -0,0 +1,20 @@ +var RawDataService = require("montage/data/service/raw-data-service").RawDataService, + AuthorizationPolicy = require("montage/data/service/authorization-policy").AuthorizationPolicy; + +exports.OnDemandService = RawDataService.specialize(/** @lends OnDemandService.prototype */ { + + authorizationServices: { + value: ["spec/data/logic/authorization/authorization-service"] + }, + + authorizationPolicy: { + value: AuthorizationPolicy.ON_DEMAND + }, + + fetchRawData: { + value: function (stream) { + stream.dataDone(); + } + } + +}); \ No newline at end of file diff --git a/test/spec/data/logic/authorization/on-first-fetch-service.js b/test/spec/data/logic/authorization/on-first-fetch-service.js new file mode 100644 index 0000000000..682b5d787c --- /dev/null +++ b/test/spec/data/logic/authorization/on-first-fetch-service.js @@ -0,0 +1,20 @@ +var RawDataService = require("montage/data/service/raw-data-service").RawDataService, + AuthorizationPolicy = require("montage/data/service/authorization-policy").AuthorizationPolicy; + +exports.OnFirstFetchService = RawDataService.specialize(/** @lends OnFirstFetchService.prototype */ { + + authorizationServices: { + value: ["spec/data/logic/authorization/authorization-service"] + }, + + authorizationPolicy: { + value: AuthorizationPolicy.ON_FIRST_FETCH + }, + + fetchRawData: { + value: function (stream) { + stream.dataDone(); + } + } + +}); \ No newline at end of file diff --git a/test/spec/data/logic/authorization/up-front-service.js b/test/spec/data/logic/authorization/up-front-service.js new file mode 100644 index 0000000000..859b234b48 --- /dev/null +++ b/test/spec/data/logic/authorization/up-front-service.js @@ -0,0 +1,20 @@ +var RawDataService = require("montage/data/service/raw-data-service").RawDataService, + AuthorizationPolicy = require("montage/data/service/authorization-policy").AuthorizationPolicy; + +exports.UpFrontService = RawDataService.specialize(/** @lends UpFrontService.prototype */ { + + authorizationServices: { + value: ["spec/data/logic/authorization/authorization-service"] + }, + + authorizationPolicy: { + value: AuthorizationPolicy.UP_FRONT + }, + + fetchRawData: { + value: function (stream) { + stream.dataDone(); + } + } + +}); diff --git a/test/spec/data/logic/model/prop.js b/test/spec/data/logic/model/prop.js new file mode 100644 index 0000000000..65bbe273d3 --- /dev/null +++ b/test/spec/data/logic/model/prop.js @@ -0,0 +1,17 @@ +var Montage = require("montage").Montage; + +/** + * @class Prop + * @extends Montage + */ +exports.Prop = Montage.specialize({ + + movie: { + value: undefined + }, + + name: { + value: undefined + } + +}); diff --git a/test/spec/data/logic/service/prop-service.js b/test/spec/data/logic/service/prop-service.js new file mode 100644 index 0000000000..7f3e2fb90d --- /dev/null +++ b/test/spec/data/logic/service/prop-service.js @@ -0,0 +1,21 @@ +var RawDataService = require("montage/data/service/raw-data-service").RawDataService, + CategoryNames = ["Action"]; + +exports.PropService = RawDataService.specialize(/** @lends PropService.prototype */ { + + _data: { + value: [ + {name: "Falcon"}, + {name: "Lightsaber"} + ] + }, + + fetchRawData: { + value: function (stream) { + console.log("PropService.fetchRawData"); + this.addRawData(stream, this._data); + this.rawDataDone(stream); + } + } + +}); diff --git a/test/spec/data/ui/authorization/authorization-panel.reel/authorization-panel.css b/test/spec/data/ui/authorization/authorization-panel.reel/authorization-panel.css new file mode 100644 index 0000000000..1c42b401ba --- /dev/null +++ b/test/spec/data/ui/authorization/authorization-panel.reel/authorization-panel.css @@ -0,0 +1,3 @@ +.AuthorizationPanel { + +} \ No newline at end of file diff --git a/test/spec/data/ui/authorization/authorization-panel.reel/authorization-panel.html b/test/spec/data/ui/authorization/authorization-panel.reel/authorization-panel.html new file mode 100644 index 0000000000..0d9b649a03 --- /dev/null +++ b/test/spec/data/ui/authorization/authorization-panel.reel/authorization-panel.html @@ -0,0 +1,20 @@ + + + + + + + + +
+
+ + diff --git a/test/spec/data/ui/authorization/authorization-panel.reel/authorization-panel.js b/test/spec/data/ui/authorization/authorization-panel.reel/authorization-panel.js new file mode 100644 index 0000000000..1dea724168 --- /dev/null +++ b/test/spec/data/ui/authorization/authorization-panel.reel/authorization-panel.js @@ -0,0 +1,32 @@ +var AuthorizationPanel = require("montage/ui/authorization-panel.reel").AuthorizationPanel, + Authorization = require("spec/data/logic/authorization/authorization").Authorization; + +/** + * @class AuthorizationPanel + * @extends Component + */ +exports.AuthorizationPanel = AuthorizationPanel.specialize(/** @lends AuthorizationPanel# */ { + + + approveAuthorization: { + value: function () { + this.authorizationManagerPanel.approveAuthorization(this.authorization, this); + } + }, + + rejectAuthorization: { + value: function () { + this.authorizationManagerPanel.cancelAuthorization(this); + } + }, + + authorization: { + get: function () { + if (!this._authorization) { + this._authorization = new Authorization(); + } + return this._authorization; + } + } + +}); diff --git a/test/spec/montage-custom-element-spec.js b/test/spec/montage-custom-element-spec.js index d4615e15c3..54f6f599a7 100644 --- a/test/spec/montage-custom-element-spec.js +++ b/test/spec/montage-custom-element-spec.js @@ -1,14 +1,7 @@ -var Montage = require("montage").Montage, - TestPageLoader = require("montage-testing/testpageloader").TestPageLoader, - Template = require("montage/core/template").Template, - Application = require("montage/core/application").application; +var TestPageLoader = require("montage-testing/testpageloader").TestPageLoader; TestPageLoader.queueTest("custom-elements/custom-elements", function (testPage) { describe("montage-custom-element-spec", function () { - var eventManager, - application, - delegate; - var querySelector = function (s) { return testPage.querySelector(s); }; @@ -16,14 +9,7 @@ TestPageLoader.queueTest("custom-elements/custom-elements", function (testPage) return testPage.querySelectorAll(s); }; - beforeEach(function () { - application = testPage.global.mr("montage/core/application").application; - eventManager = application.eventManager; - delegate = application.delegate; - }); - describe('montage-text', function () { - it("should be instantiated", function () { var textLabel1 = querySelector(".textLabel1"); expect(textLabel1).toBeDefined(); @@ -94,7 +80,6 @@ TestPageLoader.queueTest("custom-elements/custom-elements", function (testPage) }); describe('my-button', function () { - it("should be instantiated", function () { var myButton = querySelector(".myButton"); expect(myButton).toBeDefined(); diff --git a/ui/anchor.info/sample/index.html b/ui/anchor.info/sample/index.html index 2e20589864..44c2960e33 100644 --- a/ui/anchor.info/sample/index.html +++ b/ui/anchor.info/sample/index.html @@ -5,7 +5,7 @@ Anchor Sample - + + + + + + - diff --git a/ui/label.info/sample/package.json b/ui/label.info/sample/package.json index daae48b583..abd921c551 100644 --- a/ui/label.info/sample/package.json +++ b/ui/label.info/sample/package.json @@ -6,6 +6,6 @@ "montage": "*" }, "mappings": { - "montage": "../../../../" + "montage": "../../../" } } diff --git a/ui/label.info/sample/main.reel/main.css b/ui/label.info/sample/ui/main.reel/main.css similarity index 100% rename from ui/label.info/sample/main.reel/main.css rename to ui/label.info/sample/ui/main.reel/main.css diff --git a/ui/label.info/sample/main.reel/main.html b/ui/label.info/sample/ui/main.reel/main.html similarity index 100% rename from ui/label.info/sample/main.reel/main.html rename to ui/label.info/sample/ui/main.reel/main.html diff --git a/ui/label.info/sample/main.reel/main.js b/ui/label.info/sample/ui/main.reel/main.js similarity index 100% rename from ui/label.info/sample/main.reel/main.js rename to ui/label.info/sample/ui/main.reel/main.js diff --git a/ui/loader.reel/loader.js b/ui/loader.reel/loader.js index c11c08e66f..860be73212 100644 --- a/ui/loader.reel/loader.js +++ b/ui/loader.reel/loader.js @@ -341,7 +341,7 @@ exports.Loader = Component.specialize( /** @lends Loader.prototype # */ { this.isLoadingMainComponent = true; var self = this; - return global.require.async(this.mainModule).then(function (exports) { + return global.mr.async(this.mainModule).then(function (exports) { if (!(self.mainName in exports)) { throw new Error(self.mainName + " was not found in " + self.mainModule); } diff --git a/ui/number-field.info/sample/index.html b/ui/number-field.info/sample/index.html index 59b9cbfb16..e8a426fb59 100644 --- a/ui/number-field.info/sample/index.html +++ b/ui/number-field.info/sample/index.html @@ -4,7 +4,7 @@ Number Field Sample - + + + + + diff --git a/ui/slot.info/sample/package.json b/ui/slot.info/sample/package.json index 6fb75fb995..a398fa1d74 100644 --- a/ui/slot.info/sample/package.json +++ b/ui/slot.info/sample/package.json @@ -2,6 +2,9 @@ "name": "slot.info", "private": true, "dependencies": { - "montage": "../.." + "montage": "*" + }, + "mappings": { + "montage": "../../../" } } \ No newline at end of file diff --git a/ui/slot.info/sample/main.reel/main.css b/ui/slot.info/sample/ui/main.reel/main.css similarity index 100% rename from ui/slot.info/sample/main.reel/main.css rename to ui/slot.info/sample/ui/main.reel/main.css diff --git a/ui/slot.info/sample/main.reel/main.html b/ui/slot.info/sample/ui/main.reel/main.html similarity index 100% rename from ui/slot.info/sample/main.reel/main.html rename to ui/slot.info/sample/ui/main.reel/main.html diff --git a/ui/slot.info/sample/main.reel/main.js b/ui/slot.info/sample/ui/main.reel/main.js similarity index 100% rename from ui/slot.info/sample/main.reel/main.js rename to ui/slot.info/sample/ui/main.reel/main.js diff --git a/ui/slot.info/sample/photo-viewer.reel/photo-viewer.html b/ui/slot.info/sample/ui/photo-viewer.reel/photo-viewer.html similarity index 100% rename from ui/slot.info/sample/photo-viewer.reel/photo-viewer.html rename to ui/slot.info/sample/ui/photo-viewer.reel/photo-viewer.html diff --git a/ui/slot.info/sample/photo-viewer.reel/photo-viewer.js b/ui/slot.info/sample/ui/photo-viewer.reel/photo-viewer.js similarity index 100% rename from ui/slot.info/sample/photo-viewer.reel/photo-viewer.js rename to ui/slot.info/sample/ui/photo-viewer.reel/photo-viewer.js diff --git a/ui/slot.info/sample/video-viewer.reel/video-viewer.html b/ui/slot.info/sample/ui/video-viewer.reel/video-viewer.html similarity index 100% rename from ui/slot.info/sample/video-viewer.reel/video-viewer.html rename to ui/slot.info/sample/ui/video-viewer.reel/video-viewer.html diff --git a/ui/slot.info/sample/video-viewer.reel/video-viewer.js b/ui/slot.info/sample/ui/video-viewer.reel/video-viewer.js similarity index 100% rename from ui/slot.info/sample/video-viewer.reel/video-viewer.js rename to ui/slot.info/sample/ui/video-viewer.reel/video-viewer.js diff --git a/ui/substitution.info/index.html b/ui/substitution.info/sample/index.html similarity index 52% rename from ui/substitution.info/index.html rename to ui/substitution.info/sample/index.html index fd758b066b..eb8baf334e 100644 --- a/ui/substitution.info/index.html +++ b/ui/substitution.info/sample/index.html @@ -5,14 +5,11 @@ substitution.info - + diff --git a/ui/substitution.info/package.json b/ui/substitution.info/sample/package.json similarity index 54% rename from ui/substitution.info/package.json rename to ui/substitution.info/sample/package.json index 7d0d601a2b..70eb0c8fb9 100644 --- a/ui/substitution.info/package.json +++ b/ui/substitution.info/sample/package.json @@ -2,6 +2,9 @@ "name": "substitution.info", "private": true, "dependencies": { - "montage": "../.." + "montage": "*" + }, + "mappings": { + "montage": "../../../" } } \ No newline at end of file diff --git a/ui/substitution.info/sample/foo.reel/foo.html b/ui/substitution.info/sample/ui/foo.reel/foo.html similarity index 100% rename from ui/substitution.info/sample/foo.reel/foo.html rename to ui/substitution.info/sample/ui/foo.reel/foo.html diff --git a/ui/substitution.info/sample/foo.reel/foo.js b/ui/substitution.info/sample/ui/foo.reel/foo.js similarity index 100% rename from ui/substitution.info/sample/foo.reel/foo.js rename to ui/substitution.info/sample/ui/foo.reel/foo.js diff --git a/ui/substitution.info/sample/main.reel/main.css b/ui/substitution.info/sample/ui/main.reel/main.css similarity index 100% rename from ui/substitution.info/sample/main.reel/main.css rename to ui/substitution.info/sample/ui/main.reel/main.css diff --git a/ui/substitution.info/sample/main.reel/main.html b/ui/substitution.info/sample/ui/main.reel/main.html similarity index 61% rename from ui/substitution.info/sample/main.reel/main.html rename to ui/substitution.info/sample/ui/main.reel/main.html index 283f9953d9..975fdc76a5 100644 --- a/ui/substitution.info/sample/main.reel/main.html +++ b/ui/substitution.info/sample/ui/main.reel/main.html @@ -5,7 +5,9 @@ -
-
-

Title 1

+
+
+
+

Title 1

+
+
+

Title 2

+
-
-

Title 2

+ +
+
+

Title 1

+
+
+

Title 2

+
-
- -
-
-

Title 1

+ +
+
+
-
-

Title 2

+ + +
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
-
- -
-
-
-
- - -
-
- -
-
-
-
- -
-
-
-
- -
-
-
\ No newline at end of file diff --git a/ui/substitution.info/sample/main.reel/main.js b/ui/substitution.info/sample/ui/main.reel/main.js similarity index 100% rename from ui/substitution.info/sample/main.reel/main.js rename to ui/substitution.info/sample/ui/main.reel/main.js diff --git a/ui/succession.info/sample/index.html b/ui/succession.info/sample/index.html index 4457450a03..c9f18c64cf 100644 --- a/ui/succession.info/sample/index.html +++ b/ui/succession.info/sample/index.html @@ -5,7 +5,7 @@ succession.info - + +