diff --git a/package-lock.json b/package-lock.json
index 4961bd4835b21763b819a70da0b0b88cfab411bf..643e93a95043e4c04a456e46ebff8b81884c7ba3 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -7376,6 +7376,14 @@
"css-what": "^3.2.1",
"domutils": "^1.7.0",
"nth-check": "^1.0.2"
+ },
+ "dependencies": {
+ "css-what": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/css-what/-/css-what-5.0.1.tgz",
+ "integrity": "sha512-FYDTSHb/7KXsWICVsxdmiExPjCfRC4qRFBdVwv7Ax9hMnvMmEjP9RfxTEZ3qPZGmADDn2vAKSo9UcN1jKVYscg==",
+ "dev": true
+ }
}
},
"css-select-base-adapter": {
@@ -7394,12 +7402,6 @@
"source-map": "^0.6.1"
}
},
- "css-what": {
- "version": "3.4.2",
- "resolved": "https://registry.npmjs.org/css-what/-/css-what-3.4.2.tgz",
- "integrity": "sha512-ACUm3L0/jiZTqfzRM3Hi9Q8eZqd6IK37mMWPLz9PJxkLWllYeRf+EHUSHYEtFop2Eqytaq1FizFVh7XfBnXCDQ==",
- "dev": true
- },
"cssesc": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz",
@@ -13705,6 +13707,12 @@
"lru-cache": "^6.0.0"
}
},
+ "trim-newlines": {
+ "version": "3.0.1",
+ "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-3.0.1.tgz",
+ "integrity": "sha512-c1PTsA3tYrIsLGkJkzHF+w9F2EyxfXGo4UyJc4pFL++FMjnq0HJS69T3M7d//gKrFKwy429bouPescbjecU+Zw==",
+ "dev": true
+ },
"type-fest": {
"version": "0.18.1",
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.18.1.tgz",
@@ -19936,12 +19944,6 @@
"punycode": "^2.1.0"
}
},
- "trim-newlines": {
- "version": "3.0.0",
- "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-3.0.0.tgz",
- "integrity": "sha512-C4+gOpvmxaSMKuEf9Qc134F1ZuOHVXKRbtEflf4NTtuuJDEIJ9p5PXsalL8SkeRw+qit1Mo+yuvMPAKwWg/1hA==",
- "dev": true
- },
"trough": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/trough/-/trough-1.0.5.tgz",
diff --git a/package.json b/package.json
index f1216d70c9374e6d9d80fea6387666d7ca3fd499..24d49e2d338cc3d09df0e91239d1e4df5575e364 100644
--- a/package.json
+++ b/package.json
@@ -149,6 +149,7 @@
},
"resolutions": {
"ajv": "^6.12.6",
+ "css-what": "^5.0.1",
"browserslist": "^4.16.5",
"faye-websocket": "^0.11.3",
"http-proxy": "^1.18.1",
@@ -161,6 +162,7 @@
"serialize-javascript": "^3.1.0",
"sockjs": "^0.3.21",
"ssri": "^8.0.1",
+ "trim-newlines": "^3.0.0",
"y18n": "^5.0.5",
"yargs-parser": "^18.1.3",
"ws": "^7.4.6",
diff --git a/src/components/AddCourse.vue b/src/components/AddCourse.vue
index a8ebba7022eadbc36dad8790f5c52a0d4c333bb1..d21fb825e5d221d909669de524b22160cccc15d9 100644
--- a/src/components/AddCourse.vue
+++ b/src/components/AddCourse.vue
@@ -26,7 +26,13 @@
hint="* Required"
persistent-hint
required
- :rules="[inputRules.required]"
+ :rules="[
+ inputRules.characterCountWithinRange(toAdd.name, {
+ min: 2,
+ max: 256,
+ }),
+ inputRules.required,
+ ]"
>
-
-
+ >
{
item.completed = { value: item.completed, loading: false };
diff --git a/tests/e2e/specs/superAdmin/courses.spec.js b/tests/e2e/specs/superAdmin/courses.spec.js
index e434c4dcaef18b0f103cd844958b9548a3aa686a..092b58a12a53dd2dc6d7da51c015a95ad9eb7035 100644
--- a/tests/e2e/specs/superAdmin/courses.spec.js
+++ b/tests/e2e/specs/superAdmin/courses.spec.js
@@ -1,11 +1,25 @@
describe("super admin user", () => {
before(() => {
cy.userFixture("users/superAdmin");
+ cy.visit("/training");
+ });
+ beforeEach(() => {
cy.intercept("GET", "/api/courses?*", {
fixture: "api/myCourses",
});
- cy.visit("/training");
});
+
+ function randomStringLength(length) {
+ var text = "";
+ var possible =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+
+ for (var i = 0; i < length; i++)
+ text += possible.charAt(Math.floor(Math.random() * possible.length));
+
+ return text;
+ }
+
it("courses - should list course information", () => {
cy.get("table tbody").within(() => {
cy.get("tr")
@@ -15,4 +29,57 @@ describe("super admin user", () => {
.should("have.length", 4);
});
});
+
+ it("courses - if no input should not be able to add a new course", () => {
+ cy.get("#training-table-header .text-right").within(() => {
+ cy.get("button").eq(0).click();
+ });
+ cy.get(".v-dialog .v-card__actions").within(() => {
+ cy.get("button").eq(1).should("be.disabled");
+ cy.get("button").eq(0).click(); // reset to popup closed
+ cy.wait(500);
+ });
+ });
+
+ it("courses - if title is too short should not be able to add a new course", () => {
+ cy.get("#training-table-header .text-right").within(() => {
+ cy.get("button").eq(0).click();
+ });
+ cy.get(".v-dialog").within(() => {
+ cy.get("input").eq(0).type(randomStringLength(1));
+ });
+ cy.get(".v-dialog .v-card__actions").within(() => {
+ cy.get("button").eq(1).should("be.disabled");
+ cy.get("button").eq(0).click(); // reset to popup closed
+ cy.wait(500);
+ });
+ });
+
+ it("courses - if title is too long should not be able to add a new course", () => {
+ cy.get("#training-table-header .text-right").within(() => {
+ cy.get("button").eq(0).click();
+ });
+ cy.get(".v-dialog").within(() => {
+ cy.get("input").eq(0).type(randomStringLength(256));
+ });
+ cy.get(".v-dialog .v-card__actions").within(() => {
+ cy.get("button").eq(1).should("be.disabled");
+ cy.get("button").eq(0).click(); // reset to popup closed
+ cy.wait(500);
+ });
+ });
+
+ it("courses - if description is too long should not be able to add a new course", () => {
+ cy.get("#training-table-header .text-right").within(() => {
+ cy.get("button").eq(0).click();
+ });
+ cy.get(".v-dialog").within(() => {
+ cy.get("textarea").eq(0).type(randomStringLength(2010));
+ });
+ cy.get(".v-dialog .v-card__actions").within(() => {
+ cy.get("button").eq(1).should("be.disabled");
+ cy.get("button").eq(0).click(); // reset to popup closed
+ cy.wait(500);
+ });
+ });
});
diff --git a/tests/e2e/specs/superAdmin/teams.spec.js b/tests/e2e/specs/superAdmin/teams.spec.js
index 3c2142ea22aef6567695991b7249b79e21d79ae7..0b918f1752c4b883a9f63fd3a2b99f8bb4993000 100644
--- a/tests/e2e/specs/superAdmin/teams.spec.js
+++ b/tests/e2e/specs/superAdmin/teams.spec.js
@@ -1,12 +1,26 @@
describe("super admin user", () => {
before(() => {
cy.userFixture("users/superAdmin");
+ cy.visit("/teams");
+ });
+
+ beforeEach(() => {
cy.intercept("GET", "api/teams?*", {
fixture: "api/teamsList",
});
- cy.visit("/teams");
});
+ function randomStringLength(length) {
+ var text = "";
+ var possible =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+
+ for (var i = 0; i < length; i++)
+ text += possible.charAt(Math.floor(Math.random() * possible.length));
+
+ return text;
+ }
+
it("teams - should list one team with names that contain the text 'Test'", () => {
cy.get("table tbody").within(() => {
cy.get("tr")
@@ -16,4 +30,57 @@ describe("super admin user", () => {
.should("have.length", 2);
});
});
+
+ it("teams - if no input should not be able to add a new team", () => {
+ cy.get(".teams .text-right").within(() => {
+ cy.get("button").eq(0).click();
+ });
+ cy.get(".v-dialog .v-card__actions").within(() => {
+ cy.get("button").eq(1).should("be.disabled");
+ cy.get("button").eq(0).click(); // reset to popup closed
+ cy.wait(500);
+ });
+ });
+
+ it("teams - if title is too short should not be able to add a new team", () => {
+ cy.get(".teams .text-right").within(() => {
+ cy.get("button").eq(0).click();
+ });
+ cy.get(".v-dialog").within(() => {
+ cy.get("input").eq(0).type(randomStringLength(1));
+ });
+ cy.get(".v-dialog .v-card__actions").within(() => {
+ cy.get("button").eq(1).should("be.disabled");
+ cy.get("button").eq(0).click(); // reset to popup closed
+ cy.wait(500);
+ });
+ });
+
+ it("teams - if title is too long should not be able to add a new team", () => {
+ cy.get(".teams .text-right").within(() => {
+ cy.get("button").eq(0).click();
+ });
+ cy.get(".v-dialog").within(() => {
+ cy.get("input").eq(0).type(randomStringLength(256));
+ });
+ cy.get(".v-dialog .v-card__actions").within(() => {
+ cy.get("button").eq(1).should("be.disabled");
+ cy.get("button").eq(0).click(); // reset to popup closed
+ cy.wait(500);
+ });
+ });
+
+ it("teams - if description is too long should not be able to add a new team", () => {
+ cy.get(".teams .text-right").within(() => {
+ cy.get("button").eq(0).click();
+ });
+ cy.get(".v-dialog").within(() => {
+ cy.get("textarea").eq(0).type(randomStringLength(2010));
+ });
+ cy.get(".v-dialog .v-card__actions").within(() => {
+ cy.get("button").eq(1).should("be.disabled");
+ cy.get("button").eq(0).click(); // reset to popup closed
+ cy.wait(500);
+ });
+ });
});