From 1e4d00477a25d3164f6271fba0cab3b377b265be Mon Sep 17 00:00:00 2001 From: Tony Atkins Date: Tue, 12 May 2020 11:51:16 +0200 Subject: [PATCH 1/4] GPII-4479: Update to work with newer versions of Infusion. --- package.json | 2 +- ...dated-component-pre-potentia-ii-tests.html | 1 + .../schema-validated-component-tests.html | 1 + tests/js/common/lib/check-potentia-grades.js | 35 +++++++++++++++++++ ...lidated-component-pre-potentia-ii-tests.js | 4 +-- .../schema-validated-component-tests.js | 4 +-- .../schema-validated-modelComponent-tests.js | 30 +++++++++++++--- 7 files changed, 68 insertions(+), 9 deletions(-) create mode 100644 tests/js/common/lib/check-potentia-grades.js diff --git a/package.json b/package.json index 55eacef..287bf30 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "gpii-binder": "1.0.6", "gpii-express": "1.0.15", "gpii-handlebars": "2.1.0-dev.20191014T141924Z.45a74ef.GPII-4100", - "infusion": "3.0.0-dev.20191009T141140Z.32c9263b4.FLUID-6148", + "infusion": "3.0.0-dev.20200326T173810Z.24ddb2718", "kettle": "1.11.0" }, "devDependencies": { diff --git a/tests/browser-fixtures/schema-validated-component-pre-potentia-ii-tests.html b/tests/browser-fixtures/schema-validated-component-pre-potentia-ii-tests.html index 2e10635..f76411f 100644 --- a/tests/browser-fixtures/schema-validated-component-pre-potentia-ii-tests.html +++ b/tests/browser-fixtures/schema-validated-component-pre-potentia-ii-tests.html @@ -29,6 +29,7 @@

    + diff --git a/tests/browser-fixtures/schema-validated-component-tests.html b/tests/browser-fixtures/schema-validated-component-tests.html index 9c8edc4..136074e 100644 --- a/tests/browser-fixtures/schema-validated-component-tests.html +++ b/tests/browser-fixtures/schema-validated-component-tests.html @@ -28,6 +28,7 @@

      + diff --git a/tests/js/common/lib/check-potentia-grades.js b/tests/js/common/lib/check-potentia-grades.js new file mode 100644 index 0000000..e4ff3de --- /dev/null +++ b/tests/js/common/lib/check-potentia-grades.js @@ -0,0 +1,35 @@ +/* globals require */ +/* eslint-env browser */ +var fluid = fluid || {}; + +(function (fluid) { + "use strict"; + if (!fluid.identity) { + fluid = require("infusion"); + } + + var gpii = fluid.registerNamespace("gpii"); + + require("../../../../"); + fluid.registerNamespace("gpii.test.schema"); + + /** + * + * Confirm that the context-based approach to handling both potentia-ii and mainline Infusion is working. + * @param {Object} component - The component to be inspected. + * @param {Object} jqUnit - The instance of jqUnit to use to check assertions. + * + */ + gpii.test.schema.checkContextGrades = function (component, jqUnit) { + var isPotentiaTwo = gpii.schema.component.hasRegisterPotentia(); + + if (isPotentiaTwo) { + jqUnit.assertTrue("The resulting component should have the 'potentia ii' grade mixed in.", fluid.componentHasGrade(component, "gpii.schema.component.potentiaII")); + jqUnit.assertFalse("The resulting component should not have the 'legacy' grade mixed in.", fluid.componentHasGrade(component, "gpii.schema.component.legacy")); + } + else { + jqUnit.assertFalse("The resulting component should not have the 'potentia ii' grade mixed in.", fluid.componentHasGrade(component, "gpii.schema.component.potentiaII")); + jqUnit.assertTrue("The resulting component should have the 'legacy' grade mixed in.", fluid.componentHasGrade(component, "gpii.schema.component.legacy")); + } + }; +})(fluid); diff --git a/tests/js/common/schema-validated-component-pre-potentia-ii-tests.js b/tests/js/common/schema-validated-component-pre-potentia-ii-tests.js index 7fa385d..4c12e40 100644 --- a/tests/js/common/schema-validated-component-pre-potentia-ii-tests.js +++ b/tests/js/common/schema-validated-component-pre-potentia-ii-tests.js @@ -16,6 +16,7 @@ var jqUnit = jqUnit || {}; fluid = require("infusion"); jqUnit = require("node-jqunit"); require("../../../src/js/common/schemaValidatedComponent"); + require("./lib/check-potentia-grades"); } var gpii = fluid.registerNamespace("gpii"); @@ -48,8 +49,7 @@ var jqUnit = jqUnit || {}; var component = gpii.tests.schemaValidatedComponent.legacy.component({ mustHave: true }); jqUnit.assert("We should have been able to instantiate our custom component with valid options."); - jqUnit.assertTrue("The resulting component should have the 'potentia ii' grade mixed in.", fluid.componentHasGrade(component, "gpii.schema.component.potentiaII")); - jqUnit.assertFalse("The resulting component should not have the 'legacy' grade mixed in.", fluid.componentHasGrade(component, "gpii.schema.component.legacy")); + gpii.test.schema.checkContextGrades(component, jqUnit); }); jqUnit.test("Testing invalid component options.", function () { diff --git a/tests/js/common/schema-validated-component-tests.js b/tests/js/common/schema-validated-component-tests.js index 60ae01b..3ab49e5 100644 --- a/tests/js/common/schema-validated-component-tests.js +++ b/tests/js/common/schema-validated-component-tests.js @@ -10,6 +10,7 @@ var jqUnit = jqUnit || {}; fluid = require("infusion"); jqUnit = require("node-jqunit"); require("../../../src/js/common/schemaValidatedComponent"); + require("./lib/check-potentia-grades"); } var gpii = fluid.registerNamespace("gpii"); @@ -38,8 +39,7 @@ var jqUnit = jqUnit || {}; var component = gpii.tests.schema.valid({ newBoolean: true }); jqUnit.assert("We should have been able to instantiate our custom component with valid options."); - jqUnit.assertTrue("The resulting component should have the 'potentia ii' grade mixed in.", fluid.componentHasGrade(component, "gpii.schema.component.potentiaII")); - jqUnit.assertFalse("The resulting component should not have the 'legacy' grade mixed in.", fluid.componentHasGrade(component, "gpii.schema.component.legacy")); + gpii.test.schema.checkContextGrades(component, jqUnit); }); jqUnit.test("Testing invalid component options.", function () { diff --git a/tests/js/common/schema-validated-modelComponent-tests.js b/tests/js/common/schema-validated-modelComponent-tests.js index 3ccfeed..bbc5978 100644 --- a/tests/js/common/schema-validated-modelComponent-tests.js +++ b/tests/js/common/schema-validated-modelComponent-tests.js @@ -14,16 +14,37 @@ var jqUnit = jqUnit || {}; var gpii = fluid.registerNamespace("gpii"); + fluid.defaults("gpii.tests.schema.modelComponent", { + gradeNames: ["gpii.schema.modelComponent"], + members: { + validationPasses: 0 + }, + listeners: { + "onCreate.validate": { + funcName: "gpii.tests.schema.modelComponent.trackedModelValidation", + args: ["{gpii.schema.validator}", "{that}"] // globalValidator, validatedModelComponent + } + } + }); + + gpii.tests.schema.modelComponent.trackedModelValidation = function (globalValidator, validatedModelComponent) { + validatedModelComponent.validationPasses++; + gpii.schema.modelComponent.validateModel(globalValidator, validatedModelComponent); + }; + jqUnit.module("Schema validated model component tests."); jqUnit.test("Testing the base grade.", function () { - var component = gpii.schema.modelComponent(); + var component = gpii.tests.schema.modelComponent(); jqUnit.assert("We should have been able to instantiate an instance of the base gpii.schema.component grade successfully."); + + jqUnit.assertEquals("There should have been a single validation pass on component startup.", 1, component.validationPasses); + jqUnit.assertLeftHand("The initial model should be valid.", { isValid: true }, component.model.validationResults); }); fluid.defaults("gpii.tests.schemaValidatedModelComponent.basicValidation",{ - gradeNames: ["gpii.schema.modelComponent"], + gradeNames: ["gpii.tests.schema.modelComponent"], modelSchema: { properties: { validModelVariableIsValid: { @@ -41,12 +62,12 @@ var jqUnit = jqUnit || {}; var component = gpii.tests.schemaValidatedModelComponent.basicValidation(); jqUnit.assert("We should have been able to instantiate an instance of our grade successfully."); - // This may be need to be removed to avoid timing problems, the next test is a more meaningful test of initial vs. subsequent validation. - jqUnit.assertLeftHand("The initial model should be valid.", { isValid: true }, component.model.validationResults); + jqUnit.assertEquals("There should have been a single validation pass on component startup.", 1, component.validationPasses); component.applier.modelChanged.addListener({ path: "validationResults"}, function (validationResults) { jqUnit.start(); jqUnit.assertLeftHand("The updated model should be invalid.", { isValid: false }, validationResults); + jqUnit.assertEquals("There should have been a second validation pass on a model change.", 2, component.validationPasses); }); jqUnit.stop(); @@ -62,6 +83,7 @@ var jqUnit = jqUnit || {}; jqUnit.start(); jqUnit.assertLeftHand("The old model should be invalid.", { isValid: false }, oldValidationResults); jqUnit.assertLeftHand("The new model should be valid.", { isValid: true }, newValidationResults); + jqUnit.assertEquals("There should have been a second validation pass on a model change.", 2, component.validationPasses); }); jqUnit.stop(); From 20fa3ba5eb50f8b0d211d84e0c7dfc4862876d41 Mon Sep 17 00:00:00 2001 From: Tony Atkins Date: Thu, 14 May 2020 11:08:43 +0200 Subject: [PATCH 2/4] GPII-4479: Tidied up lazy plain require of the package. --- package.json | 28 +++++++++---------- .../common/schemaValidatedModelComponent.js | 3 +- tests/js/common/lib/check-potentia-grades.js | 2 +- .../schema-validated-modelComponent-tests.js | 10 ++++++- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 287bf30..4dd5e8d 100644 --- a/package.json +++ b/package.json @@ -17,27 +17,27 @@ "author": "Tony Atkins ", "license": "BSD-3-Clause", "dependencies": { - "ajv": "6.10.2", - "gpii-binder": "1.0.6", + "ajv": "6.12.2", + "gpii-binder": "1.1.0", "gpii-express": "1.0.15", - "gpii-handlebars": "2.1.0-dev.20191014T141924Z.45a74ef.GPII-4100", + "gpii-handlebars": "2.1.0", "infusion": "3.0.0-dev.20200326T173810Z.24ddb2718", - "kettle": "1.11.0" + "kettle": "1.12.0" }, "devDependencies": { - "eslint": "6.5.1", + "eslint": "7.0.0", "eslint-config-fluid": "1.4.0", - "foundation-sites": "6.4.1", - "gpii-grunt-lint-all": "1.0.5", - "gpii-testem": "2.1.11-dev.20191003T113129Z.477bcc0.GPII-4156", - "grunt": "1.0.4", - "handlebars": "4.4.3", + "foundation-sites": "6.6.3", + "gpii-grunt-lint-all": "1.0.7", + "gpii-testem": "2.1.11", + "grunt": "1.1.0", + "handlebars": "4.7.6", "markdown-it": "10.0.0", - "mkdirp": "0.5.1", + "mkdirp": "1.0.4", "node-jqunit": "1.1.8", "nyc": "14.1.1", - "request": "2.88.0", - "rimraf": "3.0.0", - "testem": "2.17.0" + "request": "2.88.2", + "rimraf": "3.0.2", + "testem": "3.1.0" } } diff --git a/src/js/common/schemaValidatedModelComponent.js b/src/js/common/schemaValidatedModelComponent.js index 063dca7..ba75684 100644 --- a/src/js/common/schemaValidatedModelComponent.js +++ b/src/js/common/schemaValidatedModelComponent.js @@ -74,13 +74,14 @@ var fluid = fluid || require("infusion"); }, modelListeners: { "*": { + namespace: "validateModel", excludeSource: ["init", "validation"], funcName: "gpii.schema.modelComponent.validateModel", args: ["{gpii.schema.validator}", "{that}"] // globalValidator, validatedModelComponent } }, listeners: { - "onCreate.validate": { + "onCreate.validateModel": { funcName: "gpii.schema.modelComponent.validateModel", args: ["{gpii.schema.validator}", "{that}"] // globalValidator, validatedModelComponent } diff --git a/tests/js/common/lib/check-potentia-grades.js b/tests/js/common/lib/check-potentia-grades.js index e4ff3de..0e87d4a 100644 --- a/tests/js/common/lib/check-potentia-grades.js +++ b/tests/js/common/lib/check-potentia-grades.js @@ -6,11 +6,11 @@ var fluid = fluid || {}; "use strict"; if (!fluid.identity) { fluid = require("infusion"); + fluid.require("%gpii-json-schema"); } var gpii = fluid.registerNamespace("gpii"); - require("../../../../"); fluid.registerNamespace("gpii.test.schema"); /** diff --git a/tests/js/common/schema-validated-modelComponent-tests.js b/tests/js/common/schema-validated-modelComponent-tests.js index bbc5978..a72c486 100644 --- a/tests/js/common/schema-validated-modelComponent-tests.js +++ b/tests/js/common/schema-validated-modelComponent-tests.js @@ -19,8 +19,16 @@ var jqUnit = jqUnit || {}; members: { validationPasses: 0 }, + modelListeners: { + "*": { + namespace: "validateModel", + excludeSource: ["init", "validation"], + funcName: "gpii.tests.schema.modelComponent.trackedModelValidation", + args: ["{gpii.schema.validator}", "{that}"] // globalValidator, validatedModelComponent + } + }, listeners: { - "onCreate.validate": { + "onCreate.validateModel": { funcName: "gpii.tests.schema.modelComponent.trackedModelValidation", args: ["{gpii.schema.validator}", "{that}"] // globalValidator, validatedModelComponent } From 5d1cbba7b43833db68ecf30cad2522319542e1d8 Mon Sep 17 00:00:00 2001 From: Tony Atkins Date: Tue, 26 May 2020 09:41:38 +0200 Subject: [PATCH 3/4] GPII-4479: Updated to infusion with resource loader fix. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4dd5e8d..0781cde 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "gpii-binder": "1.1.0", "gpii-express": "1.0.15", "gpii-handlebars": "2.1.0", - "infusion": "3.0.0-dev.20200326T173810Z.24ddb2718", + "infusion": "3.0.0-dev.20200525T143422Z.f7f6aab.FLUID-6148", "kettle": "1.12.0" }, "devDependencies": { From 3929d4aac9e10ef3a444fd588c8a37eccc6a6310 Mon Sep 17 00:00:00 2001 From: Tony Atkins Date: Tue, 26 May 2020 16:20:27 +0200 Subject: [PATCH 4/4] GPII-4479: Further updated dependencies to pick up recent releases. --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 0781cde..f61d8d7 100644 --- a/package.json +++ b/package.json @@ -20,22 +20,22 @@ "ajv": "6.12.2", "gpii-binder": "1.1.0", "gpii-express": "1.0.15", - "gpii-handlebars": "2.1.0", + "gpii-handlebars": "2.1.1", "infusion": "3.0.0-dev.20200525T143422Z.f7f6aab.FLUID-6148", "kettle": "1.12.0" }, "devDependencies": { - "eslint": "7.0.0", + "eslint": "7.1.0", "eslint-config-fluid": "1.4.0", "foundation-sites": "6.6.3", "gpii-grunt-lint-all": "1.0.7", - "gpii-testem": "2.1.11", + "gpii-testem": "2.1.12", "grunt": "1.1.0", "handlebars": "4.7.6", - "markdown-it": "10.0.0", + "markdown-it": "11.0.0", "mkdirp": "1.0.4", "node-jqunit": "1.1.8", - "nyc": "14.1.1", + "nyc": "15.0.1", "request": "2.88.2", "rimraf": "3.0.2", "testem": "3.1.0"