Skip to content

Commit

Permalink
Add linter for UI tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
karelmaxa committed Feb 23, 2024
1 parent 1c1d4b1 commit df99ee4
Show file tree
Hide file tree
Showing 21 changed files with 357 additions and 352 deletions.
2 changes: 1 addition & 1 deletion openidm-ui/openidm-ui-admin/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const TEST_RESOURCES = {
"../openidm-ui-common/src/test/qunit/testRunner.js": ""
};

gulp.task("eslint", useEslint({ src: "src/main/js/**/*.js" }));
gulp.task("eslint", useEslint({ src: "src/{main/js,test/qunit}/**/*.js" }));

gulp.task("build:assets", useLocalResources({ "src/main/resources/**": "" }, { dest: TARGET_PATH }));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
define([
"org/forgerock/openidm/ui/admin/authentication/AuthenticationAbstractView"
], function (AuthenticationAbstractView) {
"org/forgerock/openidm/ui/admin/authentication/AuthenticationAbstractView",
"lodash"
], function (AuthenticationAbstractView, _) {
QUnit.module("AuthenticationAbstractView Tests");

QUnit.test("Derives custom properties from all properties", function(assert) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ define([
QUnit.module('AbstractConnectorView Tests');
QUnit.test("#cleanseObject traverses object removing all empty strings and falsy array elements", function (assert) {
let uncleanObj = {
a: "",
b: {
a: "",
b: {
a: "",
b: {
a: ["", "foo", null, "bar", undefined]
}
},
c: "foo"
a: ["", "foo", null, "bar", undefined]
}
},
cleanObj = {
c: "foo"
};
let cleanObj = {
a: null,
b: {
a: null,
b: {
a: null,
b: {
a: ["foo", "bar"]
}
},
c: "foo"
a: ["foo", "bar"]
}
},
testView = new AbstractConnectorView();
c: "foo"
};
let testView = new AbstractConnectorView();
assert.deepEqual(testView.cleanseObject(uncleanObj), cleanObj, "AbstractConnectorView #cleanseObject");
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@

/*global define */

define([
"org/forgerock/openidm/ui/admin/connector/ConnectorListView"
], function (ConnectorListView) {
Expand All @@ -9,19 +7,19 @@ define([
QUnit.test("prune connector collections", function (assert) {

var testConnector = {
"objectTypes": [
"__GROUP__",
"groupOfNames",
"person",
"organizationalPerson",
"organization",
"__ACCOUNT__",
"account",
"__SERVER_INFO__",
"organizationalUnit"
],
"ok": true
};
"objectTypes": [
"__GROUP__",
"groupOfNames",
"person",
"organizationalPerson",
"organization",
"__ACCOUNT__",
"account",
"__SERVER_INFO__",
"organizationalUnit"
],
"ok": true
};

assert.equal(ConnectorListView.pruneObjectTypes(testConnector).objectTypes.length, 9, "connector collection created with good connection");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ define([
"org/forgerock/openidm/ui/admin/connector/EditConnectorView",
"lodash",
"sinon",
"org/forgerock/openidm/ui/admin/connector/oauth/GoogleTypeView"
"org/forgerock/openidm/ui/admin/connector/oauth/GoogleTypeView",
"jquery"
],
function (EditConnectorView, _,
sinon,
GoogleTypeView) {
function (EditConnectorView, _, sinon, GoogleTypeView, $) {
QUnit.module('Connectors');

QUnit.test("Advanced Connector Save", function (assert) {
Expand Down Expand Up @@ -62,11 +61,11 @@ function (EditConnectorView, _,

QUnit.test("OAuth Connector Whitespace Trimming", function (assert) {
var whiteSpaceMerge = {
"configurationProperties" : {
"clientSecret" : " test ",
"clientId" : " test "
}
};
"configurationProperties" : {
"clientSecret" : " test ",
"clientId" : " test "
}
};

whiteSpaceMerge = GoogleTypeView.cleanSpacing(whiteSpaceMerge);

Expand All @@ -76,21 +75,20 @@ function (EditConnectorView, _,

QUnit.test("Generate correct connector patch", function (assert) {
var connector = {
"test" : "stuff"
},
change = {
"test" : "new stuff"
},
patch = EditConnectorView.generateConnectorPatch(connector, change, null);
"test" : "stuff"
},
change = {
"test" : "new stuff"
},
patch = EditConnectorView.generateConnectorPatch(connector, change, null);

assert.equal(patch[0].value, "new stuff", "Correctly generated patch value");
assert.equal(patch[1].field, "/enabled", "Correctly disable connector for testing");
});

QUnit.test("Testing a connector with pass result", function (assert) {
var ready = assert.async();

var connectorPassStub = sinon.stub(EditConnectorView, "connectorPass").callsFake(function(preTestResult, updatedForm){
var ready = assert.async(),
connectorPassStub = sinon.stub(EditConnectorView, "connectorPass").callsFake(function(preTestResult, updatedForm) {
ready();

assert.equal(preTestResult, true, "Promise correctly resolved and called pass function");
Expand All @@ -105,9 +103,8 @@ function (EditConnectorView, _,
});

QUnit.test("Testing a connector with fail result", function (assert) {
var ready = assert.async();

var connectorFailstub = sinon.stub(EditConnectorView, "connectorFail").callsFake(function(preTestResult, updatedForm, message){
var ready = assert.async(),
connectorFailstub = sinon.stub(EditConnectorView, "connectorFail").callsFake(function(preTestResult, updatedForm, message){
ready();

assert.equal(preTestResult, false, "Promise correctly resolved and called fail function");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ define([

QUnit.test("syncSearchablePropertiesForGenericResource", function (assert) {
var updatedConfig = RepoDelegate.syncSearchablePropertiesForGenericResource(
RepoDelegate.findGenericResourceMappingForRoute(_.cloneDeep(jdbcRepoConfig), "managed/user"),
["userName","mail"]
);
RepoDelegate.findGenericResourceMappingForRoute(_.cloneDeep(jdbcRepoConfig), "managed/user"),
["userName","mail"]
);

assert.equal(updatedConfig.properties["/userName"].searchable,true, "userName still searchable");
assert.equal(updatedConfig.properties["/mail"].searchable,true, "mail now searchable");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ define([
selectManaged = ["managed", "User"],
selectResult = AddMappingView.preselectMappingCard(selectConnector, connectors, managed);

assert.equal(selectResult.name, "ldap", "Successfully selected LDAP connector");
assert.equal(selectResult.resourceType, "connector", "Successfully detected and set resource type of connector");
assert.equal(selectResult.name, "ldap", "Successfully selected LDAP connector");
assert.equal(selectResult.resourceType, "connector", "Successfully detected and set resource type of connector");

selectResult = AddMappingView.preselectMappingCard(selectManaged, connectors, managed);
selectResult = AddMappingView.preselectMappingCard(selectManaged, connectors, managed);

assert.equal(selectResult.name, "User", "Successfully selected User managed object");
assert.equal(selectResult.resourceType, "managed", "Successfully detected and set resource type of managed");
assert.equal(selectResult.name, "User", "Successfully selected User managed object");
assert.equal(selectResult.resourceType, "managed", "Successfully detected and set resource type of managed");
});

QUnit.test("Add mapping card based on card location in dom", function (assert) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ define([
/*
* Task Threads
*/
/*
/*
* PrefetchLinks
*/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
define([
"org/forgerock/openidm/ui/admin/mapping/association/IndividualRecordValidationView"
], function (IndividualRecordValidationView) {
"org/forgerock/openidm/ui/admin/mapping/association/IndividualRecordValidationView",
"jquery"
], function (IndividualRecordValidationView, $) {
QUnit.module('IndividualRecordValidationView Tests');

QUnit.test("Generate correct rendering information for validSource", function (assert) {
var preferenceTest = {
"type" : "text/javascript",
"globals" : {
"preferences" : [
"marketing"
]
"type" : "text/javascript",
"globals" : {
"preferences" : [
"marketing"
]
},
"file" : "ui/preferenceCheck.js"
},
scriptTest = {
"type" : "text/javascript",
"globals" : {},
"file" : "ui/test.js"
},
"file" : "ui/preferenceCheck.js"
},
scriptTest = {
"type" : "text/javascript",
"globals" : {},
"file" : "ui/test.js"
},
results;
results;

results = IndividualRecordValidationView.getDisplayDetails(undefined);

Expand Down Expand Up @@ -92,7 +93,7 @@ define([

assert.equal(checkbox.is(":checked"), true, "Correctly checked preference check box");

checkbox = $("<input class='preference-check' type='checkbox' value='update'>")
checkbox = $("<input class='preference-check' type='checkbox' value='update'>");

IndividualRecordValidationView.setPreferences(preferences, checkbox);

Expand All @@ -102,16 +103,16 @@ define([

QUnit.test("Set edited script to correct mapping validation event", function (assert) {
var testScript = {
"type" : "text/javascript",
"globals" : {},
"source" : "test"
},
testScript2 = {
"type" : "text/javascript",
"globals" : {},
"file" : "fake"
},
mapping = {};
"type" : "text/javascript",
"globals" : {},
"source" : "test"
},
testScript2 = {
"type" : "text/javascript",
"globals" : {},
"file" : "fake"
},
mapping = {};

mapping = IndividualRecordValidationView.setScript(testScript, "target", mapping);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
define([
"org/forgerock/openidm/ui/admin/mapping/association/dataAssociationManagement/ChangeAssociationDialog"
"org/forgerock/openidm/ui/admin/mapping/association/dataAssociationManagement/ChangeAssociationDialog",
"jquery"
],
function (ChangeAssociationDialog, _) {
function (ChangeAssociationDialog, $) {
QUnit.module('ChangeAssociationDialog');

QUnit.test("formatResult", function (assert) {
Expand Down
Loading

0 comments on commit df99ee4

Please sign in to comment.