From 9eea7773d57d6c877588bce22cfdd3fd5495a975 Mon Sep 17 00:00:00 2001 From: Stephan Krusche Date: Mon, 13 Apr 2020 17:29:24 +0200 Subject: [PATCH 001/152] update client configs 1) run all client tests 2) check documentation automatically 3) also check files in test folder for code style --- package.json | 2 +- src/test/javascript/jest.config.js | 2 +- src/test/resources/config/bootstrap.yml | 4 ---- tsconfig.json | 6 +++--- 4 files changed, 5 insertions(+), 9 deletions(-) delete mode 100644 src/test/resources/config/bootstrap.yml diff --git a/package.json b/package.json index 82ced79278e2..c2ac86437b6a 100644 --- a/package.json +++ b/package.json @@ -178,7 +178,7 @@ "scripts": { "prettier:format": "prettier --write 'src/{main/webapp,test}/**/*.{json,ts,css,scss,html}'", "prettier:check": "prettier --check 'src/{main/webapp,test}/**/*.{json,ts,css,scss,html}'", - "lint": "eslint . --ext .ts", + "lint": "eslint . --ext .ts && yarn run lint:doc", "lint:fix": "yarn run lint --fix", "lint:doc": "tslint --config tslint-doc.json --project tsconfig.json -e 'node_modules/**'", "ngc": "ngc -p tsconfig.app.json", diff --git a/src/test/javascript/jest.config.js b/src/test/javascript/jest.config.js index 5eb8184d5ac6..9c3a49ec306e 100644 --- a/src/test/javascript/jest.config.js +++ b/src/test/javascript/jest.config.js @@ -13,7 +13,7 @@ module.exports = { modulePaths: ['/src/main/webapp/'], transformIgnorePatterns: [`/node_modules/(?!${esModules})`], rootDir: '../../../', - testMatch: ['/src/test/javascript/spec/integration/**/*.ts', '/src/test/javascript/spec/component/**/*.ts', '/src/test/javascript/spec/service/**/*.ts'], + testMatch: ['/src/test/javascript/spec/**/*.ts'], moduleNameMapper: { '^app/(.*)': '/src/main/webapp/app/$1', 'test/(.*)': '/src/test/javascript/spec/$1', diff --git a/src/test/resources/config/bootstrap.yml b/src/test/resources/config/bootstrap.yml deleted file mode 100644 index 11cd6af21cba..000000000000 --- a/src/test/resources/config/bootstrap.yml +++ /dev/null @@ -1,4 +0,0 @@ -spring: - cloud: - config: - enabled: false diff --git a/tsconfig.json b/tsconfig.json index 1abb362bbd15..757d7ea9350f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -35,10 +35,10 @@ "preserveWhitespaces": true }, "include": [ - "src/main/webapp/app" + "src/main/webapp/app", + "src/test/javascript" ], "exclude": [ - "node_modules", - "src/test" + "node_modules" ] } From 39c6080e2c531092da57f27d7504fbc9cb904230 Mon Sep 17 00:00:00 2001 From: Stephan Krusche Date: Mon, 13 Apr 2020 17:33:22 +0200 Subject: [PATCH 002/152] update more config --- .eslintignore | 5 ----- .eslintrc.json | 2 -- 2 files changed, 7 deletions(-) diff --git a/.eslintignore b/.eslintignore index 60c136febd52..8b65ae5e2e97 100644 --- a/.eslintignore +++ b/.eslintignore @@ -16,11 +16,6 @@ src/main/generated/ src/main/java/ src/main/jib/ src/main/resources/ -src/test/ -src/test/javascript/e2e/ -src/test/javascript/protractor.conf.js -src/test/javascript/jest.conf.js -src/test/k6/ uploads/ webpack/ target/ diff --git a/.eslintrc.json b/.eslintrc.json index e1d6c85cfcb9..95095647f3e5 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -4,8 +4,6 @@ "@typescript-eslint/tslint" ], "extends": [ -// "plugin:@typescript-eslint/eslint-recommended", -// "plugin:@typescript-eslint/recommended", "prettier/@typescript-eslint", "plugin:prettier/recommended" ], From eb1e8461447c33efaff9c95dc053aaa400f998c8 Mon Sep 17 00:00:00 2001 From: Stephan Krusche Date: Mon, 13 Apr 2020 20:26:11 +0200 Subject: [PATCH 003/152] also apply prettier on js files and format them except k6 files to avoid merge conflicts with the open PR --- package.json | 4 ++-- .../InlineHtmlStripStylesTransformer.js | 6 +++--- src/test/javascript/protractor.conf.js | 19 +++++++++---------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index c2ac86437b6a..da7b3b8e1e35 100644 --- a/package.json +++ b/package.json @@ -176,8 +176,8 @@ "src/{main,test}/java/**/*.java": "bash ./linting.sh" }, "scripts": { - "prettier:format": "prettier --write 'src/{main/webapp,test}/**/*.{json,ts,css,scss,html}'", - "prettier:check": "prettier --check 'src/{main/webapp,test}/**/*.{json,ts,css,scss,html}'", + "prettier:format": "prettier --write 'src/{main/webapp,test}/**/*.{json,ts,js,css,scss,html}'", + "prettier:check": "prettier --check 'src/{main/webapp,test}/**/*.{json,ts,js,css,scss,html}'", "lint": "eslint . --ext .ts && yarn run lint:doc", "lint:fix": "yarn run lint --fix", "lint:doc": "tslint --config tslint-doc.json --project tsconfig.json -e 'node_modules/**'", diff --git a/src/test/javascript/InlineHtmlStripStylesTransformer.js b/src/test/javascript/InlineHtmlStripStylesTransformer.js index d64599a73873..1b6b13fa462e 100644 --- a/src/test/javascript/InlineHtmlStripStylesTransformer.js +++ b/src/test/javascript/InlineHtmlStripStylesTransformer.js @@ -94,7 +94,7 @@ function factory(cs) { * Our main visitor, which will be called recursively for each node in the source file's AST * @param node The node to be visited */ - var visitor = function(node) { + var visitor = function (node) { var resultNode; // before we create a deep clone to modify, we make sure that // this is an assignment which we want to transform @@ -110,8 +110,8 @@ function factory(cs) { }; return visitor; } - return function(ctx) { - return function(sf) { + return function (ctx) { + return function (sf) { return ts.visitNode(sf, createVisitor(ctx, sf)); }; }; diff --git a/src/test/javascript/protractor.conf.js b/src/test/javascript/protractor.conf.js index a1019b701157..bae7fcab1f8f 100644 --- a/src/test/javascript/protractor.conf.js +++ b/src/test/javascript/protractor.conf.js @@ -1,4 +1,3 @@ - exports.config = { allScriptsTimeout: 20000, @@ -11,9 +10,9 @@ exports.config = { browserName: 'chrome', chromeOptions: { args: process.env.JHI_E2E_HEADLESS - ? [ "--headless", "--disable-gpu", "--window-size=1280,1024", "--disable-extensions", "incognito" ] - : [ "--disable-gpu", "--window-size=1280,1024", "--disable-extensions", "incognito" ] - } + ? ['--headless', '--disable-gpu', '--window-size=1280,1024', '--disable-extensions', 'incognito'] + : ['--disable-gpu', '--window-size=1280,1024', '--disable-extensions', 'incognito'], + }, }, directConnect: true, @@ -28,17 +27,17 @@ exports.config = { reporter: 'spec', slow: 3000, ui: 'bdd', - timeout: 720000 + timeout: 720000, }, - beforeLaunch: function() { + beforeLaunch: function () { require('ts-node').register({ - project: 'tsconfig.e2e.json' + project: 'tsconfig.e2e.json', }); }, - onPrepare: function() { - browser.driver.manage().window().setRect({x: 100, y: 100, width: 1280, height: 1024}); + onPrepare: function () { + browser.driver.manage().window().setRect({ x: 100, y: 100, width: 1280, height: 1024 }); // Disable animations // @ts-ignore browser.executeScript('document.body.className += " notransition";'); @@ -51,5 +50,5 @@ exports.config = { global.chai = chai; }, - useAllAngular2AppRoots: true + useAllAngular2AppRoots: true, }; From 9b1ddf17709bea1575de097281adae0157ba7797 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Tue, 14 Apr 2020 16:08:41 +0200 Subject: [PATCH 004/152] Fix typescript code formatting --- src/test/k6/ArtemisLogin.js | 791 ++++++++++---------- src/test/k6/ArtemisLoginNoJS.js | 551 +++++++------- src/test/k6/ArtemisLoginOnlyWebsocket.js | 271 +++---- src/test/k6/ArtemisOnlyDashboard.js | 273 +++---- src/test/k6/CodeEditor.js | 17 +- src/test/k6/ProgrammingExerciseAPIs.js | 37 +- src/test/k6/QuizExerciseAPIs.js | 26 +- src/test/k6/requests/course.js | 10 +- src/test/k6/requests/endpoints.js | 10 +- src/test/k6/requests/programmingExercise.js | 85 +-- src/test/k6/requests/quiz.js | 36 +- src/test/k6/requests/requests.js | 164 ++-- src/test/k6/requests/user.js | 37 +- src/test/k6/resource/constants_c.js | 186 ++--- src/test/k6/resource/constants_java.js | 89 ++- src/test/k6/resource/constants_python.js | 71 +- src/test/k6/util/utils.js | 5 +- 17 files changed, 1356 insertions(+), 1303 deletions(-) diff --git a/src/test/k6/ArtemisLogin.js b/src/test/k6/ArtemisLogin.js index 216f7636a459..c8b97baff8c2 100644 --- a/src/test/k6/ArtemisLogin.js +++ b/src/test/k6/ArtemisLogin.js @@ -1,437 +1,452 @@ import { group, sleep } from 'k6'; import http from 'k6/http'; import ws from 'k6/ws'; -import { Trend } from "k6/metrics"; +import { Trend } from 'k6/metrics'; // Version: 1.1 // Creator: Firefox // Browser: Firefox -var rest_call_metrics = new Trend("rest_call_metrics"); +var rest_call_metrics = new Trend('rest_call_metrics'); export let options = { maxRedirects: 0, ext: { - "loadimpact": { - "distribution": { - "load_zone0": { - "loadZone": "amazon:de:frankfurt", - "percent": 100 - } - } - } + loadimpact: { + distribution: { + load_zone0: { + loadZone: 'amazon:de:frankfurt', + percent: 100, + }, + }, + }, }, stages: [ { - "duration": "15s", - "target": 10 + duration: '15s', + target: 10, }, { - "duration": "15s", - "target": 20 + duration: '15s', + target: 20, }, { - "duration": "15s", - "target": 30 + duration: '15s', + target: 30, }, { - "duration": "15s", - "target": 40 + duration: '15s', + target: 40, }, { - "duration": "15s", - "target": 50 + duration: '15s', + target: 50, }, { - "duration": "15s", - "target": 60 + duration: '15s', + target: 60, }, { - "duration": "15s", - "target": 70 + duration: '15s', + target: 70, }, { - "duration": "15s", - "target": 80 + duration: '15s', + target: 80, }, { - "duration": "15s", - "target": 90 + duration: '15s', + target: 90, }, { - "duration": "180s", - "target": 100 - } + duration: '180s', + target: 100, + }, ], - vus: 100 + vus: 100, }; -export default function() { - let defaultXSRFToken = "42d141b5-9e1c-4390-ae06-5143753b4459"; - let protocol = "http"; // https or http - let websocketProtocol = "ws"; // wss if https is used; ws if http is used - let host = "nginx:80"; // host including port if differing from 80 (http) or 443 (https) - let baseUrl = protocol + "://" + host; - - let maxTestUser = 100; // the userId will be an integer between 1 and this number - - let delayBeforeLogin = 1; // Time in seconds the simulated user needs to enter username/password - let websocketConnectionTime = 100; // Time in seconds the websocket is kept open, if set to 0 no websocket connection is estahblished - - let userAgent = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:66.0) Gecko/20100101 Firefox/66.0"; - let acceptLanguage = "en-CA,en-US;q=0.7,en;q=0.3"; - let acceptEncoding = "gzip, deflate, br"; - - let username = __ENV.BASE_USERNAME; // USERID gets replaced with a random number between 1 and maxTestUser - let password = "__ENV.BASE_PASSWORD"; // USERID gets replaced with a random number between 1 and maxTestUser - - group("Artemis Login", function() { - let req, res; - var total_waiting_time = 0; - - // The website is loaded initialy - req = [{ - "method": "get", - "url": baseUrl + "/#/", - "params": { - "headers": { - "Host": host, - "User-Agent": userAgent, - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", - "Accept-Language": acceptLanguage, - "Accept-Encoding": acceptEncoding, - "Connection": "keep-alive", - "Upgrade-Insecure-Requests": "1", - "Pragma": "no-cache", - "Cache-Control": "no-cache" - }, - "tags": {"name": baseUrl + "/#/"} - } - } - ]; - res = http.batch(req); - for (var i = 0; i < req.length; i++) { - total_waiting_time += res[i].timings.waiting; - } - - // The dynamically generated links to the .css and .js files get extracted from the first response and a request is sent to every of these files - req = []; - // Add css/js files dynamically - let regex = /(?:"([^"]*\.(css|js))")/g; - var matched; - while((matched = regex.exec(res[0].body)) != undefined) { - req.push({ - "method": "get", - "url": baseUrl + "/" + matched[1], - "params": { - "cookies": { - "XSRF-TOKEN": defaultXSRFToken - }, - "headers": { - "Host": host, - "User-Agent": userAgent, - "Accept": "*/*;q=0.1", - "Accept-Language": acceptLanguage, - "Accept-Encoding": acceptEncoding, - "Referer": baseUrl + "/", - "Connection": "keep-alive", - "Pragma": "no-cache", - "Cache-Control": "no-cache", - "TE": "Trailers" - }, - "tags": {"name": baseUrl + "/dynamic-files"} - } - }); - } - res = http.batch(req); - for (var i = 0; i < req.length; i++) { - total_waiting_time += res[i].timings.waiting; - } - - // The favicon, the translations, some management information and the TUM logo is downloaded next - req = [{ - "method": "get", - "url": baseUrl + "/public/images/favicon.ico", - "params": { - "cookies": { - "XSRF-TOKEN": defaultXSRFToken - }, - "headers": { - "Host": host, - "User-Agent": userAgent, - "Accept": "image/webp,*/*", - "Accept-Language": acceptLanguage, - "Accept-Encoding": acceptEncoding, - "Connection": "keep-alive", - "Pragma": "no-cache", - "Cache-Control": "no-cache", - "TE": "Trailers" - }, - "tags": {"name": baseUrl + "/favicon"} - } - },{ - "method": "get", - "url": baseUrl + "/i18n/en.json?buildTimestamp=1556135702468", - "params": { - "cookies": { - "XSRF-TOKEN": defaultXSRFToken - }, - "headers": { - "Host": host, - "User-Agent": userAgent, - "Accept": "application/json, text/plain, */*", - "Accept-Language": acceptLanguage, - "Accept-Encoding": acceptEncoding, - "Referer": baseUrl + "/", - "Connection": "keep-alive", - "Pragma": "no-cache", - "Cache-Control": "no-cache", - "TE": "Trailers" - }, - "tags": {"name": baseUrl + "/i18n"} - } - },{ - "method": "get", - "url": baseUrl + "/management/info", - "params": { - "cookies": { - "XSRF-TOKEN": defaultXSRFToken - }, - "headers": { - "Host": host, - "User-Agent": userAgent, - "Accept": "application/json, text/plain, */*", - "Accept-Language": acceptLanguage, - "Accept-Encoding": acceptEncoding, - "Referer": baseUrl + "/", - "Connection": "keep-alive", - "Pragma": "no-cache", - "Cache-Control": "no-cache", - "TE": "Trailers" - }, - "tags": {"name": baseUrl + "/management/info"} - } - },{ - "method": "get", - "url": baseUrl + "/api/account", - "params": { - "cookies": { - "XSRF-TOKEN": defaultXSRFToken - }, - "headers": { - "Host": host, - "User-Agent": userAgent, - "Accept": "application/json, text/plain, */*", - "Accept-Language": acceptLanguage, - "Accept-Encoding": acceptEncoding, - "Referer": baseUrl + "/", - "Connection": "keep-alive", - "Pragma": "no-cache", - "Cache-Control": "no-cache", - "TE": "Trailers" - }, - "tags": {"name": baseUrl + "/api/account"} - } - },{ - "method": "get", - "url": baseUrl + "/content/7c761975dc7a3abfc710400d4dd51933.png", - "params": { - "cookies": { - "XSRF-TOKEN": defaultXSRFToken - }, - "headers": { - "Host": host, - "User-Agent": userAgent, - "Accept": "image/webp,*/*", - "Accept-Language": acceptLanguage, - "Accept-Encoding": acceptEncoding, - "Referer": baseUrl + "/", - "Connection": "keep-alive", - "Pragma": "no-cache", - "Cache-Control": "no-cache", - "TE": "Trailers" - }, - "tags": {"name": baseUrl + "/content"} - } - }]; - res = http.batch(req); - for (var i = 0; i < req.length; i++) { - total_waiting_time += res[i].timings.waiting; - } - - - // Now the user should type his login credentials, therefor we wait some time - sleep(delayBeforeLogin); - - // The user is randomly selected - let userId = Math.floor((Math.random() * maxTestUser)) + 1; - let currentUsername = username.replace("USERID", userId); - let currentPassword = password.replace("USERID", userId); - - // The user logs in; the authToken gets saved as we need it later - req = [{ - "method": "post", - "url": baseUrl + "/api/authenticate", - "body": "{\"username\":\"" + currentUsername + "\",\"password\":\"" + currentPassword +"\",\"rememberMe\":true}", - "params": { - "cookies": { - "XSRF-TOKEN": defaultXSRFToken - }, - "headers": { - "Host": host, - "User-Agent": userAgent, - "Accept": "application/json, text/plain, */*", - "Accept-Language": acceptLanguage, - "Accept-Encoding": acceptEncoding, - "Referer": baseUrl + "/", - "X-XSRF-TOKEN": defaultXSRFToken, - "Content-Type": "application/json", - "Content-Length": "74", - "Connection": "keep-alive", - "TE": "Trailers" - }, - "tags": {"name": baseUrl + "/api/authenticate"} - } - }]; - res = http.batch(req); - for (var i = 0; i < req.length; i++) { - total_waiting_time += res[i].timings.waiting; - } - let authToken = JSON.parse(res[0].body).id_token; - - // The user requests it own information of the account - req = [{ - "method": "get", - "url": baseUrl + "/api/account", - "params": { - "cookies": { - "XSRF-TOKEN": defaultXSRFToken - }, - "headers": { - "Host": host, - "User-Agent": userAgent, - "Accept": "application/json, text/plain, */*", - "Accept-Language": acceptLanguage, - "Accept-Encoding": acceptEncoding, - "Referer": baseUrl + "/", - "Authorization": "Bearer " + authToken, - "Connection": "keep-alive", - "TE": "Trailers" - }, - "tags": {"name": baseUrl + "/api/account"} - } - }]; - - res = http.batch(req); - for (var i = 0; i < req.length; i++) { - total_waiting_time += res[i].timings.waiting; - } - - // A new XSRF Token is needed now, we have to extract it from the cookies - let xsrftoken = res[0].headers["Set-Cookie"].match('XSRF-TOKEN=(.*); path=\/(; secure)?')[1]; - - // Extract user as we need it for some websocket information - let user = JSON.parse(res[0].body); - - // Some more calls (dashboard, notification, courses to register) are made - req = [{ - "method": "get", - "url": baseUrl + "/api/courses/for-dashboard", - "params": { - "cookies": { - "XSRF-TOKEN": xsrftoken - }, - "headers": { - "Host": host, - "User-Agent": userAgent, - "Accept": "application/json, text/plain, */*", - "Accept-Language": acceptLanguage, - "Accept-Encoding": acceptEncoding, - "Referer": baseUrl + "/", - "Authorization": "Bearer " + authToken, - "Connection": "keep-alive", - "TE": "Trailers" - }, - "tags": {"name": baseUrl + "/api/courses/for-dashboard"} - } - },{ - "method": "get", - "url": baseUrl + "/api/notifications/for-user", - "params": { - "cookies": { - "XSRF-TOKEN": xsrftoken - }, - "headers": { - "Host": host, - "User-Agent": userAgent, - "Accept": "application/json, text/plain, */*", - "Accept-Language": acceptLanguage, - "Accept-Encoding": acceptEncoding, - "Referer": baseUrl + "/", - "Authorization": "Bearer " + authToken, - "Connection": "keep-alive", - "TE": "Trailers" - }, - "tags": {"name": baseUrl + "/api/notifications/for-user"} - } - }]; - res = http.batch(req); - for (var i = 0; i < req.length; i++) { - total_waiting_time += res[i].timings.waiting; - } - rest_call_metrics.add(total_waiting_time); - - let courses = JSON.parse(res[1].body); +export default function () { + let defaultXSRFToken = '42d141b5-9e1c-4390-ae06-5143753b4459'; + let protocol = 'http'; // https or http + let websocketProtocol = 'ws'; // wss if https is used; ws if http is used + let host = 'nginx:80'; // host including port if differing from 80 (http) or 443 (https) + let baseUrl = protocol + '://' + host; + + let maxTestUser = 100; // the userId will be an integer between 1 and this number + + let delayBeforeLogin = 1; // Time in seconds the simulated user needs to enter username/password + let websocketConnectionTime = 100; // Time in seconds the websocket is kept open, if set to 0 no websocket connection is estahblished + + let userAgent = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:66.0) Gecko/20100101 Firefox/66.0'; + let acceptLanguage = 'en-CA,en-US;q=0.7,en;q=0.3'; + let acceptEncoding = 'gzip, deflate, br'; + + let username = __ENV.BASE_USERNAME; // USERID gets replaced with a random number between 1 and maxTestUser + let password = '__ENV.BASE_PASSWORD'; // USERID gets replaced with a random number between 1 and maxTestUser + + group('Artemis Login', function () { + let req, res; + var total_waiting_time = 0; + + // The website is loaded initialy + req = [ + { + method: 'get', + url: baseUrl + '/#/', + params: { + headers: { + Host: host, + 'User-Agent': userAgent, + Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', + 'Accept-Language': acceptLanguage, + 'Accept-Encoding': acceptEncoding, + Connection: 'keep-alive', + 'Upgrade-Insecure-Requests': '1', + Pragma: 'no-cache', + 'Cache-Control': 'no-cache', + }, + tags: { name: baseUrl + '/#/' }, + }, + }, + ]; + res = http.batch(req); + for (var i = 0; i < req.length; i++) { + total_waiting_time += res[i].timings.waiting; + } - // Initiate websocket connection if connection time is set to value greater than 0 - if (websocketConnectionTime > 0) { - let websocketEndpoint = websocketProtocol + "://" + host + "/websocket/tracker/websocket"; - let websocketUrl = websocketEndpoint + "?access_token=" + authToken; + // The dynamically generated links to the .css and .js files get extracted from the first response and a request is sent to every of these files + req = []; + // Add css/js files dynamically + let regex = /(?:"([^"]*\.(css|js))")/g; + var matched; + while ((matched = regex.exec(res[0].body)) != undefined) { + req.push({ + method: 'get', + url: baseUrl + '/' + matched[1], + params: { + cookies: { + 'XSRF-TOKEN': defaultXSRFToken, + }, + headers: { + Host: host, + 'User-Agent': userAgent, + Accept: '*/*;q=0.1', + 'Accept-Language': acceptLanguage, + 'Accept-Encoding': acceptEncoding, + Referer: baseUrl + '/', + Connection: 'keep-alive', + Pragma: 'no-cache', + 'Cache-Control': 'no-cache', + TE: 'Trailers', + }, + tags: { name: baseUrl + '/dynamic-files' }, + }, + }); + } + res = http.batch(req); + for (var i = 0; i < req.length; i++) { + total_waiting_time += res[i].timings.waiting; + } - var response = ws.connect(websocketUrl, {"tags": {"name": websocketEndpoint}}, function(socket) { - socket.on('open', function open() { - socket.send("CONNECT\nX-XSRF-TOKEN:" + xsrftoken + "\naccept-version:1.1,1.0\nheart-beat:10000,10000\n\n\u0000"); - }); + // The favicon, the translations, some management information and the TUM logo is downloaded next + req = [ + { + method: 'get', + url: baseUrl + '/public/images/favicon.ico', + params: { + cookies: { + 'XSRF-TOKEN': defaultXSRFToken, + }, + headers: { + Host: host, + 'User-Agent': userAgent, + Accept: 'image/webp,*/*', + 'Accept-Language': acceptLanguage, + 'Accept-Encoding': acceptEncoding, + Connection: 'keep-alive', + Pragma: 'no-cache', + 'Cache-Control': 'no-cache', + TE: 'Trailers', + }, + tags: { name: baseUrl + '/favicon' }, + }, + }, + { + method: 'get', + url: baseUrl + '/i18n/en.json?buildTimestamp=1556135702468', + params: { + cookies: { + 'XSRF-TOKEN': defaultXSRFToken, + }, + headers: { + Host: host, + 'User-Agent': userAgent, + Accept: 'application/json, text/plain, */*', + 'Accept-Language': acceptLanguage, + 'Accept-Encoding': acceptEncoding, + Referer: baseUrl + '/', + Connection: 'keep-alive', + Pragma: 'no-cache', + 'Cache-Control': 'no-cache', + TE: 'Trailers', + }, + tags: { name: baseUrl + '/i18n' }, + }, + }, + { + method: 'get', + url: baseUrl + '/management/info', + params: { + cookies: { + 'XSRF-TOKEN': defaultXSRFToken, + }, + headers: { + Host: host, + 'User-Agent': userAgent, + Accept: 'application/json, text/plain, */*', + 'Accept-Language': acceptLanguage, + 'Accept-Encoding': acceptEncoding, + Referer: baseUrl + '/', + Connection: 'keep-alive', + Pragma: 'no-cache', + 'Cache-Control': 'no-cache', + TE: 'Trailers', + }, + tags: { name: baseUrl + '/management/info' }, + }, + }, + { + method: 'get', + url: baseUrl + '/api/account', + params: { + cookies: { + 'XSRF-TOKEN': defaultXSRFToken, + }, + headers: { + Host: host, + 'User-Agent': userAgent, + Accept: 'application/json, text/plain, */*', + 'Accept-Language': acceptLanguage, + 'Accept-Encoding': acceptEncoding, + Referer: baseUrl + '/', + Connection: 'keep-alive', + Pragma: 'no-cache', + 'Cache-Control': 'no-cache', + TE: 'Trailers', + }, + tags: { name: baseUrl + '/api/account' }, + }, + }, + { + method: 'get', + url: baseUrl + '/content/7c761975dc7a3abfc710400d4dd51933.png', + params: { + cookies: { + 'XSRF-TOKEN': defaultXSRFToken, + }, + headers: { + Host: host, + 'User-Agent': userAgent, + Accept: 'image/webp,*/*', + 'Accept-Language': acceptLanguage, + 'Accept-Encoding': acceptEncoding, + Referer: baseUrl + '/', + Connection: 'keep-alive', + Pragma: 'no-cache', + 'Cache-Control': 'no-cache', + TE: 'Trailers', + }, + tags: { name: baseUrl + '/content' }, + }, + }, + ]; + res = http.batch(req); + for (var i = 0; i < req.length; i++) { + total_waiting_time += res[i].timings.waiting; + } - function getSubscriptionId() { - return Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 12); + // Now the user should type his login credentials, therefor we wait some time + sleep(delayBeforeLogin); + + // The user is randomly selected + let userId = Math.floor(Math.random() * maxTestUser) + 1; + let currentUsername = username.replace('USERID', userId); + let currentPassword = password.replace('USERID', userId); + + // The user logs in; the authToken gets saved as we need it later + req = [ + { + method: 'post', + url: baseUrl + '/api/authenticate', + body: '{"username":"' + currentUsername + '","password":"' + currentPassword + '","rememberMe":true}', + params: { + cookies: { + 'XSRF-TOKEN': defaultXSRFToken, + }, + headers: { + Host: host, + 'User-Agent': userAgent, + Accept: 'application/json, text/plain, */*', + 'Accept-Language': acceptLanguage, + 'Accept-Encoding': acceptEncoding, + Referer: baseUrl + '/', + 'X-XSRF-TOKEN': defaultXSRFToken, + 'Content-Type': 'application/json', + 'Content-Length': '74', + Connection: 'keep-alive', + TE: 'Trailers', + }, + tags: { name: baseUrl + '/api/authenticate' }, + }, + }, + ]; + res = http.batch(req); + for (var i = 0; i < req.length; i++) { + total_waiting_time += res[i].timings.waiting; + } + let authToken = JSON.parse(res[0].body).id_token; + + // The user requests it own information of the account + req = [ + { + method: 'get', + url: baseUrl + '/api/account', + params: { + cookies: { + 'XSRF-TOKEN': defaultXSRFToken, + }, + headers: { + Host: host, + 'User-Agent': userAgent, + Accept: 'application/json, text/plain, */*', + 'Accept-Language': acceptLanguage, + 'Accept-Encoding': acceptEncoding, + Referer: baseUrl + '/', + Authorization: 'Bearer ' + authToken, + Connection: 'keep-alive', + TE: 'Trailers', + }, + tags: { name: baseUrl + '/api/account' }, + }, + }, + ]; + + res = http.batch(req); + for (var i = 0; i < req.length; i++) { + total_waiting_time += res[i].timings.waiting; } - function subscribeCourse(courseId, role) { - socket.send("SUBSCRIBE\nid:sub-" + getSubscriptionId() + "\ndestination:/topic/course/" + courseId + "/" + role +"\n\n\u0000"); + // A new XSRF Token is needed now, we have to extract it from the cookies + let xsrftoken = res[0].headers['Set-Cookie'].match('XSRF-TOKEN=(.*); path=/(; secure)?')[1]; + + // Extract user as we need it for some websocket information + let user = JSON.parse(res[0].body); + + // Some more calls (dashboard, notification, courses to register) are made + req = [ + { + method: 'get', + url: baseUrl + '/api/courses/for-dashboard', + params: { + cookies: { + 'XSRF-TOKEN': xsrftoken, + }, + headers: { + Host: host, + 'User-Agent': userAgent, + Accept: 'application/json, text/plain, */*', + 'Accept-Language': acceptLanguage, + 'Accept-Encoding': acceptEncoding, + Referer: baseUrl + '/', + Authorization: 'Bearer ' + authToken, + Connection: 'keep-alive', + TE: 'Trailers', + }, + tags: { name: baseUrl + '/api/courses/for-dashboard' }, + }, + }, + { + method: 'get', + url: baseUrl + '/api/notifications/for-user', + params: { + cookies: { + 'XSRF-TOKEN': xsrftoken, + }, + headers: { + Host: host, + 'User-Agent': userAgent, + Accept: 'application/json, text/plain, */*', + 'Accept-Language': acceptLanguage, + 'Accept-Encoding': acceptEncoding, + Referer: baseUrl + '/', + Authorization: 'Bearer ' + authToken, + Connection: 'keep-alive', + TE: 'Trailers', + }, + tags: { name: baseUrl + '/api/notifications/for-user' }, + }, + }, + ]; + res = http.batch(req); + for (var i = 0; i < req.length; i++) { + total_waiting_time += res[i].timings.waiting; } + rest_call_metrics.add(total_waiting_time); - socket.setInterval(function timeout() { - socket.ping(); - // console.log("Pinging every 10sec (setInterval test)"); - }, 10000); + let courses = JSON.parse(res[1].body); - // Send destination and subscription after 1 second - socket.setTimeout(function() { - socket.send("SEND\ndestination:/topic/activity\ncontent-length:20\n\n{\"page\":\"/overview\"}\u0000"); + // Initiate websocket connection if connection time is set to value greater than 0 + if (websocketConnectionTime > 0) { + let websocketEndpoint = websocketProtocol + '://' + host + '/websocket/tracker/websocket'; + let websocketUrl = websocketEndpoint + '?access_token=' + authToken; - courses.forEach(function(course) { - if (user.groups.includes(course.studentGroupName)) { - subscribeCourse(course.id, "STUDENT"); - } - if (user.groups.includes(course.teachingAssistantGroupName)) { - subscribeCourse(course.id, "TA"); - } - if (user.groups.includes(course.instructorGroupName)) { - subscribeCourse(course.id, "INSTRUCTOR"); - } + var response = ws.connect(websocketUrl, { tags: { name: websocketEndpoint } }, function (socket) { + socket.on('open', function open() { + socket.send('CONNECT\nX-XSRF-TOKEN:' + xsrftoken + '\naccept-version:1.1,1.0\nheart-beat:10000,10000\n\n\u0000'); + }); - // Subscribe for system and user notifications - socket.send("SUBSCRIBE\nid:sub-" + getSubscriptionId() + "\ndestination:/topic/system-notification\n\n\u0000"); - socket.send("SUBSCRIBE\nid:sub-" + getSubscriptionId() + "\ndestination:/topic/user/" + user.id + "/notifications\n\n\u0000"); - }); - }, 1 * 1000); + function getSubscriptionId() { + return Math.random() + .toString(36) + .replace(/[^a-z]+/g, '') + .substr(0, 12); + } - socket.setTimeout(function() { - socket.close(); - }, websocketConnectionTime * 1000); - }); - } - }); + function subscribeCourse(courseId, role) { + socket.send('SUBSCRIBE\nid:sub-' + getSubscriptionId() + '\ndestination:/topic/course/' + courseId + '/' + role + '\n\n\u0000'); + } + socket.setInterval(function timeout() { + socket.ping(); + // console.log("Pinging every 10sec (setInterval test)"); + }, 10000); + + // Send destination and subscription after 1 second + socket.setTimeout(function () { + socket.send('SEND\ndestination:/topic/activity\ncontent-length:20\n\n{"page":"/overview"}\u0000'); + + courses.forEach(function (course) { + if (user.groups.includes(course.studentGroupName)) { + subscribeCourse(course.id, 'STUDENT'); + } + if (user.groups.includes(course.teachingAssistantGroupName)) { + subscribeCourse(course.id, 'TA'); + } + if (user.groups.includes(course.instructorGroupName)) { + subscribeCourse(course.id, 'INSTRUCTOR'); + } + + // Subscribe for system and user notifications + socket.send('SUBSCRIBE\nid:sub-' + getSubscriptionId() + '\ndestination:/topic/system-notification\n\n\u0000'); + socket.send('SUBSCRIBE\nid:sub-' + getSubscriptionId() + '\ndestination:/topic/user/' + user.id + '/notifications\n\n\u0000'); + }); + }, 1 * 1000); + + socket.setTimeout(function () { + socket.close(); + }, websocketConnectionTime * 1000); + }); + } + }); } diff --git a/src/test/k6/ArtemisLoginNoJS.js b/src/test/k6/ArtemisLoginNoJS.js index d1a00c4382ab..5ad015870a8c 100644 --- a/src/test/k6/ArtemisLoginNoJS.js +++ b/src/test/k6/ArtemisLoginNoJS.js @@ -9,310 +9,323 @@ import ws from 'k6/ws'; export let options = { maxRedirects: 0, ext: { - "loadimpact": { - "distribution": { - "load_zone0": { - "loadZone": "amazon:de:frankfurt", - "percent": 100 - } - } - } + loadimpact: { + distribution: { + load_zone0: { + loadZone: 'amazon:de:frankfurt', + percent: 100, + }, + }, + }, }, stages: [ { - "duration": "5s", - "target": 30 + duration: '5s', + target: 30, }, { - "duration": "5s", - "target": 50 + duration: '5s', + target: 50, }, { - "duration": "5s", - "target": 80 + duration: '5s', + target: 80, }, { - "duration": "300s", - "target": 100 - } + duration: '300s', + target: 100, + }, ], - vus: 100 + vus: 100, }; -export default function() { - let defaultXSRFToken = "42d141b5-9e1c-4390-ae06-5143753b4459"; - let protocol = "https"; // https or http - let websocketProtocol = "wss"; // wss if https is used; ws if http is used - let host = "artemis.ase.in.tum.de"; // host including port if differing from 80 (http) or 443 (https) - let baseUrl = protocol + "://" + host; - - let maxTestUser = 100; // the userId will be an integer between 1 and this number +export default function () { + let defaultXSRFToken = '42d141b5-9e1c-4390-ae06-5143753b4459'; + let protocol = 'https'; // https or http + let websocketProtocol = 'wss'; // wss if https is used; ws if http is used + let host = 'artemis.ase.in.tum.de'; // host including port if differing from 80 (http) or 443 (https) + let baseUrl = protocol + '://' + host; - let delayBeforeLogin = 1; // Time in seconds the simulated user needs to enter username/password - let websocketConnectionTime = 300; // Time in seconds the websocket is kept open, if set to 0 no websocket connection is estahblished + let maxTestUser = 100; // the userId will be an integer between 1 and this number - let userAgent = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:66.0) Gecko/20100101 Firefox/66.0"; - let acceptLanguage = "en-CA,en-US;q=0.7,en;q=0.3"; - let acceptEncoding = "gzip, deflate, br"; + let delayBeforeLogin = 1; // Time in seconds the simulated user needs to enter username/password + let websocketConnectionTime = 300; // Time in seconds the websocket is kept open, if set to 0 no websocket connection is estahblished - let username = __ENV.BASE_USERNAME; // USERID gets replaced with a random number between 1 and maxTestUser - let password = "__ENV.BASE_PASSWORD"; // USERID gets replaced with a random number between 1 and maxTestUser + let userAgent = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:66.0) Gecko/20100101 Firefox/66.0'; + let acceptLanguage = 'en-CA,en-US;q=0.7,en;q=0.3'; + let acceptEncoding = 'gzip, deflate, br'; - group("Artemis Login", function() { - let req, res; + let username = __ENV.BASE_USERNAME; // USERID gets replaced with a random number between 1 and maxTestUser + let password = '__ENV.BASE_PASSWORD'; // USERID gets replaced with a random number between 1 and maxTestUser - // The website is loaded initialy - req = [{ - "method": "get", - "url": baseUrl + "/#/", - "params": { - "headers": { - "Host": host, - "User-Agent": userAgent, - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", - "Accept-Language": acceptLanguage, - "Accept-Encoding": acceptEncoding, - "Connection": "keep-alive", - "Upgrade-Insecure-Requests": "1", - "Pragma": "no-cache", - "Cache-Control": "no-cache" - }, - "tags": {"name": baseUrl + "/#/"} - } - } - ]; - res = http.batch(req); + group('Artemis Login', function () { + let req, res; - // The favicon, the translations, some management information and the TUM logo is downloaded next - req = [{ - "method": "get", - "url": baseUrl + "/i18n/en.json?buildTimestamp=1556135702468", - "params": { - "cookies": { - "XSRF-TOKEN": defaultXSRFToken - }, - "headers": { - "Host": host, - "User-Agent": userAgent, - "Accept": "application/json, text/plain, */*", - "Accept-Language": acceptLanguage, - "Accept-Encoding": acceptEncoding, - "Referer": baseUrl + "/", - "Connection": "keep-alive", - "Pragma": "no-cache", - "Cache-Control": "no-cache", - "TE": "Trailers" - }, - "tags": {"name": baseUrl + "/i18n"} - } - },{ - "method": "get", - "url": baseUrl + "/management/info", - "params": { - "cookies": { - "XSRF-TOKEN": defaultXSRFToken - }, - "headers": { - "Host": host, - "User-Agent": userAgent, - "Accept": "application/json, text/plain, */*", - "Accept-Language": acceptLanguage, - "Accept-Encoding": acceptEncoding, - "Referer": baseUrl + "/", - "Connection": "keep-alive", - "Pragma": "no-cache", - "Cache-Control": "no-cache", - "TE": "Trailers" - }, - "tags": {"name": baseUrl + "/management/info"} - } - },{ - "method": "get", - "url": baseUrl + "/api/account", - "params": { - "cookies": { - "XSRF-TOKEN": defaultXSRFToken - }, - "headers": { - "Host": host, - "User-Agent": userAgent, - "Accept": "application/json, text/plain, */*", - "Accept-Language": acceptLanguage, - "Accept-Encoding": acceptEncoding, - "Referer": baseUrl + "/", - "Connection": "keep-alive", - "Pragma": "no-cache", - "Cache-Control": "no-cache", - "TE": "Trailers" - }, - "tags": {"name": baseUrl + "/api/account"} - } - }]; - res = http.batch(req); + // The website is loaded initialy + req = [ + { + method: 'get', + url: baseUrl + '/#/', + params: { + headers: { + Host: host, + 'User-Agent': userAgent, + Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', + 'Accept-Language': acceptLanguage, + 'Accept-Encoding': acceptEncoding, + Connection: 'keep-alive', + 'Upgrade-Insecure-Requests': '1', + Pragma: 'no-cache', + 'Cache-Control': 'no-cache', + }, + tags: { name: baseUrl + '/#/' }, + }, + }, + ]; + res = http.batch(req); + // The favicon, the translations, some management information and the TUM logo is downloaded next + req = [ + { + method: 'get', + url: baseUrl + '/i18n/en.json?buildTimestamp=1556135702468', + params: { + cookies: { + 'XSRF-TOKEN': defaultXSRFToken, + }, + headers: { + Host: host, + 'User-Agent': userAgent, + Accept: 'application/json, text/plain, */*', + 'Accept-Language': acceptLanguage, + 'Accept-Encoding': acceptEncoding, + Referer: baseUrl + '/', + Connection: 'keep-alive', + Pragma: 'no-cache', + 'Cache-Control': 'no-cache', + TE: 'Trailers', + }, + tags: { name: baseUrl + '/i18n' }, + }, + }, + { + method: 'get', + url: baseUrl + '/management/info', + params: { + cookies: { + 'XSRF-TOKEN': defaultXSRFToken, + }, + headers: { + Host: host, + 'User-Agent': userAgent, + Accept: 'application/json, text/plain, */*', + 'Accept-Language': acceptLanguage, + 'Accept-Encoding': acceptEncoding, + Referer: baseUrl + '/', + Connection: 'keep-alive', + Pragma: 'no-cache', + 'Cache-Control': 'no-cache', + TE: 'Trailers', + }, + tags: { name: baseUrl + '/management/info' }, + }, + }, + { + method: 'get', + url: baseUrl + '/api/account', + params: { + cookies: { + 'XSRF-TOKEN': defaultXSRFToken, + }, + headers: { + Host: host, + 'User-Agent': userAgent, + Accept: 'application/json, text/plain, */*', + 'Accept-Language': acceptLanguage, + 'Accept-Encoding': acceptEncoding, + Referer: baseUrl + '/', + Connection: 'keep-alive', + Pragma: 'no-cache', + 'Cache-Control': 'no-cache', + TE: 'Trailers', + }, + tags: { name: baseUrl + '/api/account' }, + }, + }, + ]; + res = http.batch(req); - // Now the user should type his login credentials, therefor we wait some time - sleep(delayBeforeLogin); + // Now the user should type his login credentials, therefor we wait some time + sleep(delayBeforeLogin); - // The user is randomly selected - let userId = Math.floor((Math.random() * maxTestUser)) + 1; - let currentUsername = username.replace("USERID", userId); - let currentPassword = password.replace("USERID", userId); + // The user is randomly selected + let userId = Math.floor(Math.random() * maxTestUser) + 1; + let currentUsername = username.replace('USERID', userId); + let currentPassword = password.replace('USERID', userId); - // The user logs in; the authToken gets saved as we need it later - req = [{ - "method": "post", - "url": baseUrl + "/api/authenticate", - "body": "{\"username\":\"" + currentUsername + "\",\"password\":\"" + currentPassword +"\",\"rememberMe\":true}", - "params": { - "cookies": { - "XSRF-TOKEN": defaultXSRFToken - }, - "headers": { - "Host": host, - "User-Agent": userAgent, - "Accept": "application/json, text/plain, */*", - "Accept-Language": acceptLanguage, - "Accept-Encoding": acceptEncoding, - "Referer": baseUrl + "/", - "X-XSRF-TOKEN": defaultXSRFToken, - "Content-Type": "application/json", - "Content-Length": "74", - "Connection": "keep-alive", - "TE": "Trailers" - }, - "tags": {"name": baseUrl + "/api/authenticate"} - } - }]; - res = http.batch(req); - let authToken = JSON.parse(res[0].body).id_token; + // The user logs in; the authToken gets saved as we need it later + req = [ + { + method: 'post', + url: baseUrl + '/api/authenticate', + body: '{"username":"' + currentUsername + '","password":"' + currentPassword + '","rememberMe":true}', + params: { + cookies: { + 'XSRF-TOKEN': defaultXSRFToken, + }, + headers: { + Host: host, + 'User-Agent': userAgent, + Accept: 'application/json, text/plain, */*', + 'Accept-Language': acceptLanguage, + 'Accept-Encoding': acceptEncoding, + Referer: baseUrl + '/', + 'X-XSRF-TOKEN': defaultXSRFToken, + 'Content-Type': 'application/json', + 'Content-Length': '74', + Connection: 'keep-alive', + TE: 'Trailers', + }, + tags: { name: baseUrl + '/api/authenticate' }, + }, + }, + ]; + res = http.batch(req); + let authToken = JSON.parse(res[0].body).id_token; - // The user requests it own information of the account - req = [{ - "method": "get", - "url": baseUrl + "/api/account", - "params": { - "cookies": { - "XSRF-TOKEN": defaultXSRFToken - }, - "headers": { - "Host": host, - "User-Agent": userAgent, - "Accept": "application/json, text/plain, */*", - "Accept-Language": acceptLanguage, - "Accept-Encoding": acceptEncoding, - "Referer": baseUrl + "/", - "Authorization": "Bearer " + authToken, - "Connection": "keep-alive", - "TE": "Trailers" - }, - "tags": {"name": baseUrl + "/api/account"} - } - }]; + // The user requests it own information of the account + req = [ + { + method: 'get', + url: baseUrl + '/api/account', + params: { + cookies: { + 'XSRF-TOKEN': defaultXSRFToken, + }, + headers: { + Host: host, + 'User-Agent': userAgent, + Accept: 'application/json, text/plain, */*', + 'Accept-Language': acceptLanguage, + 'Accept-Encoding': acceptEncoding, + Referer: baseUrl + '/', + Authorization: 'Bearer ' + authToken, + Connection: 'keep-alive', + TE: 'Trailers', + }, + tags: { name: baseUrl + '/api/account' }, + }, + }, + ]; - res = http.batch(req); + res = http.batch(req); - // A new XSRF Token is needed now, we have to extract it from the cookies - let xsrftoken = res[0].headers["Set-Cookie"].match('XSRF-TOKEN=(.*); path=\/(; secure)?')[1]; + // A new XSRF Token is needed now, we have to extract it from the cookies + let xsrftoken = res[0].headers['Set-Cookie'].match('XSRF-TOKEN=(.*); path=/(; secure)?')[1]; - // Extract user as we need it for some websocket information - let user = JSON.parse(res[0].body); + // Extract user as we need it for some websocket information + let user = JSON.parse(res[0].body); - // Some more calls (dashboard, notification, courses to register) are made - req = [{ - "method": "get", - "url": baseUrl + "/api/courses/for-dashboard", - "params": { - "cookies": { - "XSRF-TOKEN": xsrftoken - }, - "headers": { - "Host": host, - "User-Agent": userAgent, - "Accept": "application/json, text/plain, */*", - "Accept-Language": acceptLanguage, - "Accept-Encoding": acceptEncoding, - "Referer": baseUrl + "/", - "Authorization": "Bearer " + authToken, - "Connection": "keep-alive", - "TE": "Trailers" - }, - "tags": {"name": baseUrl + "/api/courses/for-dashboard"} - } - },{ - "method": "get", - "url": baseUrl + "/api/notifications/for-user", - "params": { - "cookies": { - "XSRF-TOKEN": xsrftoken - }, - "headers": { - "Host": host, - "User-Agent": userAgent, - "Accept": "application/json, text/plain, */*", - "Accept-Language": acceptLanguage, - "Accept-Encoding": acceptEncoding, - "Referer": baseUrl + "/", - "Authorization": "Bearer " + authToken, - "Connection": "keep-alive", - "TE": "Trailers" - }, - "tags": {"name": baseUrl + "/api/notifications/for-user"} - } - }]; - res = http.batch(req); + // Some more calls (dashboard, notification, courses to register) are made + req = [ + { + method: 'get', + url: baseUrl + '/api/courses/for-dashboard', + params: { + cookies: { + 'XSRF-TOKEN': xsrftoken, + }, + headers: { + Host: host, + 'User-Agent': userAgent, + Accept: 'application/json, text/plain, */*', + 'Accept-Language': acceptLanguage, + 'Accept-Encoding': acceptEncoding, + Referer: baseUrl + '/', + Authorization: 'Bearer ' + authToken, + Connection: 'keep-alive', + TE: 'Trailers', + }, + tags: { name: baseUrl + '/api/courses/for-dashboard' }, + }, + }, + { + method: 'get', + url: baseUrl + '/api/notifications/for-user', + params: { + cookies: { + 'XSRF-TOKEN': xsrftoken, + }, + headers: { + Host: host, + 'User-Agent': userAgent, + Accept: 'application/json, text/plain, */*', + 'Accept-Language': acceptLanguage, + 'Accept-Encoding': acceptEncoding, + Referer: baseUrl + '/', + Authorization: 'Bearer ' + authToken, + Connection: 'keep-alive', + TE: 'Trailers', + }, + tags: { name: baseUrl + '/api/notifications/for-user' }, + }, + }, + ]; + res = http.batch(req); - let courses = JSON.parse(res[1].body); + let courses = JSON.parse(res[1].body); - // Initiate websocket connection if connection time is set to value greater than 0 - if (websocketConnectionTime > 0) { - let websocketEndpoint = websocketProtocol + "://" + host + "/websocket/tracker/websocket"; - let websocketUrl = websocketEndpoint + "?access_token=" + authToken; + // Initiate websocket connection if connection time is set to value greater than 0 + if (websocketConnectionTime > 0) { + let websocketEndpoint = websocketProtocol + '://' + host + '/websocket/tracker/websocket'; + let websocketUrl = websocketEndpoint + '?access_token=' + authToken; - var response = ws.connect(websocketUrl, {"tags": {"name": websocketEndpoint}}, function(socket) { - socket.on('open', function open() { - socket.send("CONNECT\nX-XSRF-TOKEN:" + xsrftoken + "\naccept-version:1.1,1.0\nheart-beat:10000,10000\n\n\u0000"); - }); + var response = ws.connect(websocketUrl, { tags: { name: websocketEndpoint } }, function (socket) { + socket.on('open', function open() { + socket.send('CONNECT\nX-XSRF-TOKEN:' + xsrftoken + '\naccept-version:1.1,1.0\nheart-beat:10000,10000\n\n\u0000'); + }); - function getSubscriptionId() { - return Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 12); - } - - function subscribeCourse(courseId, role) { - socket.send("SUBSCRIBE\nid:sub-" + getSubscriptionId() + "\ndestination:/topic/course/" + courseId + "/" + role +"\n\n\u0000"); - } + function getSubscriptionId() { + return Math.random() + .toString(36) + .replace(/[^a-z]+/g, '') + .substr(0, 12); + } - socket.setInterval(function timeout() { - socket.ping(); - // console.log("Pinging every 10sec (setInterval test)"); - }, 10000); + function subscribeCourse(courseId, role) { + socket.send('SUBSCRIBE\nid:sub-' + getSubscriptionId() + '\ndestination:/topic/course/' + courseId + '/' + role + '\n\n\u0000'); + } - // Send destination and subscription after 1 second - socket.setTimeout(function() { - socket.send("SEND\ndestination:/topic/activity\ncontent-length:20\n\n{\"page\":\"/overview\"}\u0000"); + socket.setInterval(function timeout() { + socket.ping(); + // console.log("Pinging every 10sec (setInterval test)"); + }, 10000); - courses.forEach(function(course) { - if (user.groups.includes(course.studentGroupName)) { - subscribeCourse(course.id, "STUDENT"); - } - if (user.groups.includes(course.teachingAssistantGroupName)) { - subscribeCourse(course.id, "TA"); - } - if (user.groups.includes(course.instructorGroupName)) { - subscribeCourse(course.id, "INSTRUCTOR"); - } + // Send destination and subscription after 1 second + socket.setTimeout(function () { + socket.send('SEND\ndestination:/topic/activity\ncontent-length:20\n\n{"page":"/overview"}\u0000'); - // Subscribe for system and user notifications - socket.send("SUBSCRIBE\nid:sub-" + getSubscriptionId() + "\ndestination:/topic/system-notification\n\n\u0000"); - socket.send("SUBSCRIBE\nid:sub-" + getSubscriptionId() + "\ndestination:/topic/user/" + user.id + "/notifications\n\n\u0000"); - }); - }, 1 * 1000); + courses.forEach(function (course) { + if (user.groups.includes(course.studentGroupName)) { + subscribeCourse(course.id, 'STUDENT'); + } + if (user.groups.includes(course.teachingAssistantGroupName)) { + subscribeCourse(course.id, 'TA'); + } + if (user.groups.includes(course.instructorGroupName)) { + subscribeCourse(course.id, 'INSTRUCTOR'); + } - socket.setTimeout(function() { - socket.close(); - }, websocketConnectionTime * 1000); - }); - } - }); + // Subscribe for system and user notifications + socket.send('SUBSCRIBE\nid:sub-' + getSubscriptionId() + '\ndestination:/topic/system-notification\n\n\u0000'); + socket.send('SUBSCRIBE\nid:sub-' + getSubscriptionId() + '\ndestination:/topic/user/' + user.id + '/notifications\n\n\u0000'); + }); + }, 1 * 1000); + socket.setTimeout(function () { + socket.close(); + }, websocketConnectionTime * 1000); + }); + } + }); } diff --git a/src/test/k6/ArtemisLoginOnlyWebsocket.js b/src/test/k6/ArtemisLoginOnlyWebsocket.js index c41ee27c93c3..72f5b4247795 100644 --- a/src/test/k6/ArtemisLoginOnlyWebsocket.js +++ b/src/test/k6/ArtemisLoginOnlyWebsocket.js @@ -9,153 +9,158 @@ import ws from 'k6/ws'; export let options = { maxRedirects: 0, ext: { - "loadimpact": { - "distribution": { - "load_zone0": { - "loadZone": "amazon:de:frankfurt", - "percent": 100 - } - } - } + loadimpact: { + distribution: { + load_zone0: { + loadZone: 'amazon:de:frankfurt', + percent: 100, + }, + }, + }, }, stages: [ { - "duration": "5s", - "target": 30 + duration: '5s', + target: 30, }, { - "duration": "5s", - "target": 50 + duration: '5s', + target: 50, }, { - "duration": "5s", - "target": 80 + duration: '5s', + target: 80, }, { - "duration": "300s", - "target": 100 - } + duration: '300s', + target: 100, + }, ], - vus: 100 + vus: 100, }; -export default function() { - let defaultXSRFToken = "42d141b5-9e1c-4390-ae06-5143753b4459"; - let protocol = "https"; // https or http - let websocketProtocol = "wss"; // wss if https is used; ws if http is used - let host = "artemis.ase.in.tum.de"; // host including port if differing from 80 (http) or 443 (https) - let baseUrl = protocol + "://" + host; - - let maxTestUser = 100; // the userId will be an integer between 1 and this number - - let delayBeforeLogin = 1; // Time in seconds the simulated user needs to enter username/password - let websocketConnectionTime = 300; // Time in seconds the websocket is kept open, if set to 0 no websocket connection is estahblished - - let userAgent = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:66.0) Gecko/20100101 Firefox/66.0"; - let acceptLanguage = "en-CA,en-US;q=0.7,en;q=0.3"; - let acceptEncoding = "gzip, deflate, br"; - - let username = __ENV.BASE_USERNAME; // USERID gets replaced with a random number between 1 and maxTestUser - let password = "__ENV.BASE_PASSWORD"; // USERID gets replaced with a random number between 1 and maxTestUser - - group("Artemis Login", function() { - let req, res; - - - // The user is randomly selected - let userId = Math.floor((Math.random() * maxTestUser)) + 1; - let currentUsername = username.replace("USERID", userId); - let currentPassword = password.replace("USERID", userId); - - // The user logs in; the authToken gets saved as we need it later - req = [{ - "method": "post", - "url": baseUrl + "/api/authenticate", - "body": "{\"username\":\"" + currentUsername + "\",\"password\":\"" + currentPassword +"\",\"rememberMe\":true}", - "params": { - "cookies": { - "XSRF-TOKEN": defaultXSRFToken - }, - "headers": { - "Host": host, - "User-Agent": userAgent, - "Accept": "application/json, text/plain, */*", - "Accept-Language": acceptLanguage, - "Accept-Encoding": acceptEncoding, - "Referer": baseUrl + "/", - "X-XSRF-TOKEN": defaultXSRFToken, - "Content-Type": "application/json", - "Content-Length": "74", - "Connection": "keep-alive", - "TE": "Trailers" - }, - "tags": {"name": baseUrl + "/api/authenticate"} - } - }]; - res = http.batch(req); - let authToken = JSON.parse(res[0].body).id_token; - - // The user requests it own information of the account - req = [{ - "method": "get", - "url": baseUrl + "/api/account", - "params": { - "cookies": { - "XSRF-TOKEN": defaultXSRFToken - }, - "headers": { - "Host": host, - "User-Agent": userAgent, - "Accept": "application/json, text/plain, */*", - "Accept-Language": acceptLanguage, - "Accept-Encoding": acceptEncoding, - "Referer": baseUrl + "/", - "Authorization": "Bearer " + authToken, - "Connection": "keep-alive", - "TE": "Trailers" - }, - "tags": {"name": baseUrl + "/api/account"} - } - }]; - - res = http.batch(req); - - // A new XSRF Token is needed now, we have to extract it from the cookies - let xsrftoken = res[0].headers["Set-Cookie"].match('XSRF-TOKEN=(.*); path=\/(; secure)?')[1]; - - // Initiate websocket connection if connection time is set to value greater than 0 - if (websocketConnectionTime > 0) { - let websocketEndpoint = websocketProtocol + "://" + host + "/websocket/tracker/websocket"; - let websocketUrl = websocketEndpoint + "?access_token=" + authToken; - - var response = ws.connect(websocketUrl, {"tags": {"name": websocketEndpoint}}, function(socket) { - socket.on('open', function open() { - socket.send("CONNECT\nX-XSRF-TOKEN:" + xsrftoken + "\naccept-version:1.1,1.0\nheart-beat:10000,10000\n\n\u0000"); - }); - - function getSubscriptionId() { - return Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 12); - } - - function subscribeCourse(courseId, role) { - socket.send("SUBSCRIBE\nid:sub-" + getSubscriptionId() + "\ndestination:/topic/course/" + courseId + "/" + role +"\n\n\u0000"); - } +export default function () { + let defaultXSRFToken = '42d141b5-9e1c-4390-ae06-5143753b4459'; + let protocol = 'https'; // https or http + let websocketProtocol = 'wss'; // wss if https is used; ws if http is used + let host = 'artemis.ase.in.tum.de'; // host including port if differing from 80 (http) or 443 (https) + let baseUrl = protocol + '://' + host; + + let maxTestUser = 100; // the userId will be an integer between 1 and this number + + let delayBeforeLogin = 1; // Time in seconds the simulated user needs to enter username/password + let websocketConnectionTime = 300; // Time in seconds the websocket is kept open, if set to 0 no websocket connection is estahblished + + let userAgent = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:66.0) Gecko/20100101 Firefox/66.0'; + let acceptLanguage = 'en-CA,en-US;q=0.7,en;q=0.3'; + let acceptEncoding = 'gzip, deflate, br'; + + let username = __ENV.BASE_USERNAME; // USERID gets replaced with a random number between 1 and maxTestUser + let password = '__ENV.BASE_PASSWORD'; // USERID gets replaced with a random number between 1 and maxTestUser + + group('Artemis Login', function () { + let req, res; + + // The user is randomly selected + let userId = Math.floor(Math.random() * maxTestUser) + 1; + let currentUsername = username.replace('USERID', userId); + let currentPassword = password.replace('USERID', userId); + + // The user logs in; the authToken gets saved as we need it later + req = [ + { + method: 'post', + url: baseUrl + '/api/authenticate', + body: '{"username":"' + currentUsername + '","password":"' + currentPassword + '","rememberMe":true}', + params: { + cookies: { + 'XSRF-TOKEN': defaultXSRFToken, + }, + headers: { + Host: host, + 'User-Agent': userAgent, + Accept: 'application/json, text/plain, */*', + 'Accept-Language': acceptLanguage, + 'Accept-Encoding': acceptEncoding, + Referer: baseUrl + '/', + 'X-XSRF-TOKEN': defaultXSRFToken, + 'Content-Type': 'application/json', + 'Content-Length': '74', + Connection: 'keep-alive', + TE: 'Trailers', + }, + tags: { name: baseUrl + '/api/authenticate' }, + }, + }, + ]; + res = http.batch(req); + let authToken = JSON.parse(res[0].body).id_token; + + // The user requests it own information of the account + req = [ + { + method: 'get', + url: baseUrl + '/api/account', + params: { + cookies: { + 'XSRF-TOKEN': defaultXSRFToken, + }, + headers: { + Host: host, + 'User-Agent': userAgent, + Accept: 'application/json, text/plain, */*', + 'Accept-Language': acceptLanguage, + 'Accept-Encoding': acceptEncoding, + Referer: baseUrl + '/', + Authorization: 'Bearer ' + authToken, + Connection: 'keep-alive', + TE: 'Trailers', + }, + tags: { name: baseUrl + '/api/account' }, + }, + }, + ]; + + res = http.batch(req); + + // A new XSRF Token is needed now, we have to extract it from the cookies + let xsrftoken = res[0].headers['Set-Cookie'].match('XSRF-TOKEN=(.*); path=/(; secure)?')[1]; + + // Initiate websocket connection if connection time is set to value greater than 0 + if (websocketConnectionTime > 0) { + let websocketEndpoint = websocketProtocol + '://' + host + '/websocket/tracker/websocket'; + let websocketUrl = websocketEndpoint + '?access_token=' + authToken; + + var response = ws.connect(websocketUrl, { tags: { name: websocketEndpoint } }, function (socket) { + socket.on('open', function open() { + socket.send('CONNECT\nX-XSRF-TOKEN:' + xsrftoken + '\naccept-version:1.1,1.0\nheart-beat:10000,10000\n\n\u0000'); + }); + + function getSubscriptionId() { + return Math.random() + .toString(36) + .replace(/[^a-z]+/g, '') + .substr(0, 12); + } - socket.setInterval(function timeout() { - socket.ping(); - // console.log("Pinging every 10sec (setInterval test)"); - }, 10000); + function subscribeCourse(courseId, role) { + socket.send('SUBSCRIBE\nid:sub-' + getSubscriptionId() + '\ndestination:/topic/course/' + courseId + '/' + role + '\n\n\u0000'); + } - // Send destination and subscription after 1 second - socket.setTimeout(function() { - socket.send("SEND\ndestination:/topic/activity\ncontent-length:20\n\n{\"page\":\"/overview\"}\u0000"); - }, 1 * 1000); + socket.setInterval(function timeout() { + socket.ping(); + // console.log("Pinging every 10sec (setInterval test)"); + }, 10000); - socket.setTimeout(function() { - socket.close(); - }, websocketConnectionTime * 1000); - }); - } - }); + // Send destination and subscription after 1 second + socket.setTimeout(function () { + socket.send('SEND\ndestination:/topic/activity\ncontent-length:20\n\n{"page":"/overview"}\u0000'); + }, 1 * 1000); + socket.setTimeout(function () { + socket.close(); + }, websocketConnectionTime * 1000); + }); + } + }); } diff --git a/src/test/k6/ArtemisOnlyDashboard.js b/src/test/k6/ArtemisOnlyDashboard.js index 27b4e2ebbeae..c770dd198421 100644 --- a/src/test/k6/ArtemisOnlyDashboard.js +++ b/src/test/k6/ArtemisOnlyDashboard.js @@ -1,28 +1,28 @@ import { group, sleep } from 'k6'; import http from 'k6/http'; import ws from 'k6/ws'; -import { Trend } from "k6/metrics"; +import { Trend } from 'k6/metrics'; // Version: 1.1 // Creator: Firefox // Browser: Firefox -var rest_call_metrics = new Trend("rest_call_metrics"); +var rest_call_metrics = new Trend('rest_call_metrics'); export let options = { maxRedirects: 0, ext: { - "loadimpact": { - "distribution": { - "load_zone0": { - "loadZone": "amazon:de:frankfurt", - "percent": 100 - } - } - } + loadimpact: { + distribution: { + load_zone0: { + loadZone: 'amazon:de:frankfurt', + percent: 100, + }, + }, + }, }, stages: [ - /*{ + /*{ "duration": "15s", "target": 10 }, @@ -58,133 +58,138 @@ export let options = { "duration": "15s", "target": 90 },*/ - { - "duration": "300s", - "target": 100 - } + { + duration: '300s', + target: 100, + }, ], - vus: 70 + vus: 70, }; -export default function() { - let defaultXSRFToken = "42d141b5-9e1c-4390-ae06-5143753b4459"; - let protocol = "http"; // https or http - let websocketProtocol = "ws"; // wss if https is used; ws if http is used - let host = "nginx:80"; // host including port if differing from 80 (http) or 443 (https) - let baseUrl = protocol + "://" + host; - - let maxTestUser = 100; // the userId will be an integer between 1 and this number - - let delayBeforeLogin = 1; // Time in seconds the simulated user needs to enter username/password - let websocketConnectionTime = 100; // Time in seconds the websocket is kept open, if set to 0 no websocket connection is estahblished - - let userAgent = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:66.0) Gecko/20100101 Firefox/66.0"; - let acceptLanguage = "en-CA,en-US;q=0.7,en;q=0.3"; - let acceptEncoding = "gzip, deflate, br"; - - let username = __ENV.BASE_USERNAME; // USERID gets replaced with a random number between 1 and maxTestUser - let password = "__ENV.BASE_PASSWORD"; // USERID gets replaced with a random number between 1 and maxTestUser - - group("Artemis Login", function() { - let req, res; - - // The user is randomly selected - let userId = Math.floor((Math.random() * maxTestUser)) + 1; - let currentUsername = username.replace("USERID", userId); - let currentPassword = password.replace("USERID", userId); - - // The user logs in; the authToken gets saved as we need it later - req = [{ - "method": "post", - "url": baseUrl + "/api/authenticate", - "body": "{\"username\":\"" + currentUsername + "\",\"password\":\"" + currentPassword +"\",\"rememberMe\":true}", - "params": { - "cookies": { - "XSRF-TOKEN": defaultXSRFToken - }, - "headers": { - "Host": host, - "User-Agent": userAgent, - "Accept": "application/json, text/plain, */*", - "Accept-Language": acceptLanguage, - "Accept-Encoding": acceptEncoding, - "Referer": baseUrl + "/", - "X-XSRF-TOKEN": defaultXSRFToken, - "Content-Type": "application/json", - "Content-Length": "74", - "Connection": "keep-alive", - "TE": "Trailers" - }, - "tags": {"name": baseUrl + "/api/authenticate"} - } - }]; - res = http.batch(req); - let authToken = JSON.parse(res[0].body).id_token; - - // The user requests it own information of the account - req = [{ - "method": "get", - "url": baseUrl + "/api/account", - "params": { - "cookies": { - "XSRF-TOKEN": defaultXSRFToken - }, - "headers": { - "Host": host, - "User-Agent": userAgent, - "Accept": "application/json, text/plain, */*", - "Accept-Language": acceptLanguage, - "Accept-Encoding": acceptEncoding, - "Referer": baseUrl + "/", - "Authorization": "Bearer " + authToken, - "Connection": "keep-alive", - "TE": "Trailers" - }, - "tags": {"name": baseUrl + "/api/account"} - } - }]; - - res = http.batch(req); - - // A new XSRF Token is needed now, we have to extract it from the cookies - let xsrftoken = res[0].headers["Set-Cookie"].match('XSRF-TOKEN=(.*); path=\/(; secure)?')[1]; - - // Extract user as we need it for some websocket information - let user = JSON.parse(res[0].body); - - // Some more calls (dashboard, notification, courses to register) are made - var i; - for (i = 0; i < 5; i++) { - req = [{ - "method": "get", - "url": baseUrl + "/api/courses/for-dashboard", - "params": { - "cookies": { - "XSRF-TOKEN": xsrftoken - }, - "headers": { - "Host": host, - "User-Agent": userAgent, - "Accept": "application/json, text/plain, */*", - "Accept-Language": acceptLanguage, - "Accept-Encoding": acceptEncoding, - "Referer": baseUrl + "/", - "Authorization": "Bearer " + authToken, - "Connection": "keep-alive", - "TE": "Trailers" - }, - "tags": {"name": baseUrl + "/api/courses/for-dashboard"} - } - }]; - res = http.batch(req); - rest_call_metrics.add(res[0].timings.waiting); - } - sleep(Math.random() * 30); - // sleep(5000); - }); - +export default function () { + let defaultXSRFToken = '42d141b5-9e1c-4390-ae06-5143753b4459'; + let protocol = 'http'; // https or http + let websocketProtocol = 'ws'; // wss if https is used; ws if http is used + let host = 'nginx:80'; // host including port if differing from 80 (http) or 443 (https) + let baseUrl = protocol + '://' + host; + + let maxTestUser = 100; // the userId will be an integer between 1 and this number + + let delayBeforeLogin = 1; // Time in seconds the simulated user needs to enter username/password + let websocketConnectionTime = 100; // Time in seconds the websocket is kept open, if set to 0 no websocket connection is estahblished + + let userAgent = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:66.0) Gecko/20100101 Firefox/66.0'; + let acceptLanguage = 'en-CA,en-US;q=0.7,en;q=0.3'; + let acceptEncoding = 'gzip, deflate, br'; + + let username = __ENV.BASE_USERNAME; // USERID gets replaced with a random number between 1 and maxTestUser + let password = '__ENV.BASE_PASSWORD'; // USERID gets replaced with a random number between 1 and maxTestUser + + group('Artemis Login', function () { + let req, res; + + // The user is randomly selected + let userId = Math.floor(Math.random() * maxTestUser) + 1; + let currentUsername = username.replace('USERID', userId); + let currentPassword = password.replace('USERID', userId); + + // The user logs in; the authToken gets saved as we need it later + req = [ + { + method: 'post', + url: baseUrl + '/api/authenticate', + body: '{"username":"' + currentUsername + '","password":"' + currentPassword + '","rememberMe":true}', + params: { + cookies: { + 'XSRF-TOKEN': defaultXSRFToken, + }, + headers: { + Host: host, + 'User-Agent': userAgent, + Accept: 'application/json, text/plain, */*', + 'Accept-Language': acceptLanguage, + 'Accept-Encoding': acceptEncoding, + Referer: baseUrl + '/', + 'X-XSRF-TOKEN': defaultXSRFToken, + 'Content-Type': 'application/json', + 'Content-Length': '74', + Connection: 'keep-alive', + TE: 'Trailers', + }, + tags: { name: baseUrl + '/api/authenticate' }, + }, + }, + ]; + res = http.batch(req); + let authToken = JSON.parse(res[0].body).id_token; + + // The user requests it own information of the account + req = [ + { + method: 'get', + url: baseUrl + '/api/account', + params: { + cookies: { + 'XSRF-TOKEN': defaultXSRFToken, + }, + headers: { + Host: host, + 'User-Agent': userAgent, + Accept: 'application/json, text/plain, */*', + 'Accept-Language': acceptLanguage, + 'Accept-Encoding': acceptEncoding, + Referer: baseUrl + '/', + Authorization: 'Bearer ' + authToken, + Connection: 'keep-alive', + TE: 'Trailers', + }, + tags: { name: baseUrl + '/api/account' }, + }, + }, + ]; + + res = http.batch(req); + + // A new XSRF Token is needed now, we have to extract it from the cookies + let xsrftoken = res[0].headers['Set-Cookie'].match('XSRF-TOKEN=(.*); path=/(; secure)?')[1]; + + // Extract user as we need it for some websocket information + let user = JSON.parse(res[0].body); + + // Some more calls (dashboard, notification, courses to register) are made + var i; + for (i = 0; i < 5; i++) { + req = [ + { + method: 'get', + url: baseUrl + '/api/courses/for-dashboard', + params: { + cookies: { + 'XSRF-TOKEN': xsrftoken, + }, + headers: { + Host: host, + 'User-Agent': userAgent, + Accept: 'application/json, text/plain, */*', + 'Accept-Language': acceptLanguage, + 'Accept-Encoding': acceptEncoding, + Referer: baseUrl + '/', + Authorization: 'Bearer ' + authToken, + Connection: 'keep-alive', + TE: 'Trailers', + }, + tags: { name: baseUrl + '/api/courses/for-dashboard' }, + }, + }, + ]; + res = http.batch(req); + rest_call_metrics.add(res[0].timings.waiting); + } + sleep(Math.random() * 30); + // sleep(5000); + }); } export function teardown() { - console.log(rest_call_metrics.avg); + console.log(rest_call_metrics.avg); } diff --git a/src/test/k6/CodeEditor.js b/src/test/k6/CodeEditor.js index fcb15ecac6fa..236474d15f57 100644 --- a/src/test/k6/CodeEditor.js +++ b/src/test/k6/CodeEditor.js @@ -1,14 +1,7 @@ import { login } from './requests/requests.js'; import { group, sleep } from 'k6'; import { deleteCourse, newCourse } from './requests/course.js'; -import { - startExercise, - createExercise, - deleteExercise, - ParticipationSimulation, - simulateSubmission, - TestResult -} from './requests/programmingExercise.js'; +import { startExercise, createExercise, deleteExercise, ParticipationSimulation, simulateSubmission, TestResult } from './requests/programmingExercise.js'; import { buildErrorContent } from './resource/constants.js'; // Version: 1.1 @@ -19,7 +12,7 @@ export let options = { maxRedirects: 0, iterations: __ENV.ITERATIONS, vus: __ENV.ITERATIONS, - rps: 5 + rps: 5, }; const adminUsername = __ENV.ADMIN_USERNAME; @@ -44,14 +37,14 @@ export function setup() { return { exerciseId: exerciseId, courseId: courseId }; } -export default function(data) { +export default function (data) { const websocketConnectionTime = parseFloat(__ENV.TIMEOUT_PARTICIPATION); // Time in seconds the websocket is kept open, if set to 0 no websocket connection is estahblished // Delay so that not all users start at the same time, batches of 3 users per second const delay = Math.floor(__VU / 3); sleep(delay); - group('Artemis Programming Exercise Participation Loadtest', function() { + group('Artemis Programming Exercise Participation Loadtest', function () { // The user is randomly selected const userId = __VU; // Math.floor((Math.random() * maxTestUser)) + 1; const currentUsername = baseUsername.replace('USERID', userId); @@ -71,7 +64,7 @@ export default function(data) { } }); - return data; + return data; } export function teardown(data) { diff --git a/src/test/k6/ProgrammingExerciseAPIs.js b/src/test/k6/ProgrammingExerciseAPIs.js index d4efd910e1cc..d9f13eb0720a 100644 --- a/src/test/k6/ProgrammingExerciseAPIs.js +++ b/src/test/k6/ProgrammingExerciseAPIs.js @@ -1,11 +1,11 @@ import { group, sleep } from 'k6'; -import { login } from "./requests/requests.js"; -import { createProgrammingExercise, startExercise, simulateSubmission, ParticipationSimulation, TestResult, deleteProgrammingExercise } from "./requests/programmingExercise.js"; -import { deleteCourse, newCourse, addUserToStudentsInCourse, addUserToInstructorsInCourse } from "./requests/course.js"; +import { login } from './requests/requests.js'; +import { createProgrammingExercise, startExercise, simulateSubmission, ParticipationSimulation, TestResult, deleteProgrammingExercise } from './requests/programmingExercise.js'; +import { deleteCourse, newCourse, addUserToStudentsInCourse, addUserToInstructorsInCourse } from './requests/course.js'; import { newUser, getUser, updateUser, createUsersIfNeeded } from './requests/user.js'; -import {allSuccessfulContentJava, buildErrorContentJava, someSuccessfulErrorContentJava} from "./resource/constants_java.js"; -import {allSuccessfulContentPython, buildErrorContentPython, someSuccessfulErrorContentPython} from "./resource/constants_python.js"; -import {allSuccessfulContentC, buildErrorContentC, someSuccessfulErrorContentC} from "./resource/constants_c.js"; +import { allSuccessfulContentJava, buildErrorContentJava, someSuccessfulErrorContentJava } from './resource/constants_java.js'; +import { allSuccessfulContentPython, buildErrorContentPython, someSuccessfulErrorContentPython } from './resource/constants_python.js'; +import { allSuccessfulContentC, buildErrorContentC, someSuccessfulErrorContentC } from './resource/constants_c.js'; export const options = { maxRedirects: 0, @@ -13,21 +13,20 @@ export const options = { vus: __ENV.ITERATIONS, rps: 4, setupTimeout: '240s', - teardownTimeout: '240s' + teardownTimeout: '240s', }; const adminUsername = __ENV.ADMIN_USERNAME; const adminPassword = __ENV.ADMIN_PASSWORD; let baseUsername = __ENV.BASE_USERNAME; let basePassword = __ENV.BASE_PASSWORD; -let programmingLanguage= __ENV.PROGRAMMING_LANGUAGE; +let programmingLanguage = __ENV.PROGRAMMING_LANGUAGE; export function setup() { - - console.log("__ENV.CREATE_USERS: " + __ENV.CREATE_USERS); - console.log("__ENV.TIMEOUT_PARTICIPATION: " + __ENV.TIMEOUT_PARTICIPATION); - console.log("__ENV.TIMEOUT_EXERCISE: " + __ENV.TIMEOUT_EXERCISE); - console.log("__ENV.ITERATIONS: " + __ENV.ITERATIONS); + console.log('__ENV.CREATE_USERS: ' + __ENV.CREATE_USERS); + console.log('__ENV.TIMEOUT_PARTICIPATION: ' + __ENV.TIMEOUT_PARTICIPATION); + console.log('__ENV.TIMEOUT_EXERCISE: ' + __ENV.TIMEOUT_EXERCISE); + console.log('__ENV.ITERATIONS: ' + __ENV.ITERATIONS); let artemis, exerciseId, course, userId; @@ -47,7 +46,7 @@ export function setup() { // it might be necessary that the newly created groups or accounts are synced with the version control and continuous integration servers, so we wait for 1 minute const timeoutExercise = parseFloat(__ENV.TIMEOUT_EXERCISE); if (timeoutExercise > 0) { - console.log("Wait " + timeoutExercise + "s before creating the programming exercise so that the setup can finish properly"); + console.log('Wait ' + timeoutExercise + 's before creating the programming exercise so that the setup can finish properly'); sleep(timeoutExercise); } @@ -76,7 +75,7 @@ export default function (data) { sleep(delay * 3); let someSuccessfulErrorContent, allSuccessfulContent, buildErrorContent, somePassedString; - switch(programmingLanguage) { + switch (programmingLanguage) { case 'JAVA': someSuccessfulErrorContent = someSuccessfulErrorContentJava; allSuccessfulContent = allSuccessfulContentJava; @@ -97,7 +96,7 @@ export default function (data) { break; } - group('Participate in Programming Exercise', function() { + group('Participate in Programming Exercise', function () { let participationId = startExercise(artemis, courseId, exerciseId); if (participationId) { // partial success, then 100%, then build error -- wait some time between submissions in order to the build server time for the result @@ -106,8 +105,9 @@ export default function (data) { simulation = new ParticipationSimulation(timeoutParticipation, exerciseId, participationId, allSuccessfulContent); simulateSubmission(artemis, simulation, TestResult.SUCCESS); simulation = new ParticipationSimulation(timeoutParticipation, exerciseId, participationId, buildErrorContent); - if (programmingLanguage === 'C') { // C builds do never fail - they will only show 0/20 passed - simulateSubmission(artemis, simulation, TestResult.FAIL, "0 of 20 passed"); + if (programmingLanguage === 'C') { + // C builds do never fail - they will only show 0/20 passed + simulateSubmission(artemis, simulation, TestResult.FAIL, '0 of 20 passed'); } else { simulateSubmission(artemis, simulation, TestResult.BUILD_ERROR); } @@ -121,7 +121,6 @@ export default function (data) { } export function teardown(data) { - const shouldCleanup = __ENV.CLEANUP === true || __ENV.CLEANUP === 'true'; if (shouldCleanup) { const artemis = login(adminUsername, adminPassword); diff --git a/src/test/k6/QuizExerciseAPIs.js b/src/test/k6/QuizExerciseAPIs.js index 4269a14c5de8..0720387b32c4 100644 --- a/src/test/k6/QuizExerciseAPIs.js +++ b/src/test/k6/QuizExerciseAPIs.js @@ -1,9 +1,9 @@ import { login } from './requests/requests.js'; import { group, sleep } from 'k6'; -import { getQuizQuestions, simulateQuizWork } from "./requests/quiz.js"; -import {newCourse, deleteCourse} from "./requests/course.js"; -import {createUsersIfNeeded} from "./requests/user.js"; -import {createQuizExercise, deleteQuizExercise} from "./requests/quiz.js"; +import { getQuizQuestions, simulateQuizWork } from './requests/quiz.js'; +import { newCourse, deleteCourse } from './requests/course.js'; +import { createUsersIfNeeded } from './requests/user.js'; +import { createQuizExercise, deleteQuizExercise } from './requests/quiz.js'; // Version: 1.1 // Creator: Firefox @@ -15,7 +15,7 @@ export let options = { vus: __ENV.ITERATIONS, rps: 5, setupTimeout: '240s', - teardownTimeout: '240s' + teardownTimeout: '240s', }; const adminUsername = __ENV.ADMIN_USERNAME; @@ -24,11 +24,10 @@ let baseUsername = __ENV.BASE_USERNAME; let basePassword = __ENV.BASE_PASSWORD; export function setup() { - - console.log("__ENV.CREATE_USERS: " + __ENV.CREATE_USERS); - console.log("__ENV.TIMEOUT_PARTICIPATION: " + __ENV.TIMEOUT_PARTICIPATION); - console.log("__ENV.TIMEOUT_EXERCISE: " + __ENV.TIMEOUT_EXERCISE); - console.log("__ENV.ITERATIONS: " + __ENV.ITERATIONS); + console.log('__ENV.CREATE_USERS: ' + __ENV.CREATE_USERS); + console.log('__ENV.TIMEOUT_PARTICIPATION: ' + __ENV.TIMEOUT_PARTICIPATION); + console.log('__ENV.TIMEOUT_EXERCISE: ' + __ENV.TIMEOUT_EXERCISE); + console.log('__ENV.ITERATIONS: ' + __ENV.ITERATIONS); let artemis, exerciseId, course, userId; @@ -48,7 +47,7 @@ export function setup() { // it might be necessary that the newly created groups or accounts are synced with the version control and continuous integration servers, so we wait for 1 minute const timeoutExercise = parseFloat(__ENV.TIMEOUT_EXERCISE); if (timeoutExercise > 0) { - console.log("Wait " + timeoutExercise + "s before creating the programming exercise so that the setup can finish properly"); + console.log('Wait ' + timeoutExercise + 's before creating the programming exercise so that the setup can finish properly'); sleep(timeoutExercise); } @@ -60,14 +59,14 @@ export function setup() { return { exerciseId: exerciseId, courseId: course.id }; } -export default function(data) { +export default function (data) { const websocketConnectionTime = parseFloat(__ENV.TIMEOUT_PARTICIPATION); // Time in seconds the websocket is kept open, if set to 0 no websocket connection is estahblished // Delay so that not all users start at the same time, batches of 50 users per second const delay = Math.floor(__VU / 50); sleep(delay); - group('Artemis Programming Exercise Participation Websocket Stresstest', function() { + group('Artemis Programming Exercise Participation Websocket Stresstest', function () { const userId = __VU; const currentUsername = baseUsername.replace('USERID', userId); const currentPassword = basePassword.replace('USERID', userId); @@ -85,7 +84,6 @@ export default function(data) { } export function teardown(data) { - const shouldCleanup = __ENV.CLEANUP === true || __ENV.CLEANUP === 'true'; if (shouldCleanup) { const artemis = login(adminUsername, adminPassword); diff --git a/src/test/k6/requests/course.js b/src/test/k6/requests/course.js index 8e2c3bfa3eac..0f6fa1687d53 100644 --- a/src/test/k6/requests/course.js +++ b/src/test/k6/requests/course.js @@ -20,7 +20,7 @@ export function newCourse(artemis) { const res = artemis.post(COURSES, course); if (res[0].status !== 201) { - console.log("ERROR when creating a new course. Response headers:"); + console.log('ERROR when creating a new course. Response headers:'); for (let [key, value] of Object.entries(res[0].headers)) { console.log(`${key}: ${value}`); } @@ -33,22 +33,22 @@ export function newCourse(artemis) { export function addUserToStudentsInCourse(artemis, username, courseId) { const res = artemis.post(COURSE_STUDENTS(courseId, username)); - console.log("Add user " + username + " to students in course " + courseId + " status: " + res[0].status); + console.log('Add user ' + username + ' to students in course ' + courseId + ' status: ' + res[0].status); } export function removeUserFromStudentsInCourse(artemis, username, courseId) { const res = artemis.delete(COURSE_STUDENTS(courseId, username)); - console.log("Remove user " + username + " from students in course " + courseId + " status: " + res[0].status); + console.log('Remove user ' + username + ' from students in course ' + courseId + ' status: ' + res[0].status); } export function addUserToInstructorsInCourse(artemis, username, courseId) { const res = artemis.post(COURSE_INSTRUCTORS(courseId, username)); - console.log("Add user " + username + " to instructors in course " + courseId + " status: " + res[0].status); + console.log('Add user ' + username + ' to instructors in course ' + courseId + ' status: ' + res[0].status); } export function removeUserFromInstructorsInCourse(artemis, username, courseId) { const res = artemis.delete(COURSE_INSTRUCTORS(courseId, username)); - console.log("Remove user " + username + " from instructors in course " + courseId + " status: " + res[0].status); + console.log('Remove user ' + username + ' from instructors in course ' + courseId + ' status: ' + res[0].status); } export function deleteCourse(artemis, courseId) { diff --git a/src/test/k6/requests/endpoints.js b/src/test/k6/requests/endpoints.js index 6718853e6717..bbce6ab003c2 100644 --- a/src/test/k6/requests/endpoints.js +++ b/src/test/k6/requests/endpoints.js @@ -1,10 +1,10 @@ -export const PROGRAMMING_EXERCISES_SETUP = "/programming-exercises/setup"; -export const PROGRAMMING_EXERCISES = "/programming-exercises"; +export const PROGRAMMING_EXERCISES_SETUP = '/programming-exercises/setup'; +export const PROGRAMMING_EXERCISES = '/programming-exercises'; export const PROGRAMMING_EXERCISE = (exerciseId) => `${PROGRAMMING_EXERCISES}/${exerciseId}`; -export const QUIZ_EXERCISES = "/quiz-exercises"; +export const QUIZ_EXERCISES = '/quiz-exercises'; export const QUIZ_EXERCISE = (exerciseId) => `${QUIZ_EXERCISES}/${exerciseId}`; -export const COURSES = "/courses"; -export const USERS = "/users"; +export const COURSES = '/courses'; +export const USERS = '/users'; export const COURSE = (courseId) => `${COURSES}/${courseId}`; export const COURSE_STUDENTS = (courseId, username) => `${COURSES}/${courseId}/students/${username}`; export const COURSE_TUTORS = (courseId, username) => `${COURSES}/${courseId}/tutors/${username}`; diff --git a/src/test/k6/requests/programmingExercise.js b/src/test/k6/requests/programmingExercise.js index 684e19b0dd29..5ea3f6cfb4d8 100644 --- a/src/test/k6/requests/programmingExercise.js +++ b/src/test/k6/requests/programmingExercise.js @@ -1,16 +1,9 @@ -import {nextAlphanumeric, nextWSSubscriptionId} from '../util/utils.js'; -import { - COMMIT, - NEW_FILE, - PARTICIPATION_WITH_RESULT, - PARTICIPATIONS, - PROGRAMMING_EXERCISE, - PROGRAMMING_EXERCISES_SETUP -} from './endpoints.js'; -import {fail, sleep} from 'k6'; -import {programmingExerciseProblemStatementJava} from "../resource/constants_java.js"; -import {programmingExerciseProblemStatementPython} from "../resource/constants_python.js"; -import {programmingExerciseProblemStatementC} from "../resource/constants_c.js"; +import { nextAlphanumeric, nextWSSubscriptionId } from '../util/utils.js'; +import { COMMIT, NEW_FILE, PARTICIPATION_WITH_RESULT, PARTICIPATIONS, PROGRAMMING_EXERCISE, PROGRAMMING_EXERCISES_SETUP } from './endpoints.js'; +import { fail, sleep } from 'k6'; +import { programmingExerciseProblemStatementJava } from '../resource/constants_java.js'; +import { programmingExerciseProblemStatementPython } from '../resource/constants_python.js'; +import { programmingExerciseProblemStatementC } from '../resource/constants_c.js'; export function ParticipationSimulation(timeout, exerciseId, participationId, content) { this.timeout = timeout; @@ -19,30 +12,32 @@ export function ParticipationSimulation(timeout, exerciseId, participationId, co this.newFiles = content.newFiles; this.content = content.content; - this.returnsExpectedResult = function(result, expectedResult, resultString) { - console.log("Received test result " + result.successful + ", " + result.resultString); + this.returnsExpectedResult = function (result, expectedResult, resultString) { + console.log('Received test result ' + result.successful + ', ' + result.resultString); switch (expectedResult) { - case TestResult.SUCCESS: { - if(!result.successful) fail(`ERROR: The result for participation ${participationId} was not successful!`); - } - break; - case TestResult.FAIL: { - if(result.successful || !result.hasFeedback || result.resultString !== resultString) - fail(`ERROR: The result for participation ${participationId} did not fail with ${resultString}! Was ${result.resultString}`) - } - break; + case TestResult.SUCCESS: + { + if (!result.successful) fail(`ERROR: The result for participation ${participationId} was not successful!`); + } + break; + case TestResult.FAIL: + { + if (result.successful || !result.hasFeedback || result.resultString !== resultString) + fail(`ERROR: The result for participation ${participationId} did not fail with ${resultString}! Was ${result.resultString}`); + } + break; default: { - if(result.successful || result.hasFeedback) fail(`ERROR: The result for participation ${participationId} contained no build errors!`) + if (result.successful || result.hasFeedback) fail(`ERROR: The result for participation ${participationId} contained no build errors!`); } } }; - this.extractResultFromWebSocketMessage = function(message) { + this.extractResultFromWebSocketMessage = function (message) { const resReg = /(.*\n\n)([^\u0000]*)(\u0000)/g; const match = resReg.exec(message); return JSON.parse(match[2]); - } + }; } export function getLatestResult(artemis, participationId) { @@ -60,7 +55,7 @@ export function getLatestResult(artemis, participationId) { export const TestResult = { SUCCESS: 'success', FAIL: 'failure', - BUILD_ERROR: 'error' + BUILD_ERROR: 'error', }; export function createProgrammingExercise(artemis, courseId, programmingLanguage) { @@ -82,7 +77,7 @@ export function createProgrammingExercise(artemis, courseId, programmingLanguage // The actual exercise const exercise = { title: 'TEST ' + nextAlphanumeric(10), - shortName: 'TEST'+ nextAlphanumeric(5).toUpperCase(), + shortName: 'TEST' + nextAlphanumeric(5).toUpperCase(), maxScore: 42, assessmentType: 'AUTOMATIC', type: 'programming', @@ -94,13 +89,13 @@ export function createProgrammingExercise(artemis, courseId, programmingLanguage sequentialTestRuns: false, mode: 'INDIVIDUAL', course: { - id: courseId - } + id: courseId, + }, }; res = artemis.post(PROGRAMMING_EXERCISES_SETUP, exercise); if (res[0].status !== 201) { - console.log("ERROR when creating a new programming exercise. Response headers:"); + console.log('ERROR when creating a new programming exercise. Response headers:'); for (let [key, value] of Object.entries(res[0].headers)) { console.log(`${key}: ${value}`); } @@ -115,7 +110,7 @@ export function createProgrammingExercise(artemis, courseId, programmingLanguage export function deleteProgrammingExercise(artemis, exerciseId) { const res = artemis.delete(PROGRAMMING_EXERCISE(exerciseId), { deleteStudentReposBuildPlans: true, - deleteBaseReposBuildPlans: true + deleteBaseReposBuildPlans: true, }); if (res[0].status !== 200) { fail('Could not delete exercise (' + res[0].status + ')! Response was + ' + res[0].body); @@ -152,20 +147,27 @@ export function createNewFile(artemis, participationId, filename) { export function simulateSubmission(artemis, participationSimulation, expectedResult, resultString) { // First, we have to create all new files - participationSimulation.newFiles.forEach(file => createNewFile(artemis, participationSimulation.participationId, file)); + participationSimulation.newFiles.forEach((file) => createNewFile(artemis, participationSimulation.participationId, file)); artemis.websocket(function (socket) { // Send changes via websocket function submitChange(content) { const contentString = JSON.stringify(content); - const changeMessage = 'SEND\ndestination:/topic/repository/' + participationSimulation.participationId + '/files\ncontent-length:' + contentString.length + '\n\n' + contentString + '\u0000'; + const changeMessage = + 'SEND\ndestination:/topic/repository/' + + participationSimulation.participationId + + '/files\ncontent-length:' + + contentString.length + + '\n\n' + + contentString + + '\u0000'; socket.send(changeMessage); socket.send('SUBSCRIBE\nid:sub-' + nextWSSubscriptionId() + '\ndestination:/user/topic/repository/' + participationSimulation.participationId + '/files\n\n\u0000'); } // Subscribe to new results and participations function subscribe(exerciseId, participationId) { - socket.send('SUBSCRIBE\nid:sub-' + nextWSSubscriptionId() + '\ndestination:/topic/participation/' + participationId +'/newResults\n\n\u0000'); + socket.send('SUBSCRIBE\nid:sub-' + nextWSSubscriptionId() + '\ndestination:/topic/participation/' + participationId + '/newResults\n\n\u0000'); socket.send('SUBSCRIBE\nid:sub-' + nextWSSubscriptionId() + '\ndestination:/user/topic/exercise/' + exerciseId + '/participation\n\n\u0000'); } @@ -174,17 +176,17 @@ export function simulateSubmission(artemis, participationSimulation, expectedRes socket.ping(); }, 10000); - socket.setTimeout(function() { + socket.setTimeout(function () { subscribe(participationSimulation.exerciseId, participationSimulation.participationId); }, 5 * 1000); - socket.setTimeout(function() { + socket.setTimeout(function () { submitChange(participationSimulation.content); - console.log('SEND file data for test user ' + __VU) + console.log('SEND file data for test user ' + __VU); }, 10 * 1000); // Commit changes - socket.setTimeout(function() { + socket.setTimeout(function () { artemis.post(COMMIT(participationSimulation.participationId)); console.log('COMMIT changes for test user ' + __VU); }, 15 * 1000); @@ -200,7 +202,7 @@ export function simulateSubmission(artemis, participationSimulation, expectedRes }); // Fail after timeout - socket.setTimeout(function() { + socket.setTimeout(function () { socket.close(); // Try to GET latest result console.log('Websocket timed out, trying to GET now'); @@ -210,7 +212,6 @@ export function simulateSubmission(artemis, participationSimulation, expectedRes } else { fail('ERROR: Did not receive result for test user ' + __VU); } - }, participationSimulation.timeout * 1000); }); } diff --git a/src/test/k6/requests/quiz.js b/src/test/k6/requests/quiz.js index 64b5efdcc634..98a99632d100 100644 --- a/src/test/k6/requests/quiz.js +++ b/src/test/k6/requests/quiz.js @@ -1,7 +1,7 @@ -import {PARTICIPATION, QUIZ_EXERCISES} from "./endpoints.js"; -import {fail, sleep} from 'k6'; -import {nextAlphanumeric, nextWSSubscriptionId, randomArrayValue} from "../util/utils.js"; -import {QUIZ_EXERCISE} from "./endpoints.js"; +import { PARTICIPATION, QUIZ_EXERCISES } from './endpoints.js'; +import { fail, sleep } from 'k6'; +import { nextAlphanumeric, nextWSSubscriptionId, randomArrayValue } from '../util/utils.js'; +import { QUIZ_EXERCISE } from './endpoints.js'; export function createQuizExercise(artemis, course) { let res; @@ -24,12 +24,12 @@ export function createQuizExercise(artemis, course) { isVisibleBeforeStart: false, mode: 'INDIVIDUAL', course: course, - quizQuestions: generateQuizQuestions(10) + quizQuestions: generateQuizQuestions(10), }; res = artemis.post(QUIZ_EXERCISES, exercise); if (res[0].status !== 201) { - console.log("ERROR when creating a new quiz exercise. Response headers:"); + console.log('ERROR when creating a new quiz exercise. Response headers:'); for (let [key, value] of Object.entries(res[0].headers)) { console.log(`${key}: ${value}`); } @@ -39,13 +39,13 @@ export function createQuizExercise(artemis, course) { console.log('CREATED new quiz exercise, ID=' + exerciseId); console.log('Setting quiz to visible'); - res = artemis.put(QUIZ_EXERCISE(exerciseId) + "/set-visible"); + res = artemis.put(QUIZ_EXERCISE(exerciseId) + '/set-visible'); if (res[0].status !== 200) { fail('Could not set quiz to visible (' + res[0].status + ')! Response was + ' + res[0].body); } console.log('Starting quiz'); - res = artemis.put(QUIZ_EXERCISE(exerciseId) + "/start-now"); + res = artemis.put(QUIZ_EXERCISE(exerciseId) + '/start-now'); if (res[0].status !== 200) { fail('Could not start quiz (' + res[0].status + ')! Response was + ' + res[0].body); } @@ -66,7 +66,7 @@ export function generateQuizQuestions(amount) { invalid: false, hint: 'Some question hint', exportQuiz: 'false', - answerOptions: generateAnswerOptions() + answerOptions: generateAnswerOptions(), }; questions.push(question); } @@ -80,14 +80,14 @@ export function generateQuizQuestions(amount) { hint: 'Correct answer hint', invalid: false, isCorrect: true, - text: 'Correct answer option' + text: 'Correct answer option', }; let wrongAnswerOption = { explanation: 'Wrong answer explanation', hint: 'Wrong answer hint', invalid: false, isCorrect: false, - text: 'Wrong answer option' + text: 'Wrong answer option', }; answerOptions.push(correctAnswerOption); @@ -117,14 +117,14 @@ export function getQuizQuestions(artemis, courseId, exerciseId) { export function simulateQuizWork(artemis, exerciseId, questions, timeout) { artemis.websocket(function (socket) { function subscribe() { - socket.send('SUBSCRIBE\nid:sub-' + nextWSSubscriptionId() + '\ndestination:/user/topic/quizExercise/' + exerciseId +'/submission\n\n\u0000'); + socket.send('SUBSCRIBE\nid:sub-' + nextWSSubscriptionId() + '\ndestination:/user/topic/quizExercise/' + exerciseId + '/submission\n\n\u0000'); } function submitRandomAnswer() { const answer = { submissionExerciseType: 'quiz', submitted: false, - submittedAnswers: questions.map(q => generateAnswer(q)) + submittedAnswers: questions.map((q) => generateAnswer(q)), }; const answerString = JSON.stringify(answer); const wsMessage = `SEND\ndestination:/topic/quizExercise/${exerciseId}/submission\ncontent-length:${answerString.length}\n\n${answerString}\u0000`; @@ -137,12 +137,12 @@ export function simulateQuizWork(artemis, exerciseId, questions, timeout) { return { type: question.type, quizQuestion: question, - selectedOptions: [randAnswer] + selectedOptions: [randAnswer], }; } // Subscribe to callback response from server (response after submitted answer - socket.setTimeout(function() { + socket.setTimeout(function () { subscribe(); }, 5 * 1000); @@ -156,13 +156,13 @@ export function simulateQuizWork(artemis, exerciseId, questions, timeout) { }); // submit new quiz answer - socket.setTimeout(function() { + socket.setTimeout(function () { submitRandomAnswer(); }, 10 * 1000); // Stop after timeout - socket.setTimeout(function() { + socket.setTimeout(function () { socket.close(); }, timeout * 1000); - }) + }); } diff --git a/src/test/k6/requests/requests.js b/src/test/k6/requests/requests.js index 46f9520d6afc..f13f337530bf 100644 --- a/src/test/k6/requests/requests.js +++ b/src/test/k6/requests/requests.js @@ -1,48 +1,52 @@ import http from 'k6/http'; import ws from 'k6/ws'; -import {fail} from 'k6'; +import { fail } from 'k6'; -const defaultXSRFToken = "42d141b5-9e1c-4390-ae06-5143753b4459"; -const protocol = "https"; // https or http -const websocketProtocol = "wss"; // wss if https is used; ws if http is used +const defaultXSRFToken = '42d141b5-9e1c-4390-ae06-5143753b4459'; +const protocol = 'https'; // https or http +const websocketProtocol = 'wss'; // wss if https is used; ws if http is used const host = __ENV.BASE_URL; // host including port if differing from 80 (http) or 443 (https) -const baseUrl = protocol + "://" + host; +const baseUrl = protocol + '://' + host; const userAgent = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:66.0) Gecko/20100101 Firefox/66.0'; const acceptLanguage = 'en-CA,en-US;q=0.7,en;q=0.3'; const acceptEncoding = 'gzip, deflate, br'; -const request = function(method, endpoint, authToken, xsrftoken, body, params) { +const request = function (method, endpoint, authToken, xsrftoken, body, params) { let paramString; if (params) { - paramString = Object.keys(params).map(key => key + '=' + params[key]).join('&'); + paramString = Object.keys(params) + .map((key) => key + '=' + params[key]) + .join('&'); } let url = baseUrl + '/api' + endpoint + (paramString ? '?' + paramString : ''); - let req = [{ - method: method, - url: url, - body: body ? JSON.stringify(body) : null, - params: { - 'cookies': { - 'XSRF-TOKEN': xsrftoken + let req = [ + { + method: method, + url: url, + body: body ? JSON.stringify(body) : null, + params: { + cookies: { + 'XSRF-TOKEN': xsrftoken, + }, + headers: { + Host: host, + 'User-Agent': userAgent, + Accept: 'application/json, text/plain, */*', + 'Accept-Language': acceptLanguage, + 'Accept-Encoding': acceptEncoding, + Referer: baseUrl + '/', + Authorization: 'Bearer ' + authToken, + 'X-XSRF-TOKEN': xsrftoken, + 'Content-Type': 'application/json', + Connection: 'keep-alive', + TE: 'Trailers', + }, + tags: { name: url }, }, - 'headers': { - 'Host': host, - 'User-Agent': userAgent, - 'Accept': 'application/json, text/plain, */*', - 'Accept-Language': acceptLanguage, - 'Accept-Encoding': acceptEncoding, - 'Referer': baseUrl + '/', - 'Authorization': 'Bearer ' + authToken, - 'X-XSRF-TOKEN': xsrftoken, - 'Content-Type': 'application/json', - 'Connection': 'keep-alive', - 'TE': 'Trailers' - }, - 'tags': {name: url} - } - }]; + }, + ]; return http.batch(req); }; @@ -53,29 +57,31 @@ export function login(username, password) { console.log('Try to login with ' + username + ':' + password); // The user logs in; the authToken gets saved as we need it later - req = [{ - 'method': 'post', - 'url': baseUrl + '/api/authenticate', - 'body': '{"username":"' + username + '","password":"' + password + '","rememberMe":true}', - 'params': { - 'cookies': { - 'XSRF-TOKEN': defaultXSRFToken - }, - 'headers': { - 'Host': host, - 'User-Agent': userAgent, - 'Accept': 'application/json, text/plain, */*', - 'Accept-Language': acceptLanguage, - 'Accept-Encoding': acceptEncoding, - 'Referer': baseUrl + '/', - 'X-XSRF-TOKEN': defaultXSRFToken, - 'Content-Type': 'application/json', - 'Connection': 'keep-alive', - 'TE': 'Trailers' + req = [ + { + method: 'post', + url: baseUrl + '/api/authenticate', + body: '{"username":"' + username + '","password":"' + password + '","rememberMe":true}', + params: { + cookies: { + 'XSRF-TOKEN': defaultXSRFToken, + }, + headers: { + Host: host, + 'User-Agent': userAgent, + Accept: 'application/json, text/plain, */*', + 'Accept-Language': acceptLanguage, + 'Accept-Encoding': acceptEncoding, + Referer: baseUrl + '/', + 'X-XSRF-TOKEN': defaultXSRFToken, + 'Content-Type': 'application/json', + Connection: 'keep-alive', + TE: 'Trailers', + }, + tags: { name: baseUrl + '/api/authenticate' }, }, - 'tags': {'name': baseUrl + '/api/authenticate'} - } - }]; + }, + ]; res = http.batch(req); if (res[0].status !== 200) { fail('Failed to login as user ' + username + ' (' + res[0].status + ')! Response was + ' + res[0].body); @@ -84,27 +90,29 @@ export function login(username, password) { // console.log('GOT authToken ' + authToken + ' for user ' + username); // The user requests it own information of the account - req = [{ - 'method': 'get', - 'url': baseUrl + '/api/account', - 'params': { - 'cookies': { - 'XSRF-TOKEN': defaultXSRFToken - }, - 'headers': { - 'Host': host, - 'User-Agent': userAgent, - 'Accept': 'application/json, text/plain, */*', - 'Accept-Language': acceptLanguage, - 'Accept-Encoding': acceptEncoding, - 'Referer': baseUrl + '/', - 'Authorization': 'Bearer ' + authToken, - 'Connection': 'keep-alive', - 'TE': 'Trailers' + req = [ + { + method: 'get', + url: baseUrl + '/api/account', + params: { + cookies: { + 'XSRF-TOKEN': defaultXSRFToken, + }, + headers: { + Host: host, + 'User-Agent': userAgent, + Accept: 'application/json, text/plain, */*', + 'Accept-Language': acceptLanguage, + 'Accept-Encoding': acceptEncoding, + Referer: baseUrl + '/', + Authorization: 'Bearer ' + authToken, + Connection: 'keep-alive', + TE: 'Trailers', + }, + tags: { name: baseUrl + '/api/account' }, }, - 'tags': {'name': baseUrl + '/api/account'} - } - }]; + }, + ]; res = http.batch(req); // A new XSRF Token is needed now, we have to extract it from the cookies const xsrftoken = res[0].headers['Set-Cookie'].match('(.*XSRF-TOKEN=)([a-z0-9]+[a-z0-9\\-]+[a-z0-9]+)(;.*)')[2]; @@ -113,23 +121,23 @@ export function login(username, password) { } export function Artemis(authToken, xsrftoken) { - this.get = function(endpoint, params) { + this.get = function (endpoint, params) { return request('get', endpoint, authToken, xsrftoken, null, params); }; - this.post = function(endpoint, body, params) { + this.post = function (endpoint, body, params) { return request('post', endpoint, authToken, xsrftoken, body, params); }; - this.put = function(endpoint, body, params) { + this.put = function (endpoint, body, params) { return request('put', endpoint, authToken, xsrftoken, body, params); }; - this.delete = function(endpoint, params) { + this.delete = function (endpoint, params) { return request('delete', endpoint, authToken, xsrftoken, null, params); }; - this.websocket = function(doOnSocket) { + this.websocket = function (doOnSocket) { const websocketEndpoint = websocketProtocol + '://' + host + '/websocket/tracker/websocket'; const websocketUrl = websocketEndpoint + '?access_token=' + authToken; - ws.connect(websocketUrl, { tags: { name: websocketEndpoint } }, function(socket) { + ws.connect(websocketUrl, { tags: { name: websocketEndpoint } }, function (socket) { socket.on('open', function open() { socket.send('CONNECT\nX-XSRF-TOKEN:' + xsrftoken + '\naccept-version:1.1,1.0\nheart-beat:10000,10000\n\n\u0000'); }); diff --git a/src/test/k6/requests/user.js b/src/test/k6/requests/user.js index ec5323bd6063..bdadec601c31 100644 --- a/src/test/k6/requests/user.js +++ b/src/test/k6/requests/user.js @@ -1,7 +1,6 @@ import { USERS } from './endpoints.js'; -import {addUserToInstructorsInCourse, addUserToStudentsInCourse} from "./course.js"; -import {login} from "./requests.js"; - +import { addUserToInstructorsInCourse, addUserToStudentsInCourse } from './course.js'; +import { login } from './requests.js'; export function getUser(artemis, i, baseUsername) { const username = baseUsername.replace('USERID', i); @@ -20,12 +19,11 @@ export function updateUser(artemis, user) { } export function newUser(artemis, i, baseUsername, basePassword, studentGroupName, instructorGroupName) { - const username = baseUsername.replace('USERID', i); const password = basePassword.replace('USERID', i); - let authorities = ["ROLE_USER"]; + let authorities = ['ROLE_USER']; if (i === 1) { - authorities = ["ROLE_USER", "ROLE_INSTRUCTOR"]; + authorities = ['ROLE_USER', 'ROLE_INSTRUCTOR']; } let groups = [studentGroupName]; @@ -36,14 +34,14 @@ export function newUser(artemis, i, baseUsername, basePassword, studentGroupName const user = { login: username, password: password, - firstName: "Artemis Test " + i, - lastName: "Artemis Test " + i, - email: "testuser_"+i+"@tum.invalid", + firstName: 'Artemis Test ' + i, + lastName: 'Artemis Test ' + i, + email: 'testuser_' + i + '@tum.invalid', activated: true, - langKey: "en", + langKey: 'en', authorities: authorities, groups: groups, - createdBy: "test-case", + createdBy: 'test-case', }; console.log('Try to create new user ' + username); @@ -51,16 +49,14 @@ export function newUser(artemis, i, baseUsername, basePassword, studentGroupName if (res[0].status !== 201) { console.info('Unable to generate new user ' + username + ' (status: ' + res[0].status + ')!'); return -1; - } - else { - console.log('SUCCESS: Created new user ' + username + " with groups " + res[0].body.groups); + } else { + console.log('SUCCESS: Created new user ' + username + ' with groups ' + res[0].body.groups); } return JSON.parse(res[0].body).id; } export function updateUserWithGroup(artemis, i, baseUsername, course) { - const username = baseUsername.replace('USERID', i); addUserToStudentsInCourse(artemis, username, course.id); @@ -73,8 +69,8 @@ export function createUsersIfNeeded(artemis, baseUsername, basePassword, adminUs const shouldCreateUsers = __ENV.CREATE_USERS === true || __ENV.CREATE_USERS === 'true'; const iterations = parseInt(__ENV.ITERATIONS); - if(shouldCreateUsers) { - console.log("Try to create " + iterations + " users"); + if (shouldCreateUsers) { + console.log('Try to create ' + iterations + ' users'); for (let i = 1; i <= iterations; i++) { let userId = newUser(artemis, i, baseUsername, basePassword, course.studentGroupName, course.instructorGroupName); if (userId === -1) { @@ -82,12 +78,11 @@ export function createUsersIfNeeded(artemis, baseUsername, basePassword, adminUs updateUserWithGroup(artemis, i, baseUsername, course); } } - } - else { - console.log("Do not create users, assume the user exists in the external system, will update their groups"); + } else { + console.log('Do not create users, assume the user exists in the external system, will update their groups'); for (let i = 1; i <= iterations; i++) { // we need to login once with the user, so that the user is synced and available for the update with the groups - login(baseUsername.replace('USERID', i), basePassword.replace('USERID', i)) + login(baseUsername.replace('USERID', i), basePassword.replace('USERID', i)); } artemis = login(adminUsername, adminPassword); for (let i = 1; i <= iterations; i++) { diff --git a/src/test/k6/resource/constants_c.js b/src/test/k6/resource/constants_c.js index f80fecf88062..546d36f42605 100644 --- a/src/test/k6/resource/constants_c.js +++ b/src/test/k6/resource/constants_c.js @@ -1,4 +1,5 @@ -export const programmingExerciseProblemStatementC = '### Tests\n' + +export const programmingExerciseProblemStatementC = + '### Tests\n' + '\n' + '#### General Tasks\n' + '1. [task][0 as Input](TestInput_0)\n' + @@ -22,20 +23,22 @@ export const programmingExerciseProblemStatementC = '### Tests\n' + export const buildErrorContentC = { newFiles: [], - content: [{ - fileName: 'main.c', - fileContent: 'a' - }] + content: [ + { + fileName: 'main.c', + fileContent: 'a', + }, + ], }; -export const someSuccessfulErrorContentC= { +export const someSuccessfulErrorContentC = { newFiles: [], - content: [{ - fileName: 'main.c', - fileContent: 'int main(void) {\n' + - '\treturn 0; // Success\n'+ - '}\n' - }] + content: [ + { + fileName: 'main.c', + fileContent: 'int main(void) {\n' + '\treturn 0; // Success\n' + '}\n', + }, + ], }; export const allSuccessfulContentC = { @@ -43,83 +46,84 @@ export const allSuccessfulContentC = { content: [ { fileName: 'main.c', - fileContent: '#include // For printf(...)\n' + - '#include // For fork()\n' + - '#include // For wait(...)\n' + - '#include // strcmp(...)\n' + - '\n' + - 'int readProcessCount();\n' + - 'int createForks(int count);\n' + - 'void waitForEnd();\n' + - 'void waitPidChildren(int count);\n' + - '\n' + - 'int main(void) {\n' + - '\tint count = readProcessCount();\n' + - '\n' + - '\tint pid = createForks(count);\n' + - '\tif(pid != 0) {\n' + - '\t\twaitPidChildren(count);\n' + - '\t\tprintf("Parent with PID %i terminated.\\n", getpid());\n' + - '\t}\n' + - '\treturn 0; // Success\n' + - '}\n' + - '\n' + - 'int readProcessCount() {\n' + - '\tint count = -1;\n' + - '\tdo\n' + - '\t{\n' + - '\t\tprintf("Enter process count:\\n");\n' + - '\t\tfflush(stdout);\n' + - '\t\tif(!scanf("%i", &count)) {\n' + - '\t\t\t// Clear input if user did not enter a valid int:\n' + - '\t\t\tint c;\n' + - '\t\t\twhile ((c = getchar()) != \'\\n\' && c != EOF);\n' + - '\t\t}\n' + - '\t} while (count < 0);\n' + - '\treturn count;\n' + - '}\n' + - '\n' + - '// Recursively create new processes:\n' + - 'int createForks(int count) {\n' + - '\tif(count <= 0) { return 1;}\n' + - '\n' + - '\tint pid = fork();\n' + - '\tswitch(pid) {\n' + - '\t\tcase -1: // Error\n' + - '\t\t\tperror ("fork() failed");\n' + - '\t\t\tbreak;\n' + - '\n' + - '\t\tcase 0: // Child\n' + - '\t\t\tpid = getpid();\n' + - '\t\t\tprintf("I\'m your child! PID: %i, PPID: %i\\n", pid, getppid());\n' + - '\t\t\twaitForEnd();\n' + - '\t\t\tprintf("Child with PID %i terminated.\\n", pid);\n' + - '\t\t\treturn 0;\n' + - '\n' + - '\t\tdefault: // Parent\n' + - '\t\t\treturn createForks(--count);\n' + - '\t}\n' + - '\treturn pid;\n' + - '}\n' + - '\n' + - 'void waitForEnd() {\n' + - '\tchar buffer[1024];\n' + - '\tdo\n' + - '\t{\n' + - '\t\tif(!scanf("%s", buffer)) {\n' + - '\t\t\t// Clear input if user did not enter a valid int:\n' + - '\t\t\tint c;\n' + - '\t\t\twhile ((c = getchar()) != \'\\n\' && c != EOF);\n' + - '\t\t}\n' + - '\t\t// printf("Read: %s\\n", buffer); // Debug output\n' + - '\t} while (strcmp(buffer, "END"));\n' + - '}\n' + - '\n' + - 'void waitPidChildren(int count) {\n' + - '\tfor(int i = 0; i < count; i++) {\n' + - '\t\twaitpid(-1, NULL, 0); // Make sure we wait on the child process to prevent it from getting a Zombie process\n' + - '\t}\n' + - '}' - } - ] + fileContent: + '#include // For printf(...)\n' + + '#include // For fork()\n' + + '#include // For wait(...)\n' + + '#include // strcmp(...)\n' + + '\n' + + 'int readProcessCount();\n' + + 'int createForks(int count);\n' + + 'void waitForEnd();\n' + + 'void waitPidChildren(int count);\n' + + '\n' + + 'int main(void) {\n' + + '\tint count = readProcessCount();\n' + + '\n' + + '\tint pid = createForks(count);\n' + + '\tif(pid != 0) {\n' + + '\t\twaitPidChildren(count);\n' + + '\t\tprintf("Parent with PID %i terminated.\\n", getpid());\n' + + '\t}\n' + + '\treturn 0; // Success\n' + + '}\n' + + '\n' + + 'int readProcessCount() {\n' + + '\tint count = -1;\n' + + '\tdo\n' + + '\t{\n' + + '\t\tprintf("Enter process count:\\n");\n' + + '\t\tfflush(stdout);\n' + + '\t\tif(!scanf("%i", &count)) {\n' + + '\t\t\t// Clear input if user did not enter a valid int:\n' + + '\t\t\tint c;\n' + + "\t\t\twhile ((c = getchar()) != '\\n' && c != EOF);\n" + + '\t\t}\n' + + '\t} while (count < 0);\n' + + '\treturn count;\n' + + '}\n' + + '\n' + + '// Recursively create new processes:\n' + + 'int createForks(int count) {\n' + + '\tif(count <= 0) { return 1;}\n' + + '\n' + + '\tint pid = fork();\n' + + '\tswitch(pid) {\n' + + '\t\tcase -1: // Error\n' + + '\t\t\tperror ("fork() failed");\n' + + '\t\t\tbreak;\n' + + '\n' + + '\t\tcase 0: // Child\n' + + '\t\t\tpid = getpid();\n' + + '\t\t\tprintf("I\'m your child! PID: %i, PPID: %i\\n", pid, getppid());\n' + + '\t\t\twaitForEnd();\n' + + '\t\t\tprintf("Child with PID %i terminated.\\n", pid);\n' + + '\t\t\treturn 0;\n' + + '\n' + + '\t\tdefault: // Parent\n' + + '\t\t\treturn createForks(--count);\n' + + '\t}\n' + + '\treturn pid;\n' + + '}\n' + + '\n' + + 'void waitForEnd() {\n' + + '\tchar buffer[1024];\n' + + '\tdo\n' + + '\t{\n' + + '\t\tif(!scanf("%s", buffer)) {\n' + + '\t\t\t// Clear input if user did not enter a valid int:\n' + + '\t\t\tint c;\n' + + "\t\t\twhile ((c = getchar()) != '\\n' && c != EOF);\n" + + '\t\t}\n' + + '\t\t// printf("Read: %s\\n", buffer); // Debug output\n' + + '\t} while (strcmp(buffer, "END"));\n' + + '}\n' + + '\n' + + 'void waitPidChildren(int count) {\n' + + '\tfor(int i = 0; i < count; i++) {\n' + + '\t\twaitpid(-1, NULL, 0); // Make sure we wait on the child process to prevent it from getting a Zombie process\n' + + '\t}\n' + + '}', + }, + ], }; diff --git a/src/test/k6/resource/constants_java.js b/src/test/k6/resource/constants_java.js index 70fdfded1b36..e47c2c3776f1 100644 --- a/src/test/k6/resource/constants_java.js +++ b/src/test/k6/resource/constants_java.js @@ -1,4 +1,5 @@ -export const programmingExerciseProblemStatementJava = '# Sorting with the Strategy Pattern\n' + +export const programmingExerciseProblemStatementJava = + '# Sorting with the Strategy Pattern\n' + '\n' + 'In this exercise, we want to implement sorting algorithms and choose them based on runtime specific variables.\n' + '\n' + @@ -87,41 +88,42 @@ export const programmingExerciseProblemStatementJava = '# Sorting with the Strat export const buildErrorContentJava = { newFiles: [], - content: [{ - fileName: 'src/de/test/BubbleSort.java', - fileContent: 'a' - }] + content: [ + { + fileName: 'src/de/test/BubbleSort.java', + fileContent: 'a', + }, + ], }; export const testErrorContentJava = { newFiles: [], - content: [{ - fileName: 'src/de/test/BubbleSort.java', - fileContent: 'package de.test;\n' + - '\n' + - 'import java.util.*;\n' + - '\n' + - 'public class BubbleSort {\n' + - '\n' + - ' public void performSort(List input) {}\n' + - '}' - }] + content: [ + { + fileName: 'src/de/test/BubbleSort.java', + fileContent: + 'package de.test;\n' + '\n' + 'import java.util.*;\n' + '\n' + 'public class BubbleSort {\n' + '\n' + ' public void performSort(List input) {}\n' + '}', + }, + ], }; export const someSuccessfulErrorContentJava = { newFiles: ['src/de/test/SortStrategy.java'], - content: [{ - fileName: 'src/de/test/SortStrategy.java', - fileContent: 'package de.test;\n' + - '\n' + - 'import java.util.Date;\n' + - 'import java.util.List;\n' + - '\n' + - 'public interface SortStrategy {\n' + - '\n' + - '\tpublic void performSort(List input);\n' + - '}' - }] + content: [ + { + fileName: 'src/de/test/SortStrategy.java', + fileContent: + 'package de.test;\n' + + '\n' + + 'import java.util.Date;\n' + + 'import java.util.List;\n' + + '\n' + + 'public interface SortStrategy {\n' + + '\n' + + '\tpublic void performSort(List input);\n' + + '}', + }, + ], }; export const allSuccessfulContentJava = { @@ -129,7 +131,8 @@ export const allSuccessfulContentJava = { content: [ { fileName: 'src/de/test/Context.java', - fileContent: 'package de.test;\n' + + fileContent: + 'package de.test;\n' + '\n' + 'import java.util.Date;\n' + 'import java.util.List;\n' + @@ -163,7 +166,8 @@ export const allSuccessfulContentJava = { }, { fileName: 'src/de/test/BubbleSort.java', - fileContent: 'package de.test;\n' + + fileContent: + 'package de.test;\n' + '\n' + 'import java.util.*;\n' + '\n' + @@ -182,11 +186,12 @@ export const allSuccessfulContentJava = { '\t\t}\n' + '\n' + '\t}\n' + - '}' + '}', }, { - fileName: "src/de/test/Client.java", - fileContent: 'package de.test;\n' + + fileName: 'src/de/test/Client.java', + fileContent: + 'package de.test;\n' + '\n' + 'import java.text.*;\n' + 'import java.util.*;\n' + @@ -267,11 +272,12 @@ export const allSuccessfulContentJava = { ' private static void printDateList(List list) {\n' + ' System.out.println(list.toString());\n' + ' }\n' + - '}' + '}', }, { - fileName: "src/de/test/MergeSort.java", - fileContent: 'package de.test;\n' + + fileName: 'src/de/test/MergeSort.java', + fileContent: + 'package de.test;\n' + '\n' + 'import java.util.*;\n' + '\n' + @@ -323,11 +329,12 @@ export const allSuccessfulContentJava = { ' input.set(wholeIndex + low, temp[wholeIndex]);\n' + ' }\n' + ' }\n' + - '}' + '}', }, { fileName: 'src/de/test/Policy.java', - fileContent: 'package de.test;\n' + + fileContent: + 'package de.test;\n' + '\n' + 'public class Policy {\n' + '\t\n' + @@ -346,7 +353,7 @@ export const allSuccessfulContentJava = { '\t\t\tthis.context.setSortAlgorithm(new BubbleSort());\n' + '\t\t}\n' + '\t}\n' + - '}' - } - ] + '}', + }, + ], }; diff --git a/src/test/k6/resource/constants_python.js b/src/test/k6/resource/constants_python.js index b4db3f20f212..bfb87c809022 100644 --- a/src/test/k6/resource/constants_python.js +++ b/src/test/k6/resource/constants_python.js @@ -1,4 +1,5 @@ -export const programmingExerciseProblemStatementPython = '# Sorting with the Strategy Pattern\n' + +export const programmingExerciseProblemStatementPython = + '# Sorting with the Strategy Pattern\n' + '\n' + 'In this exercise, we want to implement sorting algorithms and choose them based on runtime specific variables.\n' + '\n' + @@ -91,28 +92,32 @@ export const programmingExerciseProblemStatementPython = '# Sorting with the Str '\n' + '2. Think about a useful decision in `Policy` when to use the new `QuickSort` algorithm.\n'; - export const buildErrorContentPython = { newFiles: [], - content: [{ - fileName: 'context.py', - fileContent: 'a' - }] + content: [ + { + fileName: 'context.py', + fileContent: 'a', + }, + ], }; export const someSuccessfulErrorContentPython = { newFiles: [], - content: [{ - fileName: 'sort_strategy.py', - fileContent: 'from abc import ABC, abstractmethod\n' + - '\n' + - '\n' + - 'class SortStrategy(ABC):\n' + - '\n' + - '\t@abstractmethod\n' + - '\tdef perform_sort(self, array):\n' + - '\t\tpass' - }] + content: [ + { + fileName: 'sort_strategy.py', + fileContent: + 'from abc import ABC, abstractmethod\n' + + '\n' + + '\n' + + 'class SortStrategy(ABC):\n' + + '\n' + + '\t@abstractmethod\n' + + '\tdef perform_sort(self, array):\n' + + '\t\tpass', + }, + ], }; export const allSuccessfulContentPython = { @@ -120,7 +125,8 @@ export const allSuccessfulContentPython = { content: [ { fileName: 'sorting_algorithms.py', - fileContent: 'from .sort_strategy import SortStrategy\n' + + fileContent: + 'from .sort_strategy import SortStrategy\n' + '\n' + '\n' + 'class BubbleSort(SortStrategy):\n' + @@ -181,7 +187,8 @@ export const allSuccessfulContentPython = { }, { fileName: 'policy.py', - fileContent: 'from .sorting_algorithms import *\n' + + fileContent: + 'from .sorting_algorithms import *\n' + '\n' + '\n' + 'class Policy:\n' + @@ -192,16 +199,16 @@ export const allSuccessfulContentPython = { '\n' + '\tdef configure(self):\n' + '\t\tif len(self.context.numbers) > 10:\n' + - '\t\t\tprint(\'More than 10 numbers, choosing merge sort!\')\n' + + "\t\t\tprint('More than 10 numbers, choosing merge sort!')\n" + '\t\t\tself.context.sorting_algorithm = MergeSort()\n' + '\t\telse:\n' + - '\t\t\tprint(\'Less or equal than 10 numbers, choosing bubble sort!\')\n' + - '\t\t\tself.context.sorting_algorithm = BubbleSort()\n' - + "\t\t\tprint('Less or equal than 10 numbers, choosing bubble sort!')\n" + + '\t\t\tself.context.sorting_algorithm = BubbleSort()\n', }, { - fileName: "context.py", - fileContent: 'package de.test;\n' + + fileName: 'context.py', + fileContent: + 'package de.test;\n' + '\n' + 'import java.text.*;\n' + 'import java.util.*;\n' + @@ -282,17 +289,17 @@ export const allSuccessfulContentPython = { ' private static void printDateList(List list) {\n' + ' System.out.println(list.toString());\n' + ' }\n' + - '}' + '}', }, { - fileName: "context.py", - fileContent: 'class Context:\n' + + fileName: 'context.py', + fileContent: + 'class Context:\n' + '\tsorting_algorithm = None\n' + '\tnumbers = None\n' + '\n' + '\tdef sort(self):\n' + - '\t\tself.sorting_algorithm.perform_sort(self.numbers)\n' - - } - ] + '\t\tself.sorting_algorithm.perform_sort(self.numbers)\n', + }, + ], }; diff --git a/src/test/k6/util/utils.js b/src/test/k6/util/utils.js index 4806ca140725..73c61a5377c1 100644 --- a/src/test/k6/util/utils.js +++ b/src/test/k6/util/utils.js @@ -13,7 +13,10 @@ export function nextAlphanumeric(length) { } export function nextWSSubscriptionId() { - return Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 12); + return Math.random() + .toString(36) + .replace(/[^a-z]+/g, '') + .substr(0, 12); } export function randomArrayValue(array) { From 5da7dda7248c3887cc2e0a1a0edd73221627e69c Mon Sep 17 00:00:00 2001 From: Linus Michel Date: Tue, 14 Apr 2020 16:51:44 +0200 Subject: [PATCH 005/152] remove unused variable --- .../programming-exercise-test-schedule-picker.spec.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-test-schedule-picker.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-test-schedule-picker.spec.ts index ce87d62da0a2..09fcb2432c72 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-test-schedule-picker.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-test-schedule-picker.spec.ts @@ -2,7 +2,6 @@ import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; import * as moment from 'moment'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { DebugElement } from '@angular/core'; import { TranslateModule } from '@ngx-translate/core'; import { ArtemisTestModule } from '../../test.module'; import { ArtemisSharedModule } from 'app/shared/shared.module'; @@ -18,7 +17,6 @@ const expect = chai.expect; describe('ProgrammingExerciseTestSchedulePickerComponent', () => { let comp: ProgrammingExerciseLifecycleComponent; let fixture: ComponentFixture; - let debugElement: DebugElement; const nextDueDate = moment().add(5, 'days'); const afterDueDate = moment().add(7, 'days'); @@ -34,7 +32,6 @@ describe('ProgrammingExerciseTestSchedulePickerComponent', () => { .then(() => { fixture = TestBed.createComponent(ProgrammingExerciseLifecycleComponent); comp = fixture.componentInstance; - debugElement = fixture.debugElement; }); }); From 5e645076b1fdbc8adc7cdeef5b220f397f85f954 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Lei=C3=9F?= Date: Tue, 14 Apr 2020 16:53:10 +0200 Subject: [PATCH 006/152] Fix batch of codestyle issues. --- .../confirm-autofocus-button.component.ts | 4 +- .../shared/data-table/data-table.component.ts | 2 +- .../date-time-picker.component.ts | 4 +- .../layouts/profiles/page-ribbon.component.ts | 2 +- .../commands/fullscreen.command.ts | 2 +- .../markdown-editor/commands/katex.command.ts | 2 +- .../app/shared/pipes/format-date.pipe.ts | 2 +- .../shared/result/result-detail.component.ts | 2 +- .../webapp/app/shared/util/security-util.ts | 2 +- .../javascript/e2e/account/account.spec.ts | 1 - .../javascript/e2e/entities/course.spec.ts | 2 +- .../exercise-hint.page-object.ts | 12 ++-- .../entities/course-page-object.ts | 6 +- .../e2e/quiz-exercise/quiz-exericse.spec.ts | 61 +++++++++---------- .../password-reset-finish.component.spec.ts | 2 +- .../password-reset-init.component.spec.ts | 2 +- 16 files changed, 53 insertions(+), 55 deletions(-) diff --git a/src/main/webapp/app/shared/components/confirm-autofocus-button.component.ts b/src/main/webapp/app/shared/components/confirm-autofocus-button.component.ts index f602d86d6a91..46877a614409 100644 --- a/src/main/webapp/app/shared/components/confirm-autofocus-button.component.ts +++ b/src/main/webapp/app/shared/components/confirm-autofocus-button.component.ts @@ -48,10 +48,10 @@ export class ConfirmAutofocusButtonComponent { modalRef.componentInstance.text = this.confirmationText; modalRef.componentInstance.title = this.confirmationTitle; modalRef.result.then( - (result) => { + () => { this.onConfirm.emit(); }, - (reason) => { + () => { this.onCancel.emit(); }, ); diff --git a/src/main/webapp/app/shared/data-table/data-table.component.ts b/src/main/webapp/app/shared/data-table/data-table.component.ts index e51559a450f5..52fe324eeb1a 100644 --- a/src/main/webapp/app/shared/data-table/data-table.component.ts +++ b/src/main/webapp/app/shared/data-table/data-table.component.ts @@ -398,7 +398,7 @@ export class DataTableComponent implements OnInit, OnChanges { * * @param entity Entity that was selected via autocomplete */ - filterAfterAutocompleteSelect = (entity: BaseEntity) => { + filterAfterAutocompleteSelect = () => { this.updateEntities(); }; diff --git a/src/main/webapp/app/shared/date-time-picker/date-time-picker.component.ts b/src/main/webapp/app/shared/date-time-picker/date-time-picker.component.ts index 8c901e5548e1..515eda7482d8 100644 --- a/src/main/webapp/app/shared/date-time-picker/date-time-picker.component.ts +++ b/src/main/webapp/app/shared/date-time-picker/date-time-picker.component.ts @@ -47,7 +47,7 @@ export class FormDateTimePickerComponent implements ControlValueAccessor { @Input() max: Moment; // Dates after this date are not selectable. @Output() valueChange = new EventEmitter(); - _onChange = (val: Moment) => {}; + _onChange = () => {}; valueChanged() { this.valueChange.emit(); @@ -61,7 +61,7 @@ export class FormDateTimePickerComponent implements ControlValueAccessor { this.value = value; } } - registerOnTouched(fn: any) {} + registerOnTouched() {} registerOnChange(fn: any) { this._onChange = fn; } diff --git a/src/main/webapp/app/shared/layouts/profiles/page-ribbon.component.ts b/src/main/webapp/app/shared/layouts/profiles/page-ribbon.component.ts index 9ad0d2d2059f..430b9534c2e0 100644 --- a/src/main/webapp/app/shared/layouts/profiles/page-ribbon.component.ts +++ b/src/main/webapp/app/shared/layouts/profiles/page-ribbon.component.ts @@ -28,7 +28,7 @@ export class PageRibbonComponent implements OnInit { } } }, - (reason) => {}, + () => {}, ); } } diff --git a/src/main/webapp/app/shared/markdown-editor/commands/fullscreen.command.ts b/src/main/webapp/app/shared/markdown-editor/commands/fullscreen.command.ts index 02037545c012..fc6d813d7f94 100644 --- a/src/main/webapp/app/shared/markdown-editor/commands/fullscreen.command.ts +++ b/src/main/webapp/app/shared/markdown-editor/commands/fullscreen.command.ts @@ -10,7 +10,7 @@ export class FullscreenCommand extends Command { buttonIcon = 'compress'; buttonTranslationString = 'artemisApp.markdownEditor.commands.fullscreen'; - execute(input?: string): void { + execute(): void { if (this.isFullScreen()) { this.exitFullscreen(); } else { diff --git a/src/main/webapp/app/shared/markdown-editor/commands/katex.command.ts b/src/main/webapp/app/shared/markdown-editor/commands/katex.command.ts index adc7225818ad..1389c18c72ed 100644 --- a/src/main/webapp/app/shared/markdown-editor/commands/katex.command.ts +++ b/src/main/webapp/app/shared/markdown-editor/commands/katex.command.ts @@ -8,7 +8,7 @@ import { addTextAtCursor } from 'app/shared/util/markdown-util'; export class KatexCommand extends DomainTagCommand { buttonIcon = 'equals'; buttonTranslationString = 'artemisApp.markdownEditor.commands.katex'; - execute(input?: string): void { + execute(): void { const text = `${this.getOpeningIdentifier()}e^{\\frac{1}{4} y^2}${this.getClosingIdentifier()}`; addTextAtCursor(text, this.aceEditor); } diff --git a/src/main/webapp/app/shared/pipes/format-date.pipe.ts b/src/main/webapp/app/shared/pipes/format-date.pipe.ts index 7ac527b986d0..55966408cfd5 100644 --- a/src/main/webapp/app/shared/pipes/format-date.pipe.ts +++ b/src/main/webapp/app/shared/pipes/format-date.pipe.ts @@ -5,7 +5,7 @@ import * as moment from 'moment'; name: 'formatDate', }) export class DatePipe implements PipeTransform { - transform(date: any, args?: any): any { + transform(date: any): any { if (date == null) { return 'DD MMMM YYYY, hh:mm:ss PM'; } diff --git a/src/main/webapp/app/shared/result/result-detail.component.ts b/src/main/webapp/app/shared/result/result-detail.component.ts index dbf2cd43ae2e..13917ef226c0 100644 --- a/src/main/webapp/app/shared/result/result-detail.component.ts +++ b/src/main/webapp/app/shared/result/result-detail.component.ts @@ -51,7 +51,7 @@ export class ResultDetailComponent implements OnInit { } return of(null); }), - catchError((error: HttpErrorResponse) => { + catchError(() => { // TODO: When the server would give better error information, we could improve the UI. this.loadingFailed = true; return of(null); diff --git a/src/main/webapp/app/shared/util/security-util.ts b/src/main/webapp/app/shared/util/security-util.ts index 32108c78a8ec..c03464d3e8a0 100644 --- a/src/main/webapp/app/shared/util/security-util.ts +++ b/src/main/webapp/app/shared/util/security-util.ts @@ -1,4 +1,4 @@ export const safeUnescape = (s: string, mode = 'text/html') => { const parser = new DOMParser(); - return parser.parseFromString(s, 'text/html').body.textContent; + return parser.parseFromString(s, mode).body.textContent; }; diff --git a/src/test/javascript/e2e/account/account.spec.ts b/src/test/javascript/e2e/account/account.spec.ts index 60512df84cbe..6e3a2b81c102 100644 --- a/src/test/javascript/e2e/account/account.spec.ts +++ b/src/test/javascript/e2e/account/account.spec.ts @@ -7,7 +7,6 @@ const expect = chai.expect; describe('account', function () { let navBarPage: NavBarPage; let signInPage: SignInPage; - let settingsPage: SettingsPage; beforeEach(async function () { await browser.get('/'); diff --git a/src/test/javascript/e2e/entities/course.spec.ts b/src/test/javascript/e2e/entities/course.spec.ts index 54605fad1d96..45062a5ab954 100644 --- a/src/test/javascript/e2e/entities/course.spec.ts +++ b/src/test/javascript/e2e/entities/course.spec.ts @@ -57,7 +57,7 @@ describe('course', function () { await newCoursePage.browseCourseIcon(); await newCoursePage.uploadCourseIcon(); - expect(await element(by.css('.headline jhi-secured-image img'))).to.not.be.undefined; + expect(await element(by.css('.headline jhi-secured-image img'))).to.not.equal(undefined); await newCoursePage.clickCancel(); }); diff --git a/src/test/javascript/e2e/entities/exercise-hint/exercise-hint.page-object.ts b/src/test/javascript/e2e/entities/exercise-hint/exercise-hint.page-object.ts index 87db9896cfd5..e9b549c1711c 100644 --- a/src/test/javascript/e2e/entities/exercise-hint/exercise-hint.page-object.ts +++ b/src/test/javascript/e2e/entities/exercise-hint/exercise-hint.page-object.ts @@ -5,11 +5,11 @@ export class ExerciseHintComponentsPage { deleteButtons = element.all(by.css('jhi-exercise-hint div table .btn-danger')); title = element.all(by.css('jhi-exercise-hint div h2#page-heading span')).first(); - async clickOnCreateButton(timeout?: number) { + async clickOnCreateButton() { await this.createButton.click(); } - async clickOnLastDeleteButton(timeout?: number) { + async clickOnLastDeleteButton() { await this.deleteButtons.last().click(); } @@ -50,7 +50,7 @@ export class ExerciseHintUpdatePage { return await this.contentInput.getAttribute('value'); } - async exerciseSelectLastOption(timeout?: number) { + async exerciseSelectLastOption() { await this.exerciseSelect.all(by.tagName('option')).last().click(); } @@ -66,11 +66,11 @@ export class ExerciseHintUpdatePage { return await this.exerciseSelect.element(by.css('option:checked')).getText(); } - async save(timeout?: number) { + async save() { await this.saveButton.click(); } - async cancel(timeout?: number) { + async cancel() { await this.cancelButton.click(); } @@ -87,7 +87,7 @@ export class ExerciseHintDeleteDialog { return this.dialogTitle.getAttribute('jhiTranslate'); } - async clickOnConfirmButton(timeout?: number) { + async clickOnConfirmButton() { await this.confirmButton.click(); } } diff --git a/src/test/javascript/e2e/page-objects/entities/course-page-object.ts b/src/test/javascript/e2e/page-objects/entities/course-page-object.ts index a8aa015dbe3b..a471e5a735a6 100644 --- a/src/test/javascript/e2e/page-objects/entities/course-page-object.ts +++ b/src/test/javascript/e2e/page-objects/entities/course-page-object.ts @@ -44,9 +44,9 @@ export class NewCoursePage { } async browseCourseIcon() { - let path = require('path'); - let fileToUpload = '../entities/tum-logo.png'; - let absolutePath = path.resolve(__dirname, fileToUpload); + const path = require('path'); + const fileToUpload = '../entities/tum-logo.png'; + const absolutePath = path.resolve(__dirname, fileToUpload); await this.browse.sendKeys(absolutePath); } diff --git a/src/test/javascript/e2e/quiz-exercise/quiz-exericse.spec.ts b/src/test/javascript/e2e/quiz-exercise/quiz-exericse.spec.ts index 61cfe58f3fed..5d882dd6d850 100644 --- a/src/test/javascript/e2e/quiz-exercise/quiz-exericse.spec.ts +++ b/src/test/javascript/e2e/quiz-exercise/quiz-exericse.spec.ts @@ -10,7 +10,6 @@ describe('quiz-exercise', function () { let signInPage: SignInPage; let coursePage: CoursePage; let newCoursePage: NewCoursePage; - let quizExercisePage: QuizExercisePage; let courseId: string; let quizId: string; @@ -57,11 +56,11 @@ describe('quiz-exercise', function () { // expect(createQuizButton.isPresent()); await createQuizButton.click(); - //set title of quiz + // set title of quiz const title = element(by.id('quiz-title')); title.sendKeys('test-quiz'); - //set duration of quiz + // set duration of quiz const durationMinutes = await element(by.id('quiz-duration-minutes')); durationMinutes.clear(); durationMinutes.sendKeys('0'); @@ -69,7 +68,7 @@ describe('quiz-exercise', function () { durationSeconds.clear(); durationSeconds.sendKeys('5'); - //add MC question + // add MC question const addMcButton = await element(by.id('quiz-add-mc-question')); await addMcButton.click(); @@ -77,7 +76,7 @@ describe('quiz-exercise', function () { const mcQuestionTitle = await element(by.id('mc-question-title')); //TODO: we need to support multiple questions mcQuestionTitle.sendKeys('test-mc'); - //deactivate random order to make the test case deterministic + // deactivate random order to make the test case deterministic const randomOrder = await element(by.css('[for="cbRandomizeOrderMC1"]')); await randomOrder.click(); @@ -89,35 +88,35 @@ describe('quiz-exercise', function () { const backButton = await element(by.id('quiz-cancel-back-button')); expect(backButton.isPresent()); - //TODO: check that the button name is "Back" + // TODO: check that the button name is "Back" await backButton.click(); const quizRows = element.all(by.tagName('tbody')).all(by.tagName('tr')); quizId = await quizRows.last().element(by.css('td:nth-child(1) > a')).getText(); - //TODO: check that we leave the page and there is a new entry + // TODO: check that we leave the page and there is a new entry }); it('participate in quiz', async function () { - //set visible + // set visible const setVisibleButton = await element(by.id(`quiz-set-visible-${quizId}`)); expect(setVisibleButton.isPresent()); await setVisibleButton.click(); await browser.sleep(500); // let's wait shortly so that the server gets everything right with the database - //start quiz + // start quiz const startQuizInstructorButton = await element(by.id(`instructor-quiz-start-${quizId}`)); expect(startQuizInstructorButton.isPresent()); await startQuizInstructorButton.click(); await browser.sleep(500); // let's wait shortly so that the server gets everything right with the database - //navigate to courses + // navigate to courses await navBarPage.clickOnOverviewMenu(); browser.wait(ec.urlContains(`overview`), 1000).then((result: any) => expect(result).to.be.true); - //open or start quiz (depends a bit on the timing) + // open or start quiz (depends a bit on the timing) let startQuizButton = await element(by.id(`student-quiz-start-${quizId}`)); if (!startQuizButton.isPresent()) { startQuizButton = await element(by.id(`student-quiz-open-${quizId}`)); @@ -131,25 +130,25 @@ describe('quiz-exercise', function () { browser.waitForAngularEnabled(false); await browser.sleep(2000); // wait till ui is loaded - //answer quiz - //TODO the answer options are random, search for the correct and incorrect answer option before clicking in it + // answer quiz + // TODO the answer options are random, search for the correct and incorrect answer option before clicking in it const firstAnswerOption = await element(by.id(`answer-option-0`)); expect(firstAnswerOption.isPresent()); - await firstAnswerOption.click(); //select - await firstAnswerOption.click(); //deselect - await firstAnswerOption.click(); //select + await firstAnswerOption.click(); // select + await firstAnswerOption.click(); // deselect + await firstAnswerOption.click(); // select const secondAnswerOption = await element(by.id(`answer-option-1`)); expect(secondAnswerOption.isPresent()); - await secondAnswerOption.click(); //select - await secondAnswerOption.click(); //deselect + await secondAnswerOption.click(); // select + await secondAnswerOption.click(); // deselect - //submit quiz + // submit quiz const submitQuizButton = await element(by.id(`submit-quiz`)); expect(submitQuizButton.isPresent()); await submitQuizButton.click(); - //wait until the quiz has finished + // wait until the quiz has finished await expect(browser.wait(ec.visibilityOf(element(by.id('quiz-score'))), 15000)).to.become(true); await element(by.id('quiz-score-result')) @@ -163,7 +162,7 @@ describe('quiz-exercise', function () { .then((text) => { expect(text).equals('Correct'); }) - .catch((error) => { + .catch(() => { expect.fail('first answer option not found as correct'); }); @@ -172,7 +171,7 @@ describe('quiz-exercise', function () { .then((text) => { expect(text).equals('Wrong'); }) - .catch((error) => { + .catch(() => { expect.fail('second answer option not found as correct'); }); @@ -182,7 +181,7 @@ describe('quiz-exercise', function () { it('delete quiz', async function () { browser.waitForAngularEnabled(false); await browser.sleep(500); // let's wait shortly so that the server gets everything right with the database - //navigate to course administration + // navigate to course administration await navBarPage.clickOnCourseAdminMenu(); browser.wait(ec.urlContains(`course`), 1000).then((result: any) => expect(result).to.be.true); @@ -198,11 +197,11 @@ describe('quiz-exercise', function () { // expect(createQuizButton.isPresent()); await createQuizButton.click(); - //set title of SA quiz + // set title of SA quiz const title = element(by.id('quiz-title')); title.sendKeys('test-SA-quiz'); - //set duration of quiz + // set duration of quiz const durationMinutes = await element(by.id('quiz-duration-minutes')); durationMinutes.clear(); durationMinutes.sendKeys('0'); @@ -210,12 +209,12 @@ describe('quiz-exercise', function () { durationSeconds.clear(); durationSeconds.sendKeys('5'); - //add short answer question + // add short answer question const addShortAnswerButton = await element(by.id('quiz-add-short-answer-question')); await addShortAnswerButton.click(); // set title of short answer question - const shortAnswerQuestionTitle = await element(by.id('short-answer-question-title')); //TODO: we need to support multiple questions + const shortAnswerQuestionTitle = await element(by.id('short-answer-question-title')); // TODO: we need to support multiple questions shortAnswerQuestionTitle.sendKeys('test-short-answer'); const quizSaveButton = await element(by.id('quiz-save')); @@ -226,16 +225,16 @@ describe('quiz-exercise', function () { const backButton = await element(by.id('quiz-cancel-back-button')); expect(backButton.isPresent()); - //TODO: check that the button name is "Back" + // TODO: check that the button name is "Back" await backButton.click(); await browser .switchTo() .alert() .then((alert: any) => alert.accept()) - .catch((reason: any) => expect.fail('Did not show Alert on unsaed changes!')); + .catch(() => expect.fail('Did not show Alert on unsaved changes!')); - //TODO: check that we leave the page and there is a new entry + // TODO: check that we leave the page and there is a new entry }); after(async function () { @@ -245,7 +244,7 @@ describe('quiz-exercise', function () { await navBarPage.clickOnCourseAdminMenu(); browser.waitForAngularEnabled(true); - //Delete course + // Delete course let rows = element.all(by.tagName('tbody')).all(by.tagName('tr')); const numberOfCourses = await rows.count(); diff --git a/src/test/javascript/spec/app/account/password-reset/finish/password-reset-finish.component.spec.ts b/src/test/javascript/spec/app/account/password-reset/finish/password-reset-finish.component.spec.ts index aa13f52f56d8..24816fb17a8c 100644 --- a/src/test/javascript/spec/app/account/password-reset/finish/password-reset-finish.component.spec.ts +++ b/src/test/javascript/spec/app/account/password-reset/finish/password-reset-finish.component.spec.ts @@ -25,7 +25,7 @@ describe('Component Tests', () => { { provide: Renderer2, useValue: { - invokeElementMethod(renderElement: any, methodName: string, args?: any[]) {}, + invokeElementMethod() {}, }, }, { diff --git a/src/test/javascript/spec/app/account/password-reset/init/password-reset-init.component.spec.ts b/src/test/javascript/spec/app/account/password-reset/init/password-reset-init.component.spec.ts index 322000a79ca0..e8a2ab7b8ee7 100644 --- a/src/test/javascript/spec/app/account/password-reset/init/password-reset-init.component.spec.ts +++ b/src/test/javascript/spec/app/account/password-reset/init/password-reset-init.component.spec.ts @@ -20,7 +20,7 @@ describe('Component Tests', () => { { provide: Renderer2, useValue: { - invokeElementMethod(renderElement: any, methodName: string, args?: any[]) {}, + invokeElementMethod() {}, }, }, { From 69c841e07c97a89ba7527bbba1f0c6e94cd0af0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Lei=C3=9F?= Date: Tue, 14 Apr 2020 17:30:01 +0200 Subject: [PATCH 007/152] Fix more style errors. --- src/main/webapp/app/shared/result/result-detail.component.ts | 1 - src/test/javascript/e2e/account/account.spec.ts | 2 +- src/test/javascript/e2e/quiz-exercise/quiz-exericse.spec.ts | 3 +-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/webapp/app/shared/result/result-detail.component.ts b/src/main/webapp/app/shared/result/result-detail.component.ts index 13917ef226c0..0317ec611947 100644 --- a/src/main/webapp/app/shared/result/result-detail.component.ts +++ b/src/main/webapp/app/shared/result/result-detail.component.ts @@ -2,7 +2,6 @@ import { Component, Input, OnInit } from '@angular/core'; import { RepositoryService } from 'app/shared/result/repository.service'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { catchError, map, switchMap, tap } from 'rxjs/operators'; -import { HttpErrorResponse } from '@angular/common/http'; import { of } from 'rxjs'; import { BuildLogEntry, BuildLogEntryArray, BuildLogType } from 'app/entities/build-log.model'; import { Feedback } from 'app/entities/feedback.model'; diff --git a/src/test/javascript/e2e/account/account.spec.ts b/src/test/javascript/e2e/account/account.spec.ts index 6e3a2b81c102..bf64095e682e 100644 --- a/src/test/javascript/e2e/account/account.spec.ts +++ b/src/test/javascript/e2e/account/account.spec.ts @@ -1,6 +1,6 @@ import { browser, by, element, ExpectedConditions as ec } from 'protractor'; -import { NavBarPage, SettingsPage, SignInPage } from '../page-objects/jhi-page-objects'; +import { NavBarPage, SignInPage } from '../page-objects/jhi-page-objects'; const expect = chai.expect; diff --git a/src/test/javascript/e2e/quiz-exercise/quiz-exericse.spec.ts b/src/test/javascript/e2e/quiz-exercise/quiz-exericse.spec.ts index 5d882dd6d850..48fcde731482 100644 --- a/src/test/javascript/e2e/quiz-exercise/quiz-exericse.spec.ts +++ b/src/test/javascript/e2e/quiz-exercise/quiz-exericse.spec.ts @@ -1,7 +1,6 @@ import { NavBarPage, SignInPage } from '../page-objects/jhi-page-objects'; import { browser, by, element, ExpectedConditions as ec } from 'protractor'; import { CoursePage, NewCoursePage } from '../page-objects/entities/course-page-object'; -import { QuizExercisePage } from '../page-objects/entities/quiz-exercise-page-object'; const expect = chai.expect; @@ -73,7 +72,7 @@ describe('quiz-exercise', function () { await addMcButton.click(); // set title of mc question - const mcQuestionTitle = await element(by.id('mc-question-title')); //TODO: we need to support multiple questions + const mcQuestionTitle = await element(by.id('mc-question-title')); // TODO: we need to support multiple questions mcQuestionTitle.sendKeys('test-mc'); // deactivate random order to make the test case deterministic From 093f9dca6a310aa1d50b89351b250c7d61f8fa2f Mon Sep 17 00:00:00 2001 From: Jonas Petry Date: Tue, 14 Apr 2020 18:06:19 +0200 Subject: [PATCH 008/152] fix batch of codestyle issues --- .../textblock-feedback-editor.spec.ts | 1 - .../spec/helpers/mock-language.service.ts | 6 +++--- .../code-editor/code-editor-instructor.spec.ts | 3 +-- .../code-editor/code-editor-student.spec.ts | 15 +++++++-------- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/test/javascript/spec/component/text-submission-assessment/textblock-feedback-editor.spec.ts b/src/test/javascript/spec/component/text-submission-assessment/textblock-feedback-editor.spec.ts index a96d524a9cc6..cb3c3f9745f0 100644 --- a/src/test/javascript/spec/component/text-submission-assessment/textblock-feedback-editor.spec.ts +++ b/src/test/javascript/spec/component/text-submission-assessment/textblock-feedback-editor.spec.ts @@ -8,7 +8,6 @@ import { ArtemisConfirmIconModule } from 'app/shared/confirm-icon/confirm-icon.m import { TranslateModule } from '@ngx-translate/core'; import { MockComponent } from 'ng-mocks'; import { FaIconComponent } from '@fortawesome/angular-fontawesome'; -import { By } from '@angular/platform-browser'; describe('TextblockFeedbackEditorComponent', () => { let component: TextblockFeedbackEditorComponent; diff --git a/src/test/javascript/spec/helpers/mock-language.service.ts b/src/test/javascript/spec/helpers/mock-language.service.ts index 4bb69f6d765c..0771817ab031 100644 --- a/src/test/javascript/spec/helpers/mock-language.service.ts +++ b/src/test/javascript/spec/helpers/mock-language.service.ts @@ -17,11 +17,11 @@ export class MockLanguageService extends SpyObject { init() {} - changeLanguage(languageKey: string) {} + changeLanguage(languageKey: string) {} // eslint-disable-line no-unused-vars - setLocations(locations: string[]) {} + setLocations(locations: string[]) {} // eslint-disable-line no-unused-vars - addLocation(location: string) {} + addLocation(location: string) {} // eslint-disable-line no-unused-vars reload() {} } diff --git a/src/test/javascript/spec/integration/code-editor/code-editor-instructor.spec.ts b/src/test/javascript/spec/integration/code-editor/code-editor-instructor.spec.ts index 330d92cd120b..252fcf4f6ddf 100644 --- a/src/test/javascript/spec/integration/code-editor/code-editor-instructor.spec.ts +++ b/src/test/javascript/spec/integration/code-editor/code-editor-instructor.spec.ts @@ -76,7 +76,6 @@ describe('CodeEditorInstructorIntegration', () => { let domainService: DomainService; let exerciseHintService: IExerciseHintService; let route: ActivatedRoute; - let router: Router; let checkIfRepositoryIsCleanStub: SinonStub; let getRepositoryContentStub: SinonStub; @@ -145,7 +144,7 @@ describe('CodeEditorInstructorIntegration', () => { domainService = containerDebugElement.injector.get(DomainService); exerciseHintService = containerDebugElement.injector.get(ExerciseHintService); route = containerDebugElement.injector.get(ActivatedRoute); - router = containerDebugElement.injector.get(Router); + containerDebugElement.injector.get(Router); checkIfRepositoryIsCleanSubject = new Subject<{ isClean: boolean }>(); getRepositoryContentSubject = new Subject<{ [fileName: string]: FileType }>(); diff --git a/src/test/javascript/spec/integration/code-editor/code-editor-student.spec.ts b/src/test/javascript/spec/integration/code-editor/code-editor-student.spec.ts index 24df29602a7c..f7a7dec32e9a 100644 --- a/src/test/javascript/spec/integration/code-editor/code-editor-student.spec.ts +++ b/src/test/javascript/spec/integration/code-editor/code-editor-student.spec.ts @@ -440,7 +440,7 @@ describe('CodeEditorStudentIntegration', () => { it('should wait for build result after submission if no unsaved changes exist', () => { cleanInitialize(); - const result = { id: 4, successful: true, feedbacks: [] as Feedback[], participation: { id: 3 } } as Result; + const successfulResult = { id: 4, successful: true, feedbacks: [] as Feedback[], participation: { id: 3 } } as Result; const expectedBuildLog = new BuildLogEntryArray(); expect(container.unsavedFiles).to.be.empty; container.commitState = CommitState.UNCOMMITTED_CHANGES; @@ -452,21 +452,21 @@ describe('CodeEditorStudentIntegration', () => { getLatestPendingSubmissionSubject.next({ submissionState: ProgrammingSubmissionState.IS_BUILDING_PENDING_SUBMISSION, submission: {} as ProgrammingSubmission, - participationId: result!.participation!.id, + participationId: successfulResult!.participation!.id, }); container.actions.commit(); containerFixture.detectChanges(); - // waiting for build result + // waiting for build successfulResult expect(container.commitState).to.equal(CommitState.CLEAN); expect(container.buildOutput.isBuilding).to.be.true; getLatestPendingSubmissionSubject.next({ submissionState: ProgrammingSubmissionState.HAS_NO_PENDING_SUBMISSION, submission: null, - participationId: result!.participation!.id, + participationId: successfulResult!.participation!.id, }); - subscribeForLatestResultOfParticipationSubject.next(result); + subscribeForLatestResultOfParticipationSubject.next(successfulResult); containerFixture.detectChanges(); expect(container.buildOutput.isBuilding).to.be.false; @@ -603,9 +603,8 @@ describe('CodeEditorStudentIntegration', () => { spyOn(guidedTourService, 'checkTourState').and.returnValue(true); guidedTourService.guidedTourMapping = guidedTourMapping; container.ngOnInit(); - const exercise = { id: 1, problemStatement }; - const result = { id: 3, successful: false }; - const participation = { id: 1, results: [result], exercise: { id: 99 } } as Participation; + const successfulResult = { id: 3, successful: false }; + const participation = { id: 1, results: [successfulResult], exercise: { id: 99 } } as Participation; const feedbacks = [{ id: 2 }] as Feedback[]; const findWithLatestResultSubject = new Subject(); const getFeedbackDetailsForResultSubject = new Subject<{ body: Feedback[] }>(); From 10f09b1cd1a6ece91da03b0a224e0ab34da0ecb1 Mon Sep 17 00:00:00 2001 From: Filip Gregurevic Date: Tue, 14 Apr 2020 18:22:40 +0200 Subject: [PATCH 009/152] remove some unused declarations --- .../guided-tour/guided-tour.component.spec.ts | 9 ++------- .../spec/component/lecture/lecture-attachments.spec.ts | 2 +- .../modeling-submission.component.spec.ts | 2 +- .../course-statistics/course-statistics.spec.ts | 10 ---------- 4 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/test/javascript/spec/component/guided-tour/guided-tour.component.spec.ts b/src/test/javascript/spec/component/guided-tour/guided-tour.component.spec.ts index 64daea4c9812..a55525305149 100644 --- a/src/test/javascript/spec/component/guided-tour/guided-tour.component.spec.ts +++ b/src/test/javascript/spec/component/guided-tour/guided-tour.component.spec.ts @@ -1,8 +1,7 @@ import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; -import { DebugElement, NO_ERRORS_SCHEMA } from '@angular/core'; -import { ComponentFixture, TestBed, inject, fakeAsync } from '@angular/core/testing'; -import { Router } from '@angular/router'; +import { NO_ERRORS_SCHEMA } from '@angular/core'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { CookieService } from 'ngx-cookie-service'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; @@ -61,9 +60,7 @@ describe('GuidedTourComponent', () => { let guidedTourComponent: GuidedTourComponent; let guidedTourComponentFixture: ComponentFixture; - let guidedTourDebugElement: DebugElement; let guidedTourService: GuidedTourService; - let router: Router; beforeEach(() => { TestBed.configureTestingModule({ @@ -92,9 +89,7 @@ describe('GuidedTourComponent', () => { .then(() => { guidedTourComponentFixture = TestBed.createComponent(GuidedTourComponent); guidedTourComponent = guidedTourComponentFixture.componentInstance; - guidedTourDebugElement = guidedTourComponentFixture.debugElement; guidedTourService = TestBed.inject(GuidedTourService); - router = TestBed.inject(Router); }); }); diff --git a/src/test/javascript/spec/component/lecture/lecture-attachments.spec.ts b/src/test/javascript/spec/component/lecture/lecture-attachments.spec.ts index dbed8a68f517..429ad2bdf12b 100644 --- a/src/test/javascript/spec/component/lecture/lecture-attachments.spec.ts +++ b/src/test/javascript/spec/component/lecture/lecture-attachments.spec.ts @@ -150,7 +150,7 @@ describe('LectureAttachmentsComponent', () => { expect(comp.attachments.length).to.equal(3); })); - it('should not accept too large file', fakeAsync((done: Function) => { + it('should not accept too large file', fakeAsync(() => { fixture.detectChanges(); const addAttachmentButton = fixture.debugElement.query(By.css('#add-attachment')); expect(comp.attachmentToBeCreated).to.be.undefined; diff --git a/src/test/javascript/spec/component/modeling-submission/modeling-submission.component.spec.ts b/src/test/javascript/spec/component/modeling-submission/modeling-submission.component.spec.ts index e3600f335b4a..ba4e98e785e5 100644 --- a/src/test/javascript/spec/component/modeling-submission/modeling-submission.component.spec.ts +++ b/src/test/javascript/spec/component/modeling-submission/modeling-submission.component.spec.ts @@ -178,7 +178,7 @@ describe('Component Tests', () => { it('should navigate to access denied page on 403 error status', () => { sinon.replace(service, 'getLatestSubmissionForModelingEditor', sinon.fake.returns(throwError({ status: 403 }))); const spy = stub(router, 'navigate'); - spy.returns(new Promise((resolve) => true)); + spy.returns(new Promise(() => true)); fixture.detectChanges(); expect(spy.called).to.be.true; }); diff --git a/src/test/javascript/spec/component/overview/course-statistics/course-statistics.spec.ts b/src/test/javascript/spec/component/overview/course-statistics/course-statistics.spec.ts index b2d59192d532..c8fc1765caaf 100644 --- a/src/test/javascript/spec/component/overview/course-statistics/course-statistics.spec.ts +++ b/src/test/javascript/spec/component/overview/course-statistics/course-statistics.spec.ts @@ -17,7 +17,6 @@ import { Result } from 'app/entities/result.model'; import { CourseScoreCalculationService } from 'app/overview/course-score-calculation.service'; import { ProgrammingSubmission } from 'app/entities/programming-submission.model'; import { ModelingExercise } from 'app/entities/modeling-exercise.model'; -import { Attachment } from 'app/entities/attachment.model'; import { SubmissionExerciseType } from 'app/entities/submission.model'; import { CourseStatisticsComponent } from 'app/overview/course-statistics/course-statistics.component'; @@ -153,15 +152,6 @@ describe('CourseStatisticsComponent', () => { course.exercises = []; course.presentationScore = 1; - const newAttachment = { - id: 53, - name: 'TestFile', - link: '/api/files/attachments/lecture/4/Mein_Test_PDF3.pdf', - version: 1, - uploadDate: moment('2019-05-07T08:49:59+02:00'), - attachmentType: 'FILE', - } as Attachment; - beforeEach(async () => { return TestBed.configureTestingModule({ imports: [TranslateModule.forRoot(), ArtemisTestModule, TreeviewModule.forRoot(), RouterTestingModule.withRoutes([]), ArtemisSharedModule, ChartsModule], From 057426cc67e08236280a0465ddbc751a61b11aad Mon Sep 17 00:00:00 2001 From: Filip Gregurevic Date: Tue, 14 Apr 2020 18:33:54 +0200 Subject: [PATCH 010/152] fixed all unused declarations --- .../spec/component/overview/overview.component.spec.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/test/javascript/spec/component/overview/overview.component.spec.ts b/src/test/javascript/spec/component/overview/overview.component.spec.ts index d1e27c766be0..8dd57e7607c7 100644 --- a/src/test/javascript/spec/component/overview/overview.component.spec.ts +++ b/src/test/javascript/spec/component/overview/overview.component.spec.ts @@ -2,7 +2,6 @@ import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; -import { Router } from '@angular/router'; import { of } from 'rxjs'; import { CookieService } from 'ngx-cookie-service'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; @@ -16,7 +15,6 @@ import { MockSyncStorage } from '../../mocks/mock-sync.storage'; import { MockCookieService } from '../../mocks/mock-cookie.service'; import { RouterTestingModule } from '@angular/router/testing'; import { courseOverviewTour } from 'app/guided-tour/tours/course-overview-tour'; -import { CourseExerciseService } from 'app/course/manage/course-management.service'; import { CoursesComponent } from 'app/overview/courses.component'; import { TranslateTestingModule } from '../../mocks/mock-translate.service'; import { NavbarComponent } from 'app/shared/layouts/navbar/navbar.component'; @@ -47,13 +45,10 @@ describe('Courses Component', () => { let navBarComponentFixture: ComponentFixture; let courseCardComponent: CourseCardComponent; let courseCardComponentFixture: ComponentFixture; - let footerComponent: FooterComponent; let footerComponentFixture: ComponentFixture; let guidedTourService: GuidedTourService; - let courseExerciseService: CourseExerciseService; let exerciseService: ExerciseService; - let router: Router; beforeEach(() => { TestBed.configureTestingModule({ @@ -90,11 +85,8 @@ describe('Courses Component', () => { guidedTourComponent = guidedTourComponentFixture.componentInstance; navBarComponent = navBarComponentFixture.componentInstance; courseCardComponent = courseCardComponentFixture.componentInstance; - footerComponent = footerComponentFixture.componentInstance; - router = TestBed.inject(Router); guidedTourService = TestBed.inject(GuidedTourService); - courseExerciseService = TestBed.inject(CourseExerciseService); exerciseService = TestBed.inject(ExerciseService); spyOn(courseCardComponent, 'displayTotalRelativeScore').and.returnValue(of()); From fb636de38cbf8d34cc19aecb3e3f3a74abf06f3b Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Wed, 15 Apr 2020 13:05:15 +0200 Subject: [PATCH 011/152] Fix code style issues --- .../notification-management-update.component.ts | 6 +++--- .../notification-management.route.ts | 5 ++--- .../user-management-update.component.ts | 6 +++--- .../admin/user-management/user-management.route.ts | 3 +-- .../list-of-complaints.component.ts | 2 +- .../app/core/auth/user-route-access-service.ts | 2 +- .../app/core/interceptor/auth-expired.interceptor.ts | 2 +- .../app/core/interceptor/errorhandler.interceptor.ts | 2 +- src/main/webapp/app/core/login/login.service.ts | 2 +- .../webapp/app/core/websocket/websocket.service.ts | 4 ++-- .../course/course-scores/course-scores.component.ts | 2 +- .../app/course/manage/course-group.component.ts | 6 ++---- .../app/course/manage/course-management.route.ts | 4 ++-- .../app/course/manage/course-update.component.ts | 4 ++-- .../assess/file-upload-assessment.component.ts | 2 +- .../manage/file-upload-exercise-management.route.ts | 7 +++---- .../manage/file-upload-exercise-update.component.ts | 4 ++-- .../modeling-assessment-conflict.component.ts | 8 ++++---- .../modeling-assessment-dashboard.component.ts | 2 +- .../modeling-assessment-editor.component.ts | 4 ++-- .../modeling/assess/modeling-assessment.service.ts | 2 +- .../example-modeling-submission.component.ts | 4 ++-- .../manage/modeling-exercise-update.component.ts | 12 ++++++------ .../modeling/manage/modeling-exercise.route.ts | 4 ++-- ...amming-assessment-repo-export-dialog.component.ts | 10 ++++------ ...programming-exercise-management-routing.module.ts | 4 ++-- ...ogramming-exercise-manage-test-cases.component.ts | 4 ++-- ...g-exercise-test-schedule-date-picker.component.ts | 4 ++-- .../update/programming-exercise-update.component.ts | 2 +- .../code-editor-student-container.component.ts | 2 +- .../participate/programming-submission.service.ts | 4 ++-- .../programming-exercise-instruction.service.ts | 1 - .../shared/programming-exercise.component.ts | 2 +- .../apollon-diagram-create-form.component.ts | 2 +- .../apollon-diagram-list.component.ts | 2 +- 35 files changed, 64 insertions(+), 72 deletions(-) diff --git a/src/main/webapp/app/admin/notification-management/notification-management-update.component.ts b/src/main/webapp/app/admin/notification-management/notification-management-update.component.ts index 5700a9da5166..0ffdce0c497c 100644 --- a/src/main/webapp/app/admin/notification-management/notification-management-update.component.ts +++ b/src/main/webapp/app/admin/notification-management/notification-management-update.component.ts @@ -43,18 +43,18 @@ export class NotificationMgmtUpdateComponent implements OnInit { this.isSaving = true; if (this.notification.id) { this.systemNotificationService.update(this.notification).subscribe( - (response) => this.onSaveSuccess(response.body!), + (response) => this.onSaveSuccess(), () => this.onSaveError(), ); } else { this.systemNotificationService.create(this.notification).subscribe( - (response) => this.onSaveSuccess(response.body!), + (response) => this.onSaveSuccess(), () => this.onSaveError(), ); } } - private onSaveSuccess(result: SystemNotification) { + private onSaveSuccess() { this.isSaving = false; this.previousState(); } diff --git a/src/main/webapp/app/admin/notification-management/notification-management.route.ts b/src/main/webapp/app/admin/notification-management/notification-management.route.ts index 78387ccdc14f..994fcd4042b6 100644 --- a/src/main/webapp/app/admin/notification-management/notification-management.route.ts +++ b/src/main/webapp/app/admin/notification-management/notification-management.route.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { ActivatedRouteSnapshot, Resolve, Route, RouterStateSnapshot } from '@angular/router'; +import { ActivatedRouteSnapshot, Resolve, Route } from '@angular/router'; import { JhiResolvePagingParams } from 'ng-jhipster'; import { NotificationMgmtUpdateComponent } from 'app/admin/notification-management/notification-management-update.component'; import { SystemNotification } from 'app/entities/system-notification.model'; @@ -14,9 +14,8 @@ export class NotificationMgmtResolve implements Resolve { /** * Resolves the route and initializes system notification from id route param * @param route - * @param state */ - resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { + resolve(route: ActivatedRouteSnapshot) { const id = route.params['id'] ? route.params['id'] : null; if (id) { return this.service.find(parseInt(id, 10)); diff --git a/src/main/webapp/app/admin/user-management/user-management-update.component.ts b/src/main/webapp/app/admin/user-management/user-management-update.component.ts index 3d579ab301e9..a361521721a1 100644 --- a/src/main/webapp/app/admin/user-management/user-management-update.component.ts +++ b/src/main/webapp/app/admin/user-management/user-management-update.component.ts @@ -51,12 +51,12 @@ export class UserManagementUpdateComponent implements OnInit { this.isSaving = true; if (this.user.id !== null) { this.userService.update(this.user).subscribe( - (response) => this.onSaveSuccess(response.body!), + (response) => this.onSaveSuccess(), () => this.onSaveError(), ); } else { this.userService.create(this.user).subscribe( - (response) => this.onSaveSuccess(response.body!), + (response) => this.onSaveSuccess(), () => this.onSaveError(), ); } @@ -66,7 +66,7 @@ export class UserManagementUpdateComponent implements OnInit { * Set isSaving to false and navigate to previous page * @param result */ - private onSaveSuccess(result: User) { + private onSaveSuccess() { this.isSaving = false; this.previousState(); } diff --git a/src/main/webapp/app/admin/user-management/user-management.route.ts b/src/main/webapp/app/admin/user-management/user-management.route.ts index a84cb7f5bf3e..88260f4aacb4 100644 --- a/src/main/webapp/app/admin/user-management/user-management.route.ts +++ b/src/main/webapp/app/admin/user-management/user-management.route.ts @@ -14,9 +14,8 @@ export class UserMgmtResolve implements Resolve { /** * Resolve route to find the user before the route is activated * @param route contains the information about a route associated with a component loaded in an outlet at a particular moment in time - * @param state represents the state of the router at a moment in time */ - resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { + resolve(route: ActivatedRouteSnapshot) { const login = route.params['login'] ? route.params['login'] : null; if (login) { return this.userService.find(login); diff --git a/src/main/webapp/app/complaints/list-of-complaints/list-of-complaints.component.ts b/src/main/webapp/app/complaints/list-of-complaints/list-of-complaints.component.ts index 0b57d7aa8866..b666bccdeed3 100644 --- a/src/main/webapp/app/complaints/list-of-complaints/list-of-complaints.component.ts +++ b/src/main/webapp/app/complaints/list-of-complaints/list-of-complaints.component.ts @@ -115,7 +115,7 @@ export class ListOfComplaintsComponent implements OnInit { modalRef.componentInstance.result = cloneDeep(complaint.result); modalRef.componentInstance.onResultModified.subscribe(() => this.loadComplaints()); modalRef.result.then( - (_) => this.loadComplaints(), + () => this.loadComplaints(), () => {}, ); return; diff --git a/src/main/webapp/app/core/auth/user-route-access-service.ts b/src/main/webapp/app/core/auth/user-route-access-service.ts index 8fdcc2a65086..3c3ad6566ee7 100644 --- a/src/main/webapp/app/core/auth/user-route-access-service.ts +++ b/src/main/webapp/app/core/auth/user-route-access-service.ts @@ -4,7 +4,7 @@ import { LocalStorageService } from 'ngx-webstorage'; import { AccountService } from 'app/core/auth/account.service'; import { StateStorageService } from 'app/core/auth/state-storage.service'; import { OrionVersionValidator } from 'app/shared/orion/outdated-plugin-warning/orion-version-validator.service'; -import { filter, first, switchMap } from 'rxjs/operators'; +import { first, switchMap } from 'rxjs/operators'; import { from, of } from 'rxjs'; @Injectable({ providedIn: 'root' }) diff --git a/src/main/webapp/app/core/interceptor/auth-expired.interceptor.ts b/src/main/webapp/app/core/interceptor/auth-expired.interceptor.ts index 399e3406563b..f9a5c38b491c 100644 --- a/src/main/webapp/app/core/interceptor/auth-expired.interceptor.ts +++ b/src/main/webapp/app/core/interceptor/auth-expired.interceptor.ts @@ -11,7 +11,7 @@ export class AuthExpiredInterceptor implements HttpInterceptor { intercept(request: HttpRequest, next: HttpHandler): Observable> { return next.handle(request).pipe( tap( - (event: HttpEvent) => {}, + () => {}, (err: any) => { if (err instanceof HttpErrorResponse) { if (err.status === 401) { diff --git a/src/main/webapp/app/core/interceptor/errorhandler.interceptor.ts b/src/main/webapp/app/core/interceptor/errorhandler.interceptor.ts index 1d5014a69ab9..e7b25806a3e3 100644 --- a/src/main/webapp/app/core/interceptor/errorhandler.interceptor.ts +++ b/src/main/webapp/app/core/interceptor/errorhandler.interceptor.ts @@ -11,7 +11,7 @@ export class ErrorHandlerInterceptor implements HttpInterceptor { intercept(request: HttpRequest, next: HttpHandler): Observable> { return next.handle(request).pipe( tap( - (event: HttpEvent) => {}, + () => {}, (err: any) => { if (err instanceof HttpErrorResponse) { if (!(err.status === 401 && (err.message === '' || (err.url && err.url.includes('/api/account'))))) { diff --git a/src/main/webapp/app/core/login/login.service.ts b/src/main/webapp/app/core/login/login.service.ts index ca2b85b3d0ba..631e251858c3 100644 --- a/src/main/webapp/app/core/login/login.service.ts +++ b/src/main/webapp/app/core/login/login.service.ts @@ -24,7 +24,7 @@ export class LoginService { return new Promise((resolve, reject) => { this.authServerProvider.login(credentials).subscribe( (data) => { - this.accountService.identity(true).then((user) => { + this.accountService.identity(true).then(() => { this.websocketService.sendActivity(); resolve(data); }); diff --git a/src/main/webapp/app/core/websocket/websocket.service.ts b/src/main/webapp/app/core/websocket/websocket.service.ts index 36f71bebe2d0..3552779eea84 100644 --- a/src/main/webapp/app/core/websocket/websocket.service.ts +++ b/src/main/webapp/app/core/websocket/websocket.service.ts @@ -107,7 +107,7 @@ export class JhiWebsocketService implements IWebsocketService, OnDestroy { }; this.stompClient = over(socket, options); // Note: at the moment, debugging is deactivated to prevent console log statements - this.stompClient.debug = function (str) {}; + this.stompClient.debug = function () {}; const headers = {}; headers['X-CSRF-TOKEN'] = this.csrfService.getCSRF(); @@ -148,7 +148,7 @@ export class JhiWebsocketService implements IWebsocketService, OnDestroy { // Setup periodic logs of websocket connection numbers this.logTimers.push( - timer(0, 60000).subscribe((x) => { + timer(0, 60000).subscribe(() => { console.log('\n\n'); console.log(`${this.subscribers.size} websocket subscriptions: `, this.subscribers.keys()); // this.subscribers.forEach((sub, topic) => console.log(topic)); diff --git a/src/main/webapp/app/course/course-scores/course-scores.component.ts b/src/main/webapp/app/course/course-scores/course-scores.component.ts index e269609f60b5..a71e2fbc5e2e 100644 --- a/src/main/webapp/app/course/course-scores/course-scores.component.ts +++ b/src/main/webapp/app/course/course-scores/course-scores.component.ts @@ -404,7 +404,7 @@ export class CourseScoresComponent implements OnInit, OnDestroy { if (this.exerciseTitlesPerType.get(exerciseType) && this.exerciseTitlesPerType.get(exerciseType)!.length !== 0) { const exerciseTypeName = capitalizeFirstLetter(exerciseType); const exerciseTitleKeys = this.exerciseTitlesPerType.get(exerciseType)!; - exerciseTitleKeys.forEach((title, index) => { + exerciseTitleKeys.forEach((title) => { emptyLine[title] = ''; }); emptyLine[exerciseTypeName + ' ' + POINTS_KEY] = ''; diff --git a/src/main/webapp/app/course/manage/course-group.component.ts b/src/main/webapp/app/course/manage/course-group.component.ts index 3c638dadb8a3..07b8c2b06d4d 100644 --- a/src/main/webapp/app/course/manage/course-group.component.ts +++ b/src/main/webapp/app/course/manage/course-group.component.ts @@ -157,7 +157,7 @@ export class CourseGroupComponent implements OnInit, OnDestroy { // Flash green background color to signal to the user that this record was added this.flashRowClass(cssClasses.newlyAddedMember); }, - (err) => { + () => { this.isTransitioning = false; }, ); @@ -237,10 +237,8 @@ export class CourseGroupComponent implements OnInit, OnDestroy { /** * Computes the row class that is being added to all rows of the datatable - * - * @param row Row from ngx datatable */ - dataTableRowClass = (row: any) => { + dataTableRowClass = () => { return this.rowClass; }; diff --git a/src/main/webapp/app/course/manage/course-management.route.ts b/src/main/webapp/app/course/manage/course-management.route.ts index 9a059ba64873..d90cae5f8d34 100644 --- a/src/main/webapp/app/course/manage/course-management.route.ts +++ b/src/main/webapp/app/course/manage/course-management.route.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; import { HttpResponse } from '@angular/common/http'; -import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot, Routes } from '@angular/router'; +import { ActivatedRouteSnapshot, Resolve, Routes } from '@angular/router'; import { UserRouteAccessService } from 'app/core/auth/user-route-access-service'; import { Observable, of } from 'rxjs'; import { filter, map } from 'rxjs/operators'; @@ -16,7 +16,7 @@ import { CourseGroupComponent } from 'app/course/manage/course-group.component'; export class CourseResolve implements Resolve { constructor(private service: CourseManagementService) {} - resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { + resolve(route: ActivatedRouteSnapshot): Observable { const id = route.params['courseId'] ? route.params['courseId'] : null; if (id) { return this.service.find(id).pipe( diff --git a/src/main/webapp/app/course/manage/course-update.component.ts b/src/main/webapp/app/course/manage/course-update.component.ts index 32c1f41d197f..85d2946f1c2d 100644 --- a/src/main/webapp/app/course/manage/course-update.component.ts +++ b/src/main/webapp/app/course/manage/course-update.component.ts @@ -145,7 +145,7 @@ export class CourseUpdateComponent implements OnInit { private subscribeToSaveResponse(result: Observable>) { result.subscribe( - (res: HttpResponse) => this.onSaveSuccess(), + () => this.onSaveSuccess(), (res: HttpErrorResponse) => this.onSaveError(res), ); } @@ -197,7 +197,7 @@ export class CourseUpdateComponent implements OnInit { this.courseImageFile = null; this.courseImageFileName = result.path; }, - (error) => { + () => { this.isUploadingCourseImage = false; this.courseImageFile = null; this.courseImageFileName = this.course.courseIcon; diff --git a/src/main/webapp/app/exercises/file-upload/assess/file-upload-assessment.component.ts b/src/main/webapp/app/exercises/file-upload/assess/file-upload-assessment.component.ts index eba8f82ba264..bbede5003f52 100644 --- a/src/main/webapp/app/exercises/file-upload/assess/file-upload-assessment.component.ts +++ b/src/main/webapp/app/exercises/file-upload/assess/file-upload-assessment.component.ts @@ -467,7 +467,7 @@ export class FileUploadAssessmentComponent implements OnInit, AfterViewInit, OnD this.jhiAlertService.clear(); this.jhiAlertService.success('artemisApp.assessment.messages.updateAfterComplaintSuccessful'); }, - (error: HttpErrorResponse) => { + () => { this.jhiAlertService.clear(); this.jhiAlertService.error('artemisApp.assessment.messages.updateAfterComplaintFailed'); }, diff --git a/src/main/webapp/app/exercises/file-upload/manage/file-upload-exercise-management.route.ts b/src/main/webapp/app/exercises/file-upload/manage/file-upload-exercise-management.route.ts index f106603b5720..c74d25cee62d 100644 --- a/src/main/webapp/app/exercises/file-upload/manage/file-upload-exercise-management.route.ts +++ b/src/main/webapp/app/exercises/file-upload/manage/file-upload-exercise-management.route.ts @@ -1,4 +1,4 @@ -import { ActivatedRouteSnapshot, Resolve, RouterModule, RouterStateSnapshot, Routes } from '@angular/router'; +import { ActivatedRouteSnapshot, Resolve, RouterModule, Routes } from '@angular/router'; import { UserRouteAccessService } from 'app/core/auth/user-route-access-service'; import { FileUploadExerciseComponent } from './file-upload-exercise.component'; import { FileUploadExerciseDetailComponent } from './file-upload-exercise-detail.component'; @@ -9,7 +9,7 @@ import { Injectable, NgModule } from '@angular/core'; import { filter, map } from 'rxjs/operators'; import { FileUploadExerciseService } from 'app/exercises/file-upload/manage/file-upload-exercise.service'; import { FileUploadExerciseUpdateComponent } from 'app/exercises/file-upload/manage/file-upload-exercise-update.component'; -import { CourseManagementService } from '../../../course/manage/course-management.service'; +import { CourseManagementService } from 'app/course/manage/course-management.service'; import { Course } from 'app/entities/course.model'; @Injectable({ providedIn: 'root' }) @@ -20,9 +20,8 @@ export class FileUploadExerciseResolve implements Resolve { * Resolves the route and initializes file upload exercise either from exerciseId (existing exercise) or * from course id (new exercise) * @param route - * @param state */ - resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { + resolve(route: ActivatedRouteSnapshot) { if (route.params['exerciseId']) { return this.fileUploadExerciseService.find(route.params['exerciseId']).pipe( filter((res) => !!res.body), diff --git a/src/main/webapp/app/exercises/file-upload/manage/file-upload-exercise-update.component.ts b/src/main/webapp/app/exercises/file-upload/manage/file-upload-exercise-update.component.ts index 92d07a0b92a4..09cfecca9d24 100644 --- a/src/main/webapp/app/exercises/file-upload/manage/file-upload-exercise-update.component.ts +++ b/src/main/webapp/app/exercises/file-upload/manage/file-upload-exercise-update.component.ts @@ -5,7 +5,7 @@ import { Observable } from 'rxjs'; import { AlertService } from 'app/core/alert/alert.service'; import { FileUploadExerciseService } from './file-upload-exercise.service'; import { FileUploadExercise } from 'app/entities/file-upload-exercise.model'; -import { CourseManagementService } from '../../../course/manage/course-management.service'; +import { CourseManagementService } from 'app/course/manage/course-management.service'; import { MAX_SCORE_PATTERN } from 'app/app.constants'; import { ExerciseService } from 'app/exercises/shared/exercise/exercise.service'; import { ExerciseCategory } from 'app/entities/exercise.model'; @@ -95,7 +95,7 @@ export class FileUploadExerciseUpdateComponent implements OnInit { private subscribeToSaveResponse(result: Observable>) { result.subscribe( - (res: HttpResponse) => this.onSaveSuccess(), + () => this.onSaveSuccess(), (res: HttpErrorResponse) => this.onSaveError(res), ); } diff --git a/src/main/webapp/app/exercises/modeling/assess/modeling-assessment-editor/modeling-assessment-conflict.component.ts b/src/main/webapp/app/exercises/modeling/assess/modeling-assessment-editor/modeling-assessment-conflict.component.ts index ced3d74bb42a..42fa59e7d8de 100644 --- a/src/main/webapp/app/exercises/modeling/assess/modeling-assessment-editor/modeling-assessment-conflict.component.ts +++ b/src/main/webapp/app/exercises/modeling/assess/modeling-assessment-editor/modeling-assessment-conflict.component.ts @@ -124,10 +124,10 @@ export class ModelingAssessmentConflictComponent implements OnInit, AfterViewIni } this.modelingAssessmentService.saveAssessment(this.mergedFeedbacks, this.submissionId).subscribe( - (result) => { + () => { this.jhiAlertService.success('modelingAssessmentEditor.messages.saveSuccessful'); }, - (error) => this.jhiAlertService.error('modelingAssessmentEditor.messages.saveFailed'), + () => this.jhiAlertService.error('modelingAssessmentEditor.messages.saveFailed'), ); } @@ -143,9 +143,9 @@ export class ModelingAssessmentConflictComponent implements OnInit, AfterViewIni escalatedConflicts.push(this.conflicts![i]); } } - this.modelingAssessmentService.escalateConflict(escalatedConflicts).subscribe((value) => { + this.modelingAssessmentService.escalateConflict(escalatedConflicts).subscribe(() => { this.modelingAssessmentService.saveAssessment(this.mergedFeedbacks, this.submissionId, true).subscribe( - (result) => { + () => { this.jhiAlertService.success('modelingAssessmentEditor.messages.submitSuccessful'); this.router.navigate(['/course-management', this.courseId, 'modeling-exercises', this.modelingExercise.id, 'submissions', this.submissionId, 'assessment']); }, diff --git a/src/main/webapp/app/exercises/modeling/assess/modeling-assessment-editor/modeling-assessment-dashboard.component.ts b/src/main/webapp/app/exercises/modeling/assess/modeling-assessment-editor/modeling-assessment-dashboard.component.ts index 53492824333e..c02321b57ea4 100644 --- a/src/main/webapp/app/exercises/modeling/assess/modeling-assessment-editor/modeling-assessment-dashboard.component.ts +++ b/src/main/webapp/app/exercises/modeling/assess/modeling-assessment-editor/modeling-assessment-dashboard.component.ts @@ -143,7 +143,7 @@ export class ModelingAssessmentDashboardComponent implements OnInit, OnDestroy { this.nextOptimalSubmissionIds = optimal; this.applyFilter(); }, - (error) => { + () => { this.applyFilter(); }, ); diff --git a/src/main/webapp/app/exercises/modeling/assess/modeling-assessment-editor/modeling-assessment-editor.component.ts b/src/main/webapp/app/exercises/modeling/assess/modeling-assessment-editor/modeling-assessment-editor.component.ts index 35b7d1921d3a..91aa6847c08a 100644 --- a/src/main/webapp/app/exercises/modeling/assess/modeling-assessment-editor/modeling-assessment-editor.component.ts +++ b/src/main/webapp/app/exercises/modeling/assess/modeling-assessment-editor/modeling-assessment-editor.component.ts @@ -182,7 +182,7 @@ export class ModelingAssessmentEditorComponent implements OnInit { (res) => { this.complaint = res.body!; }, - (err: HttpErrorResponse) => { + () => { this.onError(); }, ); @@ -328,7 +328,7 @@ export class ModelingAssessmentEditorComponent implements OnInit { this.jhiAlertService.clear(); this.jhiAlertService.success('modelingAssessmentEditor.messages.updateAfterComplaintSuccessful'); }, - (error: HttpErrorResponse) => { + () => { this.jhiAlertService.clear(); this.jhiAlertService.error('modelingAssessmentEditor.messages.updateAfterComplaintFailed'); }, diff --git a/src/main/webapp/app/exercises/modeling/assess/modeling-assessment.service.ts b/src/main/webapp/app/exercises/modeling/assess/modeling-assessment.service.ts index a53f96642f91..1e25caa3c422 100644 --- a/src/main/webapp/app/exercises/modeling/assess/modeling-assessment.service.ts +++ b/src/main/webapp/app/exercises/modeling/assess/modeling-assessment.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import { HttpClient, HttpResponse } from '@angular/common/http'; import { Observable } from 'rxjs/Observable'; import { SERVER_API_URL } from 'app/app.constants'; -import { UMLElementType, UMLModel, UMLModelElementType, UMLRelationshipType } from '@ls1intum/apollon'; +import { UMLElementType, UMLModel, UMLRelationshipType } from '@ls1intum/apollon'; import { mergeMap } from 'rxjs/operators'; import { timer } from 'rxjs'; import * as moment from 'moment'; diff --git a/src/main/webapp/app/exercises/modeling/manage/example-modeling/example-modeling-submission.component.ts b/src/main/webapp/app/exercises/modeling/manage/example-modeling/example-modeling-submission.component.ts index 55c58a9c1375..9d544cea6af7 100644 --- a/src/main/webapp/app/exercises/modeling/manage/example-modeling/example-modeling-submission.component.ts +++ b/src/main/webapp/app/exercises/modeling/manage/example-modeling/example-modeling-submission.component.ts @@ -314,7 +314,7 @@ export class ExampleModelingSubmissionComponent implements OnInit { exampleSubmission.submission.result.feedbacks = this.feedbacks; this.tutorParticipationService.assessExampleSubmission(exampleSubmission, this.exerciseId).subscribe( - (res: HttpResponse) => { + () => { this.jhiAlertService.success('artemisApp.exampleSubmission.assessScore.success'); }, (error: HttpErrorResponse) => { @@ -333,7 +333,7 @@ export class ExampleModelingSubmissionComponent implements OnInit { } readAndUnderstood() { - this.tutorParticipationService.assessExampleSubmission(this.exampleSubmission, this.exerciseId).subscribe((res: HttpResponse) => { + this.tutorParticipationService.assessExampleSubmission(this.exampleSubmission, this.exerciseId).subscribe(() => { this.jhiAlertService.success('artemisApp.exampleSubmission.readSuccessfully'); this.back(); }); diff --git a/src/main/webapp/app/exercises/modeling/manage/modeling-exercise-update.component.ts b/src/main/webapp/app/exercises/modeling/manage/modeling-exercise-update.component.ts index 94f7e2052c43..a41845798a86 100644 --- a/src/main/webapp/app/exercises/modeling/manage/modeling-exercise-update.component.ts +++ b/src/main/webapp/app/exercises/modeling/manage/modeling-exercise-update.component.ts @@ -1,11 +1,11 @@ -import { Component, OnInit, Input } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { HttpErrorResponse, HttpResponse } from '@angular/common/http'; import { Observable } from 'rxjs/Observable'; import { JhiEventManager } from 'ng-jhipster'; -import { ModelingExercise } from '../../../entities/modeling-exercise.model'; +import { ModelingExercise } from 'app/entities/modeling-exercise.model'; import { ModelingExerciseService } from './modeling-exercise.service'; -import { CourseManagementService } from '../../../course/manage/course-management.service'; +import { CourseManagementService } from 'app/course/manage/course-management.service'; import { ExampleSubmissionService } from 'app/exercises/shared/example-submission/example-submission.service'; import { MAX_SCORE_PATTERN } from 'app/app.constants'; import { WindowRef } from 'app/core/websocket/window.service'; @@ -126,12 +126,12 @@ export class ModelingExerciseUpdateComponent implements OnInit { private subscribeToSaveResponse(result: Observable>): void { result.subscribe( - (res: HttpResponse) => this.onSaveSuccess(res.body!), - (res: HttpErrorResponse) => this.onSaveError(), + () => this.onSaveSuccess(), + () => this.onSaveError(), ); } - private onSaveSuccess(result: ModelingExercise): void { + private onSaveSuccess(): void { this.eventManager.broadcast({ name: 'modelingExerciseListModification', content: 'OK' }); this.isSaving = false; this.previousState(); diff --git a/src/main/webapp/app/exercises/modeling/manage/modeling-exercise.route.ts b/src/main/webapp/app/exercises/modeling/manage/modeling-exercise.route.ts index dd9b04185944..2616f160e1c1 100644 --- a/src/main/webapp/app/exercises/modeling/manage/modeling-exercise.route.ts +++ b/src/main/webapp/app/exercises/modeling/manage/modeling-exercise.route.ts @@ -1,5 +1,5 @@ import { Injectable, NgModule } from '@angular/core'; -import { ActivatedRouteSnapshot, Resolve, RouterModule, RouterStateSnapshot, Routes } from '@angular/router'; +import { ActivatedRouteSnapshot, Resolve, RouterModule, Routes } from '@angular/router'; import { UserRouteAccessService } from 'app/core/auth/user-route-access-service'; import { ModelingExerciseComponent } from './modeling-exercise.component'; import { ModelingExerciseDetailComponent } from './modeling-exercise-detail.component'; @@ -15,7 +15,7 @@ import { Course } from 'app/entities/course.model'; @Injectable({ providedIn: 'root' }) export class ModelingExerciseResolver implements Resolve { constructor(private modelingExerciseService: ModelingExerciseService, private courseService: CourseManagementService) {} - resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { + resolve(route: ActivatedRouteSnapshot) { if (route.params['exerciseId']) { return this.modelingExerciseService.find(route.params['exerciseId']).pipe( filter((res) => !!res.body), diff --git a/src/main/webapp/app/exercises/programming/assess/repo-export/programming-assessment-repo-export-dialog.component.ts b/src/main/webapp/app/exercises/programming/assess/repo-export/programming-assessment-repo-export-dialog.component.ts index 4d3912cd368e..79ec05954115 100644 --- a/src/main/webapp/app/exercises/programming/assess/repo-export/programming-assessment-repo-export-dialog.component.ts +++ b/src/main/webapp/app/exercises/programming/assess/repo-export/programming-assessment-repo-export-dialog.component.ts @@ -74,11 +74,9 @@ export class ProgrammingAssessmentRepoExportDialogComponent implements OnInit { if (this.participationIdList) { // We anonymize the assessment process ("double-blind"). this.repositoryExportOptions.addParticipantName = false; - this.repoExportService - .exportReposByParticipations(exerciseId, this.participationIdList, this.repositoryExportOptions) - .subscribe(this.handleExportRepoResponse, (err) => { - this.exportInProgress = false; - }); + this.repoExportService.exportReposByParticipations(exerciseId, this.participationIdList, this.repositoryExportOptions).subscribe(this.handleExportRepoResponse, () => { + this.exportInProgress = false; + }); return; } const participantIdentifierList = @@ -86,7 +84,7 @@ export class ProgrammingAssessmentRepoExportDialogComponent implements OnInit { this.repoExportService .exportReposByParticipantIdentifiers(exerciseId, participantIdentifierList, this.repositoryExportOptions) - .subscribe(this.handleExportRepoResponse, (err) => { + .subscribe(this.handleExportRepoResponse, () => { this.exportInProgress = false; }); } diff --git a/src/main/webapp/app/exercises/programming/manage/programming-exercise-management-routing.module.ts b/src/main/webapp/app/exercises/programming/manage/programming-exercise-management-routing.module.ts index b67348d801ad..322912ee598a 100644 --- a/src/main/webapp/app/exercises/programming/manage/programming-exercise-management-routing.module.ts +++ b/src/main/webapp/app/exercises/programming/manage/programming-exercise-management-routing.module.ts @@ -1,4 +1,4 @@ -import { ActivatedRouteSnapshot, Resolve, RouterModule, RouterStateSnapshot, Routes } from '@angular/router'; +import { ActivatedRouteSnapshot, Resolve, RouterModule, Routes } from '@angular/router'; import { UserRouteAccessService } from 'app/core/auth/user-route-access-service'; import { Injectable, NgModule } from '@angular/core'; import { ProgrammingExerciseDetailComponent } from 'app/exercises/programming/manage/programming-exercise-detail.component'; @@ -15,7 +15,7 @@ import { Observable } from 'rxjs/Observable'; export class ProgrammingExerciseResolve implements Resolve { constructor(private service: ProgrammingExerciseService) {} - resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { + resolve(route: ActivatedRouteSnapshot) { const id = route.params['id'] ? route.params['id'] : null; if (id) { return this.service.find(id).pipe(map((programmingExercise: HttpResponse) => programmingExercise.body!)); diff --git a/src/main/webapp/app/exercises/programming/manage/test-cases/programming-exercise-manage-test-cases.component.ts b/src/main/webapp/app/exercises/programming/manage/test-cases/programming-exercise-manage-test-cases.component.ts index a3283e4960d3..a7526e5bb1b4 100644 --- a/src/main/webapp/app/exercises/programming/manage/test-cases/programming-exercise-manage-test-cases.component.ts +++ b/src/main/webapp/app/exercises/programming/manage/test-cases/programming-exercise-manage-test-cases.component.ts @@ -232,7 +232,7 @@ export class ProgrammingExerciseManageTestCasesComponent implements OnInit, OnDe this.alertService.success(`artemisApp.programmingExercise.manageTestCases.testCasesUpdated`); } }), - catchError((err: HttpErrorResponse) => { + catchError(() => { this.alertService.error(`artemisApp.programmingExercise.manageTestCases.testCasesCouldNotBeUpdated`, { testCases: testCasesToUpdate }); return of(null); }), @@ -272,7 +272,7 @@ export class ProgrammingExerciseManageTestCasesComponent implements OnInit, OnDe this.alertService.success(`artemisApp.programmingExercise.manageTestCases.weightsReset`); this.testCaseService.notifyTestCases(this.exercise.id, testCases); }), - catchError((err: HttpErrorResponse) => { + catchError(() => { this.alertService.error(`artemisApp.programmingExercise.manageTestCases.weightsResetFailed`); return of(null); }), diff --git a/src/main/webapp/app/exercises/programming/manage/update/programming-exercise-test-schedule-date-picker.component.ts b/src/main/webapp/app/exercises/programming/manage/update/programming-exercise-test-schedule-date-picker.component.ts index 4f85cdb642c1..ba319c96bb1e 100644 --- a/src/main/webapp/app/exercises/programming/manage/update/programming-exercise-test-schedule-date-picker.component.ts +++ b/src/main/webapp/app/exercises/programming/manage/update/programming-exercise-test-schedule-date-picker.component.ts @@ -30,9 +30,9 @@ export class ProgrammingExerciseTestScheduleDatePickerComponent implements Contr this._onChange = fn; } - registerOnTouched(fn: any): void {} + registerOnTouched(): void {} - setDisabledState(isDisabled: boolean): void {} + setDisabledState(): void {} writeValue(obj: any): void { if (obj !== undefined && this.selectedDate !== obj) { diff --git a/src/main/webapp/app/exercises/programming/manage/update/programming-exercise-update.component.ts b/src/main/webapp/app/exercises/programming/manage/update/programming-exercise-update.component.ts index 1560965a9cb8..25083a859be5 100644 --- a/src/main/webapp/app/exercises/programming/manage/update/programming-exercise-update.component.ts +++ b/src/main/webapp/app/exercises/programming/manage/update/programming-exercise-update.component.ts @@ -173,7 +173,7 @@ export class ProgrammingExerciseUpdateComponent implements OnInit { private subscribeToSaveResponse(result: Observable>) { result.subscribe( - (res: HttpResponse) => this.onSaveSuccess(), + () => this.onSaveSuccess(), (res: HttpErrorResponse) => this.onSaveError(res), ); } diff --git a/src/main/webapp/app/exercises/programming/participate/code-editor-student-container.component.ts b/src/main/webapp/app/exercises/programming/participate/code-editor-student-container.component.ts index f0a3a498c633..bdddfc009f1f 100644 --- a/src/main/webapp/app/exercises/programming/participate/code-editor-student-container.component.ts +++ b/src/main/webapp/app/exercises/programming/participate/code-editor-student-container.component.ts @@ -91,7 +91,7 @@ export class CodeEditorStudentContainerComponent extends CodeEditorContainer imp this.loadingParticipation = false; this.guidedTourService.enableTourForExercise(this.exercise, codeEditorTour, true); }, - (err) => { + () => { this.participationCouldNotBeFetched = true; this.loadingParticipation = false; }, diff --git a/src/main/webapp/app/exercises/programming/participate/programming-submission.service.ts b/src/main/webapp/app/exercises/programming/participate/programming-submission.service.ts index cdf87f7af85f..734c8abbcfc7 100644 --- a/src/main/webapp/app/exercises/programming/participate/programming-submission.service.ts +++ b/src/main/webapp/app/exercises/programming/participate/programming-submission.service.ts @@ -74,7 +74,7 @@ export class ProgrammingSubmissionService implements IProgrammingSubmissionServi ngOnDestroy(): void { Object.values(this.resultSubscriptions).forEach((sub) => sub.unsubscribe()); Object.values(this.resultTimerSubscriptions).forEach((sub) => sub.unsubscribe()); - this.submissionTopicsSubscribed.forEach((topic, _) => this.websocketService.unsubscribe(topic)); + this.submissionTopicsSubscribed.forEach((topic) => this.websocketService.unsubscribe(topic)); } get exerciseBuildState() { @@ -538,7 +538,7 @@ export class ProgrammingSubmissionService implements IProgrammingSubmissionServi this.resultSubscriptions = {}; Object.values(this.resultTimerSubscriptions).forEach((sub) => sub.unsubscribe()); this.resultTimerSubscriptions = {}; - this.submissionTopicsSubscribed.forEach((topic, _) => this.websocketService.unsubscribe(topic)); + this.submissionTopicsSubscribed.forEach((topic) => this.websocketService.unsubscribe(topic)); this.submissionTopicsSubscribed.forEach((_, participationId) => this.participationWebsocketService.unsubscribeForLatestResultOfParticipation(participationId, exercise)); this.submissionTopicsSubscribed.clear(); this.submissionSubjects = {}; diff --git a/src/main/webapp/app/exercises/programming/shared/instructions-render/service/programming-exercise-instruction.service.ts b/src/main/webapp/app/exercises/programming/shared/instructions-render/service/programming-exercise-instruction.service.ts index 3a90da2dfba9..3bc6da90c4cb 100644 --- a/src/main/webapp/app/exercises/programming/shared/instructions-render/service/programming-exercise-instruction.service.ts +++ b/src/main/webapp/app/exercises/programming/shared/instructions-render/service/programming-exercise-instruction.service.ts @@ -27,7 +27,6 @@ export class ProgrammingExerciseInstructionService { * @param latestResult */ public testStatusForTask = (tests: string[], latestResult: Result | null): TaskResult => { - const totalTests = tests.length; if (latestResult && latestResult.successful && (!latestResult.feedbacks || !latestResult.feedbacks.length)) { // Case 1: Submission fulfills all test cases and there are no feedbacks (legacy case), no further checking needed. return { testCaseState: TestCaseState.SUCCESS, detailed: { successfulTests: tests, failedTests: [], notExecutedTests: [] } }; diff --git a/src/main/webapp/app/exercises/programming/shared/programming-exercise.component.ts b/src/main/webapp/app/exercises/programming/shared/programming-exercise.component.ts index c6d8bf29032d..97eb7a135ae0 100644 --- a/src/main/webapp/app/exercises/programming/shared/programming-exercise.component.ts +++ b/src/main/webapp/app/exercises/programming/shared/programming-exercise.component.ts @@ -113,7 +113,7 @@ export class ProgrammingExerciseComponent extends ExerciseComponent implements O (result: ProgrammingExercise) => { this.router.navigate(['course-management', this.courseId, 'programming-exercises', 'import', result.id]); }, - (reason) => {}, + () => {}, ); } diff --git a/src/main/webapp/app/exercises/quiz/manage/apollon-diagrams/apollon-diagram-create-form.component.ts b/src/main/webapp/app/exercises/quiz/manage/apollon-diagrams/apollon-diagram-create-form.component.ts index 164b161263de..e8159de80eed 100644 --- a/src/main/webapp/app/exercises/quiz/manage/apollon-diagrams/apollon-diagram-create-form.component.ts +++ b/src/main/webapp/app/exercises/quiz/manage/apollon-diagrams/apollon-diagram-create-form.component.ts @@ -36,7 +36,7 @@ export class ApollonDiagramCreateFormComponent implements AfterViewInit { this.dismiss(); this.router.navigate(['course-management', 'apollon-diagrams', newDiagram.id]); }, - (response) => { + () => { this.jhiAlertService.error('artemisApp.apollonDiagram.create.error'); }, ); diff --git a/src/main/webapp/app/exercises/quiz/manage/apollon-diagrams/apollon-diagram-list.component.ts b/src/main/webapp/app/exercises/quiz/manage/apollon-diagrams/apollon-diagram-list.component.ts index dd2db10cecbf..9d6e5548e1b1 100644 --- a/src/main/webapp/app/exercises/quiz/manage/apollon-diagrams/apollon-diagram-list.component.ts +++ b/src/main/webapp/app/exercises/quiz/manage/apollon-diagrams/apollon-diagram-list.component.ts @@ -36,7 +36,7 @@ export class ApollonDiagramListComponent implements OnInit { (response) => { this.apollonDiagrams = response.body!; }, - (response) => { + () => { this.jhiAlertService.error('artemisApp.apollonDiagram.home.error.loading'); }, ); From a8ed9d3700e2b89ba5d240c832cd630851fca123 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Wed, 15 Apr 2020 13:57:36 +0200 Subject: [PATCH 012/152] Fix more code style issues --- .../notification-management-update.component.ts | 4 ++-- .../admin/user-management/user-management-update.component.ts | 4 ++-- .../webapp/app/admin/user-management/user-management.route.ts | 2 +- src/main/webapp/app/app.main.ts | 2 +- .../webapp/app/course/manage/course-management.service.ts | 4 ++-- .../example-modeling/example-modeling-submission.component.ts | 1 - .../programming-exercise-manage-test-cases.component.ts | 1 + .../manage/apollon-diagrams/apollon-diagram-list.component.ts | 4 ++-- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/webapp/app/admin/notification-management/notification-management-update.component.ts b/src/main/webapp/app/admin/notification-management/notification-management-update.component.ts index 0ffdce0c497c..9b178093915a 100644 --- a/src/main/webapp/app/admin/notification-management/notification-management-update.component.ts +++ b/src/main/webapp/app/admin/notification-management/notification-management-update.component.ts @@ -43,12 +43,12 @@ export class NotificationMgmtUpdateComponent implements OnInit { this.isSaving = true; if (this.notification.id) { this.systemNotificationService.update(this.notification).subscribe( - (response) => this.onSaveSuccess(), + () => this.onSaveSuccess(), () => this.onSaveError(), ); } else { this.systemNotificationService.create(this.notification).subscribe( - (response) => this.onSaveSuccess(), + () => this.onSaveSuccess(), () => this.onSaveError(), ); } diff --git a/src/main/webapp/app/admin/user-management/user-management-update.component.ts b/src/main/webapp/app/admin/user-management/user-management-update.component.ts index a361521721a1..938984e1f7a0 100644 --- a/src/main/webapp/app/admin/user-management/user-management-update.component.ts +++ b/src/main/webapp/app/admin/user-management/user-management-update.component.ts @@ -51,12 +51,12 @@ export class UserManagementUpdateComponent implements OnInit { this.isSaving = true; if (this.user.id !== null) { this.userService.update(this.user).subscribe( - (response) => this.onSaveSuccess(), + () => this.onSaveSuccess(), () => this.onSaveError(), ); } else { this.userService.create(this.user).subscribe( - (response) => this.onSaveSuccess(), + () => this.onSaveSuccess(), () => this.onSaveError(), ); } diff --git a/src/main/webapp/app/admin/user-management/user-management.route.ts b/src/main/webapp/app/admin/user-management/user-management.route.ts index 88260f4aacb4..d1c410bff4cf 100644 --- a/src/main/webapp/app/admin/user-management/user-management.route.ts +++ b/src/main/webapp/app/admin/user-management/user-management.route.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { ActivatedRouteSnapshot, Resolve, Route, RouterStateSnapshot } from '@angular/router'; +import { ActivatedRouteSnapshot, Resolve, Route } from '@angular/router'; import { JhiResolvePagingParams } from 'ng-jhipster'; import { User } from 'app/core/user/user.model'; import { UserService } from 'app/core/user/user.service'; diff --git a/src/main/webapp/app/app.main.ts b/src/main/webapp/app/app.main.ts index 538009f7e60a..16cc06ac5908 100644 --- a/src/main/webapp/app/app.main.ts +++ b/src/main/webapp/app/app.main.ts @@ -14,5 +14,5 @@ if (module['hot']) { platformBrowserDynamic() .bootstrapModule(ArtemisAppModule, { preserveWhitespaces: true }) - .then((platformRef) => {}) + .then(() => {}) .catch((err) => console.error(err)); diff --git a/src/main/webapp/app/course/manage/course-management.service.ts b/src/main/webapp/app/course/manage/course-management.service.ts index 4202be157e80..b92200d17f70 100644 --- a/src/main/webapp/app/course/manage/course-management.service.ts +++ b/src/main/webapp/app/course/manage/course-management.service.ts @@ -206,11 +206,11 @@ export class CourseManagementService { } private reconnectObjects(res: EntityArrayResponseType): EntityArrayResponseType { - if (res.body) { + /*if (res.body) { res.body.forEach((course: Course) => { // TODO: implement }); - } + }*/ return res; } diff --git a/src/main/webapp/app/exercises/modeling/manage/example-modeling/example-modeling-submission.component.ts b/src/main/webapp/app/exercises/modeling/manage/example-modeling/example-modeling-submission.component.ts index 9d544cea6af7..2af93cef8d6c 100644 --- a/src/main/webapp/app/exercises/modeling/manage/example-modeling/example-modeling-submission.component.ts +++ b/src/main/webapp/app/exercises/modeling/manage/example-modeling/example-modeling-submission.component.ts @@ -15,7 +15,6 @@ import { ExerciseService } from 'app/exercises/shared/exercise/exercise.service' import { ModelingAssessmentService } from 'app/exercises/modeling/assess/modeling-assessment.service'; import { ModelingSubmission } from 'app/entities/modeling-submission.model'; import { ModelingExercise } from 'app/entities/modeling-exercise.model'; -import { TutorParticipation } from 'app/entities/participation/tutor-participation.model'; import { ModelingAssessmentComponent } from 'app/exercises/modeling/assess/modeling-assessment.component'; @Component({ diff --git a/src/main/webapp/app/exercises/programming/manage/test-cases/programming-exercise-manage-test-cases.component.ts b/src/main/webapp/app/exercises/programming/manage/test-cases/programming-exercise-manage-test-cases.component.ts index a7526e5bb1b4..895286f089e8 100644 --- a/src/main/webapp/app/exercises/programming/manage/test-cases/programming-exercise-manage-test-cases.component.ts +++ b/src/main/webapp/app/exercises/programming/manage/test-cases/programming-exercise-manage-test-cases.component.ts @@ -261,6 +261,7 @@ export class ProgrammingExerciseManageTestCasesComponent implements OnInit, OnDe const existsUnchangedWithCustomWeight = this.testCases.filter(({ id }) => !this.changedTestCaseIds.includes(id)).some(({ weight }) => weight > 1); // If the updated weights are unsaved, we can just reset them locally in the browser without contacting the server. if (!existsUnchangedWithCustomWeight) { + // eslint-disable-next-line @typescript-eslint/no-unused-vars this.testCases = this.testCases.map(({ weight, ...rest }) => ({ weight: 1, ...rest })); return; } diff --git a/src/main/webapp/app/exercises/quiz/manage/apollon-diagrams/apollon-diagram-list.component.ts b/src/main/webapp/app/exercises/quiz/manage/apollon-diagrams/apollon-diagram-list.component.ts index 9d6e5548e1b1..89728bd9ccf6 100644 --- a/src/main/webapp/app/exercises/quiz/manage/apollon-diagrams/apollon-diagram-list.component.ts +++ b/src/main/webapp/app/exercises/quiz/manage/apollon-diagrams/apollon-diagram-list.component.ts @@ -58,13 +58,13 @@ export class ApollonDiagramListComponent implements OnInit { */ delete(apollonDiagram: ApollonDiagram) { this.apollonDiagramsService.delete(apollonDiagram.id).subscribe( - (response) => { + () => { this.jhiAlertService.success('artemisApp.apollonDiagram.delete.success', { title: apollonDiagram.title }); this.apollonDiagrams = this.apollonDiagrams.filter((diagram) => { return diagram.id !== apollonDiagram.id; }); }, - (response) => { + () => { this.jhiAlertService.error('artemisApp.apollonDiagram.delete.error', { title: apollonDiagram.title }); }, ); From 1c03728d66b7388ada152476be4b74f9e244f88e Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Wed, 15 Apr 2020 14:09:30 +0200 Subject: [PATCH 013/152] Fix even more code style issues --- .../assessment-warning/assessment-warning.component.ts | 2 +- .../file-upload/assess/file-upload-assessment.component.html | 2 +- .../file-upload/assess/file-upload-assessment.component.ts | 2 +- .../shared/code-editor/layout/code-editor-grid.component.ts | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/webapp/app/assessment/assessment-warning/assessment-warning.component.ts b/src/main/webapp/app/assessment/assessment-warning/assessment-warning.component.ts index 3039b000f4ba..5158b755e52f 100644 --- a/src/main/webapp/app/assessment/assessment-warning/assessment-warning.component.ts +++ b/src/main/webapp/app/assessment/assessment-warning/assessment-warning.component.ts @@ -22,7 +22,7 @@ export class AssessmentWarningComponent implements OnChanges { currentDate: moment.MomentInput; isBeforeDueDate = false; - ngOnChanges(changes: SimpleChanges): void { + ngOnChanges(): void { const dueDate = this.exercise.dueDate; if (dueDate != null) { this.isBeforeDueDate = dueDate.isAfter(this.currentDate); diff --git a/src/main/webapp/app/exercises/file-upload/assess/file-upload-assessment.component.html b/src/main/webapp/app/exercises/file-upload/assess/file-upload-assessment.component.html index eb030c13a08b..6bb77a401485 100644 --- a/src/main/webapp/app/exercises/file-upload/assess/file-upload-assessment.component.html +++ b/src/main/webapp/app/exercises/file-upload/assess/file-upload-assessment.component.html @@ -43,7 +43,7 @@

Feedback
diff --git a/src/main/webapp/app/exercises/file-upload/assess/file-upload-assessment.component.ts b/src/main/webapp/app/exercises/file-upload/assess/file-upload-assessment.component.ts index bbede5003f52..d1101d45ef3a 100644 --- a/src/main/webapp/app/exercises/file-upload/assess/file-upload-assessment.component.ts +++ b/src/main/webapp/app/exercises/file-upload/assess/file-upload-assessment.component.ts @@ -379,7 +379,7 @@ export class FileUploadAssessmentComponent implements OnInit, AfterViewInit, OnD } } - updateAssessment(assessment: Feedback) { + updateAssessment() { this.validateAssessment(); } diff --git a/src/main/webapp/app/exercises/programming/shared/code-editor/layout/code-editor-grid.component.ts b/src/main/webapp/app/exercises/programming/shared/code-editor/layout/code-editor-grid.component.ts index 685cb9e5aab0..2ca81a847bcc 100644 --- a/src/main/webapp/app/exercises/programming/shared/code-editor/layout/code-editor-grid.component.ts +++ b/src/main/webapp/app/exercises/programming/shared/code-editor/layout/code-editor-grid.component.ts @@ -167,6 +167,7 @@ export class CodeEditorGridComponent implements AfterViewInit { * @param minWidth {number} Width to set the element to after toggling the collapse * @param minHeight {number} Height to set the element to after toggling the collapse */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars toggleCollapse($event: any, horizontal: boolean, interactResizable: Interactable, minWidth?: number, minHeight?: number) { const target = $event.toElement || $event.relatedTarget || $event.target; target.blur(); From e80a783bb1e92d76c5df2a8d245013e085c6c999 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Wed, 15 Apr 2020 14:28:49 +0200 Subject: [PATCH 014/152] Fix remaining code style issues --- .../assessment-warning/assessment-warning.component.ts | 2 +- .../programming-exercise-manage-test-cases.component.ts | 1 - .../extensions/programming-exercise-plant-uml.extension.ts | 2 +- .../extensions/programming-exercise-task.extension.ts | 4 ++-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/webapp/app/assessment/assessment-warning/assessment-warning.component.ts b/src/main/webapp/app/assessment/assessment-warning/assessment-warning.component.ts index 5158b755e52f..1ac13ecb339d 100644 --- a/src/main/webapp/app/assessment/assessment-warning/assessment-warning.component.ts +++ b/src/main/webapp/app/assessment/assessment-warning/assessment-warning.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnChanges, SimpleChanges } from '@angular/core'; +import { Component, Input, OnChanges } from '@angular/core'; import * as moment from 'moment'; import { Exercise } from 'app/entities/exercise.model'; diff --git a/src/main/webapp/app/exercises/programming/manage/test-cases/programming-exercise-manage-test-cases.component.ts b/src/main/webapp/app/exercises/programming/manage/test-cases/programming-exercise-manage-test-cases.component.ts index 895286f089e8..2cede78ea6f2 100644 --- a/src/main/webapp/app/exercises/programming/manage/test-cases/programming-exercise-manage-test-cases.component.ts +++ b/src/main/webapp/app/exercises/programming/manage/test-cases/programming-exercise-manage-test-cases.component.ts @@ -1,7 +1,6 @@ import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core'; import { TranslateService } from '@ngx-translate/core'; import { ActivatedRoute } from '@angular/router'; -import { HttpErrorResponse } from '@angular/common/http'; import { of, Subscription, zip } from 'rxjs'; import { catchError, distinctUntilChanged, map, take, tap } from 'rxjs/operators'; import { differenceBy as _differenceBy, differenceWith as _differenceWith, intersectionWith as _intersectionWith, unionBy as _unionBy } from 'lodash'; diff --git a/src/main/webapp/app/exercises/programming/shared/instructions-render/extensions/programming-exercise-plant-uml.extension.ts b/src/main/webapp/app/exercises/programming/shared/instructions-render/extensions/programming-exercise-plant-uml.extension.ts index 8258acbb8b0c..cc81c56a0da8 100644 --- a/src/main/webapp/app/exercises/programming/shared/instructions-render/extensions/programming-exercise-plant-uml.extension.ts +++ b/src/main/webapp/app/exercises/programming/shared/instructions-render/extensions/programming-exercise-plant-uml.extension.ts @@ -48,7 +48,7 @@ export class ProgrammingExercisePlantUmlExtensionWrapper implements ArtemisShowd getExtension() { const extension: showdown.ShowdownExtension = { type: 'lang', - filter: (text: string, converter: showdown.Converter, options: showdown.ConverterOptions) => { + filter: (text: string) => { const idPlaceholder = '%idPlaceholder%'; // E.g. [task][Implement BubbleSort](testBubbleSort) const plantUmlRegex = /@startuml([^@]*)@enduml/g; diff --git a/src/main/webapp/app/exercises/programming/shared/instructions-render/extensions/programming-exercise-task.extension.ts b/src/main/webapp/app/exercises/programming/shared/instructions-render/extensions/programming-exercise-task.extension.ts index 39631e16b5ea..767683248e65 100644 --- a/src/main/webapp/app/exercises/programming/shared/instructions-render/extensions/programming-exercise-task.extension.ts +++ b/src/main/webapp/app/exercises/programming/shared/instructions-render/extensions/programming-exercise-task.extension.ts @@ -65,7 +65,7 @@ export class ProgrammingExerciseTaskExtensionWrapper implements ArtemisShowdownE getExtension() { const extension: showdown.ShowdownExtension = { type: 'lang', - filter: (text: string, converter: showdown.Converter, options: showdown.ConverterOptions) => { + filter: (text: string) => { const idPlaceholder = '%idPlaceholder%'; // E.g. [task][Implement BubbleSort](testBubbleSort) const taskRegex = /\[task\]\[.*\]\(.*\)({.*})?/g; @@ -92,7 +92,7 @@ export class ProgrammingExerciseTaskExtensionWrapper implements ArtemisShowdownE // Emit new found elements that need to be injected into html after it is rendered. this.injectableElementsFoundSubject.next(() => this.injectTasks(testsForTask)); return testsForTask.reduce( - (acc: string, { completeString: task, taskName, tests }, index: number): string => + (acc: string, { completeString: task }, index: number): string => // Insert anchor divs into the text so that injectable elements can be inserted into them. acc.replace(new RegExp(escapeStringForUseInRegex(task), 'g'), taskContainer.replace(idPlaceholder, index.toString())), text, From 0a19509673b9826e2d7de85a8e84b1e6af9365fb Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Wed, 15 Apr 2020 14:54:10 +0200 Subject: [PATCH 015/152] Fix failing test: default value for page in audits component should be 1 instead of 10 --- .../javascript/spec/app/admin/audits/audits.component.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/javascript/spec/app/admin/audits/audits.component.spec.ts b/src/test/javascript/spec/app/admin/audits/audits.component.spec.ts index cec00e27bd92..9c55d29b64b5 100644 --- a/src/test/javascript/spec/app/admin/audits/audits.component.spec.ts +++ b/src/test/javascript/spec/app/admin/audits/audits.component.spec.ts @@ -72,7 +72,7 @@ describe('Component Tests', () => { expect(comp.toDate).toBe(getDate()); expect(comp.fromDate).toBe(getDate(false)); expect(comp.itemsPerPage).toBe(ITEMS_PER_PAGE); - expect(comp.page).toBe(10); + expect(comp.page).toBe(1); expect(comp.reverse).toBeFalsy(); }); }); From b0d2130ab54f6be296e8547fef52fe448cfd3f57 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Wed, 15 Apr 2020 14:58:34 +0200 Subject: [PATCH 016/152] Fix failing test: remove test case as filterNaN function no longer exists in metrics component --- .../spec/app/admin/metrics/metrics.component.spec.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/test/javascript/spec/app/admin/metrics/metrics.component.spec.ts b/src/test/javascript/spec/app/admin/metrics/metrics.component.spec.ts index 6b44e69e26d2..6d36e95474e9 100644 --- a/src/test/javascript/spec/app/admin/metrics/metrics.component.spec.ts +++ b/src/test/javascript/spec/app/admin/metrics/metrics.component.spec.ts @@ -52,12 +52,5 @@ describe('Component Tests', () => { expect(comp.cachesStats).toEqual({ jcache: { name: 17, value: 2 } }); }); }); - - describe('isNan', () => { - it('should return if a variable is NaN', () => { - expect(comp.filterNaN(1)).toBe(1); - expect(comp.filterNaN('test')).toBe(0); - }); - }); }); }); From 7b3b3a62a758779cabcfd1970a19b804298b53d9 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Wed, 15 Apr 2020 15:12:54 +0200 Subject: [PATCH 017/152] Fix failing test: adjust resource url to real value in metrics service --- .../javascript/spec/app/admin/metrics/metrics.service.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/javascript/spec/app/admin/metrics/metrics.service.spec.ts b/src/test/javascript/spec/app/admin/metrics/metrics.service.spec.ts index af33f34c0696..dde4b224653c 100644 --- a/src/test/javascript/spec/app/admin/metrics/metrics.service.spec.ts +++ b/src/test/javascript/spec/app/admin/metrics/metrics.service.spec.ts @@ -27,7 +27,7 @@ describe('Service Tests', () => { service.getMetrics().subscribe(() => {}); const req = httpMock.expectOne({ method: 'GET' }); - const resourceUrl = SERVER_API_URL + 'management/metrics'; + const resourceUrl = SERVER_API_URL + 'management/jhimetrics'; expect(req.request.url).toEqual(resourceUrl); }); From f74bef43dc43f92bde1bfd2f288928354041eff9 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Wed, 15 Apr 2020 15:34:10 +0200 Subject: [PATCH 018/152] Fix failing test: remove two expect statements as servicesStats and cachesStats attributes no longer exist --- .../javascript/spec/app/admin/metrics/metrics.component.spec.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/test/javascript/spec/app/admin/metrics/metrics.component.spec.ts b/src/test/javascript/spec/app/admin/metrics/metrics.component.spec.ts index 6d36e95474e9..fd53408bf0b7 100644 --- a/src/test/javascript/spec/app/admin/metrics/metrics.component.spec.ts +++ b/src/test/javascript/spec/app/admin/metrics/metrics.component.spec.ts @@ -48,8 +48,6 @@ describe('Component Tests', () => { // THEN expect(service.getMetrics).toHaveBeenCalled(); - expect(comp.servicesStats).toEqual({ service: 'test' }); - expect(comp.cachesStats).toEqual({ jcache: { name: 17, value: 2 } }); }); }); }); From 5acfed807013c4a55d2e4d70a243e910296e1755 Mon Sep 17 00:00:00 2001 From: Jonas Petry Date: Wed, 15 Apr 2020 18:13:10 +0200 Subject: [PATCH 019/152] fix "sets focus after the view has been initialized" test case --- .../password-reset/finish/password-reset-finish.component.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/webapp/app/account/password-reset/finish/password-reset-finish.component.ts b/src/main/webapp/app/account/password-reset/finish/password-reset-finish.component.ts index 08f8f0196c0b..603e6f3e5037 100644 --- a/src/main/webapp/app/account/password-reset/finish/password-reset-finish.component.ts +++ b/src/main/webapp/app/account/password-reset/finish/password-reset-finish.component.ts @@ -29,8 +29,9 @@ export class PasswordResetFinishComponent implements OnInit, AfterViewInit { } ngAfterViewInit() { - if (this.elementRef.nativeElement.querySelector('#password') != null) { - this.renderer.selectRootElement('#password', true).focus(); + const passwordElement = this.elementRef.nativeElement.querySelector('#password'); + if (passwordElement != null) { + this.renderer.selectRootElement(passwordElement, true).focus(); } } From 1ead4a373e9e23497f1575b1a93e1e7534d056d3 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Thu, 16 Apr 2020 09:31:45 +0200 Subject: [PATCH 020/152] Fix password reset init component test --- .../password-reset/init/password-reset-init.component.ts | 5 ++++- .../init/password-reset-init.component.spec.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/webapp/app/account/password-reset/init/password-reset-init.component.ts b/src/main/webapp/app/account/password-reset/init/password-reset-init.component.ts index 14aa092e297f..7279574019ff 100644 --- a/src/main/webapp/app/account/password-reset/init/password-reset-init.component.ts +++ b/src/main/webapp/app/account/password-reset/init/password-reset-init.component.ts @@ -19,7 +19,10 @@ export class PasswordResetInitComponent implements OnInit, AfterViewInit { } ngAfterViewInit() { - this.renderer.selectRootElement('#email', true).focus(); + const emailElement = this.elementRef.nativeElement.querySelector('#email'); + if (emailElement != null) { + this.renderer.selectRootElement(emailElement, true).focus(); + } } requestReset() { diff --git a/src/test/javascript/spec/app/account/password-reset/init/password-reset-init.component.spec.ts b/src/test/javascript/spec/app/account/password-reset/init/password-reset-init.component.spec.ts index e8a2ab7b8ee7..f74abdee91df 100644 --- a/src/test/javascript/spec/app/account/password-reset/init/password-reset-init.component.spec.ts +++ b/src/test/javascript/spec/app/account/password-reset/init/password-reset-init.component.spec.ts @@ -5,7 +5,7 @@ import { of, throwError } from 'rxjs'; import { ArtemisTestModule } from '../../../../test.module'; import { PasswordResetInitComponent } from 'app/account/password-reset/init/password-reset-init.component'; import { PasswordResetInitService } from 'app/account/password-reset/init/password-reset-init.service'; -import { EMAIL_NOT_FOUND_TYPE } from 'app/shared'; +import { EMAIL_NOT_FOUND_TYPE } from 'app/shared/constants/error.constants'; describe('Component Tests', () => { describe('PasswordResetInitComponent', () => { From 8bfe6ad486d2d1fb9cf07343e4a655c36dd74a22 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Thu, 16 Apr 2020 11:05:51 +0200 Subject: [PATCH 021/152] Fix failing test: Remove "Should call load all on init" as loadAll is not dependent on service's query method --- .../user-management.component.spec.ts | 30 +++---------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/src/test/javascript/spec/app/admin/user-management/user-management.component.spec.ts b/src/test/javascript/spec/app/admin/user-management/user-management.component.spec.ts index 40dbc5bdfa41..dc8f97849535 100644 --- a/src/test/javascript/spec/app/admin/user-management/user-management.component.spec.ts +++ b/src/test/javascript/spec/app/admin/user-management/user-management.component.spec.ts @@ -1,11 +1,14 @@ import { async, ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; import { of } from 'rxjs'; import { HttpHeaders, HttpResponse } from '@angular/common/http'; +import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { ArtemisTestModule } from '../../../test.module'; import { UserManagementComponent } from 'app/admin/user-management/user-management.component'; import { User } from 'app/core/user/user.model'; import { UserService } from 'app/core/user/user.service'; +import { AccountService } from 'app/core/auth/account.service'; +import { MockSyncStorage } from '../../../mocks/mock-sync.storage'; describe('Component Tests', () => { describe('User Management Component', () => { @@ -17,6 +20,7 @@ describe('Component Tests', () => { TestBed.configureTestingModule({ imports: [ArtemisTestModule], declarations: [UserManagementComponent], + providers: [AccountService, { provide: SessionStorageService, useClass: MockSyncStorage }, { provide: LocalStorageService, useClass: MockSyncStorage }], }) .overrideTemplate(UserManagementComponent, '') .compileComponents(); @@ -28,32 +32,6 @@ describe('Component Tests', () => { service = fixture.debugElement.injector.get(UserService); }); - describe('OnInit', () => { - it('Should call load all on init', inject( - [], - fakeAsync(() => { - // GIVEN - const headers = new HttpHeaders().append('link', 'link;link'); - spyOn(service, 'query').and.returnValue( - of( - new HttpResponse({ - body: [new User(123)], - headers, - }), - ), - ); - - // WHEN - comp.ngOnInit(); - tick(); // simulate async - - // THEN - expect(service.query).toHaveBeenCalled(); - expect(comp.users[0]).toEqual(jasmine.objectContaining({ id: 123 })); - }), - )); - }); - describe('setActive', () => { it('Should update user and call load all', inject( [], From 11ccb41e3f9a294a603f23d52ad7b36d16b0d736 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Thu, 16 Apr 2020 14:32:17 +0200 Subject: [PATCH 022/152] Fix failing test: add missing fields to compared user object in user management detail component test --- .../user-management-detail.component.spec.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/test/javascript/spec/app/admin/user-management/user-management-detail.component.spec.ts b/src/test/javascript/spec/app/admin/user-management/user-management-detail.component.spec.ts index fe56aa0c724c..d09292347da8 100644 --- a/src/test/javascript/spec/app/admin/user-management/user-management-detail.component.spec.ts +++ b/src/test/javascript/spec/app/admin/user-management/user-management-detail.component.spec.ts @@ -52,11 +52,15 @@ describe('Component Tests', () => { activated: true, langKey: 'en', authorities: ['ROLE_USER'], - createdBy: 'admin', + createdBy: null, createdDate: null, lastModifiedBy: null, lastModifiedDate: null, password: null, + groups: 'admin', + guidedTourSettings: [], + imageUrl: null, + lastNotificationRead: null, }), ); }); From c3cd3ef3817f21ea9ba08c0e7b80b6bc358f41bf Mon Sep 17 00:00:00 2001 From: Filip Gregurevic Date: Fri, 17 Apr 2020 15:56:09 +0200 Subject: [PATCH 023/152] add plugin for chai support --- package.json | 1 + tslint.json | 8 ++++++-- yarn.lock | 9 ++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index da7b3b8e1e35..77077e75a9ab 100644 --- a/package.json +++ b/package.json @@ -77,6 +77,7 @@ "sugar": "2.0.6", "ts-jest": "25.3.1", "tslib": "1.11.1", + "tslint-no-unused-expression-chai": "^0.1.4", "webstomp-client": "1.2.6", "yarn": "1.22.4", "zone.js": "0.10.3" diff --git a/tslint.json b/tslint.json index 7df1c42e6787..278111196878 100644 --- a/tslint.json +++ b/tslint.json @@ -1,5 +1,8 @@ { - "rulesDirectory": ["node_modules/codelyzer"], + "rulesDirectory": [ + "node_modules/codelyzer", + "tslint-no-unused-expression-chai" + ], "extends": [ "tslint-config-prettier" ], @@ -42,7 +45,8 @@ "no-string-literal": false, "no-switch-case-fall-through": true, "no-trailing-whitespace": true, - "no-unused-expression": true, + "no-unused-expression-chai": true, +// "no-unused-expression": true, "no-var-keyword": true, "object-literal-sort-keys": false, "one-line": [ diff --git a/yarn.lock b/yarn.lock index ddd0c0fbc072..3844c4d03638 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12329,6 +12329,13 @@ tslint-loader@3.6.0: rimraf "^2.4.4" semver "^5.3.0" +tslint-no-unused-expression-chai@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/tslint-no-unused-expression-chai/-/tslint-no-unused-expression-chai-0.1.4.tgz#f4a2c9dd3306088f44eb7574cf470082b09ade49" + integrity sha512-frEWKNTcq7VsaWKgUxMDOB2N/cmQadVkUtUGIut+2K4nv/uFXPfgJyPjuNC/cHyfUVqIkHMAvHOCL+d/McU3nQ== + dependencies: + tsutils "^3.0.0" + tslint@6.1.1: version "6.1.1" resolved "https://registry.yarnpkg.com/tslint/-/tslint-6.1.1.tgz#ac03fbd17f85bfefaae348b353b25a88efe10cde" @@ -12355,7 +12362,7 @@ tsutils@^2.29.0: dependencies: tslib "^1.8.1" -tsutils@^3.17.1: +tsutils@^3.0.0, tsutils@^3.17.1: version "3.17.1" resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.17.1.tgz#ed719917f11ca0dee586272b2ac49e015a2dd759" integrity sha512-kzeQ5B8H3w60nFY2g8cJIuH7JDpsALXySGtwGJ0p2LSjLgay3NdIpqq5SoOBe46bKDW2iq25irHCr8wjomUS2g== From cf59cc962481b1245be59749707ce732bcb78232 Mon Sep 17 00:00:00 2001 From: Jonas Petry Date: Sat, 18 Apr 2020 09:51:40 +0200 Subject: [PATCH 024/152] supress eslint warning for mock methods --- .../javascript/spec/helpers/mock-language.service.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/test/javascript/spec/helpers/mock-language.service.ts b/src/test/javascript/spec/helpers/mock-language.service.ts index 0771817ab031..5ff0be310655 100644 --- a/src/test/javascript/spec/helpers/mock-language.service.ts +++ b/src/test/javascript/spec/helpers/mock-language.service.ts @@ -17,11 +17,14 @@ export class MockLanguageService extends SpyObject { init() {} - changeLanguage(languageKey: string) {} // eslint-disable-line no-unused-vars + // eslint-disable-next-line @typescript-eslint/no-unused-vars + changeLanguage(languageKey: string) {} - setLocations(locations: string[]) {} // eslint-disable-line no-unused-vars + // eslint-disable-next-line @typescript-eslint/no-unused-vars + setLocations(locations: string[]) {} - addLocation(location: string) {} // eslint-disable-line no-unused-vars + // eslint-disable-next-line @typescript-eslint/no-unused-vars + addLocation(location: string) {} reload() {} } From b7957c8884070edd158520c85a25b99fc10802bc Mon Sep 17 00:00:00 2001 From: Martin Wauligmann Date: Sat, 18 Apr 2020 13:03:14 +0200 Subject: [PATCH 025/152] Chai friendly eslint rules + clean up code-editor-status.spec.ts --- .eslintrc.json | 11 +++++-- package.json | 1 + .../code-editor/code-editor-status.spec.ts | 33 ++++++++++--------- yarn.lock | 5 +++ 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 95095647f3e5..e76a2b318751 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,7 +1,8 @@ { "plugins": [ "@typescript-eslint", - "@typescript-eslint/tslint" + "@typescript-eslint/tslint", + "chai-friendly" ], "extends": [ "prettier/@typescript-eslint", @@ -20,7 +21,10 @@ "@typescript-eslint/tslint/config": [ "error", { - "lintFile": "./tslint.json" + "lintFile": "./tslint.json", + "rules": { + "no-unused-expressions": "off" + } } ], "@typescript-eslint/no-unused-vars": [ @@ -31,6 +35,7 @@ "ignoreRestSiblings": false } ], - "@typescript-eslint/no-non-null-assertion": "off" + "@typescript-eslint/no-non-null-assertion": "off", + "chai-friendly/no-unused-expressions": 2 } } diff --git a/package.json b/package.json index 4fbaad8a3f61..387afd90f179 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "compare-versions": "3.6.0", "core-js": "3.6.5", "dompurify": "2.0.8", + "eslint-plugin-chai-friendly": "^0.5.0", "export-to-csv": "0.2.1", "franc-min": "5.0.0", "interactjs": "1.9.9", diff --git a/src/test/javascript/spec/component/code-editor/code-editor-status.spec.ts b/src/test/javascript/spec/component/code-editor/code-editor-status.spec.ts index 8aad06aebc72..2cc6f41d29b5 100644 --- a/src/test/javascript/spec/component/code-editor/code-editor-status.spec.ts +++ b/src/test/javascript/spec/component/code-editor/code-editor-status.spec.ts @@ -1,3 +1,4 @@ +import { DebugElement } from '@angular/core/'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { AceEditorModule } from 'ng2-ace-editor'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; @@ -30,34 +31,36 @@ describe('CodeEditorStatusComponent', () => { const editorStateSegment = fixture.debugElement.query(By.css('#editor_state')); expect(editorStateSegment.children).to.be.empty; }); + it('should show an empty status segment for EditorState if no EditorState is given', () => { - const commitStateSegement = fixture.debugElement.query(By.css('#commit_state')); - expect(commitStateSegement.children).to.be.empty; + const commitStateSegment = fixture.debugElement.query(By.css('#commit_state')); + expect(commitStateSegment.children).to.be.empty; }); + Object.keys(EditorState).map((editorState) => it(`should show exactly one status segment for EditorState ${editorState} with an icon and a non empty description`, function () { comp.editorState = editorState as EditorState; fixture.detectChanges(); const editorStateSegment = fixture.debugElement.query(By.css('#editor_state')); - expect(editorStateSegment.children).to.have.length(1); - const icon = editorStateSegment.query(By.css('fa-icon')); - expect(icon).to.exist; - const text = editorStateSegment.query(By.css('span')); - expect(text).to.exist; - expect(text.nativeElement.textContent).not.to.equal(''); + showsExactlyOneStatusSegment(editorStateSegment); }), ); + Object.keys(CommitState).map((commitState) => it(`should show exactly one status segment for CommitState ${commitState} with an icon and a non empty description`, function () { comp.commitState = commitState as CommitState; fixture.detectChanges(); - const commitStateSegement = fixture.debugElement.query(By.css('#commit_state')); - expect(commitStateSegement.children).to.have.length(1); - const icon = commitStateSegement.query(By.css('fa-icon')); - expect(icon).to.exist; - const text = commitStateSegement.query(By.css('span')); - expect(text).to.exist; - expect(text.nativeElement.textContent).not.to.equal(''); + const commitStateSegment = fixture.debugElement.query(By.css('#commit_state')); + showsExactlyOneStatusSegment(commitStateSegment); }), ); + + const showsExactlyOneStatusSegment = (stateSegment: DebugElement) => { + expect(stateSegment.children).to.have.length(1); + const icon = stateSegment.query(By.css('fa-icon')); + expect(icon).to.exist; + const text = stateSegment.query(By.css('span')); + expect(text).to.exist; + expect(text.nativeElement.textContent).not.to.equal(''); + }; }); diff --git a/yarn.lock b/yarn.lock index af6647f1f85f..ec86e9c07113 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4976,6 +4976,11 @@ eslint-loader@4.0.0: object-hash "^2.0.3" schema-utils "^2.6.5" +eslint-plugin-chai-friendly@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-chai-friendly/-/eslint-plugin-chai-friendly-0.5.0.tgz#42418c35c4a83584f3b98449b7b8f4f56205a0a3" + integrity sha512-Pxe6z8C9fP0pn2X2nGFU/b3GBOCM/5FVus1hsMwJsXP3R7RiXFl7g0ksJbsc0GxiLyidTW4mEFk77qsNn7Tk7g== + eslint-plugin-prettier@3.1.3: version "3.1.3" resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.3.tgz#ae116a0fc0e598fdae48743a4430903de5b4e6ca" From 71d26957be814b125a42f2c6644083fcf70d718a Mon Sep 17 00:00:00 2001 From: Martin Wauligmann Date: Sat, 18 Apr 2020 13:29:04 +0200 Subject: [PATCH 026/152] Fix complaints.spec.ts, exercise-hint.service.spec.ts, file-upload-assessment.spec.ts --- .../component/complaints/complaints.spec.ts | 5 ++-- .../exercise-hint.service.spec.ts | 4 +-- .../file-upload-assessment.spec.ts | 25 +++++++++++++------ 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/test/javascript/spec/component/complaints/complaints.spec.ts b/src/test/javascript/spec/component/complaints/complaints.spec.ts index 15e4354438d2..1d409bc91390 100644 --- a/src/test/javascript/spec/component/complaints/complaints.spec.ts +++ b/src/test/javascript/spec/component/complaints/complaints.spec.ts @@ -1,14 +1,12 @@ import { async, ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; import * as chai from 'chai'; -import { BrowserModule, By } from '@angular/platform-browser'; +import { By } from '@angular/platform-browser'; import { ComplaintService } from 'app/complaints/complaint.service'; import { MockComplaintResponse, MockComplaintService } from '../../mocks/mock-complaint.service'; import { MockAlertService } from '../../helpers/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; import { MomentModule } from 'ngx-moment'; -import { ClipboardModule } from 'ngx-clipboard'; import { DebugElement } from '@angular/core'; -import { HttpClientModule } from '@angular/common/http'; import { TranslateModule } from '@ngx-translate/core'; import { ComplaintsComponent } from 'app/complaints/complaints.component'; import { ArtemisTestModule } from '../../test.module'; @@ -57,6 +55,7 @@ describe('ComplaintsComponent', () => { expect(textarea.value).to.be.equal(MockComplaintResponse.body.complaintText); expect(textarea.readOnly).to.be.true; })); + it('should show accepted message when complaint is accepted', () => { comp.resultId = 111; comp.ngOnInit(); diff --git a/src/test/javascript/spec/component/exercise-hint/exercise-hint.service.spec.ts b/src/test/javascript/spec/component/exercise-hint/exercise-hint.service.spec.ts index c45c07584f18..27b0c6d19fc1 100644 --- a/src/test/javascript/spec/component/exercise-hint/exercise-hint.service.spec.ts +++ b/src/test/javascript/spec/component/exercise-hint/exercise-hint.service.spec.ts @@ -1,4 +1,3 @@ -/* tslint:disable max-line-length */ import { getTestBed, TestBed } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { HttpResponse } from '@angular/common/http'; @@ -16,6 +15,7 @@ describe('Service Tests', () => { let httpMock: HttpTestingController; let elemDefault: ExerciseHint; let expectedResult: any; + beforeEach(() => { TestBed.configureTestingModule({ imports: [HttpClientTestingModule], @@ -81,7 +81,7 @@ describe('Service Tests', () => { }); it('should delete a ExerciseHint', async () => { - const rxPromise = service.delete(123).subscribe((resp) => (expectedResult = resp.ok)); + service.delete(123).subscribe((resp) => (expectedResult = resp.ok)); const req = httpMock.expectOne({ method: 'DELETE' }); req.flush({ status: 200 }); diff --git a/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.spec.ts b/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.spec.ts index 659697cd01f8..00ed21c4e14f 100644 --- a/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.spec.ts +++ b/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.spec.ts @@ -1,4 +1,4 @@ -import { ComponentFixture, fakeAsync, flush, TestBed, tick } from '@angular/core/testing'; +import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { JhiLanguageHelper } from 'app/core/language/language.helper'; import { AccountService } from 'app/core/auth/account.service'; @@ -13,12 +13,10 @@ import { ArtemisSharedModule } from 'app/shared/shared.module'; import { MockAlertService } from '../../helpers/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; import { Router } from '@angular/router'; -import { of } from 'rxjs'; import { FileUploadAssessmentComponent } from 'app/exercises/file-upload/assess/file-upload-assessment.component'; import { ResizableInstructionsComponent } from 'app/exercises/text/assess/resizable-instructions/resizable-instructions.component'; import { DebugElement } from '@angular/core'; import { MockAccountService } from '../../mocks/mock-account.service'; -import { Location } from '@angular/common'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { ComplaintService } from 'app/complaints/complaint.service'; import { MockComplaintService } from '../../mocks/mock-complaint.service'; @@ -35,10 +33,13 @@ import { AssessmentType } from 'app/entities/assessment-type.model'; import { Result } from 'app/entities/result.model'; import { ModelingAssessmentModule } from 'app/exercises/modeling/assess/modeling-assessment.module'; import { routes } from 'app/exercises/file-upload/assess/file-upload-assessment.route'; -import { Course } from 'app/entities/course.model'; import { By } from '@angular/platform-browser'; +import { throwError } from 'rxjs'; +import { MockActivatedRoute } from '../../mocks/mock-activated-route'; +import { Participation, ParticipationType } from 'app/entities/participation/participation.model'; chai.use(sinonChai); + const expect = chai.expect; describe('FileUploadAssessmentComponent', () => { @@ -48,9 +49,8 @@ describe('FileUploadAssessmentComponent', () => { let getFileUploadSubmissionForExerciseWithoutAssessmentStub: SinonStub; let debugElement: DebugElement; let router: Router; - let location: Location; + const activatedRouteMock: MockActivatedRoute = new MockActivatedRoute(); - const course = { id: 5 } as Course; const exercise = { id: 20, type: ExerciseType.FILE_UPLOAD } as FileUploadExercise; beforeEach(async () => { @@ -85,7 +85,6 @@ describe('FileUploadAssessmentComponent', () => { comp.exercise = exercise; debugElement = fixture.debugElement; router = debugElement.injector.get(Router); - location = debugElement.injector.get(Location); fileUploadSubmissionService = TestBed.inject(FileUploadSubmissionService); getFileUploadSubmissionForExerciseWithoutAssessmentStub = stub(fileUploadSubmissionService, 'getFileUploadSubmissionForExerciseWithoutAssessment'); @@ -98,6 +97,9 @@ describe('FileUploadAssessmentComponent', () => { }); it('AssessNextButton should be visible', fakeAsync(() => { + activatedRouteMock.testParams = { exerciseId: 1, submissionId: 'new' }; + getFileUploadSubmissionForExerciseWithoutAssessmentStub.returns(throwError({ status: 404 })); + // set all attributes for comp comp.ngOnInit(); tick(); @@ -109,6 +111,7 @@ describe('FileUploadAssessmentComponent', () => { submitted: true, type: SubmissionType.MANUAL, submissionDate: moment('2019-07-09T10:47:33.244Z'), + participation: ({ type: ParticipationType.STUDENT, exercise } as unknown) as Participation, } as FileUploadSubmission; comp.result = new Result(); comp.result.id = 2374; @@ -123,11 +126,17 @@ describe('FileUploadAssessmentComponent', () => { comp.result.assessmentType = AssessmentType.MANUAL; comp.result.exampleResult = false; comp.result.hasComplaint = false; + comp.submission.result = comp.result; + comp.submission.participation.submissions = [comp.submission]; + comp.submission.participation.results = [comp.submission.result]; comp.isAssessor = true; comp.isAtLeastInstructor = true; comp.assessmentsAreValid = true; - const unassessedSubmission = { submissionExerciseType: SubmissionExerciseType.FILE_UPLOAD, id: 2279, submitted: true, type: 'MANUAL' }; + comp.isLoading = false; fixture.detectChanges(); + + const assessNextButton = debugElement.query(By.css('#assessNextButton')); + expect(assessNextButton).to.exist; })); }); From 7db130c1b1ff44318922c52daa5ff7dce016ce1d Mon Sep 17 00:00:00 2001 From: Martin Wauligmann Date: Sat, 18 Apr 2020 13:37:56 +0200 Subject: [PATCH 027/152] Fix file-upload-exercise-detail.component.spec.ts and file-upload-result.spec.ts --- .../file-upload-exercise-detail.component.spec.ts | 6 +----- .../file-upload-submission/file-upload-result.spec.ts | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise-detail.component.spec.ts b/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise-detail.component.spec.ts index b46e3fdf490e..8dbbf5680bdb 100644 --- a/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise-detail.component.spec.ts +++ b/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise-detail.component.spec.ts @@ -1,13 +1,10 @@ -/* tslint:disable max-line-length */ import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; import { ActivatedRoute } from '@angular/router'; import { DebugElement } from '@angular/core'; import { of } from 'rxjs'; - import { ArtemisTestModule } from '../../test.module'; import { FileUploadExerciseDetailComponent } from 'app/exercises/file-upload/manage/file-upload-exercise-detail.component'; import { By } from '@angular/platform-browser'; - import * as sinonChai from 'sinon-chai'; import * as chai from 'chai'; import { fileUploadExercise, MockFileUploadExerciseService } from '../../mocks/mock-file-upload-exercise.service'; @@ -33,7 +30,7 @@ describe('Component Tests', () => { let debugElement: DebugElement; const route = ({ - data: of({ fileUploadExercise: fileUploadExercise }), + data: of({ fileUploadExercise }), params: of({ exerciseId: 2 }), } as any) as ActivatedRoute; @@ -61,7 +58,6 @@ describe('Component Tests', () => { describe('Title should contain exercise id and description list', () => { it('Should call load all on init', fakeAsync(() => { comp.ngOnInit(); - tick(); expect(comp.fileUploadExercise).to.equal(fileUploadExercise); diff --git a/src/test/javascript/spec/component/file-upload-submission/file-upload-result.spec.ts b/src/test/javascript/spec/component/file-upload-submission/file-upload-result.spec.ts index 19310d53e2d6..8dd0a1b957cb 100644 --- a/src/test/javascript/spec/component/file-upload-submission/file-upload-result.spec.ts +++ b/src/test/javascript/spec/component/file-upload-submission/file-upload-result.spec.ts @@ -11,7 +11,6 @@ import { DebugElement } from '@angular/core'; import { By } from '@angular/platform-browser'; import { MockAccountService } from '../../mocks/mock-account.service'; import { NgxDatatableModule } from '@swimlane/ngx-datatable'; -import { FileUploadSubmissionComponent } from 'app/exercises/file-upload/participate/file-upload-submission.component'; import { TranslateModule } from '@ngx-translate/core'; import { FileUploadResultComponent } from 'app/exercises/file-upload/participate/file-upload-result.component'; import { ArtemisSharedComponentModule } from 'app/shared/components/shared-component.module'; @@ -63,6 +62,7 @@ describe('FileUploadSubmissionComponent', () => { const groupedFeedbackElements = debugElement.query(By.css('div')); expect(groupedFeedbackElements).to.exist; + // exactly two feedback items are displayed expect(groupedFeedbackElements.childNodes.length).to.be.equal(2); }); From 78527299c8b5bb16796002a21517c9c0ea6a18f7 Mon Sep 17 00:00:00 2001 From: Martin Wauligmann Date: Sat, 18 Apr 2020 13:40:16 +0200 Subject: [PATCH 028/152] Fix file-upload-submission.spec.ts --- .../file-upload-submission/file-upload-submission.spec.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/test/javascript/spec/component/file-upload-submission/file-upload-submission.spec.ts b/src/test/javascript/spec/component/file-upload-submission/file-upload-submission.spec.ts index 026aec0351cd..0999ee84ee72 100644 --- a/src/test/javascript/spec/component/file-upload-submission/file-upload-submission.spec.ts +++ b/src/test/javascript/spec/component/file-upload-submission/file-upload-submission.spec.ts @@ -14,12 +14,11 @@ import { ResizableInstructionsComponent } from 'app/exercises/text/assess/resiza import { DebugElement } from '@angular/core'; import { By } from '@angular/platform-browser'; import { MockAccountService } from '../../mocks/mock-account.service'; -import { Location } from '@angular/common'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { ComplaintService } from 'app/complaints/complaint.service'; import { MockComplaintService } from '../../mocks/mock-complaint.service'; import { NgxDatatableModule } from '@swimlane/ngx-datatable'; -import { fileUploadSubmissionRoute, routes } from 'app/exercises/file-upload/participate/file-upload-participation.route'; +import { routes } from 'app/exercises/file-upload/participate/file-upload-participation.route'; import { FileUploadSubmissionComponent } from 'app/exercises/file-upload/participate/file-upload-submission.component'; import { MomentModule } from 'ngx-moment'; import { createFileUploadSubmission, MockFileUploadSubmissionService } from '../../mocks/mock-file-upload-submission.service'; @@ -50,7 +49,6 @@ describe('FileUploadSubmissionComponent', () => { let fixture: ComponentFixture; let debugElement: DebugElement; let router: Router; - let location: Location; let fileUploaderService: FileUploaderService; let jhiAlertService: AlertService; let fileUploadSubmissionService: FileUploadSubmissionService; @@ -93,7 +91,6 @@ describe('FileUploadSubmissionComponent', () => { comp = fixture.componentInstance; debugElement = fixture.debugElement; router = debugElement.injector.get(Router); - location = debugElement.injector.get(Location); router.initialNavigation(); fileUploaderService = TestBed.inject(FileUploaderService); jhiAlertService = TestBed.inject(AlertService); From d0ff13961b80e4e179eba8d47df22013d47b739a Mon Sep 17 00:00:00 2001 From: F4lka Date: Sat, 18 Apr 2020 21:23:03 +0200 Subject: [PATCH 029/152] removed unused variables --- .../participation-submission/participation-submission.spec.ts | 2 -- .../programming-exercise/build-plan-link.directive.spec.ts | 3 --- .../programming-exercise-instruction-step-wizard.spec.ts | 4 ---- 3 files changed, 9 deletions(-) diff --git a/src/test/javascript/spec/component/participation-submission/participation-submission.spec.ts b/src/test/javascript/spec/component/participation-submission/participation-submission.spec.ts index ad5717c1259c..35e075f63f87 100644 --- a/src/test/javascript/spec/component/participation-submission/participation-submission.spec.ts +++ b/src/test/javascript/spec/component/participation-submission/participation-submission.spec.ts @@ -45,7 +45,6 @@ describe('ParticipationSubmissionComponent', () => { let findAllSubmissionsOfParticipationStub: SinonStub; let debugElement: DebugElement; let router: Router; - let location: Location; beforeEach(async () => { return TestBed.configureTestingModule({ @@ -75,7 +74,6 @@ describe('ParticipationSubmissionComponent', () => { comp.participationId = 1; debugElement = fixture.debugElement; router = debugElement.injector.get(Router); - location = debugElement.injector.get(Location); submissionService = TestBed.inject(SubmissionService); findAllSubmissionsOfParticipationStub = stub(submissionService, 'findAllSubmissionsOfParticipation'); router.initialNavigation(); diff --git a/src/test/javascript/spec/component/programming-exercise/build-plan-link.directive.spec.ts b/src/test/javascript/spec/component/programming-exercise/build-plan-link.directive.spec.ts index c9e147367f7a..b84d7537ecc2 100644 --- a/src/test/javascript/spec/component/programming-exercise/build-plan-link.directive.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/build-plan-link.directive.spec.ts @@ -30,7 +30,6 @@ describe('BuildPlanLinkDirective', () => { let profileService: ProfileService; let getProfileInfoStub: SinonStub; let profileInfoSubject: BehaviorSubject; - let correctBuildPlan: string; const profileInfo = { buildPlanURLTemplate: 'https://some.url.com/plans/{buildPlanId}/path/{projectKey}' } as ProfileInfo; @@ -52,8 +51,6 @@ describe('BuildPlanLinkDirective', () => { profileInfoSubject = new BehaviorSubject(profileInfo); getProfileInfoStub.returns(profileInfoSubject); - - correctBuildPlan = `https://some.url.com/plans/${comp.buildPlanId}/path/${comp.projectKey}`; }); }); diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-step-wizard.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-step-wizard.spec.ts index 69bdfa71c1d5..9b99565f07a0 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-step-wizard.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-step-wizard.spec.ts @@ -21,8 +21,6 @@ describe('ProgrammingExerciseInstructionStepWizard', () => { let fixture: ComponentFixture; let debugElement: DebugElement; - let programmingExerciseInstructionService: ProgrammingExerciseInstructionService; - const stepWizardStep = '.stepwizard-step'; beforeEach(async () => { @@ -37,8 +35,6 @@ describe('ProgrammingExerciseInstructionStepWizard', () => { fixture = TestBed.createComponent(ProgrammingExerciseInstructionStepWizardComponent); comp = fixture.componentInstance; debugElement = fixture.debugElement; - - programmingExerciseInstructionService = debugElement.injector.get(ProgrammingExerciseInstructionService); }); }); From a7e99d229637983390e51a6445a9414de646d1f4 Mon Sep 17 00:00:00 2001 From: F4lka Date: Sat, 18 Apr 2020 21:23:59 +0200 Subject: [PATCH 030/152] moved variables to avoid shadowed varialves --- .../programming-exercise-instruction.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction.spec.ts index 4fe5b5e7bad8..20f8b78c014e 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction.spec.ts @@ -61,7 +61,6 @@ describe('ProgrammingExerciseInstructionComponent', () => { let getHintsForExerciseStub: SinonStub; const exerciseHints = [{ id: 1 }, { id: 2 }]; - const exercise = { id: 1 }; beforeEach(async () => { return TestBed.configureTestingModule({ @@ -109,6 +108,7 @@ describe('ProgrammingExerciseInstructionComponent', () => { }); it('should on participation change clear old subscription for participation results set up new one', () => { + const exercise = { id: 1 }; const oldParticipation = { id: 1 } as Participation; const result = { id: 1 }; const participation = { id: 2, results: [result] } as Participation; From 970e9e375fc33c4f7ae825ebef40e4b08b0a04e8 Mon Sep 17 00:00:00 2001 From: F4lka Date: Sat, 18 Apr 2020 21:42:06 +0200 Subject: [PATCH 031/152] fix participation-submission.spec.ts and build-plan-link.directive.spec.ts --- .../participation-submission/participation-submission.spec.ts | 1 - .../programming-exercise/build-plan-link.directive.spec.ts | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/test/javascript/spec/component/participation-submission/participation-submission.spec.ts b/src/test/javascript/spec/component/participation-submission/participation-submission.spec.ts index 35e075f63f87..d4952e6cca94 100644 --- a/src/test/javascript/spec/component/participation-submission/participation-submission.spec.ts +++ b/src/test/javascript/spec/component/participation-submission/participation-submission.spec.ts @@ -19,7 +19,6 @@ import { AssessmentDetailComponent } from 'app/assessment/assessment-detail/asse import { DebugElement } from '@angular/core'; import { By } from '@angular/platform-browser'; import { MockAccountService } from '../../mocks/mock-account.service'; -import { Location } from '@angular/common'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { ComplaintService } from 'app/complaints/complaint.service'; import { ParticipationSubmissionComponent } from 'app/exercises/shared/participation-submission/participation-submission.component'; diff --git a/src/test/javascript/spec/component/programming-exercise/build-plan-link.directive.spec.ts b/src/test/javascript/spec/component/programming-exercise/build-plan-link.directive.spec.ts index b84d7537ecc2..f95dd794605c 100644 --- a/src/test/javascript/spec/component/programming-exercise/build-plan-link.directive.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/build-plan-link.directive.spec.ts @@ -24,7 +24,6 @@ class TestComponent { } describe('BuildPlanLinkDirective', () => { - let comp: TestComponent; let fixture: ComponentFixture; let debugElement: DebugElement; let profileService: ProfileService; @@ -42,7 +41,6 @@ describe('BuildPlanLinkDirective', () => { .compileComponents() .then(() => { fixture = TestBed.createComponent(TestComponent); - comp = fixture.componentInstance; debugElement = fixture.debugElement; profileService = fixture.debugElement.injector.get(ProfileService); From fb2bcdc5f37cf6d1a0c5075e5c0b5899d9350175 Mon Sep 17 00:00:00 2001 From: ga94taf Date: Sat, 18 Apr 2020 22:27:03 +0200 Subject: [PATCH 032/152] Fix batch of code style issues --- .../student-question-answer.service.spec.ts | 2 +- .../student-question.service.spec.ts | 2 +- .../component/team/team-update-dialog.spec.ts | 2 - .../spec/component/team/teams.spec.ts | 9 +--- .../text-exercise-assessement.spec.ts | 45 +++++++++---------- 5 files changed, 23 insertions(+), 37 deletions(-) diff --git a/src/test/javascript/spec/component/student-questions/student-question-answer.service.spec.ts b/src/test/javascript/spec/component/student-questions/student-question-answer.service.spec.ts index f047094fd611..d2b6517ac948 100644 --- a/src/test/javascript/spec/component/student-questions/student-question-answer.service.spec.ts +++ b/src/test/javascript/spec/component/student-questions/student-question-answer.service.spec.ts @@ -81,7 +81,7 @@ describe('Service Tests', () => { }); it('should delete a StudentQuestionAnswer', async () => { - const rxPromise = service.delete(123).subscribe((resp) => (expectedResult = resp.ok)); + service.delete(123).subscribe((resp) => (expectedResult = resp.ok)); const req = httpMock.expectOne({ method: 'DELETE' }); req.flush({ status: 200 }); diff --git a/src/test/javascript/spec/component/student-questions/student-question.service.spec.ts b/src/test/javascript/spec/component/student-questions/student-question.service.spec.ts index 95d3bcc53354..7d70c08bf88b 100644 --- a/src/test/javascript/spec/component/student-questions/student-question.service.spec.ts +++ b/src/test/javascript/spec/component/student-questions/student-question.service.spec.ts @@ -58,7 +58,7 @@ describe('Service Tests', () => { }); it('should delete a StudentQuestion', async () => { - const rxPromise = service.delete(123).subscribe((resp) => (expectedResult = resp.ok)); + service.delete(123).subscribe((resp) => (expectedResult = resp.ok)); const req = httpMock.expectOne({ method: 'DELETE' }); req.flush({ status: 200 }); diff --git a/src/test/javascript/spec/component/team/team-update-dialog.spec.ts b/src/test/javascript/spec/component/team/team-update-dialog.spec.ts index 847eec97bb8a..8c1a5b418d94 100644 --- a/src/test/javascript/spec/component/team/team-update-dialog.spec.ts +++ b/src/test/javascript/spec/component/team/team-update-dialog.spec.ts @@ -26,7 +26,6 @@ const expect = chai.expect; describe('TeamUpdateDialogComponent', () => { let comp: TeamUpdateDialogComponent; let fixture: ComponentFixture; - let service: TeamService; let debugElement: DebugElement; let ngbActiveModal: NgbActiveModal; @@ -47,7 +46,6 @@ describe('TeamUpdateDialogComponent', () => { fixture = TestBed.createComponent(TeamUpdateDialogComponent); comp = fixture.componentInstance; debugElement = fixture.debugElement; - service = debugElement.injector.get(TeamService); ngbActiveModal = TestBed.inject(NgbActiveModal); }); }); diff --git a/src/test/javascript/spec/component/team/teams.spec.ts b/src/test/javascript/spec/component/team/teams.spec.ts index c36c17fa2ec1..52127534672f 100644 --- a/src/test/javascript/spec/component/team/teams.spec.ts +++ b/src/test/javascript/spec/component/team/teams.spec.ts @@ -7,7 +7,7 @@ import { ArtemisTestModule } from '../../test.module'; import { By } from '@angular/platform-browser'; import { JhiEventManager, NgJhipsterModule } from 'ng-jhipster'; import { FormsModule } from '@angular/forms'; -import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap'; +import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { AlertService } from 'app/core/alert/alert.service'; import { MockAlertService } from '../../helpers/mock-alert.service'; import { ArtemisSharedModule } from 'app/shared/shared.module'; @@ -30,7 +30,6 @@ import { MockExerciseService } from '../../mocks/mock-exercise.service'; import { teamRoute } from 'app/exercises/shared/team/team.route.ts'; import { RouterTestingModule } from '@angular/router/testing'; import { Router } from '@angular/router'; -import { Location } from '@angular/common'; import { ParticipationService } from 'app/exercises/shared/participation/participation.service'; import { MockParticipationService } from '../../mocks/mock-participation.service'; import { AccountService } from 'app/core/auth/account.service'; @@ -42,11 +41,8 @@ const expect = chai.expect; describe('TeamsComponent', () => { let comp: TeamsComponent; let fixture: ComponentFixture; - let service: TeamService; let debugElement: DebugElement; let router: Router; - let location: Location; - let ngbActiveModal: NgbActiveModal; const route = ({ params: of({ exerciseId: 1 }), @@ -88,9 +84,6 @@ describe('TeamsComponent', () => { comp = fixture.componentInstance; debugElement = fixture.debugElement; router = debugElement.injector.get(Router); - location = debugElement.injector.get(Location); - service = debugElement.injector.get(TeamService); - ngbActiveModal = TestBed.inject(NgbActiveModal); router.initialNavigation(); }); }); diff --git a/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.spec.ts b/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.spec.ts index 0060adcf5870..a3a5a6cf3214 100644 --- a/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.spec.ts +++ b/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.spec.ts @@ -1,4 +1,4 @@ -import { ComponentFixture, fakeAsync, flush, TestBed, tick } from '@angular/core/testing'; +import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { JhiLanguageHelper } from 'app/core/language/language.helper'; import { AccountService } from 'app/core/auth/account.service'; @@ -22,7 +22,6 @@ import { AssessmentDetailComponent } from 'app/assessment/assessment-detail/asse import { DebugElement } from '@angular/core'; import { By } from '@angular/platform-browser'; import { MockAccountService } from '../../mocks/mock-account.service'; -import { Location } from '@angular/common'; import { textAssessmentRoutes } from 'app/exercises/text/assess/text-assessment.route'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { ComplaintService } from 'app/complaints/complaint.service'; @@ -31,9 +30,9 @@ import { TranslateModule } from '@ngx-translate/core'; import { TextSubmissionService } from 'app/exercises/text/participate/text-submission.service'; import { ComplaintsForTutorComponent } from 'app/complaints/complaints-for-tutor/complaints-for-tutor.component'; import { ResultComponent } from 'app/shared/result/result.component'; -import { SubmissionExerciseType, SubmissionType } from 'app/entities/submission.model'; +import { Submission, SubmissionExerciseType, SubmissionType } from 'app/entities/submission.model'; import { TextExercise } from 'app/entities/text-exercise.model'; -import { ExerciseType } from 'app/entities/exercise.model'; +import { Exercise, ExerciseType } from 'app/entities/exercise.model'; import { TextSubmission } from 'app/entities/text-submission.model'; import { Participation, ParticipationType } from 'app/entities/participation/participation.model'; import { AssessmentType } from 'app/entities/assessment-type.model'; @@ -55,16 +54,15 @@ describe('TextAssessmentComponent', () => { let getTextSubmissionForExerciseWithoutAssessmentStub: SinonStub; let getFeedbackDataForExerciseSubmissionStub: SinonStub; let saveAssessmentStub: SinonStub; - let submitAsssessmentStub: SinonStub; + let submitAssessmentStub: SinonStub; let getResultWithPredefinedTextblocksStub: SinonStub; let updateAssessmentAfterComplaintStub: SinonStub; let debugElement: DebugElement; let router: Router; - let location: Location; - let activatedRouteMock: MockActivatedRoute = new MockActivatedRoute(); + const activatedRouteMock: MockActivatedRoute = new MockActivatedRoute(); const exercise = { id: 20, type: ExerciseType.TEXT, assessmentType: AssessmentType.MANUAL } as TextExercise; - const participation: Participation = ({ type: ParticipationType.STUDENT, exercise: exercise }); + const participation: Participation = ({ type: ParticipationType.STUDENT, exercise: Exercise }); const submission = { submissionExerciseType: SubmissionExerciseType.TEXT, id: 2278, @@ -72,7 +70,7 @@ describe('TextAssessmentComponent', () => { type: SubmissionType.MANUAL, submissionDate: moment('2019-07-09T10:47:33.244Z'), text: 'asdfasdfasdfasdf', - participation: participation, + participation: Participation, } as TextSubmission; const result = ({ id: 2374, @@ -83,8 +81,8 @@ describe('TextAssessmentComponent', () => { rated: true, hasFeedback: false, hasComplaint: false, - submission: submission, - participation: participation, + submission: Submission, + participation: Participation, } as unknown) as Result; submission.result = result; submission.participation.submissions = [submission]; @@ -122,14 +120,13 @@ describe('TextAssessmentComponent', () => { debugElement = fixture.debugElement; router = debugElement.injector.get(Router); - location = debugElement.injector.get(Location); textSubmissionService = debugElement.injector.get(TextSubmissionService); assessmentsService = debugElement.injector.get(TextAssessmentsService); getTextSubmissionForExerciseWithoutAssessmentStub = stub(textSubmissionService, 'getTextSubmissionForExerciseWithoutAssessment'); getFeedbackDataForExerciseSubmissionStub = stub(assessmentsService, 'getFeedbackDataForExerciseSubmission'); saveAssessmentStub = stub(assessmentsService, 'save'); - submitAsssessmentStub = stub(assessmentsService, 'submit'); + submitAssessmentStub = stub(assessmentsService, 'submit'); getResultWithPredefinedTextblocksStub = stub(assessmentsService, 'getResultWithPredefinedTextblocks'); updateAssessmentAfterComplaintStub = stub(assessmentsService, 'updateAssessmentAfterComplaint'); @@ -141,7 +138,7 @@ describe('TextAssessmentComponent', () => { getTextSubmissionForExerciseWithoutAssessmentStub.restore(); getFeedbackDataForExerciseSubmissionStub.restore(); saveAssessmentStub.restore(); - submitAsssessmentStub.restore(); + submitAssessmentStub.restore(); getResultWithPredefinedTextblocksStub.restore(); updateAssessmentAfterComplaintStub.restore(); }); @@ -162,8 +159,6 @@ describe('TextAssessmentComponent', () => { comp.isAssessor = true; comp.isAtLeastInstructor = true; comp.assessmentsAreValid = true; - const unassessedSubmission = { submissionExerciseType: 'text', id: 2279, submitted: true, type: 'MANUAL' }; - fixture.detectChanges(); // check if assessNextButton is available @@ -193,7 +188,7 @@ describe('TextAssessmentComponent', () => { activatedRouteMock.testParams = { exerciseId: 1, submissionId: 'new' }; getTextSubmissionForExerciseWithoutAssessmentStub.returns(throwError({ error: { errorKey: 'lockedSubmissionsLimitReached' } })); const spy = stub(router, 'navigateByUrl'); - spy.returns(new Promise((resolve) => true)); + spy.returns(new Promise(() => true)); comp.ngOnInit(); tick(); expect(spy.called).to.be.true; @@ -205,7 +200,7 @@ describe('TextAssessmentComponent', () => { exercise.course = course; comp.exercise = exercise; activatedRouteMock.testParams = { exerciseId: 1, submissionId: 'new' }; - getTextSubmissionForExerciseWithoutAssessmentStub.returns(throwError({ headers: { get: (s: string) => 'error' } })); + getTextSubmissionForExerciseWithoutAssessmentStub.returns(throwError({ headers: { get: () => 'error' } })); const spy = stub(TestBed.inject(AlertService), 'error'); spy.returns({ type: 'danger', msg: '' }); comp.ngOnInit(); @@ -299,7 +294,7 @@ describe('TextAssessmentComponent', () => { it('Should handle error on save assessment', fakeAsync(() => { comp.referencedFeedback = [refFeedback]; comp.result = { id: 1 } as any; - saveAssessmentStub.returns(throwError({ headers: { get: (s: string) => 'error' } })); + saveAssessmentStub.returns(throwError({ headers: { get: () => 'error' } })); const spy = stub(TestBed.inject(AlertService), 'error'); spy.returns({ type: 'danger', msg: '' }); comp.save(); @@ -325,9 +320,9 @@ describe('TextAssessmentComponent', () => { comp.result = { id: 1 } as any; participation.results = []; comp.participation = participation; - submitAsssessmentStub.returns(of({ body: result })); + submitAssessmentStub.returns(of({ body: result })); comp.submit(); - expect(submitAsssessmentStub.called).to.be.true; + expect(submitAssessmentStub.called).to.be.true; expect(comp.result).to.be.equal(result); expect(comp.participation.results[0]).to.be.equal(result); expect(comp.showResult).to.be.true; @@ -335,16 +330,16 @@ describe('TextAssessmentComponent', () => { it('Should not submit without already existing result', fakeAsync(() => { comp.result = {} as any; - submitAsssessmentStub.returns(of({ body: result })); + submitAssessmentStub.returns(of({ body: result })); comp.submit(); - expect(submitAsssessmentStub.called).to.be.false; + expect(submitAssessmentStub.called).to.be.false; })); it('Should not submit without valid assessments', fakeAsync(() => { comp.result = { id: 1 } as any; - submitAsssessmentStub.returns(of({ body: result })); + submitAssessmentStub.returns(of({ body: result })); comp.submit(); - expect(submitAsssessmentStub.called).to.be.false; + expect(submitAssessmentStub.called).to.be.false; })); it('Should set predefined text blocks', fakeAsync(() => { From dc2c84ce76598ba955075bd86ff5f06e4efe1c70 Mon Sep 17 00:00:00 2001 From: F4lka Date: Sun, 19 Apr 2020 10:23:56 +0200 Subject: [PATCH 033/152] fix code style issues --- .../programming-exercise-instruction.spec.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction.spec.ts index 20f8b78c014e..d65dc6f8ec6b 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction.spec.ts @@ -164,8 +164,8 @@ describe('ProgrammingExerciseInstructionComponent', () => { it('should NOT try to fetch README.md from assignment repository if a problemStatement was provided', () => { const result = { id: 1, feedbacks: [] as Feedback[] } as Result; const participation = { id: 2 } as Participation; - const problemStatement = 'lorem ipsum'; - const exercise = { id: 3, course: { id: 4 }, problemStatement } as ProgrammingExercise; + const problemstatement = 'lorem ipsum'; + const exercise = { id: 3, course: { id: 4 }, problemStatement: problemstatement } as ProgrammingExercise; const loadInitialResultStub = stub(comp, 'loadInitialResult').returns(of(result)); const updateMarkdownStub = stub(comp, 'updateMarkdown'); comp.participation = participation; @@ -259,8 +259,8 @@ describe('ProgrammingExerciseInstructionComponent', () => { it('should still render the instructions if fetching the latest result fails', () => { const participation = { id: 2 } as Participation; - const problemStatement = 'lorem ipsum'; - const exercise = { id: 3, course: { id: 4 }, problemStatement } as ProgrammingExercise; + const problemstatement = 'lorem ipsum'; + const exercise = { id: 3, course: { id: 4 }, problemStatement: problemstatement } as ProgrammingExercise; const updateMarkdownStub = stub(comp, 'updateMarkdown'); getLatestResultWithFeedbacks.returns(throwError('fatal error')); comp.participation = participation; From 263dd1330eeec27688e906e6ab5bbf77b75fc5b2 Mon Sep 17 00:00:00 2001 From: F4lka Date: Sun, 19 Apr 2020 10:24:35 +0200 Subject: [PATCH 034/152] fix code style issues --- .../programming-exercise.component.spec.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.component.spec.ts b/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.component.spec.ts index 408e1fc7ad0d..27ddfcaf9fe4 100644 --- a/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.component.spec.ts +++ b/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.component.spec.ts @@ -7,6 +7,10 @@ import { ArtemisTestModule } from '../../../test.module'; import { ProgrammingExerciseComponent } from 'app/exercises/programming/shared/programming-exercise.component'; import { ProgrammingExerciseService } from 'app/exercises/programming/manage/services/programming-exercise.service'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; +import { MockSyncStorage } from '../../../mocks/mock-sync.storage'; +import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; +import { TranslateService } from '@ngx-translate/core'; +import { MockTranslateService } from '../../../mocks/mock-translate.service'; describe('Component Tests', () => { describe('ProgrammingExercise Management Component', () => { @@ -18,7 +22,11 @@ describe('Component Tests', () => { TestBed.configureTestingModule({ imports: [ArtemisTestModule], declarations: [ProgrammingExerciseComponent], - providers: [], + providers: [ + { provide: LocalStorageService, useClass: MockSyncStorage }, + { provide: SessionStorageService, useClass: MockSyncStorage }, + { provide: TranslateService, useClass: MockTranslateService }, + ], }) .overrideTemplate(ProgrammingExerciseComponent, '') .compileComponents(); @@ -26,6 +34,9 @@ describe('Component Tests', () => { fixture = TestBed.createComponent(ProgrammingExerciseComponent); comp = fixture.componentInstance; service = fixture.debugElement.injector.get(ProgrammingExerciseService); + comp.route.params.subscribe((params) => { + comp.instanceNumber = params['12345']; + }); }); it('Should call load all on init', () => { From 5304b07758c9adc8dddcb4ef970aedded7562615 Mon Sep 17 00:00:00 2001 From: F4lka Date: Sun, 19 Apr 2020 10:57:42 +0200 Subject: [PATCH 035/152] Revert "fix code style issues" This reverts commit 263dd133 --- .../programming-exercise.component.spec.ts | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.component.spec.ts b/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.component.spec.ts index 27ddfcaf9fe4..408e1fc7ad0d 100644 --- a/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.component.spec.ts +++ b/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.component.spec.ts @@ -7,10 +7,6 @@ import { ArtemisTestModule } from '../../../test.module'; import { ProgrammingExerciseComponent } from 'app/exercises/programming/shared/programming-exercise.component'; import { ProgrammingExerciseService } from 'app/exercises/programming/manage/services/programming-exercise.service'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; -import { MockSyncStorage } from '../../../mocks/mock-sync.storage'; -import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; -import { TranslateService } from '@ngx-translate/core'; -import { MockTranslateService } from '../../../mocks/mock-translate.service'; describe('Component Tests', () => { describe('ProgrammingExercise Management Component', () => { @@ -22,11 +18,7 @@ describe('Component Tests', () => { TestBed.configureTestingModule({ imports: [ArtemisTestModule], declarations: [ProgrammingExerciseComponent], - providers: [ - { provide: LocalStorageService, useClass: MockSyncStorage }, - { provide: SessionStorageService, useClass: MockSyncStorage }, - { provide: TranslateService, useClass: MockTranslateService }, - ], + providers: [], }) .overrideTemplate(ProgrammingExerciseComponent, '') .compileComponents(); @@ -34,9 +26,6 @@ describe('Component Tests', () => { fixture = TestBed.createComponent(ProgrammingExerciseComponent); comp = fixture.componentInstance; service = fixture.debugElement.injector.get(ProgrammingExerciseService); - comp.route.params.subscribe((params) => { - comp.instanceNumber = params['12345']; - }); }); it('Should call load all on init', () => { From b9d59134df436df6074dc6471c18e810acee5099 Mon Sep 17 00:00:00 2001 From: Clemens Zuck Date: Sun, 19 Apr 2020 11:36:57 +0200 Subject: [PATCH 036/152] fix code-editor-file-browser.spec.ts --- .../code-editor-file-browser.spec.ts | 103 +++++++++--------- 1 file changed, 50 insertions(+), 53 deletions(-) diff --git a/src/test/javascript/spec/component/code-editor/code-editor-file-browser.spec.ts b/src/test/javascript/spec/component/code-editor/code-editor-file-browser.spec.ts index 9df585545167..ff1476b3151b 100644 --- a/src/test/javascript/spec/component/code-editor/code-editor-file-browser.spec.ts +++ b/src/test/javascript/spec/component/code-editor/code-editor-file-browser.spec.ts @@ -139,56 +139,54 @@ describe('CodeEditorFileBrowserComponent', () => { 'folder2/folder3': FileType.FOLDER, 'folder2/folder3/file3': FileType.FILE, }; - const expectedTreeviewItems = [ - new TreeviewItem({ - internalDisabled: false, - internalChecked: false, - internalCollapsed: false, - text: 'folder', - value: 'folder', - internalChildren: [ - new TreeviewItem({ - internalDisabled: false, - internalChecked: false, - internalCollapsed: false, - text: 'file1', - value: 'folder/file1', - } as any), - ], - } as any), - new TreeviewItem({ - internalDisabled: false, - internalChecked: false, - internalCollapsed: false, - text: 'folder2', - value: 'folder2', - internalChildren: [ - new TreeviewItem({ - internalDisabled: false, - internalChecked: false, - internalCollapsed: false, - text: 'file2', - value: 'folder2/file2', - } as any), - new TreeviewItem({ - internalDisabled: false, - internalChecked: false, - internalCollapsed: false, - text: 'folder3', - value: 'folder2/folder3', - internalChildren: [ - new TreeviewItem({ - internalDisabled: false, - internalChecked: false, - internalCollapsed: false, - text: 'file3', - value: 'folder2/file3', - } as any), - ], - } as any), - ], - } as any), - ]; + new TreeviewItem({ + internalDisabled: false, + internalChecked: false, + internalCollapsed: false, + text: 'folder', + value: 'folder', + internalChildren: [ + new TreeviewItem({ + internalDisabled: false, + internalChecked: false, + internalCollapsed: false, + text: 'file1', + value: 'folder/file1', + } as any), + ], + } as any); + new TreeviewItem({ + internalDisabled: false, + internalChecked: false, + internalCollapsed: false, + text: 'folder2', + value: 'folder2', + internalChildren: [ + new TreeviewItem({ + internalDisabled: false, + internalChecked: false, + internalCollapsed: false, + text: 'file2', + value: 'folder2/file2', + } as any), + new TreeviewItem({ + internalDisabled: false, + internalChecked: false, + internalCollapsed: false, + text: 'folder3', + value: 'folder2/folder3', + internalChildren: [ + new TreeviewItem({ + internalDisabled: false, + internalChecked: false, + internalCollapsed: false, + text: 'file3', + value: 'folder2/file3', + } as any), + ], + } as any), + ], + } as any); comp.repositoryFiles = repositoryFiles; comp.setupTreeview(); fixture.detectChanges(); @@ -311,7 +309,7 @@ describe('CodeEditorFileBrowserComponent', () => { folder2: FileType.FOLDER, 'folder/file2': FileType.FILE, }; - const treeItems = [ + comp.filesTreeViewItem = [ new TreeviewItem({ internalDisabled: false, internalChecked: false, @@ -327,7 +325,6 @@ describe('CodeEditorFileBrowserComponent', () => { value: 'file2', } as any), ]; - comp.filesTreeViewItem = treeItems; comp.repositoryFiles = repositoryFiles; comp.selectedFile = selectedFile; triggerChanges(comp, { property: 'selectedFile', currentValue: 'folder/file2', firstChange: false }); @@ -349,7 +346,7 @@ describe('CodeEditorFileBrowserComponent', () => { expect(areUnSelected).to.be.true; }); - it('should add file to node tree if created', fakeAsync((done: any) => { + it('should add file to node tree if created', fakeAsync(() => { const fileName = 'file2'; const filePath = 'folder2/file2'; const repositoryFiles = { file1: FileType.FILE, folder2: FileType.FOLDER }; From b275f112fb7a972a4c3a6edeb7bb3e1b07df9906 Mon Sep 17 00:00:00 2001 From: Clemens Zuck Date: Sun, 19 Apr 2020 11:50:47 +0200 Subject: [PATCH 037/152] fix code-editor-file-browser.spec.ts again --- .../code-editor-file-browser.spec.ts | 48 ------------------- 1 file changed, 48 deletions(-) diff --git a/src/test/javascript/spec/component/code-editor/code-editor-file-browser.spec.ts b/src/test/javascript/spec/component/code-editor/code-editor-file-browser.spec.ts index ff1476b3151b..78ac5d0c29c0 100644 --- a/src/test/javascript/spec/component/code-editor/code-editor-file-browser.spec.ts +++ b/src/test/javascript/spec/component/code-editor/code-editor-file-browser.spec.ts @@ -139,54 +139,6 @@ describe('CodeEditorFileBrowserComponent', () => { 'folder2/folder3': FileType.FOLDER, 'folder2/folder3/file3': FileType.FILE, }; - new TreeviewItem({ - internalDisabled: false, - internalChecked: false, - internalCollapsed: false, - text: 'folder', - value: 'folder', - internalChildren: [ - new TreeviewItem({ - internalDisabled: false, - internalChecked: false, - internalCollapsed: false, - text: 'file1', - value: 'folder/file1', - } as any), - ], - } as any); - new TreeviewItem({ - internalDisabled: false, - internalChecked: false, - internalCollapsed: false, - text: 'folder2', - value: 'folder2', - internalChildren: [ - new TreeviewItem({ - internalDisabled: false, - internalChecked: false, - internalCollapsed: false, - text: 'file2', - value: 'folder2/file2', - } as any), - new TreeviewItem({ - internalDisabled: false, - internalChecked: false, - internalCollapsed: false, - text: 'folder3', - value: 'folder2/folder3', - internalChildren: [ - new TreeviewItem({ - internalDisabled: false, - internalChecked: false, - internalCollapsed: false, - text: 'file3', - value: 'folder2/file3', - } as any), - ], - } as any), - ], - } as any); comp.repositoryFiles = repositoryFiles; comp.setupTreeview(); fixture.detectChanges(); From ca0ced638714e05bd24215f573d81eff620e08ca Mon Sep 17 00:00:00 2001 From: Balazs Czopf Date: Sun, 19 Apr 2020 12:38:23 +0200 Subject: [PATCH 038/152] fix code style issues --- .../programming-exercise-instructor-status.spec.ts | 2 -- ...rogramming-exercise-instructor-submission-state.spec.ts | 2 -- .../programming-exercise-manage-test-cases.spec.ts | 7 ------- 3 files changed, 11 deletions(-) diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-status.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-status.spec.ts index 3f75dc8db887..98cc13459ecf 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-status.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-status.spec.ts @@ -28,7 +28,6 @@ describe('ProgrammingExerciseInstructorStatusComponent', () => { let fixture: ComponentFixture; let participationWebsocketService: ParticipationWebsocketService; let subscribeForLatestResultStub: SinonStub; - let addParticipationToListStub: SinonStub; let latestResultSubject: Subject; beforeEach(async(() => { @@ -48,7 +47,6 @@ describe('ProgrammingExerciseInstructorStatusComponent', () => { participationWebsocketService = fixture.debugElement.injector.get(ParticipationWebsocketService); - addParticipationToListStub = stub(participationWebsocketService, 'addParticipation'); subscribeForLatestResultStub = stub(participationWebsocketService, 'subscribeForLatestResultOfParticipation'); latestResultSubject = new Subject(); subscribeForLatestResultStub.returns(latestResultSubject); diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-submission-state.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-submission-state.spec.ts index 1084cac09d0b..c07d7d255227 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-submission-state.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-submission-state.spec.ts @@ -36,7 +36,6 @@ describe('ProgrammingExerciseInstructorSubmissionState', () => { let getExerciseSubmissionStateStub: SinonStub; let getExerciseSubmissionStateSubject: Subject; - let getBuildRunStateStub: SinonStub; let getBuildRunStateSubject: Subject; let triggerAllStub: SinonStub; @@ -75,7 +74,6 @@ describe('ProgrammingExerciseInstructorSubmissionState', () => { getExerciseSubmissionStateStub = stub(submissionService, 'getSubmissionStateOfExercise').returns(getExerciseSubmissionStateSubject); getBuildRunStateSubject = new Subject(); - getBuildRunStateStub = stub(buildRunService, 'getBuildRunUpdates').returns(getBuildRunStateSubject); triggerAllStub = stub(submissionService, 'triggerInstructorBuildForParticipationsOfExercise').returns(of()); triggerParticipationsStub = stub(submissionService, 'triggerInstructorBuildForAllParticipationsOfExercise').returns(of()); diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-manage-test-cases.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-manage-test-cases.spec.ts index 03ab8aa2995d..22b2c190460c 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-manage-test-cases.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-manage-test-cases.spec.ts @@ -62,7 +62,6 @@ describe('ProgrammingExerciseManageTestCases', () => { const tableEditingInput = '.table-editable-field__input'; const rowClass = 'datatable-body-row'; const saveTestCasesButton = '#save-test-cases-button'; - const resetWeightsButton = '#reset-weights-button'; const triggerSubmissionRunButton = '#trigger-all-button > button'; const testCasesNoUnsavedChanges = '#test-case-status-no-unsaved-changes'; const testCasesUnsavedChanges = '#test-case-status-unsaved-changes'; @@ -97,10 +96,6 @@ describe('ProgrammingExerciseManageTestCases', () => { return getElement(debugElement, saveTestCasesButton); }; - const getResetButton = () => { - return getElement(debugElement, resetWeightsButton); - }; - const getTriggerButton = () => { return getElement(debugElement, triggerSubmissionRunButton); }; @@ -343,8 +338,6 @@ describe('ProgrammingExerciseManageTestCases', () => { routeSubject.next({ exerciseId }); getExerciseTestCaseStateSubject.next(getExerciseTestCasteStateDTO(true, true, false, null)); - const orderedTests = _sortBy(testCases1, 'testName'); - (testCaseService as any).next(testCases1); fixture.detectChanges(); From 22d7f1efc0df3d6bac0dbf42501486b6d39eea3f Mon Sep 17 00:00:00 2001 From: ge72zan Date: Sun, 19 Apr 2020 16:55:39 +0200 Subject: [PATCH 039/152] turn off "no-unused-vars" warning for mock TypeScript files --- .eslintrc.json | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.eslintrc.json b/.eslintrc.json index e76a2b318751..029a4b7f7b40 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -37,5 +37,11 @@ ], "@typescript-eslint/no-non-null-assertion": "off", "chai-friendly/no-unused-expressions": 2 - } + }, + "overrides": [{ + "files": ["mock-*.ts"], + "rules": { + "@typescript-eslint/no-unused-vars": "off" + } + }] } From b5239d0156e2c90c8ccc7686c080a749005d4a77 Mon Sep 17 00:00:00 2001 From: Birtan Date: Sun, 19 Apr 2020 17:01:23 +0200 Subject: [PATCH 040/152] Fix delete-dialog-service.spec.ts and guided-tour.service.spec.ts --- .../spec/service/delete-dialog-service.spec.ts | 5 +++-- .../spec/service/guided-tour.service.spec.ts | 18 +++++++----------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/test/javascript/spec/service/delete-dialog-service.spec.ts b/src/test/javascript/spec/service/delete-dialog-service.spec.ts index e5790118991b..3309249adaad 100644 --- a/src/test/javascript/spec/service/delete-dialog-service.spec.ts +++ b/src/test/javascript/spec/service/delete-dialog-service.spec.ts @@ -12,6 +12,7 @@ import { TranslateModule } from '@ngx-translate/core'; import { AlertService } from 'app/core/alert/alert.service'; import { ActionType, DeleteDialogData } from 'app/shared/delete-dialog/delete-dialog.model'; import { EventEmitter } from '@angular/core'; +import { Observable } from 'rxjs'; chai.use(sinonChai); const expect = chai.expect; @@ -33,6 +34,7 @@ describe('Delete Dialog Service', () => { it('should open delete dialog', () => { expect(service.modalRef).to.be.undefined; const data: DeleteDialogData = { + dialogError: new Observable(), entityTitle: 'title', deleteQuestion: 'artemisApp.exercise.delete.question', deleteConfirmationText: 'artemisApp.exercise.delete.typeNameToConfirm', @@ -42,8 +44,7 @@ describe('Delete Dialog Service', () => { const modalSpy = sinon.spy(modalService, 'open'); service.openDeleteDialog(data); expect(modalSpy.callCount).to.be.equal(1); - let call = modalSpy.getCall(0); - let args = call.args; + const args = modalSpy.getCall(0).args; expect(args[0].name).to.be.equal('DeleteDialogComponent'); expect(args[1]).to.be.not.null; }); diff --git a/src/test/javascript/spec/service/guided-tour.service.spec.ts b/src/test/javascript/spec/service/guided-tour.service.spec.ts index 46a0977d13ce..79a968fd3a37 100644 --- a/src/test/javascript/spec/service/guided-tour.service.spec.ts +++ b/src/test/javascript/spec/service/guided-tour.service.spec.ts @@ -87,7 +87,7 @@ describe('GuidedTourService', () => { describe('Service method', () => { let service: GuidedTourService; - let httpMock: any; + let httpMock: HttpTestingController; const expected = new GuidedTourSetting('guided_tour_key', 1, GuidedTourState.STARTED); beforeEach(() => { @@ -171,9 +171,6 @@ describe('GuidedTourService', () => { guidedTourComponentFixture = TestBed.createComponent(GuidedTourComponent); guidedTourComponent = guidedTourComponentFixture.componentInstance; - const navBarComponentFixture = TestBed.createComponent(NavbarComponent); - const navBarComponent = navBarComponentFixture.componentInstance; - router = TestBed.inject(Router); guidedTourService = TestBed.inject(GuidedTourService); participationService = TestBed.inject(ParticipationService); @@ -187,7 +184,7 @@ describe('GuidedTourService', () => { }); }); - function prepareGuidedTour(tour: GuidedTour) { + function prepareGuidedTour(guidedTour: GuidedTour) { // Prepare GuidedTourService and GuidedTourComponent spyOn(guidedTourService, 'init').and.returnValue(of()); spyOn(guidedTourService, 'getLastSeenTourStepIndex').and.returnValue(0); @@ -195,13 +192,13 @@ describe('GuidedTourService', () => { spyOn(guidedTourService, 'checkTourState').and.returnValue(true); spyOn(guidedTourService, 'updateGuidedTourSettings').and.returnValue(of()); spyOn(guidedTourService, 'enableTour').and.callFake(() => { - guidedTourService['availableTourForComponent'] = tour; - guidedTourService.currentTour = tour; + guidedTourService['availableTourForComponent'] = guidedTour; + guidedTourService.currentTour = guidedTour; }); spyOn(guidedTourComponent, 'subscribeToDotChanges').and.callFake(() => {}); } - async function startCourseOverviewTour(tour: GuidedTour) { + async function startCourseOverviewTour(guidedTour: GuidedTour) { guidedTourComponent.ngAfterViewInit(); await guidedTourComponentFixture.ngZone!.run(() => { @@ -210,7 +207,7 @@ describe('GuidedTourService', () => { // Start course overview tour expect(guidedTourComponentFixture.debugElement.query(By.css('.tour-step'))).to.not.exist; - guidedTourService['enableTour'](tour, true); + guidedTourService['enableTour'](guidedTour, true); guidedTourService['startTour'](); guidedTourComponentFixture.detectChanges(); expect(guidedTourComponentFixture.debugElement.query(By.css('.tour-step'))).to.exist; @@ -309,8 +306,7 @@ describe('GuidedTourService', () => { expect(guidedTourService['currentExercise']).to.equal(exercise1); resetCurrentTour(); - const tourWithoutExerciseMapping = { courseShortName: 'tutorial', tours: { tour_with_course_and_exercise: '' } } as GuidedTourMapping; - guidedTourService.guidedTourMapping = tourWithoutExerciseMapping; + guidedTourService.guidedTourMapping = { courseShortName: 'tutorial', tours: { tour_with_course_and_exercise: '' } } as GuidedTourMapping; // enable tour for matching course title guidedTourService.enableTourForCourseOverview(courses, tourWithCourseAndExercise, true); From 9aee646d15f9c64536a1500bdf0d469ace0daae7 Mon Sep 17 00:00:00 2001 From: Birtan Date: Sun, 19 Apr 2020 18:09:55 +0200 Subject: [PATCH 041/152] Fix batch of code style issues --- src/test/javascript/spec/helpers/mock-websocket.service.ts | 2 +- src/test/javascript/spec/service/account-service.spec.ts | 4 +--- .../javascript/spec/service/delete-dialog-service.spec.ts | 1 - 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/test/javascript/spec/helpers/mock-websocket.service.ts b/src/test/javascript/spec/helpers/mock-websocket.service.ts index fbaeabd21b87..8f14acd63190 100644 --- a/src/test/javascript/spec/helpers/mock-websocket.service.ts +++ b/src/test/javascript/spec/helpers/mock-websocket.service.ts @@ -1,5 +1,5 @@ import { SpyObject } from './spyobject'; -import { JhiWebsocketService } from '../../../../main/webapp/app/core/websocket/websocket.service'; +import { JhiWebsocketService } from 'app/core/websocket/websocket.service'; export class MockTrackerService extends SpyObject { constructor() { diff --git a/src/test/javascript/spec/service/account-service.spec.ts b/src/test/javascript/spec/service/account-service.spec.ts index ca5915ded337..94d4b476ffb8 100644 --- a/src/test/javascript/spec/service/account-service.spec.ts +++ b/src/test/javascript/spec/service/account-service.spec.ts @@ -1,7 +1,7 @@ import { async } from '@angular/core/testing'; import * as chai from 'chai'; import { SinonStub, stub } from 'sinon'; -import { Observable, of } from 'rxjs'; +import { of } from 'rxjs'; import * as sinonChai from 'sinon-chai'; import { MockWebsocketService } from '../mocks/mock-websocket.service'; import { MockLanguageService } from '../helpers/mock-language.service'; @@ -18,7 +18,6 @@ describe('AccountService', () => { let accountService: AccountService; let httpService: MockHttpService; let getStub: SinonStub; - let getAuthenticated: Observable; const getUserUrl = 'undefinedapi/account'; const user = { id: 1, groups: ['USER'] } as User; @@ -29,7 +28,6 @@ describe('AccountService', () => { // @ts-ignore accountService = new AccountService(new MockLanguageService(), new MockSyncStorage(), httpService, new MockWebsocketService(), new MockFeatureToggleService()); getStub = stub(httpService, 'get'); - getAuthenticated = accountService.getAuthenticationState(); expect(accountService.userIdentity).to.deep.equal(null); expect(accountService.isAuthenticated()).to.be.false; diff --git a/src/test/javascript/spec/service/delete-dialog-service.spec.ts b/src/test/javascript/spec/service/delete-dialog-service.spec.ts index 3309249adaad..788d6f011426 100644 --- a/src/test/javascript/spec/service/delete-dialog-service.spec.ts +++ b/src/test/javascript/spec/service/delete-dialog-service.spec.ts @@ -7,7 +7,6 @@ import { ArtemisTestModule } from '../test.module'; import { DeleteDialogService } from 'app/shared/delete-dialog/delete-dialog.service'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import * as sinon from 'sinon'; -import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component'; import { TranslateModule } from '@ngx-translate/core'; import { AlertService } from 'app/core/alert/alert.service'; import { ActionType, DeleteDialogData } from 'app/shared/delete-dialog/delete-dialog.model'; From 833720b67fe9c4762139de424d707ec92869820a Mon Sep 17 00:00:00 2001 From: Can Arisan Date: Sun, 19 Apr 2020 20:02:17 +0300 Subject: [PATCH 042/152] fix mock-auth-server-provider.service.ts --- .../spec/mocks/mock-auth-server-provider.service.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/test/javascript/spec/mocks/mock-auth-server-provider.service.ts b/src/test/javascript/spec/mocks/mock-auth-server-provider.service.ts index 287049f0974e..fa7a56dbf65f 100644 --- a/src/test/javascript/spec/mocks/mock-auth-server-provider.service.ts +++ b/src/test/javascript/spec/mocks/mock-auth-server-provider.service.ts @@ -1,11 +1,12 @@ import { Credentials, IAuthServerProvider } from 'app/core/auth/auth-jwt.service'; +import { Observable } from 'rxjs/Observable'; import { of } from 'rxjs'; export class MockAuthServerProviderService implements IAuthServerProvider { getToken = () => 'abc'; - login = (credentials: Credentials) => of('abc'); - loginWithToken = (jwt: string, rememberMe: string) => Promise.resolve('abc'); + login = (credentials: Credentials) => Observable.empty(); + loginWithToken = (jwt: string, rememberMe: boolean) => Promise.resolve('abc'); removeAuthTokenFromCaches = () => of(null); clearCaches = () => of(null); - storeAuthenticationToken = (jwt: string, rememberMe: string) => {}; + storeAuthenticationToken = (jwt: string, rememberMe: boolean) => {}; } From d4d10143949a4ba53ff46bb5eb117506d8971122 Mon Sep 17 00:00:00 2001 From: Can Arisan Date: Sun, 19 Apr 2020 21:40:34 +0300 Subject: [PATCH 043/152] Fix mock-cookie.service.ts --- .../javascript/spec/mocks/mock-cookie.service.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/test/javascript/spec/mocks/mock-cookie.service.ts b/src/test/javascript/spec/mocks/mock-cookie.service.ts index 2736019064bf..6873351c1493 100644 --- a/src/test/javascript/spec/mocks/mock-cookie.service.ts +++ b/src/test/javascript/spec/mocks/mock-cookie.service.ts @@ -1,11 +1,11 @@ -import { CookieOptions, ICookieService } from 'ngx-cookie-service'; +import { CookieService } from 'ngx-cookie-service'; -export class MockCookieService implements ICookieService { +export class MockCookieService extends CookieService { get(key: string): string { return ''; } - getAll(): Object { + getAll(): any { return {}; } @@ -13,11 +13,11 @@ export class MockCookieService implements ICookieService { return {}; } - put(key: string, value: string, options?: CookieOptions): void {} + put(key: string, value: string, options?: any): void {} - putObject(key: string, value: Object, options?: CookieOptions): void {} + putObject(key: string, value: Object, options?: any): void {} - remove(key: string, options?: CookieOptions): void {} + remove(key: string, options?: any): void {} - removeAll(options?: CookieOptions): void {} + removeAll(options?: any): void {} } From 774d48eccb15894d03b8eab9cb3026d370ac5f20 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Sun, 19 Apr 2020 23:09:14 +0200 Subject: [PATCH 044/152] Fix code style in quiz related files --- .../exercise-generation/quiz-exercise-generator.ts | 2 +- .../quiz/manage/quiz-exercise-detail.component.ts | 6 +++--- .../exercises/quiz/manage/quiz-exercise-popup.service.ts | 4 ++-- .../app/exercises/quiz/manage/quiz-exercise.service.ts | 4 ++-- .../re-evaluate/quiz-re-evaluate-warning.component.ts | 8 +++----- .../quiz-point-statistic.component.ts | 2 +- .../quiz/participate/quiz-participation.component.ts | 2 +- 7 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/main/webapp/app/exercises/quiz/manage/apollon-diagrams/exercise-generation/quiz-exercise-generator.ts b/src/main/webapp/app/exercises/quiz/manage/apollon-diagrams/exercise-generation/quiz-exercise-generator.ts index 21a28852950e..4796daf532d4 100644 --- a/src/main/webapp/app/exercises/quiz/manage/apollon-diagrams/exercise-generation/quiz-exercise-generator.ts +++ b/src/main/webapp/app/exercises/quiz/manage/apollon-diagrams/exercise-generation/quiz-exercise-generator.ts @@ -300,7 +300,7 @@ function createCorrectMappings(dragItems: Map, dropLocations: if (!dragElement || !dragElement.name) { continue; } - for (const [dropLocationElementId, _] of dropLocations.entries()) { + for (const [dropLocationElementId] of dropLocations.entries()) { const dropElement = textualElements.find((element) => element.id === dropLocationElementId); if (!dropElement || dropElement.id === dragElement.id || dropElement.owner === dragElement.owner || dropElement.name !== dragElement.name) { continue; diff --git a/src/main/webapp/app/exercises/quiz/manage/quiz-exercise-detail.component.ts b/src/main/webapp/app/exercises/quiz/manage/quiz-exercise-detail.component.ts index 54af857d8b56..dd1e0d374c4b 100644 --- a/src/main/webapp/app/exercises/quiz/manage/quiz-exercise-detail.component.ts +++ b/src/main/webapp/app/exercises/quiz/manage/quiz-exercise-detail.component.ts @@ -957,7 +957,7 @@ export class QuizExerciseDetailComponent implements OnInit, OnChanges, Component this.onSaveError(); } }, - (res: HttpErrorResponse) => this.onSaveError(res), + () => this.onSaveError(), ); this.pendingChangesCache = false; } else { @@ -969,7 +969,7 @@ export class QuizExerciseDetailComponent implements OnInit, OnChanges, Component this.onSaveError(); } }, - (res: HttpErrorResponse) => this.onSaveError(res), + () => this.onSaveError(), ); this.pendingChangesCache = false; } @@ -993,7 +993,7 @@ export class QuizExerciseDetailComponent implements OnInit, OnChanges, Component * @function onSaveError * @desc Callback function for when the save fails */ - private onSaveError = (error?: HttpErrorResponse): void => { + private onSaveError = (): void => { console.error('Saving Quiz Failed! Please try again later.'); this.jhiAlertService.error('artemisApp.quizExercise.saveError'); this.isSaving = false; diff --git a/src/main/webapp/app/exercises/quiz/manage/quiz-exercise-popup.service.ts b/src/main/webapp/app/exercises/quiz/manage/quiz-exercise-popup.service.ts index c81b4a59c152..0c1723d58e74 100644 --- a/src/main/webapp/app/exercises/quiz/manage/quiz-exercise-popup.service.ts +++ b/src/main/webapp/app/exercises/quiz/manage/quiz-exercise-popup.service.ts @@ -13,7 +13,7 @@ export class QuizExercisePopupService { } open(component: Component, quizExercise: QuizExercise): Promise { - return new Promise((resolve, reject) => { + return new Promise((resolve) => { if (this.ngbModalRef == null) { this.ngbModalRef = this.quizExerciseModalRef(component, quizExercise); } @@ -33,7 +33,7 @@ export class QuizExercisePopupService { this.ngbModalRef = null; } }, - (reason) => { + () => { this.router.navigate([{ outlets: { popup: null } }], { replaceUrl: true, queryParamsHandling: 'merge' }); this.ngbModalRef = null; }, diff --git a/src/main/webapp/app/exercises/quiz/manage/quiz-exercise.service.ts b/src/main/webapp/app/exercises/quiz/manage/quiz-exercise.service.ts index 16cc722da7ca..41cb316f2869 100644 --- a/src/main/webapp/app/exercises/quiz/manage/quiz-exercise.service.ts +++ b/src/main/webapp/app/exercises/quiz/manage/quiz-exercise.service.ts @@ -4,7 +4,7 @@ import { Observable } from 'rxjs/Observable'; import { map } from 'rxjs/operators'; import { SERVER_API_URL } from 'app/app.constants'; -import { QuizExercise } from '../../../entities/quiz/quiz-exercise.model'; +import { QuizExercise } from 'app/entities/quiz/quiz-exercise.model'; import { createRequestOption } from 'app/shared/util/request-util'; import { ExerciseService } from 'app/exercises/shared/exercise/exercise.service'; import { QuizQuestion } from 'app/entities/quiz/quiz-question.model'; @@ -88,7 +88,7 @@ export class QuizExerciseService { .pipe(map((res: EntityResponseType) => this.exerciseService.convertDateFromServer(res))); } - query(req?: any): Observable { + query(): Observable { return this.http .get(this.resourceUrl, { observe: 'response' }) .pipe(map((res: EntityArrayResponseType) => this.exerciseService.convertDateArrayFromServer(res))); diff --git a/src/main/webapp/app/exercises/quiz/manage/re-evaluate/quiz-re-evaluate-warning.component.ts b/src/main/webapp/app/exercises/quiz/manage/re-evaluate/quiz-re-evaluate-warning.component.ts index af01b71aa3e2..96bcb3738c02 100644 --- a/src/main/webapp/app/exercises/quiz/manage/re-evaluate/quiz-re-evaluate-warning.component.ts +++ b/src/main/webapp/app/exercises/quiz/manage/re-evaluate/quiz-re-evaluate-warning.component.ts @@ -43,7 +43,7 @@ export class QuizReEvaluateWarningComponent implements OnInit { this.isSaving = false; this.quizExerciseService.find(this.quizExercise.id).subscribe((res) => { this.backUpQuiz = res.body!; - this.loadQuizSuccess(this.quizExercise); + this.loadQuizSuccess(); }); } @@ -66,10 +66,8 @@ export class QuizReEvaluateWarningComponent implements OnInit { * 3. check for each question-element if: * - it is set invalid * - the correctness was changed - * - * @param quiz {quizExercise} the reference Quiz from Server */ - loadQuizSuccess(quiz: QuizExercise): void { + loadQuizSuccess(): void { // question deleted? this.questionDeleted = this.backUpQuiz.quizQuestions.length !== this.quizExercise.quizQuestions.length; @@ -250,7 +248,7 @@ export class QuizReEvaluateWarningComponent implements OnInit { this.busy = true; this.quizReEvaluateService.update(this.quizExercise).subscribe( - (res) => { + () => { this.busy = false; this.successful = true; }, diff --git a/src/main/webapp/app/exercises/quiz/manage/statistics/quiz-point-statistic/quiz-point-statistic.component.ts b/src/main/webapp/app/exercises/quiz/manage/statistics/quiz-point-statistic/quiz-point-statistic.component.ts index 91aa1358ffd7..aa7698029a01 100644 --- a/src/main/webapp/app/exercises/quiz/manage/statistics/quiz-point-statistic/quiz-point-statistic.component.ts +++ b/src/main/webapp/app/exercises/quiz/manage/statistics/quiz-point-statistic/quiz-point-statistic.component.ts @@ -84,7 +84,7 @@ export class QuizPointStatisticComponent implements OnInit, OnDestroy, DataSetPr this.loadQuizSuccess(quiz); } }, - (error) => {}, + () => {}, ); } diff --git a/src/main/webapp/app/exercises/quiz/participate/quiz-participation.component.ts b/src/main/webapp/app/exercises/quiz/participate/quiz-participation.component.ts index e06de92a6b3c..4ca6e2829335 100644 --- a/src/main/webapp/app/exercises/quiz/participate/quiz-participation.component.ts +++ b/src/main/webapp/app/exercises/quiz/participate/quiz-participation.component.ts @@ -350,7 +350,7 @@ export class QuizParticipationComponent implements OnInit, OnDestroy { this.applyQuizFull(payload); } }, - (error) => {}, + () => {}, ); } } From 200c456ef0242f80d95463733bace71e090f1366 Mon Sep 17 00:00:00 2001 From: Tobias Priesching Date: Sun, 19 Apr 2020 23:20:08 +0200 Subject: [PATCH 045/152] fix ts-lint errors in metrics-modal.component.spec.ts, course.service.spec.ts, file-upload-exercise.service.spec.ts, file-upload-submission.service.spec.ts, modeling-exercise.service.spec.ts, modeling-submission.service.spec.ts, participation.service.spec.ts, programming-exercise.service.spec.ts, programming-submission.service.spec.ts, quiz-exercise.service.spec.ts, quiz-submission.service.spec.ts, text-exercise.service.spec.ts, text-submission.service.spec.ts, admin.spec.ts, user-management.spec.ts, assessment-layout.component.spec.ts, code-editor-ace.spec.ts, code-editor-actions.spec.ts, code-editor-build-output.spec.ts --- .../metrics/metrics-modal.component.spec.ts | 3 +-- .../entities/course/course.service.spec.ts | 25 +++++++++++++------ .../file-upload-exercise.service.spec.ts | 2 +- .../file-upload-submission.service.spec.ts | 2 +- .../modeling-exercise.service.spec.ts | 2 +- .../modeling-submission.service.spec.ts | 2 +- .../participation.service.spec.ts | 2 +- .../programming-exercise.service.spec.ts | 2 +- .../programming-submission.service.spec.ts | 2 +- .../text-exercise.service.spec.ts | 2 +- .../text-submission.service.spec.ts | 2 +- .../spec/component/admin/admin.spec.ts | 2 -- .../component/admin/user-management.spec.ts | 2 -- .../assessment-layout.component.spec.ts | 1 - 14 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/test/javascript/spec/app/admin/metrics/metrics-modal.component.spec.ts b/src/test/javascript/spec/app/admin/metrics/metrics-modal.component.spec.ts index 9495c6ad7444..24d8faf5c7ec 100644 --- a/src/test/javascript/spec/app/admin/metrics/metrics-modal.component.spec.ts +++ b/src/test/javascript/spec/app/admin/metrics/metrics-modal.component.spec.ts @@ -8,7 +8,6 @@ describe('Component Tests', () => { describe('JhiMetricsMonitoringModalComponent', () => { let comp: JhiMetricsMonitoringModalComponent; let fixture: ComponentFixture; - let service: JhiMetricsService; beforeEach(async(() => { TestBed.configureTestingModule({ @@ -22,7 +21,7 @@ describe('Component Tests', () => { beforeEach(() => { fixture = TestBed.createComponent(JhiMetricsMonitoringModalComponent); comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(JhiMetricsService); + fixture.debugElement.injector.get(JhiMetricsService); }); describe('ngOnInit', () => { diff --git a/src/test/javascript/spec/app/entities/course/course.service.spec.ts b/src/test/javascript/spec/app/entities/course/course.service.spec.ts index a69afafe2191..21e9991c282f 100644 --- a/src/test/javascript/spec/app/entities/course/course.service.spec.ts +++ b/src/test/javascript/spec/app/entities/course/course.service.spec.ts @@ -4,26 +4,35 @@ import { HttpClientTestingModule, HttpTestingController } from '@angular/common/ import { map, take } from 'rxjs/operators'; import * as moment from 'moment'; import { DATE_TIME_FORMAT } from 'app/shared/constants/input.constants'; -import { CourseService } from 'app/course/manage/course.service'; -import { Course, ICourse } from 'app/shared/model/course.model'; +import { CourseManagementService } from 'app/course/manage/course-management.service'; +import { Course } from 'app/entities/course.model'; describe('Service Tests', () => { describe('Course Service', () => { let injector: TestBed; - let service: CourseService; + let service: CourseManagementService; let httpMock: HttpTestingController; - let elemDefault: ICourse; + let elemDefault: Course; let currentDate: moment.Moment; beforeEach(() => { TestBed.configureTestingModule({ imports: [HttpClientTestingModule], }); injector = getTestBed(); - service = injector.get(CourseService); + service = injector.get(CourseManagementService); httpMock = injector.get(HttpTestingController); currentDate = moment(); - elemDefault = new Course(0, 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', currentDate, currentDate, false); + elemDefault = new Course(); + elemDefault.id = 0; + elemDefault.title = 'AAAAAAA'; + elemDefault.description = 'AAAAAAA'; + elemDefault.shortName = 'AAAAAAA'; + elemDefault.title = 'AAAAAAA'; + elemDefault.startDate = currentDate; + elemDefault.endDate = currentDate; + elemDefault.complaintsEnabled = false; + elemDefault.studentQuestionsEnabled = false; }); describe('Service methods', async () => { @@ -61,7 +70,7 @@ describe('Service Tests', () => { returnedFromService, ); service - .create(new Course(null)) + .create(new Course()) .pipe(take(1)) .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); const req = httpMock.expectOne({ method: 'POST' }); @@ -130,7 +139,7 @@ describe('Service Tests', () => { }); it('should delete a Course', async () => { - const rxPromise = service.delete(123).subscribe((resp) => expect(resp.ok)); + service.delete(123).subscribe((resp) => expect(resp.ok)); const req = httpMock.expectOne({ method: 'DELETE' }); req.flush({ status: 200 }); diff --git a/src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise.service.spec.ts b/src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise.service.spec.ts index 7c7d8ed2ed8f..58006ee21221 100644 --- a/src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise.service.spec.ts +++ b/src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise.service.spec.ts @@ -88,7 +88,7 @@ describe('Service Tests', () => { }); it('should delete a FileUploadExercise', async () => { - const rxPromise = service.delete(123).subscribe((resp) => expect(resp.ok)); + service.delete(123).subscribe((resp) => expect(resp.ok)); const req = httpMock.expectOne({ method: 'DELETE' }); req.flush({ status: 200 }); diff --git a/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission.service.spec.ts b/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission.service.spec.ts index 48ab8418bdcd..bcf1a51b8bba 100644 --- a/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission.service.spec.ts +++ b/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission.service.spec.ts @@ -88,7 +88,7 @@ describe('Service Tests', () => { }); it('should delete a FileUploadSubmission', async () => { - const rxPromise = service.delete(123).subscribe((resp) => expect(resp.ok)); + service.delete(123).subscribe((resp) => expect(resp.ok)); const req = httpMock.expectOne({ method: 'DELETE' }); req.flush({ status: 200 }); diff --git a/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise.service.spec.ts b/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise.service.spec.ts index d749f9d379aa..8ebafad0f4fa 100644 --- a/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise.service.spec.ts +++ b/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise.service.spec.ts @@ -92,7 +92,7 @@ describe('Service Tests', () => { }); it('should delete a ModelingExercise', async () => { - const rxPromise = service.delete(123).subscribe((resp) => expect(resp.ok)); + service.delete(123).subscribe((resp) => expect(resp.ok)); const req = httpMock.expectOne({ method: 'DELETE' }); req.flush({ status: 200 }); diff --git a/src/test/javascript/spec/app/entities/modeling-submission/modeling-submission.service.spec.ts b/src/test/javascript/spec/app/entities/modeling-submission/modeling-submission.service.spec.ts index b58981c1552e..c967eb7aa896 100644 --- a/src/test/javascript/spec/app/entities/modeling-submission/modeling-submission.service.spec.ts +++ b/src/test/javascript/spec/app/entities/modeling-submission/modeling-submission.service.spec.ts @@ -90,7 +90,7 @@ describe('Service Tests', () => { }); it('should delete a ModelingSubmission', async () => { - const rxPromise = service.delete(123).subscribe((resp) => expect(resp.ok)); + service.delete(123).subscribe((resp) => expect(resp.ok)); const req = httpMock.expectOne({ method: 'DELETE' }); req.flush({ status: 200 }); diff --git a/src/test/javascript/spec/app/entities/participation/participation.service.spec.ts b/src/test/javascript/spec/app/entities/participation/participation.service.spec.ts index 11dd3a5d4cc6..a70f1cae6370 100644 --- a/src/test/javascript/spec/app/entities/participation/participation.service.spec.ts +++ b/src/test/javascript/spec/app/entities/participation/participation.service.spec.ts @@ -121,7 +121,7 @@ describe('Service Tests', () => { }); it('should delete a Participation', async () => { - const rxPromise = service.delete(123).subscribe((resp) => expect(resp.ok)); + service.delete(123).subscribe((resp) => expect(resp.ok)); const req = httpMock.expectOne({ method: 'DELETE' }); req.flush({ status: 200 }); diff --git a/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.service.spec.ts b/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.service.spec.ts index 6d2f86852dda..d13741c342c0 100644 --- a/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.service.spec.ts +++ b/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.service.spec.ts @@ -96,7 +96,7 @@ describe('Service Tests', () => { }); it('should delete a ProgrammingExercise', async () => { - const rxPromise = service.delete(123).subscribe((resp) => expect(resp.ok)); + service.delete(123).subscribe((resp) => expect(resp.ok)); const req = httpMock.expectOne({ method: 'DELETE' }); req.flush({ status: 200 }); diff --git a/src/test/javascript/spec/app/entities/programming-submission/programming-submission.service.spec.ts b/src/test/javascript/spec/app/entities/programming-submission/programming-submission.service.spec.ts index b4227c3c5b9c..04acf7e9cb23 100644 --- a/src/test/javascript/spec/app/entities/programming-submission/programming-submission.service.spec.ts +++ b/src/test/javascript/spec/app/entities/programming-submission/programming-submission.service.spec.ts @@ -88,7 +88,7 @@ describe('Service Tests', () => { }); it('should delete a ProgrammingSubmission', async () => { - const rxPromise = service.delete(123).subscribe((resp) => expect(resp.ok)); + service.delete(123).subscribe((resp) => expect(resp.ok)); const req = httpMock.expectOne({ method: 'DELETE' }); req.flush({ status: 200 }); diff --git a/src/test/javascript/spec/app/entities/text-exercise/text-exercise.service.spec.ts b/src/test/javascript/spec/app/entities/text-exercise/text-exercise.service.spec.ts index 8a9fc32dc765..1af9307ccc69 100644 --- a/src/test/javascript/spec/app/entities/text-exercise/text-exercise.service.spec.ts +++ b/src/test/javascript/spec/app/entities/text-exercise/text-exercise.service.spec.ts @@ -88,7 +88,7 @@ describe('Service Tests', () => { }); it('should delete a TextExercise', async () => { - const rxPromise = service.delete(123).subscribe((resp) => expect(resp.ok)); + service.delete(123).subscribe((resp) => expect(resp.ok)); const req = httpMock.expectOne({ method: 'DELETE' }); req.flush({ status: 200 }); diff --git a/src/test/javascript/spec/app/entities/text-submission/text-submission.service.spec.ts b/src/test/javascript/spec/app/entities/text-submission/text-submission.service.spec.ts index eeee8fcf355d..47de959d7081 100644 --- a/src/test/javascript/spec/app/entities/text-submission/text-submission.service.spec.ts +++ b/src/test/javascript/spec/app/entities/text-submission/text-submission.service.spec.ts @@ -88,7 +88,7 @@ describe('Service Tests', () => { }); it('should delete a TextSubmission', async () => { - const rxPromise = service.delete(123).subscribe((resp) => expect(resp.ok)); + service.delete(123).subscribe((resp) => expect(resp.ok)); const req = httpMock.expectOne({ method: 'DELETE' }); req.flush({ status: 200 }); diff --git a/src/test/javascript/spec/component/admin/admin.spec.ts b/src/test/javascript/spec/component/admin/admin.spec.ts index 07669ec72663..5e6053fbc9dc 100644 --- a/src/test/javascript/spec/component/admin/admin.spec.ts +++ b/src/test/javascript/spec/component/admin/admin.spec.ts @@ -14,7 +14,6 @@ const expect = chai.expect; describe('AdminModule', () => { let comp: AuditsComponent; let fixture: ComponentFixture; - let debugElement: DebugElement; beforeEach(async () => { return TestBed.configureTestingModule({ @@ -24,7 +23,6 @@ describe('AdminModule', () => { .then(() => { fixture = TestBed.createComponent(AuditsComponent); comp = fixture.componentInstance; - debugElement = fixture.debugElement; }); }); diff --git a/src/test/javascript/spec/component/admin/user-management.spec.ts b/src/test/javascript/spec/component/admin/user-management.spec.ts index 5d5c0e596534..45eaffee7ff0 100644 --- a/src/test/javascript/spec/component/admin/user-management.spec.ts +++ b/src/test/javascript/spec/component/admin/user-management.spec.ts @@ -18,7 +18,6 @@ const expect = chai.expect; describe('UserManagementComponent', () => { let comp: UserManagementComponent; let fixture: ComponentFixture; - let debugElement: DebugElement; beforeEach(async () => { return TestBed.configureTestingModule({ @@ -32,7 +31,6 @@ describe('UserManagementComponent', () => { .then(() => { fixture = TestBed.createComponent(UserManagementComponent); comp = fixture.componentInstance; - debugElement = fixture.debugElement; }); }); diff --git a/src/test/javascript/spec/component/assessment-shared/assessment-layout.component.spec.ts b/src/test/javascript/spec/component/assessment-shared/assessment-layout.component.spec.ts index dd6fba64619e..8d6f60b381ec 100644 --- a/src/test/javascript/spec/component/assessment-shared/assessment-layout.component.spec.ts +++ b/src/test/javascript/spec/component/assessment-shared/assessment-layout.component.spec.ts @@ -1,7 +1,6 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; import { TranslateModule } from '@ngx-translate/core'; -import { AlertService } from 'app/core/alert/alert.service'; import { ArtemisTestModule } from '../../test.module'; import { JhiLanguageHelper } from 'app/core/language/language.helper'; From 688bc1805a69eb68cf2c3ffb9a77887600bc38be Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Mon, 20 Apr 2020 01:04:07 +0200 Subject: [PATCH 046/152] Fix more code style issues --- .../drag-and-drop-question.component.ts | 5 +++-- .../tutor/tutor-exercise-dashboard.component.ts | 2 +- .../exercise-headers/difficulty-badge.component.ts | 2 +- .../header-exercise-page-with-details.component.ts | 2 +- .../manage/exercise-hint-update.component.ts | 2 +- .../manage/exercise-hint.component.ts | 2 +- .../exercise-hint/manage/exercise-hint.route.ts | 4 ++-- .../shared/exercise/exercise-popup.service.ts | 6 +++--- .../participation-submission-popup.service.ts | 6 +++--- .../app/exercises/shared/result/result.service.ts | 3 +-- .../grading-instructions-details.component.ts | 10 +++++----- .../team-exercise-search.component.ts | 2 +- .../team-owner-search.component.ts | 2 +- .../team-student-search.component.ts | 2 +- .../team-delete-button.component.ts | 1 + .../app/exercises/shared/team/team.component.html | 2 +- .../app/exercises/shared/team/team.component.ts | 4 +--- .../app/exercises/shared/team/teams.component.ts | 1 - .../text-assessment-area.component.ts | 2 +- .../assess-new/text-submission-assessment.route.ts | 8 +++----- .../textblock-feedback-editor.component.ts | 2 +- .../text/assess/text-assessment.component.ts | 2 +- .../example-text-submission.component.ts | 5 ++--- .../text-exercise-update.component.ts | 4 ++-- .../manage/text-exercise/text-exercise.route.ts | 5 ++--- .../text/participate/text-editor.component.ts | 2 +- .../app/guided-tour/guided-tour.component.ts | 4 ++-- .../webapp/app/guided-tour/guided-tour.service.ts | 2 +- .../app/guided-tour/tours/course-overview-tour.ts | 4 ++-- src/main/webapp/app/home/home.component.ts | 6 +++--- .../webapp/app/lecture/lecture-update.component.ts | 6 +++--- src/main/webapp/app/lecture/lecture.route.ts | 4 ++-- .../course-lecture-row.component.html | 2 +- .../course-lecture-row.component.ts | 2 +- .../course-lectures/course-lectures.component.ts | 6 +++--- .../course-statistics.component.ts | 6 +++--- .../student-question-row.component.ts | 14 +++++++------- .../category-selector.component.ts | 5 +++-- 38 files changed, 72 insertions(+), 77 deletions(-) diff --git a/src/main/webapp/app/exercises/quiz/shared/questions/drag-and-drop-question/drag-and-drop-question.component.ts b/src/main/webapp/app/exercises/quiz/shared/questions/drag-and-drop-question/drag-and-drop-question.component.ts index 6226ae3bac85..92ffd639be22 100644 --- a/src/main/webapp/app/exercises/quiz/shared/questions/drag-and-drop-question/drag-and-drop-question.component.ts +++ b/src/main/webapp/app/exercises/quiz/shared/questions/drag-and-drop-question/drag-and-drop-question.component.ts @@ -17,10 +17,11 @@ polyfill({ }); // Drag-enter listener for mobile devices -// tslint:disable-next-line +/* eslint-disable */ (event: any) => { event.preventDefault(); }; +/* eslint-enable */ window.addEventListener('touchmove', function () {}, { passive: false }); @@ -87,7 +88,7 @@ export class DragAndDropQuestionComponent implements OnChanges { resizeImage(); } - ngOnChanges(changes: SimpleChanges): void { + ngOnChanges(): void { this.countCorrectMappings(); } diff --git a/src/main/webapp/app/exercises/shared/dashboards/tutor/tutor-exercise-dashboard.component.ts b/src/main/webapp/app/exercises/shared/dashboards/tutor/tutor-exercise-dashboard.component.ts index 131d47c61952..7d7949bd272a 100644 --- a/src/main/webapp/app/exercises/shared/dashboards/tutor/tutor-exercise-dashboard.component.ts +++ b/src/main/webapp/app/exercises/shared/dashboards/tutor/tutor-exercise-dashboard.component.ts @@ -377,7 +377,7 @@ export class TutorExerciseDashboardComponent implements OnInit, AfterViewInit { modalRef.componentInstance.exercise = this.exercise; modalRef.componentInstance.onResultModified.subscribe(() => this.loadAll()); modalRef.result.then( - (_) => this.loadAll(), + () => this.loadAll(), () => {}, ); return; diff --git a/src/main/webapp/app/exercises/shared/exercise-headers/difficulty-badge.component.ts b/src/main/webapp/app/exercises/shared/exercise-headers/difficulty-badge.component.ts index 960c9ab671b7..77f0136e6f55 100644 --- a/src/main/webapp/app/exercises/shared/exercise-headers/difficulty-badge.component.ts +++ b/src/main/webapp/app/exercises/shared/exercise-headers/difficulty-badge.component.ts @@ -17,7 +17,7 @@ export class DifficultyBadgeComponent implements OnInit, OnDestroy { constructor(private translateService: TranslateService) {} ngOnInit(): void { - this.translateSubscription = this.translateService.onLangChange.subscribe((event: LangChangeEvent) => { + this.translateSubscription = this.translateService.onLangChange.subscribe(() => { this.setBadgeAttributes(); }); this.setBadgeAttributes(); diff --git a/src/main/webapp/app/exercises/shared/exercise-headers/header-exercise-page-with-details.component.ts b/src/main/webapp/app/exercises/shared/exercise-headers/header-exercise-page-with-details.component.ts index 80e99c09aaf8..24c6050df79d 100644 --- a/src/main/webapp/app/exercises/shared/exercise-headers/header-exercise-page-with-details.component.ts +++ b/src/main/webapp/app/exercises/shared/exercise-headers/header-exercise-page-with-details.component.ts @@ -24,7 +24,7 @@ export class HeaderExercisePageWithDetailsComponent implements OnInit, OnChanges this.exerciseCategories = this.exerciseService.convertExerciseCategoriesFromServer(this.exercise); } - ngOnChanges(changes: SimpleChanges): void { + ngOnChanges(): void { this.setExerciseStatusBadge(); this.exerciseCategories = this.exerciseService.convertExerciseCategoriesFromServer(this.exercise); } diff --git a/src/main/webapp/app/exercises/shared/exercise-hint/manage/exercise-hint-update.component.ts b/src/main/webapp/app/exercises/shared/exercise-hint/manage/exercise-hint-update.component.ts index 14ef8ef17842..c1e58cb75906 100644 --- a/src/main/webapp/app/exercises/shared/exercise-hint/manage/exercise-hint-update.component.ts +++ b/src/main/webapp/app/exercises/shared/exercise-hint/manage/exercise-hint-update.component.ts @@ -61,7 +61,7 @@ export class ExerciseHintUpdateComponent implements OnInit, OnDestroy { return of(null); }), ) - .subscribe((res: Exercise) => { + .subscribe(() => { this.isLoading = false; }); } else { diff --git a/src/main/webapp/app/exercises/shared/exercise-hint/manage/exercise-hint.component.ts b/src/main/webapp/app/exercises/shared/exercise-hint/manage/exercise-hint.component.ts index b37350a96a0e..307c05b2bcdd 100644 --- a/src/main/webapp/app/exercises/shared/exercise-hint/manage/exercise-hint.component.ts +++ b/src/main/webapp/app/exercises/shared/exercise-hint/manage/exercise-hint.component.ts @@ -76,7 +76,7 @@ export class ExerciseHintComponent implements OnInit, OnDestroy { if (this.eventSubscriber) { this.eventSubscriber.unsubscribe(); } - this.eventSubscriber = this.eventManager.subscribe('exerciseHintListModification', (response: any) => this.loadAllByExerciseId()); + this.eventSubscriber = this.eventManager.subscribe('exerciseHintListModification', () => this.loadAllByExerciseId()); } /** diff --git a/src/main/webapp/app/exercises/shared/exercise-hint/manage/exercise-hint.route.ts b/src/main/webapp/app/exercises/shared/exercise-hint/manage/exercise-hint.route.ts index 3f27c047f530..46cb87b77227 100644 --- a/src/main/webapp/app/exercises/shared/exercise-hint/manage/exercise-hint.route.ts +++ b/src/main/webapp/app/exercises/shared/exercise-hint/manage/exercise-hint.route.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; import { HttpResponse } from '@angular/common/http'; -import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot, Routes } from '@angular/router'; +import { ActivatedRouteSnapshot, Resolve, Routes } from '@angular/router'; import { UserRouteAccessService } from 'app/core/auth/user-route-access-service'; import { Observable, of } from 'rxjs'; import { filter, map } from 'rxjs/operators'; @@ -14,7 +14,7 @@ import { ExerciseHint } from 'app/entities/exercise-hint.model'; export class ExerciseHintResolve implements Resolve { constructor(private service: ExerciseHintService) {} - resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { + resolve(route: ActivatedRouteSnapshot): Observable { const id = route.params['hintId'] ? route.params['hintId'] : null; if (id) { return this.service.find(id).pipe( diff --git a/src/main/webapp/app/exercises/shared/exercise/exercise-popup.service.ts b/src/main/webapp/app/exercises/shared/exercise/exercise-popup.service.ts index 6244d5a413ab..72ab6475a197 100644 --- a/src/main/webapp/app/exercises/shared/exercise/exercise-popup.service.ts +++ b/src/main/webapp/app/exercises/shared/exercise/exercise-popup.service.ts @@ -20,7 +20,7 @@ export class ExercisePopupService { } open(component: Component, id?: number | any, lti?: boolean | any): Promise { - return new Promise((resolve, reject) => { + return new Promise((resolve) => { if (this.ngbModalRef != null) { resolve(this.ngbModalRef); } @@ -49,11 +49,11 @@ export class ExercisePopupService { modalRef.componentInstance.exercise = exercise; modalRef.componentInstance.ltiConfiguration = ltiConfiguration; modalRef.result.then( - (result) => { + () => { this.router.navigate([{ outlets: { popup: null } }], { replaceUrl: true, queryParamsHandling: 'merge' }); this.ngbModalRef = null; }, - (reason) => { + () => { this.router.navigate([{ outlets: { popup: null } }], { replaceUrl: true, queryParamsHandling: 'merge' }); this.ngbModalRef = null; }, diff --git a/src/main/webapp/app/exercises/shared/participation-submission/participation-submission-popup.service.ts b/src/main/webapp/app/exercises/shared/participation-submission/participation-submission-popup.service.ts index c3b3dcec1753..752d8419e990 100644 --- a/src/main/webapp/app/exercises/shared/participation-submission/participation-submission-popup.service.ts +++ b/src/main/webapp/app/exercises/shared/participation-submission/participation-submission-popup.service.ts @@ -11,7 +11,7 @@ export class ParticipationSubmissionPopupService { } open(component: Component, participationId?: number | any, submissionId?: number | any): Promise { - return new Promise((resolve, reject) => { + return new Promise((resolve) => { if (this.ngbModalRef != null) { resolve(this.ngbModalRef); } @@ -28,11 +28,11 @@ export class ParticipationSubmissionPopupService { modalRef.componentInstance.participationId = participationId; modalRef.componentInstance.submissionId = submissionId; modalRef.result.then( - (result) => { + () => { this.router.navigate([{ outlets: { popup: null } }], { replaceUrl: true, queryParamsHandling: 'merge' }); this.ngbModalRef = null; }, - (reason) => { + () => { this.router.navigate([{ outlets: { popup: null } }], { replaceUrl: true, queryParamsHandling: 'merge' }); this.ngbModalRef = null; }, diff --git a/src/main/webapp/app/exercises/shared/result/result.service.ts b/src/main/webapp/app/exercises/shared/result/result.service.ts index cfda02780697..9f5599eb27ce 100644 --- a/src/main/webapp/app/exercises/shared/result/result.service.ts +++ b/src/main/webapp/app/exercises/shared/result/result.service.ts @@ -69,10 +69,9 @@ export class ResultService implements IResultService { * Create a new example result for the provided submission ID. * * @param submissionId The ID of the example submission for which a result should get created - * @param isProgrammingExerciseWithFeedback defines if the programming exercise contains feedback * @return The newly created (and empty) example result */ - createNewExampleResult(submissionId: number, isProgrammingExerciseWithFeedback = false): Observable> { + createNewExampleResult(submissionId: number): Observable> { return this.http.post(`${this.submissionResourceUrl}/${submissionId}/example-result`, null, { observe: 'response' }); } diff --git a/src/main/webapp/app/exercises/shared/structured-grading-criterion/grading-instructions-details/grading-instructions-details.component.ts b/src/main/webapp/app/exercises/shared/structured-grading-criterion/grading-instructions-details/grading-instructions-details.component.ts index 4cd12184cf1b..2c2e8bec0e3c 100644 --- a/src/main/webapp/app/exercises/shared/structured-grading-criterion/grading-instructions-details/grading-instructions-details.component.ts +++ b/src/main/webapp/app/exercises/shared/structured-grading-criterion/grading-instructions-details/grading-instructions-details.component.ts @@ -149,7 +149,7 @@ export class GradingInstructionsDetailsComponent implements OnInit { } hasCriterionCommand(domainCommands: [string, DomainCommand][]): boolean { - return domainCommands.some(([text, command]) => command instanceof GradingCriterionCommand); + return domainCommands.some(([, command]) => command instanceof GradingCriterionCommand); } /** @@ -167,7 +167,7 @@ export class GradingInstructionsDetailsComponent implements OnInit { if (this.hasCriterionCommand(domainCommands) === false) { this.setParentForInstructionsWithNoCriterion(domainCommands); } else { - for (const [text, command] of domainCommands) { + for (const [, command] of domainCommands) { endOfInstructionsCommand++; if (command instanceof GradingCriterionCommand) { instructionCommands = domainCommands.slice(0, endOfInstructionsCommand - 1); @@ -191,7 +191,7 @@ export class GradingInstructionsDetailsComponent implements OnInit { * @param domainCommands containing tuples of [text, domainCommandIdentifiers] */ setParentForInstructionsWithNoCriterion(domainCommands: [string, DomainCommand][]): void { - for (const [text, command] of domainCommands) { + for (const [, command] of domainCommands) { if (command instanceof GradingInstructionCommand) { const dummyCriterion = new GradingCriterion(); const newInstruction = new GradingInstruction(); @@ -222,7 +222,7 @@ export class GradingInstructionsDetailsComponent implements OnInit { this.exercise.gradingCriteria.push(newCriterion); newCriterion.structuredGradingInstructions = []; const modifiedArray = domainCommands.slice(1); // remove GradingCriterionCommandIdentifier after creating its criterion object - for (const [instrText, instrCommand] of modifiedArray) { + for (const [, instrCommand] of modifiedArray) { if (instrCommand instanceof GradingInstructionCommand) { const newInstruction = new GradingInstruction(); // create instruction objects that belong to the above created criterion newCriterion.structuredGradingInstructions.push(newInstruction); @@ -234,7 +234,7 @@ export class GradingInstructionsDetailsComponent implements OnInit { } } } - this.setInstructionParameters(domainCommands.filter(([text, command]) => command instanceof GradingCriterionCommand === false)); + this.setInstructionParameters(domainCommands.filter(([, command]) => command instanceof GradingCriterionCommand === false)); } /** diff --git a/src/main/webapp/app/exercises/shared/team/team-exercise-search/team-exercise-search.component.ts b/src/main/webapp/app/exercises/shared/team/team-exercise-search/team-exercise-search.component.ts index 20916a5a6b34..be376fa5270b 100644 --- a/src/main/webapp/app/exercises/shared/team/team-exercise-search/team-exercise-search.component.ts +++ b/src/main/webapp/app/exercises/shared/team/team-exercise-search/team-exercise-search.component.ts @@ -79,7 +79,7 @@ export class TeamExerciseSearchComponent implements OnInit { this.searchNoResults.emit(searchTerm); } }), - map(([_, exerciseOptions]) => exerciseOptions || []), + map(([, exerciseOptions]) => exerciseOptions || []), map((exerciseOptions) => orderBy(exerciseOptions, ['releaseDate', 'id'])), ); }; diff --git a/src/main/webapp/app/exercises/shared/team/team-owner-search/team-owner-search.component.ts b/src/main/webapp/app/exercises/shared/team/team-owner-search/team-owner-search.component.ts index 0322febf9019..3fc6c568ea1f 100644 --- a/src/main/webapp/app/exercises/shared/team/team-owner-search/team-owner-search.component.ts +++ b/src/main/webapp/app/exercises/shared/team/team-owner-search/team-owner-search.component.ts @@ -91,7 +91,7 @@ export class TeamOwnerSearchComponent implements OnInit { this.searchNoResults.emit(loginOrName); } }), - map(([_, ownerOptions]) => ownerOptions || []), + map(([, ownerOptions]) => ownerOptions || []), ); }; diff --git a/src/main/webapp/app/exercises/shared/team/team-student-search/team-student-search.component.ts b/src/main/webapp/app/exercises/shared/team/team-student-search/team-student-search.component.ts index 7099ada8743e..50c2cdbe7d02 100644 --- a/src/main/webapp/app/exercises/shared/team/team-student-search/team-student-search.component.ts +++ b/src/main/webapp/app/exercises/shared/team/team-student-search/team-student-search.component.ts @@ -82,7 +82,7 @@ export class TeamStudentSearchComponent { this.searchNoResults.emit(loginOrName); } }), - map(([_, users]) => users || []), + map(([, users]) => users || []), tap((users) => { setTimeout(() => { for (let i = 0; i < this.typeaheadButtons.length; i++) { diff --git a/src/main/webapp/app/exercises/shared/team/team-update-dialog/team-delete-button.component.ts b/src/main/webapp/app/exercises/shared/team/team-update-dialog/team-delete-button.component.ts index ebe7359530e1..fbc4e4e619ff 100644 --- a/src/main/webapp/app/exercises/shared/team/team-update-dialog/team-delete-button.component.ts +++ b/src/main/webapp/app/exercises/shared/team/team-update-dialog/team-delete-button.component.ts @@ -47,6 +47,7 @@ export class TeamDeleteButtonComponent implements OnDestroy { * * @param additionalChecksValues Not used here */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars removeTeam = (additionalChecksValues: { [key: string]: boolean }) => { this.teamService.delete(this.exercise, this.team.id).subscribe( () => { diff --git a/src/main/webapp/app/exercises/shared/team/team.component.html b/src/main/webapp/app/exercises/shared/team/team.component.html index 0e3cb34840f1..32ada42dd66f 100644 --- a/src/main/webapp/app/exercises/shared/team/team.component.html +++ b/src/main/webapp/app/exercises/shared/team/team.component.html @@ -42,7 +42,7 @@

[exercise]="exercise" [team]="team" [buttonSize]="ButtonSize.MEDIUM" - (delete)="onTeamDelete($event)" + (delete)="onTeamDelete()" > diff --git a/src/main/webapp/app/exercises/shared/team/team.component.ts b/src/main/webapp/app/exercises/shared/team/team.component.ts index 54d9a6591c48..4e690899f865 100644 --- a/src/main/webapp/app/exercises/shared/team/team.component.ts +++ b/src/main/webapp/app/exercises/shared/team/team.component.ts @@ -78,10 +78,8 @@ export class TeamComponent implements OnInit { * Called when the team was deleted by TeamDeleteButtonComponent * * Navigates back to the overviews of teams for the exercise. - * - * @param team Deleted team */ - onTeamDelete(team: Team) { + onTeamDelete() { this.router.navigate(['/course-management', this.exercise.course?.id, 'exercises', this.exercise.id, 'teams']); } diff --git a/src/main/webapp/app/exercises/shared/team/teams.component.ts b/src/main/webapp/app/exercises/shared/team/teams.component.ts index 9d0f90d93afb..1fe1a92031a0 100644 --- a/src/main/webapp/app/exercises/shared/team/teams.component.ts +++ b/src/main/webapp/app/exercises/shared/team/teams.component.ts @@ -1,5 +1,4 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; -import { Subscription } from 'rxjs/Subscription'; import { ParticipationService } from 'app/exercises/shared/participation/participation.service'; import { JhiAlertService, JhiEventManager } from 'ng-jhipster'; import { ActivatedRoute } from '@angular/router'; diff --git a/src/main/webapp/app/exercises/text/assess-new/text-assessment-area/text-assessment-area.component.ts b/src/main/webapp/app/exercises/text/assess-new/text-assessment-area/text-assessment-area.component.ts index 9b424368afec..d37fd1387443 100644 --- a/src/main/webapp/app/exercises/text/assess-new/text-assessment-area/text-assessment-area.component.ts +++ b/src/main/webapp/app/exercises/text/assess-new/text-assessment-area/text-assessment-area.component.ts @@ -28,7 +28,7 @@ export class TextAssessmentAreaComponent implements OnChanges { @Output() textBlockRefsChange = new EventEmitter(); selectedRef: TextBlockRef | null = null; - ngOnChanges(changes: SimpleChanges): void { + ngOnChanges(): void { this.textBlockRefs.sort((a, b) => a.block.startIndex - b.block.startIndex); } diff --git a/src/main/webapp/app/exercises/text/assess-new/text-submission-assessment.route.ts b/src/main/webapp/app/exercises/text/assess-new/text-submission-assessment.route.ts index 43a52c624769..42ee44902457 100644 --- a/src/main/webapp/app/exercises/text/assess-new/text-submission-assessment.route.ts +++ b/src/main/webapp/app/exercises/text/assess-new/text-submission-assessment.route.ts @@ -1,5 +1,5 @@ import { Injectable } from '@angular/core'; -import { Routes, Resolve, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; +import { Routes, Resolve, ActivatedRouteSnapshot } from '@angular/router'; import { Location } from '@angular/common'; import { Observable } from 'rxjs'; @@ -16,9 +16,8 @@ export class StudentParticipationResolver implements Resolve { + () => { this.jhiAlertService.clear(); this.jhiAlertService.error('artemisApp.textAssessment.updateAfterComplaintFailed'); }, diff --git a/src/main/webapp/app/exercises/text/manage/example-text-submission/example-text-submission.component.ts b/src/main/webapp/app/exercises/text/manage/example-text-submission/example-text-submission.component.ts index 9a407e91505b..ad1724957b86 100644 --- a/src/main/webapp/app/exercises/text/manage/example-text-submission/example-text-submission.component.ts +++ b/src/main/webapp/app/exercises/text/manage/example-text-submission/example-text-submission.component.ts @@ -21,7 +21,6 @@ import { Feedback } from 'app/entities/feedback.model'; import { ExerciseService } from 'app/exercises/shared/exercise/exercise.service'; import { ResultService } from 'app/exercises/shared/result/result.service'; import { TextExercise } from 'app/entities/text-exercise.model'; -import { TutorParticipation } from 'app/entities/participation/tutor-participation.model'; import { TextSubmission } from 'app/entities/text-submission.model'; import { Result } from 'app/entities/result.model'; @@ -355,7 +354,7 @@ export class ExampleTextSubmissionComponent implements OnInit, AfterViewInit { exampleSubmission.submission.result.feedbacks = this.assessments; this.tutorParticipationService.assessExampleSubmission(exampleSubmission, this.exerciseId).subscribe( - (res: HttpResponse) => { + () => { this.jhiAlertService.success('artemisApp.exampleSubmission.assessScore.success'); }, (error: HttpErrorResponse) => { @@ -373,7 +372,7 @@ export class ExampleTextSubmissionComponent implements OnInit, AfterViewInit { } readAndUnderstood() { - this.tutorParticipationService.assessExampleSubmission(this.exampleSubmission, this.exerciseId).subscribe((res: HttpResponse) => { + this.tutorParticipationService.assessExampleSubmission(this.exampleSubmission, this.exerciseId).subscribe(() => { this.jhiAlertService.success('artemisApp.exampleSubmission.readSuccessfully'); this.back(); }); diff --git a/src/main/webapp/app/exercises/text/manage/text-exercise/text-exercise-update.component.ts b/src/main/webapp/app/exercises/text/manage/text-exercise/text-exercise-update.component.ts index 10a17576f215..12792e8c58ca 100644 --- a/src/main/webapp/app/exercises/text/manage/text-exercise/text-exercise-update.component.ts +++ b/src/main/webapp/app/exercises/text/manage/text-exercise/text-exercise-update.component.ts @@ -128,12 +128,12 @@ export class TextExerciseUpdateComponent implements OnInit { private subscribeToSaveResponse(result: Observable>) { result.subscribe( - (res: HttpResponse) => this.onSaveSuccess(res.body!), + () => this.onSaveSuccess(), (res: HttpErrorResponse) => this.onSaveError(res), ); } - private onSaveSuccess(result: TextExercise) { + private onSaveSuccess() { this.eventManager.broadcast({ name: 'textExerciseListModification', content: 'OK' }); this.isSaving = false; this.previousState(); diff --git a/src/main/webapp/app/exercises/text/manage/text-exercise/text-exercise.route.ts b/src/main/webapp/app/exercises/text/manage/text-exercise/text-exercise.route.ts index 489da246521b..1e61012ec190 100644 --- a/src/main/webapp/app/exercises/text/manage/text-exercise/text-exercise.route.ts +++ b/src/main/webapp/app/exercises/text/manage/text-exercise/text-exercise.route.ts @@ -1,4 +1,4 @@ -import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot, Routes } from '@angular/router'; +import { ActivatedRouteSnapshot, Resolve, Routes } from '@angular/router'; import { UserRouteAccessService } from 'app/core/auth/user-route-access-service'; import { TextExerciseComponent } from './text-exercise.component'; @@ -20,9 +20,8 @@ export class TextExerciseResolver implements Resolve { /** * Resolves the route and initializes text exercise * @param route - * @param state */ - resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { + resolve(route: ActivatedRouteSnapshot) { if (route.params['exerciseId']) { return this.textExerciseService.find(route.params['exerciseId']).pipe( filter((res) => !!res.body), diff --git a/src/main/webapp/app/exercises/text/participate/text-editor.component.ts b/src/main/webapp/app/exercises/text/participate/text-editor.component.ts index 5f4634f703dd..ebe783866809 100644 --- a/src/main/webapp/app/exercises/text/participate/text-editor.component.ts +++ b/src/main/webapp/app/exercises/text/participate/text-editor.component.ts @@ -192,7 +192,7 @@ export class TextEditorComponent implements OnInit, OnDestroy, ComponentCanDeact this.jhiAlertService.warning('entity.action.submitDeadlineMissedAlert'); } }, - (err) => { + () => { this.jhiAlertService.error('artemisApp.modelingEditor.error'); this.submission.submitted = false; this.isSaving = false; diff --git a/src/main/webapp/app/guided-tour/guided-tour.component.ts b/src/main/webapp/app/guided-tour/guided-tour.component.ts index ef2f75ca9f74..f50ede6057c7 100644 --- a/src/main/webapp/app/guided-tour/guided-tour.component.ts +++ b/src/main/webapp/app/guided-tour/guided-tour.component.ts @@ -4,7 +4,7 @@ import { take, tap } from 'rxjs/internal/operators'; import { Direction, Orientation, OverlayPosition, UserInteractionEvent } from './guided-tour.constants'; import { GuidedTourService } from './guided-tour.service'; import { AccountService } from 'app/core/auth/account.service'; -import { ImageTourStep, TextTourStep, TourStep, VideoTourStep } from 'app/guided-tour/guided-tour-step.model'; +import { ImageTourStep, TextTourStep, VideoTourStep } from 'app/guided-tour/guided-tour-step.model'; import { cancelTour, completedTour } from 'app/guided-tour/tours/general-tour'; import { calculateLeftOffset, calculateTopOffset, isElementInViewPortHorizontally } from 'app/guided-tour/guided-tour.utils'; @@ -682,7 +682,7 @@ export class GuidedTourComponent implements AfterViewInit, OnDestroy { this.guidedTourService .observeMutations(alertElement, { childList: true }) .pipe(take(1)) - .subscribe((mutation) => { + .subscribe(() => { if (this.getSelectedElement()) { this.scrollToAndSetElement(); } diff --git a/src/main/webapp/app/guided-tour/guided-tour.service.ts b/src/main/webapp/app/guided-tour/guided-tour.service.ts index bca5d470f36e..3c47049ec4f2 100644 --- a/src/main/webapp/app/guided-tour/guided-tour.service.ts +++ b/src/main/webapp/app/guided-tour/guided-tour.service.ts @@ -649,7 +649,7 @@ export class GuidedTourService { mutation.addedNodes.length !== mutation.removedNodes.length && (mutation.addedNodes.length >= 1 || mutation.removedNodes.length >= 1), ), ) - .subscribe((mutation: MutationRecord) => { + .subscribe(() => { this.enableNextStepClick(); }); } else if (userInteraction === UserInteractionEvent.MODELING) { diff --git a/src/main/webapp/app/guided-tour/tours/course-overview-tour.ts b/src/main/webapp/app/guided-tour/tours/course-overview-tour.ts index 0a2013c04194..f75395c07a04 100644 --- a/src/main/webapp/app/guided-tour/tours/course-overview-tour.ts +++ b/src/main/webapp/app/guided-tour/tours/course-overview-tour.ts @@ -1,6 +1,6 @@ -import { Orientation, ResetParticipation, UserInteractionEvent } from 'app/guided-tour/guided-tour.constants'; +import { Orientation, ResetParticipation } from 'app/guided-tour/guided-tour.constants'; import { GuidedTour } from 'app/guided-tour/guided-tour.model'; -import { ImageTourStep, TextTourStep, UserInterActionTourStep } from 'app/guided-tour/guided-tour-step.model'; +import { ImageTourStep, TextTourStep } from 'app/guided-tour/guided-tour-step.model'; /** * This constant contains the guided tour configuration and steps for the course overview page diff --git a/src/main/webapp/app/home/home.component.ts b/src/main/webapp/app/home/home.component.ts index f4ebc053e31c..041ab1fe797f 100644 --- a/src/main/webapp/app/home/home.component.ts +++ b/src/main/webapp/app/home/home.component.ts @@ -84,7 +84,7 @@ export class HomeComponent implements OnInit, AfterViewInit { } registerAuthenticationSuccess() { - this.eventManager.subscribe('authenticationSuccess', (message: string) => { + this.eventManager.subscribe('authenticationSuccess', () => { this.accountService.identity().then((user) => { this.currentUserCallback(user!); }); @@ -131,10 +131,10 @@ export class HomeComponent implements OnInit, AfterViewInit { modalRef.componentInstance.text = 'login.ide.confirmation'; modalRef.componentInstance.title = 'login.ide.title'; modalRef.result.then( - (result) => { + () => { this.javaBridge.login(this.username, this.password); }, - (reason) => {}, + () => {}, ); } }) diff --git a/src/main/webapp/app/lecture/lecture-update.component.ts b/src/main/webapp/app/lecture/lecture-update.component.ts index 400002bf5a82..31a7f2dbf024 100644 --- a/src/main/webapp/app/lecture/lecture-update.component.ts +++ b/src/main/webapp/app/lecture/lecture-update.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; -import { HttpErrorResponse, HttpResponse } from '@angular/common/http'; +import { HttpResponse } from '@angular/common/http'; import { Observable } from 'rxjs'; import { AlertService } from 'app/core/alert/alert.service'; import { LectureService } from './lecture.service'; @@ -58,8 +58,8 @@ export class LectureUpdateComponent implements OnInit { protected subscribeToSaveResponse(result: Observable>) { result.subscribe( - (res: HttpResponse) => this.onSaveSuccess(), - (res: HttpErrorResponse) => this.onSaveError(), + () => this.onSaveSuccess(), + () => this.onSaveError(), ); } diff --git a/src/main/webapp/app/lecture/lecture.route.ts b/src/main/webapp/app/lecture/lecture.route.ts index 6b2d0cf353e6..ac26c1ba596a 100644 --- a/src/main/webapp/app/lecture/lecture.route.ts +++ b/src/main/webapp/app/lecture/lecture.route.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; import { HttpResponse } from '@angular/common/http'; -import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot, Routes } from '@angular/router'; +import { ActivatedRouteSnapshot, Resolve, Routes } from '@angular/router'; import { UserRouteAccessService } from 'app/core/auth/user-route-access-service'; import { Observable, of } from 'rxjs'; import { filter, map } from 'rxjs/operators'; @@ -15,7 +15,7 @@ import { LectureAttachmentsComponent } from 'app/lecture/lecture-attachments.com export class LectureResolve implements Resolve { constructor(private service: LectureService) {} - resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable { + resolve(route: ActivatedRouteSnapshot): Observable { const id = route.params['id'] ? route.params['id'] : null; if (id) { return this.service.find(id).pipe( diff --git a/src/main/webapp/app/overview/course-lectures/course-lecture-row.component.html b/src/main/webapp/app/overview/course-lectures/course-lecture-row.component.html index 33b327015447..e31f0ac90513 100644 --- a/src/main/webapp/app/overview/course-lectures/course-lecture-row.component.html +++ b/src/main/webapp/app/overview/course-lectures/course-lecture-row.component.html @@ -1,4 +1,4 @@ -
+
{ + this.translateSubscription = this.translateService.onLangChange.subscribe(() => { this.groupLectures(this.DUE_DATE_DESC); }); diff --git a/src/main/webapp/app/overview/course-statistics/course-statistics.component.ts b/src/main/webapp/app/overview/course-statistics/course-statistics.component.ts index 2457fc76ee2f..96cc41894a8c 100644 --- a/src/main/webapp/app/overview/course-statistics/course-statistics.component.ts +++ b/src/main/webapp/app/overview/course-statistics/course-statistics.component.ts @@ -2,10 +2,10 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { Subscription } from 'rxjs/Subscription'; import { HttpResponse } from '@angular/common/http'; -import { LangChangeEvent, TranslateService } from '@ngx-translate/core'; +import { TranslateService } from '@ngx-translate/core'; import { sortBy } from 'lodash'; import { Course } from 'app/entities/course.model'; -import { CourseManagementService } from '../../course/manage/course-management.service'; +import { CourseManagementService } from 'app/course/manage/course-management.service'; import { Result } from 'app/entities/result.model'; import * as moment from 'moment'; import { Exercise, ExerciseType } from 'app/entities/exercise.model'; @@ -206,7 +206,7 @@ export class CourseStatisticsComponent implements OnInit, OnDestroy { this.groupExercisesByType(); } - this.translationSubscription = this.translateService.onLangChange.subscribe((event: LangChangeEvent) => { + this.translationSubscription = this.translateService.onLangChange.subscribe(() => { this.exerciseTitles = { quiz: { name: this.translateService.instant('artemisApp.course.quizExercises'), diff --git a/src/main/webapp/app/overview/student-questions/student-question-row.component.ts b/src/main/webapp/app/overview/student-questions/student-question-row.component.ts index be729eac24d0..031127a11559 100644 --- a/src/main/webapp/app/overview/student-questions/student-question-row.component.ts +++ b/src/main/webapp/app/overview/student-questions/student-question-row.component.ts @@ -118,7 +118,7 @@ export class StudentQuestionRowComponent implements OnInit, OnDestroy { */ saveQuestion(): void { this.studentQuestion.questionText = this.studentQuestionText; - this.studentQuestionService.update(this.studentQuestion).subscribe((studentQuestionResponse: HttpResponse) => { + this.studentQuestionService.update(this.studentQuestion).subscribe(() => { this.studentQuestionText = null; this.isEditMode = false; }); @@ -128,7 +128,7 @@ export class StudentQuestionRowComponent implements OnInit, OnDestroy { * deletes the studentQuestion */ deleteQuestion(): void { - this.studentQuestionService.delete(this.studentQuestion.id).subscribe((res: HttpResponse) => { + this.studentQuestionService.delete(this.studentQuestion.id).subscribe(() => { this.interactQuestion.emit({ name: QuestionActionName.DELETE, studentQuestion: this.studentQuestion, @@ -163,7 +163,7 @@ export class StudentQuestionRowComponent implements OnInit, OnDestroy { */ saveAnswer(): void { this.selectedQuestionAnswer!.answerText = this.questionAnswerText; - this.studentQuestionAnswerService.update(this.selectedQuestionAnswer!).subscribe((studentAnswerResponse: HttpResponse) => { + this.studentQuestionAnswerService.update(this.selectedQuestionAnswer!).subscribe(() => { this.questionAnswerText = null; this.selectedQuestionAnswer = null; this.isAnswerMode = false; @@ -172,10 +172,10 @@ export class StudentQuestionRowComponent implements OnInit, OnDestroy { /** * Takes a studentAnswer and deletes it - * @param {studentQuestionAnswer} studentAnswer + * @param {StudentQuestionAnswer} studentAnswer */ deleteAnswer(studentAnswer: StudentQuestionAnswer): void { - this.studentQuestionAnswerService.delete(studentAnswer.id).subscribe((res: HttpResponse) => { + this.studentQuestionAnswerService.delete(studentAnswer.id).subscribe(() => { this.studentQuestion.answers = this.studentQuestion.answers.filter((el) => el.id !== studentAnswer.id); this.sortQuestionAnswers(); }); @@ -183,11 +183,11 @@ export class StudentQuestionRowComponent implements OnInit, OnDestroy { /** * Takes a studentAnswer and toggles the tutorApproved field - * @param {studentQuestionAnswer} studentAnswer + * @param {StudentQuestionAnswer} studentAnswer */ toggleAnswerTutorApproved(studentAnswer: StudentQuestionAnswer): void { studentAnswer.tutorApproved = !studentAnswer.tutorApproved; - this.studentQuestionAnswerService.update(studentAnswer).subscribe((studentAnswerResponse: HttpResponse) => { + this.studentQuestionAnswerService.update(studentAnswer).subscribe(() => { this.sortQuestionAnswers(); }); } diff --git a/src/main/webapp/app/shared/category-selector/category-selector.component.ts b/src/main/webapp/app/shared/category-selector/category-selector.component.ts index 68f1ddca5315..ab8602c01126 100644 --- a/src/main/webapp/app/shared/category-selector/category-selector.component.ts +++ b/src/main/webapp/app/shared/category-selector/category-selector.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, Input, OnChanges, Output, SimpleChanges, ViewChild, ViewEncapsulation } from '@angular/core'; +import { Component, EventEmitter, Input, OnChanges, Output, ViewChild, ViewEncapsulation } from '@angular/core'; import { ExerciseCategory } from 'app/entities/exercise.model'; import { ColorSelectorComponent } from 'app/shared/color-selector/color-selector.component'; @@ -19,11 +19,12 @@ export class CategorySelectorComponent implements OnChanges { @Output() selectedCategories = new EventEmitter(); uniqueCategories: ExerciseCategory[] = []; - ngOnChanges(changes: SimpleChanges) { + ngOnChanges() { if (!this.existingCategories) { return; } this.existingCategories.forEach((category) => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars const categoryIsInArray = (el: ExerciseCategory, index: number, categories: ExerciseCategory[]): boolean => { return el.category === category.category; }; From 9309ad644ccc7baa779570f6b1369184ad1652ba Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Mon, 20 Apr 2020 01:16:42 +0200 Subject: [PATCH 047/152] Fix code style issues: remove unnecessary imports --- .../drag-and-drop-question/drag-and-drop-question.component.ts | 2 +- .../shared/exercise-headers/difficulty-badge.component.ts | 2 +- .../header-exercise-page-with-details.component.ts | 2 +- .../text-assessment-area/text-assessment-area.component.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/webapp/app/exercises/quiz/shared/questions/drag-and-drop-question/drag-and-drop-question.component.ts b/src/main/webapp/app/exercises/quiz/shared/questions/drag-and-drop-question/drag-and-drop-question.component.ts index 92ffd639be22..76960fd455f4 100644 --- a/src/main/webapp/app/exercises/quiz/shared/questions/drag-and-drop-question/drag-and-drop-question.component.ts +++ b/src/main/webapp/app/exercises/quiz/shared/questions/drag-and-drop-question/drag-and-drop-question.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, HostListener, Input, OnChanges, Output, SimpleChanges, ViewChild, ViewEncapsulation } from '@angular/core'; +import { Component, EventEmitter, HostListener, Input, OnChanges, Output, ViewChild, ViewEncapsulation } from '@angular/core'; import { ArtemisMarkdownService } from 'app/shared/markdown.service'; import { DragAndDropQuestionUtil } from 'app/exercises/quiz/shared/drag-and-drop-question-util.service'; import { polyfill } from 'mobile-drag-drop'; diff --git a/src/main/webapp/app/exercises/shared/exercise-headers/difficulty-badge.component.ts b/src/main/webapp/app/exercises/shared/exercise-headers/difficulty-badge.component.ts index 77f0136e6f55..e772a5114819 100644 --- a/src/main/webapp/app/exercises/shared/exercise-headers/difficulty-badge.component.ts +++ b/src/main/webapp/app/exercises/shared/exercise-headers/difficulty-badge.component.ts @@ -1,5 +1,5 @@ import { Component, Input, OnDestroy, OnInit } from '@angular/core'; -import { LangChangeEvent, TranslateService } from '@ngx-translate/core'; +import { TranslateService } from '@ngx-translate/core'; import { Subscription } from 'rxjs/Subscription'; import { DifficultyLevel, Exercise } from 'app/entities/exercise.model'; diff --git a/src/main/webapp/app/exercises/shared/exercise-headers/header-exercise-page-with-details.component.ts b/src/main/webapp/app/exercises/shared/exercise-headers/header-exercise-page-with-details.component.ts index 24c6050df79d..dfce6e9b3072 100644 --- a/src/main/webapp/app/exercises/shared/exercise-headers/header-exercise-page-with-details.component.ts +++ b/src/main/webapp/app/exercises/shared/exercise-headers/header-exercise-page-with-details.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'; +import { Component, Input, OnChanges, OnInit } from '@angular/core'; import * as moment from 'moment'; import { Exercise, ExerciseCategory, getIcon } from 'app/entities/exercise.model'; import { ExerciseService } from 'app/exercises/shared/exercise/exercise.service'; diff --git a/src/main/webapp/app/exercises/text/assess-new/text-assessment-area/text-assessment-area.component.ts b/src/main/webapp/app/exercises/text/assess-new/text-assessment-area/text-assessment-area.component.ts index d37fd1387443..c26ce98675ba 100644 --- a/src/main/webapp/app/exercises/text/assess-new/text-assessment-area/text-assessment-area.component.ts +++ b/src/main/webapp/app/exercises/text/assess-new/text-assessment-area/text-assessment-area.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, Input, Output, OnChanges, SimpleChanges } from '@angular/core'; +import { Component, EventEmitter, Input, Output, OnChanges } from '@angular/core'; import { TextSubmission } from 'app/entities/text-submission.model'; import { TextBlockRef } from 'app/entities/text-block-ref.model'; import { TextBlock } from 'app/entities/text-block.model'; From 9c73dd467d435b84fec8e8c4fc95285cdb75ccd3 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Mon, 20 Apr 2020 02:09:42 +0200 Subject: [PATCH 048/152] Fix failing tests in text-exercise-assessment.spec.ts --- .../text/assess/text-assessment.component.ts | 3 ++- .../text-exercise-assessement.spec.ts | 24 +++++++++---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main/webapp/app/exercises/text/assess/text-assessment.component.ts b/src/main/webapp/app/exercises/text/assess/text-assessment.component.ts index 52f6a55e9fc5..591269d1898f 100644 --- a/src/main/webapp/app/exercises/text/assess/text-assessment.component.ts +++ b/src/main/webapp/app/exercises/text/assess/text-assessment.component.ts @@ -26,6 +26,7 @@ import { ResultService } from 'app/exercises/shared/result/result.service'; import { AssessmentType } from 'app/entities/assessment-type.model'; import { TextExercise } from 'app/entities/text-exercise.model'; import { ExerciseType } from 'app/entities/exercise.model'; +import { Participation } from 'app/entities/participation/participation.model'; import { StudentParticipation } from 'app/entities/participation/student-participation.model'; import { TextSubmission } from 'app/entities/text-submission.model'; import { Result } from 'app/entities/result.model'; @@ -38,7 +39,7 @@ import { Result } from 'app/entities/result.model'; }) export class TextAssessmentComponent implements OnInit, OnDestroy, AfterViewInit { text: string; - participation: StudentParticipation; + participation: Participation; submission: TextSubmission; unassessedSubmission: TextSubmission; result: Result; diff --git a/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.spec.ts b/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.spec.ts index a3a5a6cf3214..baa2f1330ea1 100644 --- a/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.spec.ts +++ b/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.spec.ts @@ -63,15 +63,6 @@ describe('TextAssessmentComponent', () => { const exercise = { id: 20, type: ExerciseType.TEXT, assessmentType: AssessmentType.MANUAL } as TextExercise; const participation: Participation = ({ type: ParticipationType.STUDENT, exercise: Exercise }); - const submission = { - submissionExerciseType: SubmissionExerciseType.TEXT, - id: 2278, - submitted: true, - type: SubmissionType.MANUAL, - submissionDate: moment('2019-07-09T10:47:33.244Z'), - text: 'asdfasdfasdfasdf', - participation: Participation, - } as TextSubmission; const result = ({ id: 2374, resultString: '1 of 12 points', @@ -84,7 +75,18 @@ describe('TextAssessmentComponent', () => { submission: Submission, participation: Participation, } as unknown) as Result; - submission.result = result; + const submission = { + submissionExerciseType: SubmissionExerciseType.TEXT, + id: 2278, + submitted: true, + type: SubmissionType.MANUAL, + submissionDate: moment('2019-07-09T10:47:33.244Z'), + text: 'asdfasdfasdfasdf', + participation, + result, + exampleSubmission: false, + language: null, + } as TextSubmission; submission.participation.submissions = [submission]; submission.participation.results = [submission.result]; const refFeedback = { reference: 'reference', credits: 5 } as Feedback; @@ -174,7 +176,6 @@ describe('TextAssessmentComponent', () => { tick(); expect(comp.submission).to.be.deep.equal(submission); expect(comp.result).to.be.deep.equal(result); - expect(comp.exercise).to.be.deep.equal(exercise); expect(comp.participation).to.be.deep.equal(participation); expect(comp.isAtLeastInstructor).to.be.true; expect(comp.complaint).to.be.deep.equal(MockComplaintResponse.body); @@ -213,7 +214,6 @@ describe('TextAssessmentComponent', () => { getFeedbackDataForExerciseSubmissionStub.returns(of(participation)); comp.ngOnInit(); tick(); - expect(comp.exercise).to.be.deep.equal(exercise); expect(comp.isAtLeastInstructor).to.be.true; })); From ffdd7a6c70c7ebd3e82a1b3aacbf1a20e3542d25 Mon Sep 17 00:00:00 2001 From: ga24cev Date: Mon, 20 Apr 2020 16:57:18 +0200 Subject: [PATCH 049/152] Fix code style warnings and errore for: - markdown.service.spec.ts - participation-websocket-service.spec.ts - programming-exercise-test-case-service.spec.ts - programming-submission-service.spec.ts - text-editor-service.spec.ts - user-route-access-service.spec.ts --- src/test/javascript/spec/service/markdown.service.spec.ts | 2 +- .../spec/service/participation-websocket-service.spec.ts | 3 +-- .../programming-exercise-test-case-service.spec.ts | 8 ++++---- .../spec/service/programming-submission-service.spec.ts | 4 ++-- .../javascript/spec/service/text-editor-service.spec.ts | 6 +++--- .../spec/service/user-route-access-service.spec.ts | 5 ++--- 6 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/test/javascript/spec/service/markdown.service.spec.ts b/src/test/javascript/spec/service/markdown.service.spec.ts index 2d3d4f39232b..509a9f6548ac 100644 --- a/src/test/javascript/spec/service/markdown.service.spec.ts +++ b/src/test/javascript/spec/service/markdown.service.spec.ts @@ -8,7 +8,7 @@ chai.use(sinonChai); const expect = chai.expect; describe('Markdown Service', () => { - let artemisMarkdown = new ArtemisMarkdownService(); + const artemisMarkdown = new ArtemisMarkdownService(); const hintText = 'Add an explanation here (only visible in feedback after quiz has ended)'; const markdownHint = '[hint] ' + hintText; const explanationText = 'Add an explanation here (only visible in feedback after quiz has ended)'; diff --git a/src/test/javascript/spec/service/participation-websocket-service.spec.ts b/src/test/javascript/spec/service/participation-websocket-service.spec.ts index 619aa7d5c43e..49b6bcfac2fa 100644 --- a/src/test/javascript/spec/service/participation-websocket-service.spec.ts +++ b/src/test/javascript/spec/service/participation-websocket-service.spec.ts @@ -15,9 +15,7 @@ const expect = chai.expect; describe('ParticipationWebsocketService', () => { let websocketService: IWebsocketService; let receiveResultForParticipationSubject: Subject; - let receiveParticipationSubject: Subject; let receiveResultForParticipation2Subject: Subject; - let receiveParticipation2Subject: Subject; let subscribeSpy: SinonSpy; let receiveStub: SinonStub; let unsubscribeSpy: SinonSpy; @@ -169,6 +167,7 @@ describe('ParticipationWebsocketService', () => { expect(participationSpy).to.have.been.calledOnceWithExactly({ ...participation, results: [...participation.results, newRatedResult] }); }); + /*eslint no-unused-vars: ["error", { "ignoreRestSiblings": true }]*/ it('should attach the result to participation if the participation has null for results value', () => { const { results, ...participationWithoutResult } = participation; participationWebsocketService.subscribeForLatestResultOfParticipation(participationWithoutResult.id); diff --git a/src/test/javascript/spec/service/programming-exercise-test-case-service.spec.ts b/src/test/javascript/spec/service/programming-exercise-test-case-service.spec.ts index ef11b99e2c57..ec8bf1aac6cb 100644 --- a/src/test/javascript/spec/service/programming-exercise-test-case-service.spec.ts +++ b/src/test/javascript/spec/service/programming-exercise-test-case-service.spec.ts @@ -114,7 +114,7 @@ describe('ProgrammingExerciseTestCaseService', () => { }); it('should notify subscribers on new test case value', () => { - const newTestCases = testCases1.map((testCase) => ({ ...testCase, weight: 30 })); + const newTestCasesOracle = testCases1.map((testCase) => ({ ...testCase, weight: 30 })); let testCasesExercise1Subscriber1; let testCasesExercise1Subscriber2; // Subscriber 1. @@ -131,9 +131,9 @@ describe('ProgrammingExerciseTestCaseService', () => { expect(testCasesExercise1Subscriber1).to.equal(testCases1); expect(testCasesExercise1Subscriber2).to.equal(testCases1); - testCaseService.notifyTestCases(exercise1.id, newTestCases); + testCaseService.notifyTestCases(exercise1.id, newTestCasesOracle); - expect(testCasesExercise1Subscriber1).to.equal(newTestCases); - expect(testCasesExercise1Subscriber2).to.equal(newTestCases); + expect(testCasesExercise1Subscriber1).to.equal(newTestCasesOracle); + expect(testCasesExercise1Subscriber2).to.equal(newTestCasesOracle); }); }); diff --git a/src/test/javascript/spec/service/programming-submission-service.spec.ts b/src/test/javascript/spec/service/programming-submission-service.spec.ts index fb9ee526c442..17265fba79d8 100644 --- a/src/test/javascript/spec/service/programming-submission-service.spec.ts +++ b/src/test/javascript/spec/service/programming-submission-service.spec.ts @@ -82,7 +82,7 @@ describe('ProgrammingSubmissionService', () => { // @ts-ignore submissionService.submissionSubjects = { [participationId]: cachedSubject }; - const returnedObservable = submissionService.getLatestPendingSubmissionByParticipationId(participationId, 10); + submissionService.getLatestPendingSubmissionByParticipationId(participationId, 10); expect(fetchLatestPendingSubmissionSpy).to.not.have.been.called; expect(setupWebsocketSubscriptionSpy).to.not.have.been.called; expect(subscribeForNewResultSpy).to.not.have.been.called; @@ -258,7 +258,7 @@ describe('ProgrammingSubmissionService', () => { expect(fetchLatestPendingSubmissionsByExerciseIdSpy).to.have.been.calledOnceWithExactly(exerciseId); expect(receivedSubmissionState).to.deep.equal(expectedSubmissionState); - let resultEta: number = -1; + let resultEta = -1; submissionService.getResultEtaInMs().subscribe((eta) => (resultEta = eta)); // With 340 submissions, the eta should now have increased. diff --git a/src/test/javascript/spec/service/text-editor-service.spec.ts b/src/test/javascript/spec/service/text-editor-service.spec.ts index 0b9efe92d2ef..d35d815e59fe 100644 --- a/src/test/javascript/spec/service/text-editor-service.spec.ts +++ b/src/test/javascript/spec/service/text-editor-service.spec.ts @@ -5,7 +5,7 @@ import { Observable } from 'rxjs'; import { Language } from 'app/entities/tutor-group.model'; class MockHttpHandler implements HttpHandler { - handle(req: HttpRequest): Observable> { + handle(_: HttpRequest): Observable> { return new Observable>(); } } @@ -30,7 +30,7 @@ describe('TextEditorService', () => { expect(textEditorService.predictLanguage(testString)).toBe(Language.ENGLISH); }); it('Can detect a long German text ', () => { - //copied from https://de.wikipedia.org/wiki/Bernd_Br%C3%BCgge + // copied from https://de.wikipedia.org/wiki/Bernd_Br%C3%BCgge const testString = 'Bernd Brügge ist ein deutscher Informatiker und Ordinarius für Angewandte Softwaretechnik' + @@ -42,7 +42,7 @@ describe('TextEditorService', () => { expect(textEditorService.predictLanguage(testString)).toBe(Language.GERMAN); }); it('Can detect a long English text ', () => { - //copied from https://en.wikipedia.org/wiki/Bernd_Bruegge + // copied from https://en.wikipedia.org/wiki/Bernd_Bruegge const testString = 'Bernd Bruegge (German: Bernd Brügge) (born 1951) is a German computer scientist,' + diff --git a/src/test/javascript/spec/service/user-route-access-service.spec.ts b/src/test/javascript/spec/service/user-route-access-service.spec.ts index 177b975f8edb..fbe5723225d2 100644 --- a/src/test/javascript/spec/service/user-route-access-service.spec.ts +++ b/src/test/javascript/spec/service/user-route-access-service.spec.ts @@ -23,11 +23,10 @@ chai.use(sinonChai); const expect = chai.expect; describe('UserRouteAccessService', () => { - let comp: CourseExerciseDetailsComponent; + const routeStateMock: any = { snapshot: {}, url: '/' }; + const route = 'courses/:courseId/exercises/:exerciseId'; let fixture: ComponentFixture; let service: UserRouteAccessService; - let routeStateMock: any = { snapshot: {}, url: '/' }; - let route = 'courses/:courseId/exercises/:exerciseId'; beforeEach(async(() => { TestBed.configureTestingModule({ From c93d0d44f370f3487f311760cb1841eb7ab5b0b3 Mon Sep 17 00:00:00 2001 From: Andi Turdiu Date: Mon, 20 Apr 2020 17:32:32 +0200 Subject: [PATCH 050/152] Fix code style for participation-websocket-service.spec.ts, programming-exercise-test-case-service.spec.ts, text-editor-service.spec.ts --- .../spec/service/participation-websocket-service.spec.ts | 3 ++- .../service/programming-exercise-test-case-service.spec.ts | 4 ---- src/test/javascript/spec/service/text-editor-service.spec.ts | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/test/javascript/spec/service/participation-websocket-service.spec.ts b/src/test/javascript/spec/service/participation-websocket-service.spec.ts index 49b6bcfac2fa..fe20cb5fb1c5 100644 --- a/src/test/javascript/spec/service/participation-websocket-service.spec.ts +++ b/src/test/javascript/spec/service/participation-websocket-service.spec.ts @@ -167,9 +167,10 @@ describe('ParticipationWebsocketService', () => { expect(participationSpy).to.have.been.calledOnceWithExactly({ ...participation, results: [...participation.results, newRatedResult] }); }); - /*eslint no-unused-vars: ["error", { "ignoreRestSiblings": true }]*/ it('should attach the result to participation if the participation has null for results value', () => { + /* eslint-disable no-unused-vars */ const { results, ...participationWithoutResult } = participation; + /* eslint-enable no-unused-vars */ participationWebsocketService.subscribeForLatestResultOfParticipation(participationWithoutResult.id); participationWebsocketService.addParticipation(participationWithoutResult as Participation); participationWebsocketService.subscribeForParticipationChanges(); diff --git a/src/test/javascript/spec/service/programming-exercise-test-case-service.spec.ts b/src/test/javascript/spec/service/programming-exercise-test-case-service.spec.ts index ec8bf1aac6cb..f68f4b80f246 100644 --- a/src/test/javascript/spec/service/programming-exercise-test-case-service.spec.ts +++ b/src/test/javascript/spec/service/programming-exercise-test-case-service.spec.ts @@ -19,9 +19,7 @@ describe('ProgrammingExerciseTestCaseService', () => { let websocketService: IWebsocketService; let httpService: MockHttpService; let exercise1TestCaseSubject: Subject; - let receiveParticipationSubject: Subject; let exercise2TestCaseSubject: Subject; - let receiveParticipation2Subject: Subject; let subscribeSpy: SinonSpy; let receiveStub: SinonStub; let unsubscribeSpy: SinonSpy; @@ -58,8 +56,6 @@ describe('ProgrammingExerciseTestCaseService', () => { exercise1TestCaseSubject = new Subject(); exercise2TestCaseSubject = new Subject(); - receiveParticipationSubject = new Subject(); - receiveParticipation2Subject = new Subject(); receiveStub.withArgs(exercise1Topic).returns(exercise1TestCaseSubject); receiveStub.withArgs(exercise2Topic).returns(exercise2TestCaseSubject); getStub.withArgs(`${testCaseService.testCaseUrl}/${exercise1.id}/test-cases`).returns(of(testCases1)); diff --git a/src/test/javascript/spec/service/text-editor-service.spec.ts b/src/test/javascript/spec/service/text-editor-service.spec.ts index d35d815e59fe..72ad3fd300c8 100644 --- a/src/test/javascript/spec/service/text-editor-service.spec.ts +++ b/src/test/javascript/spec/service/text-editor-service.spec.ts @@ -5,7 +5,7 @@ import { Observable } from 'rxjs'; import { Language } from 'app/entities/tutor-group.model'; class MockHttpHandler implements HttpHandler { - handle(_: HttpRequest): Observable> { + handle(): Observable> { return new Observable>(); } } From e0f6acce279c4903472c93c19e2176174b421ec9 Mon Sep 17 00:00:00 2001 From: Andi Turdiu Date: Mon, 20 Apr 2020 17:46:48 +0200 Subject: [PATCH 051/152] remove unused imports, try to ignore false postive no-unused-vars --- .../spec/service/participation-websocket-service.spec.ts | 5 +++-- .../service/programming-exercise-test-case-service.spec.ts | 1 - src/test/javascript/spec/service/text-editor-service.spec.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/javascript/spec/service/participation-websocket-service.spec.ts b/src/test/javascript/spec/service/participation-websocket-service.spec.ts index fe20cb5fb1c5..edaadd54c98e 100644 --- a/src/test/javascript/spec/service/participation-websocket-service.spec.ts +++ b/src/test/javascript/spec/service/participation-websocket-service.spec.ts @@ -167,10 +167,10 @@ describe('ParticipationWebsocketService', () => { expect(participationSpy).to.have.been.calledOnceWithExactly({ ...participation, results: [...participation.results, newRatedResult] }); }); + /* eslint-disable no-unused-vars */ it('should attach the result to participation if the participation has null for results value', () => { - /* eslint-disable no-unused-vars */ const { results, ...participationWithoutResult } = participation; - /* eslint-enable no-unused-vars */ + participationWebsocketService.subscribeForLatestResultOfParticipation(participationWithoutResult.id); participationWebsocketService.addParticipation(participationWithoutResult as Participation); participationWebsocketService.subscribeForParticipationChanges(); @@ -190,4 +190,5 @@ describe('ParticipationWebsocketService', () => { expect(resultSpy).to.have.been.calledOnceWithExactly(newRatedResult); expect(participationSpy).to.have.been.calledOnceWithExactly({ ...participationWithoutResult, results: [newRatedResult] }); }); + /* eslint-enable no-unused-vars */ }); diff --git a/src/test/javascript/spec/service/programming-exercise-test-case-service.spec.ts b/src/test/javascript/spec/service/programming-exercise-test-case-service.spec.ts index f68f4b80f246..e2329bcbe3ca 100644 --- a/src/test/javascript/spec/service/programming-exercise-test-case-service.spec.ts +++ b/src/test/javascript/spec/service/programming-exercise-test-case-service.spec.ts @@ -9,7 +9,6 @@ import { IWebsocketService } from 'app/core/websocket/websocket.service.ts'; import { ProgrammingExerciseTestCaseService } from 'app/exercises/programming/manage/services/programming-exercise-test-case.service'; import { MockHttpService } from '../mocks/mock-http.service'; import { ProgrammingExerciseTestCase } from 'app/entities/programming-exercise-test-case.model'; -import { Participation } from 'app/entities/participation/participation.model'; import { Result } from 'app/entities/result.model'; chai.use(sinonChai); diff --git a/src/test/javascript/spec/service/text-editor-service.spec.ts b/src/test/javascript/spec/service/text-editor-service.spec.ts index 72ad3fd300c8..582d3a429718 100644 --- a/src/test/javascript/spec/service/text-editor-service.spec.ts +++ b/src/test/javascript/spec/service/text-editor-service.spec.ts @@ -1,6 +1,6 @@ import { TextEditorService } from 'app/exercises/text/participate/text-editor.service'; -import { HttpClient, HttpEvent, HttpHandler, HttpRequest } from '@angular/common/http'; +import { HttpClient, HttpEvent, HttpHandler } from '@angular/common/http'; import { Observable } from 'rxjs'; import { Language } from 'app/entities/tutor-group.model'; From ef1e71a6bcea24e590513b2fbffa5cf6850bce97 Mon Sep 17 00:00:00 2001 From: Stephan Krusche Date: Tue, 21 Apr 2020 11:06:20 +0200 Subject: [PATCH 052/152] fix compile errors --- .../app/shared/date-time-picker/date-time-picker.component.ts | 2 +- src/main/webapp/app/shared/util/security-util.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/webapp/app/shared/date-time-picker/date-time-picker.component.ts b/src/main/webapp/app/shared/date-time-picker/date-time-picker.component.ts index 515eda7482d8..b793dcb874aa 100644 --- a/src/main/webapp/app/shared/date-time-picker/date-time-picker.component.ts +++ b/src/main/webapp/app/shared/date-time-picker/date-time-picker.component.ts @@ -47,7 +47,7 @@ export class FormDateTimePickerComponent implements ControlValueAccessor { @Input() max: Moment; // Dates after this date are not selectable. @Output() valueChange = new EventEmitter(); - _onChange = () => {}; + _onChange = (_: Moment) => {}; valueChanged() { this.valueChange.emit(); diff --git a/src/main/webapp/app/shared/util/security-util.ts b/src/main/webapp/app/shared/util/security-util.ts index c03464d3e8a0..ea35f2bf796e 100644 --- a/src/main/webapp/app/shared/util/security-util.ts +++ b/src/main/webapp/app/shared/util/security-util.ts @@ -1,4 +1,4 @@ -export const safeUnescape = (s: string, mode = 'text/html') => { +export const safeUnescape = (s: string) => { const parser = new DOMParser(); - return parser.parseFromString(s, mode).body.textContent; + return parser.parseFromString(s, 'text/html').body.textContent; }; From 54fffae6b559bf16539d36d06b6bfc61f112e928 Mon Sep 17 00:00:00 2001 From: Stephan Krusche Date: Tue, 21 Apr 2020 12:01:58 +0200 Subject: [PATCH 053/152] fix config for yarn webpack:build and yarn start commands remove unused client files remove event.preventDefault because it should not be needed (we should quickly test though, if DnD questions work on tablets) --- .../app/core/config/uib-pagination.config.ts | 14 -------------- .../webapp/app/entities/lti-outcome-url.model.ts | 13 ------------- src/main/webapp/app/entities/lti-user-id.model.ts | 10 ---------- .../app/entities/single-user-notification.model.ts | 11 ----------- .../drag-and-drop-question.component.ts | 7 ------- tsconfig.json | 3 +-- 6 files changed, 1 insertion(+), 57 deletions(-) delete mode 100644 src/main/webapp/app/core/config/uib-pagination.config.ts delete mode 100644 src/main/webapp/app/entities/lti-outcome-url.model.ts delete mode 100644 src/main/webapp/app/entities/lti-user-id.model.ts delete mode 100644 src/main/webapp/app/entities/single-user-notification.model.ts diff --git a/src/main/webapp/app/core/config/uib-pagination.config.ts b/src/main/webapp/app/core/config/uib-pagination.config.ts deleted file mode 100644 index f9da52573032..000000000000 --- a/src/main/webapp/app/core/config/uib-pagination.config.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { Injectable } from '@angular/core'; -import { NgbPaginationConfig } from '@ng-bootstrap/ng-bootstrap'; -import { ITEMS_PER_PAGE } from 'app/shared/constants/pagination.constants'; - -@Injectable({ providedIn: 'root' }) -export class PaginationConfig { - // tslint:disable-next-line: no-unused-variable - constructor(private config: NgbPaginationConfig) { - config.boundaryLinks = true; - config.maxSize = 5; - config.pageSize = ITEMS_PER_PAGE; - config.size = 'sm'; - } -} diff --git a/src/main/webapp/app/entities/lti-outcome-url.model.ts b/src/main/webapp/app/entities/lti-outcome-url.model.ts deleted file mode 100644 index 78334782cc58..000000000000 --- a/src/main/webapp/app/entities/lti-outcome-url.model.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { BaseEntity } from 'app/shared/model/base-entity'; -import { User } from 'app/core/user/user.model'; -import { Exercise } from 'app/entities/exercise.model'; - -export class LtiOutcomeUrl implements BaseEntity { - public id: number; - public url: string; - public sourcedId: string; - public user: User; - public exercise: Exercise; - - constructor() {} -} diff --git a/src/main/webapp/app/entities/lti-user-id.model.ts b/src/main/webapp/app/entities/lti-user-id.model.ts deleted file mode 100644 index ddfdfdf07253..000000000000 --- a/src/main/webapp/app/entities/lti-user-id.model.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { BaseEntity } from 'app/shared/model/base-entity'; -import { User } from 'app/core/user/user.model'; - -export class LtiUserId implements BaseEntity { - public id: number; - public ltiUserId: string; - public user: User; - - constructor() {} -} diff --git a/src/main/webapp/app/entities/single-user-notification.model.ts b/src/main/webapp/app/entities/single-user-notification.model.ts deleted file mode 100644 index b79f2e22dbdf..000000000000 --- a/src/main/webapp/app/entities/single-user-notification.model.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { User } from 'app/core/user/user.model'; -import { Notification, NotificationType } from 'app/entities/notification.model'; - -export class SingleUserNotification extends Notification { - public id: number; - public recipient: User; - - constructor() { - super(NotificationType.SINGLE); - } -} diff --git a/src/main/webapp/app/exercises/quiz/shared/questions/drag-and-drop-question/drag-and-drop-question.component.ts b/src/main/webapp/app/exercises/quiz/shared/questions/drag-and-drop-question/drag-and-drop-question.component.ts index 76960fd455f4..661abb28e7e7 100644 --- a/src/main/webapp/app/exercises/quiz/shared/questions/drag-and-drop-question/drag-and-drop-question.component.ts +++ b/src/main/webapp/app/exercises/quiz/shared/questions/drag-and-drop-question/drag-and-drop-question.component.ts @@ -16,13 +16,6 @@ polyfill({ dragImageTranslateOverride: scrollBehaviourDragImageTranslateOverride, }); -// Drag-enter listener for mobile devices -/* eslint-disable */ -(event: any) => { - event.preventDefault(); -}; -/* eslint-enable */ - window.addEventListener('touchmove', function () {}, { passive: false }); @Component({ diff --git a/tsconfig.json b/tsconfig.json index 757d7ea9350f..f06880acea72 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -35,8 +35,7 @@ "preserveWhitespaces": true }, "include": [ - "src/main/webapp/app", - "src/test/javascript" + "src/main/webapp/app" ], "exclude": [ "node_modules" From 7875e97fb8a3a363d7d752586693860a8743ee39 Mon Sep 17 00:00:00 2001 From: Stephan Krusche Date: Tue, 21 Apr 2020 12:07:00 +0200 Subject: [PATCH 054/152] small spec config change --- tsconfig.spec.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.spec.json b/tsconfig.spec.json index 3ef45db569ce..9da8414ba025 100644 --- a/tsconfig.spec.json +++ b/tsconfig.spec.json @@ -12,6 +12,6 @@ } }, "files": ["src/test/javascript/spec/entry.ts"], - "include": ["src/test/javascript/spec", "src/main/webapp/app"], + "include": ["src/test/javascript", "src/main/webapp/app"], "exclude": ["node_modules"] } From ff37043b87ee81cdbdfa30be55a30add45329dc6 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Tue, 21 Apr 2020 22:47:57 +0200 Subject: [PATCH 055/152] Ignore false positive of chai-friendly/no-unused-expressions --- .../complaints-for-tutor/complaints-for-tutor.component.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/webapp/app/complaints/complaints-for-tutor/complaints-for-tutor.component.ts b/src/main/webapp/app/complaints/complaints-for-tutor/complaints-for-tutor.component.ts index bc7aeb99c6f7..47ec045dff51 100644 --- a/src/main/webapp/app/complaints/complaints-for-tutor/complaints-for-tutor.component.ts +++ b/src/main/webapp/app/complaints/complaints-for-tutor/complaints-for-tutor.component.ts @@ -56,6 +56,7 @@ export class ComplaintsForTutorComponent implements OnInit { this.complaintResponseService.create(this.complaintResponse).subscribe( (response) => { this.handled = true; + // eslint-disable-next-line chai-friendly/no-unused-expressions this.complaint.complaintType === ComplaintType.MORE_FEEDBACK ? this.jhiAlertService.success('artemisApp.moreFeedbackResponse.created') : this.jhiAlertService.success('artemisApp.complaintResponse.created'); From c8787f92f9dea464b1d1515fa301935644b54141 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Tue, 21 Apr 2020 22:48:27 +0200 Subject: [PATCH 056/152] Fix code style issue: "Expected an assignment or function call" --- .../assess/file-upload-assessment-dashboard.component.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/webapp/app/exercises/file-upload/assess/file-upload-assessment-dashboard.component.ts b/src/main/webapp/app/exercises/file-upload/assess/file-upload-assessment-dashboard.component.ts index 17fc122f0223..6d6fac574b92 100644 --- a/src/main/webapp/app/exercises/file-upload/assess/file-upload-assessment-dashboard.component.ts +++ b/src/main/webapp/app/exercises/file-upload/assess/file-upload-assessment-dashboard.component.ts @@ -88,7 +88,11 @@ export class FileUploadAssessmentDashboardComponent implements OnInit { .subscribe((submissions: FileUploadSubmission[]) => { this.submissions = submissions; this.filteredSubmissions = submissions; - submissions.length > 0 ? resolve() : reject(); + if (submissions.length > 0) { + resolve(); + } else { + reject(); + } }); }); } From a85d7968c0d93599b84398325a7bb332039cc2d9 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Tue, 21 Apr 2020 22:53:21 +0200 Subject: [PATCH 057/152] Fix code style issues: is defined but never used --- .../course-exercise-submission-result-simulation.service.ts | 1 - .../manage/update/programming-exercise-update.component.ts | 1 - .../grading-instructions-details.component.ts | 2 +- .../app/shared/date-time-picker/date-time-picker.component.ts | 4 ++-- src/test/javascript/spec/component/admin/admin.spec.ts | 1 - .../javascript/spec/component/admin/user-management.spec.ts | 1 - 6 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/main/webapp/app/course/manage/course-exercise-submission-result-simulation.service.ts b/src/main/webapp/app/course/manage/course-exercise-submission-result-simulation.service.ts index ec06b5c9fe55..116923d6ef48 100644 --- a/src/main/webapp/app/course/manage/course-exercise-submission-result-simulation.service.ts +++ b/src/main/webapp/app/course/manage/course-exercise-submission-result-simulation.service.ts @@ -1,4 +1,3 @@ -import { SERVER_API_URL } from 'app/app.constants'; import { Injectable } from '@angular/core'; import { ProgrammingSubmission } from 'app/entities/programming-submission.model'; import { Result } from 'app/entities/result.model'; diff --git a/src/main/webapp/app/exercises/programming/manage/update/programming-exercise-update.component.ts b/src/main/webapp/app/exercises/programming/manage/update/programming-exercise-update.component.ts index 3b6da2465819..2b3b48eef3f9 100644 --- a/src/main/webapp/app/exercises/programming/manage/update/programming-exercise-update.component.ts +++ b/src/main/webapp/app/exercises/programming/manage/update/programming-exercise-update.component.ts @@ -16,7 +16,6 @@ import { AssessmentType } from 'app/entities/assessment-type.model'; import { ExerciseCategory } from 'app/entities/exercise.model'; import { EditorMode } from 'app/shared/markdown-editor/markdown-editor.component'; import { KatexCommand } from 'app/shared/markdown-editor/commands/katex.command'; -import { ProfileInfo } from 'app/shared/layouts/profiles/profile-info.model'; import { ProfileService } from 'app/shared/layouts/profiles/profile.service'; import { ProgrammingExerciseSimulationService } from 'app/exercises/programming/manage/services/programming-exercise-simulation.service'; diff --git a/src/main/webapp/app/exercises/shared/structured-grading-criterion/grading-instructions-details/grading-instructions-details.component.ts b/src/main/webapp/app/exercises/shared/structured-grading-criterion/grading-instructions-details/grading-instructions-details.component.ts index aba130b9d87f..c77b2f839a4c 100644 --- a/src/main/webapp/app/exercises/shared/structured-grading-criterion/grading-instructions-details/grading-instructions-details.component.ts +++ b/src/main/webapp/app/exercises/shared/structured-grading-criterion/grading-instructions-details/grading-instructions-details.component.ts @@ -245,7 +245,7 @@ export class GradingInstructionsDetailsComponent implements OnInit { } } } - this.setInstructionParameters(initialCriteriaCommands.filter(([text, command]) => command instanceof GradingCriterionCommand === false)); + this.setInstructionParameters(initialCriteriaCommands.filter(([, command]) => command instanceof GradingCriterionCommand === false)); } /** diff --git a/src/main/webapp/app/shared/date-time-picker/date-time-picker.component.ts b/src/main/webapp/app/shared/date-time-picker/date-time-picker.component.ts index b793dcb874aa..4ff9bfe1cae2 100644 --- a/src/main/webapp/app/shared/date-time-picker/date-time-picker.component.ts +++ b/src/main/webapp/app/shared/date-time-picker/date-time-picker.component.ts @@ -47,7 +47,7 @@ export class FormDateTimePickerComponent implements ControlValueAccessor { @Input() max: Moment; // Dates after this date are not selectable. @Output() valueChange = new EventEmitter(); - _onChange = (_: Moment) => {}; + _onChange = () => {}; valueChanged() { this.valueChange.emit(); @@ -67,7 +67,7 @@ export class FormDateTimePickerComponent implements ControlValueAccessor { } updateField(newValue: Moment) { this.value = newValue; - this._onChange(moment(this.value)); + this._onChange(); this.valueChanged(); } } diff --git a/src/test/javascript/spec/component/admin/admin.spec.ts b/src/test/javascript/spec/component/admin/admin.spec.ts index 5e6053fbc9dc..98d84834f234 100644 --- a/src/test/javascript/spec/component/admin/admin.spec.ts +++ b/src/test/javascript/spec/component/admin/admin.spec.ts @@ -1,7 +1,6 @@ /* tslint:disable:no-unused-expression */ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { TranslateModule } from '@ngx-translate/core'; -import { DebugElement } from '@angular/core'; import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; import { ArtemisTestModule } from '../../test.module'; diff --git a/src/test/javascript/spec/component/admin/user-management.spec.ts b/src/test/javascript/spec/component/admin/user-management.spec.ts index 45eaffee7ff0..eb4fb89b5518 100644 --- a/src/test/javascript/spec/component/admin/user-management.spec.ts +++ b/src/test/javascript/spec/component/admin/user-management.spec.ts @@ -1,7 +1,6 @@ /* tslint:disable:no-unused-expression */ import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; import { TranslateModule } from '@ngx-translate/core'; -import { DebugElement } from '@angular/core'; import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; import { ArtemisTestModule } from '../../test.module'; From 4aff8bb935c5025e85cdaa561a0dd8c1de6beff3 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Tue, 21 Apr 2020 23:03:48 +0200 Subject: [PATCH 058/152] Fix code style issues: is assigned a value but never used --- .../grading-instructions-details.component.ts | 2 +- .../app/entities/quiz-exercise/quiz-exercise.service.spec.ts | 2 +- .../entities/quiz-submission/quiz-submission.service.spec.ts | 2 +- .../programming-exercise-instructor-submission-state.spec.ts | 2 -- .../spec/service/participation-websocket-service.spec.ts | 1 + 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/webapp/app/exercises/shared/structured-grading-criterion/grading-instructions-details/grading-instructions-details.component.ts b/src/main/webapp/app/exercises/shared/structured-grading-criterion/grading-instructions-details/grading-instructions-details.component.ts index c77b2f839a4c..6f49d5dfa2a5 100644 --- a/src/main/webapp/app/exercises/shared/structured-grading-criterion/grading-instructions-details/grading-instructions-details.component.ts +++ b/src/main/webapp/app/exercises/shared/structured-grading-criterion/grading-instructions-details/grading-instructions-details.component.ts @@ -231,7 +231,7 @@ export class GradingInstructionsDetailsComponent implements OnInit { newCriterion.structuredGradingInstructions = []; const modifiedArray = domainCommands.slice(1); // remove GradingCriterionCommandIdentifier after creating its criterion object let endOfCriterion = 0; - for (const [instrText, instrCommand] of modifiedArray) { + for (const [, instrCommand] of modifiedArray) { endOfCriterion++; if (instrCommand instanceof GradingInstructionCommand) { const newInstruction = new GradingInstruction(); // create instruction objects that belong to the above created criterion diff --git a/src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise.service.spec.ts b/src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise.service.spec.ts index d98e568239b8..21ad4ea9315b 100644 --- a/src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise.service.spec.ts +++ b/src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise.service.spec.ts @@ -102,7 +102,7 @@ describe('Service Tests', () => { }); it('should delete a QuizExercise', async () => { - const rxPromise = service.delete(123).subscribe((resp) => expect(resp.ok)); + service.delete(123).subscribe((resp) => expect(resp.ok)); const req = httpMock.expectOne({ method: 'DELETE' }); req.flush({ status: 200 }); diff --git a/src/test/javascript/spec/app/entities/quiz-submission/quiz-submission.service.spec.ts b/src/test/javascript/spec/app/entities/quiz-submission/quiz-submission.service.spec.ts index bb8f2e7cf63b..595a1d4cdca7 100644 --- a/src/test/javascript/spec/app/entities/quiz-submission/quiz-submission.service.spec.ts +++ b/src/test/javascript/spec/app/entities/quiz-submission/quiz-submission.service.spec.ts @@ -88,7 +88,7 @@ describe('Service Tests', () => { }); it('should delete a QuizSubmission', async () => { - const rxPromise = service.delete(123).subscribe((resp) => expect(resp.ok)); + service.delete(123).subscribe((resp) => expect(resp.ok)); const req = httpMock.expectOne({ method: 'DELETE' }); req.flush({ status: 200 }); diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-submission-state.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-submission-state.spec.ts index c07d7d255227..bb113f573c60 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-submission-state.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-submission-state.spec.ts @@ -31,7 +31,6 @@ describe('ProgrammingExerciseInstructorSubmissionState', () => { let fixture: ComponentFixture; let debugElement: DebugElement; let submissionService: ProgrammingSubmissionService; - let buildRunService: ProgrammingBuildRunService; let getExerciseSubmissionStateStub: SinonStub; let getExerciseSubmissionStateSubject: Subject; @@ -68,7 +67,6 @@ describe('ProgrammingExerciseInstructorSubmissionState', () => { debugElement = fixture.debugElement; submissionService = debugElement.injector.get(ProgrammingSubmissionService); - buildRunService = debugElement.injector.get(ProgrammingBuildRunService); getExerciseSubmissionStateSubject = new Subject(); getExerciseSubmissionStateStub = stub(submissionService, 'getSubmissionStateOfExercise').returns(getExerciseSubmissionStateSubject); diff --git a/src/test/javascript/spec/service/participation-websocket-service.spec.ts b/src/test/javascript/spec/service/participation-websocket-service.spec.ts index edaadd54c98e..6444d69749f7 100644 --- a/src/test/javascript/spec/service/participation-websocket-service.spec.ts +++ b/src/test/javascript/spec/service/participation-websocket-service.spec.ts @@ -169,6 +169,7 @@ describe('ParticipationWebsocketService', () => { /* eslint-disable no-unused-vars */ it('should attach the result to participation if the participation has null for results value', () => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars const { results, ...participationWithoutResult } = participation; participationWebsocketService.subscribeForLatestResultOfParticipation(participationWithoutResult.id); From 7e2daf8b22d9e7e4863ac164598c29696eb90cec Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Tue, 21 Apr 2020 23:05:18 +0200 Subject: [PATCH 059/152] Fix code style issue: == should be === --- src/test/javascript/spec/mocks/mock-complaint.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/javascript/spec/mocks/mock-complaint.service.ts b/src/test/javascript/spec/mocks/mock-complaint.service.ts index ba581ec11de1..36509821b859 100644 --- a/src/test/javascript/spec/mocks/mock-complaint.service.ts +++ b/src/test/javascript/spec/mocks/mock-complaint.service.ts @@ -36,7 +36,7 @@ export class MockComplaintService implements IComplaintService { return of(); } findByResultId(resultId: number): Observable { - if (resultId == 111) { + if (resultId === 111) { return of(MockComplaintResponse2); } return of(MockComplaintResponse); From b6fbaded8f2b72613156647e52c129c223040d94 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Tue, 21 Apr 2020 23:08:23 +0200 Subject: [PATCH 060/152] Fix code style issue: shadowed name --- .../spec/mocks/mock-file-upload-exercise.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/javascript/spec/mocks/mock-file-upload-exercise.service.ts b/src/test/javascript/spec/mocks/mock-file-upload-exercise.service.ts index 40ef05044a55..adedf9bfa96e 100644 --- a/src/test/javascript/spec/mocks/mock-file-upload-exercise.service.ts +++ b/src/test/javascript/spec/mocks/mock-file-upload-exercise.service.ts @@ -10,8 +10,8 @@ fileUploadExercise.filePattern = 'pdf,png'; fileUploadExercise.problemStatement = 'Example problem statement'; export class MockFileUploadExerciseService { - create = (fileUploadExercise: FileUploadExercise) => of(); - update = (fileUploadExercise: FileUploadExercise, exerciseId: number, req?: any) => of(); + create = (fileUploadExerciseParam: FileUploadExercise) => of(); + update = (fileUploadExerciseParam: FileUploadExercise, exerciseId: number, req?: any) => of(); find = (id: number) => of(new HttpResponse({ body: fileUploadExercise })); query = (req?: any) => of(); delete = (id: number) => of(); From 9316487a1ceed2f533c11dab7a585ddaaf30d750 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Tue, 21 Apr 2020 23:11:51 +0200 Subject: [PATCH 061/152] Fix code style issue: Exceeds maximum line length --- .../code-editor/code-editor-build-output.spec.ts | 8 ++++---- .../programming-exercise-instruction.spec.ts | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/test/javascript/spec/component/code-editor/code-editor-build-output.spec.ts b/src/test/javascript/spec/component/code-editor/code-editor-build-output.spec.ts index 2a6918093403..1fab9694c8d5 100644 --- a/src/test/javascript/spec/component/code-editor/code-editor-build-output.spec.ts +++ b/src/test/javascript/spec/component/code-editor/code-editor-build-output.spec.ts @@ -92,8 +92,8 @@ describe('CodeEditorBuildOutputComponent', () => { }, { time: '2019-05-15T10:32:11+02:00', - log: - '[ERROR] /var/atlassian/application-data/bamboo/xml-data/build-dir/COURSEPROGSHORT-BASE-JOB1/assignment/src/todo/main/BubbleSort.java:[8,12] cannot find symbol', + log: `[ERROR] /var/atlassian/application-data/bamboo/xml-data/build-dir/COURSEPROGSHORT-BASE-JOB1 + /assignment/src/todo/main/BubbleSort.java:[8,12] cannot find symbol`, }, { time: '2019-05-15T10:32:11+02:00', @@ -195,8 +195,8 @@ describe('CodeEditorBuildOutputComponent', () => { }, { time: '2019-05-15T10:32:11+02:00', - log: - '[ERROR] /var/atlassian/application-data/bamboo/xml-data/build-dir/COURSEPROGSHORT-BASE-JOB1/assignment/src/todo/main/BubbleSort.java:[8,12] cannot find symbol', + log: `[ERROR] /var/atlassian/application-data/bamboo/xml-data/build-dir/COURSEPROGSHORT-BASE-JOB1/ + assignment/src/todo/main/BubbleSort.java:[8,12] cannot find symbol`, }, { time: '2019-05-15T10:32:11+02:00', diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction.spec.ts index d65dc6f8ec6b..e754907ea8ce 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction.spec.ts @@ -31,6 +31,7 @@ import { ArtemisSharedModule } from 'app/shared/shared.module'; import { ResultService } from 'app/exercises/shared/result/result.service'; import { RepositoryFileService } from 'app/shared/result/repository.service'; import { ProgrammingExerciseParticipationService } from 'app/exercises/programming/manage/services/programming-exercise-participation.service'; +// eslint-disable-next-line @typescript-eslint/tslint/config import { ProgrammingExerciseInstructionTaskStatusComponent } from 'app/exercises/programming/shared/instructions-render/task/programming-exercise-instruction-task-status.component'; import { Result } from 'app/entities/result.model'; import { Feedback } from 'app/entities/feedback.model'; From 1fc615968ef3113d7edda6c351f24d6b216a71a9 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Wed, 22 Apr 2020 00:19:18 +0200 Subject: [PATCH 062/152] Fix now failing test cases due to added multi-line strings --- .../code-editor/code-editor-build-output.spec.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/test/javascript/spec/component/code-editor/code-editor-build-output.spec.ts b/src/test/javascript/spec/component/code-editor/code-editor-build-output.spec.ts index 1fab9694c8d5..07eac4addf50 100644 --- a/src/test/javascript/spec/component/code-editor/code-editor-build-output.spec.ts +++ b/src/test/javascript/spec/component/code-editor/code-editor-build-output.spec.ts @@ -92,8 +92,9 @@ describe('CodeEditorBuildOutputComponent', () => { }, { time: '2019-05-15T10:32:11+02:00', - log: `[ERROR] /var/atlassian/application-data/bamboo/xml-data/build-dir/COURSEPROGSHORT-BASE-JOB1 - /assignment/src/todo/main/BubbleSort.java:[8,12] cannot find symbol`, + log: + '[ERROR] /var/atlassian/application-data/bamboo/xml-data/build-dir/COURSEPROGSHORT-BASE-JOB1' + + '/assignment/src/todo/main/BubbleSort.java:[8,12] cannot find symbol', }, { time: '2019-05-15T10:32:11+02:00', @@ -195,8 +196,9 @@ describe('CodeEditorBuildOutputComponent', () => { }, { time: '2019-05-15T10:32:11+02:00', - log: `[ERROR] /var/atlassian/application-data/bamboo/xml-data/build-dir/COURSEPROGSHORT-BASE-JOB1/ - assignment/src/todo/main/BubbleSort.java:[8,12] cannot find symbol`, + log: + '[ERROR] /var/atlassian/application-data/bamboo/xml-data/build-dir/COURSEPROGSHORT-BASE-JOB1/' + + 'assignment/src/todo/main/BubbleSort.java:[8,12] cannot find symbol', }, { time: '2019-05-15T10:32:11+02:00', From 7b4346c3285c153ef067559e4a3b4a4bff26410a Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Wed, 22 Apr 2020 00:22:19 +0200 Subject: [PATCH 063/152] Fix code style issue in date-time-picker component --- .../app/shared/date-time-picker/date-time-picker.component.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/webapp/app/shared/date-time-picker/date-time-picker.component.ts b/src/main/webapp/app/shared/date-time-picker/date-time-picker.component.ts index 4ff9bfe1cae2..4a3d1fb94532 100644 --- a/src/main/webapp/app/shared/date-time-picker/date-time-picker.component.ts +++ b/src/main/webapp/app/shared/date-time-picker/date-time-picker.component.ts @@ -1,6 +1,5 @@ import { Component, ElementRef, EventEmitter, forwardRef, Input, Output, ViewChild } from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; -import * as moment from 'moment'; import { isMoment, Moment } from 'moment'; @Component({ From 530360fe9c4b0b9767cb2560554c8696354eaec3 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Wed, 22 Apr 2020 12:58:42 +0200 Subject: [PATCH 064/152] Temporarily disable "completed-docs" lint rule --- tslint-doc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tslint-doc.json b/tslint-doc.json index 476be9d189df..ffb43d11b3d6 100644 --- a/tslint-doc.json +++ b/tslint-doc.json @@ -7,7 +7,7 @@ ], "rules": { "completed-docs": [ - true, + false, { "enums": { "visibilities": ["all"] }, "functions": { "visibilities": ["all"] }, From 4944eaac7fb6654e5cf77d4ef7e0fd4ce732b2d5 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Wed, 22 Apr 2020 15:06:54 +0200 Subject: [PATCH 065/152] Fix failing test case in user-route-access-service.spec.ts --- .../javascript/spec/service/user-route-access-service.spec.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/javascript/spec/service/user-route-access-service.spec.ts b/src/test/javascript/spec/service/user-route-access-service.spec.ts index fbe5723225d2..d1b194ef3856 100644 --- a/src/test/javascript/spec/service/user-route-access-service.spec.ts +++ b/src/test/javascript/spec/service/user-route-access-service.spec.ts @@ -23,6 +23,8 @@ chai.use(sinonChai); const expect = chai.expect; describe('UserRouteAccessService', () => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + let comp: CourseExerciseDetailsComponent; const routeStateMock: any = { snapshot: {}, url: '/' }; const route = 'courses/:courseId/exercises/:exerciseId'; let fixture: ComponentFixture; From 108a80385a66dda86fe94c9d44af2885813caeeb Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Wed, 22 Apr 2020 15:30:35 +0200 Subject: [PATCH 066/152] Fix failing test cases in course.service.spec.ts --- .../app/entities/course/course.service.spec.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/test/javascript/spec/app/entities/course/course.service.spec.ts b/src/test/javascript/spec/app/entities/course/course.service.spec.ts index 21e9991c282f..a7b44db6e138 100644 --- a/src/test/javascript/spec/app/entities/course/course.service.spec.ts +++ b/src/test/javascript/spec/app/entities/course/course.service.spec.ts @@ -1,11 +1,16 @@ -/* tslint:disable max-line-length */ +import { TranslateService } from '@ngx-translate/core'; import { getTestBed, TestBed } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; +import { Router } from '@angular/router'; import { map, take } from 'rxjs/operators'; +import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import * as moment from 'moment'; import { DATE_TIME_FORMAT } from 'app/shared/constants/input.constants'; import { CourseManagementService } from 'app/course/manage/course-management.service'; import { Course } from 'app/entities/course.model'; +import { MockTranslateService } from '../../../mocks/mock-translate.service'; +import { MockSyncStorage } from '../../../mocks/mock-sync.storage'; +import { MockRouter } from '../../../mocks/mock-router.service'; describe('Service Tests', () => { describe('Course Service', () => { @@ -17,6 +22,12 @@ describe('Service Tests', () => { beforeEach(() => { TestBed.configureTestingModule({ imports: [HttpClientTestingModule], + providers: [ + { provide: Router, useClass: MockRouter }, + { provide: LocalStorageService, useClass: MockSyncStorage }, + { provide: SessionStorageService, useClass: MockSyncStorage }, + { provide: TranslateService, useClass: MockTranslateService }, + ], }); injector = getTestBed(); service = injector.get(CourseManagementService); @@ -127,7 +138,7 @@ describe('Service Tests', () => { returnedFromService, ); service - .query(expected) + .findAll(expected) .pipe( take(1), map((resp) => resp.body), From ae612119733a3e93a373aa22624d95df40ce9ecc Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Wed, 22 Apr 2020 15:34:50 +0200 Subject: [PATCH 067/152] Fix failing test cases in participation-websocket-service.spec.ts --- .../spec/service/participation-websocket-service.spec.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/javascript/spec/service/participation-websocket-service.spec.ts b/src/test/javascript/spec/service/participation-websocket-service.spec.ts index 6444d69749f7..67077750b534 100644 --- a/src/test/javascript/spec/service/participation-websocket-service.spec.ts +++ b/src/test/javascript/spec/service/participation-websocket-service.spec.ts @@ -14,6 +14,8 @@ const expect = chai.expect; describe('ParticipationWebsocketService', () => { let websocketService: IWebsocketService; + let receiveParticipationSubject: Subject; + let receiveParticipation2Subject: Subject; let receiveResultForParticipationSubject: Subject; let receiveResultForParticipation2Subject: Subject; let subscribeSpy: SinonSpy; From a9addbc820eb3ea155999a1444ad736e5066f1da Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Wed, 22 Apr 2020 15:52:47 +0200 Subject: [PATCH 068/152] Fix failing test case in guided-tour.service.spec.ts --- .../javascript/spec/service/guided-tour.service.spec.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/test/javascript/spec/service/guided-tour.service.spec.ts b/src/test/javascript/spec/service/guided-tour.service.spec.ts index 79a968fd3a37..fbc00319b784 100644 --- a/src/test/javascript/spec/service/guided-tour.service.spec.ts +++ b/src/test/javascript/spec/service/guided-tour.service.spec.ts @@ -171,6 +171,10 @@ describe('GuidedTourService', () => { guidedTourComponentFixture = TestBed.createComponent(GuidedTourComponent); guidedTourComponent = guidedTourComponentFixture.componentInstance; + const navBarComponentFixture = TestBed.createComponent(NavbarComponent); + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const navBarComponent = navBarComponentFixture.componentInstance; + router = TestBed.inject(Router); guidedTourService = TestBed.inject(GuidedTourService); participationService = TestBed.inject(ParticipationService); @@ -306,7 +310,8 @@ describe('GuidedTourService', () => { expect(guidedTourService['currentExercise']).to.equal(exercise1); resetCurrentTour(); - guidedTourService.guidedTourMapping = { courseShortName: 'tutorial', tours: { tour_with_course_and_exercise: '' } } as GuidedTourMapping; + const tourWithoutExerciseMapping = { courseShortName: 'tutorial', tours: { tour_with_course_and_exercise: '' } } as GuidedTourMapping; + guidedTourService.guidedTourMapping = tourWithoutExerciseMapping; // enable tour for matching course title guidedTourService.enableTourForCourseOverview(courses, tourWithCourseAndExercise, true); From 092978f637984a0dbcf70ec80f6d7620fcc9faeb Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Wed, 22 Apr 2020 16:00:00 +0200 Subject: [PATCH 069/152] Fix failing test case in programming-exercise-instructor-submission-state.spec.ts --- .../programming-exercise-instructor-submission-state.spec.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-submission-state.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-submission-state.spec.ts index bb113f573c60..0e7eddaed233 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-submission-state.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-submission-state.spec.ts @@ -31,10 +31,13 @@ describe('ProgrammingExerciseInstructorSubmissionState', () => { let fixture: ComponentFixture; let debugElement: DebugElement; let submissionService: ProgrammingSubmissionService; + let buildRunService: ProgrammingBuildRunService; let getExerciseSubmissionStateStub: SinonStub; let getExerciseSubmissionStateSubject: Subject; + // eslint-disable-next-line @typescript-eslint/no-unused-vars + let getBuildRunStateStub: SinonStub; let getBuildRunStateSubject: Subject; let triggerAllStub: SinonStub; @@ -67,11 +70,13 @@ describe('ProgrammingExerciseInstructorSubmissionState', () => { debugElement = fixture.debugElement; submissionService = debugElement.injector.get(ProgrammingSubmissionService); + buildRunService = debugElement.injector.get(ProgrammingBuildRunService); getExerciseSubmissionStateSubject = new Subject(); getExerciseSubmissionStateStub = stub(submissionService, 'getSubmissionStateOfExercise').returns(getExerciseSubmissionStateSubject); getBuildRunStateSubject = new Subject(); + getBuildRunStateStub = stub(buildRunService, 'getBuildRunUpdates').returns(getBuildRunStateSubject); triggerAllStub = stub(submissionService, 'triggerInstructorBuildForParticipationsOfExercise').returns(of()); triggerParticipationsStub = stub(submissionService, 'triggerInstructorBuildForAllParticipationsOfExercise').returns(of()); From 1c04a10113cfa8afd546b49ba72cee07f2f60d49 Mon Sep 17 00:00:00 2001 From: Martin Wauligmann Date: Wed, 22 Apr 2020 21:01:49 +0200 Subject: [PATCH 070/152] Fix test --- .../programming-exercise.component.spec.ts | 42 +++++++++++++++---- .../mocks/mock-course-exercise.service.ts | 3 ++ 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.component.spec.ts b/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.component.spec.ts index c7f810ea1bb4..4384cdf9870a 100644 --- a/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.component.spec.ts +++ b/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.component.spec.ts @@ -1,51 +1,75 @@ -/* tslint:disable max-line-length */ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { of } from 'rxjs'; import { HttpHeaders, HttpResponse } from '@angular/common/http'; +import { of } from 'rxjs'; import { ArtemisTestModule } from '../../../test.module'; import { ProgrammingExerciseComponent } from 'app/exercises/programming/manage/programming-exercise.component'; import { ProgrammingExerciseService } from 'app/exercises/programming/manage/services/programming-exercise.service'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; +import { MockSyncStorage } from '../../../mocks/mock-sync.storage'; +import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; +import { MockTranslateService } from '../../../mocks/mock-translate.service'; +import { TranslateService } from '@ngx-translate/core'; +import { ActivatedRoute, convertToParamMap } from '@angular/router'; +import { Course } from 'app/entities/course.model'; +import { OrionConnectorService } from 'app/shared/orion/orion-connector.service'; +import { MockOrionConnectorService } from '../../../mocks/mock-orion-connector.service'; +import { CourseExerciseService } from 'app/course/manage/course-management.service'; +import { MockCourseExerciseService } from '../../../mocks/mock-course-exercise.service'; describe('Component Tests', () => { describe('ProgrammingExercise Management Component', () => { + const course = { id: 123 } as Course; + const programmingExercise = new ProgrammingExercise(course); + programmingExercise.id = 456; + let comp: ProgrammingExerciseComponent; let fixture: ComponentFixture; - let service: ProgrammingExerciseService; + let service: CourseExerciseService; + + const route = ({ snapshot: { paramMap: convertToParamMap({ courseId: course.id }) } } as any) as ActivatedRoute; beforeEach(() => { TestBed.configureTestingModule({ imports: [ArtemisTestModule], declarations: [ProgrammingExerciseComponent], - providers: [], + providers: [ + { provide: SessionStorageService, useClass: MockSyncStorage }, + { provide: LocalStorageService, useClass: MockSyncStorage }, + { provide: TranslateService, useClass: MockTranslateService }, + { provide: ActivatedRoute, useValue: route }, + { provide: OrionConnectorService, useClass: MockOrionConnectorService }, + { provide: CourseExerciseService, useClass: MockCourseExerciseService }, + ], }) .overrideTemplate(ProgrammingExerciseComponent, '') .compileComponents(); fixture = TestBed.createComponent(ProgrammingExerciseComponent); comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ProgrammingExerciseService); + service = fixture.debugElement.injector.get(CourseExerciseService); }); it('Should call load all on init', () => { // GIVEN const headers = new HttpHeaders().append('link', 'link;link'); - spyOn(service, 'query').and.returnValue( + spyOn(service, 'findAllProgrammingExercisesForCourse').and.returnValue( of( new HttpResponse({ - body: [new ProgrammingExercise(123)], + body: [programmingExercise], headers, }), ), ); // WHEN + comp.course = course; + fixture.detectChanges(); comp.ngOnInit(); // THEN - expect(service.query).toHaveBeenCalled(); - expect(comp.programmingExercises[0]).toEqual(jasmine.objectContaining({ id: 123 })); + expect(service.findAllProgrammingExercisesForCourse).toHaveBeenCalled(); + expect(comp.programmingExercises[0]).toEqual(jasmine.objectContaining({ id: programmingExercise.id })); }); }); }); diff --git a/src/test/javascript/spec/mocks/mock-course-exercise.service.ts b/src/test/javascript/spec/mocks/mock-course-exercise.service.ts index b0393d6d5c2f..e32de8dad885 100644 --- a/src/test/javascript/spec/mocks/mock-course-exercise.service.ts +++ b/src/test/javascript/spec/mocks/mock-course-exercise.service.ts @@ -1,6 +1,9 @@ import { Observable } from 'rxjs'; import { StudentParticipation } from 'app/entities/participation/student-participation.model'; +import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; export class MockCourseExerciseService { startExercise = (courseId: number, exerciseId: number) => Observable.of({} as StudentParticipation); + + findAllProgrammingExercisesForCourse = (courseId: number) => Observable.of([{ id: 456 } as ProgrammingExercise]); } From 308a1b39b08e99393353cf3c5ddfbeef244328b9 Mon Sep 17 00:00:00 2001 From: Martin Wauligmann Date: Wed, 22 Apr 2020 21:06:20 +0200 Subject: [PATCH 071/152] Fix test --- .../app/admin/user-management/user-management.component.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/javascript/spec/app/admin/user-management/user-management.component.spec.ts b/src/test/javascript/spec/app/admin/user-management/user-management.component.spec.ts index dc8f97849535..622426aa7fb7 100644 --- a/src/test/javascript/spec/app/admin/user-management/user-management.component.spec.ts +++ b/src/test/javascript/spec/app/admin/user-management/user-management.component.spec.ts @@ -51,7 +51,7 @@ describe('Component Tests', () => { // WHEN comp.setActive(user, true); - tick(); // simulate async + tick(2000); // simulate async (needs to wait for the debounce time in UserManagementComponent) // THEN expect(service.update).toHaveBeenCalledWith(user); From 73c8daf6c0bd7b9b2ab55e5651bd544a7720d4ed Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Wed, 22 Apr 2020 21:37:19 +0200 Subject: [PATCH 072/152] Set testPathIgnorePatterns to ignore mock files --- src/test/javascript/jest.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/javascript/jest.config.js b/src/test/javascript/jest.config.js index 9c3a49ec306e..25f3bf31cb4f 100644 --- a/src/test/javascript/jest.config.js +++ b/src/test/javascript/jest.config.js @@ -14,6 +14,7 @@ module.exports = { transformIgnorePatterns: [`/node_modules/(?!${esModules})`], rootDir: '../../../', testMatch: ['/src/test/javascript/spec/**/*.ts'], + testPathIgnorePatterns: ['/src/test/javascript/spec/mocks/*.ts'], moduleNameMapper: { '^app/(.*)': '/src/main/webapp/app/$1', 'test/(.*)': '/src/test/javascript/spec/$1', From 69bc742da2ff0e63b935f9960ffcc97b105580b8 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Wed, 22 Apr 2020 22:01:15 +0200 Subject: [PATCH 073/152] Restore jest.config.js --- src/test/javascript/jest.config.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/javascript/jest.config.js b/src/test/javascript/jest.config.js index 25f3bf31cb4f..9c3a49ec306e 100644 --- a/src/test/javascript/jest.config.js +++ b/src/test/javascript/jest.config.js @@ -14,7 +14,6 @@ module.exports = { transformIgnorePatterns: [`/node_modules/(?!${esModules})`], rootDir: '../../../', testMatch: ['/src/test/javascript/spec/**/*.ts'], - testPathIgnorePatterns: ['/src/test/javascript/spec/mocks/*.ts'], moduleNameMapper: { '^app/(.*)': '/src/main/webapp/app/$1', 'test/(.*)': '/src/test/javascript/spec/$1', From f5767baaf9f9220f0f8e15ccdc4c4368de86140f Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Wed, 22 Apr 2020 22:54:24 +0200 Subject: [PATCH 074/152] Remove unnecessary test suite quiz-submission-detail.component.spec.ts --- .../quiz-submission-detail.component.spec.ts | 40 ------------------- 1 file changed, 40 deletions(-) delete mode 100644 src/test/javascript/spec/app/entities/quiz-submission/quiz-submission-detail.component.spec.ts diff --git a/src/test/javascript/spec/app/entities/quiz-submission/quiz-submission-detail.component.spec.ts b/src/test/javascript/spec/app/entities/quiz-submission/quiz-submission-detail.component.spec.ts deleted file mode 100644 index 23fa4ad27cfb..000000000000 --- a/src/test/javascript/spec/app/entities/quiz-submission/quiz-submission-detail.component.spec.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { ActivatedRoute } from '@angular/router'; -import { of } from 'rxjs'; - -import { ArtemisTestModule } from '../../../test.module'; -import { QuizSubmissionDetailComponent } from 'app/exercises/quiz/participate/quiz-submission/quiz-submission-detail.component'; -import { QuizSubmission } from 'app/shared/model/quiz-submission.model'; - -describe('Component Tests', () => { - describe('QuizSubmission Management Detail Component', () => { - let comp: QuizSubmissionDetailComponent; - let fixture: ComponentFixture; - const route = ({ data: of({ quizSubmission: new QuizSubmission(123) }) } as any) as ActivatedRoute; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [QuizSubmissionDetailComponent], - providers: [{ provide: ActivatedRoute, useValue: route }], - }) - .overrideTemplate(QuizSubmissionDetailComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(QuizSubmissionDetailComponent); - comp = fixture.componentInstance; - }); - - describe('OnInit', () => { - it('Should call load all on init', () => { - // GIVEN - - // WHEN - comp.ngOnInit(); - - // THEN - expect(comp.quizSubmission).toEqual(jasmine.objectContaining({ id: 123 })); - }); - }); - }); -}); From e5b29a6b0ccac33b2e93328696474326967f4b54 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Wed, 22 Apr 2020 23:07:14 +0200 Subject: [PATCH 075/152] Prevent jest from handling mocks, helpers, utils as test suites --- src/test/javascript/jest.config.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/test/javascript/jest.config.js b/src/test/javascript/jest.config.js index 9c3a49ec306e..3fbbab84f76c 100644 --- a/src/test/javascript/jest.config.js +++ b/src/test/javascript/jest.config.js @@ -13,7 +13,12 @@ module.exports = { modulePaths: ['/src/main/webapp/'], transformIgnorePatterns: [`/node_modules/(?!${esModules})`], rootDir: '../../../', - testMatch: ['/src/test/javascript/spec/**/*.ts'], + testMatch: [ + '/src/test/javascript/spec/app/**/*.ts', + '/src/test/javascript/spec/component/**/*.ts', + '/src/test/javascript/spec/integration/**/*.ts', + '/src/test/javascript/spec/service/**/*.ts', + ], moduleNameMapper: { '^app/(.*)': '/src/main/webapp/app/$1', 'test/(.*)': '/src/test/javascript/spec/$1', From 8cbcf277d9cfadc4956fe8f04324bdaedd6863fe Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Thu, 23 Apr 2020 12:13:31 +0200 Subject: [PATCH 076/152] Fix imports in test suites so that their test cases will be executed --- .../spec/app/account/register/register.component.spec.ts | 2 +- .../spec/app/admin/logs/logs.component.spec.ts | 2 +- .../app/entities/course/course-detail.component.spec.ts | 5 ++--- .../app/entities/course/course-update.component.spec.ts | 9 ++++----- .../file-upload-exercise-update.component.spec.ts | 7 +++---- .../file-upload-exercise.component.spec.ts | 7 +++---- .../file-upload-exercise.service.spec.ts | 7 +++---- .../file-upload-submission.component.spec.ts | 9 ++++----- .../file-upload-submission.service.spec.ts | 7 +++---- .../modeling-exercise-detail.component.spec.ts | 3 +-- .../modeling-exercise-update.component.spec.ts | 3 +-- .../modeling-exercise.component.spec.ts | 3 +-- .../modeling-exercise/modeling-exercise.service.spec.ts | 7 +++---- .../modeling-submission.service.spec.ts | 7 +++---- .../entities/participation/participation.service.spec.ts | 8 ++++---- .../programming-exercise-detail.component.spec.ts | 3 +-- .../programming-exercise-update.component.spec.ts | 3 +-- .../programming-exercise.service.spec.ts | 7 +++---- .../programming-submission.service.spec.ts | 9 ++++----- .../quiz-exercise/quiz-exercise-detail.component.spec.ts | 5 ++--- .../quiz-exercise/quiz-exercise.component.spec.ts | 5 ++--- .../entities/quiz-exercise/quiz-exercise.service.spec.ts | 8 ++++---- .../text-exercise/text-exercise-detail.component.spec.ts | 7 +++---- .../text-exercise/text-exercise-update.component.spec.ts | 7 +++---- .../text-exercise/text-exercise.component.spec.ts | 7 +++---- .../entities/text-exercise/text-exercise.service.spec.ts | 7 ++++--- .../text-submission/text-submission.service.spec.ts | 7 +++---- 27 files changed, 70 insertions(+), 91 deletions(-) diff --git a/src/test/javascript/spec/app/account/register/register.component.spec.ts b/src/test/javascript/spec/app/account/register/register.component.spec.ts index 5e814523e211..b531d55a30c3 100644 --- a/src/test/javascript/spec/app/account/register/register.component.spec.ts +++ b/src/test/javascript/spec/app/account/register/register.component.spec.ts @@ -4,7 +4,7 @@ import { of, throwError } from 'rxjs'; import { JhiLanguageService } from 'ng-jhipster'; import { MockLanguageService } from '../../../helpers/mock-language.service'; import { ArtemisTestModule } from '../../../test.module'; -import { EMAIL_ALREADY_USED_TYPE, LOGIN_ALREADY_USED_TYPE } from 'app/shared'; +import { EMAIL_ALREADY_USED_TYPE, LOGIN_ALREADY_USED_TYPE } from 'app/shared/constants/error.constants'; import { RegisterService } from 'app/account/register/register.service'; import { RegisterComponent } from 'app/account/register/register.component'; diff --git a/src/test/javascript/spec/app/admin/logs/logs.component.spec.ts b/src/test/javascript/spec/app/admin/logs/logs.component.spec.ts index 68f11e5dd5bf..b9c7d0cd1223 100644 --- a/src/test/javascript/spec/app/admin/logs/logs.component.spec.ts +++ b/src/test/javascript/spec/app/admin/logs/logs.component.spec.ts @@ -5,7 +5,7 @@ import { HttpHeaders, HttpResponse } from '@angular/common/http'; import { ArtemisTestModule } from '../../../test.module'; import { LogsComponent } from 'app/admin/logs/logs.component'; import { LogsService } from 'app/admin/logs/logs.service'; -import { Log } from 'app/admin'; +import { Log } from 'app/admin/logs/log.model'; describe('Component Tests', () => { describe('LogsComponent', () => { diff --git a/src/test/javascript/spec/app/entities/course/course-detail.component.spec.ts b/src/test/javascript/spec/app/entities/course/course-detail.component.spec.ts index fbc54243c480..3d37dbc37146 100644 --- a/src/test/javascript/spec/app/entities/course/course-detail.component.spec.ts +++ b/src/test/javascript/spec/app/entities/course/course-detail.component.spec.ts @@ -1,11 +1,10 @@ -/* tslint:disable max-line-length */ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ActivatedRoute } from '@angular/router'; import { of } from 'rxjs'; import { ArtemisTestModule } from '../../../test.module'; -import { CourseDetailComponent } from 'app/entities/manage/course-detail.component'; -import { Course } from 'app/shared/model/course.model'; +import { CourseDetailComponent } from 'app/course/manage/course-detail.component'; +import { Course } from 'app/entities/course.model'; describe('Component Tests', () => { describe('Course Management Detail Component', () => { diff --git a/src/test/javascript/spec/app/entities/course/course-update.component.spec.ts b/src/test/javascript/spec/app/entities/course/course-update.component.spec.ts index fd0f0d4850bc..20905227ad75 100644 --- a/src/test/javascript/spec/app/entities/course/course-update.component.spec.ts +++ b/src/test/javascript/spec/app/entities/course/course-update.component.spec.ts @@ -1,18 +1,17 @@ -/* tslint:disable max-line-length */ import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; import { HttpResponse } from '@angular/common/http'; import { of } from 'rxjs'; import { ArtemisTestModule } from '../../../test.module'; -import { CourseUpdateComponent } from 'app/entities/manage/course-update.component'; -import { CourseService } from 'app/course/manage/course.service'; +import { CourseUpdateComponent } from 'app/course/manage/course-update.component'; +import { CourseManagementService } from 'app/course/manage/course-management.service'; import { Course } from 'app/entities/course.model'; describe('Component Tests', () => { describe('Course Management Update Component', () => { let comp: CourseUpdateComponent; let fixture: ComponentFixture; - let service: CourseService; + let service: CourseManagementService; beforeEach(() => { TestBed.configureTestingModule({ @@ -24,7 +23,7 @@ describe('Component Tests', () => { fixture = TestBed.createComponent(CourseUpdateComponent); comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(CourseService); + service = fixture.debugElement.injector.get(CourseManagementService); }); describe('save', () => { diff --git a/src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise-update.component.spec.ts b/src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise-update.component.spec.ts index e017d6534e72..a4878ab8bc3a 100644 --- a/src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise-update.component.spec.ts +++ b/src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise-update.component.spec.ts @@ -1,12 +1,11 @@ -/* tslint:disable max-line-length */ import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; import { HttpResponse } from '@angular/common/http'; import { of } from 'rxjs'; -import { ArTeMiSTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../../test.module'; import { FileUploadExerciseUpdateComponent } from 'app/exercises/file-upload/manage/file-upload-exercise-update.component'; import { FileUploadExerciseService } from 'app/exercises/file-upload/manage/file-upload-exercise.service'; -import { FileUploadExercise } from 'app/shared/model/file-upload-exercise.model'; +import { FileUploadExercise } from 'app/entities/file-upload-exercise.model'; describe('Component Tests', () => { describe('FileUploadExercise Management Update Component', () => { @@ -16,7 +15,7 @@ describe('Component Tests', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ArTeMiSTestModule], + imports: [ArtemisTestModule], declarations: [FileUploadExerciseUpdateComponent], }) .overrideTemplate(FileUploadExerciseUpdateComponent, '') diff --git a/src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise.component.spec.ts b/src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise.component.spec.ts index ebb275735301..74a8c33997c1 100644 --- a/src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise.component.spec.ts +++ b/src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise.component.spec.ts @@ -1,12 +1,11 @@ -/* tslint:disable max-line-length */ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { of } from 'rxjs'; import { HttpHeaders, HttpResponse } from '@angular/common/http'; -import { ArTeMiSTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../../test.module'; import { FileUploadExerciseComponent } from 'app/exercises/file-upload/manage/file-upload-exercise.component'; import { FileUploadExerciseService } from 'app/exercises/file-upload/manage/file-upload-exercise.service'; -import { FileUploadExercise } from 'app/shared/model/file-upload-exercise.model'; +import { FileUploadExercise } from 'app/entities/file-upload-exercise.model'; describe('Component Tests', () => { describe('FileUploadExercise Management Component', () => { @@ -16,7 +15,7 @@ describe('Component Tests', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ArTeMiSTestModule], + imports: [ArtemisTestModule], declarations: [FileUploadExerciseComponent], providers: [], }) diff --git a/src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise.service.spec.ts b/src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise.service.spec.ts index 58006ee21221..43ac22028f76 100644 --- a/src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise.service.spec.ts +++ b/src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise.service.spec.ts @@ -1,16 +1,15 @@ -/* tslint:disable max-line-length */ import { getTestBed, TestBed } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { map, take } from 'rxjs/operators'; import { FileUploadExerciseService } from 'app/exercises/file-upload/manage/file-upload-exercise.service'; -import { FileUploadExercise, IFileUploadExercise } from 'app/shared/model/file-upload-exercise.model'; +import { FileUploadExercise } from 'app/entities/file-upload-exercise.model'; describe('Service Tests', () => { describe('FileUploadExercise Service', () => { let injector: TestBed; let service: FileUploadExerciseService; let httpMock: HttpTestingController; - let elemDefault: IFileUploadExercise; + let elemDefault: FileUploadExercise; beforeEach(() => { TestBed.configureTestingModule({ imports: [HttpClientTestingModule], @@ -19,7 +18,7 @@ describe('Service Tests', () => { service = injector.get(FileUploadExerciseService); httpMock = injector.get(HttpTestingController); - elemDefault = new FileUploadExercise(0, 'AAAAAAA'); + elemDefault = new FileUploadExercise(0); }); describe('Service methods', async () => { diff --git a/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission.component.spec.ts b/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission.component.spec.ts index fddebd5ba11c..b98003e7d680 100644 --- a/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission.component.spec.ts +++ b/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission.component.spec.ts @@ -1,12 +1,11 @@ -/* tslint:disable max-line-length */ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { of } from 'rxjs'; import { HttpHeaders, HttpResponse } from '@angular/common/http'; -import { ArTeMiSTestModule } from '../../../test.module'; -import { FileUploadSubmissionComponent } from 'app/exercises/file-upload-submission/file-upload-submission.component'; +import { ArtemisTestModule } from '../../../test.module'; +import { FileUploadSubmissionComponent } from 'app/exercises/file-upload/participate/file-upload-submission.component'; import { FileUploadSubmissionService } from 'app/exercises/file-upload/participate/file-upload-submission.service'; -import { FileUploadSubmission } from 'app/shared/model/file-upload-submission.model'; +import { FileUploadSubmission } from 'app/entities/file-upload-submission.model'; describe('Component Tests', () => { describe('FileUploadSubmission Management Component', () => { @@ -16,7 +15,7 @@ describe('Component Tests', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ArTeMiSTestModule], + imports: [ArtemisTestModule], declarations: [FileUploadSubmissionComponent], providers: [], }) diff --git a/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission.service.spec.ts b/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission.service.spec.ts index bcf1a51b8bba..aeb5db84f198 100644 --- a/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission.service.spec.ts +++ b/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission.service.spec.ts @@ -1,16 +1,15 @@ -/* tslint:disable max-line-length */ import { getTestBed, TestBed } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { map, take } from 'rxjs/operators'; import { FileUploadSubmissionService } from 'app/exercises/file-upload/participate/file-upload-submission.service'; -import { FileUploadSubmission, IFileUploadSubmission } from 'app/shared/model/file-upload-submission.model'; +import { FileUploadSubmission } from 'app/entities/file-upload-submission.model'; describe('Service Tests', () => { describe('FileUploadSubmission Service', () => { let injector: TestBed; let service: FileUploadSubmissionService; let httpMock: HttpTestingController; - let elemDefault: IFileUploadSubmission; + let elemDefault: FileUploadSubmission; beforeEach(() => { TestBed.configureTestingModule({ imports: [HttpClientTestingModule], @@ -19,7 +18,7 @@ describe('Service Tests', () => { service = injector.get(FileUploadSubmissionService); httpMock = injector.get(HttpTestingController); - elemDefault = new FileUploadSubmission(0, 'AAAAAAA'); + elemDefault = new FileUploadSubmission(); }); describe('Service methods', async () => { diff --git a/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise-detail.component.spec.ts b/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise-detail.component.spec.ts index db3a25ca63f2..c22dd3fc5daf 100644 --- a/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise-detail.component.spec.ts +++ b/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise-detail.component.spec.ts @@ -1,11 +1,10 @@ -/* tslint:disable max-line-length */ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ActivatedRoute } from '@angular/router'; import { of } from 'rxjs'; import { ArtemisTestModule } from '../../../test.module'; import { ModelingExerciseDetailComponent } from 'app/exercises/modeling/manage/modeling-exercise-detail.component'; -import { ModelingExercise } from 'app/shared/model/modeling-exercise.model'; +import { ModelingExercise } from 'app/entities/modeling-exercise.model'; describe('Component Tests', () => { describe('ModelingExercise Management Detail Component', () => { diff --git a/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise-update.component.spec.ts b/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise-update.component.spec.ts index af9603e9ea54..be860fd75320 100644 --- a/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise-update.component.spec.ts +++ b/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise-update.component.spec.ts @@ -1,4 +1,3 @@ -/* tslint:disable max-line-length */ import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; import { HttpResponse } from '@angular/common/http'; import { of } from 'rxjs'; @@ -6,7 +5,7 @@ import { of } from 'rxjs'; import { ArtemisTestModule } from '../../../test.module'; import { ModelingExerciseUpdateComponent } from 'app/exercises/modeling/manage/modeling-exercise-update.component'; import { ModelingExerciseService } from 'app/exercises/modeling/manage/modeling-exercise.service'; -import { ModelingExercise } from 'app/shared/model/modeling-exercise.model'; +import { ModelingExercise } from 'app/entities/modeling-exercise.model'; describe('Component Tests', () => { describe('ModelingExercise Management Update Component', () => { diff --git a/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise.component.spec.ts b/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise.component.spec.ts index 868352cd2a6b..fa3ec3910c20 100644 --- a/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise.component.spec.ts +++ b/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise.component.spec.ts @@ -1,4 +1,3 @@ -/* tslint:disable max-line-length */ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { of } from 'rxjs'; import { HttpHeaders, HttpResponse } from '@angular/common/http'; @@ -6,7 +5,7 @@ import { HttpHeaders, HttpResponse } from '@angular/common/http'; import { ArtemisTestModule } from '../../../test.module'; import { ModelingExerciseComponent } from 'app/exercises/modeling/manage/modeling-exercise.component'; import { ModelingExerciseService } from 'app/exercises/modeling/manage/modeling-exercise.service'; -import { ModelingExercise } from 'app/shared/model/modeling-exercise.model'; +import { ModelingExercise } from 'app/entities/modeling-exercise.model'; describe('Component Tests', () => { describe('ModelingExercise Management Component', () => { diff --git a/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise.service.spec.ts b/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise.service.spec.ts index 8ebafad0f4fa..d77031074fca 100644 --- a/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise.service.spec.ts +++ b/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise.service.spec.ts @@ -1,16 +1,15 @@ -/* tslint:disable max-line-length */ import { getTestBed, TestBed } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { map, take } from 'rxjs/operators'; import { ModelingExerciseService } from 'app/exercises/modeling/manage/modeling-exercise.service'; -import { DiagramType, IModelingExercise, ModelingExercise } from 'app/shared/model/modeling-exercise.model'; +import { DiagramType, ModelingExercise } from 'app/entities/modeling-exercise.model'; describe('Service Tests', () => { describe('ModelingExercise Service', () => { let injector: TestBed; let service: ModelingExerciseService; let httpMock: HttpTestingController; - let elemDefault: IModelingExercise; + let elemDefault: ModelingExercise; beforeEach(() => { TestBed.configureTestingModule({ imports: [HttpClientTestingModule], @@ -19,7 +18,7 @@ describe('Service Tests', () => { service = injector.get(ModelingExerciseService); httpMock = injector.get(HttpTestingController); - elemDefault = new ModelingExercise(0, DiagramType.CLASS, 'AAAAAAA', 'AAAAAAA'); + elemDefault = new ModelingExercise(DiagramType.ComponentDiagram); }); describe('Service methods', async () => { diff --git a/src/test/javascript/spec/app/entities/modeling-submission/modeling-submission.service.spec.ts b/src/test/javascript/spec/app/entities/modeling-submission/modeling-submission.service.spec.ts index c967eb7aa896..fbf1f3143a41 100644 --- a/src/test/javascript/spec/app/entities/modeling-submission/modeling-submission.service.spec.ts +++ b/src/test/javascript/spec/app/entities/modeling-submission/modeling-submission.service.spec.ts @@ -1,16 +1,15 @@ -/* tslint:disable max-line-length */ import { getTestBed, TestBed } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { map, take } from 'rxjs/operators'; import { ModelingSubmissionService } from 'app/exercises/modeling/participate/modeling-submission.service'; -import { IModelingSubmission, ModelingSubmission } from 'app/shared/model/modeling-submission.model'; +import { ModelingSubmission } from 'app/entities/modeling-submission.model'; describe('Service Tests', () => { describe('ModelingSubmission Service', () => { let injector: TestBed; let service: ModelingSubmissionService; let httpMock: HttpTestingController; - let elemDefault: IModelingSubmission; + let elemDefault: ModelingSubmission; beforeEach(() => { TestBed.configureTestingModule({ imports: [HttpClientTestingModule], @@ -19,7 +18,7 @@ describe('Service Tests', () => { service = injector.get(ModelingSubmissionService); httpMock = injector.get(HttpTestingController); - elemDefault = new ModelingSubmission(0, 'AAAAAAA', 'AAAAAAA'); + elemDefault = new ModelingSubmission(); }); describe('Service methods', async () => { diff --git a/src/test/javascript/spec/app/entities/participation/participation.service.spec.ts b/src/test/javascript/spec/app/entities/participation/participation.service.spec.ts index a70f1cae6370..483a50c33278 100644 --- a/src/test/javascript/spec/app/entities/participation/participation.service.spec.ts +++ b/src/test/javascript/spec/app/entities/participation/participation.service.spec.ts @@ -1,18 +1,18 @@ -/* tslint:disable max-line-length */ import { getTestBed, TestBed } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { map, take } from 'rxjs/operators'; import * as moment from 'moment'; import { DATE_TIME_FORMAT } from 'app/shared/constants/input.constants'; import { ParticipationService } from 'app/exercises/shared/participation/participation.service'; -import { InitializationState, IParticipation, Participation } from 'app/shared/model/participation.model'; +import { Participation } from 'app/entities/participation/participation.model'; +import { StudentParticipation } from 'app/entities/participation/student-participation.model'; describe('Service Tests', () => { describe('Participation Service', () => { let injector: TestBed; let service: ParticipationService; let httpMock: HttpTestingController; - let elemDefault: IParticipation; + let elemDefault: Participation; let currentDate: moment.Moment; beforeEach(() => { TestBed.configureTestingModule({ @@ -23,7 +23,7 @@ describe('Service Tests', () => { httpMock = injector.get(HttpTestingController); currentDate = moment(); - elemDefault = new Participation(0, 'AAAAAAA', 'AAAAAAA', InitializationState.UNINITIALIZED, currentDate, 0); + elemDefault = new StudentParticipation(); }); describe('Service methods', async () => { diff --git a/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise-detail.component.spec.ts b/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise-detail.component.spec.ts index 8e16b674c650..ee5451141c64 100644 --- a/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise-detail.component.spec.ts +++ b/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise-detail.component.spec.ts @@ -1,11 +1,10 @@ -/* tslint:disable max-line-length */ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ActivatedRoute } from '@angular/router'; import { of } from 'rxjs'; import { ArtemisTestModule } from '../../../test.module'; import { ProgrammingExerciseDetailComponent } from 'app/exercises/programming/manage/programming-exercise-detail.component'; -import { ProgrammingExercise } from 'app/shared/model/programming-exercise.model'; +import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; describe('Component Tests', () => { describe('ProgrammingExercise Management Detail Component', () => { diff --git a/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise-update.component.spec.ts b/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise-update.component.spec.ts index 905c2ee7cc6c..409e17938526 100644 --- a/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise-update.component.spec.ts +++ b/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise-update.component.spec.ts @@ -1,4 +1,3 @@ -/* tslint:disable max-line-length */ import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; import { HttpResponse } from '@angular/common/http'; import { of } from 'rxjs'; @@ -6,7 +5,7 @@ import { of } from 'rxjs'; import { ArtemisTestModule } from '../../../test.module'; import { ProgrammingExerciseUpdateComponent } from 'app/exercises/programming/manage/update/programming-exercise-update.component'; import { ProgrammingExerciseService } from 'app/exercises/programming/manage/services/programming-exercise.service'; -import { ProgrammingExercise } from 'app/shared/model/programming-exercise.model'; +import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; describe('Component Tests', () => { describe('ProgrammingExercise Management Update Component', () => { diff --git a/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.service.spec.ts b/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.service.spec.ts index d13741c342c0..9edaac704acd 100644 --- a/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.service.spec.ts +++ b/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.service.spec.ts @@ -1,16 +1,15 @@ -/* tslint:disable max-line-length */ import { getTestBed, TestBed } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { map, take } from 'rxjs/operators'; import { ProgrammingExerciseService } from 'app/exercises/programming/manage/services/programming-exercise.service'; -import { IProgrammingExercise, ProgrammingExercise } from 'app/shared/model/programming-exercise.model'; +import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; describe('Service Tests', () => { describe('ProgrammingExercise Service', () => { let injector: TestBed; let service: ProgrammingExerciseService; let httpMock: HttpTestingController; - let elemDefault: IProgrammingExercise; + let elemDefault: ProgrammingExercise; beforeEach(() => { TestBed.configureTestingModule({ imports: [HttpClientTestingModule], @@ -19,7 +18,7 @@ describe('Service Tests', () => { service = injector.get(ProgrammingExerciseService); httpMock = injector.get(HttpTestingController); - elemDefault = new ProgrammingExercise(0, 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', false, false); + elemDefault = new ProgrammingExercise(); }); describe('Service methods', async () => { diff --git a/src/test/javascript/spec/app/entities/programming-submission/programming-submission.service.spec.ts b/src/test/javascript/spec/app/entities/programming-submission/programming-submission.service.spec.ts index 04acf7e9cb23..2bbe1d6811d5 100644 --- a/src/test/javascript/spec/app/entities/programming-submission/programming-submission.service.spec.ts +++ b/src/test/javascript/spec/app/entities/programming-submission/programming-submission.service.spec.ts @@ -1,16 +1,15 @@ -/* tslint:disable max-line-length */ import { getTestBed, TestBed } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { map, take } from 'rxjs/operators'; -import { ProgrammingSubmissionService } from 'app/entities/programming-submission/programming-submission.service'; -import { IProgrammingSubmission, ProgrammingSubmission } from 'app/shared/model/programming-submission.model'; +import { ProgrammingSubmissionService } from 'app/exercises/programming/participate/programming-submission.service'; +import { ProgrammingSubmission } from 'app/entities/programming-submission.model'; describe('Service Tests', () => { describe('ProgrammingSubmission Service', () => { let injector: TestBed; let service: ProgrammingSubmissionService; let httpMock: HttpTestingController; - let elemDefault: IProgrammingSubmission; + let elemDefault: ProgrammingSubmission; beforeEach(() => { TestBed.configureTestingModule({ imports: [HttpClientTestingModule], @@ -19,7 +18,7 @@ describe('Service Tests', () => { service = injector.get(ProgrammingSubmissionService); httpMock = injector.get(HttpTestingController); - elemDefault = new ProgrammingSubmission(0, 'AAAAAAA'); + elemDefault = new ProgrammingSubmission(); }); describe('Service methods', async () => { diff --git a/src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise-detail.component.spec.ts b/src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise-detail.component.spec.ts index f44e8baba56e..ed7c54d76880 100644 --- a/src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise-detail.component.spec.ts +++ b/src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise-detail.component.spec.ts @@ -1,11 +1,10 @@ -/* tslint:disable max-line-length */ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ActivatedRoute } from '@angular/router'; import { of } from 'rxjs'; import { ArtemisTestModule } from '../../../test.module'; -import { QuizExerciseDetailComponent } from 'app/entities/quiz-exercise/quiz-exercise-detail.component'; -import { QuizExercise } from 'app/shared/model/quiz-exercise.model'; +import { QuizExerciseDetailComponent } from 'app/exercises/quiz/manage/quiz-exercise-detail.component'; +import { QuizExercise } from 'app/entities/quiz/quiz-exercise.model'; describe('Component Tests', () => { describe('QuizExercise Management Detail Component', () => { diff --git a/src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise.component.spec.ts b/src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise.component.spec.ts index 4b2a5a5701d6..a40d492f1c30 100644 --- a/src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise.component.spec.ts +++ b/src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise.component.spec.ts @@ -1,12 +1,11 @@ -/* tslint:disable max-line-length */ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { of } from 'rxjs'; import { HttpHeaders, HttpResponse } from '@angular/common/http'; import { ArtemisTestModule } from '../../../test.module'; -import { QuizExerciseComponent } from 'app/entities/quiz-exercise/quiz-exercise.component'; +import { QuizExerciseComponent } from 'app/exercises/quiz/manage/quiz-exercise.component'; import { QuizExerciseService } from 'app/exercises/quiz/manage/quiz-exercise.service'; -import { QuizExercise } from 'app/shared/model/quiz-exercise.model'; +import { QuizExercise } from 'app/entities/quiz/quiz-exercise.model'; describe('Component Tests', () => { describe('QuizExercise Management Component', () => { diff --git a/src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise.service.spec.ts b/src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise.service.spec.ts index 21ad4ea9315b..848efc9841b3 100644 --- a/src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise.service.spec.ts +++ b/src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise.service.spec.ts @@ -1,16 +1,16 @@ -/* tslint:disable max-line-length */ import { getTestBed, TestBed } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { map, take } from 'rxjs/operators'; import { QuizExerciseService } from 'app/exercises/quiz/manage/quiz-exercise.service'; -import { IQuizExercise, QuizExercise } from 'app/shared/model/quiz-exercise.model'; +import { QuizExercise } from 'app/entities/quiz/quiz-exercise.model'; +import { Course } from 'app/entities/course.model'; describe('Service Tests', () => { describe('QuizExercise Service', () => { let injector: TestBed; let service: QuizExerciseService; let httpMock: HttpTestingController; - let elemDefault: IQuizExercise; + let elemDefault: QuizExercise; beforeEach(() => { TestBed.configureTestingModule({ imports: [HttpClientTestingModule], @@ -19,7 +19,7 @@ describe('Service Tests', () => { service = injector.get(QuizExerciseService); httpMock = injector.get(HttpTestingController); - elemDefault = new QuizExercise(0, 'AAAAAAA', 'AAAAAAA', false, 0, false, false, false, 0); + elemDefault = new QuizExercise(new Course()); }); describe('Service methods', async () => { diff --git a/src/test/javascript/spec/app/entities/text-exercise/text-exercise-detail.component.spec.ts b/src/test/javascript/spec/app/entities/text-exercise/text-exercise-detail.component.spec.ts index 22b6b2ede930..a1cce1a91aa3 100644 --- a/src/test/javascript/spec/app/entities/text-exercise/text-exercise-detail.component.spec.ts +++ b/src/test/javascript/spec/app/entities/text-exercise/text-exercise-detail.component.spec.ts @@ -1,11 +1,10 @@ -/* tslint:disable max-line-length */ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ActivatedRoute } from '@angular/router'; import { of } from 'rxjs'; -import { ArTeMiSTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../../test.module'; import { TextExerciseDetailComponent } from 'app/exercises/text/manage/text-exercise/text-exercise-detail.component'; -import { TextExercise } from 'app/shared/model/text-exercise.model'; +import { TextExercise } from 'app/entities/text-exercise.model'; describe('Component Tests', () => { describe('TextExercise Management Detail Component', () => { @@ -15,7 +14,7 @@ describe('Component Tests', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ArTeMiSTestModule], + imports: [ArtemisTestModule], declarations: [TextExerciseDetailComponent], providers: [{ provide: ActivatedRoute, useValue: route }], }) diff --git a/src/test/javascript/spec/app/entities/text-exercise/text-exercise-update.component.spec.ts b/src/test/javascript/spec/app/entities/text-exercise/text-exercise-update.component.spec.ts index 0820c194199b..367422387c72 100644 --- a/src/test/javascript/spec/app/entities/text-exercise/text-exercise-update.component.spec.ts +++ b/src/test/javascript/spec/app/entities/text-exercise/text-exercise-update.component.spec.ts @@ -1,12 +1,11 @@ -/* tslint:disable max-line-length */ import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; import { HttpResponse } from '@angular/common/http'; import { of } from 'rxjs'; -import { ArTeMiSTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../../test.module'; import { TextExerciseUpdateComponent } from 'app/exercises/text/manage/text-exercise/text-exercise-update.component'; import { TextExerciseService } from 'app/exercises/text/manage/text-exercise/text-exercise.service'; -import { TextExercise } from 'app/shared/model/text-exercise.model'; +import { TextExercise } from 'app/entities/text-exercise.model'; describe('Component Tests', () => { describe('TextExercise Management Update Component', () => { @@ -16,7 +15,7 @@ describe('Component Tests', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ArTeMiSTestModule], + imports: [ArtemisTestModule], declarations: [TextExerciseUpdateComponent], }) .overrideTemplate(TextExerciseUpdateComponent, '') diff --git a/src/test/javascript/spec/app/entities/text-exercise/text-exercise.component.spec.ts b/src/test/javascript/spec/app/entities/text-exercise/text-exercise.component.spec.ts index 1074a449e0ee..8baad59527c1 100644 --- a/src/test/javascript/spec/app/entities/text-exercise/text-exercise.component.spec.ts +++ b/src/test/javascript/spec/app/entities/text-exercise/text-exercise.component.spec.ts @@ -1,12 +1,11 @@ -/* tslint:disable max-line-length */ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { of } from 'rxjs'; import { HttpHeaders, HttpResponse } from '@angular/common/http'; -import { ArTeMiSTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../../test.module'; import { TextExerciseComponent } from 'app/exercises/text/manage/text-exercise/text-exercise.component'; import { TextExerciseService } from 'app/exercises/text/manage/text-exercise/text-exercise.service'; -import { TextExercise } from 'app/shared/model/text-exercise.model'; +import { TextExercise } from 'app/entities/text-exercise.model'; describe('Component Tests', () => { describe('TextExercise Management Component', () => { @@ -16,7 +15,7 @@ describe('Component Tests', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ArTeMiSTestModule], + imports: [ArtemisTestModule], declarations: [TextExerciseComponent], providers: [], }) diff --git a/src/test/javascript/spec/app/entities/text-exercise/text-exercise.service.spec.ts b/src/test/javascript/spec/app/entities/text-exercise/text-exercise.service.spec.ts index 1af9307ccc69..d50c3018d441 100644 --- a/src/test/javascript/spec/app/entities/text-exercise/text-exercise.service.spec.ts +++ b/src/test/javascript/spec/app/entities/text-exercise/text-exercise.service.spec.ts @@ -3,14 +3,15 @@ import { getTestBed, TestBed } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { map, take } from 'rxjs/operators'; import { TextExerciseService } from 'app/exercises/text/manage/text-exercise/text-exercise.service'; -import { ITextExercise, TextExercise } from 'app/shared/model/text-exercise.model'; +import { TextExercise } from 'app/entities/text-exercise.model'; +import { Course } from 'app/entities/course.model'; describe('Service Tests', () => { describe('TextExercise Service', () => { let injector: TestBed; let service: TextExerciseService; let httpMock: HttpTestingController; - let elemDefault: ITextExercise; + let elemDefault: TextExercise; beforeEach(() => { TestBed.configureTestingModule({ imports: [HttpClientTestingModule], @@ -19,7 +20,7 @@ describe('Service Tests', () => { service = injector.get(TextExerciseService); httpMock = injector.get(HttpTestingController); - elemDefault = new TextExercise(0, 'AAAAAAA'); + elemDefault = new TextExercise(new Course()); }); describe('Service methods', async () => { diff --git a/src/test/javascript/spec/app/entities/text-submission/text-submission.service.spec.ts b/src/test/javascript/spec/app/entities/text-submission/text-submission.service.spec.ts index 47de959d7081..647ffdef45fa 100644 --- a/src/test/javascript/spec/app/entities/text-submission/text-submission.service.spec.ts +++ b/src/test/javascript/spec/app/entities/text-submission/text-submission.service.spec.ts @@ -1,16 +1,15 @@ -/* tslint:disable max-line-length */ import { getTestBed, TestBed } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { map, take } from 'rxjs/operators'; import { TextSubmissionService } from 'app/exercises/text/participate/text-submission.service'; -import { ITextSubmission, TextSubmission } from 'app/shared/model/text-submission.model'; +import { TextSubmission } from 'app/entities/text-submission.model'; describe('Service Tests', () => { describe('TextSubmission Service', () => { let injector: TestBed; let service: TextSubmissionService; let httpMock: HttpTestingController; - let elemDefault: ITextSubmission; + let elemDefault: TextSubmission; beforeEach(() => { TestBed.configureTestingModule({ imports: [HttpClientTestingModule], @@ -19,7 +18,7 @@ describe('Service Tests', () => { service = injector.get(TextSubmissionService); httpMock = injector.get(HttpTestingController); - elemDefault = new TextSubmission(0, 'AAAAAAA'); + elemDefault = new TextSubmission(); }); describe('Service methods', async () => { From 4f30f8a182294ecdfa4dfeb7ddc071c580d9b436 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Thu, 23 Apr 2020 17:34:14 +0200 Subject: [PATCH 077/152] Delete outdated test suites --- .../metrics/metrics-modal.component.spec.ts | 85 --------------- ...management-delete-dialog.component.spec.ts | 54 --------- .../user-management-dialog.component.spec.ts | 103 ------------------ .../course-delete-dialog.component.spec.ts | 52 --------- .../course/course-dialog.component.spec.ts | 79 -------------- ...e-upload-exercise-dialog.component.spec.ts | 79 -------------- ...submission-delete-dialog.component.spec.ts | 52 --------- ...upload-submission-detail.component.spec.ts | 40 ------- ...upload-submission-dialog.component.spec.ts | 79 -------------- ...upload-submission-update.component.spec.ts | 60 ---------- ...g-exercise-delete-dialog.component.spec.ts | 52 --------- ...modeling-exercise-dialog.component.spec.ts | 80 -------------- ...submission-delete-dialog.component.spec.ts | 52 --------- ...deling-submission-detail.component.spec.ts | 40 ------- ...deling-submission-dialog.component.spec.ts | 79 -------------- ...deling-submission-update.component.spec.ts | 60 ---------- ...ticipation-delete-dialog.component.spec.ts | 52 --------- .../participation-detail.component.spec.ts | 40 ------- .../participation-update.component.spec.ts | 60 ---------- ...g-exercise-delete-dialog.component.spec.ts | 52 --------- ...submission-delete-dialog.component.spec.ts | 52 --------- ...amming-submission-detail.component.spec.ts | 40 ------- ...amming-submission-dialog.component.spec.ts | 79 -------------- ...amming-submission-update.component.spec.ts | 60 ---------- .../programming-submission.component.spec.ts | 51 --------- ...z-exercise-delete-dialog.component.spec.ts | 52 --------- .../quiz-exercise-update.component.spec.ts | 60 ---------- ...submission-delete-dialog.component.spec.ts | 52 --------- .../quiz-submission-dialog.component.spec.ts | 79 -------------- .../quiz-submission-update.component.spec.ts | 60 ---------- .../quiz-submission.component.spec.ts | 51 --------- .../quiz-submission.service.spec.ts | 102 ----------------- .../result/result-dialog.component.spec.ts | 81 -------------- ...t-exercise-delete-dialog.component.spec.ts | 52 --------- .../text-exercise-dialog.component.spec.ts | 79 -------------- ...submission-delete-dialog.component.spec.ts | 52 --------- .../text-submission-detail.component.spec.ts | 40 ------- .../text-submission-dialog.component.spec.ts | 79 -------------- .../text-submission-update.component.spec.ts | 60 ---------- .../text-submission.component.spec.ts | 51 --------- 40 files changed, 2482 deletions(-) delete mode 100644 src/test/javascript/spec/app/admin/metrics/metrics-modal.component.spec.ts delete mode 100644 src/test/javascript/spec/app/admin/user-management/user-management-delete-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/admin/user-management/user-management-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/course/course-delete-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/course/course-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission-delete-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission-detail.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission-update.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise-delete-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/modeling-submission/modeling-submission-delete-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/modeling-submission/modeling-submission-detail.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/modeling-submission/modeling-submission-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/modeling-submission/modeling-submission-update.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/participation/participation-delete-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/participation/participation-detail.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/participation/participation-update.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/programming-exercise/programming-exercise-delete-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/programming-submission/programming-submission-delete-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/programming-submission/programming-submission-detail.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/programming-submission/programming-submission-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/programming-submission/programming-submission-update.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/programming-submission/programming-submission.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise-delete-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise-update.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/quiz-submission/quiz-submission-delete-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/quiz-submission/quiz-submission-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/quiz-submission/quiz-submission-update.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/quiz-submission/quiz-submission.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/quiz-submission/quiz-submission.service.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/result/result-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/text-exercise/text-exercise-delete-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/text-exercise/text-exercise-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/text-submission/text-submission-delete-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/text-submission/text-submission-detail.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/text-submission/text-submission-dialog.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/text-submission/text-submission-update.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/text-submission/text-submission.component.spec.ts diff --git a/src/test/javascript/spec/app/admin/metrics/metrics-modal.component.spec.ts b/src/test/javascript/spec/app/admin/metrics/metrics-modal.component.spec.ts deleted file mode 100644 index 24d8faf5c7ec..000000000000 --- a/src/test/javascript/spec/app/admin/metrics/metrics-modal.component.spec.ts +++ /dev/null @@ -1,85 +0,0 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { ArtemisTestModule } from '../../../test.module'; -import { JhiMetricsMonitoringModalComponent } from 'app/admin/metrics/metrics-modal.component'; -import { JhiMetricsService } from 'app/admin/metrics/metrics.service'; - -describe('Component Tests', () => { - describe('JhiMetricsMonitoringModalComponent', () => { - let comp: JhiMetricsMonitoringModalComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [JhiMetricsMonitoringModalComponent], - }) - .overrideTemplate(JhiMetricsMonitoringModalComponent, '') - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(JhiMetricsMonitoringModalComponent); - comp = fixture.componentInstance; - fixture.debugElement.injector.get(JhiMetricsService); - }); - - describe('ngOnInit', () => { - it('should count the numbers of each thread type', () => { - comp.threadDump = [ - { name: 'test1', threadState: 'RUNNABLE' }, - { name: 'test2', threadState: 'WAITING' }, - { name: 'test3', threadState: 'TIMED_WAITING' }, - { name: 'test4', threadState: 'BLOCKED' }, - { name: 'test5', threadState: 'BLOCKED' }, - { name: 'test5', threadState: 'NONE' }, - ]; - fixture.detectChanges(); - - expect(comp.threadDumpRunnable).toBe(1); - expect(comp.threadDumpWaiting).toBe(1); - expect(comp.threadDumpTimedWaiting).toBe(1); - expect(comp.threadDumpBlocked).toBe(2); - expect(comp.threadDumpAll).toBe(5); - }); - - it('should return badge-info for WAITING', () => { - expect(comp.getBadgeClass('WAITING')).toBe('badge-info'); - }); - - it('should return badge-warning for TIMED_WAITING', () => { - expect(comp.getBadgeClass('TIMED_WAITING')).toBe('badge-warning'); - }); - - it('should return badge-danger for BLOCKED', () => { - expect(comp.getBadgeClass('BLOCKED')).toBe('badge-danger'); - }); - - it('should return undefined for anything else', () => { - expect(comp.getBadgeClass('')).toBe(undefined); - }); - }); - - describe('getBadgeClass', () => { - it('should return badge-success for RUNNABLE', () => { - expect(comp.getBadgeClass('RUNNABLE')).toBe('badge-success'); - }); - - it('should return badge-info for WAITING', () => { - expect(comp.getBadgeClass('WAITING')).toBe('badge-info'); - }); - - it('should return badge-warning for TIMED_WAITING', () => { - expect(comp.getBadgeClass('TIMED_WAITING')).toBe('badge-warning'); - }); - - it('should return badge-danger for BLOCKED', () => { - expect(comp.getBadgeClass('BLOCKED')).toBe('badge-danger'); - }); - - it('should return undefined for anything else', () => { - expect(comp.getBadgeClass('')).toBe(undefined); - }); - }); - }); -}); diff --git a/src/test/javascript/spec/app/admin/user-management/user-management-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/admin/user-management/user-management-delete-dialog.component.spec.ts deleted file mode 100644 index 61aa9e27b53a..000000000000 --- a/src/test/javascript/spec/app/admin/user-management/user-management-delete-dialog.component.spec.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { async, ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { of } from 'rxjs'; -import { JhiEventManager } from 'ng-jhipster'; - -import { ArtemisTestModule } from '../../../test.module'; -import { UserManagementDeleteDialogComponent } from 'app/admin/user-management/user-management-delete-dialog.component'; -import { UserService } from 'app/core/user/user.service'; - -describe('Component Tests', () => { - describe('User Management Delete Component', () => { - let comp: UserManagementDeleteDialogComponent; - let fixture: ComponentFixture; - let service: UserService; - let mockEventManager: any; - let mockActiveModal: any; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [UserManagementDeleteDialogComponent], - }) - .overrideTemplate(UserManagementDeleteDialogComponent, '') - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(UserManagementDeleteDialogComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(UserService); - mockEventManager = fixture.debugElement.injector.get(JhiEventManager); - mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); - }); - - describe('confirmDelete', () => { - it('Should call delete service on confirmDelete', inject( - [], - fakeAsync(() => { - // GIVEN - spyOn(service, 'delete').and.returnValue(of({})); - - // WHEN - comp.confirmDelete('user'); - tick(); - - // THEN - expect(service.delete).toHaveBeenCalledWith('user'); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); - }), - )); - }); - }); -}); diff --git a/src/test/javascript/spec/app/admin/user-management/user-management-dialog.component.spec.ts b/src/test/javascript/spec/app/admin/user-management/user-management-dialog.component.spec.ts deleted file mode 100644 index bd49d4264eb3..000000000000 --- a/src/test/javascript/spec/app/admin/user-management/user-management-dialog.component.spec.ts +++ /dev/null @@ -1,103 +0,0 @@ -import { async, ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; -import { HttpResponse } from '@angular/common/http'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { Observable } from 'rxjs/Observable'; -import { JhiEventManager } from 'ng-jhipster'; - -import { ArtemisTestModule } from '../../../test.module'; -import { UserMgmtDialogComponent } from '../../../../../../main/webapp/app/admin/user-management/user-management-dialog.component'; -import { JhiLanguageHelper, User, UserService } from '../../../../../../main/webapp/app/shared'; - -describe('Component Tests', () => { - describe('User Management Dialog Component', () => { - let comp: UserMgmtDialogComponent; - let fixture: ComponentFixture; - let service: UserService; - let mockEventManager: any; - let mockActiveModal: any; - let mockLanguageHelper: any; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [UserMgmtDialogComponent], - providers: [UserService], - }) - .overrideTemplate(UserMgmtDialogComponent, '') - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(UserMgmtDialogComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(UserService); - mockEventManager = fixture.debugElement.injector.get(JhiEventManager); - mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); - mockLanguageHelper = fixture.debugElement.injector.get(JhiLanguageHelper); - }); - - describe('OnInit', () => { - it('Should load authorities and language on init', inject( - [], - fakeAsync(() => { - // GIVEN - spyOn(service, 'authorities').and.returnValue(Observable.of(['USER'])); - - // WHEN - comp.ngOnInit(); - - // THEN - expect(service.authorities).toHaveBeenCalled(); - expect(comp.authorities).toEqual(['USER']); - expect(mockLanguageHelper.getAllSpy).toHaveBeenCalled(); - }), - )); - }); - - describe('save', () => { - it('Should call update service on save for existing user', inject( - [], - fakeAsync(() => { - // GIVEN - const entity = new User(123); - spyOn(service, 'update').and.returnValue( - Observable.of( - new HttpResponse({ - body: entity, - }), - ), - ); - comp.user = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.update).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - expect(mockEventManager.broadcastSpy).toHaveBeenCalledWith({ name: 'userListModification', content: 'OK' }); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - }), - )); - - it('Should call create service on save for new user', inject( - [], - fakeAsync(() => { - // GIVEN - const entity = new User(); - spyOn(service, 'create').and.returnValue(Observable.of(new HttpResponse({ body: entity }))); - comp.user = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.create).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - expect(mockEventManager.broadcastSpy).toHaveBeenCalledWith({ name: 'userListModification', content: 'OK' }); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - }), - )); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/course/course-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/course/course-delete-dialog.component.spec.ts deleted file mode 100644 index 6bc78bd911d6..000000000000 --- a/src/test/javascript/spec/app/entities/course/course-delete-dialog.component.spec.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { of } from 'rxjs'; -import { JhiEventManager } from 'ng-jhipster'; - -import { ArtemisTestModule } from '../../../test.module'; -import { CourseDeleteDialogComponent } from 'app/entities/manage/course-delete-dialog.component'; -import { CourseService } from 'app/course/manage/course.service'; - -describe('Component Tests', () => { - describe('Course Management Delete Component', () => { - let comp: CourseDeleteDialogComponent; - let fixture: ComponentFixture; - let service: CourseService; - let mockEventManager: any; - let mockActiveModal: any; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [CourseDeleteDialogComponent], - }) - .overrideTemplate(CourseDeleteDialogComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(CourseDeleteDialogComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(CourseService); - mockEventManager = fixture.debugElement.injector.get(JhiEventManager); - mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); - }); - - describe('confirmDelete', () => { - it('Should call delete service on confirmDelete', inject( - [], - fakeAsync(() => { - // GIVEN - spyOn(service, 'delete').and.returnValue(of({})); - - // WHEN - comp.confirmDelete(123); - tick(); - - // THEN - expect(service.delete).toHaveBeenCalledWith(123); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); - }), - )); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/course/course-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/course/course-dialog.component.spec.ts deleted file mode 100644 index b3feb9d9c304..000000000000 --- a/src/test/javascript/spec/app/entities/course/course-dialog.component.spec.ts +++ /dev/null @@ -1,79 +0,0 @@ -/* tslint:disable max-line-length */ -import { async, ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; -import { HttpResponse } from '@angular/common/http'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { Observable } from 'rxjs/Observable'; -import { JhiEventManager } from 'ng-jhipster'; - -import { ArtemisTestModule } from '../../../test.module'; -import { CourseDialogComponent } from '../../../../../../main/webapp/app/entities/manage/course-dialog.component'; -import { CourseService } from '../../../../../../main/webapp/app/entities/manage/course.service'; -import { Course } from 'app/entities/course.model'; - -describe('Component Tests', () => { - describe('Course Management Dialog Component', () => { - let comp: CourseDialogComponent; - let fixture: ComponentFixture; - let service: CourseService; - let mockEventManager: any; - let mockActiveModal: any; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [CourseDialogComponent], - providers: [CourseService], - }) - .overrideTemplate(CourseDialogComponent, '') - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(CourseDialogComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(CourseService); - mockEventManager = fixture.debugElement.injector.get(JhiEventManager); - mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); - }); - - describe('save', () => { - it('Should call update service on save for existing entity', inject( - [], - fakeAsync(() => { - // GIVEN - const entity = new Course(123); - spyOn(service, 'update').and.returnValue(Observable.of(new HttpResponse({ body: entity }))); - comp.course = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.update).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - expect(mockEventManager.broadcastSpy).toHaveBeenCalledWith({ name: 'courseListModification', content: 'OK' }); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - }), - )); - - it('Should call create service on save for new entity', inject( - [], - fakeAsync(() => { - // GIVEN - const entity = new Course(); - spyOn(service, 'create').and.returnValue(Observable.of(new HttpResponse({ body: entity }))); - comp.course = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.create).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - expect(mockEventManager.broadcastSpy).toHaveBeenCalledWith({ name: 'courseListModification', content: 'OK' }); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - }), - )); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise-dialog.component.spec.ts deleted file mode 100644 index cd20d11e44d3..000000000000 --- a/src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise-dialog.component.spec.ts +++ /dev/null @@ -1,79 +0,0 @@ -/* tslint:disable max-line-length */ -import { async, ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; -import { HttpResponse } from '@angular/common/http'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { Observable } from 'rxjs/Observable'; -import { JhiEventManager } from 'ng-jhipster'; - -import { ArtemisTestModule } from '../../../test.module'; -import { FileUploadExerciseDialogComponent } from '../../../../../../main/webapp/app/exercises/file-upload/manage/file-upload-exercise/file-upload-exercise-dialog.component'; -import { FileUploadExerciseService } from 'app/exercises/file-upload/manage/file-upload-exercise.service'; -import { FileUploadExercise } from 'app/entities/file-upload-exercise.model'; - -describe('Component Tests', () => { - describe('FileUploadExercise Management Dialog Component', () => { - let comp: FileUploadExerciseDialogComponent; - let fixture: ComponentFixture; - let service: FileUploadExerciseService; - let mockEventManager: any; - let mockActiveModal: any; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [FileUploadExerciseDialogComponent], - providers: [FileUploadExerciseService], - }) - .overrideTemplate(FileUploadExerciseDialogComponent, '') - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(FileUploadExerciseDialogComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(FileUploadExerciseService); - mockEventManager = fixture.debugElement.injector.get(JhiEventManager); - mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); - }); - - describe('save', () => { - it('Should call update service on save for existing entity', inject( - [], - fakeAsync(() => { - // GIVEN - const entity = new FileUploadExercise(123); - spyOn(service, 'update').and.returnValue(Observable.of(new HttpResponse({ body: entity }))); - comp.fileUploadExercise = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.update).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - expect(mockEventManager.broadcastSpy).toHaveBeenCalledWith({ name: 'fileUploadExerciseListModification', content: 'OK' }); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - }), - )); - - it('Should call create service on save for new entity', inject( - [], - fakeAsync(() => { - // GIVEN - const entity = new FileUploadExercise(); - spyOn(service, 'create').and.returnValue(Observable.of(new HttpResponse({ body: entity }))); - comp.fileUploadExercise = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.create).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - expect(mockEventManager.broadcastSpy).toHaveBeenCalledWith({ name: 'fileUploadExerciseListModification', content: 'OK' }); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - }), - )); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission-delete-dialog.component.spec.ts deleted file mode 100644 index a96d79a80d0a..000000000000 --- a/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission-delete-dialog.component.spec.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { of } from 'rxjs'; -import { JhiEventManager } from 'ng-jhipster'; - -import { ArTeMiSTestModule } from '../../../test.module'; -import { FileUploadSubmissionDeleteDialogComponent } from 'app/exercises/file-upload-submission/file-upload-submission-delete-dialog.component'; -import { FileUploadSubmissionService } from 'app/exercises/file-upload/participate/file-upload-submission.service'; - -describe('Component Tests', () => { - describe('FileUploadSubmission Management Delete Component', () => { - let comp: FileUploadSubmissionDeleteDialogComponent; - let fixture: ComponentFixture; - let service: FileUploadSubmissionService; - let mockEventManager: any; - let mockActiveModal: any; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArTeMiSTestModule], - declarations: [FileUploadSubmissionDeleteDialogComponent], - }) - .overrideTemplate(FileUploadSubmissionDeleteDialogComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(FileUploadSubmissionDeleteDialogComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(FileUploadSubmissionService); - mockEventManager = fixture.debugElement.injector.get(JhiEventManager); - mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); - }); - - describe('confirmDelete', () => { - it('Should call delete service on confirmDelete', inject( - [], - fakeAsync(() => { - // GIVEN - spyOn(service, 'delete').and.returnValue(of({})); - - // WHEN - comp.confirmDelete(123); - tick(); - - // THEN - expect(service.delete).toHaveBeenCalledWith(123); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); - }), - )); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission-detail.component.spec.ts b/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission-detail.component.spec.ts deleted file mode 100644 index 42932d000fc5..000000000000 --- a/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission-detail.component.spec.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { ActivatedRoute } from '@angular/router'; -import { of } from 'rxjs'; - -import { ArTeMiSTestModule } from '../../../test.module'; -import { FileUploadSubmissionDetailComponent } from 'app/exercises/file-upload-submission/file-upload-submission-detail.component'; -import { FileUploadSubmission } from 'app/shared/model/file-upload-submission.model'; - -describe('Component Tests', () => { - describe('FileUploadSubmission Management Detail Component', () => { - let comp: FileUploadSubmissionDetailComponent; - let fixture: ComponentFixture; - const route = ({ data: of({ fileUploadSubmission: new FileUploadSubmission(123) }) } as any) as ActivatedRoute; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArTeMiSTestModule], - declarations: [FileUploadSubmissionDetailComponent], - providers: [{ provide: ActivatedRoute, useValue: route }], - }) - .overrideTemplate(FileUploadSubmissionDetailComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(FileUploadSubmissionDetailComponent); - comp = fixture.componentInstance; - }); - - describe('OnInit', () => { - it('Should call load all on init', () => { - // GIVEN - - // WHEN - comp.ngOnInit(); - - // THEN - expect(comp.fileUploadSubmission).toEqual(jasmine.objectContaining({ id: 123 })); - }); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission-dialog.component.spec.ts deleted file mode 100644 index 12ee8b7e28fe..000000000000 --- a/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission-dialog.component.spec.ts +++ /dev/null @@ -1,79 +0,0 @@ -/* tslint:disable max-line-length */ -import { async, ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; -import { HttpResponse } from '@angular/common/http'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { Observable } from 'rxjs/Observable'; -import { JhiEventManager } from 'ng-jhipster'; - -import { ArtemisTestModule } from '../../../test.module'; -import { FileUploadSubmissionDialogComponent } from '../../../../../../main/webapp/app/exercises/file-upload-submission/file-upload-submission-dialog.component'; -import { FileUploadSubmissionService } from 'app/exercises/file-upload/participate/file-upload-submission.service'; -import { FileUploadSubmission } from 'app/entities/file-upload-submission.model'; - -describe('Component Tests', () => { - describe('FileUploadSubmission Management Dialog Component', () => { - let comp: FileUploadSubmissionDialogComponent; - let fixture: ComponentFixture; - let service: FileUploadSubmissionService; - let mockEventManager: any; - let mockActiveModal: any; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [FileUploadSubmissionDialogComponent], - providers: [FileUploadSubmissionService], - }) - .overrideTemplate(FileUploadSubmissionDialogComponent, '') - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(FileUploadSubmissionDialogComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(FileUploadSubmissionService); - mockEventManager = fixture.debugElement.injector.get(JhiEventManager); - mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); - }); - - describe('save', () => { - it('Should call update service on save for existing entity', inject( - [], - fakeAsync(() => { - // GIVEN - const entity = new FileUploadSubmission(123); - spyOn(service, 'update').and.returnValue(Observable.of(new HttpResponse({ body: entity }))); - comp.fileUploadSubmission = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.update).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - expect(mockEventManager.broadcastSpy).toHaveBeenCalledWith({ name: 'fileUploadSubmissionListModification', content: 'OK' }); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - }), - )); - - it('Should call create service on save for new entity', inject( - [], - fakeAsync(() => { - // GIVEN - const entity = new FileUploadSubmission(); - spyOn(service, 'create').and.returnValue(Observable.of(new HttpResponse({ body: entity }))); - comp.fileUploadSubmission = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.create).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - expect(mockEventManager.broadcastSpy).toHaveBeenCalledWith({ name: 'fileUploadSubmissionListModification', content: 'OK' }); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - }), - )); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission-update.component.spec.ts b/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission-update.component.spec.ts deleted file mode 100644 index 2edb54c85048..000000000000 --- a/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission-update.component.spec.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; -import { HttpResponse } from '@angular/common/http'; -import { of } from 'rxjs'; - -import { ArTeMiSTestModule } from '../../../test.module'; -import { FileUploadSubmissionUpdateComponent } from 'app/exercises/file-upload-submission/file-upload-submission-update.component'; -import { FileUploadSubmissionService } from 'app/exercises/file-upload/participate/file-upload-submission.service'; -import { FileUploadSubmission } from 'app/shared/model/file-upload-submission.model'; - -describe('Component Tests', () => { - describe('FileUploadSubmission Management Update Component', () => { - let comp: FileUploadSubmissionUpdateComponent; - let fixture: ComponentFixture; - let service: FileUploadSubmissionService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArTeMiSTestModule], - declarations: [FileUploadSubmissionUpdateComponent], - }) - .overrideTemplate(FileUploadSubmissionUpdateComponent, '') - .compileComponents(); - - fixture = TestBed.createComponent(FileUploadSubmissionUpdateComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(FileUploadSubmissionService); - }); - - describe('save', () => { - it('Should call update service on save for existing entity', fakeAsync(() => { - // GIVEN - const entity = new FileUploadSubmission(123); - spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.fileUploadSubmission = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.update).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - })); - - it('Should call create service on save for new entity', fakeAsync(() => { - // GIVEN - const entity = new FileUploadSubmission(); - spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.fileUploadSubmission = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.create).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - })); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise-delete-dialog.component.spec.ts deleted file mode 100644 index c350676ee7d6..000000000000 --- a/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise-delete-dialog.component.spec.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { of } from 'rxjs'; -import { JhiEventManager } from 'ng-jhipster'; - -import { ArtemisTestModule } from '../../../test.module'; -import { ModelingExerciseDeleteDialogComponent } from 'app/exercises/modeling/manage/modeling-exercise/modeling-exercise-delete-dialog.component'; -import { ModelingExerciseService } from 'app/exercises/modeling/manage/modeling-exercise.service'; - -describe('Component Tests', () => { - describe('ModelingExercise Management Delete Component', () => { - let comp: ModelingExerciseDeleteDialogComponent; - let fixture: ComponentFixture; - let service: ModelingExerciseService; - let mockEventManager: any; - let mockActiveModal: any; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [ModelingExerciseDeleteDialogComponent], - }) - .overrideTemplate(ModelingExerciseDeleteDialogComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(ModelingExerciseDeleteDialogComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ModelingExerciseService); - mockEventManager = fixture.debugElement.injector.get(JhiEventManager); - mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); - }); - - describe('confirmDelete', () => { - it('Should call delete service on confirmDelete', inject( - [], - fakeAsync(() => { - // GIVEN - spyOn(service, 'delete').and.returnValue(of({})); - - // WHEN - comp.confirmDelete(123); - tick(); - - // THEN - expect(service.delete).toHaveBeenCalledWith(123); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); - }), - )); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise-dialog.component.spec.ts deleted file mode 100644 index b63e2c15c632..000000000000 --- a/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise-dialog.component.spec.ts +++ /dev/null @@ -1,80 +0,0 @@ -/* tslint:disable max-line-length */ -import { async, ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; -import { HttpResponse } from '@angular/common/http'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { Observable } from 'rxjs/Observable'; -import { JhiEventManager } from 'ng-jhipster'; - -import { ArtemisTestModule } from '../../../test.module'; -import { ModelingExerciseDialogComponent } from '../../../../../../main/webapp/app/exercises/modeling/manage/modeling-exercise/modeling-exercise-dialog.component'; -import { ModelingExerciseService } from 'app/exercises/modeling/manage/modeling-exercise.service'; -import { ModelingExercise } from 'app/entities/modeling-exercise.model'; -import { UMLDiagramType } from '@ls1intum/apollon'; - -describe('Component Tests', () => { - describe('ModelingExercise Management Dialog Component', () => { - let comp: ModelingExerciseDialogComponent; - let fixture: ComponentFixture; - let service: ModelingExerciseService; - let mockEventManager: any; - let mockActiveModal: any; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [ModelingExerciseDialogComponent], - providers: [ModelingExerciseService], - }) - .overrideTemplate(ModelingExerciseDialogComponent, '') - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(ModelingExerciseDialogComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ModelingExerciseService); - mockEventManager = fixture.debugElement.injector.get(JhiEventManager); - mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); - }); - - describe('save', () => { - it('Should call update service on save for existing entity', inject( - [], - fakeAsync(() => { - // GIVEN - const entity = new ModelingExercise(UMLDiagramType.ClassDiagram); - spyOn(service, 'update').and.returnValue(Observable.of(new HttpResponse({ body: entity }))); - comp.modelingExercise = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.update).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - expect(mockEventManager.broadcastSpy).toHaveBeenCalledWith({ name: 'modelingExerciseListModification', content: 'OK' }); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - }), - )); - - it('Should call create service on save for new entity', inject( - [], - fakeAsync(() => { - // GIVEN - const entity = new ModelingExercise(UMLDiagramType.ClassDiagram); - spyOn(service, 'create').and.returnValue(Observable.of(new HttpResponse({ body: entity }))); - comp.modelingExercise = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.create).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - expect(mockEventManager.broadcastSpy).toHaveBeenCalledWith({ name: 'modelingExerciseListModification', content: 'OK' }); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - }), - )); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/modeling-submission/modeling-submission-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/modeling-submission/modeling-submission-delete-dialog.component.spec.ts deleted file mode 100644 index 93325c7eb7a9..000000000000 --- a/src/test/javascript/spec/app/entities/modeling-submission/modeling-submission-delete-dialog.component.spec.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { of } from 'rxjs'; -import { JhiEventManager } from 'ng-jhipster'; - -import { ArtemisTestModule } from '../../../test.module'; -import { ModelingSubmissionDeleteDialogComponent } from 'app/exercises/modeling-submission/modeling-submission-delete-dialog.component'; -import { ModelingSubmissionService } from 'app/exercises/modeling/participate/modeling-submission.service'; - -describe('Component Tests', () => { - describe('ModelingSubmission Management Delete Component', () => { - let comp: ModelingSubmissionDeleteDialogComponent; - let fixture: ComponentFixture; - let service: ModelingSubmissionService; - let mockEventManager: any; - let mockActiveModal: any; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [ModelingSubmissionDeleteDialogComponent], - }) - .overrideTemplate(ModelingSubmissionDeleteDialogComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(ModelingSubmissionDeleteDialogComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ModelingSubmissionService); - mockEventManager = fixture.debugElement.injector.get(JhiEventManager); - mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); - }); - - describe('confirmDelete', () => { - it('Should call delete service on confirmDelete', inject( - [], - fakeAsync(() => { - // GIVEN - spyOn(service, 'delete').and.returnValue(of({})); - - // WHEN - comp.confirmDelete(123); - tick(); - - // THEN - expect(service.delete).toHaveBeenCalledWith(123); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); - }), - )); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/modeling-submission/modeling-submission-detail.component.spec.ts b/src/test/javascript/spec/app/entities/modeling-submission/modeling-submission-detail.component.spec.ts deleted file mode 100644 index fdf981d844e3..000000000000 --- a/src/test/javascript/spec/app/entities/modeling-submission/modeling-submission-detail.component.spec.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { ActivatedRoute } from '@angular/router'; -import { of } from 'rxjs'; - -import { ArtemisTestModule } from '../../../test.module'; -import { ModelingSubmissionDetailComponent } from 'app/exercises/modeling-submission/modeling-submission-detail.component'; -import { ModelingSubmission } from 'app/shared/model/modeling-submission.model'; - -describe('Component Tests', () => { - describe('ModelingSubmission Management Detail Component', () => { - let comp: ModelingSubmissionDetailComponent; - let fixture: ComponentFixture; - const route = ({ data: of({ modelingSubmission: new ModelingSubmission(123) }) } as any) as ActivatedRoute; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [ModelingSubmissionDetailComponent], - providers: [{ provide: ActivatedRoute, useValue: route }], - }) - .overrideTemplate(ModelingSubmissionDetailComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(ModelingSubmissionDetailComponent); - comp = fixture.componentInstance; - }); - - describe('OnInit', () => { - it('Should call load all on init', () => { - // GIVEN - - // WHEN - comp.ngOnInit(); - - // THEN - expect(comp.modelingSubmission).toEqual(jasmine.objectContaining({ id: 123 })); - }); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/modeling-submission/modeling-submission-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/modeling-submission/modeling-submission-dialog.component.spec.ts deleted file mode 100644 index 69abf45849e9..000000000000 --- a/src/test/javascript/spec/app/entities/modeling-submission/modeling-submission-dialog.component.spec.ts +++ /dev/null @@ -1,79 +0,0 @@ -/* tslint:disable max-line-length */ -import { async, ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; -import { HttpResponse } from '@angular/common/http'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { Observable } from 'rxjs/Observable'; -import { JhiEventManager } from 'ng-jhipster'; - -import { ArtemisTestModule } from '../../../test.module'; -import { ModelingSubmissionDialogComponent } from '../../../../../../main/webapp/app/exercises/modeling-submission/modeling-submission-dialog.component'; -import { ModelingSubmissionService } from 'app/exercises/modeling/participate/modeling-submission.service'; -import { ModelingSubmission } from 'app/entities/modeling-submission.model'; - -describe('Component Tests', () => { - describe('ModelingSubmission Management Dialog Component', () => { - let comp: ModelingSubmissionDialogComponent; - let fixture: ComponentFixture; - let service: ModelingSubmissionService; - let mockEventManager: any; - let mockActiveModal: any; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [ModelingSubmissionDialogComponent], - providers: [ModelingSubmissionService], - }) - .overrideTemplate(ModelingSubmissionDialogComponent, '') - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(ModelingSubmissionDialogComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ModelingSubmissionService); - mockEventManager = fixture.debugElement.injector.get(JhiEventManager); - mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); - }); - - describe('save', () => { - it('Should call update service on save for existing entity', inject( - [], - fakeAsync(() => { - // GIVEN - const entity = new ModelingSubmission(123); - spyOn(service, 'update').and.returnValue(Observable.of(new HttpResponse({ body: entity }))); - comp.modelingSubmission = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.update).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - expect(mockEventManager.broadcastSpy).toHaveBeenCalledWith({ name: 'modelingSubmissionListModification', content: 'OK' }); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - }), - )); - - it('Should call create service on save for new entity', inject( - [], - fakeAsync(() => { - // GIVEN - const entity = new ModelingSubmission(); - spyOn(service, 'create').and.returnValue(Observable.of(new HttpResponse({ body: entity }))); - comp.modelingSubmission = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.create).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - expect(mockEventManager.broadcastSpy).toHaveBeenCalledWith({ name: 'modelingSubmissionListModification', content: 'OK' }); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - }), - )); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/modeling-submission/modeling-submission-update.component.spec.ts b/src/test/javascript/spec/app/entities/modeling-submission/modeling-submission-update.component.spec.ts deleted file mode 100644 index 4f5ff308343c..000000000000 --- a/src/test/javascript/spec/app/entities/modeling-submission/modeling-submission-update.component.spec.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; -import { HttpResponse } from '@angular/common/http'; -import { of } from 'rxjs'; - -import { ArtemisTestModule } from '../../../test.module'; -import { ModelingSubmissionUpdateComponent } from 'app/exercises/modeling-submission/modeling-submission-update.component'; -import { ModelingSubmissionService } from 'app/exercises/modeling/participate/modeling-submission.service'; -import { ModelingSubmission } from 'app/shared/model/modeling-submission.model'; - -describe('Component Tests', () => { - describe('ModelingSubmission Management Update Component', () => { - let comp: ModelingSubmissionUpdateComponent; - let fixture: ComponentFixture; - let service: ModelingSubmissionService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [ModelingSubmissionUpdateComponent], - }) - .overrideTemplate(ModelingSubmissionUpdateComponent, '') - .compileComponents(); - - fixture = TestBed.createComponent(ModelingSubmissionUpdateComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ModelingSubmissionService); - }); - - describe('save', () => { - it('Should call update service on save for existing entity', fakeAsync(() => { - // GIVEN - const entity = new ModelingSubmission(123); - spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.modelingSubmission = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.update).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - })); - - it('Should call create service on save for new entity', fakeAsync(() => { - // GIVEN - const entity = new ModelingSubmission(); - spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.modelingSubmission = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.create).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - })); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/participation/participation-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/participation/participation-delete-dialog.component.spec.ts deleted file mode 100644 index 3ba8fbb0f737..000000000000 --- a/src/test/javascript/spec/app/entities/participation/participation-delete-dialog.component.spec.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { of } from 'rxjs'; -import { JhiEventManager } from 'ng-jhipster'; - -import { ArtemisTestModule } from '../../../test.module'; -import { ParticipationDeleteDialogComponent } from 'app/exercises/shared/participation/participation-delete-dialog.component'; -import { ParticipationService } from 'app/exercises/shared/participation/participation.service'; - -describe('Component Tests', () => { - describe('Participation Management Delete Component', () => { - let comp: ParticipationDeleteDialogComponent; - let fixture: ComponentFixture; - let service: ParticipationService; - let mockEventManager: any; - let mockActiveModal: any; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [ParticipationDeleteDialogComponent], - }) - .overrideTemplate(ParticipationDeleteDialogComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(ParticipationDeleteDialogComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ParticipationService); - mockEventManager = fixture.debugElement.injector.get(JhiEventManager); - mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); - }); - - describe('confirmDelete', () => { - it('Should call delete service on confirmDelete', inject( - [], - fakeAsync(() => { - // GIVEN - spyOn(service, 'delete').and.returnValue(of({})); - - // WHEN - comp.confirmDelete(123); - tick(); - - // THEN - expect(service.delete).toHaveBeenCalledWith(123); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); - }), - )); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/participation/participation-detail.component.spec.ts b/src/test/javascript/spec/app/entities/participation/participation-detail.component.spec.ts deleted file mode 100644 index 4aab6ab7ed2c..000000000000 --- a/src/test/javascript/spec/app/entities/participation/participation-detail.component.spec.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { ActivatedRoute } from '@angular/router'; -import { of } from 'rxjs'; - -import { ArtemisTestModule } from '../../../test.module'; -import { ParticipationDetailComponent } from 'app/exercises/shared/participation/participation-detail.component'; -import { Participation } from 'app/shared/model/participation.model'; - -describe('Component Tests', () => { - describe('Participation Management Detail Component', () => { - let comp: ParticipationDetailComponent; - let fixture: ComponentFixture; - const route = ({ data: of({ participation: new Participation(123) }) } as any) as ActivatedRoute; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [ParticipationDetailComponent], - providers: [{ provide: ActivatedRoute, useValue: route }], - }) - .overrideTemplate(ParticipationDetailComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(ParticipationDetailComponent); - comp = fixture.componentInstance; - }); - - describe('OnInit', () => { - it('Should call load all on init', () => { - // GIVEN - - // WHEN - comp.ngOnInit(); - - // THEN - expect(comp.participation).toEqual(jasmine.objectContaining({ id: 123 })); - }); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/participation/participation-update.component.spec.ts b/src/test/javascript/spec/app/entities/participation/participation-update.component.spec.ts deleted file mode 100644 index 1fe2cce8d587..000000000000 --- a/src/test/javascript/spec/app/entities/participation/participation-update.component.spec.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; -import { HttpResponse } from '@angular/common/http'; -import { of } from 'rxjs'; - -import { ArtemisTestModule } from '../../../test.module'; -import { ParticipationUpdateComponent } from 'app/exercises/shared/participation/participation-update.component'; -import { ParticipationService } from 'app/exercises/shared/participation/participation.service'; -import { Participation } from 'app/shared/model/participation.model'; - -describe('Component Tests', () => { - describe('Participation Management Update Component', () => { - let comp: ParticipationUpdateComponent; - let fixture: ComponentFixture; - let service: ParticipationService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [ParticipationUpdateComponent], - }) - .overrideTemplate(ParticipationUpdateComponent, '') - .compileComponents(); - - fixture = TestBed.createComponent(ParticipationUpdateComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ParticipationService); - }); - - describe('save', () => { - it('Should call update service on save for existing entity', fakeAsync(() => { - // GIVEN - const entity = new Participation(123); - spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.participation = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.update).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - })); - - it('Should call create service on save for new entity', fakeAsync(() => { - // GIVEN - const entity = new Participation(); - spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.participation = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.create).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - })); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise-delete-dialog.component.spec.ts deleted file mode 100644 index 8f7403d23d7d..000000000000 --- a/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise-delete-dialog.component.spec.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { of } from 'rxjs'; -import { JhiEventManager } from 'ng-jhipster'; - -import { ArtemisTestModule } from '../../../test.module'; -import { ProgrammingExerciseDeleteDialogComponent } from 'app/entities/programming-exercise/programming-exercise-delete-dialog.component'; -import { ProgrammingExerciseService } from 'app/exercises/programming/manage/services/programming-exercise.service'; - -describe('Component Tests', () => { - describe('ProgrammingExercise Management Delete Component', () => { - let comp: ProgrammingExerciseDeleteDialogComponent; - let fixture: ComponentFixture; - let service: ProgrammingExerciseService; - let mockEventManager: any; - let mockActiveModal: any; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [ProgrammingExerciseDeleteDialogComponent], - }) - .overrideTemplate(ProgrammingExerciseDeleteDialogComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(ProgrammingExerciseDeleteDialogComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ProgrammingExerciseService); - mockEventManager = fixture.debugElement.injector.get(JhiEventManager); - mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); - }); - - describe('confirmDelete', () => { - it('Should call delete service on confirmDelete', inject( - [], - fakeAsync(() => { - // GIVEN - spyOn(service, 'delete').and.returnValue(of({})); - - // WHEN - comp.confirmDelete(123); - tick(); - - // THEN - expect(service.delete).toHaveBeenCalledWith(123); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); - }), - )); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/programming-submission/programming-submission-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/programming-submission/programming-submission-delete-dialog.component.spec.ts deleted file mode 100644 index f38dd9d272cf..000000000000 --- a/src/test/javascript/spec/app/entities/programming-submission/programming-submission-delete-dialog.component.spec.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { of } from 'rxjs'; -import { JhiEventManager } from 'ng-jhipster'; - -import { ArTeMiSTestModule } from '../../../test.module'; -import { ProgrammingSubmissionDeleteDialogComponent } from 'app/entities/programming-submission/programming-submission-delete-dialog.component'; -import { ProgrammingSubmissionService } from 'app/entities/programming-submission/programming-submission.service'; - -describe('Component Tests', () => { - describe('ProgrammingSubmission Management Delete Component', () => { - let comp: ProgrammingSubmissionDeleteDialogComponent; - let fixture: ComponentFixture; - let service: ProgrammingSubmissionService; - let mockEventManager: any; - let mockActiveModal: any; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArTeMiSTestModule], - declarations: [ProgrammingSubmissionDeleteDialogComponent], - }) - .overrideTemplate(ProgrammingSubmissionDeleteDialogComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(ProgrammingSubmissionDeleteDialogComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ProgrammingSubmissionService); - mockEventManager = fixture.debugElement.injector.get(JhiEventManager); - mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); - }); - - describe('confirmDelete', () => { - it('Should call delete service on confirmDelete', inject( - [], - fakeAsync(() => { - // GIVEN - spyOn(service, 'delete').and.returnValue(of({})); - - // WHEN - comp.confirmDelete(123); - tick(); - - // THEN - expect(service.delete).toHaveBeenCalledWith(123); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); - }), - )); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/programming-submission/programming-submission-detail.component.spec.ts b/src/test/javascript/spec/app/entities/programming-submission/programming-submission-detail.component.spec.ts deleted file mode 100644 index bd470baa90c3..000000000000 --- a/src/test/javascript/spec/app/entities/programming-submission/programming-submission-detail.component.spec.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { ActivatedRoute } from '@angular/router'; -import { of } from 'rxjs'; - -import { ArTeMiSTestModule } from '../../../test.module'; -import { ProgrammingSubmissionDetailComponent } from 'app/entities/programming-submission/programming-submission-detail.component'; -import { ProgrammingSubmission } from 'app/shared/model/programming-submission.model'; - -describe('Component Tests', () => { - describe('ProgrammingSubmission Management Detail Component', () => { - let comp: ProgrammingSubmissionDetailComponent; - let fixture: ComponentFixture; - const route = ({ data: of({ programmingSubmission: new ProgrammingSubmission(123) }) } as any) as ActivatedRoute; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArTeMiSTestModule], - declarations: [ProgrammingSubmissionDetailComponent], - providers: [{ provide: ActivatedRoute, useValue: route }], - }) - .overrideTemplate(ProgrammingSubmissionDetailComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(ProgrammingSubmissionDetailComponent); - comp = fixture.componentInstance; - }); - - describe('OnInit', () => { - it('Should call load all on init', () => { - // GIVEN - - // WHEN - comp.ngOnInit(); - - // THEN - expect(comp.programmingSubmission).toEqual(jasmine.objectContaining({ id: 123 })); - }); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/programming-submission/programming-submission-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/programming-submission/programming-submission-dialog.component.spec.ts deleted file mode 100644 index 05fe8bccb122..000000000000 --- a/src/test/javascript/spec/app/entities/programming-submission/programming-submission-dialog.component.spec.ts +++ /dev/null @@ -1,79 +0,0 @@ -/* tslint:disable max-line-length */ -import { async, ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; -import { HttpResponse } from '@angular/common/http'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { Observable } from 'rxjs/Observable'; -import { JhiEventManager } from 'ng-jhipster'; - -import { ArtemisTestModule } from '../../../test.module'; -import { ProgrammingSubmissionDialogComponent } from '../../../../../../main/webapp/app/entities/programming-submission/programming-submission-dialog.component'; -import { ProgrammingSubmissionService } from '../../../../../../main/webapp/app/entities/programming-submission/programming-submission.service'; -import { ProgrammingSubmission } from 'app/entities/programming-submission.model'; - -describe('Component Tests', () => { - describe('ProgrammingSubmission Management Dialog Component', () => { - let comp: ProgrammingSubmissionDialogComponent; - let fixture: ComponentFixture; - let service: ProgrammingSubmissionService; - let mockEventManager: any; - let mockActiveModal: any; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [ProgrammingSubmissionDialogComponent], - providers: [ProgrammingSubmissionService], - }) - .overrideTemplate(ProgrammingSubmissionDialogComponent, '') - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(ProgrammingSubmissionDialogComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ProgrammingSubmissionService); - mockEventManager = fixture.debugElement.injector.get(JhiEventManager); - mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); - }); - - describe('save', () => { - it('Should call update service on save for existing entity', inject( - [], - fakeAsync(() => { - // GIVEN - const entity = new ProgrammingSubmission(123); - spyOn(service, 'update').and.returnValue(Observable.of(new HttpResponse({ body: entity }))); - comp.programmingSubmission = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.update).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - expect(mockEventManager.broadcastSpy).toHaveBeenCalledWith({ name: 'programmingSubmissionListModification', content: 'OK' }); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - }), - )); - - it('Should call create service on save for new entity', inject( - [], - fakeAsync(() => { - // GIVEN - const entity = new ProgrammingSubmission(); - spyOn(service, 'create').and.returnValue(Observable.of(new HttpResponse({ body: entity }))); - comp.programmingSubmission = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.create).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - expect(mockEventManager.broadcastSpy).toHaveBeenCalledWith({ name: 'programmingSubmissionListModification', content: 'OK' }); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - }), - )); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/programming-submission/programming-submission-update.component.spec.ts b/src/test/javascript/spec/app/entities/programming-submission/programming-submission-update.component.spec.ts deleted file mode 100644 index 89b539831eef..000000000000 --- a/src/test/javascript/spec/app/entities/programming-submission/programming-submission-update.component.spec.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; -import { HttpResponse } from '@angular/common/http'; -import { of } from 'rxjs'; - -import { ArTeMiSTestModule } from '../../../test.module'; -import { ProgrammingSubmissionUpdateComponent } from 'app/entities/programming-submission/programming-submission-update.component'; -import { ProgrammingSubmissionService } from 'app/entities/programming-submission/programming-submission.service'; -import { ProgrammingSubmission } from 'app/shared/model/programming-submission.model'; - -describe('Component Tests', () => { - describe('ProgrammingSubmission Management Update Component', () => { - let comp: ProgrammingSubmissionUpdateComponent; - let fixture: ComponentFixture; - let service: ProgrammingSubmissionService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArTeMiSTestModule], - declarations: [ProgrammingSubmissionUpdateComponent], - }) - .overrideTemplate(ProgrammingSubmissionUpdateComponent, '') - .compileComponents(); - - fixture = TestBed.createComponent(ProgrammingSubmissionUpdateComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ProgrammingSubmissionService); - }); - - describe('save', () => { - it('Should call update service on save for existing entity', fakeAsync(() => { - // GIVEN - const entity = new ProgrammingSubmission(123); - spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.programmingSubmission = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.update).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - })); - - it('Should call create service on save for new entity', fakeAsync(() => { - // GIVEN - const entity = new ProgrammingSubmission(); - spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.programmingSubmission = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.create).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - })); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/programming-submission/programming-submission.component.spec.ts b/src/test/javascript/spec/app/entities/programming-submission/programming-submission.component.spec.ts deleted file mode 100644 index b70e58b8e222..000000000000 --- a/src/test/javascript/spec/app/entities/programming-submission/programming-submission.component.spec.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { of } from 'rxjs'; -import { HttpHeaders, HttpResponse } from '@angular/common/http'; - -import { ArTeMiSTestModule } from '../../../test.module'; -import { ProgrammingSubmissionComponent } from 'app/entities/programming-submission/programming-submission.component'; -import { ProgrammingSubmissionService } from 'app/entities/programming-submission/programming-submission.service'; -import { ProgrammingSubmission } from 'app/shared/model/programming-submission.model'; - -describe('Component Tests', () => { - describe('ProgrammingSubmission Management Component', () => { - let comp: ProgrammingSubmissionComponent; - let fixture: ComponentFixture; - let service: ProgrammingSubmissionService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArTeMiSTestModule], - declarations: [ProgrammingSubmissionComponent], - providers: [], - }) - .overrideTemplate(ProgrammingSubmissionComponent, '') - .compileComponents(); - - fixture = TestBed.createComponent(ProgrammingSubmissionComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ProgrammingSubmissionService); - }); - - it('Should call load all on init', () => { - // GIVEN - const headers = new HttpHeaders().append('link', 'link;link'); - spyOn(service, 'query').and.returnValue( - of( - new HttpResponse({ - body: [new ProgrammingSubmission(123)], - headers, - }), - ), - ); - - // WHEN - comp.ngOnInit(); - - // THEN - expect(service.query).toHaveBeenCalled(); - expect(comp.programmingSubmissions[0]).toEqual(jasmine.objectContaining({ id: 123 })); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise-delete-dialog.component.spec.ts deleted file mode 100644 index 0dabc2604f78..000000000000 --- a/src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise-delete-dialog.component.spec.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { of } from 'rxjs'; -import { JhiEventManager } from 'ng-jhipster'; - -import { ArtemisTestModule } from '../../../test.module'; -import { QuizExerciseDeleteDialogComponent } from 'app/entities/quiz-exercise/quiz-exercise-delete-dialog.component'; -import { QuizExerciseService } from 'app/exercises/quiz/manage/quiz-exercise.service'; - -describe('Component Tests', () => { - describe('QuizExercise Management Delete Component', () => { - let comp: QuizExerciseDeleteDialogComponent; - let fixture: ComponentFixture; - let service: QuizExerciseService; - let mockEventManager: any; - let mockActiveModal: any; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [QuizExerciseDeleteDialogComponent], - }) - .overrideTemplate(QuizExerciseDeleteDialogComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(QuizExerciseDeleteDialogComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(QuizExerciseService); - mockEventManager = fixture.debugElement.injector.get(JhiEventManager); - mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); - }); - - describe('confirmDelete', () => { - it('Should call delete service on confirmDelete', inject( - [], - fakeAsync(() => { - // GIVEN - spyOn(service, 'delete').and.returnValue(of({})); - - // WHEN - comp.confirmDelete(123); - tick(); - - // THEN - expect(service.delete).toHaveBeenCalledWith(123); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); - }), - )); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise-update.component.spec.ts b/src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise-update.component.spec.ts deleted file mode 100644 index 49c91cfec755..000000000000 --- a/src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise-update.component.spec.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; -import { HttpResponse } from '@angular/common/http'; -import { of } from 'rxjs'; - -import { ArtemisTestModule } from '../../../test.module'; -import { QuizExerciseUpdateComponent } from 'app/entities/quiz-exercise/quiz-exercise-update.component'; -import { QuizExerciseService } from 'app/exercises/quiz/manage/quiz-exercise.service'; -import { QuizExercise } from 'app/shared/model/quiz-exercise.model'; - -describe('Component Tests', () => { - describe('QuizExercise Management Update Component', () => { - let comp: QuizExerciseUpdateComponent; - let fixture: ComponentFixture; - let service: QuizExerciseService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [QuizExerciseUpdateComponent], - }) - .overrideTemplate(QuizExerciseUpdateComponent, '') - .compileComponents(); - - fixture = TestBed.createComponent(QuizExerciseUpdateComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(QuizExerciseService); - }); - - describe('save', () => { - it('Should call update service on save for existing entity', fakeAsync(() => { - // GIVEN - const entity = new QuizExercise(123); - spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.quizExercise = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.update).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - })); - - it('Should call create service on save for new entity', fakeAsync(() => { - // GIVEN - const entity = new QuizExercise(); - spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.quizExercise = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.create).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - })); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/quiz-submission/quiz-submission-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/quiz-submission/quiz-submission-delete-dialog.component.spec.ts deleted file mode 100644 index e720b6110ede..000000000000 --- a/src/test/javascript/spec/app/entities/quiz-submission/quiz-submission-delete-dialog.component.spec.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { of } from 'rxjs'; -import { JhiEventManager } from 'ng-jhipster'; - -import { ArtemisTestModule } from '../../../test.module'; -import { QuizSubmissionDeleteDialogComponent } from 'app/exercises/quiz/participate/quiz-submission/quiz-submission-delete-dialog.component'; -import { QuizParticipationService } from 'app/exercises/quiz/participate/quiz-participation.service'; - -describe('Component Tests', () => { - describe('QuizSubmission Management Delete Component', () => { - let comp: QuizSubmissionDeleteDialogComponent; - let fixture: ComponentFixture; - let service: QuizParticipationService; - let mockEventManager: any; - let mockActiveModal: any; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [QuizSubmissionDeleteDialogComponent], - }) - .overrideTemplate(QuizSubmissionDeleteDialogComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(QuizSubmissionDeleteDialogComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(QuizParticipationService); - mockEventManager = fixture.debugElement.injector.get(JhiEventManager); - mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); - }); - - describe('confirmDelete', () => { - it('Should call delete service on confirmDelete', inject( - [], - fakeAsync(() => { - // GIVEN - spyOn(service, 'delete').and.returnValue(of({})); - - // WHEN - comp.confirmDelete(123); - tick(); - - // THEN - expect(service.delete).toHaveBeenCalledWith(123); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); - }), - )); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/quiz-submission/quiz-submission-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/quiz-submission/quiz-submission-dialog.component.spec.ts deleted file mode 100644 index a32738fad270..000000000000 --- a/src/test/javascript/spec/app/entities/quiz-submission/quiz-submission-dialog.component.spec.ts +++ /dev/null @@ -1,79 +0,0 @@ -/* tslint:disable max-line-length */ -import { async, ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; -import { HttpResponse } from '@angular/common/http'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { Observable } from 'rxjs/Observable'; -import { JhiEventManager } from 'ng-jhipster'; - -import { ArtemisTestModule } from '../../../test.module'; -import { QuizSubmissionDialogComponent } from '../../../../../../main/webapp/app/exercises/quiz/participate/quiz-submission/quiz-submission-dialog.component'; -import { QuizParticipationService } from 'app/exercises/quiz/participate/quiz-participation.service'; -import { QuizSubmission } from 'app/entities/quiz/quiz-submission.model'; - -describe('Component Tests', () => { - describe('QuizSubmission Management Dialog Component', () => { - let comp: QuizSubmissionDialogComponent; - let fixture: ComponentFixture; - let service: QuizParticipationService; - let mockEventManager: any; - let mockActiveModal: any; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [QuizSubmissionDialogComponent], - providers: [QuizParticipationService], - }) - .overrideTemplate(QuizSubmissionDialogComponent, '') - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(QuizSubmissionDialogComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(QuizParticipationService); - mockEventManager = fixture.debugElement.injector.get(JhiEventManager); - mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); - }); - - describe('save', () => { - it('Should call update service on save for existing entity', inject( - [], - fakeAsync(() => { - // GIVEN - const entity = new QuizSubmission(123); - spyOn(service, 'update').and.returnValue(Observable.of(new HttpResponse({ body: entity }))); - comp.quizSubmission = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.update).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - expect(mockEventManager.broadcastSpy).toHaveBeenCalledWith({ name: 'quizSubmissionListModification', content: 'OK' }); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - }), - )); - - it('Should call create service on save for new entity', inject( - [], - fakeAsync(() => { - // GIVEN - const entity = new QuizSubmission(); - spyOn(service, 'create').and.returnValue(Observable.of(new HttpResponse({ body: entity }))); - comp.quizSubmission = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.create).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - expect(mockEventManager.broadcastSpy).toHaveBeenCalledWith({ name: 'quizSubmissionListModification', content: 'OK' }); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - }), - )); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/quiz-submission/quiz-submission-update.component.spec.ts b/src/test/javascript/spec/app/entities/quiz-submission/quiz-submission-update.component.spec.ts deleted file mode 100644 index 526bac63c049..000000000000 --- a/src/test/javascript/spec/app/entities/quiz-submission/quiz-submission-update.component.spec.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; -import { HttpResponse } from '@angular/common/http'; -import { of } from 'rxjs'; - -import { ArtemisTestModule } from '../../../test.module'; -import { QuizSubmissionUpdateComponent } from 'app/exercises/quiz/participate/quiz-submission/quiz-submission-update.component'; -import { QuizParticipationService } from 'app/exercises/quiz/participate/quiz-participation.service'; -import { QuizSubmission } from 'app/shared/model/quiz-submission.model'; - -describe('Component Tests', () => { - describe('QuizSubmission Management Update Component', () => { - let comp: QuizSubmissionUpdateComponent; - let fixture: ComponentFixture; - let service: QuizParticipationService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [QuizSubmissionUpdateComponent], - }) - .overrideTemplate(QuizSubmissionUpdateComponent, '') - .compileComponents(); - - fixture = TestBed.createComponent(QuizSubmissionUpdateComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(QuizParticipationService); - }); - - describe('save', () => { - it('Should call update service on save for existing entity', fakeAsync(() => { - // GIVEN - const entity = new QuizSubmission(123); - spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.quizSubmission = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.update).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - })); - - it('Should call create service on save for new entity', fakeAsync(() => { - // GIVEN - const entity = new QuizSubmission(); - spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.quizSubmission = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.create).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - })); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/quiz-submission/quiz-submission.component.spec.ts b/src/test/javascript/spec/app/entities/quiz-submission/quiz-submission.component.spec.ts deleted file mode 100644 index d65b205622ea..000000000000 --- a/src/test/javascript/spec/app/entities/quiz-submission/quiz-submission.component.spec.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { of } from 'rxjs'; -import { HttpHeaders, HttpResponse } from '@angular/common/http'; - -import { ArtemisTestModule } from '../../../test.module'; -import { QuizSubmissionComponent } from 'app/exercises/quiz/participate/quiz-submission/quiz-submission.component'; -import { QuizParticipationService } from 'app/exercises/quiz/participate/quiz-participation.service'; -import { QuizSubmission } from 'app/shared/model/quiz-submission.model'; - -describe('Component Tests', () => { - describe('QuizSubmission Management Component', () => { - let comp: QuizSubmissionComponent; - let fixture: ComponentFixture; - let service: QuizParticipationService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [QuizSubmissionComponent], - providers: [], - }) - .overrideTemplate(QuizSubmissionComponent, '') - .compileComponents(); - - fixture = TestBed.createComponent(QuizSubmissionComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(QuizParticipationService); - }); - - it('Should call load all on init', () => { - // GIVEN - const headers = new HttpHeaders().append('link', 'link;link'); - spyOn(service, 'query').and.returnValue( - of( - new HttpResponse({ - body: [new QuizSubmission(123)], - headers, - }), - ), - ); - - // WHEN - comp.ngOnInit(); - - // THEN - expect(service.query).toHaveBeenCalled(); - expect(comp.quizSubmissions[0]).toEqual(jasmine.objectContaining({ id: 123 })); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/quiz-submission/quiz-submission.service.spec.ts b/src/test/javascript/spec/app/entities/quiz-submission/quiz-submission.service.spec.ts deleted file mode 100644 index 595a1d4cdca7..000000000000 --- a/src/test/javascript/spec/app/entities/quiz-submission/quiz-submission.service.spec.ts +++ /dev/null @@ -1,102 +0,0 @@ -/* tslint:disable max-line-length */ -import { getTestBed, TestBed } from '@angular/core/testing'; -import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; -import { map, take } from 'rxjs/operators'; -import { QuizParticipationService } from 'app/exercises/quiz/participate/quiz-participation.service'; -import { IQuizSubmission, QuizSubmission } from 'app/shared/model/quiz-submission.model'; - -describe('Service Tests', () => { - describe('QuizSubmission Service', () => { - let injector: TestBed; - let service: QuizParticipationService; - let httpMock: HttpTestingController; - let elemDefault: IQuizSubmission; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - }); - injector = getTestBed(); - service = injector.get(QuizParticipationService); - httpMock = injector.get(HttpTestingController); - - elemDefault = new QuizSubmission(0, 0); - }); - - describe('Service methods', async () => { - it('should find an element', async () => { - const returnedFromService = Object.assign({}, elemDefault); - service - .find(123) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: elemDefault })); - - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify(returnedFromService)); - }); - - it('should create a QuizSubmission', async () => { - const returnedFromService = Object.assign( - { - id: 0, - }, - elemDefault, - ); - const expected = Object.assign({}, returnedFromService); - service - .create(new QuizSubmission(null)) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); - const req = httpMock.expectOne({ method: 'POST' }); - req.flush(JSON.stringify(returnedFromService)); - }); - - it('should update a QuizSubmission', async () => { - const returnedFromService = Object.assign( - { - scoreInPoints: 1, - }, - elemDefault, - ); - - const expected = Object.assign({}, returnedFromService); - service - .update(expected) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); - const req = httpMock.expectOne({ method: 'PUT' }); - req.flush(JSON.stringify(returnedFromService)); - }); - - it('should return a list of QuizSubmission', async () => { - const returnedFromService = Object.assign( - { - scoreInPoints: 1, - }, - elemDefault, - ); - const expected = Object.assign({}, returnedFromService); - service - .query(expected) - .pipe( - take(1), - map((resp) => resp.body), - ) - .subscribe((body) => expect(body).toContainEqual(expected)); - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify([returnedFromService])); - httpMock.verify(); - }); - - it('should delete a QuizSubmission', async () => { - service.delete(123).subscribe((resp) => expect(resp.ok)); - - const req = httpMock.expectOne({ method: 'DELETE' }); - req.flush({ status: 200 }); - }); - }); - - afterEach(() => { - httpMock.verify(); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/result/result-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/result/result-dialog.component.spec.ts deleted file mode 100644 index 2ad933da7db9..000000000000 --- a/src/test/javascript/spec/app/entities/result/result-dialog.component.spec.ts +++ /dev/null @@ -1,81 +0,0 @@ -/* tslint:disable max-line-length */ -import { async, ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; -import { HttpResponse } from '@angular/common/http'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { Observable } from 'rxjs/Observable'; -import { JhiEventManager } from 'ng-jhipster'; - -import { ArtemisTestModule } from '../../../test.module'; -import { ResultDialogComponent } from '../../../../../../main/webapp/app/exercises/shared/result/result-dialog.component'; -import { ResultService } from '../../../../../../main/webapp/app/exercises/shared/result/result.service'; -import { Result } from 'app/entities/result.model'; -import { SubmissionService } from '../../../../../../main/webapp/app/exercises/shared/submission'; -import { ParticipationService } from '../../../../../../main/webapp/app/exercises/shared/participation'; - -describe('Component Tests', () => { - describe('Result Management Dialog Component', () => { - let comp: ResultDialogComponent; - let fixture: ComponentFixture; - let service: ResultService; - let mockEventManager: any; - let mockActiveModal: any; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [ResultDialogComponent], - providers: [SubmissionService, ParticipationService, ResultService], - }) - .overrideTemplate(ResultDialogComponent, '') - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(ResultDialogComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ResultService); - mockEventManager = fixture.debugElement.injector.get(JhiEventManager); - mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); - }); - - describe('save', () => { - it('Should call update service on save for existing entity', inject( - [], - fakeAsync(() => { - // GIVEN - const entity = new Result(123); - spyOn(service, 'update').and.returnValue(Observable.of(new HttpResponse({ body: entity }))); - comp.result = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.update).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - expect(mockEventManager.broadcastSpy).toHaveBeenCalledWith({ name: 'resultListModification', content: 'OK' }); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - }), - )); - - it('Should call create service on save for new entity', inject( - [], - fakeAsync(() => { - // GIVEN - const entity = new Result(); - spyOn(service, 'create').and.returnValue(Observable.of(new HttpResponse({ body: entity }))); - comp.result = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.create).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - expect(mockEventManager.broadcastSpy).toHaveBeenCalledWith({ name: 'resultListModification', content: 'OK' }); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - }), - )); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/text-exercise/text-exercise-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/text-exercise/text-exercise-delete-dialog.component.spec.ts deleted file mode 100644 index 14b48c9cceb1..000000000000 --- a/src/test/javascript/spec/app/entities/text-exercise/text-exercise-delete-dialog.component.spec.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { of } from 'rxjs'; -import { JhiEventManager } from 'ng-jhipster'; - -import { ArTeMiSTestModule } from '../../../test.module'; -import { TextExerciseDeleteDialogComponent } from 'app/exercises/text/manage/text-exercise/text-exercise-delete-dialog.component'; -import { TextExerciseService } from 'app/exercises/text/manage/text-exercise/text-exercise.service'; - -describe('Component Tests', () => { - describe('TextExercise Management Delete Component', () => { - let comp: TextExerciseDeleteDialogComponent; - let fixture: ComponentFixture; - let service: TextExerciseService; - let mockEventManager: any; - let mockActiveModal: any; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArTeMiSTestModule], - declarations: [TextExerciseDeleteDialogComponent], - }) - .overrideTemplate(TextExerciseDeleteDialogComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(TextExerciseDeleteDialogComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(TextExerciseService); - mockEventManager = fixture.debugElement.injector.get(JhiEventManager); - mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); - }); - - describe('confirmDelete', () => { - it('Should call delete service on confirmDelete', inject( - [], - fakeAsync(() => { - // GIVEN - spyOn(service, 'delete').and.returnValue(of({})); - - // WHEN - comp.confirmDelete(123); - tick(); - - // THEN - expect(service.delete).toHaveBeenCalledWith(123); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); - }), - )); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/text-exercise/text-exercise-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/text-exercise/text-exercise-dialog.component.spec.ts deleted file mode 100644 index f08bf75a6cd1..000000000000 --- a/src/test/javascript/spec/app/entities/text-exercise/text-exercise-dialog.component.spec.ts +++ /dev/null @@ -1,79 +0,0 @@ -/* tslint:disable max-line-length */ -import { async, ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; -import { HttpResponse } from '@angular/common/http'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { Observable } from 'rxjs/Observable'; -import { JhiEventManager } from 'ng-jhipster'; - -import { ArtemisTestModule } from '../../../test.module'; -import { TextExerciseDialogComponent } from '../../../../../../main/webapp/app/exercises/text/manage/text-exercise/text-exercise-dialog.component'; -import { TextExerciseService } from '../../../../../../main/webapp/app/exercises/text/manage/text-exercise/text-exercise.service'; -import { TextExercise } from 'app/entities/text-exercise.model'; - -describe('Component Tests', () => { - describe('TextExercise Management Dialog Component', () => { - let comp: TextExerciseDialogComponent; - let fixture: ComponentFixture; - let service: TextExerciseService; - let mockEventManager: any; - let mockActiveModal: any; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [TextExerciseDialogComponent], - providers: [TextExerciseService], - }) - .overrideTemplate(TextExerciseDialogComponent, '') - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(TextExerciseDialogComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(TextExerciseService); - mockEventManager = fixture.debugElement.injector.get(JhiEventManager); - mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); - }); - - describe('save', () => { - it('Should call update service on save for existing entity', inject( - [], - fakeAsync(() => { - // GIVEN - const entity = new TextExercise(123); - spyOn(service, 'update').and.returnValue(Observable.of(new HttpResponse({ body: entity }))); - comp.textExercise = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.update).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - expect(mockEventManager.broadcastSpy).toHaveBeenCalledWith({ name: 'textExerciseListModification', content: 'OK' }); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - }), - )); - - it('Should call create service on save for new entity', inject( - [], - fakeAsync(() => { - // GIVEN - const entity = new TextExercise(); - spyOn(service, 'create').and.returnValue(Observable.of(new HttpResponse({ body: entity }))); - comp.textExercise = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.create).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - expect(mockEventManager.broadcastSpy).toHaveBeenCalledWith({ name: 'textExerciseListModification', content: 'OK' }); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - }), - )); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/text-submission/text-submission-delete-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/text-submission/text-submission-delete-dialog.component.spec.ts deleted file mode 100644 index 17796a19ac31..000000000000 --- a/src/test/javascript/spec/app/entities/text-submission/text-submission-delete-dialog.component.spec.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { of } from 'rxjs'; -import { JhiEventManager } from 'ng-jhipster'; - -import { ArTeMiSTestModule } from '../../../test.module'; -import { TextSubmissionDeleteDialogComponent } from 'app/exercises/text/participate/text-submission/text-submission-delete-dialog.component'; -import { TextSubmissionService } from 'app/exercises/text/participate/text-submission.service'; - -describe('Component Tests', () => { - describe('TextSubmission Management Delete Component', () => { - let comp: TextSubmissionDeleteDialogComponent; - let fixture: ComponentFixture; - let service: TextSubmissionService; - let mockEventManager: any; - let mockActiveModal: any; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArTeMiSTestModule], - declarations: [TextSubmissionDeleteDialogComponent], - }) - .overrideTemplate(TextSubmissionDeleteDialogComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(TextSubmissionDeleteDialogComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(TextSubmissionService); - mockEventManager = fixture.debugElement.injector.get(JhiEventManager); - mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); - }); - - describe('confirmDelete', () => { - it('Should call delete service on confirmDelete', inject( - [], - fakeAsync(() => { - // GIVEN - spyOn(service, 'delete').and.returnValue(of({})); - - // WHEN - comp.confirmDelete(123); - tick(); - - // THEN - expect(service.delete).toHaveBeenCalledWith(123); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - expect(mockEventManager.broadcastSpy).toHaveBeenCalled(); - }), - )); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/text-submission/text-submission-detail.component.spec.ts b/src/test/javascript/spec/app/entities/text-submission/text-submission-detail.component.spec.ts deleted file mode 100644 index 7a9c3f53bbab..000000000000 --- a/src/test/javascript/spec/app/entities/text-submission/text-submission-detail.component.spec.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { ActivatedRoute } from '@angular/router'; -import { of } from 'rxjs'; - -import { ArTeMiSTestModule } from '../../../test.module'; -import { TextSubmissionDetailComponent } from 'app/exercises/text/participate/text-submission/text-submission-detail.component'; -import { TextSubmission } from 'app/shared/model/text-submission.model'; - -describe('Component Tests', () => { - describe('TextSubmission Management Detail Component', () => { - let comp: TextSubmissionDetailComponent; - let fixture: ComponentFixture; - const route = ({ data: of({ textSubmission: new TextSubmission(123) }) } as any) as ActivatedRoute; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArTeMiSTestModule], - declarations: [TextSubmissionDetailComponent], - providers: [{ provide: ActivatedRoute, useValue: route }], - }) - .overrideTemplate(TextSubmissionDetailComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(TextSubmissionDetailComponent); - comp = fixture.componentInstance; - }); - - describe('OnInit', () => { - it('Should call load all on init', () => { - // GIVEN - - // WHEN - comp.ngOnInit(); - - // THEN - expect(comp.textSubmission).toEqual(jasmine.objectContaining({ id: 123 })); - }); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/text-submission/text-submission-dialog.component.spec.ts b/src/test/javascript/spec/app/entities/text-submission/text-submission-dialog.component.spec.ts deleted file mode 100644 index 1e0db7339b3c..000000000000 --- a/src/test/javascript/spec/app/entities/text-submission/text-submission-dialog.component.spec.ts +++ /dev/null @@ -1,79 +0,0 @@ -/* tslint:disable max-line-length */ -import { async, ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; -import { HttpResponse } from '@angular/common/http'; -import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { Observable } from 'rxjs/Observable'; -import { JhiEventManager } from 'ng-jhipster'; - -import { ArtemisTestModule } from '../../../test.module'; -import { TextSubmissionDialogComponent } from '../../../../../../main/webapp/app/exercises/text/participate/text-submission/text-submission-dialog.component'; -import { TextSubmissionService } from 'app/exercises/text/participate/text-submission.service'; -import { TextSubmission } from 'app/entities/text-submission.model'; - -describe('Component Tests', () => { - describe('TextSubmission Management Dialog Component', () => { - let comp: TextSubmissionDialogComponent; - let fixture: ComponentFixture; - let service: TextSubmissionService; - let mockEventManager: any; - let mockActiveModal: any; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [TextSubmissionDialogComponent], - providers: [TextSubmissionService], - }) - .overrideTemplate(TextSubmissionDialogComponent, '') - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(TextSubmissionDialogComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(TextSubmissionService); - mockEventManager = fixture.debugElement.injector.get(JhiEventManager); - mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal); - }); - - describe('save', () => { - it('Should call update service on save for existing entity', inject( - [], - fakeAsync(() => { - // GIVEN - const entity = new TextSubmission(123); - spyOn(service, 'update').and.returnValue(Observable.of(new HttpResponse({ body: entity }))); - comp.textSubmission = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.update).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - expect(mockEventManager.broadcastSpy).toHaveBeenCalledWith({ name: 'textSubmissionListModification', content: 'OK' }); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - }), - )); - - it('Should call create service on save for new entity', inject( - [], - fakeAsync(() => { - // GIVEN - const entity = new TextSubmission(); - spyOn(service, 'create').and.returnValue(Observable.of(new HttpResponse({ body: entity }))); - comp.textSubmission = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.create).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - expect(mockEventManager.broadcastSpy).toHaveBeenCalledWith({ name: 'textSubmissionListModification', content: 'OK' }); - expect(mockActiveModal.dismissSpy).toHaveBeenCalled(); - }), - )); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/text-submission/text-submission-update.component.spec.ts b/src/test/javascript/spec/app/entities/text-submission/text-submission-update.component.spec.ts deleted file mode 100644 index e26d3dd9d67c..000000000000 --- a/src/test/javascript/spec/app/entities/text-submission/text-submission-update.component.spec.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; -import { HttpResponse } from '@angular/common/http'; -import { of } from 'rxjs'; - -import { ArTeMiSTestModule } from '../../../test.module'; -import { TextSubmissionUpdateComponent } from 'app/exercises/text/participate/text-submission/text-submission-update.component'; -import { TextSubmissionService } from 'app/exercises/text/participate/text-submission.service'; -import { TextSubmission } from 'app/shared/model/text-submission.model'; - -describe('Component Tests', () => { - describe('TextSubmission Management Update Component', () => { - let comp: TextSubmissionUpdateComponent; - let fixture: ComponentFixture; - let service: TextSubmissionService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArTeMiSTestModule], - declarations: [TextSubmissionUpdateComponent], - }) - .overrideTemplate(TextSubmissionUpdateComponent, '') - .compileComponents(); - - fixture = TestBed.createComponent(TextSubmissionUpdateComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(TextSubmissionService); - }); - - describe('save', () => { - it('Should call update service on save for existing entity', fakeAsync(() => { - // GIVEN - const entity = new TextSubmission(123); - spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.textSubmission = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.update).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - })); - - it('Should call create service on save for new entity', fakeAsync(() => { - // GIVEN - const entity = new TextSubmission(); - spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.textSubmission = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.create).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - })); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/text-submission/text-submission.component.spec.ts b/src/test/javascript/spec/app/entities/text-submission/text-submission.component.spec.ts deleted file mode 100644 index f8f701ea495f..000000000000 --- a/src/test/javascript/spec/app/entities/text-submission/text-submission.component.spec.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { of } from 'rxjs'; -import { HttpHeaders, HttpResponse } from '@angular/common/http'; - -import { ArTeMiSTestModule } from '../../../test.module'; -import { TextSubmissionComponent } from 'app/exercises/text/participate/text-submission/text-submission.component'; -import { TextSubmissionService } from 'app/exercises/text/participate/text-submission.service'; -import { TextSubmission } from 'app/shared/model/text-submission.model'; - -describe('Component Tests', () => { - describe('TextSubmission Management Component', () => { - let comp: TextSubmissionComponent; - let fixture: ComponentFixture; - let service: TextSubmissionService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArTeMiSTestModule], - declarations: [TextSubmissionComponent], - providers: [], - }) - .overrideTemplate(TextSubmissionComponent, '') - .compileComponents(); - - fixture = TestBed.createComponent(TextSubmissionComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(TextSubmissionService); - }); - - it('Should call load all on init', () => { - // GIVEN - const headers = new HttpHeaders().append('link', 'link;link'); - spyOn(service, 'query').and.returnValue( - of( - new HttpResponse({ - body: [new TextSubmission(123)], - headers, - }), - ), - ); - - // WHEN - comp.ngOnInit(); - - // THEN - expect(service.query).toHaveBeenCalled(); - expect(comp.textSubmissions[0]).toEqual(jasmine.objectContaining({ id: 123 })); - }); - }); -}); From 099ac6d6f486d10fd81369295fbf08fa2ab4ddbc Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Thu, 23 Apr 2020 17:36:23 +0200 Subject: [PATCH 078/152] Delete doubled test suites --- ...e-upload-exercise-detail.component.spec.ts | 40 ------------- .../modeling-submission.component.spec.ts | 56 ------------------- .../participation.component.spec.ts | 51 ----------------- 3 files changed, 147 deletions(-) delete mode 100644 src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise-detail.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/modeling-submission/modeling-submission.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/participation/participation.component.spec.ts diff --git a/src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise-detail.component.spec.ts b/src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise-detail.component.spec.ts deleted file mode 100644 index 99cd0a3af9fe..000000000000 --- a/src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise-detail.component.spec.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { ActivatedRoute } from '@angular/router'; -import { of } from 'rxjs'; - -import { ArTeMiSTestModule } from '../../../test.module'; -import { FileUploadExerciseDetailComponent } from 'app/exercises/file-upload/manage/file-upload-exercise-detail.component'; -import { FileUploadExercise } from 'app/shared/model/file-upload-exercise.model'; - -describe('Component Tests', () => { - describe('FileUploadExercise Management Detail Component', () => { - let comp: FileUploadExerciseDetailComponent; - let fixture: ComponentFixture; - const route = ({ data: of({ fileUploadExercise: new FileUploadExercise(123) }) } as any) as ActivatedRoute; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArTeMiSTestModule], - declarations: [FileUploadExerciseDetailComponent], - providers: [{ provide: ActivatedRoute, useValue: route }], - }) - .overrideTemplate(FileUploadExerciseDetailComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(FileUploadExerciseDetailComponent); - comp = fixture.componentInstance; - }); - - describe('OnInit', () => { - it('Should call load all on init', () => { - // GIVEN - - // WHEN - comp.ngOnInit(); - - // THEN - expect(comp.fileUploadExercise).toEqual(jasmine.objectContaining({ id: 123 })); - }); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/modeling-submission/modeling-submission.component.spec.ts b/src/test/javascript/spec/app/entities/modeling-submission/modeling-submission.component.spec.ts deleted file mode 100644 index 290daa2c87da..000000000000 --- a/src/test/javascript/spec/app/entities/modeling-submission/modeling-submission.component.spec.ts +++ /dev/null @@ -1,56 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { of } from 'rxjs'; -import { HttpHeaders, HttpResponse } from '@angular/common/http'; - -import { ArtemisTestModule } from '../../../test.module'; -import { ModelingSubmissionComponent } from 'app/exercises/modeling-submission/modeling-submission.component'; -import { ModelingSubmissionService } from 'app/exercises/modeling/participate/modeling-submission.service'; -import { ModelingSubmission } from 'app/shared/model/modeling-submission.model'; -import * as chai from 'chai'; -import * as sinonChai from 'sinon-chai'; - -chai.use(sinonChai); -const expect = chai.expect; - -describe('Component Tests', () => { - describe('ModelingSubmission Management Component', () => { - let comp: ModelingSubmissionComponent; - let fixture: ComponentFixture; - let service: ModelingSubmissionService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [ModelingSubmissionComponent], - providers: [], - }) - .overrideTemplate(ModelingSubmissionComponent, '') - .compileComponents(); - - fixture = TestBed.createComponent(ModelingSubmissionComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ModelingSubmissionService); - }); - - it('Should call load all on init', () => { - // GIVEN - const headers = new HttpHeaders().append('link', 'link;link'); - spyOn(service, 'query').and.returnValue( - of( - new HttpResponse({ - body: [new ModelingSubmission(123)], - headers, - }), - ), - ); - - // WHEN - comp.ngOnInit(); - - // THEN - expect(service.query).toHaveBeenCalled(); - expect(comp.modelingSubmissions[0]).toEqual(jasmine.objectContaining({ id: 123 })); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/participation/participation.component.spec.ts b/src/test/javascript/spec/app/entities/participation/participation.component.spec.ts deleted file mode 100644 index eb78f496a12f..000000000000 --- a/src/test/javascript/spec/app/entities/participation/participation.component.spec.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { of } from 'rxjs'; -import { HttpHeaders, HttpResponse } from '@angular/common/http'; - -import { ArtemisTestModule } from '../../../test.module'; -import { ParticipationComponent } from 'app/exercises/shared/participation/participation.component'; -import { ParticipationService } from 'app/exercises/shared/participation/participation.service'; -import { Participation } from 'app/shared/model/participation.model'; - -describe('Component Tests', () => { - describe('Participation Management Component', () => { - let comp: ParticipationComponent; - let fixture: ComponentFixture; - let service: ParticipationService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [ParticipationComponent], - providers: [], - }) - .overrideTemplate(ParticipationComponent, '') - .compileComponents(); - - fixture = TestBed.createComponent(ParticipationComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ParticipationService); - }); - - it('Should call load all on init', () => { - // GIVEN - const headers = new HttpHeaders().append('link', 'link;link'); - spyOn(service, 'query').and.returnValue( - of( - new HttpResponse({ - body: [new Participation(123)], - headers, - }), - ), - ); - - // WHEN - comp.ngOnInit(); - - // THEN - expect(service.query).toHaveBeenCalled(); - expect(comp.participations[0]).toEqual(jasmine.objectContaining({ id: 123 })); - }); - }); -}); From 4fd9a08cbd5fb2affd387bbb1746058ccf98129a Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Thu, 23 Apr 2020 18:33:08 +0200 Subject: [PATCH 079/152] Adjust settings.component.spec to jhipster reference implementation --- .../settings/settings.component.spec.ts | 64 +++++++++---------- .../spec/helpers/mock-account.service.ts | 26 ++++---- 2 files changed, 44 insertions(+), 46 deletions(-) diff --git a/src/test/javascript/spec/app/account/settings/settings.component.spec.ts b/src/test/javascript/spec/app/account/settings/settings.component.spec.ts index 6ee20eb1d03c..7067771c3f7a 100644 --- a/src/test/javascript/spec/app/account/settings/settings.component.spec.ts +++ b/src/test/javascript/spec/app/account/settings/settings.component.spec.ts @@ -1,30 +1,36 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { throwError } from 'rxjs'; +import { ComponentFixture, TestBed, async } from '@angular/core/testing'; +import { FormBuilder } from '@angular/forms'; +import { throwError, of } from 'rxjs'; import { ArtemisTestModule } from '../../../test.module'; -import { Principal } from 'app/core'; import { AccountService } from 'app/core/auth/account.service'; +import { Account } from 'app/core/user/account.model'; import { SettingsComponent } from 'app/account/settings/settings.component'; -import { JhiTrackerService } from 'app/core/tracker/tracker.service'; -import { MockTrackerService } from '../../../helpers/mock-tracker.service'; +import { MockAccountService } from '../../../helpers/mock-account.service'; describe('Component Tests', () => { describe('SettingsComponent', () => { let comp: SettingsComponent; let fixture: ComponentFixture; - let mockAuth: any; - let mockPrincipal: any; + let mockAuth: MockAccountService; + const accountValues: Account = { + firstName: 'John', + lastName: 'Doe', + activated: true, + email: 'john.doe@mail.com', + name: 'john', + langKey: 'en', + login: 'john', + authorities: [], + imageUrl: '', + guidedTourSettings: [], + }; beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ArtemisTestModule], declarations: [SettingsComponent], - providers: [ - { - provide: JhiTrackerService, - useClass: MockTrackerService, - }, - ], + providers: [FormBuilder], }) .overrideTemplate(SettingsComponent, '') .compileComponents(); @@ -33,47 +39,41 @@ describe('Component Tests', () => { beforeEach(() => { fixture = TestBed.createComponent(SettingsComponent); comp = fixture.componentInstance; - mockAuth = fixture.debugElement.injector.get(AccountService); - mockPrincipal = fixture.debugElement.injector.get(Principal); + mockAuth = TestBed.get(AccountService); + mockAuth.setIdentityResponse(accountValues); }); it('should send the current identity upon save', () => { // GIVEN - const accountValues = { + mockAuth.saveSpy.and.returnValue(of({})); + const settingsFormValues = { firstName: 'John', lastName: 'Doe', - - activated: true, email: 'john.doe@mail.com', langKey: 'en', - login: 'john', }; - mockPrincipal.setResponse(accountValues); // WHEN - comp.settingsAccount = accountValues; + comp.ngOnInit(); comp.save(); // THEN - expect(mockPrincipal.identitySpy).toHaveBeenCalled(); + expect(mockAuth.identitySpy).toHaveBeenCalled(); expect(mockAuth.saveSpy).toHaveBeenCalledWith(accountValues); - expect(comp.settingsAccount).toEqual(accountValues); + expect(mockAuth.authenticateSpy).toHaveBeenCalledWith(accountValues); + expect(comp.settingsForm.value).toEqual(settingsFormValues); }); it('should notify of success upon successful save', () => { // GIVEN - const accountValues = { - firstName: 'John', - lastName: 'Doe', - }; - mockPrincipal.setResponse(accountValues); + mockAuth.saveSpy.and.returnValue(of({})); // WHEN + comp.ngOnInit(); comp.save(); // THEN - expect(comp.error).toBeNull(); - expect(comp.success).toBe('OK'); + expect(comp.success).toBe(true); }); it('should notify of error upon failed save', () => { @@ -81,11 +81,11 @@ describe('Component Tests', () => { mockAuth.saveSpy.and.returnValue(throwError('ERROR')); // WHEN + comp.ngOnInit(); comp.save(); // THEN - expect(comp.error).toEqual('ERROR'); - expect(comp.success).toBeNull(); + expect(comp.success).toBe(false); }); }); }); diff --git a/src/test/javascript/spec/helpers/mock-account.service.ts b/src/test/javascript/spec/helpers/mock-account.service.ts index af0bc5445670..e52cc6a4f803 100644 --- a/src/test/javascript/spec/helpers/mock-account.service.ts +++ b/src/test/javascript/spec/helpers/mock-account.service.ts @@ -1,31 +1,29 @@ +import Spy = jasmine.Spy; +import { of } from 'rxjs'; + import { SpyObject } from './spyobject'; import { AccountService } from 'app/core/auth/account.service'; -import Spy = jasmine.Spy; +import { Account } from 'app/core/user/account.model'; export class MockAccountService extends SpyObject { getSpy: Spy; saveSpy: Spy; - fakeResponse: any; - hasAnyAuthorityDirectSpy: Spy; + authenticateSpy: Spy; identitySpy: Spy; - isAtLeastInstructorInCourseSpy: Spy; + getAuthenticationStateSpy: Spy; constructor() { super(AccountService); - this.fakeResponse = null; this.getSpy = this.spy('get').andReturn(this); this.saveSpy = this.spy('save').andReturn(this); - this.hasAnyAuthorityDirectSpy = this.spy('hasAnyAuthorityDirect').andReturn(this); - this.identitySpy = this.spy('identity').andReturn(this); - this.isAtLeastInstructorInCourseSpy = this.spy('isAtLeastInstructorInCourse').andReturn(this); - } - - subscribe(callback: any) { - callback(this.fakeResponse); + this.authenticateSpy = this.spy('authenticate').andReturn(this); + this.identitySpy = this.spy('identity').andReturn(of(null)); + this.getAuthenticationStateSpy = this.spy('getAuthenticationState').andReturn(of(null)); } - setResponse(json: any): void { - this.fakeResponse = json; + setIdentityResponse(account: Account | null): void { + this.identitySpy = this.spy('identity').andReturn(of(account)); + this.getAuthenticationStateSpy = this.spy('getAuthenticationState').andReturn(of(account)); } } From 63842e7a509891e27c6bd72f8dd3c587c6c495e1 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Thu, 23 Apr 2020 18:42:15 +0200 Subject: [PATCH 080/152] Remove JhiTrackerservice from passwort.component.spec --- .../spec/app/account/password/password.component.spec.ts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/test/javascript/spec/app/account/password/password.component.spec.ts b/src/test/javascript/spec/app/account/password/password.component.spec.ts index d3198c660b17..6dae07b0837b 100644 --- a/src/test/javascript/spec/app/account/password/password.component.spec.ts +++ b/src/test/javascript/spec/app/account/password/password.component.spec.ts @@ -5,7 +5,6 @@ import { of, throwError } from 'rxjs'; import { ArtemisTestModule } from '../../../test.module'; import { PasswordComponent } from 'app/account/password/password.component'; import { PasswordService } from 'app/account/password/password.service'; -import { MockTrackerService } from '../../../helpers/mock-tracker.service'; describe('Component Tests', () => { describe('PasswordComponent', () => { @@ -17,12 +16,6 @@ describe('Component Tests', () => { TestBed.configureTestingModule({ imports: [ArtemisTestModule], declarations: [PasswordComponent], - providers: [ - { - provide: JhiTrackerService, - useClass: MockTrackerService, - }, - ], }) .overrideTemplate(PasswordComponent, '') .compileComponents(); From 33124ab2ad100455494cbaaf78d0c604fda03092 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Thu, 23 Apr 2020 18:45:47 +0200 Subject: [PATCH 081/152] Delete course.component.spec.ts --- .../entities/course/course.component.spec.ts | 51 ------------------- 1 file changed, 51 deletions(-) delete mode 100644 src/test/javascript/spec/app/entities/course/course.component.spec.ts diff --git a/src/test/javascript/spec/app/entities/course/course.component.spec.ts b/src/test/javascript/spec/app/entities/course/course.component.spec.ts deleted file mode 100644 index 55ddbc38f38c..000000000000 --- a/src/test/javascript/spec/app/entities/course/course.component.spec.ts +++ /dev/null @@ -1,51 +0,0 @@ -/* tslint:disable max-line-length */ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { of } from 'rxjs'; -import { HttpHeaders, HttpResponse } from '@angular/common/http'; - -import { ArtemisTestModule } from '../../../test.module'; -import { CourseComponent } from 'app/entities/manage/course.component'; -import { CourseService } from 'app/course/manage/course.service'; -import { Course } from 'app/shared/model/course.model'; - -describe('Component Tests', () => { - describe('Course Management Component', () => { - let comp: CourseComponent; - let fixture: ComponentFixture; - let service: CourseService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [CourseComponent], - providers: [], - }) - .overrideTemplate(CourseComponent, '') - .compileComponents(); - - fixture = TestBed.createComponent(CourseComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(CourseService); - }); - - it('Should call load all on init', () => { - // GIVEN - const headers = new HttpHeaders().append('link', 'link;link'); - spyOn(service, 'query').and.returnValue( - of( - new HttpResponse({ - body: [new Course(123)], - headers, - }), - ), - ); - - // WHEN - comp.ngOnInit(); - - // THEN - expect(service.query).toHaveBeenCalled(); - expect(comp.courses[0]).toEqual(jasmine.objectContaining({ id: 123 })); - }); - }); -}); From de4c8480157ee7557fe6925eac19d53841df7bfc Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Thu, 23 Apr 2020 20:44:31 +0200 Subject: [PATCH 082/152] Delete file-upload-submission.component.spec.ts --- .../file-upload-submission.component.spec.ts | 50 ------------------- 1 file changed, 50 deletions(-) delete mode 100644 src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission.component.spec.ts diff --git a/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission.component.spec.ts b/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission.component.spec.ts deleted file mode 100644 index b98003e7d680..000000000000 --- a/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission.component.spec.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { of } from 'rxjs'; -import { HttpHeaders, HttpResponse } from '@angular/common/http'; - -import { ArtemisTestModule } from '../../../test.module'; -import { FileUploadSubmissionComponent } from 'app/exercises/file-upload/participate/file-upload-submission.component'; -import { FileUploadSubmissionService } from 'app/exercises/file-upload/participate/file-upload-submission.service'; -import { FileUploadSubmission } from 'app/entities/file-upload-submission.model'; - -describe('Component Tests', () => { - describe('FileUploadSubmission Management Component', () => { - let comp: FileUploadSubmissionComponent; - let fixture: ComponentFixture; - let service: FileUploadSubmissionService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [FileUploadSubmissionComponent], - providers: [], - }) - .overrideTemplate(FileUploadSubmissionComponent, '') - .compileComponents(); - - fixture = TestBed.createComponent(FileUploadSubmissionComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(FileUploadSubmissionService); - }); - - it('Should call load all on init', () => { - // GIVEN - const headers = new HttpHeaders().append('link', 'link;link'); - spyOn(service, 'query').and.returnValue( - of( - new HttpResponse({ - body: [new FileUploadSubmission(123)], - headers, - }), - ), - ); - - // WHEN - comp.ngOnInit(); - - // THEN - expect(service.query).toHaveBeenCalled(); - expect(comp.fileUploadSubmissions[0]).toEqual(jasmine.objectContaining({ id: 123 })); - }); - }); -}); From 0a311a03d432f87ab0292217fed08f021809bc57 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Thu, 23 Apr 2020 22:26:05 +0200 Subject: [PATCH 083/152] Add component/service identifier to filename of all test suites --- ...ser-management.spec.ts => user-management.component.spec.ts} | 0 .../{admin/admin.spec.ts => audits/audits.component.spec.ts} | 2 +- ...ode-editor-ace.spec.ts => code-editor-ace.component.spec.ts} | 0 ...or-actions.spec.ts => code-editor-actions.component.spec.ts} | 0 ...utput.spec.ts => code-editor-build-output.component.spec.ts} | 0 ...owser.spec.ts => code-editor-file-browser.component.spec.ts} | 0 ...tions.spec.ts => code-editor-instructions.component.spec.ts} | 0 ...itor-status.spec.ts => code-editor-status.component.spec.ts} | 0 ...for-tutor.spec.ts => complaints-for-tutor.component.spec.ts} | 0 .../{complaints.spec.ts => complaints.component.spec.ts} | 0 ...essment.spec.ts => file-upload-assessment.component.spec.ts} | 0 ...load-result.spec.ts => file-upload-result.component.spec.ts} | 2 +- ...mission.spec.ts => file-upload-submission.component.spec.ts} | 0 ....spec.ts => instructor-exercise-dashboard.component.spec.ts} | 0 ...ttachments.spec.ts => lecture-attachments.component.spec.ts} | 0 ...-complaints.spec.ts => list-of-complaints.component.spec.ts} | 0 ...and.spec.ts => gradingInstruction-command.component.spec.ts} | 0 ...ercise-row.spec.ts => course-exercise-row.component.spec.ts} | 0 ...e-statistics.spec.ts => course-statistics.component.spec.ts} | 0 ...ec.ts => exercise-details-student-actions.component.spec.ts} | 0 ... programming-exercise-student-ide-actions.component.spec.ts} | 0 ...ssion.spec.ts => participation-submission.component.spec.ts} | 0 ...ogramming-assessment-manual-result-dialog.component.spec.ts} | 0 ...programming-exercise-editable-instruction.component.spec.ts} | 0 ...rt.spec.ts => programming-exercise-import.component.spec.ts} | 0 ...programming-exercise-instruction-analysis.component.spec.ts} | 0 ...gramming-exercise-instruction-step-wizard.component.spec.ts} | 2 +- ...ec.ts => programming-exercise-instruction.component.spec.ts} | 0 ...=> programming-exercise-instructor-status.component.spec.ts} | 0 ...ming-exercise-instructor-submission-state.component.spec.ts} | 2 +- ...=> programming-exercise-manage-test-cases.component.spec.ts} | 2 +- ...programming-exercise-test-schedule-picker.component.spec.ts} | 0 ...programming-exercise-trigger-build-button.component.spec.ts} | 0 .../{button-component.spec.ts => button.component.spec.ts} | 0 .../{delete-dialog.spec.ts => delete-dialog.component.spec.ts} | 0 .../{result-detail.spec.ts => result-detail.component.spec.ts} | 0 .../{secured-image.spec.ts => secured-image.component.spec.ts} | 0 ...pdating-result.spec.ts => updating-result.component.spec.ts} | 0 ...eckbox.spec.ts => table-editable-checkbox.component.spec.ts} | 0 ...ble-field.spec.ts => table-editable-field.component.spec.ts} | 0 ...date-dialog.spec.ts => team-update-dialog.component.spec.ts} | 0 .../component/team/{teams.spec.ts => teams.component.spec.ts} | 0 .../{text-editor.spec.ts => text-editor.component.spec.ts} | 2 +- ...ment.spec.ts => text-exercise-assessement.component.spec.ts} | 2 +- ...ment-area.spec.ts => text-assessment-area.component.spec.ts} | 0 ...ent.spec.ts => text-submission-assessment.component.spec.ts} | 0 ...card.spec.ts => textblock-assessment-card.component.spec.ts} | 0 ...itor.spec.ts => textblock-feedback-editor.component.spec.ts} | 0 ...board.spec.ts => tutor-exercise-dashboard.component.spec.ts} | 0 .../{account-service.spec.ts => account.service.spec.ts} | 0 ...ete-dialog-service.spec.ts => delete-dialog.service.spec.ts} | 0 ...-test-service.spec.ts => ide-build-and-test.service.spec.ts} | 0 .../service/{login-service.spec.ts => login.service.spec.ts} | 0 ...-service.spec.ts => participation-websocket.service.spec.ts} | 0 ...> programming-exercise-instruction-analysis.service.spec.ts} | 0 ...spec.ts => programming-exercise-instruction.service.spec.ts} | 0 ...e.spec.ts => programming-exercise-test-case.service.spec.ts} | 0 ...n-service.spec.ts => programming-submission.service.spec.ts} | 0 ...{text-editor-service.spec.ts => text-editor.service.spec.ts} | 0 ...access-service.spec.ts => user-route-access.service.spec.ts} | 0 60 files changed, 7 insertions(+), 7 deletions(-) rename src/test/javascript/spec/component/admin/{user-management.spec.ts => user-management.component.spec.ts} (100%) rename src/test/javascript/spec/component/{admin/admin.spec.ts => audits/audits.component.spec.ts} (97%) rename src/test/javascript/spec/component/code-editor/{code-editor-ace.spec.ts => code-editor-ace.component.spec.ts} (100%) rename src/test/javascript/spec/component/code-editor/{code-editor-actions.spec.ts => code-editor-actions.component.spec.ts} (100%) rename src/test/javascript/spec/component/code-editor/{code-editor-build-output.spec.ts => code-editor-build-output.component.spec.ts} (100%) rename src/test/javascript/spec/component/code-editor/{code-editor-file-browser.spec.ts => code-editor-file-browser.component.spec.ts} (100%) rename src/test/javascript/spec/component/code-editor/{code-editor-instructions.spec.ts => code-editor-instructions.component.spec.ts} (100%) rename src/test/javascript/spec/component/code-editor/{code-editor-status.spec.ts => code-editor-status.component.spec.ts} (100%) rename src/test/javascript/spec/component/complaints-for-tutor/{complaints-for-tutor.spec.ts => complaints-for-tutor.component.spec.ts} (100%) rename src/test/javascript/spec/component/complaints/{complaints.spec.ts => complaints.component.spec.ts} (100%) rename src/test/javascript/spec/component/file-upload-assessment/{file-upload-assessment.spec.ts => file-upload-assessment.component.spec.ts} (100%) rename src/test/javascript/spec/component/file-upload-submission/{file-upload-result.spec.ts => file-upload-result.component.spec.ts} (98%) rename src/test/javascript/spec/component/file-upload-submission/{file-upload-submission.spec.ts => file-upload-submission.component.spec.ts} (100%) rename src/test/javascript/spec/component/instructor-dashboard/{instructor-exercise-dashboard.spec.ts => instructor-exercise-dashboard.component.spec.ts} (100%) rename src/test/javascript/spec/component/lecture/{lecture-attachments.spec.ts => lecture-attachments.component.spec.ts} (100%) rename src/test/javascript/spec/component/list-of-complaints/{list-of-complaints.spec.ts => list-of-complaints.component.spec.ts} (100%) rename src/test/javascript/spec/component/markdown-editor/{gradingInstruction-command.spec.ts => gradingInstruction-command.component.spec.ts} (100%) rename src/test/javascript/spec/component/overview/course-exercises/{course-exercise-row.spec.ts => course-exercise-row.component.spec.ts} (100%) rename src/test/javascript/spec/component/overview/course-statistics/{course-statistics.spec.ts => course-statistics.component.spec.ts} (100%) rename src/test/javascript/spec/component/overview/exercise-details/{exercise-details-student-actions.spec.ts => exercise-details-student-actions.component.spec.ts} (100%) rename src/test/javascript/spec/component/overview/exercise-details/{programming-exercise-student-ide-actions.spec.ts => programming-exercise-student-ide-actions.component.spec.ts} (100%) rename src/test/javascript/spec/component/participation-submission/{participation-submission.spec.ts => participation-submission.component.spec.ts} (100%) rename src/test/javascript/spec/component/programming-assessment/{programming-assessment-manual-result-dialog.component.ts => programming-assessment-manual-result-dialog.component.spec.ts} (100%) rename src/test/javascript/spec/component/programming-exercise/{programming-exercise-editable-instruction.spec.ts => programming-exercise-editable-instruction.component.spec.ts} (100%) rename src/test/javascript/spec/component/programming-exercise/{programming-exercise-import.spec.ts => programming-exercise-import.component.spec.ts} (100%) rename src/test/javascript/spec/component/programming-exercise/{programming-exercise-instruction-analysis.spec.ts => programming-exercise-instruction-analysis.component.spec.ts} (100%) rename src/test/javascript/spec/component/programming-exercise/{programming-exercise-instruction-step-wizard.spec.ts => programming-exercise-instruction-step-wizard.component.spec.ts} (98%) rename src/test/javascript/spec/component/programming-exercise/{programming-exercise-instruction.spec.ts => programming-exercise-instruction.component.spec.ts} (100%) rename src/test/javascript/spec/component/programming-exercise/{programming-exercise-instructor-status.spec.ts => programming-exercise-instructor-status.component.spec.ts} (100%) rename src/test/javascript/spec/component/programming-exercise/{programming-exercise-instructor-submission-state.spec.ts => programming-exercise-instructor-submission-state.component.spec.ts} (99%) rename src/test/javascript/spec/component/programming-exercise/{programming-exercise-manage-test-cases.spec.ts => programming-exercise-manage-test-cases.component.spec.ts} (99%) rename src/test/javascript/spec/component/programming-exercise/{programming-exercise-test-schedule-picker.spec.ts => programming-exercise-test-schedule-picker.component.spec.ts} (100%) rename src/test/javascript/spec/component/programming-exercise/{programming-exercise-trigger-build-button.spec.ts => programming-exercise-trigger-build-button.component.spec.ts} (100%) rename src/test/javascript/spec/component/shared/{button-component.spec.ts => button.component.spec.ts} (100%) rename src/test/javascript/spec/component/shared/{delete-dialog.spec.ts => delete-dialog.component.spec.ts} (100%) rename src/test/javascript/spec/component/shared/{result-detail.spec.ts => result-detail.component.spec.ts} (100%) rename src/test/javascript/spec/component/shared/{secured-image.spec.ts => secured-image.component.spec.ts} (100%) rename src/test/javascript/spec/component/shared/{updating-result.spec.ts => updating-result.component.spec.ts} (100%) rename src/test/javascript/spec/component/table/{table-editable-checkbox.spec.ts => table-editable-checkbox.component.spec.ts} (100%) rename src/test/javascript/spec/component/table/{table-editable-field.spec.ts => table-editable-field.component.spec.ts} (100%) rename src/test/javascript/spec/component/team/{team-update-dialog.spec.ts => team-update-dialog.component.spec.ts} (100%) rename src/test/javascript/spec/component/team/{teams.spec.ts => teams.component.spec.ts} (100%) rename src/test/javascript/spec/component/text-editor/{text-editor.spec.ts => text-editor.component.spec.ts} (99%) rename src/test/javascript/spec/component/text-exercise-assessment/{text-exercise-assessement.spec.ts => text-exercise-assessement.component.spec.ts} (99%) rename src/test/javascript/spec/component/text-submission-assessment/{text-assessment-area.spec.ts => text-assessment-area.component.spec.ts} (100%) rename src/test/javascript/spec/component/text-submission-assessment/{text-submission-assessment.spec.ts => text-submission-assessment.component.spec.ts} (100%) rename src/test/javascript/spec/component/text-submission-assessment/{textblock-assessment-card.spec.ts => textblock-assessment-card.component.spec.ts} (100%) rename src/test/javascript/spec/component/text-submission-assessment/{textblock-feedback-editor.spec.ts => textblock-feedback-editor.component.spec.ts} (100%) rename src/test/javascript/spec/component/tutor-dashboard/{tutor-exercise-dashboard.spec.ts => tutor-exercise-dashboard.component.spec.ts} (100%) rename src/test/javascript/spec/service/{account-service.spec.ts => account.service.spec.ts} (100%) rename src/test/javascript/spec/service/{delete-dialog-service.spec.ts => delete-dialog.service.spec.ts} (100%) rename src/test/javascript/spec/service/{ide-build-and-test-service.spec.ts => ide-build-and-test.service.spec.ts} (100%) rename src/test/javascript/spec/service/{login-service.spec.ts => login.service.spec.ts} (100%) rename src/test/javascript/spec/service/{participation-websocket-service.spec.ts => participation-websocket.service.spec.ts} (100%) rename src/test/javascript/spec/service/{programming-exercise-instruction-analysis-service.spec.ts => programming-exercise-instruction-analysis.service.spec.ts} (100%) rename src/test/javascript/spec/service/{programming-exercise-instruction-service.spec.ts => programming-exercise-instruction.service.spec.ts} (100%) rename src/test/javascript/spec/service/{programming-exercise-test-case-service.spec.ts => programming-exercise-test-case.service.spec.ts} (100%) rename src/test/javascript/spec/service/{programming-submission-service.spec.ts => programming-submission.service.spec.ts} (100%) rename src/test/javascript/spec/service/{text-editor-service.spec.ts => text-editor.service.spec.ts} (100%) rename src/test/javascript/spec/service/{user-route-access-service.spec.ts => user-route-access.service.spec.ts} (100%) diff --git a/src/test/javascript/spec/component/admin/user-management.spec.ts b/src/test/javascript/spec/component/admin/user-management.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/admin/user-management.spec.ts rename to src/test/javascript/spec/component/admin/user-management.component.spec.ts diff --git a/src/test/javascript/spec/component/admin/admin.spec.ts b/src/test/javascript/spec/component/audits/audits.component.spec.ts similarity index 97% rename from src/test/javascript/spec/component/admin/admin.spec.ts rename to src/test/javascript/spec/component/audits/audits.component.spec.ts index 98d84834f234..e57ab35f7ec3 100644 --- a/src/test/javascript/spec/component/admin/admin.spec.ts +++ b/src/test/javascript/spec/component/audits/audits.component.spec.ts @@ -10,7 +10,7 @@ import { AuditsComponent } from 'app/admin/audits/audits.component'; chai.use(sinonChai); const expect = chai.expect; -describe('AdminModule', () => { +describe('AuditsComponent', () => { let comp: AuditsComponent; let fixture: ComponentFixture; diff --git a/src/test/javascript/spec/component/code-editor/code-editor-ace.spec.ts b/src/test/javascript/spec/component/code-editor/code-editor-ace.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/code-editor/code-editor-ace.spec.ts rename to src/test/javascript/spec/component/code-editor/code-editor-ace.component.spec.ts diff --git a/src/test/javascript/spec/component/code-editor/code-editor-actions.spec.ts b/src/test/javascript/spec/component/code-editor/code-editor-actions.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/code-editor/code-editor-actions.spec.ts rename to src/test/javascript/spec/component/code-editor/code-editor-actions.component.spec.ts diff --git a/src/test/javascript/spec/component/code-editor/code-editor-build-output.spec.ts b/src/test/javascript/spec/component/code-editor/code-editor-build-output.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/code-editor/code-editor-build-output.spec.ts rename to src/test/javascript/spec/component/code-editor/code-editor-build-output.component.spec.ts diff --git a/src/test/javascript/spec/component/code-editor/code-editor-file-browser.spec.ts b/src/test/javascript/spec/component/code-editor/code-editor-file-browser.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/code-editor/code-editor-file-browser.spec.ts rename to src/test/javascript/spec/component/code-editor/code-editor-file-browser.component.spec.ts diff --git a/src/test/javascript/spec/component/code-editor/code-editor-instructions.spec.ts b/src/test/javascript/spec/component/code-editor/code-editor-instructions.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/code-editor/code-editor-instructions.spec.ts rename to src/test/javascript/spec/component/code-editor/code-editor-instructions.component.spec.ts diff --git a/src/test/javascript/spec/component/code-editor/code-editor-status.spec.ts b/src/test/javascript/spec/component/code-editor/code-editor-status.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/code-editor/code-editor-status.spec.ts rename to src/test/javascript/spec/component/code-editor/code-editor-status.component.spec.ts diff --git a/src/test/javascript/spec/component/complaints-for-tutor/complaints-for-tutor.spec.ts b/src/test/javascript/spec/component/complaints-for-tutor/complaints-for-tutor.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/complaints-for-tutor/complaints-for-tutor.spec.ts rename to src/test/javascript/spec/component/complaints-for-tutor/complaints-for-tutor.component.spec.ts diff --git a/src/test/javascript/spec/component/complaints/complaints.spec.ts b/src/test/javascript/spec/component/complaints/complaints.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/complaints/complaints.spec.ts rename to src/test/javascript/spec/component/complaints/complaints.component.spec.ts diff --git a/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.spec.ts b/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.spec.ts rename to src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.component.spec.ts diff --git a/src/test/javascript/spec/component/file-upload-submission/file-upload-result.spec.ts b/src/test/javascript/spec/component/file-upload-submission/file-upload-result.component.spec.ts similarity index 98% rename from src/test/javascript/spec/component/file-upload-submission/file-upload-result.spec.ts rename to src/test/javascript/spec/component/file-upload-submission/file-upload-result.component.spec.ts index 8dd0a1b957cb..bca9e2a4788b 100644 --- a/src/test/javascript/spec/component/file-upload-submission/file-upload-result.spec.ts +++ b/src/test/javascript/spec/component/file-upload-submission/file-upload-result.component.spec.ts @@ -19,7 +19,7 @@ import { Feedback } from 'app/entities/feedback.model'; chai.use(sinonChai); const expect = chai.expect; -describe('FileUploadSubmissionComponent', () => { +describe('FileUploadResultComponent', () => { let comp: FileUploadResultComponent; let fixture: ComponentFixture; let debugElement: DebugElement; diff --git a/src/test/javascript/spec/component/file-upload-submission/file-upload-submission.spec.ts b/src/test/javascript/spec/component/file-upload-submission/file-upload-submission.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/file-upload-submission/file-upload-submission.spec.ts rename to src/test/javascript/spec/component/file-upload-submission/file-upload-submission.component.spec.ts diff --git a/src/test/javascript/spec/component/instructor-dashboard/instructor-exercise-dashboard.spec.ts b/src/test/javascript/spec/component/instructor-dashboard/instructor-exercise-dashboard.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/instructor-dashboard/instructor-exercise-dashboard.spec.ts rename to src/test/javascript/spec/component/instructor-dashboard/instructor-exercise-dashboard.component.spec.ts diff --git a/src/test/javascript/spec/component/lecture/lecture-attachments.spec.ts b/src/test/javascript/spec/component/lecture/lecture-attachments.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/lecture/lecture-attachments.spec.ts rename to src/test/javascript/spec/component/lecture/lecture-attachments.component.spec.ts diff --git a/src/test/javascript/spec/component/list-of-complaints/list-of-complaints.spec.ts b/src/test/javascript/spec/component/list-of-complaints/list-of-complaints.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/list-of-complaints/list-of-complaints.spec.ts rename to src/test/javascript/spec/component/list-of-complaints/list-of-complaints.component.spec.ts diff --git a/src/test/javascript/spec/component/markdown-editor/gradingInstruction-command.spec.ts b/src/test/javascript/spec/component/markdown-editor/gradingInstruction-command.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/markdown-editor/gradingInstruction-command.spec.ts rename to src/test/javascript/spec/component/markdown-editor/gradingInstruction-command.component.spec.ts diff --git a/src/test/javascript/spec/component/overview/course-exercises/course-exercise-row.spec.ts b/src/test/javascript/spec/component/overview/course-exercises/course-exercise-row.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/overview/course-exercises/course-exercise-row.spec.ts rename to src/test/javascript/spec/component/overview/course-exercises/course-exercise-row.component.spec.ts diff --git a/src/test/javascript/spec/component/overview/course-statistics/course-statistics.spec.ts b/src/test/javascript/spec/component/overview/course-statistics/course-statistics.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/overview/course-statistics/course-statistics.spec.ts rename to src/test/javascript/spec/component/overview/course-statistics/course-statistics.component.spec.ts diff --git a/src/test/javascript/spec/component/overview/exercise-details/exercise-details-student-actions.spec.ts b/src/test/javascript/spec/component/overview/exercise-details/exercise-details-student-actions.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/overview/exercise-details/exercise-details-student-actions.spec.ts rename to src/test/javascript/spec/component/overview/exercise-details/exercise-details-student-actions.component.spec.ts diff --git a/src/test/javascript/spec/component/overview/exercise-details/programming-exercise-student-ide-actions.spec.ts b/src/test/javascript/spec/component/overview/exercise-details/programming-exercise-student-ide-actions.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/overview/exercise-details/programming-exercise-student-ide-actions.spec.ts rename to src/test/javascript/spec/component/overview/exercise-details/programming-exercise-student-ide-actions.component.spec.ts diff --git a/src/test/javascript/spec/component/participation-submission/participation-submission.spec.ts b/src/test/javascript/spec/component/participation-submission/participation-submission.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/participation-submission/participation-submission.spec.ts rename to src/test/javascript/spec/component/participation-submission/participation-submission.component.spec.ts diff --git a/src/test/javascript/spec/component/programming-assessment/programming-assessment-manual-result-dialog.component.ts b/src/test/javascript/spec/component/programming-assessment/programming-assessment-manual-result-dialog.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/programming-assessment/programming-assessment-manual-result-dialog.component.ts rename to src/test/javascript/spec/component/programming-assessment/programming-assessment-manual-result-dialog.component.spec.ts diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-editable-instruction.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-editable-instruction.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/programming-exercise/programming-exercise-editable-instruction.spec.ts rename to src/test/javascript/spec/component/programming-exercise/programming-exercise-editable-instruction.component.spec.ts diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-import.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-import.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/programming-exercise/programming-exercise-import.spec.ts rename to src/test/javascript/spec/component/programming-exercise/programming-exercise-import.component.spec.ts diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-analysis.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-analysis.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-analysis.spec.ts rename to src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-analysis.component.spec.ts diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-step-wizard.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-step-wizard.component.spec.ts similarity index 98% rename from src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-step-wizard.spec.ts rename to src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-step-wizard.component.spec.ts index 9b99565f07a0..11df73614022 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-step-wizard.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-step-wizard.component.spec.ts @@ -16,7 +16,7 @@ import { Task } from 'app/exercises/programming/shared/instructions-render/task/ chai.use(sinonChai); const expect = chai.expect; -describe('ProgrammingExerciseInstructionStepWizard', () => { +describe('ProgrammingExerciseInstructionStepWizardComponent', () => { let comp: ProgrammingExerciseInstructionStepWizardComponent; let fixture: ComponentFixture; let debugElement: DebugElement; diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction.spec.ts rename to src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction.component.spec.ts diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-status.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-status.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-status.spec.ts rename to src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-status.component.spec.ts diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-submission-state.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-submission-state.component.spec.ts similarity index 99% rename from src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-submission-state.spec.ts rename to src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-submission-state.component.spec.ts index 0e7eddaed233..f8a709636f60 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-submission-state.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-submission-state.component.spec.ts @@ -26,7 +26,7 @@ import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; chai.use(sinonChai); const expect = chai.expect; -describe('ProgrammingExerciseInstructorSubmissionState', () => { +describe('ProgrammingExerciseInstructorSubmissionStateComponent', () => { let comp: ProgrammingExerciseInstructorSubmissionStateComponent; let fixture: ComponentFixture; let debugElement: DebugElement; diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-manage-test-cases.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-manage-test-cases.component.spec.ts similarity index 99% rename from src/test/javascript/spec/component/programming-exercise/programming-exercise-manage-test-cases.spec.ts rename to src/test/javascript/spec/component/programming-exercise/programming-exercise-manage-test-cases.component.spec.ts index 22b2c190460c..e37ace02bebd 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-manage-test-cases.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-manage-test-cases.component.spec.ts @@ -38,7 +38,7 @@ const expect = chai.expect; // TODO: Since the update to v.16 all tests for the ngx-swimlane table need to add a 0 tick to avoid the ViewDestroyedError. // The issue is a manual call to changeDetector.detectChanges that is triggered on a timeout. -describe('ProgrammingExerciseManageTestCases', () => { +describe('ProgrammingExerciseManageTestCasesComponent', () => { let comp: ProgrammingExerciseManageTestCasesComponent; let fixture: ComponentFixture; let debugElement: DebugElement; diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-test-schedule-picker.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-test-schedule-picker.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/programming-exercise/programming-exercise-test-schedule-picker.spec.ts rename to src/test/javascript/spec/component/programming-exercise/programming-exercise-test-schedule-picker.component.spec.ts diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-trigger-build-button.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-trigger-build-button.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/programming-exercise/programming-exercise-trigger-build-button.spec.ts rename to src/test/javascript/spec/component/programming-exercise/programming-exercise-trigger-build-button.component.spec.ts diff --git a/src/test/javascript/spec/component/shared/button-component.spec.ts b/src/test/javascript/spec/component/shared/button.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/shared/button-component.spec.ts rename to src/test/javascript/spec/component/shared/button.component.spec.ts diff --git a/src/test/javascript/spec/component/shared/delete-dialog.spec.ts b/src/test/javascript/spec/component/shared/delete-dialog.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/shared/delete-dialog.spec.ts rename to src/test/javascript/spec/component/shared/delete-dialog.component.spec.ts diff --git a/src/test/javascript/spec/component/shared/result-detail.spec.ts b/src/test/javascript/spec/component/shared/result-detail.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/shared/result-detail.spec.ts rename to src/test/javascript/spec/component/shared/result-detail.component.spec.ts diff --git a/src/test/javascript/spec/component/shared/secured-image.spec.ts b/src/test/javascript/spec/component/shared/secured-image.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/shared/secured-image.spec.ts rename to src/test/javascript/spec/component/shared/secured-image.component.spec.ts diff --git a/src/test/javascript/spec/component/shared/updating-result.spec.ts b/src/test/javascript/spec/component/shared/updating-result.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/shared/updating-result.spec.ts rename to src/test/javascript/spec/component/shared/updating-result.component.spec.ts diff --git a/src/test/javascript/spec/component/table/table-editable-checkbox.spec.ts b/src/test/javascript/spec/component/table/table-editable-checkbox.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/table/table-editable-checkbox.spec.ts rename to src/test/javascript/spec/component/table/table-editable-checkbox.component.spec.ts diff --git a/src/test/javascript/spec/component/table/table-editable-field.spec.ts b/src/test/javascript/spec/component/table/table-editable-field.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/table/table-editable-field.spec.ts rename to src/test/javascript/spec/component/table/table-editable-field.component.spec.ts diff --git a/src/test/javascript/spec/component/team/team-update-dialog.spec.ts b/src/test/javascript/spec/component/team/team-update-dialog.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/team/team-update-dialog.spec.ts rename to src/test/javascript/spec/component/team/team-update-dialog.component.spec.ts diff --git a/src/test/javascript/spec/component/team/teams.spec.ts b/src/test/javascript/spec/component/team/teams.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/team/teams.spec.ts rename to src/test/javascript/spec/component/team/teams.component.spec.ts diff --git a/src/test/javascript/spec/component/text-editor/text-editor.spec.ts b/src/test/javascript/spec/component/text-editor/text-editor.component.spec.ts similarity index 99% rename from src/test/javascript/spec/component/text-editor/text-editor.spec.ts rename to src/test/javascript/spec/component/text-editor/text-editor.component.spec.ts index 287ed938c085..9b4f6e6aa5df 100644 --- a/src/test/javascript/spec/component/text-editor/text-editor.spec.ts +++ b/src/test/javascript/spec/component/text-editor/text-editor.component.spec.ts @@ -33,7 +33,7 @@ import { ArtemisHeaderExercisePageWithDetailsModule } from 'app/exercises/shared chai.use(sinonChai); const expect = chai.expect; -describe('TableEditableFieldComponent', () => { +describe('TextEditorComponent', () => { let comp: TextEditorComponent; let fixture: ComponentFixture; let debugElement: DebugElement; diff --git a/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.spec.ts b/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.component.spec.ts similarity index 99% rename from src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.spec.ts rename to src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.component.spec.ts index 9918818889d1..9aedd28b99c5 100644 --- a/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.spec.ts +++ b/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.component.spec.ts @@ -47,7 +47,7 @@ import { AssessmentGeneralFeedbackComponent } from 'app/assessment/assessment-ge chai.use(sinonChai); const expect = chai.expect; -describe('TextAssessmentComponent', () => { +describe('TextExerciseAssessmentComponent', () => { let comp: TextAssessmentComponent; let fixture: ComponentFixture; let textSubmissionService: TextSubmissionService; diff --git a/src/test/javascript/spec/component/text-submission-assessment/text-assessment-area.spec.ts b/src/test/javascript/spec/component/text-submission-assessment/text-assessment-area.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/text-submission-assessment/text-assessment-area.spec.ts rename to src/test/javascript/spec/component/text-submission-assessment/text-assessment-area.component.spec.ts diff --git a/src/test/javascript/spec/component/text-submission-assessment/text-submission-assessment.spec.ts b/src/test/javascript/spec/component/text-submission-assessment/text-submission-assessment.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/text-submission-assessment/text-submission-assessment.spec.ts rename to src/test/javascript/spec/component/text-submission-assessment/text-submission-assessment.component.spec.ts diff --git a/src/test/javascript/spec/component/text-submission-assessment/textblock-assessment-card.spec.ts b/src/test/javascript/spec/component/text-submission-assessment/textblock-assessment-card.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/text-submission-assessment/textblock-assessment-card.spec.ts rename to src/test/javascript/spec/component/text-submission-assessment/textblock-assessment-card.component.spec.ts diff --git a/src/test/javascript/spec/component/text-submission-assessment/textblock-feedback-editor.spec.ts b/src/test/javascript/spec/component/text-submission-assessment/textblock-feedback-editor.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/text-submission-assessment/textblock-feedback-editor.spec.ts rename to src/test/javascript/spec/component/text-submission-assessment/textblock-feedback-editor.component.spec.ts diff --git a/src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.spec.ts b/src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.component.spec.ts similarity index 100% rename from src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.spec.ts rename to src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.component.spec.ts diff --git a/src/test/javascript/spec/service/account-service.spec.ts b/src/test/javascript/spec/service/account.service.spec.ts similarity index 100% rename from src/test/javascript/spec/service/account-service.spec.ts rename to src/test/javascript/spec/service/account.service.spec.ts diff --git a/src/test/javascript/spec/service/delete-dialog-service.spec.ts b/src/test/javascript/spec/service/delete-dialog.service.spec.ts similarity index 100% rename from src/test/javascript/spec/service/delete-dialog-service.spec.ts rename to src/test/javascript/spec/service/delete-dialog.service.spec.ts diff --git a/src/test/javascript/spec/service/ide-build-and-test-service.spec.ts b/src/test/javascript/spec/service/ide-build-and-test.service.spec.ts similarity index 100% rename from src/test/javascript/spec/service/ide-build-and-test-service.spec.ts rename to src/test/javascript/spec/service/ide-build-and-test.service.spec.ts diff --git a/src/test/javascript/spec/service/login-service.spec.ts b/src/test/javascript/spec/service/login.service.spec.ts similarity index 100% rename from src/test/javascript/spec/service/login-service.spec.ts rename to src/test/javascript/spec/service/login.service.spec.ts diff --git a/src/test/javascript/spec/service/participation-websocket-service.spec.ts b/src/test/javascript/spec/service/participation-websocket.service.spec.ts similarity index 100% rename from src/test/javascript/spec/service/participation-websocket-service.spec.ts rename to src/test/javascript/spec/service/participation-websocket.service.spec.ts diff --git a/src/test/javascript/spec/service/programming-exercise-instruction-analysis-service.spec.ts b/src/test/javascript/spec/service/programming-exercise-instruction-analysis.service.spec.ts similarity index 100% rename from src/test/javascript/spec/service/programming-exercise-instruction-analysis-service.spec.ts rename to src/test/javascript/spec/service/programming-exercise-instruction-analysis.service.spec.ts diff --git a/src/test/javascript/spec/service/programming-exercise-instruction-service.spec.ts b/src/test/javascript/spec/service/programming-exercise-instruction.service.spec.ts similarity index 100% rename from src/test/javascript/spec/service/programming-exercise-instruction-service.spec.ts rename to src/test/javascript/spec/service/programming-exercise-instruction.service.spec.ts diff --git a/src/test/javascript/spec/service/programming-exercise-test-case-service.spec.ts b/src/test/javascript/spec/service/programming-exercise-test-case.service.spec.ts similarity index 100% rename from src/test/javascript/spec/service/programming-exercise-test-case-service.spec.ts rename to src/test/javascript/spec/service/programming-exercise-test-case.service.spec.ts diff --git a/src/test/javascript/spec/service/programming-submission-service.spec.ts b/src/test/javascript/spec/service/programming-submission.service.spec.ts similarity index 100% rename from src/test/javascript/spec/service/programming-submission-service.spec.ts rename to src/test/javascript/spec/service/programming-submission.service.spec.ts diff --git a/src/test/javascript/spec/service/text-editor-service.spec.ts b/src/test/javascript/spec/service/text-editor.service.spec.ts similarity index 100% rename from src/test/javascript/spec/service/text-editor-service.spec.ts rename to src/test/javascript/spec/service/text-editor.service.spec.ts diff --git a/src/test/javascript/spec/service/user-route-access-service.spec.ts b/src/test/javascript/spec/service/user-route-access.service.spec.ts similarity index 100% rename from src/test/javascript/spec/service/user-route-access-service.spec.ts rename to src/test/javascript/spec/service/user-route-access.service.spec.ts From 8b5a625686d851c82e5ba8028c7e3890829ff7be Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Thu, 23 Apr 2020 22:30:10 +0200 Subject: [PATCH 084/152] Remove unnecessary /* tslint:disable:no-unused-expression */ --- .../spec/component/admin/user-management.component.spec.ts | 4 ++-- .../javascript/spec/component/audits/audits.component.spec.ts | 4 ++-- .../spec/component/markdown-editor/katex-command.spec.ts | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/test/javascript/spec/component/admin/user-management.component.spec.ts b/src/test/javascript/spec/component/admin/user-management.component.spec.ts index eb4fb89b5518..b49be19d9a96 100644 --- a/src/test/javascript/spec/component/admin/user-management.component.spec.ts +++ b/src/test/javascript/spec/component/admin/user-management.component.spec.ts @@ -1,4 +1,3 @@ -/* tslint:disable:no-unused-expression */ import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; import { TranslateModule } from '@ngx-translate/core'; import * as chai from 'chai'; @@ -33,7 +32,8 @@ describe('UserManagementComponent', () => { }); }); - // The admin module is lazy loaded - we therefore need a dummy test to load the module and verify that there are no dependency related issues. + // The admin module is lazy loaded - we therefore need a dummy test to load + // the module and verify that there are no dependency related issues. it('should render a component from the admin module', () => { expect(comp).to.exist; }); diff --git a/src/test/javascript/spec/component/audits/audits.component.spec.ts b/src/test/javascript/spec/component/audits/audits.component.spec.ts index e57ab35f7ec3..56c22e88c1b0 100644 --- a/src/test/javascript/spec/component/audits/audits.component.spec.ts +++ b/src/test/javascript/spec/component/audits/audits.component.spec.ts @@ -1,4 +1,3 @@ -/* tslint:disable:no-unused-expression */ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { TranslateModule } from '@ngx-translate/core'; import * as chai from 'chai'; @@ -25,7 +24,8 @@ describe('AuditsComponent', () => { }); }); - // The admin module is lazy loaded - we therefore need a dummy test to load the module and verify that there are no dependency related issues. + // The admin module is lazy loaded - we therefore need a dummy test to load + // the module and verify that there are no dependency related issues. it('should render a component from the admin module', () => { expect(comp).to.exist; }); diff --git a/src/test/javascript/spec/component/markdown-editor/katex-command.spec.ts b/src/test/javascript/spec/component/markdown-editor/katex-command.spec.ts index 95574b18157e..271c5243d45f 100644 --- a/src/test/javascript/spec/component/markdown-editor/katex-command.spec.ts +++ b/src/test/javascript/spec/component/markdown-editor/katex-command.spec.ts @@ -1,4 +1,3 @@ -/* tslint:disable:no-unused-expression */ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { TranslateModule } from '@ngx-translate/core'; import * as chai from 'chai'; From 1c0d8250c57e7f88bb701ff7dba606c614e3dd40 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Thu, 23 Apr 2020 22:31:43 +0200 Subject: [PATCH 085/152] Fix new code style issues --- .../exercise-headers/header-participation-page.component.ts | 2 +- .../text/assess-new/text-submission-assessment.component.ts | 2 +- .../programming-exercise/programming-exercise.component.spec.ts | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/webapp/app/exercises/shared/exercise-headers/header-participation-page.component.ts b/src/main/webapp/app/exercises/shared/exercise-headers/header-participation-page.component.ts index db76499bec16..3d662180d223 100644 --- a/src/main/webapp/app/exercises/shared/exercise-headers/header-participation-page.component.ts +++ b/src/main/webapp/app/exercises/shared/exercise-headers/header-participation-page.component.ts @@ -30,7 +30,7 @@ export class HeaderParticipationPageComponent implements OnInit, OnChanges { this.exerciseCategories = this.exerciseService.convertExerciseCategoriesFromServer(this.exercise); } - ngOnChanges(changes: SimpleChanges): void { + ngOnChanges(): void { this.setExerciseStatusBadge(); this.exerciseCategories = this.exerciseService.convertExerciseCategoriesFromServer(this.exercise); } diff --git a/src/main/webapp/app/exercises/text/assess-new/text-submission-assessment.component.ts b/src/main/webapp/app/exercises/text/assess-new/text-submission-assessment.component.ts index 495931af4c58..7d98b64fb789 100644 --- a/src/main/webapp/app/exercises/text/assess-new/text-submission-assessment.component.ts +++ b/src/main/webapp/app/exercises/text/assess-new/text-submission-assessment.component.ts @@ -10,7 +10,7 @@ import { StudentParticipation } from 'app/entities/participation/student-partici import { TextSubmission } from 'app/entities/text-submission.model'; import { TextExercise } from 'app/entities/text-exercise.model'; import { Result } from 'app/entities/result.model'; -import { Complaint, ComplaintType } from 'app/entities/complaint.model'; +import { Complaint } from 'app/entities/complaint.model'; import { ComplaintResponse } from 'app/entities/complaint-response.model'; import { ComplaintService } from 'app/complaints/complaint.service'; import { TextAssessmentsService } from 'app/exercises/text/assess/text-assessments.service'; diff --git a/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.component.spec.ts b/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.component.spec.ts index 4384cdf9870a..ed35cc20fd43 100644 --- a/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.component.spec.ts +++ b/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.component.spec.ts @@ -4,7 +4,6 @@ import { of } from 'rxjs'; import { ArtemisTestModule } from '../../../test.module'; import { ProgrammingExerciseComponent } from 'app/exercises/programming/manage/programming-exercise.component'; -import { ProgrammingExerciseService } from 'app/exercises/programming/manage/services/programming-exercise.service'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; import { MockSyncStorage } from '../../../mocks/mock-sync.storage'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; From 8b4a51eff7dc69e349e9ce7522865110b71ce32d Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Thu, 23 Apr 2020 22:34:56 +0200 Subject: [PATCH 086/152] Add integration identifier to all test suites --- ...tructor.spec.ts => code-editor-instructor.integration.spec.ts} | 0 ...or-student.spec.ts => code-editor-student.integration.spec.ts} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/test/javascript/spec/integration/code-editor/{code-editor-instructor.spec.ts => code-editor-instructor.integration.spec.ts} (100%) rename src/test/javascript/spec/integration/code-editor/{code-editor-student.spec.ts => code-editor-student.integration.spec.ts} (100%) diff --git a/src/test/javascript/spec/integration/code-editor/code-editor-instructor.spec.ts b/src/test/javascript/spec/integration/code-editor/code-editor-instructor.integration.spec.ts similarity index 100% rename from src/test/javascript/spec/integration/code-editor/code-editor-instructor.spec.ts rename to src/test/javascript/spec/integration/code-editor/code-editor-instructor.integration.spec.ts diff --git a/src/test/javascript/spec/integration/code-editor/code-editor-student.spec.ts b/src/test/javascript/spec/integration/code-editor/code-editor-student.integration.spec.ts similarity index 100% rename from src/test/javascript/spec/integration/code-editor/code-editor-student.spec.ts rename to src/test/javascript/spec/integration/code-editor/code-editor-student.integration.spec.ts From 7ca48693c0c55c72abadf940d9768ff8956bfac4 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Fri, 24 Apr 2020 00:03:39 +0200 Subject: [PATCH 087/152] Assign all files in component directory to correct folder --- src/test/javascript/jest.config.js | 1 + .../programming-exercise/build-plan-link.directive.spec.ts | 0 .../shared/delete-dialog.directive.spec.ts} | 0 .../exercise-hint => service}/exercise-hint.service.spec.ts | 0 .../orion-version-validator.service.spec.ts | 6 +++--- .../student-question-answer.service.spec.ts | 0 .../student-question.service.spec.ts | 0 7 files changed, 4 insertions(+), 3 deletions(-) rename src/test/javascript/spec/{component => directive}/programming-exercise/build-plan-link.directive.spec.ts (100%) rename src/test/javascript/spec/{component/shared/delete-dialog-directive.spec.ts => directive/shared/delete-dialog.directive.spec.ts} (100%) rename src/test/javascript/spec/{component/exercise-hint => service}/exercise-hint.service.spec.ts (100%) rename src/test/javascript/spec/{component/orion => service}/orion-version-validator.service.spec.ts (93%) rename src/test/javascript/spec/{component/student-questions => service}/student-question-answer.service.spec.ts (100%) rename src/test/javascript/spec/{component/student-questions => service}/student-question.service.spec.ts (100%) diff --git a/src/test/javascript/jest.config.js b/src/test/javascript/jest.config.js index 3fbbab84f76c..2f2db92bd97b 100644 --- a/src/test/javascript/jest.config.js +++ b/src/test/javascript/jest.config.js @@ -16,6 +16,7 @@ module.exports = { testMatch: [ '/src/test/javascript/spec/app/**/*.ts', '/src/test/javascript/spec/component/**/*.ts', + '/src/test/javascript/spec/directive/**/*.ts', '/src/test/javascript/spec/integration/**/*.ts', '/src/test/javascript/spec/service/**/*.ts', ], diff --git a/src/test/javascript/spec/component/programming-exercise/build-plan-link.directive.spec.ts b/src/test/javascript/spec/directive/programming-exercise/build-plan-link.directive.spec.ts similarity index 100% rename from src/test/javascript/spec/component/programming-exercise/build-plan-link.directive.spec.ts rename to src/test/javascript/spec/directive/programming-exercise/build-plan-link.directive.spec.ts diff --git a/src/test/javascript/spec/component/shared/delete-dialog-directive.spec.ts b/src/test/javascript/spec/directive/shared/delete-dialog.directive.spec.ts similarity index 100% rename from src/test/javascript/spec/component/shared/delete-dialog-directive.spec.ts rename to src/test/javascript/spec/directive/shared/delete-dialog.directive.spec.ts diff --git a/src/test/javascript/spec/component/exercise-hint/exercise-hint.service.spec.ts b/src/test/javascript/spec/service/exercise-hint.service.spec.ts similarity index 100% rename from src/test/javascript/spec/component/exercise-hint/exercise-hint.service.spec.ts rename to src/test/javascript/spec/service/exercise-hint.service.spec.ts diff --git a/src/test/javascript/spec/component/orion/orion-version-validator.service.spec.ts b/src/test/javascript/spec/service/orion-version-validator.service.spec.ts similarity index 93% rename from src/test/javascript/spec/component/orion/orion-version-validator.service.spec.ts rename to src/test/javascript/spec/service/orion-version-validator.service.spec.ts index 4a5055b4cd55..d0b7e9da5f15 100644 --- a/src/test/javascript/spec/component/orion/orion-version-validator.service.spec.ts +++ b/src/test/javascript/spec/service/orion-version-validator.service.spec.ts @@ -4,9 +4,9 @@ import { SinonSpy, SinonStub, spy, stub } from 'sinon'; import { OrionVersionValidator } from 'app/shared/orion/outdated-plugin-warning/orion-version-validator.service'; import { ProfileService } from 'app/shared/layouts/profiles/profile.service'; import { Router } from '@angular/router'; -import { MockProfileService } from '../../mocks/mock-profile.service'; -import { MockWindowRef } from '../../mocks/mock-window.service'; -import { MockRouter } from '../../mocks/mock-router.service'; +import { MockProfileService } from '../mocks/mock-profile.service'; +import { MockWindowRef } from '../mocks/mock-window.service'; +import { MockRouter } from '../mocks/mock-router.service'; import { of } from 'rxjs'; import { ProfileInfo } from 'app/shared/layouts/profiles/profile-info.model'; diff --git a/src/test/javascript/spec/component/student-questions/student-question-answer.service.spec.ts b/src/test/javascript/spec/service/student-question-answer.service.spec.ts similarity index 100% rename from src/test/javascript/spec/component/student-questions/student-question-answer.service.spec.ts rename to src/test/javascript/spec/service/student-question-answer.service.spec.ts diff --git a/src/test/javascript/spec/component/student-questions/student-question.service.spec.ts b/src/test/javascript/spec/service/student-question.service.spec.ts similarity index 100% rename from src/test/javascript/spec/component/student-questions/student-question.service.spec.ts rename to src/test/javascript/spec/service/student-question.service.spec.ts From 3c956acab21922ae7dc4be9023dc2ebf7ab38f04 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Fri, 24 Apr 2020 00:07:26 +0200 Subject: [PATCH 088/152] Fix import in test.module.ts --- src/test/javascript/spec/test.module.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/javascript/spec/test.module.ts b/src/test/javascript/spec/test.module.ts index 78760642f531..4bd5759757e0 100644 --- a/src/test/javascript/spec/test.module.ts +++ b/src/test/javascript/spec/test.module.ts @@ -3,7 +3,7 @@ import { ActivatedRoute, Router } from '@angular/router'; import { ElementRef, NgModule, Renderer2 } from '@angular/core'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { NgbActiveModal, NgbModal, NgbDatepickerConfig } from '@ng-bootstrap/ng-bootstrap'; -import { AlertService, JhiDataUtils, JhiDateUtils, JhiEventManager, JhiLanguageService, JhiParseLinks } from 'ng-jhipster'; +import { JhiAlertService, JhiDataUtils, JhiDateUtils, JhiEventManager, JhiLanguageService, JhiParseLinks } from 'ng-jhipster'; import { MockLanguageHelper, MockLanguageService } from './helpers/mock-language.service'; import { JhiLanguageHelper } from 'app/core/language/language.helper'; @@ -65,7 +65,7 @@ import { MockComponent } from 'ng-mocks'; useValue: null, }, { - provide: AlertService, + provide: JhiAlertService, useValue: null, }, { From 42ae563e0a5a45710ea4e0ae4770876196aea1f8 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Fri, 24 Apr 2020 00:30:45 +0200 Subject: [PATCH 089/152] Remove duplicate mock for account.service --- .../settings/settings.component.spec.ts | 132 +++++++++--------- ...deling-assessment-editor.component.spec.ts | 2 +- .../spec/helpers/mock-account.service.ts | 29 ---- src/test/javascript/spec/test.module.ts | 2 +- 4 files changed, 67 insertions(+), 98 deletions(-) delete mode 100644 src/test/javascript/spec/helpers/mock-account.service.ts diff --git a/src/test/javascript/spec/app/account/settings/settings.component.spec.ts b/src/test/javascript/spec/app/account/settings/settings.component.spec.ts index 7067771c3f7a..d1b62621e0d7 100644 --- a/src/test/javascript/spec/app/account/settings/settings.component.spec.ts +++ b/src/test/javascript/spec/app/account/settings/settings.component.spec.ts @@ -6,86 +6,84 @@ import { ArtemisTestModule } from '../../../test.module'; import { AccountService } from 'app/core/auth/account.service'; import { Account } from 'app/core/user/account.model'; import { SettingsComponent } from 'app/account/settings/settings.component'; -import { MockAccountService } from '../../../helpers/mock-account.service'; +import { MockAccountService } from '../../../mocks/mock-account.service'; -describe('Component Tests', () => { - describe('SettingsComponent', () => { - let comp: SettingsComponent; - let fixture: ComponentFixture; - let mockAuth: MockAccountService; - const accountValues: Account = { +describe('SettingsComponent', () => { + let comp: SettingsComponent; + let fixture: ComponentFixture; + let mockAuth: MockAccountService; + const accountValues: Account = { + firstName: 'John', + lastName: 'Doe', + activated: true, + email: 'john.doe@mail.com', + name: 'john', + langKey: 'en', + login: 'john', + authorities: [], + imageUrl: '', + guidedTourSettings: [], + }; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [SettingsComponent], + providers: [FormBuilder], + }) + .overrideTemplate(SettingsComponent, '') + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(SettingsComponent); + comp = fixture.componentInstance; + mockAuth = TestBed.get(AccountService); + mockAuth.setIdentityResponse(accountValues); + }); + + it('should send the current identity upon save', () => { + // GIVEN + mockAuth.saveSpy.and.returnValue(of({})); + const settingsFormValues = { firstName: 'John', lastName: 'Doe', - activated: true, email: 'john.doe@mail.com', - name: 'john', langKey: 'en', - login: 'john', - authorities: [], - imageUrl: '', - guidedTourSettings: [], }; - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [SettingsComponent], - providers: [FormBuilder], - }) - .overrideTemplate(SettingsComponent, '') - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(SettingsComponent); - comp = fixture.componentInstance; - mockAuth = TestBed.get(AccountService); - mockAuth.setIdentityResponse(accountValues); - }); + // WHEN + comp.ngOnInit(); + comp.save(); - it('should send the current identity upon save', () => { - // GIVEN - mockAuth.saveSpy.and.returnValue(of({})); - const settingsFormValues = { - firstName: 'John', - lastName: 'Doe', - email: 'john.doe@mail.com', - langKey: 'en', - }; - - // WHEN - comp.ngOnInit(); - comp.save(); - - // THEN - expect(mockAuth.identitySpy).toHaveBeenCalled(); - expect(mockAuth.saveSpy).toHaveBeenCalledWith(accountValues); - expect(mockAuth.authenticateSpy).toHaveBeenCalledWith(accountValues); - expect(comp.settingsForm.value).toEqual(settingsFormValues); - }); + // THEN + expect(mockAuth.identitySpy).toHaveBeenCalled(); + expect(mockAuth.saveSpy).toHaveBeenCalledWith(accountValues); + expect(mockAuth.authenticateSpy).toHaveBeenCalledWith(accountValues); + expect(comp.settingsForm.value).toEqual(settingsFormValues); + }); - it('should notify of success upon successful save', () => { - // GIVEN - mockAuth.saveSpy.and.returnValue(of({})); + it('should notify of success upon successful save', () => { + // GIVEN + mockAuth.saveSpy.and.returnValue(of({})); - // WHEN - comp.ngOnInit(); - comp.save(); + // WHEN + comp.ngOnInit(); + comp.save(); - // THEN - expect(comp.success).toBe(true); - }); + // THEN + expect(comp.success).toBe(true); + }); - it('should notify of error upon failed save', () => { - // GIVEN - mockAuth.saveSpy.and.returnValue(throwError('ERROR')); + it('should notify of error upon failed save', () => { + // GIVEN + mockAuth.saveSpy.and.returnValue(throwError('ERROR')); - // WHEN - comp.ngOnInit(); - comp.save(); + // WHEN + comp.ngOnInit(); + comp.save(); - // THEN - expect(comp.success).toBe(false); - }); + // THEN + expect(comp.success).toBe(false); }); }); diff --git a/src/test/javascript/spec/component/modeling-assessment-editor/modeling-assessment-editor.component.spec.ts b/src/test/javascript/spec/component/modeling-assessment-editor/modeling-assessment-editor.component.spec.ts index ecf8fba98e4f..f59bdcf5be75 100644 --- a/src/test/javascript/spec/component/modeling-assessment-editor/modeling-assessment-editor.component.spec.ts +++ b/src/test/javascript/spec/component/modeling-assessment-editor/modeling-assessment-editor.component.spec.ts @@ -11,7 +11,7 @@ import { RouterTestingModule } from '@angular/router/testing'; import { User } from 'app/core/user/user.model'; import { JhiLanguageHelper } from 'app/core/language/language.helper'; import { AccountService } from 'app/core/auth/account.service'; -import { MockAccountService } from '../../helpers/mock-account.service'; +import { MockAccountService } from '../../mocks/mock-account.service'; import { AssessmentLayoutComponent } from 'app/assessment/assessment-layout/assessment-layout.component'; import { AssessmentHeaderComponent } from 'app/assessment/assessment-header/assessment-header.component'; import { Course } from 'app/entities/course.model'; diff --git a/src/test/javascript/spec/helpers/mock-account.service.ts b/src/test/javascript/spec/helpers/mock-account.service.ts deleted file mode 100644 index e52cc6a4f803..000000000000 --- a/src/test/javascript/spec/helpers/mock-account.service.ts +++ /dev/null @@ -1,29 +0,0 @@ -import Spy = jasmine.Spy; -import { of } from 'rxjs'; - -import { SpyObject } from './spyobject'; -import { AccountService } from 'app/core/auth/account.service'; -import { Account } from 'app/core/user/account.model'; - -export class MockAccountService extends SpyObject { - getSpy: Spy; - saveSpy: Spy; - authenticateSpy: Spy; - identitySpy: Spy; - getAuthenticationStateSpy: Spy; - - constructor() { - super(AccountService); - - this.getSpy = this.spy('get').andReturn(this); - this.saveSpy = this.spy('save').andReturn(this); - this.authenticateSpy = this.spy('authenticate').andReturn(this); - this.identitySpy = this.spy('identity').andReturn(of(null)); - this.getAuthenticationStateSpy = this.spy('getAuthenticationState').andReturn(of(null)); - } - - setIdentityResponse(account: Account | null): void { - this.identitySpy = this.spy('identity').andReturn(of(account)); - this.getAuthenticationStateSpy = this.spy('getAuthenticationState').andReturn(of(account)); - } -} diff --git a/src/test/javascript/spec/test.module.ts b/src/test/javascript/spec/test.module.ts index 4bd5759757e0..70baae055b67 100644 --- a/src/test/javascript/spec/test.module.ts +++ b/src/test/javascript/spec/test.module.ts @@ -8,7 +8,7 @@ import { JhiAlertService, JhiDataUtils, JhiDateUtils, JhiEventManager, JhiLangua import { MockLanguageHelper, MockLanguageService } from './helpers/mock-language.service'; import { JhiLanguageHelper } from 'app/core/language/language.helper'; import { AccountService } from 'app/core/auth/account.service'; -import { MockAccountService } from './helpers/mock-account.service'; +import { MockAccountService } from './mocks/mock-account.service'; import { MockActivatedRoute, MockRouter } from './helpers/mock-route.service'; import { MockActiveModal } from './helpers/mock-active-modal.service'; import { MockEventManager } from './helpers/mock-event-manager.service'; From 241ce001dc40ab1f7e9a9e9b1d40342af1db0133 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Fri, 24 Apr 2020 00:51:40 +0200 Subject: [PATCH 090/152] Delete unnecessary mock-websocket.service.ts --- .../javascript/spec/helpers/mock-websocket.service.ts | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 src/test/javascript/spec/helpers/mock-websocket.service.ts diff --git a/src/test/javascript/spec/helpers/mock-websocket.service.ts b/src/test/javascript/spec/helpers/mock-websocket.service.ts deleted file mode 100644 index 8f14acd63190..000000000000 --- a/src/test/javascript/spec/helpers/mock-websocket.service.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { SpyObject } from './spyobject'; -import { JhiWebsocketService } from 'app/core/websocket/websocket.service'; - -export class MockTrackerService extends SpyObject { - constructor() { - super(JhiWebsocketService); - } - - connect() {} -} From cda0f665ba4b1e70140e92aa76a6e89f9a75f2c3 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Fri, 24 Apr 2020 00:59:02 +0200 Subject: [PATCH 091/152] Move some activated route mocks from /helpers/ to /mocks/ --- .../file-upload-assessment.component.spec.ts | 2 +- .../modeling-assessment-editor.component.spec.ts | 2 +- .../component/participation/participation.component.spec.ts | 2 +- .../programming-exercise-manage-test-cases.component.spec.ts | 2 +- .../text-exercise-assessement.component.spec.ts | 2 +- .../tutor-dashboard/tutor-exercise-dashboard.component.spec.ts | 2 +- .../code-editor/code-editor-instructor.integration.spec.ts | 2 +- .../code-editor/code-editor-student.integration.spec.ts | 2 +- .../activated-route}/mock-activated-route-query-param-map.ts | 0 .../activated-route}/mock-activated-route-snapshot.ts | 0 .../spec/mocks/{ => activated-route}/mock-activated-route.ts | 0 .../spec/mocks/{ => activated-route}/mock-activated.route.ts | 0 .../javascript/spec/service/user-route-access.service.spec.ts | 2 +- 13 files changed, 9 insertions(+), 9 deletions(-) rename src/test/javascript/spec/{helpers => mocks/activated-route}/mock-activated-route-query-param-map.ts (100%) rename src/test/javascript/spec/{helpers => mocks/activated-route}/mock-activated-route-snapshot.ts (100%) rename src/test/javascript/spec/mocks/{ => activated-route}/mock-activated-route.ts (100%) rename src/test/javascript/spec/mocks/{ => activated-route}/mock-activated.route.ts (100%) diff --git a/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.component.spec.ts b/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.component.spec.ts index 00ed21c4e14f..51b0639b6e1d 100644 --- a/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.component.spec.ts +++ b/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.component.spec.ts @@ -35,7 +35,7 @@ import { ModelingAssessmentModule } from 'app/exercises/modeling/assess/modeling import { routes } from 'app/exercises/file-upload/assess/file-upload-assessment.route'; import { By } from '@angular/platform-browser'; import { throwError } from 'rxjs'; -import { MockActivatedRoute } from '../../mocks/mock-activated-route'; +import { MockActivatedRoute } from '../../mocks/activated-route/mock-activated-route'; import { Participation, ParticipationType } from 'app/entities/participation/participation.model'; chai.use(sinonChai); diff --git a/src/test/javascript/spec/component/modeling-assessment-editor/modeling-assessment-editor.component.spec.ts b/src/test/javascript/spec/component/modeling-assessment-editor/modeling-assessment-editor.component.spec.ts index f59bdcf5be75..27d6aaaa5a5d 100644 --- a/src/test/javascript/spec/component/modeling-assessment-editor/modeling-assessment-editor.component.spec.ts +++ b/src/test/javascript/spec/component/modeling-assessment-editor/modeling-assessment-editor.component.spec.ts @@ -3,7 +3,7 @@ import { TranslateModule } from '@ngx-translate/core'; import { ArtemisTestModule } from '../../test.module'; import { By } from '@angular/platform-browser'; -import { mockedActivatedRoute } from '../../helpers/mock-activated-route-query-param-map'; +import { mockedActivatedRoute } from '../../mocks/activated-route/mock-activated-route-query-param-map'; import { ActivatedRoute, convertToParamMap, ParamMap } from '@angular/router'; import { Mutable } from '../../helpers/mutable'; import { BehaviorSubject } from 'rxjs'; diff --git a/src/test/javascript/spec/component/participation/participation.component.spec.ts b/src/test/javascript/spec/component/participation/participation.component.spec.ts index 12d0ff625c66..886b6f9afb8a 100644 --- a/src/test/javascript/spec/component/participation/participation.component.spec.ts +++ b/src/test/javascript/spec/component/participation/participation.component.spec.ts @@ -5,7 +5,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { ArtemisTestModule } from '../../test.module'; import { ArtemisSharedModule } from 'app/shared/shared.module'; -import { MockActivatedRoute } from '../../mocks/mock-activated.route'; +import { MockActivatedRoute } from '../../mocks/activated-route/mock-activated.route'; import { MockSyncStorage } from '../../mocks/mock-sync.storage'; import { ParticipationService } from 'app/exercises/shared/participation/participation.service'; import { ParticipationComponent } from 'app/exercises/shared/participation/participation.component'; diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-manage-test-cases.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-manage-test-cases.component.spec.ts index e37ace02bebd..16d3924a1173 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-manage-test-cases.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-manage-test-cases.component.spec.ts @@ -29,7 +29,7 @@ import { EditableField, ProgrammingExerciseManageTestCasesComponent } from 'app/ import { ProgrammingExerciseService, ProgrammingExerciseTestCaseStateDTO } from 'app/exercises/programming/manage/services/programming-exercise.service'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; import { ProgrammingExerciseTestCaseService } from 'app/exercises/programming/manage/services/programming-exercise-test-case.service'; -import { MockActivatedRoute } from '../../mocks/mock-activated.route'; +import { MockActivatedRoute } from '../../mocks/activated-route/mock-activated.route'; import { MockCookieService } from '../../mocks/mock-cookie.service'; import { MockProgrammingExerciseService } from '../../mocks/mock-programming-exercise.service'; diff --git a/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.component.spec.ts b/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.component.spec.ts index 9aedd28b99c5..d85a08481c6e 100644 --- a/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.component.spec.ts +++ b/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.component.spec.ts @@ -36,7 +36,7 @@ import { Exercise, ExerciseType } from 'app/entities/exercise.model'; import { TextSubmission } from 'app/entities/text-submission.model'; import { Participation, ParticipationType } from 'app/entities/participation/participation.model'; import { AssessmentType } from 'app/entities/assessment-type.model'; -import { MockActivatedRoute } from '../../mocks/mock-activated-route'; +import { MockActivatedRoute } from '../../mocks/activated-route/mock-activated-route'; import { TextAssessmentsService } from 'app/exercises/text/assess/text-assessments.service'; import { Course } from 'app/entities/course.model'; import { Feedback } from 'app/entities/feedback.model'; diff --git a/src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.component.spec.ts b/src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.component.spec.ts index 7ff50d85cb5d..b9a8534404e8 100644 --- a/src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.component.spec.ts +++ b/src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.component.spec.ts @@ -4,7 +4,7 @@ import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; import { SinonStub, stub } from 'sinon'; import { ArtemisTestModule } from '../../test.module'; -import { MockActivatedRoute } from '../../mocks/mock-activated.route'; +import { MockActivatedRoute } from '../../mocks/activated-route/mock-activated.route'; import { MockSyncStorage } from '../../mocks/mock-sync.storage'; import { MockComponent } from 'ng-mocks'; import { ArtemisSharedModule } from 'app/shared/shared.module'; diff --git a/src/test/javascript/spec/integration/code-editor/code-editor-instructor.integration.spec.ts b/src/test/javascript/spec/integration/code-editor/code-editor-instructor.integration.spec.ts index 252fcf4f6ddf..a8511c63b91f 100644 --- a/src/test/javascript/spec/integration/code-editor/code-editor-instructor.integration.spec.ts +++ b/src/test/javascript/spec/integration/code-editor/code-editor-instructor.integration.spec.ts @@ -40,7 +40,7 @@ import { ParticipationService } from 'app/exercises/shared/participation/partici import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; import { ProgrammingExerciseStudentParticipation } from 'app/entities/participation/programming-exercise-student-participation.model'; import { SolutionProgrammingExerciseParticipation } from 'app/entities/participation/solution-programming-exercise-participation.model'; -import { MockActivatedRoute } from '../../mocks/mock-activated.route'; +import { MockActivatedRoute } from '../../mocks/activated-route/mock-activated.route'; import { MockSyncStorage } from '../../mocks/mock-sync.storage'; import { MockResultService } from '../../mocks/mock-result.service'; import { MockCodeEditorRepositoryService } from '../../mocks/mock-code-editor-repository.service'; diff --git a/src/test/javascript/spec/integration/code-editor/code-editor-student.integration.spec.ts b/src/test/javascript/spec/integration/code-editor/code-editor-student.integration.spec.ts index f7a7dec32e9a..0262ba739243 100644 --- a/src/test/javascript/spec/integration/code-editor/code-editor-student.integration.spec.ts +++ b/src/test/javascript/spec/integration/code-editor/code-editor-student.integration.spec.ts @@ -48,7 +48,7 @@ import { CodeEditorSessionService } from 'app/exercises/programming/shared/code- import { DomainService } from 'app/exercises/programming/shared/code-editor/service/code-editor-domain.service'; import { ProgrammingSubmission } from 'app/entities/programming-submission.model'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; -import { MockActivatedRoute } from '../../mocks/mock-activated.route'; +import { MockActivatedRoute } from '../../mocks/activated-route/mock-activated.route'; import { MockParticipationWebsocketService } from '../../mocks/mock-participation-websocket.service'; import { MockSyncStorage } from '../../mocks/mock-sync.storage'; import { MockResultService } from '../../mocks/mock-result.service'; diff --git a/src/test/javascript/spec/helpers/mock-activated-route-query-param-map.ts b/src/test/javascript/spec/mocks/activated-route/mock-activated-route-query-param-map.ts similarity index 100% rename from src/test/javascript/spec/helpers/mock-activated-route-query-param-map.ts rename to src/test/javascript/spec/mocks/activated-route/mock-activated-route-query-param-map.ts diff --git a/src/test/javascript/spec/helpers/mock-activated-route-snapshot.ts b/src/test/javascript/spec/mocks/activated-route/mock-activated-route-snapshot.ts similarity index 100% rename from src/test/javascript/spec/helpers/mock-activated-route-snapshot.ts rename to src/test/javascript/spec/mocks/activated-route/mock-activated-route-snapshot.ts diff --git a/src/test/javascript/spec/mocks/mock-activated-route.ts b/src/test/javascript/spec/mocks/activated-route/mock-activated-route.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-activated-route.ts rename to src/test/javascript/spec/mocks/activated-route/mock-activated-route.ts diff --git a/src/test/javascript/spec/mocks/mock-activated.route.ts b/src/test/javascript/spec/mocks/activated-route/mock-activated.route.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-activated.route.ts rename to src/test/javascript/spec/mocks/activated-route/mock-activated.route.ts diff --git a/src/test/javascript/spec/service/user-route-access.service.spec.ts b/src/test/javascript/spec/service/user-route-access.service.spec.ts index d1b194ef3856..bd3c5f25c9f7 100644 --- a/src/test/javascript/spec/service/user-route-access.service.spec.ts +++ b/src/test/javascript/spec/service/user-route-access.service.spec.ts @@ -16,7 +16,7 @@ import { CookieService } from 'ngx-cookie-service'; import { DeviceDetectorService } from 'ngx-device-detector'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { Mutable } from '../helpers/mutable'; -import { mockedActivatedRouteSnapshot } from '../helpers/mock-activated-route-snapshot'; +import { mockedActivatedRouteSnapshot } from '../mocks/activated-route/mock-activated-route-snapshot'; import { CourseExerciseDetailsComponent } from 'app/overview/exercise-details/course-exercise-details.component'; chai.use(sinonChai); From 22568dfcb97a9c9c6217ee9e7a0b9f751dd817e5 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Fri, 24 Apr 2020 01:03:04 +0200 Subject: [PATCH 092/152] Move some mocks from /helpers/ to /mocks/ --- .../spec/app/account/activate/activate.component.spec.ts | 2 +- .../finish/password-reset-finish.component.spec.ts | 2 +- .../spec/app/account/register/register.component.spec.ts | 2 +- .../list-of-complaints.component.spec.ts | 2 +- .../spec/{helpers => mocks}/mock-active-modal.service.ts | 2 +- .../spec/{helpers => mocks}/mock-event-manager.service.ts | 2 +- .../spec/{helpers => mocks}/mock-language.service.ts | 2 +- .../spec/{helpers => mocks}/mock-login.service.ts | 2 +- .../spec/{helpers => mocks}/mock-principal.service.ts | 2 +- .../spec/{helpers => mocks}/mock-route.service.ts | 2 +- .../spec/{helpers => mocks}/mock-state-storage.service.ts | 2 +- .../spec/{helpers => mocks}/mock-tracker.service.ts | 2 +- src/test/javascript/spec/service/account.service.spec.ts | 2 +- src/test/javascript/spec/test.module.ts | 8 ++++---- 14 files changed, 17 insertions(+), 17 deletions(-) rename src/test/javascript/spec/{helpers => mocks}/mock-active-modal.service.ts (84%) rename src/test/javascript/spec/{helpers => mocks}/mock-event-manager.service.ts (84%) rename src/test/javascript/spec/{helpers => mocks}/mock-language.service.ts (95%) rename src/test/javascript/spec/{helpers => mocks}/mock-login.service.ts (94%) rename src/test/javascript/spec/{helpers => mocks}/mock-principal.service.ts (89%) rename src/test/javascript/spec/{helpers => mocks}/mock-route.service.ts (93%) rename src/test/javascript/spec/{helpers => mocks}/mock-state-storage.service.ts (91%) rename src/test/javascript/spec/{helpers => mocks}/mock-tracker.service.ts (80%) diff --git a/src/test/javascript/spec/app/account/activate/activate.component.spec.ts b/src/test/javascript/spec/app/account/activate/activate.component.spec.ts index 30d142b11312..ea7f5429fe01 100644 --- a/src/test/javascript/spec/app/account/activate/activate.component.spec.ts +++ b/src/test/javascript/spec/app/account/activate/activate.component.spec.ts @@ -3,7 +3,7 @@ import { ActivatedRoute } from '@angular/router'; import { of, throwError } from 'rxjs'; import { ArtemisTestModule } from '../../../test.module'; -import { MockActivatedRoute } from '../../../helpers/mock-route.service'; +import { MockActivatedRoute } from '../../../mocks/mock-route.service'; import { ActivateService } from 'app/account/activate/activate.service'; import { ActivateComponent } from 'app/account/activate/activate.component'; diff --git a/src/test/javascript/spec/app/account/password-reset/finish/password-reset-finish.component.spec.ts b/src/test/javascript/spec/app/account/password-reset/finish/password-reset-finish.component.spec.ts index 24816fb17a8c..bd5abd90132d 100644 --- a/src/test/javascript/spec/app/account/password-reset/finish/password-reset-finish.component.spec.ts +++ b/src/test/javascript/spec/app/account/password-reset/finish/password-reset-finish.component.spec.ts @@ -6,7 +6,7 @@ import { ActivatedRoute } from '@angular/router'; import { ArtemisTestModule } from '../../../../test.module'; import { PasswordResetFinishComponent } from 'app/account/password-reset/finish/password-reset-finish.component'; import { PasswordResetFinishService } from 'app/account/password-reset/finish/password-reset-finish.service'; -import { MockActivatedRoute } from '../../../../helpers/mock-route.service'; +import { MockActivatedRoute } from '../../../../mocks/mock-route.service'; describe('Component Tests', () => { describe('PasswordResetFinishComponent', () => { diff --git a/src/test/javascript/spec/app/account/register/register.component.spec.ts b/src/test/javascript/spec/app/account/register/register.component.spec.ts index b531d55a30c3..6bb675eceaa3 100644 --- a/src/test/javascript/spec/app/account/register/register.component.spec.ts +++ b/src/test/javascript/spec/app/account/register/register.component.spec.ts @@ -2,7 +2,7 @@ import { async, ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angu import { of, throwError } from 'rxjs'; import { JhiLanguageService } from 'ng-jhipster'; -import { MockLanguageService } from '../../../helpers/mock-language.service'; +import { MockLanguageService } from '../../../mocks/mock-language.service'; import { ArtemisTestModule } from '../../../test.module'; import { EMAIL_ALREADY_USED_TYPE, LOGIN_ALREADY_USED_TYPE } from 'app/shared/constants/error.constants'; import { RegisterService } from 'app/account/register/register.service'; diff --git a/src/test/javascript/spec/component/list-of-complaints/list-of-complaints.component.spec.ts b/src/test/javascript/spec/component/list-of-complaints/list-of-complaints.component.spec.ts index 91256db2e721..be209956b0cd 100644 --- a/src/test/javascript/spec/component/list-of-complaints/list-of-complaints.component.spec.ts +++ b/src/test/javascript/spec/component/list-of-complaints/list-of-complaints.component.spec.ts @@ -9,7 +9,7 @@ import { MockAlertService } from '../../helpers/mock-alert.service'; import { ComplaintService } from 'app/complaints/complaint.service'; import { DifferencePipe } from 'ngx-moment'; import { ActivatedRoute } from '@angular/router'; -import { MockActivatedRoute } from '../../helpers/mock-route.service'; +import { MockActivatedRoute } from '../../mocks/mock-route.service'; import { ListOfComplaintsComponent } from 'app/complaints/list-of-complaints/list-of-complaints.component'; describe('ListOfComplaintsComponent', () => { diff --git a/src/test/javascript/spec/helpers/mock-active-modal.service.ts b/src/test/javascript/spec/mocks/mock-active-modal.service.ts similarity index 84% rename from src/test/javascript/spec/helpers/mock-active-modal.service.ts rename to src/test/javascript/spec/mocks/mock-active-modal.service.ts index 8bf0cc966fa3..9cd9b6d51cc9 100644 --- a/src/test/javascript/spec/helpers/mock-active-modal.service.ts +++ b/src/test/javascript/spec/mocks/mock-active-modal.service.ts @@ -1,4 +1,4 @@ -import { SpyObject } from './spyobject'; +import { SpyObject } from '../helpers/spyobject'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import Spy = jasmine.Spy; diff --git a/src/test/javascript/spec/helpers/mock-event-manager.service.ts b/src/test/javascript/spec/mocks/mock-event-manager.service.ts similarity index 84% rename from src/test/javascript/spec/helpers/mock-event-manager.service.ts rename to src/test/javascript/spec/mocks/mock-event-manager.service.ts index a71b5d931421..2aaea408daba 100644 --- a/src/test/javascript/spec/helpers/mock-event-manager.service.ts +++ b/src/test/javascript/spec/mocks/mock-event-manager.service.ts @@ -1,4 +1,4 @@ -import { SpyObject } from './spyobject'; +import { SpyObject } from '../helpers/spyobject'; import { JhiEventManager } from 'ng-jhipster'; import Spy = jasmine.Spy; diff --git a/src/test/javascript/spec/helpers/mock-language.service.ts b/src/test/javascript/spec/mocks/mock-language.service.ts similarity index 95% rename from src/test/javascript/spec/helpers/mock-language.service.ts rename to src/test/javascript/spec/mocks/mock-language.service.ts index 5ff0be310655..a57c1d9ef041 100644 --- a/src/test/javascript/spec/helpers/mock-language.service.ts +++ b/src/test/javascript/spec/mocks/mock-language.service.ts @@ -1,4 +1,4 @@ -import { SpyObject } from './spyobject'; +import { SpyObject } from '../helpers/spyobject'; import { JhiLanguageService } from 'ng-jhipster'; import { JhiLanguageHelper } from 'app/core/language/language.helper'; import { of } from 'rxjs'; diff --git a/src/test/javascript/spec/helpers/mock-login.service.ts b/src/test/javascript/spec/mocks/mock-login.service.ts similarity index 94% rename from src/test/javascript/spec/helpers/mock-login.service.ts rename to src/test/javascript/spec/mocks/mock-login.service.ts index 93a8ca575f21..b24e7150e30a 100644 --- a/src/test/javascript/spec/helpers/mock-login.service.ts +++ b/src/test/javascript/spec/mocks/mock-login.service.ts @@ -1,4 +1,4 @@ -import { SpyObject } from './spyobject'; +import { SpyObject } from '../helpers/spyobject'; import { LoginService } from 'app/core/login/login.service'; import Spy = jasmine.Spy; diff --git a/src/test/javascript/spec/helpers/mock-principal.service.ts b/src/test/javascript/spec/mocks/mock-principal.service.ts similarity index 89% rename from src/test/javascript/spec/helpers/mock-principal.service.ts rename to src/test/javascript/spec/mocks/mock-principal.service.ts index cb1f175cd36d..96ded028a26a 100644 --- a/src/test/javascript/spec/helpers/mock-principal.service.ts +++ b/src/test/javascript/spec/mocks/mock-principal.service.ts @@ -1,4 +1,4 @@ -import { SpyObject } from './spyobject'; +import { SpyObject } from '../helpers/spyobject'; import { Principal } from 'app/core/auth/principal.service'; import Spy = jasmine.Spy; diff --git a/src/test/javascript/spec/helpers/mock-route.service.ts b/src/test/javascript/spec/mocks/mock-route.service.ts similarity index 93% rename from src/test/javascript/spec/helpers/mock-route.service.ts rename to src/test/javascript/spec/mocks/mock-route.service.ts index 031703f446e2..a32fee00efc3 100644 --- a/src/test/javascript/spec/helpers/mock-route.service.ts +++ b/src/test/javascript/spec/mocks/mock-route.service.ts @@ -1,5 +1,5 @@ import { ActivatedRoute, Router } from '@angular/router'; -import { SpyObject } from './spyobject'; +import { SpyObject } from '../helpers/spyobject'; import { of } from 'rxjs'; import Spy = jasmine.Spy; diff --git a/src/test/javascript/spec/helpers/mock-state-storage.service.ts b/src/test/javascript/spec/mocks/mock-state-storage.service.ts similarity index 91% rename from src/test/javascript/spec/helpers/mock-state-storage.service.ts rename to src/test/javascript/spec/mocks/mock-state-storage.service.ts index 19106b869ddc..5dd82d3e186b 100644 --- a/src/test/javascript/spec/helpers/mock-state-storage.service.ts +++ b/src/test/javascript/spec/mocks/mock-state-storage.service.ts @@ -1,4 +1,4 @@ -import { SpyObject } from './spyobject'; +import { SpyObject } from '../helpers/spyobject'; import { StateStorageService } from 'app/core/auth/state-storage.service'; import Spy = jasmine.Spy; diff --git a/src/test/javascript/spec/helpers/mock-tracker.service.ts b/src/test/javascript/spec/mocks/mock-tracker.service.ts similarity index 80% rename from src/test/javascript/spec/helpers/mock-tracker.service.ts rename to src/test/javascript/spec/mocks/mock-tracker.service.ts index 1b994f7b3d66..a86e01a05eb3 100644 --- a/src/test/javascript/spec/helpers/mock-tracker.service.ts +++ b/src/test/javascript/spec/mocks/mock-tracker.service.ts @@ -1,4 +1,4 @@ -import { SpyObject } from './spyobject'; +import { SpyObject } from '../helpers/spyobject'; import { JhiTrackerService } from 'app/core/tracker/tracker.service'; export class MockTrackerService extends SpyObject { diff --git a/src/test/javascript/spec/service/account.service.spec.ts b/src/test/javascript/spec/service/account.service.spec.ts index 94d4b476ffb8..5dd6ef93ee4e 100644 --- a/src/test/javascript/spec/service/account.service.spec.ts +++ b/src/test/javascript/spec/service/account.service.spec.ts @@ -4,7 +4,7 @@ import { SinonStub, stub } from 'sinon'; import { of } from 'rxjs'; import * as sinonChai from 'sinon-chai'; import { MockWebsocketService } from '../mocks/mock-websocket.service'; -import { MockLanguageService } from '../helpers/mock-language.service'; +import { MockLanguageService } from '../mocks/mock-language.service'; import { MockHttpService } from '../mocks/mock-http.service'; import { MockFeatureToggleService } from '../mocks/mock-feature-toggle-service'; import { User } from 'app/core/user/user.model'; diff --git a/src/test/javascript/spec/test.module.ts b/src/test/javascript/spec/test.module.ts index 70baae055b67..0ce360421d6a 100644 --- a/src/test/javascript/spec/test.module.ts +++ b/src/test/javascript/spec/test.module.ts @@ -5,13 +5,13 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { NgbActiveModal, NgbModal, NgbDatepickerConfig } from '@ng-bootstrap/ng-bootstrap'; import { JhiAlertService, JhiDataUtils, JhiDateUtils, JhiEventManager, JhiLanguageService, JhiParseLinks } from 'ng-jhipster'; -import { MockLanguageHelper, MockLanguageService } from './helpers/mock-language.service'; +import { MockLanguageHelper, MockLanguageService } from './mocks/mock-language.service'; import { JhiLanguageHelper } from 'app/core/language/language.helper'; import { AccountService } from 'app/core/auth/account.service'; import { MockAccountService } from './mocks/mock-account.service'; -import { MockActivatedRoute, MockRouter } from './helpers/mock-route.service'; -import { MockActiveModal } from './helpers/mock-active-modal.service'; -import { MockEventManager } from './helpers/mock-event-manager.service'; +import { MockActivatedRoute, MockRouter } from './mocks/mock-route.service'; +import { MockActiveModal } from './mocks/mock-active-modal.service'; +import { MockEventManager } from './mocks/mock-event-manager.service'; import { CookieService } from 'ngx-cookie-service'; import { FaIconLibrary, FontAwesomeModule, FaIconComponent } from '@fortawesome/angular-fontawesome'; import { fas } from '@fortawesome/free-solid-svg-icons'; From 8470b8ea6dd7fdfade69b425a02b6926079c3755 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Fri, 24 Apr 2020 01:25:06 +0200 Subject: [PATCH 093/152] Add setIdentityResponse() to mock-account.service.ts --- src/test/javascript/spec/mocks/mock-account.service.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/javascript/spec/mocks/mock-account.service.ts b/src/test/javascript/spec/mocks/mock-account.service.ts index 3826256058ea..a0896fb04af7 100644 --- a/src/test/javascript/spec/mocks/mock-account.service.ts +++ b/src/test/javascript/spec/mocks/mock-account.service.ts @@ -2,6 +2,7 @@ import { of } from 'rxjs'; import { Course } from 'app/entities/course.model'; import { IAccountService } from 'app/core/auth/account.service'; import { User } from 'app/core/user/user.model'; +import { Account } from 'app/core/user/account.model'; export class MockAccountService implements IAccountService { identity = () => Promise.resolve({ id: 99 } as User); @@ -17,4 +18,5 @@ export class MockAccountService implements IAccountService { isAuthenticated = () => true; isAdmin = () => true; save = (account: any) => ({} as any); + setIdentityResponse = (account: Account | null) => {}; } From 37c9ae7a439d8b032ee09c9fda2932414151b4f7 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Fri, 24 Apr 2020 01:54:42 +0200 Subject: [PATCH 094/152] Merge duplicate mocks of alert.service --- .../app/shared/alert/alert-error.component.spec.ts | 2 +- .../complaints-for-tutor.component.spec.ts | 2 +- .../component/complaints/complaints.component.spec.ts | 2 +- .../file-upload-assessment.component.spec.ts | 2 +- .../file-upload-result.component.spec.ts | 2 +- .../file-upload-submission.component.spec.ts | 2 +- .../list-of-complaints.component.spec.ts | 2 +- .../modeling-submission.component.spec.ts | 2 +- .../course-exercise-row.component.spec.ts | 2 +- .../participation-submission.component.spec.ts | 2 +- .../team/team-update-dialog.component.spec.ts | 2 +- .../spec/component/team/teams.component.spec.ts | 2 +- .../text-exercise-assessement.component.spec.ts | 2 +- .../tutor-exercise-dashboard.component.spec.ts | 2 +- .../javascript/spec/helpers/mock-alert.service.ts | 11 ----------- src/test/javascript/spec/mocks/mock-alert.service.ts | 11 ++++++++++- 16 files changed, 24 insertions(+), 26 deletions(-) delete mode 100644 src/test/javascript/spec/helpers/mock-alert.service.ts diff --git a/src/test/javascript/spec/app/shared/alert/alert-error.component.spec.ts b/src/test/javascript/spec/app/shared/alert/alert-error.component.spec.ts index 3d0ef70ad9fa..a26bbe0044ea 100644 --- a/src/test/javascript/spec/app/shared/alert/alert-error.component.spec.ts +++ b/src/test/javascript/spec/app/shared/alert/alert-error.component.spec.ts @@ -5,7 +5,7 @@ import { TranslateModule } from '@ngx-translate/core'; import { ArtemisTestModule } from '../../../test.module'; import { AlertErrorComponent } from 'app/shared/alert/alert-error.component'; -import { MockAlertService } from '../../../helpers/mock-alert.service'; +import { MockAlertService } from '../../../mocks/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; describe('Component Tests', () => { diff --git a/src/test/javascript/spec/component/complaints-for-tutor/complaints-for-tutor.component.spec.ts b/src/test/javascript/spec/component/complaints-for-tutor/complaints-for-tutor.component.spec.ts index 3ccbc41af4d3..4f1b2dae99ed 100644 --- a/src/test/javascript/spec/component/complaints-for-tutor/complaints-for-tutor.component.spec.ts +++ b/src/test/javascript/spec/component/complaints-for-tutor/complaints-for-tutor.component.spec.ts @@ -3,7 +3,7 @@ import * as chai from 'chai'; import { BrowserModule, By } from '@angular/platform-browser'; import { ComplaintService } from 'app/complaints/complaint.service'; import { MockComplaintService } from '../../mocks/mock-complaint.service'; -import { MockAlertService } from '../../helpers/mock-alert.service'; +import { MockAlertService } from '../../mocks/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { MomentModule } from 'ngx-moment'; diff --git a/src/test/javascript/spec/component/complaints/complaints.component.spec.ts b/src/test/javascript/spec/component/complaints/complaints.component.spec.ts index 1d409bc91390..04c43a809bf3 100644 --- a/src/test/javascript/spec/component/complaints/complaints.component.spec.ts +++ b/src/test/javascript/spec/component/complaints/complaints.component.spec.ts @@ -3,7 +3,7 @@ import * as chai from 'chai'; import { By } from '@angular/platform-browser'; import { ComplaintService } from 'app/complaints/complaint.service'; import { MockComplaintResponse, MockComplaintService } from '../../mocks/mock-complaint.service'; -import { MockAlertService } from '../../helpers/mock-alert.service'; +import { MockAlertService } from '../../mocks/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; import { MomentModule } from 'ngx-moment'; import { DebugElement } from '@angular/core'; diff --git a/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.component.spec.ts b/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.component.spec.ts index 51b0639b6e1d..ebe97cef3213 100644 --- a/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.component.spec.ts +++ b/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.component.spec.ts @@ -10,7 +10,7 @@ import { ArtemisTestModule } from '../../test.module'; import { MockSyncStorage } from '../../mocks/mock-sync.storage'; import { MockComponent } from 'ng-mocks'; import { ArtemisSharedModule } from 'app/shared/shared.module'; -import { MockAlertService } from '../../helpers/mock-alert.service'; +import { MockAlertService } from '../../mocks/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; import { Router } from '@angular/router'; import { FileUploadAssessmentComponent } from 'app/exercises/file-upload/assess/file-upload-assessment.component'; diff --git a/src/test/javascript/spec/component/file-upload-submission/file-upload-result.component.spec.ts b/src/test/javascript/spec/component/file-upload-submission/file-upload-result.component.spec.ts index bca9e2a4788b..5bec1b9fa35b 100644 --- a/src/test/javascript/spec/component/file-upload-submission/file-upload-result.component.spec.ts +++ b/src/test/javascript/spec/component/file-upload-submission/file-upload-result.component.spec.ts @@ -5,7 +5,7 @@ import * as sinonChai from 'sinon-chai'; import { ArtemisTestModule } from '../../test.module'; import { Result } from 'app/entities/result.model'; import { ArtemisSharedModule } from 'app/shared/shared.module'; -import { MockAlertService } from '../../helpers/mock-alert.service'; +import { MockAlertService } from '../../mocks/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; import { DebugElement } from '@angular/core'; import { By } from '@angular/platform-browser'; diff --git a/src/test/javascript/spec/component/file-upload-submission/file-upload-submission.component.spec.ts b/src/test/javascript/spec/component/file-upload-submission/file-upload-submission.component.spec.ts index 5a1b02691bb1..5760994fef30 100644 --- a/src/test/javascript/spec/component/file-upload-submission/file-upload-submission.component.spec.ts +++ b/src/test/javascript/spec/component/file-upload-submission/file-upload-submission.component.spec.ts @@ -7,7 +7,7 @@ import { ArtemisTestModule } from '../../test.module'; import { MockSyncStorage } from '../../mocks/mock-sync.storage'; import { MockParticipationWebsocketService } from '../../mocks/mock-participation-websocket.service'; import { MockComponent } from 'ng-mocks'; -import { MockAlertService } from '../../helpers/mock-alert.service'; +import { MockAlertService } from '../../mocks/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; import { Router } from '@angular/router'; import { ResizableInstructionsComponent } from 'app/exercises/text/assess/resizable-instructions/resizable-instructions.component'; diff --git a/src/test/javascript/spec/component/list-of-complaints/list-of-complaints.component.spec.ts b/src/test/javascript/spec/component/list-of-complaints/list-of-complaints.component.spec.ts index be209956b0cd..a0c0fc3e1f3d 100644 --- a/src/test/javascript/spec/component/list-of-complaints/list-of-complaints.component.spec.ts +++ b/src/test/javascript/spec/component/list-of-complaints/list-of-complaints.component.spec.ts @@ -5,7 +5,7 @@ import { ArtemisSharedModule } from 'app/shared/shared.module'; import { RouterTestingModule } from '@angular/router/testing'; import { SortByModule } from 'app/shared/pipes/sort-by.module'; import { AlertService } from 'app/core/alert/alert.service'; -import { MockAlertService } from '../../helpers/mock-alert.service'; +import { MockAlertService } from '../../mocks/mock-alert.service'; import { ComplaintService } from 'app/complaints/complaint.service'; import { DifferencePipe } from 'ngx-moment'; import { ActivatedRoute } from '@angular/router'; diff --git a/src/test/javascript/spec/component/modeling-submission/modeling-submission.component.spec.ts b/src/test/javascript/spec/component/modeling-submission/modeling-submission.component.spec.ts index c191eaa2b528..a7869758694c 100644 --- a/src/test/javascript/spec/component/modeling-submission/modeling-submission.component.spec.ts +++ b/src/test/javascript/spec/component/modeling-submission/modeling-submission.component.spec.ts @@ -19,7 +19,7 @@ import { DebugElement } from '@angular/core'; import { By } from '@angular/platform-browser'; import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; -import { MockAlertService } from '../../helpers/mock-alert.service'; +import { MockAlertService } from '../../mocks/mock-alert.service'; import { MockComplaintService } from '../../mocks/mock-complaint.service'; import { AlertService } from 'app/core/alert/alert.service'; import { ArtemisSharedModule } from 'app/shared/shared.module'; diff --git a/src/test/javascript/spec/component/overview/course-exercises/course-exercise-row.component.spec.ts b/src/test/javascript/spec/component/overview/course-exercises/course-exercise-row.component.spec.ts index f27f95eb4398..ee885b56dc0b 100644 --- a/src/test/javascript/spec/component/overview/course-exercises/course-exercise-row.component.spec.ts +++ b/src/test/javascript/spec/component/overview/course-exercises/course-exercise-row.component.spec.ts @@ -11,7 +11,7 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { MockOrionConnectorService } from '../../../mocks/mock-orion-connector.service'; import { MockCourseExerciseService } from '../../../mocks/mock-course-exercise.service'; import { AlertService } from 'app/core/alert/alert.service'; -import { MockAlertService } from '../../../helpers/mock-alert.service'; +import { MockAlertService } from '../../../mocks/mock-alert.service'; import { MockParticipationWebsocketService } from '../../../mocks/mock-participation-websocket.service'; import { Result } from 'app/entities/result.model'; import { DeviceDetectorService } from 'ngx-device-detector'; diff --git a/src/test/javascript/spec/component/participation-submission/participation-submission.component.spec.ts b/src/test/javascript/spec/component/participation-submission/participation-submission.component.spec.ts index d4952e6cca94..5c344763f27b 100644 --- a/src/test/javascript/spec/component/participation-submission/participation-submission.component.spec.ts +++ b/src/test/javascript/spec/component/participation-submission/participation-submission.component.spec.ts @@ -9,7 +9,7 @@ import { ArtemisTestModule } from '../../test.module'; import { MockSyncStorage } from '../../mocks/mock-sync.storage'; import { MockComponent } from 'ng-mocks'; import { ArtemisSharedModule } from 'app/shared/shared.module'; -import { MockAlertService } from '../../helpers/mock-alert.service'; +import { MockAlertService } from '../../mocks/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; import { Router } from '@angular/router'; import { of } from 'rxjs'; diff --git a/src/test/javascript/spec/component/team/team-update-dialog.component.spec.ts b/src/test/javascript/spec/component/team/team-update-dialog.component.spec.ts index 8c1a5b418d94..b6ee0bf2efee 100644 --- a/src/test/javascript/spec/component/team/team-update-dialog.component.spec.ts +++ b/src/test/javascript/spec/component/team/team-update-dialog.component.spec.ts @@ -11,7 +11,7 @@ import { FormsModule } from '@angular/forms'; import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap'; import * as sinon from 'sinon'; import { AlertService } from 'app/core/alert/alert.service'; -import { MockAlertService } from '../../helpers/mock-alert.service'; +import { MockAlertService } from '../../mocks/mock-alert.service'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { ArtemisSharedComponentModule } from 'app/shared/components/shared-component.module'; import { ArtemisTeamModule } from 'app/exercises/shared/team/team.module'; diff --git a/src/test/javascript/spec/component/team/teams.component.spec.ts b/src/test/javascript/spec/component/team/teams.component.spec.ts index 52127534672f..975b81ab450f 100644 --- a/src/test/javascript/spec/component/team/teams.component.spec.ts +++ b/src/test/javascript/spec/component/team/teams.component.spec.ts @@ -9,7 +9,7 @@ import { JhiEventManager, NgJhipsterModule } from 'ng-jhipster'; import { FormsModule } from '@angular/forms'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { AlertService } from 'app/core/alert/alert.service'; -import { MockAlertService } from '../../helpers/mock-alert.service'; +import { MockAlertService } from '../../mocks/mock-alert.service'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { ArtemisSharedComponentModule } from 'app/shared/components/shared-component.module'; import { ArtemisTeamModule } from 'app/exercises/shared/team/team.module'; diff --git a/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.component.spec.ts b/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.component.spec.ts index d85a08481c6e..dd6aad99c252 100644 --- a/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.component.spec.ts +++ b/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.component.spec.ts @@ -11,7 +11,7 @@ import { MockSyncStorage } from '../../mocks/mock-sync.storage'; import { Result } from 'app/entities/result.model'; import { MockComponent } from 'ng-mocks'; import { ArtemisSharedModule } from 'app/shared/shared.module'; -import { MockAlertService } from '../../helpers/mock-alert.service'; +import { MockAlertService } from '../../mocks/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; import { ActivatedRoute, Router } from '@angular/router'; import { of, throwError } from 'rxjs'; diff --git a/src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.component.spec.ts b/src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.component.spec.ts index b9a8534404e8..aaf73bb8625f 100644 --- a/src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.component.spec.ts +++ b/src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.component.spec.ts @@ -8,7 +8,7 @@ import { MockActivatedRoute } from '../../mocks/activated-route/mock-activated.r import { MockSyncStorage } from '../../mocks/mock-sync.storage'; import { MockComponent } from 'ng-mocks'; import { ArtemisSharedModule } from 'app/shared/shared.module'; -import { MockAlertService } from '../../helpers/mock-alert.service'; +import { MockAlertService } from '../../mocks/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; import { ActivatedRoute, Router, RouterModule } from '@angular/router'; import { MockRouter } from '../../mocks/mock-router.service'; diff --git a/src/test/javascript/spec/helpers/mock-alert.service.ts b/src/test/javascript/spec/helpers/mock-alert.service.ts deleted file mode 100644 index 1a220f9fcb7a..000000000000 --- a/src/test/javascript/spec/helpers/mock-alert.service.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { SpyObject } from './spyobject'; -import { JhiAlert, JhiAlertService } from 'ng-jhipster'; - -export class MockAlertService extends SpyObject { - constructor() { - super(JhiAlertService); - } - addAlert(alertOptions: JhiAlert) { - return alertOptions; - } -} diff --git a/src/test/javascript/spec/mocks/mock-alert.service.ts b/src/test/javascript/spec/mocks/mock-alert.service.ts index 6cb9b85a47ed..f2ecf8bbdb5e 100644 --- a/src/test/javascript/spec/mocks/mock-alert.service.ts +++ b/src/test/javascript/spec/mocks/mock-alert.service.ts @@ -1,4 +1,13 @@ -export class MockAlertService { +import { SpyObject } from '../helpers/spyobject'; +import { JhiAlert, JhiAlertService } from 'ng-jhipster'; + +export class MockAlertService extends SpyObject { + constructor() { + super(JhiAlertService); + } + addAlert(alertOptions: JhiAlert) { + return alertOptions; + } clear = () => {}; error = () => {}; } From a9cbcc4b209dd92e51a0225ad88234eb58171a39 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Fri, 24 Apr 2020 02:03:38 +0200 Subject: [PATCH 095/152] Move mocks of services in own sub-directory --- .../activate/activate.component.spec.ts | 2 +- .../password-reset-finish.component.spec.ts | 2 +- .../register/register.component.spec.ts | 2 +- .../settings/settings.component.spec.ts | 2 +- .../user-management.component.spec.ts | 2 +- .../entities/course/course.service.spec.ts | 6 ++-- .../programming-exercise.component.spec.ts | 8 ++--- .../alert/alert-error.component.spec.ts | 2 +- .../admin/user-management.component.spec.ts | 4 +-- .../code-editor-ace.component.spec.ts | 2 +- .../code-editor-actions.component.spec.ts | 12 ++++---- ...code-editor-build-output.component.spec.ts | 12 ++++---- ...code-editor-file-browser.component.spec.ts | 10 +++---- ...code-editor-instructions.component.spec.ts | 4 +-- .../complaints-for-tutor.component.spec.ts | 4 +-- .../complaints/complaints.component.spec.ts | 4 +-- .../file-upload-assessment.component.spec.ts | 8 ++--- ...e-upload-exercise-detail.component.spec.ts | 6 ++-- .../file-upload-result.component.spec.ts | 4 +-- .../file-upload-submission.component.spec.ts | 14 ++++----- .../guided-tour/guided-tour.component.spec.ts | 6 ++-- .../list-of-complaints.component.spec.ts | 4 +-- ...deling-assessment-editor.component.spec.ts | 2 +- .../modeling-submission.component.spec.ts | 10 +++---- .../course-exercise-row.component.spec.ts | 14 ++++----- .../course-statistics.component.spec.ts | 2 +- ...-details-student-actions.component.spec.ts | 10 +++---- ...cise-student-ide-actions.component.spec.ts | 10 +++---- .../overview/overview.component.spec.ts | 10 +++---- ...participation-submission.component.spec.ts | 8 ++--- .../participation.component.spec.ts | 2 +- ...ent-manual-result-dialog.component.spec.ts | 14 ++++----- ...ise-editable-instruction.component.spec.ts | 6 ++-- ...gramming-exercise-import.component.spec.ts | 4 +-- ...ing-exercise-instruction.component.spec.ts | 14 ++++----- ...ercise-instructor-status.component.spec.ts | 4 +-- ...tructor-submission-state.component.spec.ts | 8 ++--- ...ercise-manage-test-cases.component.spec.ts | 14 ++++----- ...ise-trigger-build-button.component.spec.ts | 6 ++-- .../component/shared/button.component.spec.ts | 4 +-- .../shared/secured-image.component.spec.ts | 2 +- .../shared/updating-result.component.spec.ts | 8 ++--- .../student-questions.component.spec.ts | 2 +- .../team/team-update-dialog.component.spec.ts | 6 ++-- .../component/team/teams.component.spec.ts | 14 ++++----- .../text-editor/text-editor.component.spec.ts | 4 +-- ...ext-exercise-assessement.component.spec.ts | 8 ++--- ...tutor-exercise-dashboard.component.spec.ts | 6 ++-- ...utor-participation-graph.component.spec.ts | 2 +- .../build-plan-link.directive.spec.ts | 2 +- ...code-editor-instructor.integration.spec.ts | 30 +++++++++---------- .../code-editor-student.integration.spec.ts | 24 +++++++-------- .../mock-has-any-authority.directive.ts | 0 .../{ => service}/mock-account.service.ts | 0 .../mock-active-modal.service.ts | 2 +- .../mocks/{ => service}/mock-alert.service.ts | 2 +- .../mock-auth-server-provider.service.ts | 0 .../mock-cacheable-image.service.ts | 0 .../mock-code-editor-build-log.service.ts | 0 ...mock-code-editor-conflict-state.service.ts | 0 .../mock-code-editor-grid.service.ts | 0 ...ock-code-editor-repository-file.service.ts | 0 .../mock-code-editor-repository.service.ts | 0 .../mock-code-editor-session.service.ts | 0 .../{ => service}/mock-complaint.service.ts | 0 .../{ => service}/mock-cookie.service.ts | 0 .../mock-course-exercise.service.ts | 0 .../{ => service}/mock-course.service.ts | 0 .../mock-event-manager.service.ts | 2 +- .../mock-exercise-hint.service.ts | 0 .../{ => service}/mock-exercise.service.ts | 0 .../mock-feature-toggle.service.ts} | 0 .../mock-file-upload-exercise.service.ts | 0 .../mock-file-upload-submission.service.ts | 0 .../mocks/{ => service}/mock-http.service.ts | 0 .../mock-ide-build-and-test.service.ts | 0 .../{ => service}/mock-language.service.ts | 2 +- .../mocks/{ => service}/mock-login.service.ts | 2 +- .../{ => service}/mock-ngb-modal.service.ts | 0 .../mock-notification.service.ts | 0 .../mock-orion-connector.service.ts | 0 .../mock-participation-websocket.service.ts | 0 .../mock-participation.service.ts | 0 .../{ => service}/mock-principal.service.ts | 2 +- .../{ => service}/mock-profile.service.ts | 0 .../mock-programming-build-run.service.ts | 0 ...ock-programming-exercise-paging.service.ts | 0 ...gramming-exercise-participation.service.ts | 0 ...-programming-exercise-test-case.service.ts | 0 ...-programming-exercise-websocket.service.ts | 0 .../mock-programming-exercise.service.ts | 0 .../mock-programming-submission.service.ts | 0 .../mock-repository-file.service.ts | 0 .../{ => service}/mock-result.service.ts | 0 .../mocks/{ => service}/mock-route.service.ts | 2 +- .../{ => service}/mock-router.service.ts | 0 .../mock-state-storage.service.ts | 2 +- .../mock-sync-storage.service.ts} | 0 .../mocks/{ => service}/mock-team.service.ts | 0 .../{ => service}/mock-text-editor.service.ts | 0 .../{ => service}/mock-tracker.service.ts | 2 +- .../{ => service}/mock-translate.service.ts | 0 .../mocks/{ => service}/mock-user.service.ts | 0 .../{ => service}/mock-websocket.service.ts | 0 .../{ => service}/mock-window.service.ts | 0 .../spec/service/account.service.spec.ts | 10 +++---- .../spec/service/guided-tour.service.spec.ts | 8 ++--- .../ide-build-and-test.service.spec.ts | 8 ++--- .../spec/service/login.service.spec.ts | 12 ++++---- .../orion-version-validator.service.spec.ts | 6 ++-- .../participation-websocket.service.spec.ts | 2 +- ...rcise-instruction-analysis.service.spec.ts | 2 +- ...ramming-exercise-test-case.service.spec.ts | 4 +-- .../programming-submission.service.spec.ts | 8 ++--- .../service/user-route-access.service.spec.ts | 8 ++--- src/test/javascript/spec/test.module.ts | 10 +++---- 116 files changed, 233 insertions(+), 233 deletions(-) rename src/test/javascript/spec/mocks/{ => directive}/mock-has-any-authority.directive.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-account.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-active-modal.service.ts (84%) rename src/test/javascript/spec/mocks/{ => service}/mock-alert.service.ts (84%) rename src/test/javascript/spec/mocks/{ => service}/mock-auth-server-provider.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-cacheable-image.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-code-editor-build-log.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-code-editor-conflict-state.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-code-editor-grid.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-code-editor-repository-file.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-code-editor-repository.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-code-editor-session.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-complaint.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-cookie.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-course-exercise.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-course.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-event-manager.service.ts (83%) rename src/test/javascript/spec/mocks/{ => service}/mock-exercise-hint.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-exercise.service.ts (100%) rename src/test/javascript/spec/mocks/{mock-feature-toggle-service.ts => service/mock-feature-toggle.service.ts} (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-file-upload-exercise.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-file-upload-submission.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-http.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-ide-build-and-test.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-language.service.ts (95%) rename src/test/javascript/spec/mocks/{ => service}/mock-login.service.ts (93%) rename src/test/javascript/spec/mocks/{ => service}/mock-ngb-modal.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-notification.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-orion-connector.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-participation-websocket.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-participation.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-principal.service.ts (89%) rename src/test/javascript/spec/mocks/{ => service}/mock-profile.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-programming-build-run.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-programming-exercise-paging.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-programming-exercise-participation.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-programming-exercise-test-case.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-programming-exercise-websocket.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-programming-exercise.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-programming-submission.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-repository-file.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-result.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-route.service.ts (92%) rename src/test/javascript/spec/mocks/{ => service}/mock-router.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-state-storage.service.ts (90%) rename src/test/javascript/spec/mocks/{mock-sync.storage.ts => service/mock-sync-storage.service.ts} (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-team.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-text-editor.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-tracker.service.ts (79%) rename src/test/javascript/spec/mocks/{ => service}/mock-translate.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-user.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-websocket.service.ts (100%) rename src/test/javascript/spec/mocks/{ => service}/mock-window.service.ts (100%) diff --git a/src/test/javascript/spec/app/account/activate/activate.component.spec.ts b/src/test/javascript/spec/app/account/activate/activate.component.spec.ts index ea7f5429fe01..cf9b76774ece 100644 --- a/src/test/javascript/spec/app/account/activate/activate.component.spec.ts +++ b/src/test/javascript/spec/app/account/activate/activate.component.spec.ts @@ -3,7 +3,7 @@ import { ActivatedRoute } from '@angular/router'; import { of, throwError } from 'rxjs'; import { ArtemisTestModule } from '../../../test.module'; -import { MockActivatedRoute } from '../../../mocks/mock-route.service'; +import { MockActivatedRoute } from '../../../mocks/service/mock-route.service'; import { ActivateService } from 'app/account/activate/activate.service'; import { ActivateComponent } from 'app/account/activate/activate.component'; diff --git a/src/test/javascript/spec/app/account/password-reset/finish/password-reset-finish.component.spec.ts b/src/test/javascript/spec/app/account/password-reset/finish/password-reset-finish.component.spec.ts index bd5abd90132d..824fee1703ae 100644 --- a/src/test/javascript/spec/app/account/password-reset/finish/password-reset-finish.component.spec.ts +++ b/src/test/javascript/spec/app/account/password-reset/finish/password-reset-finish.component.spec.ts @@ -6,7 +6,7 @@ import { ActivatedRoute } from '@angular/router'; import { ArtemisTestModule } from '../../../../test.module'; import { PasswordResetFinishComponent } from 'app/account/password-reset/finish/password-reset-finish.component'; import { PasswordResetFinishService } from 'app/account/password-reset/finish/password-reset-finish.service'; -import { MockActivatedRoute } from '../../../../mocks/mock-route.service'; +import { MockActivatedRoute } from '../../../../mocks/service/mock-route.service'; describe('Component Tests', () => { describe('PasswordResetFinishComponent', () => { diff --git a/src/test/javascript/spec/app/account/register/register.component.spec.ts b/src/test/javascript/spec/app/account/register/register.component.spec.ts index 6bb675eceaa3..a95516ee1a1d 100644 --- a/src/test/javascript/spec/app/account/register/register.component.spec.ts +++ b/src/test/javascript/spec/app/account/register/register.component.spec.ts @@ -2,7 +2,7 @@ import { async, ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angu import { of, throwError } from 'rxjs'; import { JhiLanguageService } from 'ng-jhipster'; -import { MockLanguageService } from '../../../mocks/mock-language.service'; +import { MockLanguageService } from '../../../mocks/service/mock-language.service'; import { ArtemisTestModule } from '../../../test.module'; import { EMAIL_ALREADY_USED_TYPE, LOGIN_ALREADY_USED_TYPE } from 'app/shared/constants/error.constants'; import { RegisterService } from 'app/account/register/register.service'; diff --git a/src/test/javascript/spec/app/account/settings/settings.component.spec.ts b/src/test/javascript/spec/app/account/settings/settings.component.spec.ts index d1b62621e0d7..fa5722177031 100644 --- a/src/test/javascript/spec/app/account/settings/settings.component.spec.ts +++ b/src/test/javascript/spec/app/account/settings/settings.component.spec.ts @@ -6,7 +6,7 @@ import { ArtemisTestModule } from '../../../test.module'; import { AccountService } from 'app/core/auth/account.service'; import { Account } from 'app/core/user/account.model'; import { SettingsComponent } from 'app/account/settings/settings.component'; -import { MockAccountService } from '../../../mocks/mock-account.service'; +import { MockAccountService } from '../../../mocks/service/mock-account.service'; describe('SettingsComponent', () => { let comp: SettingsComponent; diff --git a/src/test/javascript/spec/app/admin/user-management/user-management.component.spec.ts b/src/test/javascript/spec/app/admin/user-management/user-management.component.spec.ts index 622426aa7fb7..2dd786c1b4b5 100644 --- a/src/test/javascript/spec/app/admin/user-management/user-management.component.spec.ts +++ b/src/test/javascript/spec/app/admin/user-management/user-management.component.spec.ts @@ -8,7 +8,7 @@ import { UserManagementComponent } from 'app/admin/user-management/user-manageme import { User } from 'app/core/user/user.model'; import { UserService } from 'app/core/user/user.service'; import { AccountService } from 'app/core/auth/account.service'; -import { MockSyncStorage } from '../../../mocks/mock-sync.storage'; +import { MockSyncStorage } from '../../../mocks/service/mock-sync-storage.service'; describe('Component Tests', () => { describe('User Management Component', () => { diff --git a/src/test/javascript/spec/app/entities/course/course.service.spec.ts b/src/test/javascript/spec/app/entities/course/course.service.spec.ts index a7b44db6e138..4a2e58a933d2 100644 --- a/src/test/javascript/spec/app/entities/course/course.service.spec.ts +++ b/src/test/javascript/spec/app/entities/course/course.service.spec.ts @@ -8,9 +8,9 @@ import * as moment from 'moment'; import { DATE_TIME_FORMAT } from 'app/shared/constants/input.constants'; import { CourseManagementService } from 'app/course/manage/course-management.service'; import { Course } from 'app/entities/course.model'; -import { MockTranslateService } from '../../../mocks/mock-translate.service'; -import { MockSyncStorage } from '../../../mocks/mock-sync.storage'; -import { MockRouter } from '../../../mocks/mock-router.service'; +import { MockTranslateService } from '../../../mocks/service/mock-translate.service'; +import { MockSyncStorage } from '../../../mocks/service/mock-sync-storage.service'; +import { MockRouter } from '../../../mocks/service/mock-router.service'; describe('Service Tests', () => { describe('Course Service', () => { diff --git a/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.component.spec.ts b/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.component.spec.ts index ed35cc20fd43..60ff3e611488 100644 --- a/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.component.spec.ts +++ b/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.component.spec.ts @@ -5,16 +5,16 @@ import { of } from 'rxjs'; import { ArtemisTestModule } from '../../../test.module'; import { ProgrammingExerciseComponent } from 'app/exercises/programming/manage/programming-exercise.component'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; -import { MockSyncStorage } from '../../../mocks/mock-sync.storage'; +import { MockSyncStorage } from '../../../mocks/service/mock-sync-storage.service'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; -import { MockTranslateService } from '../../../mocks/mock-translate.service'; +import { MockTranslateService } from '../../../mocks/service/mock-translate.service'; import { TranslateService } from '@ngx-translate/core'; import { ActivatedRoute, convertToParamMap } from '@angular/router'; import { Course } from 'app/entities/course.model'; import { OrionConnectorService } from 'app/shared/orion/orion-connector.service'; -import { MockOrionConnectorService } from '../../../mocks/mock-orion-connector.service'; +import { MockOrionConnectorService } from '../../../mocks/service/mock-orion-connector.service'; import { CourseExerciseService } from 'app/course/manage/course-management.service'; -import { MockCourseExerciseService } from '../../../mocks/mock-course-exercise.service'; +import { MockCourseExerciseService } from '../../../mocks/service/mock-course-exercise.service'; describe('Component Tests', () => { describe('ProgrammingExercise Management Component', () => { diff --git a/src/test/javascript/spec/app/shared/alert/alert-error.component.spec.ts b/src/test/javascript/spec/app/shared/alert/alert-error.component.spec.ts index a26bbe0044ea..b227cd12cbfb 100644 --- a/src/test/javascript/spec/app/shared/alert/alert-error.component.spec.ts +++ b/src/test/javascript/spec/app/shared/alert/alert-error.component.spec.ts @@ -5,7 +5,7 @@ import { TranslateModule } from '@ngx-translate/core'; import { ArtemisTestModule } from '../../../test.module'; import { AlertErrorComponent } from 'app/shared/alert/alert-error.component'; -import { MockAlertService } from '../../../mocks/mock-alert.service'; +import { MockAlertService } from '../../../mocks/service/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; describe('Component Tests', () => { diff --git a/src/test/javascript/spec/component/admin/user-management.component.spec.ts b/src/test/javascript/spec/component/admin/user-management.component.spec.ts index b49be19d9a96..5949107785fb 100644 --- a/src/test/javascript/spec/component/admin/user-management.component.spec.ts +++ b/src/test/javascript/spec/component/admin/user-management.component.spec.ts @@ -6,9 +6,9 @@ import { ArtemisTestModule } from '../../test.module'; import { ArtemisAdminModule } from 'app/admin/admin.module'; import { UserManagementComponent } from 'app/admin/user-management/user-management.component'; import { UserService } from 'app/core/user/user.service'; -import { MockUserService } from '../../mocks/mock-user.service'; +import { MockUserService } from '../../mocks/service/mock-user.service'; import { AccountService } from 'app/core/auth/account.service'; -import { MockAccountService } from '../../mocks/mock-account.service'; +import { MockAccountService } from '../../mocks/service/mock-account.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/component/code-editor/code-editor-ace.component.spec.ts b/src/test/javascript/spec/component/code-editor/code-editor-ace.component.spec.ts index d11f6b5e8731..eead78fd6ed1 100644 --- a/src/test/javascript/spec/component/code-editor/code-editor-ace.component.spec.ts +++ b/src/test/javascript/spec/component/code-editor/code-editor-ace.component.spec.ts @@ -16,7 +16,7 @@ import { AnnotationArray } from 'app/entities/annotation.model'; import { CodeEditorRepositoryFileService } from 'app/exercises/programming/shared/code-editor/service/code-editor-repository.service'; import { CodeEditorFileService } from 'app/exercises/programming/shared/code-editor/service/code-editor-file.service'; import { CodeEditorAceComponent } from 'app/exercises/programming/shared/code-editor/ace/code-editor-ace.component'; -import { MockCodeEditorRepositoryFileService } from '../../mocks/mock-code-editor-repository-file.service'; +import { MockCodeEditorRepositoryFileService } from '../../mocks/service/mock-code-editor-repository-file.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/component/code-editor/code-editor-actions.component.spec.ts b/src/test/javascript/spec/component/code-editor/code-editor-actions.component.spec.ts index 6d2b0b51f973..d79c487ee8fa 100644 --- a/src/test/javascript/spec/component/code-editor/code-editor-actions.component.spec.ts +++ b/src/test/javascript/spec/component/code-editor/code-editor-actions.component.spec.ts @@ -15,16 +15,16 @@ import { CodeEditorRepositoryFileService, CodeEditorRepositoryService } from 'ap import { ArtemisTestModule } from '../../test.module'; import { FeatureToggleModule } from 'app/shared/feature-toggle/feature-toggle.module'; import { FeatureToggleService } from 'app/shared/feature-toggle/feature-toggle.service'; -import { MockFeatureToggleService } from '../../mocks/mock-feature-toggle-service'; +import { MockFeatureToggleService } from '../../mocks/service/mock-feature-toggle.service'; import { cartesianProduct } from 'app/shared/util/utils'; -import { MockSyncStorage } from '../../mocks/mock-sync.storage'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; import { CodeEditorConflictStateService } from 'app/exercises/programming/shared/code-editor/service/code-editor-conflict-state.service'; import { CodeEditorActionsComponent } from 'app/exercises/programming/shared/code-editor/actions/code-editor-actions.component'; -import { MockCodeEditorConflictStateService } from '../../mocks/mock-code-editor-conflict-state.service'; -import { MockCodeEditorRepositoryFileService } from '../../mocks/mock-code-editor-repository-file.service'; -import { MockCodeEditorRepositoryService } from '../../mocks/mock-code-editor-repository.service'; -import { MockCookieService } from '../../mocks/mock-cookie.service'; +import { MockCodeEditorConflictStateService } from '../../mocks/service/mock-code-editor-conflict-state.service'; +import { MockCodeEditorRepositoryFileService } from '../../mocks/service/mock-code-editor-repository-file.service'; +import { MockCodeEditorRepositoryService } from '../../mocks/service/mock-code-editor-repository.service'; +import { MockCookieService } from '../../mocks/service/mock-cookie.service'; import { CommitState, EditorState } from 'app/exercises/programming/shared/code-editor/model/code-editor.model'; chai.use(sinonChai); diff --git a/src/test/javascript/spec/component/code-editor/code-editor-build-output.component.spec.ts b/src/test/javascript/spec/component/code-editor/code-editor-build-output.component.spec.ts index 07eac4addf50..a9487254553d 100644 --- a/src/test/javascript/spec/component/code-editor/code-editor-build-output.component.spec.ts +++ b/src/test/javascript/spec/component/code-editor/code-editor-build-output.component.spec.ts @@ -21,12 +21,12 @@ import { ArtemisSharedModule } from 'app/shared/shared.module'; import { ResultService } from 'app/exercises/shared/result/result.service'; import { AnnotationArray } from 'app/entities/annotation.model'; import { Feedback } from 'app/entities/feedback.model'; -import { MockResultService } from '../../mocks/mock-result.service'; -import { MockCodeEditorBuildLogService } from '../../mocks/mock-code-editor-build-log.service'; -import { MockCodeEditorSessionService } from '../../mocks/mock-code-editor-session.service'; -import { MockSyncStorage } from '../../mocks/mock-sync.storage'; -import { MockParticipationWebsocketService } from '../../mocks/mock-participation-websocket.service'; -import { MockCookieService } from '../../mocks/mock-cookie.service'; +import { MockResultService } from '../../mocks/service/mock-result.service'; +import { MockCodeEditorBuildLogService } from '../../mocks/service/mock-code-editor-build-log.service'; +import { MockCodeEditorSessionService } from '../../mocks/service/mock-code-editor-session.service'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockParticipationWebsocketService } from '../../mocks/service/mock-participation-websocket.service'; +import { MockCookieService } from '../../mocks/service/mock-cookie.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/component/code-editor/code-editor-file-browser.component.spec.ts b/src/test/javascript/spec/component/code-editor/code-editor-file-browser.component.spec.ts index 78ac5d0c29c0..f2bd1d21a752 100644 --- a/src/test/javascript/spec/component/code-editor/code-editor-file-browser.component.spec.ts +++ b/src/test/javascript/spec/component/code-editor/code-editor-file-browser.component.spec.ts @@ -24,11 +24,11 @@ import { CodeEditorFileBrowserCreateNodeComponent } from 'app/exercises/programm import { CodeEditorFileBrowserFileComponent } from 'app/exercises/programming/shared/code-editor/file-browser/code-editor-file-browser-file.component'; import { CodeEditorFileBrowserComponent } from 'app/exercises/programming/shared/code-editor/file-browser/code-editor-file-browser.component'; import { CodeEditorStatusComponent } from 'app/exercises/programming/shared/code-editor/status/code-editor-status.component'; -import { MockCodeEditorRepositoryService } from '../../mocks/mock-code-editor-repository.service'; -import { MockCodeEditorRepositoryFileService } from '../../mocks/mock-code-editor-repository-file.service'; -import { MockCodeEditorConflictStateService } from '../../mocks/mock-code-editor-conflict-state.service'; -import { MockSyncStorage } from '../../mocks/mock-sync.storage'; -import { MockCookieService } from '../../mocks/mock-cookie.service'; +import { MockCodeEditorRepositoryService } from '../../mocks/service/mock-code-editor-repository.service'; +import { MockCodeEditorRepositoryFileService } from '../../mocks/service/mock-code-editor-repository-file.service'; +import { MockCodeEditorConflictStateService } from '../../mocks/service/mock-code-editor-conflict-state.service'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockCookieService } from '../../mocks/service/mock-cookie.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/component/code-editor/code-editor-instructions.component.spec.ts b/src/test/javascript/spec/component/code-editor/code-editor-instructions.component.spec.ts index b15b91f93530..92f28a650cda 100644 --- a/src/test/javascript/spec/component/code-editor/code-editor-instructions.component.spec.ts +++ b/src/test/javascript/spec/component/code-editor/code-editor-instructions.component.spec.ts @@ -9,7 +9,7 @@ import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; import { AceEditorModule } from 'ng2-ace-editor'; import { ArtemisTestModule } from '../../test.module'; -import { MockCodeEditorGridService } from '../../mocks/mock-code-editor-grid.service'; +import { MockCodeEditorGridService } from '../../mocks/service/mock-code-editor-grid.service'; import { CodeEditorRepositoryFileService } from 'app/exercises/programming/shared/code-editor/service/code-editor-repository.service'; import { CodeEditorGridService } from 'app/exercises/programming/shared/code-editor/service/code-editor-grid.service'; import { CodeEditorInstructionsComponent } from 'app/exercises/programming/shared/code-editor/instructions/code-editor-instructions.component'; @@ -17,7 +17,7 @@ import { ProgrammingExerciseInstructionComponent } from 'app/exercises/programmi import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; import { ProgrammingExerciseEditableInstructionComponent } from 'app/exercises/programming/manage/instructions-editor/programming-exercise-editable-instruction.component'; import { ArtemisMarkdownEditorModule } from 'app/shared/markdown-editor/markdown-editor.module'; -import { MockCodeEditorRepositoryFileService } from '../../mocks/mock-code-editor-repository-file.service'; +import { MockCodeEditorRepositoryFileService } from '../../mocks/service/mock-code-editor-repository-file.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/component/complaints-for-tutor/complaints-for-tutor.component.spec.ts b/src/test/javascript/spec/component/complaints-for-tutor/complaints-for-tutor.component.spec.ts index 4f1b2dae99ed..7d99e4ab37df 100644 --- a/src/test/javascript/spec/component/complaints-for-tutor/complaints-for-tutor.component.spec.ts +++ b/src/test/javascript/spec/component/complaints-for-tutor/complaints-for-tutor.component.spec.ts @@ -2,8 +2,8 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import * as chai from 'chai'; import { BrowserModule, By } from '@angular/platform-browser'; import { ComplaintService } from 'app/complaints/complaint.service'; -import { MockComplaintService } from '../../mocks/mock-complaint.service'; -import { MockAlertService } from '../../mocks/mock-alert.service'; +import { MockComplaintService } from '../../mocks/service/mock-complaint.service'; +import { MockAlertService } from '../../mocks/service/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { MomentModule } from 'ngx-moment'; diff --git a/src/test/javascript/spec/component/complaints/complaints.component.spec.ts b/src/test/javascript/spec/component/complaints/complaints.component.spec.ts index 04c43a809bf3..52c6abdf1b6b 100644 --- a/src/test/javascript/spec/component/complaints/complaints.component.spec.ts +++ b/src/test/javascript/spec/component/complaints/complaints.component.spec.ts @@ -2,8 +2,8 @@ import { async, ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core import * as chai from 'chai'; import { By } from '@angular/platform-browser'; import { ComplaintService } from 'app/complaints/complaint.service'; -import { MockComplaintResponse, MockComplaintService } from '../../mocks/mock-complaint.service'; -import { MockAlertService } from '../../mocks/mock-alert.service'; +import { MockComplaintResponse, MockComplaintService } from '../../mocks/service/mock-complaint.service'; +import { MockAlertService } from '../../mocks/service/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; import { MomentModule } from 'ngx-moment'; import { DebugElement } from '@angular/core'; diff --git a/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.component.spec.ts b/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.component.spec.ts index ebe97cef3213..d91b9bf0cb81 100644 --- a/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.component.spec.ts +++ b/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.component.spec.ts @@ -7,19 +7,19 @@ import * as sinonChai from 'sinon-chai'; import * as moment from 'moment'; import { SinonStub, stub } from 'sinon'; import { ArtemisTestModule } from '../../test.module'; -import { MockSyncStorage } from '../../mocks/mock-sync.storage'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; import { MockComponent } from 'ng-mocks'; import { ArtemisSharedModule } from 'app/shared/shared.module'; -import { MockAlertService } from '../../mocks/mock-alert.service'; +import { MockAlertService } from '../../mocks/service/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; import { Router } from '@angular/router'; import { FileUploadAssessmentComponent } from 'app/exercises/file-upload/assess/file-upload-assessment.component'; import { ResizableInstructionsComponent } from 'app/exercises/text/assess/resizable-instructions/resizable-instructions.component'; import { DebugElement } from '@angular/core'; -import { MockAccountService } from '../../mocks/mock-account.service'; +import { MockAccountService } from '../../mocks/service/mock-account.service'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { ComplaintService } from 'app/complaints/complaint.service'; -import { MockComplaintService } from '../../mocks/mock-complaint.service'; +import { MockComplaintService } from '../../mocks/service/mock-complaint.service'; import { ArtemisAssessmentSharedModule } from 'app/assessment/assessment-shared.module'; import { TranslateModule } from '@ngx-translate/core'; import { FileUploadExercise } from 'app/entities/file-upload-exercise.model'; diff --git a/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise-detail.component.spec.ts b/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise-detail.component.spec.ts index b7e0a8fb69ee..6b4a85c2fc6a 100644 --- a/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise-detail.component.spec.ts +++ b/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise-detail.component.spec.ts @@ -7,15 +7,15 @@ import { FileUploadExerciseDetailComponent } from 'app/exercises/file-upload/man import { By } from '@angular/platform-browser'; import * as sinonChai from 'sinon-chai'; import * as chai from 'chai'; -import { fileUploadExercise, MockFileUploadExerciseService } from '../../mocks/mock-file-upload-exercise.service'; +import { fileUploadExercise, MockFileUploadExerciseService } from '../../mocks/service/mock-file-upload-exercise.service'; import { JhiLanguageHelper } from 'app/core/language/language.helper'; import { AlertService } from 'app/core/alert/alert.service'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { RouterTestingModule } from '@angular/router/testing'; import { TranslateModule } from '@ngx-translate/core'; import { ArtemisAssessmentSharedModule } from 'app/assessment/assessment-shared.module'; -import { MockSyncStorage } from '../../mocks/mock-sync.storage'; -import { MockCookieService } from '../../mocks/mock-cookie.service'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockCookieService } from '../../mocks/service/mock-cookie.service'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { CookieService } from 'ngx-cookie-service'; import { FileUploadExerciseService } from 'app/exercises/file-upload/manage/file-upload-exercise.service'; diff --git a/src/test/javascript/spec/component/file-upload-submission/file-upload-result.component.spec.ts b/src/test/javascript/spec/component/file-upload-submission/file-upload-result.component.spec.ts index 5bec1b9fa35b..29d7e4293eaa 100644 --- a/src/test/javascript/spec/component/file-upload-submission/file-upload-result.component.spec.ts +++ b/src/test/javascript/spec/component/file-upload-submission/file-upload-result.component.spec.ts @@ -5,11 +5,11 @@ import * as sinonChai from 'sinon-chai'; import { ArtemisTestModule } from '../../test.module'; import { Result } from 'app/entities/result.model'; import { ArtemisSharedModule } from 'app/shared/shared.module'; -import { MockAlertService } from '../../mocks/mock-alert.service'; +import { MockAlertService } from '../../mocks/service/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; import { DebugElement } from '@angular/core'; import { By } from '@angular/platform-browser'; -import { MockAccountService } from '../../mocks/mock-account.service'; +import { MockAccountService } from '../../mocks/service/mock-account.service'; import { NgxDatatableModule } from '@swimlane/ngx-datatable'; import { TranslateModule } from '@ngx-translate/core'; import { FileUploadResultComponent } from 'app/exercises/file-upload/participate/file-upload-result.component'; diff --git a/src/test/javascript/spec/component/file-upload-submission/file-upload-submission.component.spec.ts b/src/test/javascript/spec/component/file-upload-submission/file-upload-submission.component.spec.ts index 5760994fef30..26bdc45cc7ff 100644 --- a/src/test/javascript/spec/component/file-upload-submission/file-upload-submission.component.spec.ts +++ b/src/test/javascript/spec/component/file-upload-submission/file-upload-submission.component.spec.ts @@ -4,26 +4,26 @@ import { AccountService } from 'app/core/auth/account.service'; import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; import { ArtemisTestModule } from '../../test.module'; -import { MockSyncStorage } from '../../mocks/mock-sync.storage'; -import { MockParticipationWebsocketService } from '../../mocks/mock-participation-websocket.service'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockParticipationWebsocketService } from '../../mocks/service/mock-participation-websocket.service'; import { MockComponent } from 'ng-mocks'; -import { MockAlertService } from '../../mocks/mock-alert.service'; +import { MockAlertService } from '../../mocks/service/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; import { Router } from '@angular/router'; import { ResizableInstructionsComponent } from 'app/exercises/text/assess/resizable-instructions/resizable-instructions.component'; import { DebugElement } from '@angular/core'; import { By } from '@angular/platform-browser'; -import { MockAccountService } from '../../mocks/mock-account.service'; +import { MockAccountService } from '../../mocks/service/mock-account.service'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { ComplaintService } from 'app/complaints/complaint.service'; -import { MockComplaintService } from '../../mocks/mock-complaint.service'; +import { MockComplaintService } from '../../mocks/service/mock-complaint.service'; import { NgxDatatableModule } from '@swimlane/ngx-datatable'; import { routes } from 'app/exercises/file-upload/participate/file-upload-participation.route'; import { FileUploadSubmissionComponent } from 'app/exercises/file-upload/participate/file-upload-submission.component'; import { MomentModule } from 'ngx-moment'; -import { createFileUploadSubmission, MockFileUploadSubmissionService } from '../../mocks/mock-file-upload-submission.service'; +import { createFileUploadSubmission, MockFileUploadSubmissionService } from '../../mocks/service/mock-file-upload-submission.service'; import { ParticipationWebsocketService } from 'app/overview/participation-websocket.service'; -import { fileUploadExercise } from '../../mocks/mock-file-upload-exercise.service'; +import { fileUploadExercise } from '../../mocks/service/mock-file-upload-exercise.service'; import { MAX_SUBMISSION_FILE_SIZE } from 'app/shared/constants/input.constants'; import { TranslateModule } from '@ngx-translate/core'; import * as sinon from 'sinon'; diff --git a/src/test/javascript/spec/component/guided-tour/guided-tour.component.spec.ts b/src/test/javascript/spec/component/guided-tour/guided-tour.component.spec.ts index a55525305149..a50d4f06872f 100644 --- a/src/test/javascript/spec/component/guided-tour/guided-tour.component.spec.ts +++ b/src/test/javascript/spec/component/guided-tour/guided-tour.component.spec.ts @@ -8,8 +8,8 @@ import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { of } from 'rxjs'; import { TranslateService } from '@ngx-translate/core'; import { ArtemisTestModule } from '../../test.module'; -import { MockSyncStorage } from '../../mocks/mock-sync.storage'; -import { MockCookieService } from '../../mocks/mock-cookie.service'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockCookieService } from '../../mocks/service/mock-cookie.service'; import { TextTourStep } from 'app/guided-tour/guided-tour-step.model'; import { GuidedTour } from 'app/guided-tour/guided-tour.model'; import { GuidedTourComponent } from 'app/guided-tour/guided-tour.component'; @@ -18,7 +18,7 @@ import { Orientation, OverlayPosition, ResetParticipation } from 'app/guided-tou import { DeviceDetectorService } from 'ngx-device-detector'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { By } from '@angular/platform-browser'; -import { MockTranslateService } from '../../mocks/mock-translate.service'; +import { MockTranslateService } from '../../mocks/service/mock-translate.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/component/list-of-complaints/list-of-complaints.component.spec.ts b/src/test/javascript/spec/component/list-of-complaints/list-of-complaints.component.spec.ts index a0c0fc3e1f3d..1275e37a641e 100644 --- a/src/test/javascript/spec/component/list-of-complaints/list-of-complaints.component.spec.ts +++ b/src/test/javascript/spec/component/list-of-complaints/list-of-complaints.component.spec.ts @@ -5,11 +5,11 @@ import { ArtemisSharedModule } from 'app/shared/shared.module'; import { RouterTestingModule } from '@angular/router/testing'; import { SortByModule } from 'app/shared/pipes/sort-by.module'; import { AlertService } from 'app/core/alert/alert.service'; -import { MockAlertService } from '../../mocks/mock-alert.service'; +import { MockAlertService } from '../../mocks/service/mock-alert.service'; import { ComplaintService } from 'app/complaints/complaint.service'; import { DifferencePipe } from 'ngx-moment'; import { ActivatedRoute } from '@angular/router'; -import { MockActivatedRoute } from '../../mocks/mock-route.service'; +import { MockActivatedRoute } from '../../mocks/service/mock-route.service'; import { ListOfComplaintsComponent } from 'app/complaints/list-of-complaints/list-of-complaints.component'; describe('ListOfComplaintsComponent', () => { diff --git a/src/test/javascript/spec/component/modeling-assessment-editor/modeling-assessment-editor.component.spec.ts b/src/test/javascript/spec/component/modeling-assessment-editor/modeling-assessment-editor.component.spec.ts index 27d6aaaa5a5d..dc8673a19bd9 100644 --- a/src/test/javascript/spec/component/modeling-assessment-editor/modeling-assessment-editor.component.spec.ts +++ b/src/test/javascript/spec/component/modeling-assessment-editor/modeling-assessment-editor.component.spec.ts @@ -11,7 +11,7 @@ import { RouterTestingModule } from '@angular/router/testing'; import { User } from 'app/core/user/user.model'; import { JhiLanguageHelper } from 'app/core/language/language.helper'; import { AccountService } from 'app/core/auth/account.service'; -import { MockAccountService } from '../../mocks/mock-account.service'; +import { MockAccountService } from '../../mocks/service/mock-account.service'; import { AssessmentLayoutComponent } from 'app/assessment/assessment-layout/assessment-layout.component'; import { AssessmentHeaderComponent } from 'app/assessment/assessment-header/assessment-header.component'; import { Course } from 'app/entities/course.model'; diff --git a/src/test/javascript/spec/component/modeling-submission/modeling-submission.component.spec.ts b/src/test/javascript/spec/component/modeling-submission/modeling-submission.component.spec.ts index a7869758694c..985da1286915 100644 --- a/src/test/javascript/spec/component/modeling-submission/modeling-submission.component.spec.ts +++ b/src/test/javascript/spec/component/modeling-submission/modeling-submission.component.spec.ts @@ -6,9 +6,9 @@ import { ArtemisTestModule } from '../../test.module'; import { ModelingSubmissionComponent } from 'app/exercises/modeling/participate/modeling-submission.component'; import { ModelingSubmissionService } from 'app/exercises/modeling/participate/modeling-submission.service'; import { ModelingSubmission } from 'app/entities/modeling-submission.model'; -import { MockSyncStorage } from '../../mocks/mock-sync.storage'; -import { MockParticipationWebsocketService } from '../../mocks/mock-participation-websocket.service'; -import { MockCookieService } from '../../mocks/mock-cookie.service'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockParticipationWebsocketService } from '../../mocks/service/mock-participation-websocket.service'; +import { MockCookieService } from '../../mocks/service/mock-cookie.service'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { CookieService } from 'ngx-cookie-service'; import { TranslateModule } from '@ngx-translate/core'; @@ -19,8 +19,8 @@ import { DebugElement } from '@angular/core'; import { By } from '@angular/platform-browser'; import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; -import { MockAlertService } from '../../mocks/mock-alert.service'; -import { MockComplaintService } from '../../mocks/mock-complaint.service'; +import { MockAlertService } from '../../mocks/service/mock-alert.service'; +import { MockComplaintService } from '../../mocks/service/mock-complaint.service'; import { AlertService } from 'app/core/alert/alert.service'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { ArtemisSharedComponentModule } from 'app/shared/components/shared-component.module'; diff --git a/src/test/javascript/spec/component/overview/course-exercises/course-exercise-row.component.spec.ts b/src/test/javascript/spec/component/overview/course-exercises/course-exercise-row.component.spec.ts index ee885b56dc0b..a7a6fedb73e9 100644 --- a/src/test/javascript/spec/component/overview/course-exercises/course-exercise-row.component.spec.ts +++ b/src/test/javascript/spec/component/overview/course-exercises/course-exercise-row.component.spec.ts @@ -8,18 +8,18 @@ import { ParticipationWebsocketService } from 'app/overview/participation-websoc import { ArtemisTestModule } from '../../../test.module'; import { TranslateModule } from '@ngx-translate/core'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; -import { MockOrionConnectorService } from '../../../mocks/mock-orion-connector.service'; -import { MockCourseExerciseService } from '../../../mocks/mock-course-exercise.service'; +import { MockOrionConnectorService } from '../../../mocks/service/mock-orion-connector.service'; +import { MockCourseExerciseService } from '../../../mocks/service/mock-course-exercise.service'; import { AlertService } from 'app/core/alert/alert.service'; -import { MockAlertService } from '../../../mocks/mock-alert.service'; -import { MockParticipationWebsocketService } from '../../../mocks/mock-participation-websocket.service'; +import { MockAlertService } from '../../../mocks/service/mock-alert.service'; +import { MockParticipationWebsocketService } from '../../../mocks/service/mock-participation-websocket.service'; import { Result } from 'app/entities/result.model'; import { DeviceDetectorService } from 'ngx-device-detector'; import { of } from 'rxjs'; import { AccountService } from 'app/core/auth/account.service'; -import { MockAccountService } from '../../../mocks/mock-account.service'; +import { MockAccountService } from '../../../mocks/service/mock-account.service'; import * as moment from 'moment'; -import { MockCourseService } from '../../../mocks/mock-course.service'; +import { MockCourseService } from '../../../mocks/service/mock-course.service'; import { Exercise, ExerciseType, ParticipationStatus } from 'app/entities/exercise.model'; import { ArtemisCoursesModule } from 'app/overview/courses.module'; import { InitializationState } from 'app/entities/participation/participation.model'; @@ -28,7 +28,7 @@ import { CourseExerciseRowComponent } from 'app/overview/course-exercises/course import { QuizExercise } from 'app/entities/quiz/quiz-exercise.model'; import { CourseExerciseService, CourseManagementService } from 'app/course/manage/course-management.service'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; -import { MockSyncStorage } from '../../../mocks/mock-sync.storage'; +import { MockSyncStorage } from '../../../mocks/service/mock-sync-storage.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/component/overview/course-statistics/course-statistics.component.spec.ts b/src/test/javascript/spec/component/overview/course-statistics/course-statistics.component.spec.ts index c8fc1765caaf..94b35f95b54f 100644 --- a/src/test/javascript/spec/component/overview/course-statistics/course-statistics.component.spec.ts +++ b/src/test/javascript/spec/component/overview/course-statistics/course-statistics.component.spec.ts @@ -12,7 +12,7 @@ import { ArtemisSharedModule } from 'app/shared/shared.module'; import { ActivatedRoute } from '@angular/router'; import { By } from '@angular/platform-browser'; import { Course } from 'app/entities/course.model'; -import { MockSyncStorage } from '../../../mocks/mock-sync.storage'; +import { MockSyncStorage } from '../../../mocks/service/mock-sync-storage.service'; import { Result } from 'app/entities/result.model'; import { CourseScoreCalculationService } from 'app/overview/course-score-calculation.service'; import { ProgrammingSubmission } from 'app/entities/programming-submission.model'; diff --git a/src/test/javascript/spec/component/overview/exercise-details/exercise-details-student-actions.component.spec.ts b/src/test/javascript/spec/component/overview/exercise-details/exercise-details-student-actions.component.spec.ts index 2471617efd01..ecfcff4f39a9 100644 --- a/src/test/javascript/spec/component/overview/exercise-details/exercise-details-student-actions.component.spec.ts +++ b/src/test/javascript/spec/component/overview/exercise-details/exercise-details-student-actions.component.spec.ts @@ -13,25 +13,25 @@ import { MockComponent } from 'ng-mocks'; import { FeatureToggleModule } from 'app/shared/feature-toggle/feature-toggle.module'; import { FeatureToggleService } from 'app/shared/feature-toggle/feature-toggle.service'; import { InitializationState } from 'app/entities/participation/participation.model'; -import { MockFeatureToggleService } from '../../../mocks/mock-feature-toggle-service'; +import { MockFeatureToggleService } from '../../../mocks/service/mock-feature-toggle.service'; import { ExerciseMode, ExerciseType, ParticipationStatus } from 'app/entities/exercise.model'; -import { MockCourseExerciseService } from '../../../mocks/mock-course-exercise.service'; +import { MockCourseExerciseService } from '../../../mocks/service/mock-course-exercise.service'; import { ExerciseActionButtonComponent } from 'app/overview/exercise-details/exercise-action-button.component'; import { StudentParticipation } from 'app/entities/participation/student-participation.model'; import { ArtemisTestModule } from '../../../test.module'; import { JhiAlertService } from 'ng-jhipster'; -import { MockAlertService } from '../../../mocks/mock-alert.service'; +import { MockAlertService } from '../../../mocks/service/mock-alert.service'; import { ExerciseDetailsStudentActionsComponent } from 'app/overview/exercise-details/exercise-details-student-actions.component'; import { Team } from 'app/entities/team.model'; import { RouterModule } from '@angular/router'; import { ClipboardModule } from 'ngx-clipboard'; import { AccountService } from 'app/core/auth/account.service'; -import { MockAccountService } from '../../../mocks/mock-account.service'; +import { MockAccountService } from '../../../mocks/service/mock-account.service'; import { User } from 'app/core/user/user.model'; import { By } from '@angular/platform-browser'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; import { ProfileService } from 'app/shared/layouts/profiles/profile.service'; -import { MockProfileService } from '../../../mocks/mock-profile.service'; +import { MockProfileService } from '../../../mocks/service/mock-profile.service'; import { ProfileInfo } from 'app/shared/layouts/profiles/profile-info.model'; chai.use(sinonChai); diff --git a/src/test/javascript/spec/component/overview/exercise-details/programming-exercise-student-ide-actions.component.spec.ts b/src/test/javascript/spec/component/overview/exercise-details/programming-exercise-student-ide-actions.component.spec.ts index 8bf5ed6e07d9..69b127e1fb62 100644 --- a/src/test/javascript/spec/component/overview/exercise-details/programming-exercise-student-ide-actions.component.spec.ts +++ b/src/test/javascript/spec/component/overview/exercise-details/programming-exercise-student-ide-actions.component.spec.ts @@ -15,19 +15,19 @@ import { FeatureToggleModule } from 'app/shared/feature-toggle/feature-toggle.mo import { FeatureToggleService } from 'app/shared/feature-toggle/feature-toggle.service'; import { ProgrammingExerciseStudentIdeActionsComponent } from 'app/overview/exercise-details/programming-exercise-student-ide-actions.component'; import { InitializationState } from 'app/entities/participation/participation.model'; -import { MockFeatureToggleService } from '../../../mocks/mock-feature-toggle-service'; +import { MockFeatureToggleService } from '../../../mocks/service/mock-feature-toggle.service'; import { Exercise, ParticipationStatus } from 'app/entities/exercise.model'; -import { MockCourseExerciseService } from '../../../mocks/mock-course-exercise.service'; +import { MockCourseExerciseService } from '../../../mocks/service/mock-course-exercise.service'; import { ExerciseActionButtonComponent } from 'app/overview/exercise-details/exercise-action-button.component'; import { StudentParticipation } from 'app/entities/participation/student-participation.model'; import { ProgrammingExerciseStudentParticipation } from 'app/entities/participation/programming-exercise-student-participation.model'; import { ArtemisTestModule } from '../../../test.module'; import { JhiAlertService } from 'ng-jhipster'; -import { MockAlertService } from '../../../mocks/mock-alert.service'; -import { MockOrionConnectorService } from '../../../mocks/mock-orion-connector.service'; +import { MockAlertService } from '../../../mocks/service/mock-alert.service'; +import { MockOrionConnectorService } from '../../../mocks/service/mock-orion-connector.service'; import { ArtemisOrionConnector, OrionState } from 'app/shared/orion/orion'; import { OrionModule } from 'app/shared/orion/orion.module'; -import { MockIdeBuildAndTestService } from '../../../mocks/mock-ide-build-and-test.service'; +import { MockIdeBuildAndTestService } from '../../../mocks/service/mock-ide-build-and-test.service'; import { OrionBuildAndTestService } from 'app/shared/orion/orion-build-and-test.service'; chai.use(sinonChai); diff --git a/src/test/javascript/spec/component/overview/overview.component.spec.ts b/src/test/javascript/spec/component/overview/overview.component.spec.ts index 8dd57e7607c7..92d0373ae7f7 100644 --- a/src/test/javascript/spec/component/overview/overview.component.spec.ts +++ b/src/test/javascript/spec/component/overview/overview.component.spec.ts @@ -8,20 +8,20 @@ import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { ArtemisTestModule } from '../../test.module'; import { GuidedTourService } from 'app/guided-tour/guided-tour.service'; import { GuidedTourComponent } from 'app/guided-tour/guided-tour.component'; -import { MockAccountService } from '../../mocks/mock-account.service'; +import { MockAccountService } from '../../mocks/service/mock-account.service'; import { AccountService } from 'app/core/auth/account.service'; import { DeviceDetectorService } from 'ngx-device-detector'; -import { MockSyncStorage } from '../../mocks/mock-sync.storage'; -import { MockCookieService } from '../../mocks/mock-cookie.service'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockCookieService } from '../../mocks/service/mock-cookie.service'; import { RouterTestingModule } from '@angular/router/testing'; import { courseOverviewTour } from 'app/guided-tour/tours/course-overview-tour'; import { CoursesComponent } from 'app/overview/courses.component'; -import { TranslateTestingModule } from '../../mocks/mock-translate.service'; +import { TranslateTestingModule } from '../../mocks/service/mock-translate.service'; import { NavbarComponent } from 'app/shared/layouts/navbar/navbar.component'; import { ActiveMenuDirective } from 'app/shared/layouts/navbar/active-menu.directive'; import { NotificationContainerComponent } from 'app/shared/layouts/notification-container/notification-container.component'; import { User } from 'app/core/user/user.model'; -import { MockHasAnyAuthorityDirective } from '../../mocks/mock-has-any-authority.directive'; +import { MockHasAnyAuthorityDirective } from '../../mocks/directive/mock-has-any-authority.directive'; import { ArtemisSharedPipesModule } from 'app/shared/pipes/shared-pipes.module'; import { ArtemisSharedCommonModule } from 'app/shared/shared-common.module'; import { CourseCardComponent } from 'app/overview/course-card.component'; diff --git a/src/test/javascript/spec/component/participation-submission/participation-submission.component.spec.ts b/src/test/javascript/spec/component/participation-submission/participation-submission.component.spec.ts index 5c344763f27b..07a3885ff7a8 100644 --- a/src/test/javascript/spec/component/participation-submission/participation-submission.component.spec.ts +++ b/src/test/javascript/spec/component/participation-submission/participation-submission.component.spec.ts @@ -6,10 +6,10 @@ import * as sinonChai from 'sinon-chai'; import * as moment from 'moment'; import { SinonStub, stub } from 'sinon'; import { ArtemisTestModule } from '../../test.module'; -import { MockSyncStorage } from '../../mocks/mock-sync.storage'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; import { MockComponent } from 'ng-mocks'; import { ArtemisSharedModule } from 'app/shared/shared.module'; -import { MockAlertService } from '../../mocks/mock-alert.service'; +import { MockAlertService } from '../../mocks/service/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; import { Router } from '@angular/router'; import { of } from 'rxjs'; @@ -18,12 +18,12 @@ import { ResizableInstructionsComponent } from 'app/exercises/text/assess/resiza import { AssessmentDetailComponent } from 'app/assessment/assessment-detail/assessment-detail.component'; import { DebugElement } from '@angular/core'; import { By } from '@angular/platform-browser'; -import { MockAccountService } from '../../mocks/mock-account.service'; +import { MockAccountService } from '../../mocks/service/mock-account.service'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { ComplaintService } from 'app/complaints/complaint.service'; import { ParticipationSubmissionComponent } from 'app/exercises/shared/participation-submission/participation-submission.component'; import { SubmissionService } from 'app/exercises/shared/submission/submission.service'; -import { MockComplaintService } from '../../mocks/mock-complaint.service'; +import { MockComplaintService } from '../../mocks/service/mock-complaint.service'; import { NgxDatatableModule } from '@swimlane/ngx-datatable'; import { TranslateModule } from '@ngx-translate/core'; import { ComplaintsForTutorComponent } from 'app/complaints/complaints-for-tutor/complaints-for-tutor.component'; diff --git a/src/test/javascript/spec/component/participation/participation.component.spec.ts b/src/test/javascript/spec/component/participation/participation.component.spec.ts index 886b6f9afb8a..185de1538f19 100644 --- a/src/test/javascript/spec/component/participation/participation.component.spec.ts +++ b/src/test/javascript/spec/component/participation/participation.component.spec.ts @@ -6,7 +6,7 @@ import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { ArtemisTestModule } from '../../test.module'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { MockActivatedRoute } from '../../mocks/activated-route/mock-activated.route'; -import { MockSyncStorage } from '../../mocks/mock-sync.storage'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; import { ParticipationService } from 'app/exercises/shared/participation/participation.service'; import { ParticipationComponent } from 'app/exercises/shared/participation/participation.component'; import { Course } from 'app/entities/course.model'; diff --git a/src/test/javascript/spec/component/programming-assessment/programming-assessment-manual-result-dialog.component.spec.ts b/src/test/javascript/spec/component/programming-assessment/programming-assessment-manual-result-dialog.component.spec.ts index 6b42c76aab8b..f0b7c40b3d96 100644 --- a/src/test/javascript/spec/component/programming-assessment/programming-assessment-manual-result-dialog.component.spec.ts +++ b/src/test/javascript/spec/component/programming-assessment/programming-assessment-manual-result-dialog.component.spec.ts @@ -9,10 +9,10 @@ import { SinonStub, stub } from 'sinon'; import { of } from 'rxjs'; import { ArtemisTestModule } from '../../test.module'; import { ParticipationWebsocketService } from 'app/overview/participation-websocket.service'; -import { MockResultService } from '../../mocks/mock-result.service'; -import { MockSyncStorage } from '../../mocks/mock-sync.storage'; -import { MockParticipationWebsocketService } from '../../mocks/mock-participation-websocket.service'; -import { MockProgrammingExerciseParticipationService } from '../../mocks/mock-programming-exercise-participation.service'; +import { MockResultService } from '../../mocks/service/mock-result.service'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockParticipationWebsocketService } from '../../mocks/service/mock-participation-websocket.service'; +import { MockProgrammingExerciseParticipationService } from '../../mocks/service/mock-programming-exercise-participation.service'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { BuildLogService } from 'app/exercises/programming/shared/service/build-log.service'; import { FormDateTimePickerModule } from 'app/shared/date-time-picker/date-time-picker.module'; @@ -36,9 +36,9 @@ import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; import { Complaint } from 'app/entities/complaint.model'; import { ComplaintService } from 'app/complaints/complaint.service'; import { ExerciseHintService } from 'app/exercises/shared/exercise-hint/manage/exercise-hint.service'; -import { MockRepositoryFileService } from '../../mocks/mock-repository-file.service'; -import { MockExerciseHintService } from '../../mocks/mock-exercise-hint.service'; -import { MockNgbModalService } from '../../mocks/mock-ngb-modal.service'; +import { MockRepositoryFileService } from '../../mocks/service/mock-repository-file.service'; +import { MockExerciseHintService } from '../../mocks/service/mock-exercise-hint.service'; +import { MockNgbModalService } from '../../mocks/service/mock-ngb-modal.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-editable-instruction.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-editable-instruction.component.spec.ts index 558d61d11efd..27178b1f1c93 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-editable-instruction.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-editable-instruction.component.spec.ts @@ -10,10 +10,10 @@ import * as sinonChai from 'sinon-chai'; import { SinonSpy, SinonStub, spy, stub } from 'sinon'; import { ArtemisTestModule } from '../../test.module'; import { ParticipationWebsocketService } from 'app/overview/participation-websocket.service'; -import { MockResultService } from '../../mocks/mock-result.service'; -import { MockParticipationWebsocketService } from '../../mocks/mock-participation-websocket.service'; +import { MockResultService } from '../../mocks/service/mock-result.service'; +import { MockParticipationWebsocketService } from '../../mocks/service/mock-participation-websocket.service'; import { MarkdownEditorComponent } from 'app/shared/markdown-editor/markdown-editor.component'; -import { MockProgrammingExerciseTestCaseService } from '../../mocks/mock-programming-exercise-test-case.service'; +import { MockProgrammingExerciseTestCaseService } from '../../mocks/service/mock-programming-exercise-test-case.service'; import { ArtemisProgrammingExerciseInstructionsEditorModule } from 'app/exercises/programming/manage/instructions-editor/programming-exercise-instructions-editor.module'; import { triggerChanges } from '../../utils/general.utils'; import { Participation } from 'app/entities/participation/participation.model'; diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-import.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-import.component.spec.ts index 4c001f8a717a..666cf5d4d90e 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-import.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-import.component.spec.ts @@ -12,13 +12,13 @@ import { SortByModule } from 'app/shared/pipes/sort-by.module'; import { DifferencePipe } from 'ngx-moment'; import { FeatureToggleModule } from 'app/shared/feature-toggle/feature-toggle.module'; import { FeatureToggleService } from 'app/shared/feature-toggle/feature-toggle.service'; -import { MockFeatureToggleService } from '../../mocks/mock-feature-toggle-service'; +import { MockFeatureToggleService } from '../../mocks/service/mock-feature-toggle.service'; import { ProgrammingExerciseImportComponent } from 'app/exercises/programming/manage/programming-exercise-import.component'; import { ArtemisSharedCommonModule } from 'app/shared/shared-common.module'; import { ProgrammingExercise, ProgrammingLanguage } from 'app/entities/programming-exercise.model'; import { SearchResult } from 'app/shared/table/pageable-table'; import { ButtonComponent } from 'app/shared/components/button.component'; -import { MockProgrammingExercisePagingService } from '../../mocks/mock-programming-exercise-paging.service'; +import { MockProgrammingExercisePagingService } from '../../mocks/service/mock-programming-exercise-paging.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction.component.spec.ts index e754907ea8ce..7c6046bf76f9 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction.component.spec.ts @@ -12,15 +12,15 @@ import { Observable, of, Subject, Subscription, throwError } from 'rxjs'; import { FaIconComponent } from '@fortawesome/angular-fontawesome'; import { ArtemisTestModule } from '../../test.module'; import { ParticipationWebsocketService } from 'app/overview/participation-websocket.service'; -import { MockResultService } from '../../mocks/mock-result.service'; -import { MockRepositoryFileService } from '../../mocks/mock-repository-file.service'; +import { MockResultService } from '../../mocks/service/mock-result.service'; +import { MockRepositoryFileService } from '../../mocks/service/mock-repository-file.service'; import { problemStatement, problemStatementBubbleSortFailsHtml, problemStatementBubbleSortNotExecutedHtml } from '../../sample/problemStatement.json'; -import { MockNgbModalService } from '../../mocks/mock-ngb-modal.service'; +import { MockNgbModalService } from '../../mocks/service/mock-ngb-modal.service'; import { ProgrammingExerciseInstructionStepWizardComponent } from 'app/exercises/programming/shared/instructions-render/step-wizard/programming-exercise-instruction-step-wizard.component'; import { ProgrammingExerciseInstructionService } from 'app/exercises/programming/shared/instructions-render/service/programming-exercise-instruction.service'; import { ProgrammingExerciseTaskExtensionWrapper } from 'app/exercises/programming/shared/instructions-render/extensions/programming-exercise-task.extension'; import { ProgrammingExercisePlantUmlExtensionWrapper } from 'app/exercises/programming/shared/instructions-render/extensions/programming-exercise-plant-uml.extension'; -import { MockProgrammingExerciseParticipationService } from '../../mocks/mock-programming-exercise-participation.service'; +import { MockProgrammingExerciseParticipationService } from '../../mocks/service/mock-programming-exercise-participation.service'; import { ExerciseHint } from 'app/entities/exercise-hint.model'; import { HttpResponse } from '@angular/common/http'; import { triggerChanges } from '../../utils/general.utils'; @@ -38,9 +38,9 @@ import { Feedback } from 'app/entities/feedback.model'; import { ProgrammingExerciseInstructionComponent } from 'app/exercises/programming/shared/instructions-render/programming-exercise-instruction.component'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; import { ResultDetailComponent } from 'app/shared/result/result-detail.component'; -import { MockSyncStorage } from '../../mocks/mock-sync.storage'; -import { MockParticipationWebsocketService } from '../../mocks/mock-participation-websocket.service'; -import { MockExerciseHintService } from '../../mocks/mock-exercise-hint.service'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockParticipationWebsocketService } from '../../mocks/service/mock-participation-websocket.service'; +import { MockExerciseHintService } from '../../mocks/service/mock-exercise-hint.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-status.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-status.component.spec.ts index 98cc13459ecf..7ef95ae6d294 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-status.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-status.component.spec.ts @@ -8,8 +8,8 @@ import { ArtemisTestModule } from '../../test.module'; import { TranslateModule } from '@ngx-translate/core'; import { By } from '@angular/platform-browser'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; -import { MockSyncStorage } from '../../mocks/mock-sync.storage'; -import { MockCookieService } from '../../mocks/mock-cookie.service'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockCookieService } from '../../mocks/service/mock-cookie.service'; import { SinonStub, stub } from 'sinon'; import { Result } from 'app/entities/result.model'; import { ParticipationWebsocketService } from 'app/overview/participation-websocket.service'; diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-submission-state.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-submission-state.component.spec.ts index f8a709636f60..5ded52f93320 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-submission-state.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-submission-state.component.spec.ts @@ -9,8 +9,8 @@ import { of, Subject } from 'rxjs'; import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; import { ArtemisTestModule } from '../../test.module'; -import { MockSyncStorage } from '../../mocks/mock-sync.storage'; -import { MockParticipationWebsocketService } from '../../mocks/mock-participation-websocket.service'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockParticipationWebsocketService } from '../../mocks/service/mock-participation-websocket.service'; import { ParticipationWebsocketService } from 'app/overview/participation-websocket.service'; import { Exercise } from 'app/entities/exercise.model'; import { ExerciseSubmissionState, ProgrammingSubmissionService, ProgrammingSubmissionState } from 'app/exercises/programming/participate/programming-submission.service'; @@ -18,9 +18,9 @@ import { ArtemisProgrammingExerciseActionsModule } from 'app/exercises/programmi import { ProgrammingExerciseInstructorSubmissionStateComponent } from 'app/exercises/programming/shared/actions/programming-exercise-instructor-submission-state.component'; import { triggerChanges } from '../../utils/general.utils'; import { BuildRunState, ProgrammingBuildRunService } from 'app/exercises/programming/participate/programming-build-run.service'; -import { MockProgrammingBuildRunService } from '../../mocks/mock-programming-build-run.service'; +import { MockProgrammingBuildRunService } from '../../mocks/service/mock-programming-build-run.service'; import { FeatureToggleService } from 'app/shared/feature-toggle/feature-toggle.service'; -import { MockFeatureToggleService } from '../../mocks/mock-feature-toggle-service'; +import { MockFeatureToggleService } from '../../mocks/service/mock-feature-toggle.service'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; chai.use(sinonChai); diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-manage-test-cases.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-manage-test-cases.component.spec.ts index 16d3924a1173..b0b575656c4a 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-manage-test-cases.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-manage-test-cases.component.spec.ts @@ -13,25 +13,25 @@ import { AlertService } from 'app/core/alert/alert.service'; import * as chai from 'chai'; import { ArtemisTestModule } from '../../test.module'; import { TranslateModule } from '@ngx-translate/core'; -import { MockSyncStorage } from '../../mocks/mock-sync.storage'; -import { MockProgrammingExerciseTestCaseService } from '../../mocks/mock-programming-exercise-test-case.service'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockProgrammingExerciseTestCaseService } from '../../mocks/service/mock-programming-exercise-test-case.service'; import { ProgrammingExerciseTestCase } from 'app/entities/programming-exercise-test-case.model'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { ArtemisProgrammingExerciseTestCaseModule } from 'app/exercises/programming/manage/test-cases/programming-exercise-test-case.module'; import { expectElementToBeDisabled, expectElementToBeEnabled, getElement } from '../../utils/general.utils'; import { ProgrammingExerciseWebsocketService } from 'app/exercises/programming/manage/services/programming-exercise-websocket.service'; -import { MockProgrammingExerciseWebsocketService } from '../../mocks/mock-programming-exercise-websocket.service'; +import { MockProgrammingExerciseWebsocketService } from '../../mocks/service/mock-programming-exercise-websocket.service'; import { ProgrammingBuildRunService } from 'app/exercises/programming/participate/programming-build-run.service'; -import { MockProgrammingBuildRunService } from '../../mocks/mock-programming-build-run.service'; +import { MockProgrammingBuildRunService } from '../../mocks/service/mock-programming-build-run.service'; import { FeatureToggleService } from 'app/shared/feature-toggle/feature-toggle.service'; -import { MockFeatureToggleService } from '../../mocks/mock-feature-toggle-service'; +import { MockFeatureToggleService } from '../../mocks/service/mock-feature-toggle.service'; import { EditableField, ProgrammingExerciseManageTestCasesComponent } from 'app/exercises/programming/manage/test-cases/programming-exercise-manage-test-cases.component'; import { ProgrammingExerciseService, ProgrammingExerciseTestCaseStateDTO } from 'app/exercises/programming/manage/services/programming-exercise.service'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; import { ProgrammingExerciseTestCaseService } from 'app/exercises/programming/manage/services/programming-exercise-test-case.service'; import { MockActivatedRoute } from '../../mocks/activated-route/mock-activated.route'; -import { MockCookieService } from '../../mocks/mock-cookie.service'; -import { MockProgrammingExerciseService } from '../../mocks/mock-programming-exercise.service'; +import { MockCookieService } from '../../mocks/service/mock-cookie.service'; +import { MockProgrammingExerciseService } from '../../mocks/service/mock-programming-exercise.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-trigger-build-button.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-trigger-build-button.component.spec.ts index b5d36a7d7adf..9a2a21ea29e8 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-trigger-build-button.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-trigger-build-button.component.spec.ts @@ -12,11 +12,11 @@ import { of, Subject } from 'rxjs'; import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; import { ArtemisTestModule } from '../../test.module'; -import { MockSyncStorage } from '../../mocks/mock-sync.storage'; -import { MockParticipationWebsocketService } from '../../mocks/mock-participation-websocket.service'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockParticipationWebsocketService } from '../../mocks/service/mock-participation-websocket.service'; import { Result } from 'app/entities/result.model'; import { ParticipationWebsocketService } from 'app/overview/participation-websocket.service'; -import { MockAccountService } from '../../mocks/mock-account.service'; +import { MockAccountService } from '../../mocks/service/mock-account.service'; import { Exercise } from 'app/entities/exercise.model'; import { ProgrammingSubmissionService, ProgrammingSubmissionState, ProgrammingSubmissionStateObj } from 'app/exercises/programming/participate/programming-submission.service'; import { ArtemisProgrammingExerciseActionsModule } from 'app/exercises/programming/shared/actions/programming-exercise-actions.module'; diff --git a/src/test/javascript/spec/component/shared/button.component.spec.ts b/src/test/javascript/spec/component/shared/button.component.spec.ts index 42c769490390..6b724ff5636e 100644 --- a/src/test/javascript/spec/component/shared/button.component.spec.ts +++ b/src/test/javascript/spec/component/shared/button.component.spec.ts @@ -9,9 +9,9 @@ import * as sinonChai from 'sinon-chai'; import { ArtemisTestModule } from '../../test.module'; import { ArtemisSharedComponentModule } from 'app/shared/components/shared-component.module'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; -import { MockSyncStorage } from '../../mocks/mock-sync.storage'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; import { FeatureToggleService } from 'app/shared/feature-toggle/feature-toggle.service'; -import { MockFeatureToggleService } from '../../mocks/mock-feature-toggle-service'; +import { MockFeatureToggleService } from '../../mocks/service/mock-feature-toggle.service'; import { ButtonComponent } from 'app/shared/components/button.component'; chai.use(sinonChai); diff --git a/src/test/javascript/spec/component/shared/secured-image.component.spec.ts b/src/test/javascript/spec/component/shared/secured-image.component.spec.ts index 94879e7fd2ed..d6710b8a57fc 100644 --- a/src/test/javascript/spec/component/shared/secured-image.component.spec.ts +++ b/src/test/javascript/spec/component/shared/secured-image.component.spec.ts @@ -7,7 +7,7 @@ import { SinonStub, stub } from 'sinon'; import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; import { ArtemisTestModule } from '../../test.module'; -import { MockCacheableImageService } from '../../mocks/mock-cacheable-image.service'; +import { MockCacheableImageService } from '../../mocks/service/mock-cacheable-image.service'; import { triggerChanges } from '../../utils/general.utils'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { UpdatingResultComponent } from 'app/shared/result/updating-result.component'; diff --git a/src/test/javascript/spec/component/shared/updating-result.component.spec.ts b/src/test/javascript/spec/component/shared/updating-result.component.spec.ts index ad18fe1b1227..11b5291f2961 100644 --- a/src/test/javascript/spec/component/shared/updating-result.component.spec.ts +++ b/src/test/javascript/spec/component/shared/updating-result.component.spec.ts @@ -14,17 +14,17 @@ import * as sinonChai from 'sinon-chai'; import { ArtemisTestModule } from '../../test.module'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { ParticipationWebsocketService } from 'app/overview/participation-websocket.service'; -import { MockAccountService } from '../../mocks/mock-account.service'; +import { MockAccountService } from '../../mocks/service/mock-account.service'; import { ProgrammingSubmissionService, ProgrammingSubmissionState } from 'app/exercises/programming/participate/programming-submission.service'; -import { MockProgrammingSubmissionService } from '../../mocks/mock-programming-submission.service'; +import { MockProgrammingSubmissionService } from '../../mocks/service/mock-programming-submission.service'; import { triggerChanges } from '../../utils/general.utils'; import { Exercise, ExerciseType } from 'app/entities/exercise.model'; import { UpdatingResultComponent } from 'app/shared/result/updating-result.component'; import { ResultComponent } from 'app/shared/result/result.component'; import { CodeEditorFileService } from 'app/exercises/programming/shared/code-editor/service/code-editor-file.service'; import { Result } from 'app/entities/result.model'; -import { MockParticipationWebsocketService } from '../../mocks/mock-participation-websocket.service'; -import { MockSyncStorage } from '../../mocks/mock-sync.storage'; +import { MockParticipationWebsocketService } from '../../mocks/service/mock-participation-websocket.service'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/component/student-questions/student-questions.component.spec.ts b/src/test/javascript/spec/component/student-questions/student-questions.component.spec.ts index 0c7eb998eaaa..7a11c6770c4e 100644 --- a/src/test/javascript/spec/component/student-questions/student-questions.component.spec.ts +++ b/src/test/javascript/spec/component/student-questions/student-questions.component.spec.ts @@ -3,7 +3,7 @@ import * as sinonChai from 'sinon-chai'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { TranslateModule } from '@ngx-translate/core'; import { AccountService } from 'app/core/auth/account.service'; -import { MockAccountService } from '../../mocks/mock-account.service'; +import { MockAccountService } from '../../mocks/service/mock-account.service'; import { StudentQuestionsComponent } from 'app/overview/student-questions/student-questions.component'; import { Lecture } from 'app/entities/lecture.model'; import { StudentQuestionAnswer } from 'app/entities/student-question-answer.model'; diff --git a/src/test/javascript/spec/component/team/team-update-dialog.component.spec.ts b/src/test/javascript/spec/component/team/team-update-dialog.component.spec.ts index b6ee0bf2efee..61145c2d93a2 100644 --- a/src/test/javascript/spec/component/team/team-update-dialog.component.spec.ts +++ b/src/test/javascript/spec/component/team/team-update-dialog.component.spec.ts @@ -11,13 +11,13 @@ import { FormsModule } from '@angular/forms'; import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap'; import * as sinon from 'sinon'; import { AlertService } from 'app/core/alert/alert.service'; -import { MockAlertService } from '../../mocks/mock-alert.service'; +import { MockAlertService } from '../../mocks/service/mock-alert.service'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { ArtemisSharedComponentModule } from 'app/shared/components/shared-component.module'; import { ArtemisTeamModule } from 'app/exercises/shared/team/team.module'; -import { mockEmptyTeam, mockExercise, mockNonTeamStudents, mockTeam, MockTeamService, mockTeamStudents } from '../../mocks/mock-team.service'; +import { mockEmptyTeam, mockExercise, mockNonTeamStudents, mockTeam, MockTeamService, mockTeamStudents } from '../../mocks/service/mock-team.service'; import { TeamService } from 'app/exercises/shared/team/team.service'; -import { MockSyncStorage } from '../../mocks/mock-sync.storage'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; chai.use(sinonChai); diff --git a/src/test/javascript/spec/component/team/teams.component.spec.ts b/src/test/javascript/spec/component/team/teams.component.spec.ts index 975b81ab450f..ce8cfbbc7faf 100644 --- a/src/test/javascript/spec/component/team/teams.component.spec.ts +++ b/src/test/javascript/spec/component/team/teams.component.spec.ts @@ -9,7 +9,7 @@ import { JhiEventManager, NgJhipsterModule } from 'ng-jhipster'; import { FormsModule } from '@angular/forms'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { AlertService } from 'app/core/alert/alert.service'; -import { MockAlertService } from '../../mocks/mock-alert.service'; +import { MockAlertService } from '../../mocks/service/mock-alert.service'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { ArtemisSharedComponentModule } from 'app/shared/components/shared-component.module'; import { ArtemisTeamModule } from 'app/exercises/shared/team/team.module'; @@ -21,19 +21,19 @@ import { DifferencePipe } from 'ngx-moment'; import { SortByPipe } from 'app/shared/pipes/sort-by.pipe'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { CookieService } from 'ngx-cookie-service'; -import { MockSyncStorage } from '../../mocks/mock-sync.storage'; -import { MockCookieService } from '../../mocks/mock-cookie.service'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockCookieService } from '../../mocks/service/mock-cookie.service'; import { ActivatedRoute } from '@angular/router'; import { of } from 'rxjs'; -import { mockTeams, MockTeamService } from '../../mocks/mock-team.service'; -import { MockExerciseService } from '../../mocks/mock-exercise.service'; +import { mockTeams, MockTeamService } from '../../mocks/service/mock-team.service'; +import { MockExerciseService } from '../../mocks/service/mock-exercise.service'; import { teamRoute } from 'app/exercises/shared/team/team.route.ts'; import { RouterTestingModule } from '@angular/router/testing'; import { Router } from '@angular/router'; import { ParticipationService } from 'app/exercises/shared/participation/participation.service'; -import { MockParticipationService } from '../../mocks/mock-participation.service'; +import { MockParticipationService } from '../../mocks/service/mock-participation.service'; import { AccountService } from 'app/core/auth/account.service'; -import { MockAccountService } from '../../mocks/mock-account.service'; +import { MockAccountService } from '../../mocks/service/mock-account.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/component/text-editor/text-editor.component.spec.ts b/src/test/javascript/spec/component/text-editor/text-editor.component.spec.ts index 9b4f6e6aa5df..cdce95a0f8fb 100644 --- a/src/test/javascript/spec/component/text-editor/text-editor.component.spec.ts +++ b/src/test/javascript/spec/component/text-editor/text-editor.component.spec.ts @@ -6,7 +6,7 @@ import { ComponentFixture, fakeAsync, TestBed, tick, flush } from '@angular/core import { AlertService } from 'app/core/alert/alert.service'; import { ArtemisTestModule } from '../../test.module'; import { TranslateModule } from '@ngx-translate/core'; -import { MockTextEditorService } from '../../mocks/mock-text-editor.service'; +import { MockTextEditorService } from '../../mocks/service/mock-text-editor.service'; import { SinonStub, stub } from 'sinon'; import * as sinonChai from 'sinon-chai'; import { TextEditorService } from 'app/exercises/text/participate/text-editor.service'; @@ -14,7 +14,7 @@ import { BehaviorSubject } from 'rxjs'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { RouterTestingModule } from '@angular/router/testing'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; -import { MockSyncStorage } from '../../mocks/mock-sync.storage'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; import { MockComponent } from 'ng-mocks'; import { TextResultComponent } from 'app/exercises/text/participate/text-result/text-result.component'; import { ComplaintInteractionsComponent } from 'app/complaints/complaint-interactions.component'; diff --git a/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.component.spec.ts b/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.component.spec.ts index dd6aad99c252..f15a02511955 100644 --- a/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.component.spec.ts +++ b/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.component.spec.ts @@ -7,11 +7,11 @@ import * as sinonChai from 'sinon-chai'; import * as moment from 'moment'; import { SinonStub, stub } from 'sinon'; import { ArtemisTestModule } from '../../test.module'; -import { MockSyncStorage } from '../../mocks/mock-sync.storage'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; import { Result } from 'app/entities/result.model'; import { MockComponent } from 'ng-mocks'; import { ArtemisSharedModule } from 'app/shared/shared.module'; -import { MockAlertService } from '../../mocks/mock-alert.service'; +import { MockAlertService } from '../../mocks/service/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; import { ActivatedRoute, Router } from '@angular/router'; import { of, throwError } from 'rxjs'; @@ -21,11 +21,11 @@ import { ResizableInstructionsComponent } from 'app/exercises/text/assess/resiza import { AssessmentDetailComponent } from 'app/assessment/assessment-detail/assessment-detail.component'; import { DebugElement } from '@angular/core'; import { By } from '@angular/platform-browser'; -import { MockAccountService } from '../../mocks/mock-account.service'; +import { MockAccountService } from '../../mocks/service/mock-account.service'; import { textAssessmentRoutes } from 'app/exercises/text/assess/text-assessment.route'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { ComplaintService } from 'app/complaints/complaint.service'; -import { MockComplaintResponse, MockComplaintService } from '../../mocks/mock-complaint.service'; +import { MockComplaintResponse, MockComplaintService } from '../../mocks/service/mock-complaint.service'; import { TranslateModule } from '@ngx-translate/core'; import { TextSubmissionService } from 'app/exercises/text/participate/text-submission.service'; import { ComplaintsForTutorComponent } from 'app/complaints/complaints-for-tutor/complaints-for-tutor.component'; diff --git a/src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.component.spec.ts b/src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.component.spec.ts index aaf73bb8625f..360e4fc0b905 100644 --- a/src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.component.spec.ts +++ b/src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.component.spec.ts @@ -5,13 +5,13 @@ import * as sinonChai from 'sinon-chai'; import { SinonStub, stub } from 'sinon'; import { ArtemisTestModule } from '../../test.module'; import { MockActivatedRoute } from '../../mocks/activated-route/mock-activated.route'; -import { MockSyncStorage } from '../../mocks/mock-sync.storage'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; import { MockComponent } from 'ng-mocks'; import { ArtemisSharedModule } from 'app/shared/shared.module'; -import { MockAlertService } from '../../mocks/mock-alert.service'; +import { MockAlertService } from '../../mocks/service/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; import { ActivatedRoute, Router, RouterModule } from '@angular/router'; -import { MockRouter } from '../../mocks/mock-router.service'; +import { MockRouter } from '../../mocks/service/mock-router.service'; import { of, throwError } from 'rxjs'; import { HttpErrorResponse } from '@angular/common/http'; import { SidePanelComponent } from 'app/shared/side-panel/side-panel.component'; diff --git a/src/test/javascript/spec/component/tutor-dashboard/tutor-participation-graph.component.spec.ts b/src/test/javascript/spec/component/tutor-dashboard/tutor-participation-graph.component.spec.ts index cb9a362f389b..f083a5914696 100644 --- a/src/test/javascript/spec/component/tutor-dashboard/tutor-participation-graph.component.spec.ts +++ b/src/test/javascript/spec/component/tutor-dashboard/tutor-participation-graph.component.spec.ts @@ -4,7 +4,7 @@ import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; import { ArtemisTestModule } from '../../test.module'; import { ArtemisSharedModule } from 'app/shared/shared.module'; -import { MockSyncStorage } from '../../mocks/mock-sync.storage'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; import { TranslateModule } from '@ngx-translate/core'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { TutorParticipationGraphComponent } from 'app/shared/dashboards/tutor-participation-graph/tutor-participation-graph.component'; diff --git a/src/test/javascript/spec/directive/programming-exercise/build-plan-link.directive.spec.ts b/src/test/javascript/spec/directive/programming-exercise/build-plan-link.directive.spec.ts index f95dd794605c..0e31355313c2 100644 --- a/src/test/javascript/spec/directive/programming-exercise/build-plan-link.directive.spec.ts +++ b/src/test/javascript/spec/directive/programming-exercise/build-plan-link.directive.spec.ts @@ -6,7 +6,7 @@ import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testin import { ArtemisTestModule } from '../../test.module'; import { ProgrammingExerciseUtilsModule } from 'app/exercises/programming/shared/utils/programming-exercise-utils.module'; import { ProfileService } from 'app/shared/layouts/profiles/profile.service'; -import { MockProfileService } from '../../mocks/mock-profile.service'; +import { MockProfileService } from '../../mocks/service/mock-profile.service'; import { BehaviorSubject } from 'rxjs'; import { ProfileInfo } from 'app/shared/layouts/profiles/profile-info.model'; import { By } from '@angular/platform-browser'; diff --git a/src/test/javascript/spec/integration/code-editor/code-editor-instructor.integration.spec.ts b/src/test/javascript/spec/integration/code-editor/code-editor-instructor.integration.spec.ts index a8511c63b91f..d573b66d28af 100644 --- a/src/test/javascript/spec/integration/code-editor/code-editor-instructor.integration.spec.ts +++ b/src/test/javascript/spec/integration/code-editor/code-editor-instructor.integration.spec.ts @@ -16,15 +16,15 @@ import { ArtemisTestModule } from '../../test.module'; import { ProgrammingExerciseParticipationService } from 'app/exercises/programming/manage/services/programming-exercise-participation.service'; import { ProgrammingExerciseService } from 'app/exercises/programming/manage/services/programming-exercise.service'; import { DomainType, FileType } from 'app/exercises/programming/shared/code-editor/model/code-editor.model'; -import { MockAccountService } from '../../mocks/mock-account.service'; -import { MockRouter } from '../../mocks/mock-router.service'; +import { MockAccountService } from '../../mocks/service/mock-account.service'; +import { MockRouter } from '../../mocks/service/mock-router.service'; import { problemStatement } from '../../sample/problemStatement.json'; -import { MockProgrammingExerciseParticipationService } from '../../mocks/mock-programming-exercise-participation.service'; +import { MockProgrammingExerciseParticipationService } from '../../mocks/service/mock-programming-exercise-participation.service'; import { ExerciseHint } from 'app/entities/exercise-hint.model'; import { DeviceDetectorService } from 'ngx-device-detector'; import { CodeEditorInstructorContainerComponent } from 'app/exercises/programming/manage/code-editor/code-editor-instructor-container.component'; import { ParticipationWebsocketService } from 'app/overview/participation-websocket.service'; -import { MockCourseExerciseService } from '../../mocks/mock-course-exercise.service'; +import { MockCourseExerciseService } from '../../mocks/service/mock-course-exercise.service'; import { ExerciseHintService, IExerciseHintService } from 'app/exercises/shared/exercise-hint/manage/exercise-hint.service'; import { CodeEditorBuildLogService, @@ -41,18 +41,18 @@ import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; import { ProgrammingExerciseStudentParticipation } from 'app/entities/participation/programming-exercise-student-participation.model'; import { SolutionProgrammingExerciseParticipation } from 'app/entities/participation/solution-programming-exercise-participation.model'; import { MockActivatedRoute } from '../../mocks/activated-route/mock-activated.route'; -import { MockSyncStorage } from '../../mocks/mock-sync.storage'; -import { MockResultService } from '../../mocks/mock-result.service'; -import { MockCodeEditorRepositoryService } from '../../mocks/mock-code-editor-repository.service'; -import { MockCodeEditorBuildLogService } from '../../mocks/mock-code-editor-build-log.service'; -import { MockCodeEditorRepositoryFileService } from '../../mocks/mock-code-editor-repository-file.service'; -import { MockCodeEditorSessionService } from '../../mocks/mock-code-editor-session.service'; -import { MockParticipationWebsocketService } from '../../mocks/mock-participation-websocket.service'; -import { MockParticipationService } from '../../mocks/mock-participation.service'; -import { MockProgrammingExerciseService } from '../../mocks/mock-programming-exercise.service'; -import { MockExerciseHintService } from '../../mocks/mock-exercise-hint.service'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockResultService } from '../../mocks/service/mock-result.service'; +import { MockCodeEditorRepositoryService } from '../../mocks/service/mock-code-editor-repository.service'; +import { MockCodeEditorBuildLogService } from '../../mocks/service/mock-code-editor-build-log.service'; +import { MockCodeEditorRepositoryFileService } from '../../mocks/service/mock-code-editor-repository-file.service'; +import { MockCodeEditorSessionService } from '../../mocks/service/mock-code-editor-session.service'; +import { MockParticipationWebsocketService } from '../../mocks/service/mock-participation-websocket.service'; +import { MockParticipationService } from '../../mocks/service/mock-participation.service'; +import { MockProgrammingExerciseService } from '../../mocks/service/mock-programming-exercise.service'; +import { MockExerciseHintService } from '../../mocks/service/mock-exercise-hint.service'; import { JhiWebsocketService } from 'app/core/websocket/websocket.service'; -import { MockWebsocketService } from '../../mocks/mock-websocket.service'; +import { MockWebsocketService } from '../../mocks/service/mock-websocket.service'; import { ArtemisCodeEditorManagementModule } from 'app/exercises/programming/manage/code-editor/code-editor-management.module'; import { CourseExerciseService } from 'app/course/manage/course-management.service'; diff --git a/src/test/javascript/spec/integration/code-editor/code-editor-student.integration.spec.ts b/src/test/javascript/spec/integration/code-editor/code-editor-student.integration.spec.ts index 0262ba739243..a6b2e2d99538 100644 --- a/src/test/javascript/spec/integration/code-editor/code-editor-student.integration.spec.ts +++ b/src/test/javascript/spec/integration/code-editor/code-editor-student.integration.spec.ts @@ -19,17 +19,17 @@ import { ProgrammingExerciseParticipationService } from 'app/exercises/programmi import { CommitState, DeleteFileChange, DomainType, EditorState, FileType, GitConflictState } from 'app/exercises/programming/shared/code-editor/model/code-editor.model'; import { buildLogs, extractedBuildLogErrors } from '../../sample/build-logs'; import { problemStatement } from '../../sample/problemStatement.json'; -import { MockAccountService } from '../../mocks/mock-account.service'; -import { MockProgrammingExerciseParticipationService } from '../../mocks/mock-programming-exercise-participation.service'; +import { MockAccountService } from '../../mocks/service/mock-account.service'; +import { MockProgrammingExerciseParticipationService } from '../../mocks/service/mock-programming-exercise-participation.service'; import { ProgrammingSubmissionService, ProgrammingSubmissionState, ProgrammingSubmissionStateObj } from 'app/exercises/programming/participate/programming-submission.service'; -import { MockProgrammingSubmissionService } from '../../mocks/mock-programming-submission.service'; +import { MockProgrammingSubmissionService } from '../../mocks/service/mock-programming-submission.service'; import { ExerciseHint } from 'app/entities/exercise-hint.model'; import { DeviceDetectorService } from 'ngx-device-detector'; import { GuidedTourService } from 'app/guided-tour/guided-tour.service'; import { getElement } from '../../utils/general.utils'; import { GuidedTourMapping } from 'app/guided-tour/guided-tour-setting.model'; import { JhiWebsocketService } from 'app/core/websocket/websocket.service'; -import { MockWebsocketService } from '../../mocks/mock-websocket.service'; +import { MockWebsocketService } from '../../mocks/service/mock-websocket.service'; import { Participation } from 'app/entities/participation/participation.model'; import { BuildLogEntryArray } from 'app/entities/build-log.model'; import { CodeEditorConflictStateService } from 'app/exercises/programming/shared/code-editor/service/code-editor-conflict-state.service'; @@ -49,14 +49,14 @@ import { DomainService } from 'app/exercises/programming/shared/code-editor/serv import { ProgrammingSubmission } from 'app/entities/programming-submission.model'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; import { MockActivatedRoute } from '../../mocks/activated-route/mock-activated.route'; -import { MockParticipationWebsocketService } from '../../mocks/mock-participation-websocket.service'; -import { MockSyncStorage } from '../../mocks/mock-sync.storage'; -import { MockResultService } from '../../mocks/mock-result.service'; -import { MockCodeEditorRepositoryService } from '../../mocks/mock-code-editor-repository.service'; -import { MockExerciseHintService } from '../../mocks/mock-exercise-hint.service'; -import { MockCodeEditorRepositoryFileService } from '../../mocks/mock-code-editor-repository-file.service'; -import { MockCodeEditorSessionService } from '../../mocks/mock-code-editor-session.service'; -import { MockCodeEditorBuildLogService } from '../../mocks/mock-code-editor-build-log.service'; +import { MockParticipationWebsocketService } from '../../mocks/service/mock-participation-websocket.service'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockResultService } from '../../mocks/service/mock-result.service'; +import { MockCodeEditorRepositoryService } from '../../mocks/service/mock-code-editor-repository.service'; +import { MockExerciseHintService } from '../../mocks/service/mock-exercise-hint.service'; +import { MockCodeEditorRepositoryFileService } from '../../mocks/service/mock-code-editor-repository-file.service'; +import { MockCodeEditorSessionService } from '../../mocks/service/mock-code-editor-session.service'; +import { MockCodeEditorBuildLogService } from '../../mocks/service/mock-code-editor-build-log.service'; import { ArtemisProgrammingParticipationModule } from 'app/exercises/programming/participate/programming-participation.module'; chai.use(sinonChai); diff --git a/src/test/javascript/spec/mocks/mock-has-any-authority.directive.ts b/src/test/javascript/spec/mocks/directive/mock-has-any-authority.directive.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-has-any-authority.directive.ts rename to src/test/javascript/spec/mocks/directive/mock-has-any-authority.directive.ts diff --git a/src/test/javascript/spec/mocks/mock-account.service.ts b/src/test/javascript/spec/mocks/service/mock-account.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-account.service.ts rename to src/test/javascript/spec/mocks/service/mock-account.service.ts diff --git a/src/test/javascript/spec/mocks/mock-active-modal.service.ts b/src/test/javascript/spec/mocks/service/mock-active-modal.service.ts similarity index 84% rename from src/test/javascript/spec/mocks/mock-active-modal.service.ts rename to src/test/javascript/spec/mocks/service/mock-active-modal.service.ts index 9cd9b6d51cc9..f9374458478e 100644 --- a/src/test/javascript/spec/mocks/mock-active-modal.service.ts +++ b/src/test/javascript/spec/mocks/service/mock-active-modal.service.ts @@ -1,4 +1,4 @@ -import { SpyObject } from '../helpers/spyobject'; +import { SpyObject } from '../../helpers/spyobject'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import Spy = jasmine.Spy; diff --git a/src/test/javascript/spec/mocks/mock-alert.service.ts b/src/test/javascript/spec/mocks/service/mock-alert.service.ts similarity index 84% rename from src/test/javascript/spec/mocks/mock-alert.service.ts rename to src/test/javascript/spec/mocks/service/mock-alert.service.ts index f2ecf8bbdb5e..f423645deeea 100644 --- a/src/test/javascript/spec/mocks/mock-alert.service.ts +++ b/src/test/javascript/spec/mocks/service/mock-alert.service.ts @@ -1,4 +1,4 @@ -import { SpyObject } from '../helpers/spyobject'; +import { SpyObject } from '../../helpers/spyobject'; import { JhiAlert, JhiAlertService } from 'ng-jhipster'; export class MockAlertService extends SpyObject { diff --git a/src/test/javascript/spec/mocks/mock-auth-server-provider.service.ts b/src/test/javascript/spec/mocks/service/mock-auth-server-provider.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-auth-server-provider.service.ts rename to src/test/javascript/spec/mocks/service/mock-auth-server-provider.service.ts diff --git a/src/test/javascript/spec/mocks/mock-cacheable-image.service.ts b/src/test/javascript/spec/mocks/service/mock-cacheable-image.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-cacheable-image.service.ts rename to src/test/javascript/spec/mocks/service/mock-cacheable-image.service.ts diff --git a/src/test/javascript/spec/mocks/mock-code-editor-build-log.service.ts b/src/test/javascript/spec/mocks/service/mock-code-editor-build-log.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-code-editor-build-log.service.ts rename to src/test/javascript/spec/mocks/service/mock-code-editor-build-log.service.ts diff --git a/src/test/javascript/spec/mocks/mock-code-editor-conflict-state.service.ts b/src/test/javascript/spec/mocks/service/mock-code-editor-conflict-state.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-code-editor-conflict-state.service.ts rename to src/test/javascript/spec/mocks/service/mock-code-editor-conflict-state.service.ts diff --git a/src/test/javascript/spec/mocks/mock-code-editor-grid.service.ts b/src/test/javascript/spec/mocks/service/mock-code-editor-grid.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-code-editor-grid.service.ts rename to src/test/javascript/spec/mocks/service/mock-code-editor-grid.service.ts diff --git a/src/test/javascript/spec/mocks/mock-code-editor-repository-file.service.ts b/src/test/javascript/spec/mocks/service/mock-code-editor-repository-file.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-code-editor-repository-file.service.ts rename to src/test/javascript/spec/mocks/service/mock-code-editor-repository-file.service.ts diff --git a/src/test/javascript/spec/mocks/mock-code-editor-repository.service.ts b/src/test/javascript/spec/mocks/service/mock-code-editor-repository.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-code-editor-repository.service.ts rename to src/test/javascript/spec/mocks/service/mock-code-editor-repository.service.ts diff --git a/src/test/javascript/spec/mocks/mock-code-editor-session.service.ts b/src/test/javascript/spec/mocks/service/mock-code-editor-session.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-code-editor-session.service.ts rename to src/test/javascript/spec/mocks/service/mock-code-editor-session.service.ts diff --git a/src/test/javascript/spec/mocks/mock-complaint.service.ts b/src/test/javascript/spec/mocks/service/mock-complaint.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-complaint.service.ts rename to src/test/javascript/spec/mocks/service/mock-complaint.service.ts diff --git a/src/test/javascript/spec/mocks/mock-cookie.service.ts b/src/test/javascript/spec/mocks/service/mock-cookie.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-cookie.service.ts rename to src/test/javascript/spec/mocks/service/mock-cookie.service.ts diff --git a/src/test/javascript/spec/mocks/mock-course-exercise.service.ts b/src/test/javascript/spec/mocks/service/mock-course-exercise.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-course-exercise.service.ts rename to src/test/javascript/spec/mocks/service/mock-course-exercise.service.ts diff --git a/src/test/javascript/spec/mocks/mock-course.service.ts b/src/test/javascript/spec/mocks/service/mock-course.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-course.service.ts rename to src/test/javascript/spec/mocks/service/mock-course.service.ts diff --git a/src/test/javascript/spec/mocks/mock-event-manager.service.ts b/src/test/javascript/spec/mocks/service/mock-event-manager.service.ts similarity index 83% rename from src/test/javascript/spec/mocks/mock-event-manager.service.ts rename to src/test/javascript/spec/mocks/service/mock-event-manager.service.ts index 2aaea408daba..a894b9b3554e 100644 --- a/src/test/javascript/spec/mocks/mock-event-manager.service.ts +++ b/src/test/javascript/spec/mocks/service/mock-event-manager.service.ts @@ -1,4 +1,4 @@ -import { SpyObject } from '../helpers/spyobject'; +import { SpyObject } from '../../helpers/spyobject'; import { JhiEventManager } from 'ng-jhipster'; import Spy = jasmine.Spy; diff --git a/src/test/javascript/spec/mocks/mock-exercise-hint.service.ts b/src/test/javascript/spec/mocks/service/mock-exercise-hint.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-exercise-hint.service.ts rename to src/test/javascript/spec/mocks/service/mock-exercise-hint.service.ts diff --git a/src/test/javascript/spec/mocks/mock-exercise.service.ts b/src/test/javascript/spec/mocks/service/mock-exercise.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-exercise.service.ts rename to src/test/javascript/spec/mocks/service/mock-exercise.service.ts diff --git a/src/test/javascript/spec/mocks/mock-feature-toggle-service.ts b/src/test/javascript/spec/mocks/service/mock-feature-toggle.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-feature-toggle-service.ts rename to src/test/javascript/spec/mocks/service/mock-feature-toggle.service.ts diff --git a/src/test/javascript/spec/mocks/mock-file-upload-exercise.service.ts b/src/test/javascript/spec/mocks/service/mock-file-upload-exercise.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-file-upload-exercise.service.ts rename to src/test/javascript/spec/mocks/service/mock-file-upload-exercise.service.ts diff --git a/src/test/javascript/spec/mocks/mock-file-upload-submission.service.ts b/src/test/javascript/spec/mocks/service/mock-file-upload-submission.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-file-upload-submission.service.ts rename to src/test/javascript/spec/mocks/service/mock-file-upload-submission.service.ts diff --git a/src/test/javascript/spec/mocks/mock-http.service.ts b/src/test/javascript/spec/mocks/service/mock-http.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-http.service.ts rename to src/test/javascript/spec/mocks/service/mock-http.service.ts diff --git a/src/test/javascript/spec/mocks/mock-ide-build-and-test.service.ts b/src/test/javascript/spec/mocks/service/mock-ide-build-and-test.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-ide-build-and-test.service.ts rename to src/test/javascript/spec/mocks/service/mock-ide-build-and-test.service.ts diff --git a/src/test/javascript/spec/mocks/mock-language.service.ts b/src/test/javascript/spec/mocks/service/mock-language.service.ts similarity index 95% rename from src/test/javascript/spec/mocks/mock-language.service.ts rename to src/test/javascript/spec/mocks/service/mock-language.service.ts index a57c1d9ef041..e69e10fdc458 100644 --- a/src/test/javascript/spec/mocks/mock-language.service.ts +++ b/src/test/javascript/spec/mocks/service/mock-language.service.ts @@ -1,4 +1,4 @@ -import { SpyObject } from '../helpers/spyobject'; +import { SpyObject } from '../../helpers/spyobject'; import { JhiLanguageService } from 'ng-jhipster'; import { JhiLanguageHelper } from 'app/core/language/language.helper'; import { of } from 'rxjs'; diff --git a/src/test/javascript/spec/mocks/mock-login.service.ts b/src/test/javascript/spec/mocks/service/mock-login.service.ts similarity index 93% rename from src/test/javascript/spec/mocks/mock-login.service.ts rename to src/test/javascript/spec/mocks/service/mock-login.service.ts index b24e7150e30a..9d8da622b95e 100644 --- a/src/test/javascript/spec/mocks/mock-login.service.ts +++ b/src/test/javascript/spec/mocks/service/mock-login.service.ts @@ -1,4 +1,4 @@ -import { SpyObject } from '../helpers/spyobject'; +import { SpyObject } from '../../helpers/spyobject'; import { LoginService } from 'app/core/login/login.service'; import Spy = jasmine.Spy; diff --git a/src/test/javascript/spec/mocks/mock-ngb-modal.service.ts b/src/test/javascript/spec/mocks/service/mock-ngb-modal.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-ngb-modal.service.ts rename to src/test/javascript/spec/mocks/service/mock-ngb-modal.service.ts diff --git a/src/test/javascript/spec/mocks/mock-notification.service.ts b/src/test/javascript/spec/mocks/service/mock-notification.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-notification.service.ts rename to src/test/javascript/spec/mocks/service/mock-notification.service.ts diff --git a/src/test/javascript/spec/mocks/mock-orion-connector.service.ts b/src/test/javascript/spec/mocks/service/mock-orion-connector.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-orion-connector.service.ts rename to src/test/javascript/spec/mocks/service/mock-orion-connector.service.ts diff --git a/src/test/javascript/spec/mocks/mock-participation-websocket.service.ts b/src/test/javascript/spec/mocks/service/mock-participation-websocket.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-participation-websocket.service.ts rename to src/test/javascript/spec/mocks/service/mock-participation-websocket.service.ts diff --git a/src/test/javascript/spec/mocks/mock-participation.service.ts b/src/test/javascript/spec/mocks/service/mock-participation.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-participation.service.ts rename to src/test/javascript/spec/mocks/service/mock-participation.service.ts diff --git a/src/test/javascript/spec/mocks/mock-principal.service.ts b/src/test/javascript/spec/mocks/service/mock-principal.service.ts similarity index 89% rename from src/test/javascript/spec/mocks/mock-principal.service.ts rename to src/test/javascript/spec/mocks/service/mock-principal.service.ts index 96ded028a26a..6496e04ea475 100644 --- a/src/test/javascript/spec/mocks/mock-principal.service.ts +++ b/src/test/javascript/spec/mocks/service/mock-principal.service.ts @@ -1,4 +1,4 @@ -import { SpyObject } from '../helpers/spyobject'; +import { SpyObject } from '../../helpers/spyobject'; import { Principal } from 'app/core/auth/principal.service'; import Spy = jasmine.Spy; diff --git a/src/test/javascript/spec/mocks/mock-profile.service.ts b/src/test/javascript/spec/mocks/service/mock-profile.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-profile.service.ts rename to src/test/javascript/spec/mocks/service/mock-profile.service.ts diff --git a/src/test/javascript/spec/mocks/mock-programming-build-run.service.ts b/src/test/javascript/spec/mocks/service/mock-programming-build-run.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-programming-build-run.service.ts rename to src/test/javascript/spec/mocks/service/mock-programming-build-run.service.ts diff --git a/src/test/javascript/spec/mocks/mock-programming-exercise-paging.service.ts b/src/test/javascript/spec/mocks/service/mock-programming-exercise-paging.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-programming-exercise-paging.service.ts rename to src/test/javascript/spec/mocks/service/mock-programming-exercise-paging.service.ts diff --git a/src/test/javascript/spec/mocks/mock-programming-exercise-participation.service.ts b/src/test/javascript/spec/mocks/service/mock-programming-exercise-participation.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-programming-exercise-participation.service.ts rename to src/test/javascript/spec/mocks/service/mock-programming-exercise-participation.service.ts diff --git a/src/test/javascript/spec/mocks/mock-programming-exercise-test-case.service.ts b/src/test/javascript/spec/mocks/service/mock-programming-exercise-test-case.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-programming-exercise-test-case.service.ts rename to src/test/javascript/spec/mocks/service/mock-programming-exercise-test-case.service.ts diff --git a/src/test/javascript/spec/mocks/mock-programming-exercise-websocket.service.ts b/src/test/javascript/spec/mocks/service/mock-programming-exercise-websocket.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-programming-exercise-websocket.service.ts rename to src/test/javascript/spec/mocks/service/mock-programming-exercise-websocket.service.ts diff --git a/src/test/javascript/spec/mocks/mock-programming-exercise.service.ts b/src/test/javascript/spec/mocks/service/mock-programming-exercise.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-programming-exercise.service.ts rename to src/test/javascript/spec/mocks/service/mock-programming-exercise.service.ts diff --git a/src/test/javascript/spec/mocks/mock-programming-submission.service.ts b/src/test/javascript/spec/mocks/service/mock-programming-submission.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-programming-submission.service.ts rename to src/test/javascript/spec/mocks/service/mock-programming-submission.service.ts diff --git a/src/test/javascript/spec/mocks/mock-repository-file.service.ts b/src/test/javascript/spec/mocks/service/mock-repository-file.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-repository-file.service.ts rename to src/test/javascript/spec/mocks/service/mock-repository-file.service.ts diff --git a/src/test/javascript/spec/mocks/mock-result.service.ts b/src/test/javascript/spec/mocks/service/mock-result.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-result.service.ts rename to src/test/javascript/spec/mocks/service/mock-result.service.ts diff --git a/src/test/javascript/spec/mocks/mock-route.service.ts b/src/test/javascript/spec/mocks/service/mock-route.service.ts similarity index 92% rename from src/test/javascript/spec/mocks/mock-route.service.ts rename to src/test/javascript/spec/mocks/service/mock-route.service.ts index a32fee00efc3..7668eea1dcfe 100644 --- a/src/test/javascript/spec/mocks/mock-route.service.ts +++ b/src/test/javascript/spec/mocks/service/mock-route.service.ts @@ -1,5 +1,5 @@ import { ActivatedRoute, Router } from '@angular/router'; -import { SpyObject } from '../helpers/spyobject'; +import { SpyObject } from '../../helpers/spyobject'; import { of } from 'rxjs'; import Spy = jasmine.Spy; diff --git a/src/test/javascript/spec/mocks/mock-router.service.ts b/src/test/javascript/spec/mocks/service/mock-router.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-router.service.ts rename to src/test/javascript/spec/mocks/service/mock-router.service.ts diff --git a/src/test/javascript/spec/mocks/mock-state-storage.service.ts b/src/test/javascript/spec/mocks/service/mock-state-storage.service.ts similarity index 90% rename from src/test/javascript/spec/mocks/mock-state-storage.service.ts rename to src/test/javascript/spec/mocks/service/mock-state-storage.service.ts index 5dd82d3e186b..a28bdbd49959 100644 --- a/src/test/javascript/spec/mocks/mock-state-storage.service.ts +++ b/src/test/javascript/spec/mocks/service/mock-state-storage.service.ts @@ -1,4 +1,4 @@ -import { SpyObject } from '../helpers/spyobject'; +import { SpyObject } from '../../helpers/spyobject'; import { StateStorageService } from 'app/core/auth/state-storage.service'; import Spy = jasmine.Spy; diff --git a/src/test/javascript/spec/mocks/mock-sync.storage.ts b/src/test/javascript/spec/mocks/service/mock-sync-storage.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-sync.storage.ts rename to src/test/javascript/spec/mocks/service/mock-sync-storage.service.ts diff --git a/src/test/javascript/spec/mocks/mock-team.service.ts b/src/test/javascript/spec/mocks/service/mock-team.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-team.service.ts rename to src/test/javascript/spec/mocks/service/mock-team.service.ts diff --git a/src/test/javascript/spec/mocks/mock-text-editor.service.ts b/src/test/javascript/spec/mocks/service/mock-text-editor.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-text-editor.service.ts rename to src/test/javascript/spec/mocks/service/mock-text-editor.service.ts diff --git a/src/test/javascript/spec/mocks/mock-tracker.service.ts b/src/test/javascript/spec/mocks/service/mock-tracker.service.ts similarity index 79% rename from src/test/javascript/spec/mocks/mock-tracker.service.ts rename to src/test/javascript/spec/mocks/service/mock-tracker.service.ts index a86e01a05eb3..03b8a44a04b5 100644 --- a/src/test/javascript/spec/mocks/mock-tracker.service.ts +++ b/src/test/javascript/spec/mocks/service/mock-tracker.service.ts @@ -1,4 +1,4 @@ -import { SpyObject } from '../helpers/spyobject'; +import { SpyObject } from '../../helpers/spyobject'; import { JhiTrackerService } from 'app/core/tracker/tracker.service'; export class MockTrackerService extends SpyObject { diff --git a/src/test/javascript/spec/mocks/mock-translate.service.ts b/src/test/javascript/spec/mocks/service/mock-translate.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-translate.service.ts rename to src/test/javascript/spec/mocks/service/mock-translate.service.ts diff --git a/src/test/javascript/spec/mocks/mock-user.service.ts b/src/test/javascript/spec/mocks/service/mock-user.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-user.service.ts rename to src/test/javascript/spec/mocks/service/mock-user.service.ts diff --git a/src/test/javascript/spec/mocks/mock-websocket.service.ts b/src/test/javascript/spec/mocks/service/mock-websocket.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-websocket.service.ts rename to src/test/javascript/spec/mocks/service/mock-websocket.service.ts diff --git a/src/test/javascript/spec/mocks/mock-window.service.ts b/src/test/javascript/spec/mocks/service/mock-window.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/mock-window.service.ts rename to src/test/javascript/spec/mocks/service/mock-window.service.ts diff --git a/src/test/javascript/spec/service/account.service.spec.ts b/src/test/javascript/spec/service/account.service.spec.ts index 5dd6ef93ee4e..cd0d25006d3a 100644 --- a/src/test/javascript/spec/service/account.service.spec.ts +++ b/src/test/javascript/spec/service/account.service.spec.ts @@ -3,13 +3,13 @@ import * as chai from 'chai'; import { SinonStub, stub } from 'sinon'; import { of } from 'rxjs'; import * as sinonChai from 'sinon-chai'; -import { MockWebsocketService } from '../mocks/mock-websocket.service'; -import { MockLanguageService } from '../mocks/mock-language.service'; -import { MockHttpService } from '../mocks/mock-http.service'; -import { MockFeatureToggleService } from '../mocks/mock-feature-toggle-service'; +import { MockWebsocketService } from '../mocks/service/mock-websocket.service'; +import { MockLanguageService } from '../mocks/service/mock-language.service'; +import { MockHttpService } from '../mocks/service/mock-http.service'; +import { MockFeatureToggleService } from '../mocks/service/mock-feature-toggle.service'; import { User } from 'app/core/user/user.model'; import { AccountService } from 'app/core/auth/account.service'; -import { MockSyncStorage } from '../mocks/mock-sync.storage'; +import { MockSyncStorage } from '../mocks/service/mock-sync-storage.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/service/guided-tour.service.spec.ts b/src/test/javascript/spec/service/guided-tour.service.spec.ts index fbc00319b784..fe34166b0df4 100644 --- a/src/test/javascript/spec/service/guided-tour.service.spec.ts +++ b/src/test/javascript/spec/service/guided-tour.service.spec.ts @@ -18,11 +18,11 @@ import { GuidedTourState, Orientation, ResetParticipation, UserInteractionEvent import { GuidedTourComponent } from 'app/guided-tour/guided-tour.component'; import { GuidedTourMapping, GuidedTourSetting } from 'app/guided-tour/guided-tour-setting.model'; import { ModelingTaskTourStep, TextTourStep, UserInterActionTourStep } from 'app/guided-tour/guided-tour-step.model'; -import { MockAccountService } from '../mocks/mock-account.service'; +import { MockAccountService } from '../mocks/service/mock-account.service'; import { AccountService } from 'app/core/auth/account.service'; import { DeviceDetectorService } from 'ngx-device-detector'; import { Course } from 'app/entities/course.model'; -import { MockTranslateService } from '../mocks/mock-translate.service'; +import { MockTranslateService } from '../mocks/service/mock-translate.service'; import { GuidedTourModelingTask, personUML } from 'app/guided-tour/guided-tour-task.model'; import { completedTour } from 'app/guided-tour/tours/general-tour'; import { SinonStub, stub } from 'sinon'; @@ -32,8 +32,8 @@ import { Exercise, ExerciseType } from 'app/entities/exercise.model'; import { InitializationState } from 'app/entities/participation/participation.model'; import { NavbarComponent } from 'app/shared/layouts/navbar/navbar.component'; import { StudentParticipation } from 'app/entities/participation/student-participation.model'; -import { MockSyncStorage } from '../mocks/mock-sync.storage'; -import { MockCookieService } from '../mocks/mock-cookie.service'; +import { MockSyncStorage } from '../mocks/service/mock-sync-storage.service'; +import { MockCookieService } from '../mocks/service/mock-cookie.service'; import { CourseManagementService } from 'app/course/manage/course-management.service'; chai.use(sinonChai); diff --git a/src/test/javascript/spec/service/ide-build-and-test.service.spec.ts b/src/test/javascript/spec/service/ide-build-and-test.service.spec.ts index 3bda4ef5e39f..428c49ec6969 100644 --- a/src/test/javascript/spec/service/ide-build-and-test.service.spec.ts +++ b/src/test/javascript/spec/service/ide-build-and-test.service.spec.ts @@ -3,17 +3,17 @@ import * as sinonChai from 'sinon-chai'; import { IProgrammingSubmissionService } from 'app/exercises/programming/participate/programming-submission.service'; import { IParticipationWebsocketService } from 'app/overview/participation-websocket.service'; import { SinonSpy, SinonStub, spy, stub } from 'sinon'; -import { MockProgrammingSubmissionService } from '../mocks/mock-programming-submission.service'; +import { MockProgrammingSubmissionService } from '../mocks/service/mock-programming-submission.service'; import { Result } from 'app/entities/result.model'; import { BehaviorSubject, of } from 'rxjs'; import { Feedback } from 'app/entities/feedback.model'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; import { IBuildLogService } from 'app/exercises/programming/shared/service/build-log.service'; -import { MockParticipationWebsocketService } from '../mocks/mock-participation-websocket.service'; -import { MockCodeEditorBuildLogService } from '../mocks/mock-code-editor-build-log.service'; +import { MockParticipationWebsocketService } from '../mocks/service/mock-participation-websocket.service'; +import { MockCodeEditorBuildLogService } from '../mocks/service/mock-code-editor-build-log.service'; import { OrionBuildAndTestService } from 'app/shared/orion/orion-build-and-test.service'; import { OrionConnectorService } from 'app/shared/orion/orion-connector.service'; -import { MockOrionConnectorService } from '../mocks/mock-orion-connector.service'; +import { MockOrionConnectorService } from '../mocks/service/mock-orion-connector.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/service/login.service.spec.ts b/src/test/javascript/spec/service/login.service.spec.ts index 3b3df41d6c64..9467891a455d 100644 --- a/src/test/javascript/spec/service/login.service.spec.ts +++ b/src/test/javascript/spec/service/login.service.spec.ts @@ -2,16 +2,16 @@ import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; import { SinonStub, stub } from 'sinon'; import { of, throwError } from 'rxjs'; -import { MockWebsocketService } from '../mocks/mock-websocket.service'; -import { MockRouter } from '../mocks/mock-router.service'; -import { MockAccountService } from '../mocks/mock-account.service'; -import { MockAuthServerProviderService } from '../mocks/mock-auth-server-provider.service'; -import { MockAlertService } from '../mocks/mock-alert.service'; +import { MockWebsocketService } from '../mocks/service/mock-websocket.service'; +import { MockRouter } from '../mocks/service/mock-router.service'; +import { MockAccountService } from '../mocks/service/mock-account.service'; +import { MockAuthServerProviderService } from '../mocks/service/mock-auth-server-provider.service'; +import { MockAlertService } from '../mocks/service/mock-alert.service'; import { IAccountService } from 'app/core/auth/account.service'; import { IWebsocketService } from 'app/core/websocket/websocket.service'; import { LoginService } from 'app/core/login/login.service'; import { IAuthServerProvider } from 'app/core/auth/auth-jwt.service'; -import { MockNotificationService } from '../mocks/mock-notification.service'; +import { MockNotificationService } from '../mocks/service/mock-notification.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/service/orion-version-validator.service.spec.ts b/src/test/javascript/spec/service/orion-version-validator.service.spec.ts index d0b7e9da5f15..df59a6a5b20a 100644 --- a/src/test/javascript/spec/service/orion-version-validator.service.spec.ts +++ b/src/test/javascript/spec/service/orion-version-validator.service.spec.ts @@ -4,9 +4,9 @@ import { SinonSpy, SinonStub, spy, stub } from 'sinon'; import { OrionVersionValidator } from 'app/shared/orion/outdated-plugin-warning/orion-version-validator.service'; import { ProfileService } from 'app/shared/layouts/profiles/profile.service'; import { Router } from '@angular/router'; -import { MockProfileService } from '../mocks/mock-profile.service'; -import { MockWindowRef } from '../mocks/mock-window.service'; -import { MockRouter } from '../mocks/mock-router.service'; +import { MockProfileService } from '../mocks/service/mock-profile.service'; +import { MockWindowRef } from '../mocks/service/mock-window.service'; +import { MockRouter } from '../mocks/service/mock-router.service'; import { of } from 'rxjs'; import { ProfileInfo } from 'app/shared/layouts/profiles/profile-info.model'; diff --git a/src/test/javascript/spec/service/participation-websocket.service.spec.ts b/src/test/javascript/spec/service/participation-websocket.service.spec.ts index 67077750b534..217bdee2fad9 100644 --- a/src/test/javascript/spec/service/participation-websocket.service.spec.ts +++ b/src/test/javascript/spec/service/participation-websocket.service.spec.ts @@ -4,7 +4,7 @@ import { SinonSpy, SinonStub, spy, stub } from 'sinon'; import { BehaviorSubject, Subject } from 'rxjs'; import * as sinonChai from 'sinon-chai'; import { ParticipationWebsocketService } from 'app/overview/participation-websocket.service'; -import { MockWebsocketService } from '../mocks/mock-websocket.service'; +import { MockWebsocketService } from '../mocks/service/mock-websocket.service'; import { Participation } from 'app/entities/participation/participation.model'; import { Result } from 'app/entities/result.model'; import { IWebsocketService } from 'app/core/websocket/websocket.service'; diff --git a/src/test/javascript/spec/service/programming-exercise-instruction-analysis.service.spec.ts b/src/test/javascript/spec/service/programming-exercise-instruction-analysis.service.spec.ts index e2ec9fa20291..3f016a35317a 100644 --- a/src/test/javascript/spec/service/programming-exercise-instruction-analysis.service.spec.ts +++ b/src/test/javascript/spec/service/programming-exercise-instruction-analysis.service.spec.ts @@ -1,5 +1,5 @@ import { problemStatement } from '../sample/problemStatement.json'; -import { MockTranslateService } from '../mocks/mock-translate.service'; +import { MockTranslateService } from '../mocks/service/mock-translate.service'; import { ExerciseHint } from 'app/entities/exercise-hint.model'; import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; diff --git a/src/test/javascript/spec/service/programming-exercise-test-case.service.spec.ts b/src/test/javascript/spec/service/programming-exercise-test-case.service.spec.ts index e2329bcbe3ca..d95b34d33d32 100644 --- a/src/test/javascript/spec/service/programming-exercise-test-case.service.spec.ts +++ b/src/test/javascript/spec/service/programming-exercise-test-case.service.spec.ts @@ -4,10 +4,10 @@ import { SinonSpy, SinonStub, spy, stub } from 'sinon'; import { of, Subject } from 'rxjs'; import { tap } from 'rxjs/operators'; import * as sinonChai from 'sinon-chai'; -import { MockWebsocketService } from '../mocks/mock-websocket.service'; +import { MockWebsocketService } from '../mocks/service/mock-websocket.service'; import { IWebsocketService } from 'app/core/websocket/websocket.service.ts'; import { ProgrammingExerciseTestCaseService } from 'app/exercises/programming/manage/services/programming-exercise-test-case.service'; -import { MockHttpService } from '../mocks/mock-http.service'; +import { MockHttpService } from '../mocks/service/mock-http.service'; import { ProgrammingExerciseTestCase } from 'app/entities/programming-exercise-test-case.model'; import { Result } from 'app/entities/result.model'; diff --git a/src/test/javascript/spec/service/programming-submission.service.spec.ts b/src/test/javascript/spec/service/programming-submission.service.spec.ts index 17265fba79d8..c93036546be1 100644 --- a/src/test/javascript/spec/service/programming-submission.service.spec.ts +++ b/src/test/javascript/spec/service/programming-submission.service.spec.ts @@ -4,8 +4,8 @@ import { SinonStub, spy, stub } from 'sinon'; import { BehaviorSubject, of, Subject } from 'rxjs'; import { range as _range } from 'lodash'; import * as sinonChai from 'sinon-chai'; -import { MockWebsocketService } from '../mocks/mock-websocket.service'; -import { MockHttpService } from '../mocks/mock-http.service'; +import { MockWebsocketService } from '../mocks/service/mock-websocket.service'; +import { MockHttpService } from '../mocks/service/mock-http.service'; import { ExerciseSubmissionState, IProgrammingSubmissionService, @@ -14,13 +14,13 @@ import { ProgrammingSubmissionStateObj, } from 'app/exercises/programming/participate/programming-submission.service'; import { IParticipationWebsocketService } from 'app/overview/participation-websocket.service'; -import { MockAlertService } from '../mocks/mock-alert.service'; +import { MockAlertService } from '../mocks/service/mock-alert.service'; import { Result } from 'app/entities/result.model'; import { SERVER_API_URL } from 'app/app.constants'; import { ProgrammingSubmission } from 'app/entities/programming-submission.model'; import { Submission } from 'app/entities/submission.model'; import { StudentParticipation } from 'app/entities/participation/student-participation.model'; -import { MockParticipationWebsocketService } from '../mocks/mock-participation-websocket.service'; +import { MockParticipationWebsocketService } from '../mocks/service/mock-participation-websocket.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/service/user-route-access.service.spec.ts b/src/test/javascript/spec/service/user-route-access.service.spec.ts index bd3c5f25c9f7..2b8fa1658b32 100644 --- a/src/test/javascript/spec/service/user-route-access.service.spec.ts +++ b/src/test/javascript/spec/service/user-route-access.service.spec.ts @@ -5,12 +5,12 @@ import { UserRouteAccessService } from 'app/core/auth/user-route-access-service' import { ActivatedRouteSnapshot, Route } from '@angular/router'; import { ArtemisTestModule } from '../test.module'; import { TranslateService } from '@ngx-translate/core'; -import { MockTranslateService } from '../mocks/mock-translate.service'; -import { MockSyncStorage } from '../mocks/mock-sync.storage'; -import { MockCookieService } from '../mocks/mock-cookie.service'; +import { MockTranslateService } from '../mocks/service/mock-translate.service'; +import { MockSyncStorage } from '../mocks/service/mock-sync-storage.service'; +import { MockCookieService } from '../mocks/service/mock-cookie.service'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { AccountService } from 'app/core/auth/account.service'; -import { MockAccountService } from '../mocks/mock-account.service'; +import { MockAccountService } from '../mocks/service/mock-account.service'; import { RouterTestingModule } from '@angular/router/testing'; import { CookieService } from 'ngx-cookie-service'; import { DeviceDetectorService } from 'ngx-device-detector'; diff --git a/src/test/javascript/spec/test.module.ts b/src/test/javascript/spec/test.module.ts index 0ce360421d6a..06e75cfa218a 100644 --- a/src/test/javascript/spec/test.module.ts +++ b/src/test/javascript/spec/test.module.ts @@ -5,13 +5,13 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { NgbActiveModal, NgbModal, NgbDatepickerConfig } from '@ng-bootstrap/ng-bootstrap'; import { JhiAlertService, JhiDataUtils, JhiDateUtils, JhiEventManager, JhiLanguageService, JhiParseLinks } from 'ng-jhipster'; -import { MockLanguageHelper, MockLanguageService } from './mocks/mock-language.service'; +import { MockLanguageHelper, MockLanguageService } from './mocks/service/mock-language.service'; import { JhiLanguageHelper } from 'app/core/language/language.helper'; import { AccountService } from 'app/core/auth/account.service'; -import { MockAccountService } from './mocks/mock-account.service'; -import { MockActivatedRoute, MockRouter } from './mocks/mock-route.service'; -import { MockActiveModal } from './mocks/mock-active-modal.service'; -import { MockEventManager } from './mocks/mock-event-manager.service'; +import { MockAccountService } from './mocks/service/mock-account.service'; +import { MockActivatedRoute, MockRouter } from './mocks/service/mock-route.service'; +import { MockActiveModal } from './mocks/service/mock-active-modal.service'; +import { MockEventManager } from './mocks/service/mock-event-manager.service'; import { CookieService } from 'ngx-cookie-service'; import { FaIconLibrary, FontAwesomeModule, FaIconComponent } from '@fortawesome/angular-fontawesome'; import { fas } from '@fortawesome/free-solid-svg-icons'; From 827e856a027018ce32fe7bd4ddb137028e83a86f Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Fri, 24 Apr 2020 02:34:39 +0200 Subject: [PATCH 096/152] Move all test suites from spec/app to spec/component or spec/service --- src/test/javascript/jest.config.js | 1 - .../user-management.component.spec.ts | 64 ----------- .../programming-submission.service.spec.ts | 101 ------------------ .../spec/app/shared/user/user.service.spec.ts | 67 ------------ .../account}/activate.component.spec.ts | 4 +- .../password-reset-finish.component.spec.ts | 4 +- .../password-reset-init.component.spec.ts | 2 +- .../password-strength-bar.component.spec.ts | 0 .../account}/password.component.spec.ts | 2 +- .../account}/register.component.spec.ts | 4 +- .../account}/settings.component.spec.ts | 4 +- .../admin}/audits.component.spec.ts | 2 +- .../admin}/configuration.component.spec.ts | 2 +- .../admin}/health.component.spec.ts | 2 +- .../admin}/logs.component.spec.ts | 2 +- .../admin}/metrics.component.spec.ts | 2 +- .../user-management-detail.component.spec.ts | 2 +- .../user-management-update.component.spec.ts | 2 +- .../course/course-detail.component.spec.ts | 2 +- .../course/course-update.component.spec.ts | 2 +- ...e-upload-exercise-update.component.spec.ts | 2 +- .../file-upload-exercise.component.spec.ts | 2 +- ...modeling-exercise-detail.component.spec.ts | 2 +- ...modeling-exercise-update.component.spec.ts | 2 +- .../modeling-exercise.component.spec.ts | 2 +- ...gramming-exercise-detail.component.spec.ts | 2 +- ...gramming-exercise-update.component.spec.ts | 2 +- .../programming-exercise.component.spec.ts | 10 +- .../quiz-exercise-detail.component.spec.ts | 2 +- .../quiz-exercise.component.spec.ts | 2 +- .../shared}/alert-error.component.spec.ts | 4 +- .../text-exercise-detail.component.spec.ts | 2 +- .../text-exercise-update.component.spec.ts | 2 +- .../text-exercise.component.spec.ts | 2 +- .../audits => service}/audits.service.spec.ts | 0 .../configuration.service.spec.ts | 0 .../course => service}/course.service.spec.ts | 6 +- .../file-upload-exercise.service.spec.ts | 0 .../file-upload-submission.service.spec.ts | 0 .../logs => service}/logs.service.spec.ts | 0 .../metrics.service.spec.ts | 0 .../modeling-exercise.service.spec.ts | 0 .../modeling-submission.service.spec.ts | 0 .../participation.service.spec.ts | 0 .../programming-exercise.service.spec.ts | 0 .../quiz-exercise.service.spec.ts | 0 .../text-exercise.service.spec.ts | 0 .../text-submission.service.spec.ts | 0 .../user => service}/user.service.spec.ts | 0 49 files changed, 41 insertions(+), 274 deletions(-) delete mode 100644 src/test/javascript/spec/app/admin/user-management/user-management.component.spec.ts delete mode 100644 src/test/javascript/spec/app/entities/programming-submission/programming-submission.service.spec.ts delete mode 100644 src/test/javascript/spec/app/shared/user/user.service.spec.ts rename src/test/javascript/spec/{app/account/activate => component/account}/activate.component.spec.ts (94%) rename src/test/javascript/spec/{app/account/password-reset/finish => component/account}/password-reset-finish.component.spec.ts (96%) rename src/test/javascript/spec/{app/account/password-reset/init => component/account}/password-reset-init.component.spec.ts (98%) rename src/test/javascript/spec/{app/account/password => component/account}/password-strength-bar.component.spec.ts (100%) rename src/test/javascript/spec/{app/account/password => component/account}/password.component.spec.ts (98%) rename src/test/javascript/spec/{app/account/register => component/account}/register.component.spec.ts (96%) rename src/test/javascript/spec/{app/account/settings => component/account}/settings.component.spec.ts (94%) rename src/test/javascript/spec/{app/admin/audits => component/admin}/audits.component.spec.ts (98%) rename src/test/javascript/spec/{app/admin/configuration => component/admin}/configuration.component.spec.ts (97%) rename src/test/javascript/spec/{app/admin/health => component/admin}/health.component.spec.ts (97%) rename src/test/javascript/spec/{app/admin/logs => component/admin}/logs.component.spec.ts (97%) rename src/test/javascript/spec/{app/admin/metrics => component/admin}/metrics.component.spec.ts (96%) rename src/test/javascript/spec/{app/admin/user-management => component/admin}/user-management-detail.component.spec.ts (97%) rename src/test/javascript/spec/{app/admin/user-management => component/admin}/user-management-update.component.spec.ts (98%) rename src/test/javascript/spec/{app/entities => component}/course/course-detail.component.spec.ts (95%) rename src/test/javascript/spec/{app/entities => component}/course/course-update.component.spec.ts (97%) rename src/test/javascript/spec/{app/entities => component}/file-upload-exercise/file-upload-exercise-update.component.spec.ts (97%) rename src/test/javascript/spec/{app/entities => component}/file-upload-exercise/file-upload-exercise.component.spec.ts (97%) rename src/test/javascript/spec/{app/entities => component}/modeling-exercise/modeling-exercise-detail.component.spec.ts (96%) rename src/test/javascript/spec/{app/entities => component}/modeling-exercise/modeling-exercise-update.component.spec.ts (97%) rename src/test/javascript/spec/{app/entities => component}/modeling-exercise/modeling-exercise.component.spec.ts (97%) rename src/test/javascript/spec/{app/entities => component}/programming-exercise/programming-exercise-detail.component.spec.ts (96%) rename src/test/javascript/spec/{app/entities => component}/programming-exercise/programming-exercise-update.component.spec.ts (97%) rename src/test/javascript/spec/{app/entities => component}/programming-exercise/programming-exercise.component.spec.ts (88%) rename src/test/javascript/spec/{app/entities => component}/quiz-exercise/quiz-exercise-detail.component.spec.ts (96%) rename src/test/javascript/spec/{app/entities => component}/quiz-exercise/quiz-exercise.component.spec.ts (96%) rename src/test/javascript/spec/{app/shared/alert => component/shared}/alert-error.component.spec.ts (97%) rename src/test/javascript/spec/{app/entities => component}/text-exercise/text-exercise-detail.component.spec.ts (96%) rename src/test/javascript/spec/{app/entities => component}/text-exercise/text-exercise-update.component.spec.ts (97%) rename src/test/javascript/spec/{app/entities => component}/text-exercise/text-exercise.component.spec.ts (96%) rename src/test/javascript/spec/{app/admin/audits => service}/audits.service.spec.ts (100%) rename src/test/javascript/spec/{app/admin/configuration => service}/configuration.service.spec.ts (100%) rename src/test/javascript/spec/{app/entities/course => service}/course.service.spec.ts (96%) rename src/test/javascript/spec/{app/entities/file-upload-exercise => service}/file-upload-exercise.service.spec.ts (100%) rename src/test/javascript/spec/{app/entities/file-upload-submission => service}/file-upload-submission.service.spec.ts (100%) rename src/test/javascript/spec/{app/admin/logs => service}/logs.service.spec.ts (100%) rename src/test/javascript/spec/{app/admin/metrics => service}/metrics.service.spec.ts (100%) rename src/test/javascript/spec/{app/entities/modeling-exercise => service}/modeling-exercise.service.spec.ts (100%) rename src/test/javascript/spec/{app/entities/modeling-submission => service}/modeling-submission.service.spec.ts (100%) rename src/test/javascript/spec/{app/entities/participation => service}/participation.service.spec.ts (100%) rename src/test/javascript/spec/{app/entities/programming-exercise => service}/programming-exercise.service.spec.ts (100%) rename src/test/javascript/spec/{app/entities/quiz-exercise => service}/quiz-exercise.service.spec.ts (100%) rename src/test/javascript/spec/{app/entities/text-exercise => service}/text-exercise.service.spec.ts (100%) rename src/test/javascript/spec/{app/entities/text-submission => service}/text-submission.service.spec.ts (100%) rename src/test/javascript/spec/{app/core/user => service}/user.service.spec.ts (100%) diff --git a/src/test/javascript/jest.config.js b/src/test/javascript/jest.config.js index 2f2db92bd97b..7bb43e378ca6 100644 --- a/src/test/javascript/jest.config.js +++ b/src/test/javascript/jest.config.js @@ -14,7 +14,6 @@ module.exports = { transformIgnorePatterns: [`/node_modules/(?!${esModules})`], rootDir: '../../../', testMatch: [ - '/src/test/javascript/spec/app/**/*.ts', '/src/test/javascript/spec/component/**/*.ts', '/src/test/javascript/spec/directive/**/*.ts', '/src/test/javascript/spec/integration/**/*.ts', diff --git a/src/test/javascript/spec/app/admin/user-management/user-management.component.spec.ts b/src/test/javascript/spec/app/admin/user-management/user-management.component.spec.ts deleted file mode 100644 index 2dd786c1b4b5..000000000000 --- a/src/test/javascript/spec/app/admin/user-management/user-management.component.spec.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { async, ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; -import { of } from 'rxjs'; -import { HttpHeaders, HttpResponse } from '@angular/common/http'; -import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; - -import { ArtemisTestModule } from '../../../test.module'; -import { UserManagementComponent } from 'app/admin/user-management/user-management.component'; -import { User } from 'app/core/user/user.model'; -import { UserService } from 'app/core/user/user.service'; -import { AccountService } from 'app/core/auth/account.service'; -import { MockSyncStorage } from '../../../mocks/service/mock-sync-storage.service'; - -describe('Component Tests', () => { - describe('User Management Component', () => { - let comp: UserManagementComponent; - let fixture: ComponentFixture; - let service: UserService; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [UserManagementComponent], - providers: [AccountService, { provide: SessionStorageService, useClass: MockSyncStorage }, { provide: LocalStorageService, useClass: MockSyncStorage }], - }) - .overrideTemplate(UserManagementComponent, '') - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(UserManagementComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(UserService); - }); - - describe('setActive', () => { - it('Should update user and call load all', inject( - [], - fakeAsync(() => { - // GIVEN - const headers = new HttpHeaders().append('link', 'link;link'); - const user = new User(123); - spyOn(service, 'query').and.returnValue( - of( - new HttpResponse({ - body: [user], - headers, - }), - ), - ); - spyOn(service, 'update').and.returnValue(of(new HttpResponse({ status: 200 }))); - - // WHEN - comp.setActive(user, true); - tick(2000); // simulate async (needs to wait for the debounce time in UserManagementComponent) - - // THEN - expect(service.update).toHaveBeenCalledWith(user); - expect(service.query).toHaveBeenCalled(); - expect(comp.users[0]).toEqual(jasmine.objectContaining({ id: 123 })); - }), - )); - }); - }); -}); diff --git a/src/test/javascript/spec/app/entities/programming-submission/programming-submission.service.spec.ts b/src/test/javascript/spec/app/entities/programming-submission/programming-submission.service.spec.ts deleted file mode 100644 index 2bbe1d6811d5..000000000000 --- a/src/test/javascript/spec/app/entities/programming-submission/programming-submission.service.spec.ts +++ /dev/null @@ -1,101 +0,0 @@ -import { getTestBed, TestBed } from '@angular/core/testing'; -import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; -import { map, take } from 'rxjs/operators'; -import { ProgrammingSubmissionService } from 'app/exercises/programming/participate/programming-submission.service'; -import { ProgrammingSubmission } from 'app/entities/programming-submission.model'; - -describe('Service Tests', () => { - describe('ProgrammingSubmission Service', () => { - let injector: TestBed; - let service: ProgrammingSubmissionService; - let httpMock: HttpTestingController; - let elemDefault: ProgrammingSubmission; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - }); - injector = getTestBed(); - service = injector.get(ProgrammingSubmissionService); - httpMock = injector.get(HttpTestingController); - - elemDefault = new ProgrammingSubmission(); - }); - - describe('Service methods', async () => { - it('should find an element', async () => { - const returnedFromService = Object.assign({}, elemDefault); - service - .find(123) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: elemDefault })); - - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify(returnedFromService)); - }); - - it('should create a ProgrammingSubmission', async () => { - const returnedFromService = Object.assign( - { - id: 0, - }, - elemDefault, - ); - const expected = Object.assign({}, returnedFromService); - service - .create(new ProgrammingSubmission(null)) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); - const req = httpMock.expectOne({ method: 'POST' }); - req.flush(JSON.stringify(returnedFromService)); - }); - - it('should update a ProgrammingSubmission', async () => { - const returnedFromService = Object.assign( - { - commitHash: 'BBBBBB', - }, - elemDefault, - ); - - const expected = Object.assign({}, returnedFromService); - service - .update(expected) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); - const req = httpMock.expectOne({ method: 'PUT' }); - req.flush(JSON.stringify(returnedFromService)); - }); - - it('should return a list of ProgrammingSubmission', async () => { - const returnedFromService = Object.assign( - { - commitHash: 'BBBBBB', - }, - elemDefault, - ); - const expected = Object.assign({}, returnedFromService); - service - .query(expected) - .pipe( - take(1), - map((resp) => resp.body), - ) - .subscribe((body) => expect(body).toContainEqual(expected)); - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify([returnedFromService])); - httpMock.verify(); - }); - - it('should delete a ProgrammingSubmission', async () => { - service.delete(123).subscribe((resp) => expect(resp.ok)); - - const req = httpMock.expectOne({ method: 'DELETE' }); - req.flush({ status: 200 }); - }); - }); - - afterEach(() => { - httpMock.verify(); - }); - }); -}); diff --git a/src/test/javascript/spec/app/shared/user/user.service.spec.ts b/src/test/javascript/spec/app/shared/user/user.service.spec.ts deleted file mode 100644 index a3952c07b9e4..000000000000 --- a/src/test/javascript/spec/app/shared/user/user.service.spec.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { TestBed } from '@angular/core/testing'; -import { JhiDateUtils } from 'ng-jhipster'; - -import { User } from 'app/core/user/user.model'; -import { UserService } from 'app/core/user/user.service'; -import { SERVER_API_URL } from 'app/app.constants'; -import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; - -describe('Service Tests', () => { - describe('User Service', () => { - let service: UserService; - let httpMock: any; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - providers: [JhiDateUtils, UserService], - }); - - service = TestBed.inject(UserService); - httpMock = TestBed.inject(HttpTestingController); - }); - - afterEach(() => { - httpMock.verify(); - }); - - describe('Service methods', () => { - it('should call correct URL', () => { - service.find('user').subscribe(() => {}); - - const req = httpMock.expectOne({ method: 'GET' }); - const resourceUrl = SERVER_API_URL + 'api/users'; - expect(req.request.url).toEqual(`${resourceUrl}/user`); - }); - it('should return User', () => { - service.find('user').subscribe((received) => { - expect(received.body.login).toEqual('user'); - }); - - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(new User(1, 'user')); - }); - - it('should return Authorities', () => { - service.authorities().subscribe((_authorities) => { - expect(_authorities).toEqual(['ROLE_USER', 'ROLE_ADMIN']); - }); - const req = httpMock.expectOne({ method: 'GET' }); - - req.flush(['ROLE_USER', 'ROLE_ADMIN']); - }); - - it('should propagate not found response', () => { - service.find('user').subscribe(null, (_error: any) => { - expect(_error.status).toEqual(404); - }); - - const req = httpMock.expectOne({ method: 'GET' }); - req.flush('Invalid request parameters', { - status: 404, - statusText: 'Bad Request', - }); - }); - }); - }); -}); diff --git a/src/test/javascript/spec/app/account/activate/activate.component.spec.ts b/src/test/javascript/spec/component/account/activate.component.spec.ts similarity index 94% rename from src/test/javascript/spec/app/account/activate/activate.component.spec.ts rename to src/test/javascript/spec/component/account/activate.component.spec.ts index cf9b76774ece..8ece203988be 100644 --- a/src/test/javascript/spec/app/account/activate/activate.component.spec.ts +++ b/src/test/javascript/spec/component/account/activate.component.spec.ts @@ -2,8 +2,8 @@ import { async, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; import { ActivatedRoute } from '@angular/router'; import { of, throwError } from 'rxjs'; -import { ArtemisTestModule } from '../../../test.module'; -import { MockActivatedRoute } from '../../../mocks/service/mock-route.service'; +import { ArtemisTestModule } from '../../test.module'; +import { MockActivatedRoute } from '../../mocks/service/mock-route.service'; import { ActivateService } from 'app/account/activate/activate.service'; import { ActivateComponent } from 'app/account/activate/activate.component'; diff --git a/src/test/javascript/spec/app/account/password-reset/finish/password-reset-finish.component.spec.ts b/src/test/javascript/spec/component/account/password-reset-finish.component.spec.ts similarity index 96% rename from src/test/javascript/spec/app/account/password-reset/finish/password-reset-finish.component.spec.ts rename to src/test/javascript/spec/component/account/password-reset-finish.component.spec.ts index 824fee1703ae..524f10b2d243 100644 --- a/src/test/javascript/spec/app/account/password-reset/finish/password-reset-finish.component.spec.ts +++ b/src/test/javascript/spec/component/account/password-reset-finish.component.spec.ts @@ -3,10 +3,10 @@ import { of, throwError } from 'rxjs'; import { ElementRef, Renderer2 } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; -import { ArtemisTestModule } from '../../../../test.module'; +import { ArtemisTestModule } from '../../test.module'; import { PasswordResetFinishComponent } from 'app/account/password-reset/finish/password-reset-finish.component'; import { PasswordResetFinishService } from 'app/account/password-reset/finish/password-reset-finish.service'; -import { MockActivatedRoute } from '../../../../mocks/service/mock-route.service'; +import { MockActivatedRoute } from '../../mocks/service/mock-route.service'; describe('Component Tests', () => { describe('PasswordResetFinishComponent', () => { diff --git a/src/test/javascript/spec/app/account/password-reset/init/password-reset-init.component.spec.ts b/src/test/javascript/spec/component/account/password-reset-init.component.spec.ts similarity index 98% rename from src/test/javascript/spec/app/account/password-reset/init/password-reset-init.component.spec.ts rename to src/test/javascript/spec/component/account/password-reset-init.component.spec.ts index f74abdee91df..9aced9025fbd 100644 --- a/src/test/javascript/spec/app/account/password-reset/init/password-reset-init.component.spec.ts +++ b/src/test/javascript/spec/component/account/password-reset-init.component.spec.ts @@ -2,7 +2,7 @@ import { ComponentFixture, inject, TestBed } from '@angular/core/testing'; import { ElementRef, Renderer2 } from '@angular/core'; import { of, throwError } from 'rxjs'; -import { ArtemisTestModule } from '../../../../test.module'; +import { ArtemisTestModule } from '../../test.module'; import { PasswordResetInitComponent } from 'app/account/password-reset/init/password-reset-init.component'; import { PasswordResetInitService } from 'app/account/password-reset/init/password-reset-init.service'; import { EMAIL_NOT_FOUND_TYPE } from 'app/shared/constants/error.constants'; diff --git a/src/test/javascript/spec/app/account/password/password-strength-bar.component.spec.ts b/src/test/javascript/spec/component/account/password-strength-bar.component.spec.ts similarity index 100% rename from src/test/javascript/spec/app/account/password/password-strength-bar.component.spec.ts rename to src/test/javascript/spec/component/account/password-strength-bar.component.spec.ts diff --git a/src/test/javascript/spec/app/account/password/password.component.spec.ts b/src/test/javascript/spec/component/account/password.component.spec.ts similarity index 98% rename from src/test/javascript/spec/app/account/password/password.component.spec.ts rename to src/test/javascript/spec/component/account/password.component.spec.ts index 6dae07b0837b..89749d5cd79c 100644 --- a/src/test/javascript/spec/app/account/password/password.component.spec.ts +++ b/src/test/javascript/spec/component/account/password.component.spec.ts @@ -2,7 +2,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { HttpResponse } from '@angular/common/http'; import { of, throwError } from 'rxjs'; -import { ArtemisTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../test.module'; import { PasswordComponent } from 'app/account/password/password.component'; import { PasswordService } from 'app/account/password/password.service'; diff --git a/src/test/javascript/spec/app/account/register/register.component.spec.ts b/src/test/javascript/spec/component/account/register.component.spec.ts similarity index 96% rename from src/test/javascript/spec/app/account/register/register.component.spec.ts rename to src/test/javascript/spec/component/account/register.component.spec.ts index a95516ee1a1d..d12f22cecc20 100644 --- a/src/test/javascript/spec/app/account/register/register.component.spec.ts +++ b/src/test/javascript/spec/component/account/register.component.spec.ts @@ -2,8 +2,8 @@ import { async, ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angu import { of, throwError } from 'rxjs'; import { JhiLanguageService } from 'ng-jhipster'; -import { MockLanguageService } from '../../../mocks/service/mock-language.service'; -import { ArtemisTestModule } from '../../../test.module'; +import { MockLanguageService } from '../../mocks/service/mock-language.service'; +import { ArtemisTestModule } from '../../test.module'; import { EMAIL_ALREADY_USED_TYPE, LOGIN_ALREADY_USED_TYPE } from 'app/shared/constants/error.constants'; import { RegisterService } from 'app/account/register/register.service'; import { RegisterComponent } from 'app/account/register/register.component'; diff --git a/src/test/javascript/spec/app/account/settings/settings.component.spec.ts b/src/test/javascript/spec/component/account/settings.component.spec.ts similarity index 94% rename from src/test/javascript/spec/app/account/settings/settings.component.spec.ts rename to src/test/javascript/spec/component/account/settings.component.spec.ts index fa5722177031..739db4ba72fc 100644 --- a/src/test/javascript/spec/app/account/settings/settings.component.spec.ts +++ b/src/test/javascript/spec/component/account/settings.component.spec.ts @@ -2,11 +2,11 @@ import { ComponentFixture, TestBed, async } from '@angular/core/testing'; import { FormBuilder } from '@angular/forms'; import { throwError, of } from 'rxjs'; -import { ArtemisTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../test.module'; import { AccountService } from 'app/core/auth/account.service'; import { Account } from 'app/core/user/account.model'; import { SettingsComponent } from 'app/account/settings/settings.component'; -import { MockAccountService } from '../../../mocks/service/mock-account.service'; +import { MockAccountService } from '../../mocks/service/mock-account.service'; describe('SettingsComponent', () => { let comp: SettingsComponent; diff --git a/src/test/javascript/spec/app/admin/audits/audits.component.spec.ts b/src/test/javascript/spec/component/admin/audits.component.spec.ts similarity index 98% rename from src/test/javascript/spec/app/admin/audits/audits.component.spec.ts rename to src/test/javascript/spec/component/admin/audits.component.spec.ts index 9c55d29b64b5..0a132ac6fe36 100644 --- a/src/test/javascript/spec/app/admin/audits/audits.component.spec.ts +++ b/src/test/javascript/spec/component/admin/audits.component.spec.ts @@ -2,7 +2,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { of } from 'rxjs'; import { HttpHeaders, HttpResponse } from '@angular/common/http'; -import { ArtemisTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../test.module'; import { AuditsComponent } from 'app/admin/audits/audits.component'; import { AuditsService } from 'app/admin/audits/audits.service'; import { Audit } from 'app/admin/audits/audit.model'; diff --git a/src/test/javascript/spec/app/admin/configuration/configuration.component.spec.ts b/src/test/javascript/spec/component/admin/configuration.component.spec.ts similarity index 97% rename from src/test/javascript/spec/app/admin/configuration/configuration.component.spec.ts rename to src/test/javascript/spec/component/admin/configuration.component.spec.ts index b479bc246952..b3dda0584372 100644 --- a/src/test/javascript/spec/app/admin/configuration/configuration.component.spec.ts +++ b/src/test/javascript/spec/component/admin/configuration.component.spec.ts @@ -1,7 +1,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { of } from 'rxjs'; -import { ArtemisTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../test.module'; import { JhiConfigurationComponent } from 'app/admin/configuration/configuration.component'; import { JhiConfigurationService } from 'app/admin/configuration/configuration.service'; diff --git a/src/test/javascript/spec/app/admin/health/health.component.spec.ts b/src/test/javascript/spec/component/admin/health.component.spec.ts similarity index 97% rename from src/test/javascript/spec/app/admin/health/health.component.spec.ts rename to src/test/javascript/spec/component/admin/health.component.spec.ts index 45f32f3ddfc4..78e2e56230bc 100644 --- a/src/test/javascript/spec/app/admin/health/health.component.spec.ts +++ b/src/test/javascript/spec/component/admin/health.component.spec.ts @@ -2,7 +2,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { HttpErrorResponse } from '@angular/common/http'; import { of, throwError } from 'rxjs'; -import { ArtemisTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../test.module'; import { HealthComponent } from 'app/admin/health/health.component'; import { Health, HealthService } from 'app/admin/health/health.service'; diff --git a/src/test/javascript/spec/app/admin/logs/logs.component.spec.ts b/src/test/javascript/spec/component/admin/logs.component.spec.ts similarity index 97% rename from src/test/javascript/spec/app/admin/logs/logs.component.spec.ts rename to src/test/javascript/spec/component/admin/logs.component.spec.ts index b9c7d0cd1223..2d553670771c 100644 --- a/src/test/javascript/spec/app/admin/logs/logs.component.spec.ts +++ b/src/test/javascript/spec/component/admin/logs.component.spec.ts @@ -2,7 +2,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { of } from 'rxjs'; import { HttpHeaders, HttpResponse } from '@angular/common/http'; -import { ArtemisTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../test.module'; import { LogsComponent } from 'app/admin/logs/logs.component'; import { LogsService } from 'app/admin/logs/logs.service'; import { Log } from 'app/admin/logs/log.model'; diff --git a/src/test/javascript/spec/app/admin/metrics/metrics.component.spec.ts b/src/test/javascript/spec/component/admin/metrics.component.spec.ts similarity index 96% rename from src/test/javascript/spec/app/admin/metrics/metrics.component.spec.ts rename to src/test/javascript/spec/component/admin/metrics.component.spec.ts index fd53408bf0b7..785c685a2ba9 100644 --- a/src/test/javascript/spec/app/admin/metrics/metrics.component.spec.ts +++ b/src/test/javascript/spec/component/admin/metrics.component.spec.ts @@ -1,7 +1,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { of } from 'rxjs'; -import { ArtemisTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../test.module'; import { JhiMetricsMonitoringComponent } from 'app/admin/metrics/metrics.component'; import { JhiMetricsService } from 'app/admin/metrics/metrics.service'; diff --git a/src/test/javascript/spec/app/admin/user-management/user-management-detail.component.spec.ts b/src/test/javascript/spec/component/admin/user-management-detail.component.spec.ts similarity index 97% rename from src/test/javascript/spec/app/admin/user-management/user-management-detail.component.spec.ts rename to src/test/javascript/spec/component/admin/user-management-detail.component.spec.ts index d09292347da8..d3ed930ed965 100644 --- a/src/test/javascript/spec/app/admin/user-management/user-management-detail.component.spec.ts +++ b/src/test/javascript/spec/component/admin/user-management-detail.component.spec.ts @@ -2,7 +2,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ActivatedRoute } from '@angular/router'; import { of } from 'rxjs'; -import { ArtemisTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../test.module'; import { UserManagementDetailComponent } from 'app/admin/user-management/user-management-detail.component'; import { User } from 'app/core/user/user.model'; diff --git a/src/test/javascript/spec/app/admin/user-management/user-management-update.component.spec.ts b/src/test/javascript/spec/component/admin/user-management-update.component.spec.ts similarity index 98% rename from src/test/javascript/spec/app/admin/user-management/user-management-update.component.spec.ts rename to src/test/javascript/spec/component/admin/user-management-update.component.spec.ts index 22b320dd9dcc..18d0dc09f8c6 100644 --- a/src/test/javascript/spec/app/admin/user-management/user-management-update.component.spec.ts +++ b/src/test/javascript/spec/component/admin/user-management-update.component.spec.ts @@ -3,7 +3,7 @@ import { HttpResponse } from '@angular/common/http'; import { ActivatedRoute } from '@angular/router'; import { of } from 'rxjs'; -import { ArtemisTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../test.module'; import { UserManagementUpdateComponent } from 'app/admin/user-management/user-management-update.component'; import { User } from 'app/core/user/user.model'; import { JhiLanguageHelper } from 'app/core/language/language.helper'; diff --git a/src/test/javascript/spec/app/entities/course/course-detail.component.spec.ts b/src/test/javascript/spec/component/course/course-detail.component.spec.ts similarity index 95% rename from src/test/javascript/spec/app/entities/course/course-detail.component.spec.ts rename to src/test/javascript/spec/component/course/course-detail.component.spec.ts index 3d37dbc37146..b5de29783694 100644 --- a/src/test/javascript/spec/app/entities/course/course-detail.component.spec.ts +++ b/src/test/javascript/spec/component/course/course-detail.component.spec.ts @@ -2,7 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ActivatedRoute } from '@angular/router'; import { of } from 'rxjs'; -import { ArtemisTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../test.module'; import { CourseDetailComponent } from 'app/course/manage/course-detail.component'; import { Course } from 'app/entities/course.model'; diff --git a/src/test/javascript/spec/app/entities/course/course-update.component.spec.ts b/src/test/javascript/spec/component/course/course-update.component.spec.ts similarity index 97% rename from src/test/javascript/spec/app/entities/course/course-update.component.spec.ts rename to src/test/javascript/spec/component/course/course-update.component.spec.ts index 20905227ad75..9c9c71364db5 100644 --- a/src/test/javascript/spec/app/entities/course/course-update.component.spec.ts +++ b/src/test/javascript/spec/component/course/course-update.component.spec.ts @@ -2,7 +2,7 @@ import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testin import { HttpResponse } from '@angular/common/http'; import { of } from 'rxjs'; -import { ArtemisTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../test.module'; import { CourseUpdateComponent } from 'app/course/manage/course-update.component'; import { CourseManagementService } from 'app/course/manage/course-management.service'; import { Course } from 'app/entities/course.model'; diff --git a/src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise-update.component.spec.ts b/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise-update.component.spec.ts similarity index 97% rename from src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise-update.component.spec.ts rename to src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise-update.component.spec.ts index a4878ab8bc3a..4dde81a2c37e 100644 --- a/src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise-update.component.spec.ts +++ b/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise-update.component.spec.ts @@ -2,7 +2,7 @@ import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testin import { HttpResponse } from '@angular/common/http'; import { of } from 'rxjs'; -import { ArtemisTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../test.module'; import { FileUploadExerciseUpdateComponent } from 'app/exercises/file-upload/manage/file-upload-exercise-update.component'; import { FileUploadExerciseService } from 'app/exercises/file-upload/manage/file-upload-exercise.service'; import { FileUploadExercise } from 'app/entities/file-upload-exercise.model'; diff --git a/src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise.component.spec.ts b/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise.component.spec.ts similarity index 97% rename from src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise.component.spec.ts rename to src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise.component.spec.ts index 74a8c33997c1..653761af2f93 100644 --- a/src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise.component.spec.ts +++ b/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise.component.spec.ts @@ -2,7 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { of } from 'rxjs'; import { HttpHeaders, HttpResponse } from '@angular/common/http'; -import { ArtemisTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../test.module'; import { FileUploadExerciseComponent } from 'app/exercises/file-upload/manage/file-upload-exercise.component'; import { FileUploadExerciseService } from 'app/exercises/file-upload/manage/file-upload-exercise.service'; import { FileUploadExercise } from 'app/entities/file-upload-exercise.model'; diff --git a/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise-detail.component.spec.ts b/src/test/javascript/spec/component/modeling-exercise/modeling-exercise-detail.component.spec.ts similarity index 96% rename from src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise-detail.component.spec.ts rename to src/test/javascript/spec/component/modeling-exercise/modeling-exercise-detail.component.spec.ts index c22dd3fc5daf..2ea241449d8e 100644 --- a/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise-detail.component.spec.ts +++ b/src/test/javascript/spec/component/modeling-exercise/modeling-exercise-detail.component.spec.ts @@ -2,7 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ActivatedRoute } from '@angular/router'; import { of } from 'rxjs'; -import { ArtemisTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../test.module'; import { ModelingExerciseDetailComponent } from 'app/exercises/modeling/manage/modeling-exercise-detail.component'; import { ModelingExercise } from 'app/entities/modeling-exercise.model'; diff --git a/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise-update.component.spec.ts b/src/test/javascript/spec/component/modeling-exercise/modeling-exercise-update.component.spec.ts similarity index 97% rename from src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise-update.component.spec.ts rename to src/test/javascript/spec/component/modeling-exercise/modeling-exercise-update.component.spec.ts index be860fd75320..d2f7d1d78593 100644 --- a/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise-update.component.spec.ts +++ b/src/test/javascript/spec/component/modeling-exercise/modeling-exercise-update.component.spec.ts @@ -2,7 +2,7 @@ import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testin import { HttpResponse } from '@angular/common/http'; import { of } from 'rxjs'; -import { ArtemisTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../test.module'; import { ModelingExerciseUpdateComponent } from 'app/exercises/modeling/manage/modeling-exercise-update.component'; import { ModelingExerciseService } from 'app/exercises/modeling/manage/modeling-exercise.service'; import { ModelingExercise } from 'app/entities/modeling-exercise.model'; diff --git a/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise.component.spec.ts b/src/test/javascript/spec/component/modeling-exercise/modeling-exercise.component.spec.ts similarity index 97% rename from src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise.component.spec.ts rename to src/test/javascript/spec/component/modeling-exercise/modeling-exercise.component.spec.ts index fa3ec3910c20..1fc315b39061 100644 --- a/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise.component.spec.ts +++ b/src/test/javascript/spec/component/modeling-exercise/modeling-exercise.component.spec.ts @@ -2,7 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { of } from 'rxjs'; import { HttpHeaders, HttpResponse } from '@angular/common/http'; -import { ArtemisTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../test.module'; import { ModelingExerciseComponent } from 'app/exercises/modeling/manage/modeling-exercise.component'; import { ModelingExerciseService } from 'app/exercises/modeling/manage/modeling-exercise.service'; import { ModelingExercise } from 'app/entities/modeling-exercise.model'; diff --git a/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise-detail.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-detail.component.spec.ts similarity index 96% rename from src/test/javascript/spec/app/entities/programming-exercise/programming-exercise-detail.component.spec.ts rename to src/test/javascript/spec/component/programming-exercise/programming-exercise-detail.component.spec.ts index ee5451141c64..80e740d93ddc 100644 --- a/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise-detail.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-detail.component.spec.ts @@ -2,7 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ActivatedRoute } from '@angular/router'; import { of } from 'rxjs'; -import { ArtemisTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../test.module'; import { ProgrammingExerciseDetailComponent } from 'app/exercises/programming/manage/programming-exercise-detail.component'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; diff --git a/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise-update.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-update.component.spec.ts similarity index 97% rename from src/test/javascript/spec/app/entities/programming-exercise/programming-exercise-update.component.spec.ts rename to src/test/javascript/spec/component/programming-exercise/programming-exercise-update.component.spec.ts index 409e17938526..58c35513f040 100644 --- a/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise-update.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-update.component.spec.ts @@ -2,7 +2,7 @@ import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testin import { HttpResponse } from '@angular/common/http'; import { of } from 'rxjs'; -import { ArtemisTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../test.module'; import { ProgrammingExerciseUpdateComponent } from 'app/exercises/programming/manage/update/programming-exercise-update.component'; import { ProgrammingExerciseService } from 'app/exercises/programming/manage/services/programming-exercise.service'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; diff --git a/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise.component.spec.ts similarity index 88% rename from src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.component.spec.ts rename to src/test/javascript/spec/component/programming-exercise/programming-exercise.component.spec.ts index 60ff3e611488..c3d196e5f513 100644 --- a/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise.component.spec.ts @@ -2,19 +2,19 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { HttpHeaders, HttpResponse } from '@angular/common/http'; import { of } from 'rxjs'; -import { ArtemisTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../test.module'; import { ProgrammingExerciseComponent } from 'app/exercises/programming/manage/programming-exercise.component'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; -import { MockSyncStorage } from '../../../mocks/service/mock-sync-storage.service'; +import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; -import { MockTranslateService } from '../../../mocks/service/mock-translate.service'; +import { MockTranslateService } from '../../mocks/service/mock-translate.service'; import { TranslateService } from '@ngx-translate/core'; import { ActivatedRoute, convertToParamMap } from '@angular/router'; import { Course } from 'app/entities/course.model'; import { OrionConnectorService } from 'app/shared/orion/orion-connector.service'; -import { MockOrionConnectorService } from '../../../mocks/service/mock-orion-connector.service'; +import { MockOrionConnectorService } from '../../mocks/service/mock-orion-connector.service'; import { CourseExerciseService } from 'app/course/manage/course-management.service'; -import { MockCourseExerciseService } from '../../../mocks/service/mock-course-exercise.service'; +import { MockCourseExerciseService } from '../../mocks/service/mock-course-exercise.service'; describe('Component Tests', () => { describe('ProgrammingExercise Management Component', () => { diff --git a/src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise-detail.component.spec.ts b/src/test/javascript/spec/component/quiz-exercise/quiz-exercise-detail.component.spec.ts similarity index 96% rename from src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise-detail.component.spec.ts rename to src/test/javascript/spec/component/quiz-exercise/quiz-exercise-detail.component.spec.ts index ed7c54d76880..438669f5dc89 100644 --- a/src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise-detail.component.spec.ts +++ b/src/test/javascript/spec/component/quiz-exercise/quiz-exercise-detail.component.spec.ts @@ -2,7 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ActivatedRoute } from '@angular/router'; import { of } from 'rxjs'; -import { ArtemisTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../test.module'; import { QuizExerciseDetailComponent } from 'app/exercises/quiz/manage/quiz-exercise-detail.component'; import { QuizExercise } from 'app/entities/quiz/quiz-exercise.model'; diff --git a/src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise.component.spec.ts b/src/test/javascript/spec/component/quiz-exercise/quiz-exercise.component.spec.ts similarity index 96% rename from src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise.component.spec.ts rename to src/test/javascript/spec/component/quiz-exercise/quiz-exercise.component.spec.ts index a40d492f1c30..9e82bb58256b 100644 --- a/src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise.component.spec.ts +++ b/src/test/javascript/spec/component/quiz-exercise/quiz-exercise.component.spec.ts @@ -2,7 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { of } from 'rxjs'; import { HttpHeaders, HttpResponse } from '@angular/common/http'; -import { ArtemisTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../test.module'; import { QuizExerciseComponent } from 'app/exercises/quiz/manage/quiz-exercise.component'; import { QuizExerciseService } from 'app/exercises/quiz/manage/quiz-exercise.service'; import { QuizExercise } from 'app/entities/quiz/quiz-exercise.model'; diff --git a/src/test/javascript/spec/app/shared/alert/alert-error.component.spec.ts b/src/test/javascript/spec/component/shared/alert-error.component.spec.ts similarity index 97% rename from src/test/javascript/spec/app/shared/alert/alert-error.component.spec.ts rename to src/test/javascript/spec/component/shared/alert-error.component.spec.ts index b227cd12cbfb..4d7513f0d14d 100644 --- a/src/test/javascript/spec/app/shared/alert/alert-error.component.spec.ts +++ b/src/test/javascript/spec/component/shared/alert-error.component.spec.ts @@ -3,9 +3,9 @@ import { HttpErrorResponse, HttpHeaders } from '@angular/common/http'; import { JhiEventManager } from 'ng-jhipster'; import { TranslateModule } from '@ngx-translate/core'; -import { ArtemisTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../test.module'; import { AlertErrorComponent } from 'app/shared/alert/alert-error.component'; -import { MockAlertService } from '../../../mocks/service/mock-alert.service'; +import { MockAlertService } from '../../mocks/service/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; describe('Component Tests', () => { diff --git a/src/test/javascript/spec/app/entities/text-exercise/text-exercise-detail.component.spec.ts b/src/test/javascript/spec/component/text-exercise/text-exercise-detail.component.spec.ts similarity index 96% rename from src/test/javascript/spec/app/entities/text-exercise/text-exercise-detail.component.spec.ts rename to src/test/javascript/spec/component/text-exercise/text-exercise-detail.component.spec.ts index a1cce1a91aa3..a9b2287192f1 100644 --- a/src/test/javascript/spec/app/entities/text-exercise/text-exercise-detail.component.spec.ts +++ b/src/test/javascript/spec/component/text-exercise/text-exercise-detail.component.spec.ts @@ -2,7 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ActivatedRoute } from '@angular/router'; import { of } from 'rxjs'; -import { ArtemisTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../test.module'; import { TextExerciseDetailComponent } from 'app/exercises/text/manage/text-exercise/text-exercise-detail.component'; import { TextExercise } from 'app/entities/text-exercise.model'; diff --git a/src/test/javascript/spec/app/entities/text-exercise/text-exercise-update.component.spec.ts b/src/test/javascript/spec/component/text-exercise/text-exercise-update.component.spec.ts similarity index 97% rename from src/test/javascript/spec/app/entities/text-exercise/text-exercise-update.component.spec.ts rename to src/test/javascript/spec/component/text-exercise/text-exercise-update.component.spec.ts index 367422387c72..93c077dac250 100644 --- a/src/test/javascript/spec/app/entities/text-exercise/text-exercise-update.component.spec.ts +++ b/src/test/javascript/spec/component/text-exercise/text-exercise-update.component.spec.ts @@ -2,7 +2,7 @@ import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testin import { HttpResponse } from '@angular/common/http'; import { of } from 'rxjs'; -import { ArtemisTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../test.module'; import { TextExerciseUpdateComponent } from 'app/exercises/text/manage/text-exercise/text-exercise-update.component'; import { TextExerciseService } from 'app/exercises/text/manage/text-exercise/text-exercise.service'; import { TextExercise } from 'app/entities/text-exercise.model'; diff --git a/src/test/javascript/spec/app/entities/text-exercise/text-exercise.component.spec.ts b/src/test/javascript/spec/component/text-exercise/text-exercise.component.spec.ts similarity index 96% rename from src/test/javascript/spec/app/entities/text-exercise/text-exercise.component.spec.ts rename to src/test/javascript/spec/component/text-exercise/text-exercise.component.spec.ts index 8baad59527c1..881b827da423 100644 --- a/src/test/javascript/spec/app/entities/text-exercise/text-exercise.component.spec.ts +++ b/src/test/javascript/spec/component/text-exercise/text-exercise.component.spec.ts @@ -2,7 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { of } from 'rxjs'; import { HttpHeaders, HttpResponse } from '@angular/common/http'; -import { ArtemisTestModule } from '../../../test.module'; +import { ArtemisTestModule } from '../../test.module'; import { TextExerciseComponent } from 'app/exercises/text/manage/text-exercise/text-exercise.component'; import { TextExerciseService } from 'app/exercises/text/manage/text-exercise/text-exercise.service'; import { TextExercise } from 'app/entities/text-exercise.model'; diff --git a/src/test/javascript/spec/app/admin/audits/audits.service.spec.ts b/src/test/javascript/spec/service/audits.service.spec.ts similarity index 100% rename from src/test/javascript/spec/app/admin/audits/audits.service.spec.ts rename to src/test/javascript/spec/service/audits.service.spec.ts diff --git a/src/test/javascript/spec/app/admin/configuration/configuration.service.spec.ts b/src/test/javascript/spec/service/configuration.service.spec.ts similarity index 100% rename from src/test/javascript/spec/app/admin/configuration/configuration.service.spec.ts rename to src/test/javascript/spec/service/configuration.service.spec.ts diff --git a/src/test/javascript/spec/app/entities/course/course.service.spec.ts b/src/test/javascript/spec/service/course.service.spec.ts similarity index 96% rename from src/test/javascript/spec/app/entities/course/course.service.spec.ts rename to src/test/javascript/spec/service/course.service.spec.ts index 4a2e58a933d2..40c7e24cf288 100644 --- a/src/test/javascript/spec/app/entities/course/course.service.spec.ts +++ b/src/test/javascript/spec/service/course.service.spec.ts @@ -8,9 +8,9 @@ import * as moment from 'moment'; import { DATE_TIME_FORMAT } from 'app/shared/constants/input.constants'; import { CourseManagementService } from 'app/course/manage/course-management.service'; import { Course } from 'app/entities/course.model'; -import { MockTranslateService } from '../../../mocks/service/mock-translate.service'; -import { MockSyncStorage } from '../../../mocks/service/mock-sync-storage.service'; -import { MockRouter } from '../../../mocks/service/mock-router.service'; +import { MockTranslateService } from '../mocks/service/mock-translate.service'; +import { MockSyncStorage } from '../mocks/service/mock-sync-storage.service'; +import { MockRouter } from '../mocks/service/mock-router.service'; describe('Service Tests', () => { describe('Course Service', () => { diff --git a/src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise.service.spec.ts b/src/test/javascript/spec/service/file-upload-exercise.service.spec.ts similarity index 100% rename from src/test/javascript/spec/app/entities/file-upload-exercise/file-upload-exercise.service.spec.ts rename to src/test/javascript/spec/service/file-upload-exercise.service.spec.ts diff --git a/src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission.service.spec.ts b/src/test/javascript/spec/service/file-upload-submission.service.spec.ts similarity index 100% rename from src/test/javascript/spec/app/entities/file-upload-submission/file-upload-submission.service.spec.ts rename to src/test/javascript/spec/service/file-upload-submission.service.spec.ts diff --git a/src/test/javascript/spec/app/admin/logs/logs.service.spec.ts b/src/test/javascript/spec/service/logs.service.spec.ts similarity index 100% rename from src/test/javascript/spec/app/admin/logs/logs.service.spec.ts rename to src/test/javascript/spec/service/logs.service.spec.ts diff --git a/src/test/javascript/spec/app/admin/metrics/metrics.service.spec.ts b/src/test/javascript/spec/service/metrics.service.spec.ts similarity index 100% rename from src/test/javascript/spec/app/admin/metrics/metrics.service.spec.ts rename to src/test/javascript/spec/service/metrics.service.spec.ts diff --git a/src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise.service.spec.ts b/src/test/javascript/spec/service/modeling-exercise.service.spec.ts similarity index 100% rename from src/test/javascript/spec/app/entities/modeling-exercise/modeling-exercise.service.spec.ts rename to src/test/javascript/spec/service/modeling-exercise.service.spec.ts diff --git a/src/test/javascript/spec/app/entities/modeling-submission/modeling-submission.service.spec.ts b/src/test/javascript/spec/service/modeling-submission.service.spec.ts similarity index 100% rename from src/test/javascript/spec/app/entities/modeling-submission/modeling-submission.service.spec.ts rename to src/test/javascript/spec/service/modeling-submission.service.spec.ts diff --git a/src/test/javascript/spec/app/entities/participation/participation.service.spec.ts b/src/test/javascript/spec/service/participation.service.spec.ts similarity index 100% rename from src/test/javascript/spec/app/entities/participation/participation.service.spec.ts rename to src/test/javascript/spec/service/participation.service.spec.ts diff --git a/src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.service.spec.ts b/src/test/javascript/spec/service/programming-exercise.service.spec.ts similarity index 100% rename from src/test/javascript/spec/app/entities/programming-exercise/programming-exercise.service.spec.ts rename to src/test/javascript/spec/service/programming-exercise.service.spec.ts diff --git a/src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise.service.spec.ts b/src/test/javascript/spec/service/quiz-exercise.service.spec.ts similarity index 100% rename from src/test/javascript/spec/app/entities/quiz-exercise/quiz-exercise.service.spec.ts rename to src/test/javascript/spec/service/quiz-exercise.service.spec.ts diff --git a/src/test/javascript/spec/app/entities/text-exercise/text-exercise.service.spec.ts b/src/test/javascript/spec/service/text-exercise.service.spec.ts similarity index 100% rename from src/test/javascript/spec/app/entities/text-exercise/text-exercise.service.spec.ts rename to src/test/javascript/spec/service/text-exercise.service.spec.ts diff --git a/src/test/javascript/spec/app/entities/text-submission/text-submission.service.spec.ts b/src/test/javascript/spec/service/text-submission.service.spec.ts similarity index 100% rename from src/test/javascript/spec/app/entities/text-submission/text-submission.service.spec.ts rename to src/test/javascript/spec/service/text-submission.service.spec.ts diff --git a/src/test/javascript/spec/app/core/user/user.service.spec.ts b/src/test/javascript/spec/service/user.service.spec.ts similarity index 100% rename from src/test/javascript/spec/app/core/user/user.service.spec.ts rename to src/test/javascript/spec/service/user.service.spec.ts From 76f53e994a8ef6954779c5e2163817aefac1d796 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Fri, 24 Apr 2020 02:43:14 +0200 Subject: [PATCH 097/152] Group all non-spec files (mocks, utils, samples) in /helpers/ directory for the sake of clarity --- .../account/activate.component.spec.ts | 2 +- .../password-reset-finish.component.spec.ts | 2 +- .../account/register.component.spec.ts | 2 +- .../account/settings.component.spec.ts | 2 +- .../admin/user-management.component.spec.ts | 4 +-- .../code-editor-ace.component.spec.ts | 4 +-- .../code-editor-actions.component.spec.ts | 12 +++---- ...code-editor-build-output.component.spec.ts | 14 ++++---- ...code-editor-file-browser.component.spec.ts | 12 +++---- ...code-editor-instructions.component.spec.ts | 4 +-- .../complaints-for-tutor.component.spec.ts | 4 +-- .../complaints/complaints.component.spec.ts | 4 +-- .../file-upload-assessment.component.spec.ts | 10 +++--- ...e-upload-exercise-detail.component.spec.ts | 6 ++-- .../file-upload-result.component.spec.ts | 4 +-- .../file-upload-submission.component.spec.ts | 14 ++++---- .../guided-tour/guided-tour.component.spec.ts | 6 ++-- .../list-of-complaints.component.spec.ts | 4 +-- ...deling-assessment-editor.component.spec.ts | 4 +-- .../modeling-submission.component.spec.ts | 10 +++--- .../course-exercise-row.component.spec.ts | 14 ++++---- .../course-statistics.component.spec.ts | 2 +- ...-details-student-actions.component.spec.ts | 10 +++--- ...cise-student-ide-actions.component.spec.ts | 10 +++--- .../overview/overview.component.spec.ts | 10 +++--- ...participation-submission.component.spec.ts | 8 ++--- .../participation.component.spec.ts | 4 +-- ...ent-manual-result-dialog.component.spec.ts | 14 ++++---- ...ise-editable-instruction.component.spec.ts | 8 ++--- ...gramming-exercise-import.component.spec.ts | 4 +-- ...ise-instruction-analysis.component.spec.ts | 2 +- ...-instruction-step-wizard.component.spec.ts | 2 +- ...ing-exercise-instruction.component.spec.ts | 18 +++++----- ...ercise-instructor-status.component.spec.ts | 6 ++-- ...tructor-submission-state.component.spec.ts | 10 +++--- ...ercise-manage-test-cases.component.spec.ts | 18 +++++----- ...ise-trigger-build-button.component.spec.ts | 8 ++--- .../programming-exercise.component.spec.ts | 8 ++--- .../shared/alert-error.component.spec.ts | 2 +- .../component/shared/button.component.spec.ts | 4 +-- .../shared/secured-image.component.spec.ts | 4 +-- .../shared/updating-result.component.spec.ts | 10 +++--- .../student-questions.component.spec.ts | 2 +- .../table-editable-field.component.spec.ts | 2 +- .../team/team-update-dialog.component.spec.ts | 6 ++-- .../component/team/teams.component.spec.ts | 14 ++++---- .../text-editor/text-editor.component.spec.ts | 4 +-- ...ext-exercise-assessement.component.spec.ts | 10 +++--- ...tutor-exercise-dashboard.component.spec.ts | 8 ++--- ...utor-participation-graph.component.spec.ts | 2 +- .../build-plan-link.directive.spec.ts | 4 +-- .../delete-dialog.directive.spec.ts | 2 +- .../mock-activated-route-query-param-map.ts | 0 .../mock-activated-route-snapshot.ts | 0 .../activated-route/mock-activated-route.ts | 0 .../activated-route/mock-activated.route.ts | 0 .../mock-has-any-authority.directive.ts | 0 .../mocks/service/mock-account.service.ts | 0 .../service/mock-active-modal.service.ts | 2 +- .../mocks/service/mock-alert.service.ts | 2 +- .../mock-auth-server-provider.service.ts | 0 .../service/mock-cacheable-image.service.ts | 0 .../mock-code-editor-build-log.service.ts | 0 ...mock-code-editor-conflict-state.service.ts | 0 .../service/mock-code-editor-grid.service.ts | 0 ...ock-code-editor-repository-file.service.ts | 0 .../mock-code-editor-repository.service.ts | 0 .../mock-code-editor-session.service.ts | 0 .../mocks/service/mock-complaint.service.ts | 0 .../mocks/service/mock-cookie.service.ts | 0 .../service/mock-course-exercise.service.ts | 0 .../mocks/service/mock-course.service.ts | 0 .../service/mock-event-manager.service.ts | 2 +- .../service/mock-exercise-hint.service.ts | 0 .../mocks/service/mock-exercise.service.ts | 0 .../service/mock-feature-toggle.service.ts | 0 .../mock-file-upload-exercise.service.ts | 0 .../mock-file-upload-submission.service.ts | 0 .../mocks/service/mock-http.service.ts | 0 .../mock-ide-build-and-test.service.ts | 0 .../mocks/service/mock-language.service.ts | 2 +- .../mocks/service/mock-login.service.ts | 2 +- .../mocks/service/mock-ngb-modal.service.ts | 0 .../service/mock-notification.service.ts | 0 .../service/mock-orion-connector.service.ts | 0 .../mock-participation-websocket.service.ts | 0 .../service/mock-participation.service.ts | 0 .../mocks/service/mock-principal.service.ts | 2 +- .../mocks/service/mock-profile.service.ts | 0 .../mock-programming-build-run.service.ts | 0 ...ock-programming-exercise-paging.service.ts | 0 ...gramming-exercise-participation.service.ts | 0 ...-programming-exercise-test-case.service.ts | 0 ...-programming-exercise-websocket.service.ts | 0 .../mock-programming-exercise.service.ts | 0 .../mock-programming-submission.service.ts | 0 .../service/mock-repository-file.service.ts | 0 .../mocks/service/mock-result.service.ts | 0 .../mocks/service/mock-route.service.ts | 2 +- .../mocks/service/mock-router.service.ts | 0 .../service/mock-state-storage.service.ts | 2 +- .../service/mock-sync-storage.service.ts | 0 .../mocks/service/mock-team.service.ts | 0 .../mocks/service/mock-text-editor.service.ts | 0 .../mocks/service/mock-tracker.service.ts | 2 +- .../mocks/service/mock-translate.service.ts | 0 .../mocks/service/mock-user.service.ts | 0 .../mocks/service/mock-websocket.service.ts | 0 .../mocks/service/mock-window.service.ts | 0 .../spec/{ => helpers}/sample/build-logs.ts | 0 .../sample/problemStatement.json | 0 .../spec/{ => helpers}/utils/general.utils.ts | 0 ...code-editor-instructor.integration.spec.ts | 34 +++++++++---------- .../code-editor-student.integration.spec.ts | 32 ++++++++--------- .../spec/service/account.service.spec.ts | 10 +++--- .../spec/service/course.service.spec.ts | 6 ++-- .../spec/service/guided-tour.service.spec.ts | 8 ++--- .../ide-build-and-test.service.spec.ts | 8 ++--- .../spec/service/login.service.spec.ts | 12 +++---- .../orion-version-validator.service.spec.ts | 6 ++-- .../participation-websocket.service.spec.ts | 2 +- ...rcise-instruction-analysis.service.spec.ts | 4 +-- ...ramming-exercise-test-case.service.spec.ts | 4 +-- .../programming-submission.service.spec.ts | 8 ++--- .../service/user-route-access.service.spec.ts | 10 +++--- src/test/javascript/spec/test.module.ts | 10 +++--- 126 files changed, 263 insertions(+), 263 deletions(-) rename src/test/javascript/spec/directive/{programming-exercise => }/build-plan-link.directive.spec.ts (95%) rename src/test/javascript/spec/directive/{shared => }/delete-dialog.directive.spec.ts (98%) rename src/test/javascript/spec/{ => helpers}/mocks/activated-route/mock-activated-route-query-param-map.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/activated-route/mock-activated-route-snapshot.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/activated-route/mock-activated-route.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/activated-route/mock-activated.route.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/directive/mock-has-any-authority.directive.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-account.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-active-modal.service.ts (84%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-alert.service.ts (84%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-auth-server-provider.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-cacheable-image.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-code-editor-build-log.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-code-editor-conflict-state.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-code-editor-grid.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-code-editor-repository-file.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-code-editor-repository.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-code-editor-session.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-complaint.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-cookie.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-course-exercise.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-course.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-event-manager.service.ts (83%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-exercise-hint.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-exercise.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-feature-toggle.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-file-upload-exercise.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-file-upload-submission.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-http.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-ide-build-and-test.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-language.service.ts (95%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-login.service.ts (93%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-ngb-modal.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-notification.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-orion-connector.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-participation-websocket.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-participation.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-principal.service.ts (89%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-profile.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-programming-build-run.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-programming-exercise-paging.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-programming-exercise-participation.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-programming-exercise-test-case.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-programming-exercise-websocket.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-programming-exercise.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-programming-submission.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-repository-file.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-result.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-route.service.ts (92%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-router.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-state-storage.service.ts (90%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-sync-storage.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-team.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-text-editor.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-tracker.service.ts (79%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-translate.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-user.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-websocket.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/mocks/service/mock-window.service.ts (100%) rename src/test/javascript/spec/{ => helpers}/sample/build-logs.ts (100%) rename src/test/javascript/spec/{ => helpers}/sample/problemStatement.json (100%) rename src/test/javascript/spec/{ => helpers}/utils/general.utils.ts (100%) diff --git a/src/test/javascript/spec/component/account/activate.component.spec.ts b/src/test/javascript/spec/component/account/activate.component.spec.ts index 8ece203988be..7c92e57eba1f 100644 --- a/src/test/javascript/spec/component/account/activate.component.spec.ts +++ b/src/test/javascript/spec/component/account/activate.component.spec.ts @@ -3,7 +3,7 @@ import { ActivatedRoute } from '@angular/router'; import { of, throwError } from 'rxjs'; import { ArtemisTestModule } from '../../test.module'; -import { MockActivatedRoute } from '../../mocks/service/mock-route.service'; +import { MockActivatedRoute } from '../../helpers/mocks/service/mock-route.service'; import { ActivateService } from 'app/account/activate/activate.service'; import { ActivateComponent } from 'app/account/activate/activate.component'; diff --git a/src/test/javascript/spec/component/account/password-reset-finish.component.spec.ts b/src/test/javascript/spec/component/account/password-reset-finish.component.spec.ts index 524f10b2d243..26313e010609 100644 --- a/src/test/javascript/spec/component/account/password-reset-finish.component.spec.ts +++ b/src/test/javascript/spec/component/account/password-reset-finish.component.spec.ts @@ -6,7 +6,7 @@ import { ActivatedRoute } from '@angular/router'; import { ArtemisTestModule } from '../../test.module'; import { PasswordResetFinishComponent } from 'app/account/password-reset/finish/password-reset-finish.component'; import { PasswordResetFinishService } from 'app/account/password-reset/finish/password-reset-finish.service'; -import { MockActivatedRoute } from '../../mocks/service/mock-route.service'; +import { MockActivatedRoute } from '../../helpers/mocks/service/mock-route.service'; describe('Component Tests', () => { describe('PasswordResetFinishComponent', () => { diff --git a/src/test/javascript/spec/component/account/register.component.spec.ts b/src/test/javascript/spec/component/account/register.component.spec.ts index d12f22cecc20..790f16ea759b 100644 --- a/src/test/javascript/spec/component/account/register.component.spec.ts +++ b/src/test/javascript/spec/component/account/register.component.spec.ts @@ -2,7 +2,7 @@ import { async, ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angu import { of, throwError } from 'rxjs'; import { JhiLanguageService } from 'ng-jhipster'; -import { MockLanguageService } from '../../mocks/service/mock-language.service'; +import { MockLanguageService } from '../../helpers/mocks/service/mock-language.service'; import { ArtemisTestModule } from '../../test.module'; import { EMAIL_ALREADY_USED_TYPE, LOGIN_ALREADY_USED_TYPE } from 'app/shared/constants/error.constants'; import { RegisterService } from 'app/account/register/register.service'; diff --git a/src/test/javascript/spec/component/account/settings.component.spec.ts b/src/test/javascript/spec/component/account/settings.component.spec.ts index 739db4ba72fc..4e5a0e422bdd 100644 --- a/src/test/javascript/spec/component/account/settings.component.spec.ts +++ b/src/test/javascript/spec/component/account/settings.component.spec.ts @@ -6,7 +6,7 @@ import { ArtemisTestModule } from '../../test.module'; import { AccountService } from 'app/core/auth/account.service'; import { Account } from 'app/core/user/account.model'; import { SettingsComponent } from 'app/account/settings/settings.component'; -import { MockAccountService } from '../../mocks/service/mock-account.service'; +import { MockAccountService } from '../../helpers/mocks/service/mock-account.service'; describe('SettingsComponent', () => { let comp: SettingsComponent; diff --git a/src/test/javascript/spec/component/admin/user-management.component.spec.ts b/src/test/javascript/spec/component/admin/user-management.component.spec.ts index 5949107785fb..fdfb732b0f26 100644 --- a/src/test/javascript/spec/component/admin/user-management.component.spec.ts +++ b/src/test/javascript/spec/component/admin/user-management.component.spec.ts @@ -6,9 +6,9 @@ import { ArtemisTestModule } from '../../test.module'; import { ArtemisAdminModule } from 'app/admin/admin.module'; import { UserManagementComponent } from 'app/admin/user-management/user-management.component'; import { UserService } from 'app/core/user/user.service'; -import { MockUserService } from '../../mocks/service/mock-user.service'; +import { MockUserService } from '../../helpers/mocks/service/mock-user.service'; import { AccountService } from 'app/core/auth/account.service'; -import { MockAccountService } from '../../mocks/service/mock-account.service'; +import { MockAccountService } from '../../helpers/mocks/service/mock-account.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/component/code-editor/code-editor-ace.component.spec.ts b/src/test/javascript/spec/component/code-editor/code-editor-ace.component.spec.ts index eead78fd6ed1..0693f29678d5 100644 --- a/src/test/javascript/spec/component/code-editor/code-editor-ace.component.spec.ts +++ b/src/test/javascript/spec/component/code-editor/code-editor-ace.component.spec.ts @@ -11,12 +11,12 @@ import { SinonStub, spy, stub } from 'sinon'; import { Subject } from 'rxjs'; import { ArtemisTestModule } from '../../test.module'; import { CreateFileChange, FileType, RenameFileChange } from 'app/exercises/programming/shared/code-editor/model/code-editor.model'; -import { triggerChanges } from '../../utils/general.utils'; +import { triggerChanges } from '../../helpers/utils/general.utils'; import { AnnotationArray } from 'app/entities/annotation.model'; import { CodeEditorRepositoryFileService } from 'app/exercises/programming/shared/code-editor/service/code-editor-repository.service'; import { CodeEditorFileService } from 'app/exercises/programming/shared/code-editor/service/code-editor-file.service'; import { CodeEditorAceComponent } from 'app/exercises/programming/shared/code-editor/ace/code-editor-ace.component'; -import { MockCodeEditorRepositoryFileService } from '../../mocks/service/mock-code-editor-repository-file.service'; +import { MockCodeEditorRepositoryFileService } from '../../helpers/mocks/service/mock-code-editor-repository-file.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/component/code-editor/code-editor-actions.component.spec.ts b/src/test/javascript/spec/component/code-editor/code-editor-actions.component.spec.ts index d79c487ee8fa..282153f8da27 100644 --- a/src/test/javascript/spec/component/code-editor/code-editor-actions.component.spec.ts +++ b/src/test/javascript/spec/component/code-editor/code-editor-actions.component.spec.ts @@ -15,16 +15,16 @@ import { CodeEditorRepositoryFileService, CodeEditorRepositoryService } from 'ap import { ArtemisTestModule } from '../../test.module'; import { FeatureToggleModule } from 'app/shared/feature-toggle/feature-toggle.module'; import { FeatureToggleService } from 'app/shared/feature-toggle/feature-toggle.service'; -import { MockFeatureToggleService } from '../../mocks/service/mock-feature-toggle.service'; +import { MockFeatureToggleService } from '../../helpers/mocks/service/mock-feature-toggle.service'; import { cartesianProduct } from 'app/shared/util/utils'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; import { CodeEditorConflictStateService } from 'app/exercises/programming/shared/code-editor/service/code-editor-conflict-state.service'; import { CodeEditorActionsComponent } from 'app/exercises/programming/shared/code-editor/actions/code-editor-actions.component'; -import { MockCodeEditorConflictStateService } from '../../mocks/service/mock-code-editor-conflict-state.service'; -import { MockCodeEditorRepositoryFileService } from '../../mocks/service/mock-code-editor-repository-file.service'; -import { MockCodeEditorRepositoryService } from '../../mocks/service/mock-code-editor-repository.service'; -import { MockCookieService } from '../../mocks/service/mock-cookie.service'; +import { MockCodeEditorConflictStateService } from '../../helpers/mocks/service/mock-code-editor-conflict-state.service'; +import { MockCodeEditorRepositoryFileService } from '../../helpers/mocks/service/mock-code-editor-repository-file.service'; +import { MockCodeEditorRepositoryService } from '../../helpers/mocks/service/mock-code-editor-repository.service'; +import { MockCookieService } from '../../helpers/mocks/service/mock-cookie.service'; import { CommitState, EditorState } from 'app/exercises/programming/shared/code-editor/model/code-editor.model'; chai.use(sinonChai); diff --git a/src/test/javascript/spec/component/code-editor/code-editor-build-output.component.spec.ts b/src/test/javascript/spec/component/code-editor/code-editor-build-output.component.spec.ts index a9487254553d..7a1e39182946 100644 --- a/src/test/javascript/spec/component/code-editor/code-editor-build-output.component.spec.ts +++ b/src/test/javascript/spec/component/code-editor/code-editor-build-output.component.spec.ts @@ -11,7 +11,7 @@ import { SinonStub, stub } from 'sinon'; import { Observable, of } from 'rxjs'; import { ArtemisTestModule } from '../../test.module'; import { ParticipationWebsocketService } from 'app/overview/participation-websocket.service'; -import { triggerChanges } from '../../utils/general.utils'; +import { triggerChanges } from '../../helpers/utils/general.utils'; import { CodeEditorBuildOutputComponent } from 'app/exercises/programming/shared/code-editor/build-output/code-editor-build-output.component'; import { Participation } from 'app/entities/participation/participation.model'; import { BuildLogEntryArray } from 'app/entities/build-log.model'; @@ -21,12 +21,12 @@ import { ArtemisSharedModule } from 'app/shared/shared.module'; import { ResultService } from 'app/exercises/shared/result/result.service'; import { AnnotationArray } from 'app/entities/annotation.model'; import { Feedback } from 'app/entities/feedback.model'; -import { MockResultService } from '../../mocks/service/mock-result.service'; -import { MockCodeEditorBuildLogService } from '../../mocks/service/mock-code-editor-build-log.service'; -import { MockCodeEditorSessionService } from '../../mocks/service/mock-code-editor-session.service'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; -import { MockParticipationWebsocketService } from '../../mocks/service/mock-participation-websocket.service'; -import { MockCookieService } from '../../mocks/service/mock-cookie.service'; +import { MockResultService } from '../../helpers/mocks/service/mock-result.service'; +import { MockCodeEditorBuildLogService } from '../../helpers/mocks/service/mock-code-editor-build-log.service'; +import { MockCodeEditorSessionService } from '../../helpers/mocks/service/mock-code-editor-session.service'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; +import { MockParticipationWebsocketService } from '../../helpers/mocks/service/mock-participation-websocket.service'; +import { MockCookieService } from '../../helpers/mocks/service/mock-cookie.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/component/code-editor/code-editor-file-browser.component.spec.ts b/src/test/javascript/spec/component/code-editor/code-editor-file-browser.component.spec.ts index f2bd1d21a752..5fb7a0e6fcf2 100644 --- a/src/test/javascript/spec/component/code-editor/code-editor-file-browser.component.spec.ts +++ b/src/test/javascript/spec/component/code-editor/code-editor-file-browser.component.spec.ts @@ -14,7 +14,7 @@ import { SinonStub, spy, stub } from 'sinon'; import { Observable, Subject } from 'rxjs'; import { ArtemisTestModule } from '../../test.module'; import { CommitState, FileType, GitConflictState } from 'app/exercises/programming/shared/code-editor/model/code-editor.model'; -import { triggerChanges } from '../../utils/general.utils'; +import { triggerChanges } from '../../helpers/utils/general.utils'; import { DeviceDetectorService } from 'ngx-device-detector'; import { CodeEditorRepositoryFileService, CodeEditorRepositoryService } from 'app/exercises/programming/shared/code-editor/service/code-editor-repository.service'; import { CodeEditorConflictStateService } from 'app/exercises/programming/shared/code-editor/service/code-editor-conflict-state.service'; @@ -24,11 +24,11 @@ import { CodeEditorFileBrowserCreateNodeComponent } from 'app/exercises/programm import { CodeEditorFileBrowserFileComponent } from 'app/exercises/programming/shared/code-editor/file-browser/code-editor-file-browser-file.component'; import { CodeEditorFileBrowserComponent } from 'app/exercises/programming/shared/code-editor/file-browser/code-editor-file-browser.component'; import { CodeEditorStatusComponent } from 'app/exercises/programming/shared/code-editor/status/code-editor-status.component'; -import { MockCodeEditorRepositoryService } from '../../mocks/service/mock-code-editor-repository.service'; -import { MockCodeEditorRepositoryFileService } from '../../mocks/service/mock-code-editor-repository-file.service'; -import { MockCodeEditorConflictStateService } from '../../mocks/service/mock-code-editor-conflict-state.service'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; -import { MockCookieService } from '../../mocks/service/mock-cookie.service'; +import { MockCodeEditorRepositoryService } from '../../helpers/mocks/service/mock-code-editor-repository.service'; +import { MockCodeEditorRepositoryFileService } from '../../helpers/mocks/service/mock-code-editor-repository-file.service'; +import { MockCodeEditorConflictStateService } from '../../helpers/mocks/service/mock-code-editor-conflict-state.service'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; +import { MockCookieService } from '../../helpers/mocks/service/mock-cookie.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/component/code-editor/code-editor-instructions.component.spec.ts b/src/test/javascript/spec/component/code-editor/code-editor-instructions.component.spec.ts index 92f28a650cda..e0d1df646feb 100644 --- a/src/test/javascript/spec/component/code-editor/code-editor-instructions.component.spec.ts +++ b/src/test/javascript/spec/component/code-editor/code-editor-instructions.component.spec.ts @@ -9,7 +9,7 @@ import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; import { AceEditorModule } from 'ng2-ace-editor'; import { ArtemisTestModule } from '../../test.module'; -import { MockCodeEditorGridService } from '../../mocks/service/mock-code-editor-grid.service'; +import { MockCodeEditorGridService } from '../../helpers/mocks/service/mock-code-editor-grid.service'; import { CodeEditorRepositoryFileService } from 'app/exercises/programming/shared/code-editor/service/code-editor-repository.service'; import { CodeEditorGridService } from 'app/exercises/programming/shared/code-editor/service/code-editor-grid.service'; import { CodeEditorInstructionsComponent } from 'app/exercises/programming/shared/code-editor/instructions/code-editor-instructions.component'; @@ -17,7 +17,7 @@ import { ProgrammingExerciseInstructionComponent } from 'app/exercises/programmi import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; import { ProgrammingExerciseEditableInstructionComponent } from 'app/exercises/programming/manage/instructions-editor/programming-exercise-editable-instruction.component'; import { ArtemisMarkdownEditorModule } from 'app/shared/markdown-editor/markdown-editor.module'; -import { MockCodeEditorRepositoryFileService } from '../../mocks/service/mock-code-editor-repository-file.service'; +import { MockCodeEditorRepositoryFileService } from '../../helpers/mocks/service/mock-code-editor-repository-file.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/component/complaints-for-tutor/complaints-for-tutor.component.spec.ts b/src/test/javascript/spec/component/complaints-for-tutor/complaints-for-tutor.component.spec.ts index 7d99e4ab37df..129b51f1213d 100644 --- a/src/test/javascript/spec/component/complaints-for-tutor/complaints-for-tutor.component.spec.ts +++ b/src/test/javascript/spec/component/complaints-for-tutor/complaints-for-tutor.component.spec.ts @@ -2,8 +2,8 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import * as chai from 'chai'; import { BrowserModule, By } from '@angular/platform-browser'; import { ComplaintService } from 'app/complaints/complaint.service'; -import { MockComplaintService } from '../../mocks/service/mock-complaint.service'; -import { MockAlertService } from '../../mocks/service/mock-alert.service'; +import { MockComplaintService } from '../../helpers/mocks/service/mock-complaint.service'; +import { MockAlertService } from '../../helpers/mocks/service/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { MomentModule } from 'ngx-moment'; diff --git a/src/test/javascript/spec/component/complaints/complaints.component.spec.ts b/src/test/javascript/spec/component/complaints/complaints.component.spec.ts index 52c6abdf1b6b..3f444e484d87 100644 --- a/src/test/javascript/spec/component/complaints/complaints.component.spec.ts +++ b/src/test/javascript/spec/component/complaints/complaints.component.spec.ts @@ -2,8 +2,8 @@ import { async, ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core import * as chai from 'chai'; import { By } from '@angular/platform-browser'; import { ComplaintService } from 'app/complaints/complaint.service'; -import { MockComplaintResponse, MockComplaintService } from '../../mocks/service/mock-complaint.service'; -import { MockAlertService } from '../../mocks/service/mock-alert.service'; +import { MockComplaintResponse, MockComplaintService } from '../../helpers/mocks/service/mock-complaint.service'; +import { MockAlertService } from '../../helpers/mocks/service/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; import { MomentModule } from 'ngx-moment'; import { DebugElement } from '@angular/core'; diff --git a/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.component.spec.ts b/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.component.spec.ts index d91b9bf0cb81..9b739fa79a38 100644 --- a/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.component.spec.ts +++ b/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.component.spec.ts @@ -7,19 +7,19 @@ import * as sinonChai from 'sinon-chai'; import * as moment from 'moment'; import { SinonStub, stub } from 'sinon'; import { ArtemisTestModule } from '../../test.module'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; import { MockComponent } from 'ng-mocks'; import { ArtemisSharedModule } from 'app/shared/shared.module'; -import { MockAlertService } from '../../mocks/service/mock-alert.service'; +import { MockAlertService } from '../../helpers/mocks/service/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; import { Router } from '@angular/router'; import { FileUploadAssessmentComponent } from 'app/exercises/file-upload/assess/file-upload-assessment.component'; import { ResizableInstructionsComponent } from 'app/exercises/text/assess/resizable-instructions/resizable-instructions.component'; import { DebugElement } from '@angular/core'; -import { MockAccountService } from '../../mocks/service/mock-account.service'; +import { MockAccountService } from '../../helpers/mocks/service/mock-account.service'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { ComplaintService } from 'app/complaints/complaint.service'; -import { MockComplaintService } from '../../mocks/service/mock-complaint.service'; +import { MockComplaintService } from '../../helpers/mocks/service/mock-complaint.service'; import { ArtemisAssessmentSharedModule } from 'app/assessment/assessment-shared.module'; import { TranslateModule } from '@ngx-translate/core'; import { FileUploadExercise } from 'app/entities/file-upload-exercise.model'; @@ -35,7 +35,7 @@ import { ModelingAssessmentModule } from 'app/exercises/modeling/assess/modeling import { routes } from 'app/exercises/file-upload/assess/file-upload-assessment.route'; import { By } from '@angular/platform-browser'; import { throwError } from 'rxjs'; -import { MockActivatedRoute } from '../../mocks/activated-route/mock-activated-route'; +import { MockActivatedRoute } from '../../helpers/mocks/activated-route/mock-activated-route'; import { Participation, ParticipationType } from 'app/entities/participation/participation.model'; chai.use(sinonChai); diff --git a/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise-detail.component.spec.ts b/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise-detail.component.spec.ts index 6b4a85c2fc6a..803838628bf6 100644 --- a/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise-detail.component.spec.ts +++ b/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise-detail.component.spec.ts @@ -7,15 +7,15 @@ import { FileUploadExerciseDetailComponent } from 'app/exercises/file-upload/man import { By } from '@angular/platform-browser'; import * as sinonChai from 'sinon-chai'; import * as chai from 'chai'; -import { fileUploadExercise, MockFileUploadExerciseService } from '../../mocks/service/mock-file-upload-exercise.service'; +import { fileUploadExercise, MockFileUploadExerciseService } from '../../helpers/mocks/service/mock-file-upload-exercise.service'; import { JhiLanguageHelper } from 'app/core/language/language.helper'; import { AlertService } from 'app/core/alert/alert.service'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { RouterTestingModule } from '@angular/router/testing'; import { TranslateModule } from '@ngx-translate/core'; import { ArtemisAssessmentSharedModule } from 'app/assessment/assessment-shared.module'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; -import { MockCookieService } from '../../mocks/service/mock-cookie.service'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; +import { MockCookieService } from '../../helpers/mocks/service/mock-cookie.service'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { CookieService } from 'ngx-cookie-service'; import { FileUploadExerciseService } from 'app/exercises/file-upload/manage/file-upload-exercise.service'; diff --git a/src/test/javascript/spec/component/file-upload-submission/file-upload-result.component.spec.ts b/src/test/javascript/spec/component/file-upload-submission/file-upload-result.component.spec.ts index 29d7e4293eaa..b5b1a32d4fb8 100644 --- a/src/test/javascript/spec/component/file-upload-submission/file-upload-result.component.spec.ts +++ b/src/test/javascript/spec/component/file-upload-submission/file-upload-result.component.spec.ts @@ -5,11 +5,11 @@ import * as sinonChai from 'sinon-chai'; import { ArtemisTestModule } from '../../test.module'; import { Result } from 'app/entities/result.model'; import { ArtemisSharedModule } from 'app/shared/shared.module'; -import { MockAlertService } from '../../mocks/service/mock-alert.service'; +import { MockAlertService } from '../../helpers/mocks/service/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; import { DebugElement } from '@angular/core'; import { By } from '@angular/platform-browser'; -import { MockAccountService } from '../../mocks/service/mock-account.service'; +import { MockAccountService } from '../../helpers/mocks/service/mock-account.service'; import { NgxDatatableModule } from '@swimlane/ngx-datatable'; import { TranslateModule } from '@ngx-translate/core'; import { FileUploadResultComponent } from 'app/exercises/file-upload/participate/file-upload-result.component'; diff --git a/src/test/javascript/spec/component/file-upload-submission/file-upload-submission.component.spec.ts b/src/test/javascript/spec/component/file-upload-submission/file-upload-submission.component.spec.ts index 26bdc45cc7ff..0e8721bb42f8 100644 --- a/src/test/javascript/spec/component/file-upload-submission/file-upload-submission.component.spec.ts +++ b/src/test/javascript/spec/component/file-upload-submission/file-upload-submission.component.spec.ts @@ -4,26 +4,26 @@ import { AccountService } from 'app/core/auth/account.service'; import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; import { ArtemisTestModule } from '../../test.module'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; -import { MockParticipationWebsocketService } from '../../mocks/service/mock-participation-websocket.service'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; +import { MockParticipationWebsocketService } from '../../helpers/mocks/service/mock-participation-websocket.service'; import { MockComponent } from 'ng-mocks'; -import { MockAlertService } from '../../mocks/service/mock-alert.service'; +import { MockAlertService } from '../../helpers/mocks/service/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; import { Router } from '@angular/router'; import { ResizableInstructionsComponent } from 'app/exercises/text/assess/resizable-instructions/resizable-instructions.component'; import { DebugElement } from '@angular/core'; import { By } from '@angular/platform-browser'; -import { MockAccountService } from '../../mocks/service/mock-account.service'; +import { MockAccountService } from '../../helpers/mocks/service/mock-account.service'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { ComplaintService } from 'app/complaints/complaint.service'; -import { MockComplaintService } from '../../mocks/service/mock-complaint.service'; +import { MockComplaintService } from '../../helpers/mocks/service/mock-complaint.service'; import { NgxDatatableModule } from '@swimlane/ngx-datatable'; import { routes } from 'app/exercises/file-upload/participate/file-upload-participation.route'; import { FileUploadSubmissionComponent } from 'app/exercises/file-upload/participate/file-upload-submission.component'; import { MomentModule } from 'ngx-moment'; -import { createFileUploadSubmission, MockFileUploadSubmissionService } from '../../mocks/service/mock-file-upload-submission.service'; +import { createFileUploadSubmission, MockFileUploadSubmissionService } from '../../helpers/mocks/service/mock-file-upload-submission.service'; import { ParticipationWebsocketService } from 'app/overview/participation-websocket.service'; -import { fileUploadExercise } from '../../mocks/service/mock-file-upload-exercise.service'; +import { fileUploadExercise } from '../../helpers/mocks/service/mock-file-upload-exercise.service'; import { MAX_SUBMISSION_FILE_SIZE } from 'app/shared/constants/input.constants'; import { TranslateModule } from '@ngx-translate/core'; import * as sinon from 'sinon'; diff --git a/src/test/javascript/spec/component/guided-tour/guided-tour.component.spec.ts b/src/test/javascript/spec/component/guided-tour/guided-tour.component.spec.ts index a50d4f06872f..cd711c1fcd83 100644 --- a/src/test/javascript/spec/component/guided-tour/guided-tour.component.spec.ts +++ b/src/test/javascript/spec/component/guided-tour/guided-tour.component.spec.ts @@ -8,8 +8,8 @@ import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { of } from 'rxjs'; import { TranslateService } from '@ngx-translate/core'; import { ArtemisTestModule } from '../../test.module'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; -import { MockCookieService } from '../../mocks/service/mock-cookie.service'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; +import { MockCookieService } from '../../helpers/mocks/service/mock-cookie.service'; import { TextTourStep } from 'app/guided-tour/guided-tour-step.model'; import { GuidedTour } from 'app/guided-tour/guided-tour.model'; import { GuidedTourComponent } from 'app/guided-tour/guided-tour.component'; @@ -18,7 +18,7 @@ import { Orientation, OverlayPosition, ResetParticipation } from 'app/guided-tou import { DeviceDetectorService } from 'ngx-device-detector'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { By } from '@angular/platform-browser'; -import { MockTranslateService } from '../../mocks/service/mock-translate.service'; +import { MockTranslateService } from '../../helpers/mocks/service/mock-translate.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/component/list-of-complaints/list-of-complaints.component.spec.ts b/src/test/javascript/spec/component/list-of-complaints/list-of-complaints.component.spec.ts index 1275e37a641e..4f69cdfde83c 100644 --- a/src/test/javascript/spec/component/list-of-complaints/list-of-complaints.component.spec.ts +++ b/src/test/javascript/spec/component/list-of-complaints/list-of-complaints.component.spec.ts @@ -5,11 +5,11 @@ import { ArtemisSharedModule } from 'app/shared/shared.module'; import { RouterTestingModule } from '@angular/router/testing'; import { SortByModule } from 'app/shared/pipes/sort-by.module'; import { AlertService } from 'app/core/alert/alert.service'; -import { MockAlertService } from '../../mocks/service/mock-alert.service'; +import { MockAlertService } from '../../helpers/mocks/service/mock-alert.service'; import { ComplaintService } from 'app/complaints/complaint.service'; import { DifferencePipe } from 'ngx-moment'; import { ActivatedRoute } from '@angular/router'; -import { MockActivatedRoute } from '../../mocks/service/mock-route.service'; +import { MockActivatedRoute } from '../../helpers/mocks/service/mock-route.service'; import { ListOfComplaintsComponent } from 'app/complaints/list-of-complaints/list-of-complaints.component'; describe('ListOfComplaintsComponent', () => { diff --git a/src/test/javascript/spec/component/modeling-assessment-editor/modeling-assessment-editor.component.spec.ts b/src/test/javascript/spec/component/modeling-assessment-editor/modeling-assessment-editor.component.spec.ts index dc8673a19bd9..8eac57e0b97d 100644 --- a/src/test/javascript/spec/component/modeling-assessment-editor/modeling-assessment-editor.component.spec.ts +++ b/src/test/javascript/spec/component/modeling-assessment-editor/modeling-assessment-editor.component.spec.ts @@ -3,7 +3,7 @@ import { TranslateModule } from '@ngx-translate/core'; import { ArtemisTestModule } from '../../test.module'; import { By } from '@angular/platform-browser'; -import { mockedActivatedRoute } from '../../mocks/activated-route/mock-activated-route-query-param-map'; +import { mockedActivatedRoute } from '../../helpers/mocks/activated-route/mock-activated-route-query-param-map'; import { ActivatedRoute, convertToParamMap, ParamMap } from '@angular/router'; import { Mutable } from '../../helpers/mutable'; import { BehaviorSubject } from 'rxjs'; @@ -11,7 +11,7 @@ import { RouterTestingModule } from '@angular/router/testing'; import { User } from 'app/core/user/user.model'; import { JhiLanguageHelper } from 'app/core/language/language.helper'; import { AccountService } from 'app/core/auth/account.service'; -import { MockAccountService } from '../../mocks/service/mock-account.service'; +import { MockAccountService } from '../../helpers/mocks/service/mock-account.service'; import { AssessmentLayoutComponent } from 'app/assessment/assessment-layout/assessment-layout.component'; import { AssessmentHeaderComponent } from 'app/assessment/assessment-header/assessment-header.component'; import { Course } from 'app/entities/course.model'; diff --git a/src/test/javascript/spec/component/modeling-submission/modeling-submission.component.spec.ts b/src/test/javascript/spec/component/modeling-submission/modeling-submission.component.spec.ts index 985da1286915..663f85915bba 100644 --- a/src/test/javascript/spec/component/modeling-submission/modeling-submission.component.spec.ts +++ b/src/test/javascript/spec/component/modeling-submission/modeling-submission.component.spec.ts @@ -6,9 +6,9 @@ import { ArtemisTestModule } from '../../test.module'; import { ModelingSubmissionComponent } from 'app/exercises/modeling/participate/modeling-submission.component'; import { ModelingSubmissionService } from 'app/exercises/modeling/participate/modeling-submission.service'; import { ModelingSubmission } from 'app/entities/modeling-submission.model'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; -import { MockParticipationWebsocketService } from '../../mocks/service/mock-participation-websocket.service'; -import { MockCookieService } from '../../mocks/service/mock-cookie.service'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; +import { MockParticipationWebsocketService } from '../../helpers/mocks/service/mock-participation-websocket.service'; +import { MockCookieService } from '../../helpers/mocks/service/mock-cookie.service'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { CookieService } from 'ngx-cookie-service'; import { TranslateModule } from '@ngx-translate/core'; @@ -19,8 +19,8 @@ import { DebugElement } from '@angular/core'; import { By } from '@angular/platform-browser'; import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; -import { MockAlertService } from '../../mocks/service/mock-alert.service'; -import { MockComplaintService } from '../../mocks/service/mock-complaint.service'; +import { MockAlertService } from '../../helpers/mocks/service/mock-alert.service'; +import { MockComplaintService } from '../../helpers/mocks/service/mock-complaint.service'; import { AlertService } from 'app/core/alert/alert.service'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { ArtemisSharedComponentModule } from 'app/shared/components/shared-component.module'; diff --git a/src/test/javascript/spec/component/overview/course-exercises/course-exercise-row.component.spec.ts b/src/test/javascript/spec/component/overview/course-exercises/course-exercise-row.component.spec.ts index a7a6fedb73e9..bc66fd772431 100644 --- a/src/test/javascript/spec/component/overview/course-exercises/course-exercise-row.component.spec.ts +++ b/src/test/javascript/spec/component/overview/course-exercises/course-exercise-row.component.spec.ts @@ -8,18 +8,18 @@ import { ParticipationWebsocketService } from 'app/overview/participation-websoc import { ArtemisTestModule } from '../../../test.module'; import { TranslateModule } from '@ngx-translate/core'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; -import { MockOrionConnectorService } from '../../../mocks/service/mock-orion-connector.service'; -import { MockCourseExerciseService } from '../../../mocks/service/mock-course-exercise.service'; +import { MockOrionConnectorService } from '../../../helpers/mocks/service/mock-orion-connector.service'; +import { MockCourseExerciseService } from '../../../helpers/mocks/service/mock-course-exercise.service'; import { AlertService } from 'app/core/alert/alert.service'; -import { MockAlertService } from '../../../mocks/service/mock-alert.service'; -import { MockParticipationWebsocketService } from '../../../mocks/service/mock-participation-websocket.service'; +import { MockAlertService } from '../../../helpers/mocks/service/mock-alert.service'; +import { MockParticipationWebsocketService } from '../../../helpers/mocks/service/mock-participation-websocket.service'; import { Result } from 'app/entities/result.model'; import { DeviceDetectorService } from 'ngx-device-detector'; import { of } from 'rxjs'; import { AccountService } from 'app/core/auth/account.service'; -import { MockAccountService } from '../../../mocks/service/mock-account.service'; +import { MockAccountService } from '../../../helpers/mocks/service/mock-account.service'; import * as moment from 'moment'; -import { MockCourseService } from '../../../mocks/service/mock-course.service'; +import { MockCourseService } from '../../../helpers/mocks/service/mock-course.service'; import { Exercise, ExerciseType, ParticipationStatus } from 'app/entities/exercise.model'; import { ArtemisCoursesModule } from 'app/overview/courses.module'; import { InitializationState } from 'app/entities/participation/participation.model'; @@ -28,7 +28,7 @@ import { CourseExerciseRowComponent } from 'app/overview/course-exercises/course import { QuizExercise } from 'app/entities/quiz/quiz-exercise.model'; import { CourseExerciseService, CourseManagementService } from 'app/course/manage/course-management.service'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; -import { MockSyncStorage } from '../../../mocks/service/mock-sync-storage.service'; +import { MockSyncStorage } from '../../../helpers/mocks/service/mock-sync-storage.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/component/overview/course-statistics/course-statistics.component.spec.ts b/src/test/javascript/spec/component/overview/course-statistics/course-statistics.component.spec.ts index 94b35f95b54f..22959ac32fbe 100644 --- a/src/test/javascript/spec/component/overview/course-statistics/course-statistics.component.spec.ts +++ b/src/test/javascript/spec/component/overview/course-statistics/course-statistics.component.spec.ts @@ -12,7 +12,7 @@ import { ArtemisSharedModule } from 'app/shared/shared.module'; import { ActivatedRoute } from '@angular/router'; import { By } from '@angular/platform-browser'; import { Course } from 'app/entities/course.model'; -import { MockSyncStorage } from '../../../mocks/service/mock-sync-storage.service'; +import { MockSyncStorage } from '../../../helpers/mocks/service/mock-sync-storage.service'; import { Result } from 'app/entities/result.model'; import { CourseScoreCalculationService } from 'app/overview/course-score-calculation.service'; import { ProgrammingSubmission } from 'app/entities/programming-submission.model'; diff --git a/src/test/javascript/spec/component/overview/exercise-details/exercise-details-student-actions.component.spec.ts b/src/test/javascript/spec/component/overview/exercise-details/exercise-details-student-actions.component.spec.ts index ecfcff4f39a9..789034c06448 100644 --- a/src/test/javascript/spec/component/overview/exercise-details/exercise-details-student-actions.component.spec.ts +++ b/src/test/javascript/spec/component/overview/exercise-details/exercise-details-student-actions.component.spec.ts @@ -13,25 +13,25 @@ import { MockComponent } from 'ng-mocks'; import { FeatureToggleModule } from 'app/shared/feature-toggle/feature-toggle.module'; import { FeatureToggleService } from 'app/shared/feature-toggle/feature-toggle.service'; import { InitializationState } from 'app/entities/participation/participation.model'; -import { MockFeatureToggleService } from '../../../mocks/service/mock-feature-toggle.service'; +import { MockFeatureToggleService } from '../../../helpers/mocks/service/mock-feature-toggle.service'; import { ExerciseMode, ExerciseType, ParticipationStatus } from 'app/entities/exercise.model'; -import { MockCourseExerciseService } from '../../../mocks/service/mock-course-exercise.service'; +import { MockCourseExerciseService } from '../../../helpers/mocks/service/mock-course-exercise.service'; import { ExerciseActionButtonComponent } from 'app/overview/exercise-details/exercise-action-button.component'; import { StudentParticipation } from 'app/entities/participation/student-participation.model'; import { ArtemisTestModule } from '../../../test.module'; import { JhiAlertService } from 'ng-jhipster'; -import { MockAlertService } from '../../../mocks/service/mock-alert.service'; +import { MockAlertService } from '../../../helpers/mocks/service/mock-alert.service'; import { ExerciseDetailsStudentActionsComponent } from 'app/overview/exercise-details/exercise-details-student-actions.component'; import { Team } from 'app/entities/team.model'; import { RouterModule } from '@angular/router'; import { ClipboardModule } from 'ngx-clipboard'; import { AccountService } from 'app/core/auth/account.service'; -import { MockAccountService } from '../../../mocks/service/mock-account.service'; +import { MockAccountService } from '../../../helpers/mocks/service/mock-account.service'; import { User } from 'app/core/user/user.model'; import { By } from '@angular/platform-browser'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; import { ProfileService } from 'app/shared/layouts/profiles/profile.service'; -import { MockProfileService } from '../../../mocks/service/mock-profile.service'; +import { MockProfileService } from '../../../helpers/mocks/service/mock-profile.service'; import { ProfileInfo } from 'app/shared/layouts/profiles/profile-info.model'; chai.use(sinonChai); diff --git a/src/test/javascript/spec/component/overview/exercise-details/programming-exercise-student-ide-actions.component.spec.ts b/src/test/javascript/spec/component/overview/exercise-details/programming-exercise-student-ide-actions.component.spec.ts index 69b127e1fb62..951f71975ad3 100644 --- a/src/test/javascript/spec/component/overview/exercise-details/programming-exercise-student-ide-actions.component.spec.ts +++ b/src/test/javascript/spec/component/overview/exercise-details/programming-exercise-student-ide-actions.component.spec.ts @@ -15,19 +15,19 @@ import { FeatureToggleModule } from 'app/shared/feature-toggle/feature-toggle.mo import { FeatureToggleService } from 'app/shared/feature-toggle/feature-toggle.service'; import { ProgrammingExerciseStudentIdeActionsComponent } from 'app/overview/exercise-details/programming-exercise-student-ide-actions.component'; import { InitializationState } from 'app/entities/participation/participation.model'; -import { MockFeatureToggleService } from '../../../mocks/service/mock-feature-toggle.service'; +import { MockFeatureToggleService } from '../../../helpers/mocks/service/mock-feature-toggle.service'; import { Exercise, ParticipationStatus } from 'app/entities/exercise.model'; -import { MockCourseExerciseService } from '../../../mocks/service/mock-course-exercise.service'; +import { MockCourseExerciseService } from '../../../helpers/mocks/service/mock-course-exercise.service'; import { ExerciseActionButtonComponent } from 'app/overview/exercise-details/exercise-action-button.component'; import { StudentParticipation } from 'app/entities/participation/student-participation.model'; import { ProgrammingExerciseStudentParticipation } from 'app/entities/participation/programming-exercise-student-participation.model'; import { ArtemisTestModule } from '../../../test.module'; import { JhiAlertService } from 'ng-jhipster'; -import { MockAlertService } from '../../../mocks/service/mock-alert.service'; -import { MockOrionConnectorService } from '../../../mocks/service/mock-orion-connector.service'; +import { MockAlertService } from '../../../helpers/mocks/service/mock-alert.service'; +import { MockOrionConnectorService } from '../../../helpers/mocks/service/mock-orion-connector.service'; import { ArtemisOrionConnector, OrionState } from 'app/shared/orion/orion'; import { OrionModule } from 'app/shared/orion/orion.module'; -import { MockIdeBuildAndTestService } from '../../../mocks/service/mock-ide-build-and-test.service'; +import { MockIdeBuildAndTestService } from '../../../helpers/mocks/service/mock-ide-build-and-test.service'; import { OrionBuildAndTestService } from 'app/shared/orion/orion-build-and-test.service'; chai.use(sinonChai); diff --git a/src/test/javascript/spec/component/overview/overview.component.spec.ts b/src/test/javascript/spec/component/overview/overview.component.spec.ts index 92d0373ae7f7..13a72e850674 100644 --- a/src/test/javascript/spec/component/overview/overview.component.spec.ts +++ b/src/test/javascript/spec/component/overview/overview.component.spec.ts @@ -8,20 +8,20 @@ import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { ArtemisTestModule } from '../../test.module'; import { GuidedTourService } from 'app/guided-tour/guided-tour.service'; import { GuidedTourComponent } from 'app/guided-tour/guided-tour.component'; -import { MockAccountService } from '../../mocks/service/mock-account.service'; +import { MockAccountService } from '../../helpers/mocks/service/mock-account.service'; import { AccountService } from 'app/core/auth/account.service'; import { DeviceDetectorService } from 'ngx-device-detector'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; -import { MockCookieService } from '../../mocks/service/mock-cookie.service'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; +import { MockCookieService } from '../../helpers/mocks/service/mock-cookie.service'; import { RouterTestingModule } from '@angular/router/testing'; import { courseOverviewTour } from 'app/guided-tour/tours/course-overview-tour'; import { CoursesComponent } from 'app/overview/courses.component'; -import { TranslateTestingModule } from '../../mocks/service/mock-translate.service'; +import { TranslateTestingModule } from '../../helpers/mocks/service/mock-translate.service'; import { NavbarComponent } from 'app/shared/layouts/navbar/navbar.component'; import { ActiveMenuDirective } from 'app/shared/layouts/navbar/active-menu.directive'; import { NotificationContainerComponent } from 'app/shared/layouts/notification-container/notification-container.component'; import { User } from 'app/core/user/user.model'; -import { MockHasAnyAuthorityDirective } from '../../mocks/directive/mock-has-any-authority.directive'; +import { MockHasAnyAuthorityDirective } from '../../helpers/mocks/directive/mock-has-any-authority.directive'; import { ArtemisSharedPipesModule } from 'app/shared/pipes/shared-pipes.module'; import { ArtemisSharedCommonModule } from 'app/shared/shared-common.module'; import { CourseCardComponent } from 'app/overview/course-card.component'; diff --git a/src/test/javascript/spec/component/participation-submission/participation-submission.component.spec.ts b/src/test/javascript/spec/component/participation-submission/participation-submission.component.spec.ts index 07a3885ff7a8..ac3d9dc336a4 100644 --- a/src/test/javascript/spec/component/participation-submission/participation-submission.component.spec.ts +++ b/src/test/javascript/spec/component/participation-submission/participation-submission.component.spec.ts @@ -6,10 +6,10 @@ import * as sinonChai from 'sinon-chai'; import * as moment from 'moment'; import { SinonStub, stub } from 'sinon'; import { ArtemisTestModule } from '../../test.module'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; import { MockComponent } from 'ng-mocks'; import { ArtemisSharedModule } from 'app/shared/shared.module'; -import { MockAlertService } from '../../mocks/service/mock-alert.service'; +import { MockAlertService } from '../../helpers/mocks/service/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; import { Router } from '@angular/router'; import { of } from 'rxjs'; @@ -18,12 +18,12 @@ import { ResizableInstructionsComponent } from 'app/exercises/text/assess/resiza import { AssessmentDetailComponent } from 'app/assessment/assessment-detail/assessment-detail.component'; import { DebugElement } from '@angular/core'; import { By } from '@angular/platform-browser'; -import { MockAccountService } from '../../mocks/service/mock-account.service'; +import { MockAccountService } from '../../helpers/mocks/service/mock-account.service'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { ComplaintService } from 'app/complaints/complaint.service'; import { ParticipationSubmissionComponent } from 'app/exercises/shared/participation-submission/participation-submission.component'; import { SubmissionService } from 'app/exercises/shared/submission/submission.service'; -import { MockComplaintService } from '../../mocks/service/mock-complaint.service'; +import { MockComplaintService } from '../../helpers/mocks/service/mock-complaint.service'; import { NgxDatatableModule } from '@swimlane/ngx-datatable'; import { TranslateModule } from '@ngx-translate/core'; import { ComplaintsForTutorComponent } from 'app/complaints/complaints-for-tutor/complaints-for-tutor.component'; diff --git a/src/test/javascript/spec/component/participation/participation.component.spec.ts b/src/test/javascript/spec/component/participation/participation.component.spec.ts index 185de1538f19..2ccef9e2af3d 100644 --- a/src/test/javascript/spec/component/participation/participation.component.spec.ts +++ b/src/test/javascript/spec/component/participation/participation.component.spec.ts @@ -5,8 +5,8 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { ArtemisTestModule } from '../../test.module'; import { ArtemisSharedModule } from 'app/shared/shared.module'; -import { MockActivatedRoute } from '../../mocks/activated-route/mock-activated.route'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockActivatedRoute } from '../../helpers/mocks/activated-route/mock-activated.route'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; import { ParticipationService } from 'app/exercises/shared/participation/participation.service'; import { ParticipationComponent } from 'app/exercises/shared/participation/participation.component'; import { Course } from 'app/entities/course.model'; diff --git a/src/test/javascript/spec/component/programming-assessment/programming-assessment-manual-result-dialog.component.spec.ts b/src/test/javascript/spec/component/programming-assessment/programming-assessment-manual-result-dialog.component.spec.ts index f0b7c40b3d96..f50b46a7dcbb 100644 --- a/src/test/javascript/spec/component/programming-assessment/programming-assessment-manual-result-dialog.component.spec.ts +++ b/src/test/javascript/spec/component/programming-assessment/programming-assessment-manual-result-dialog.component.spec.ts @@ -9,10 +9,10 @@ import { SinonStub, stub } from 'sinon'; import { of } from 'rxjs'; import { ArtemisTestModule } from '../../test.module'; import { ParticipationWebsocketService } from 'app/overview/participation-websocket.service'; -import { MockResultService } from '../../mocks/service/mock-result.service'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; -import { MockParticipationWebsocketService } from '../../mocks/service/mock-participation-websocket.service'; -import { MockProgrammingExerciseParticipationService } from '../../mocks/service/mock-programming-exercise-participation.service'; +import { MockResultService } from '../../helpers/mocks/service/mock-result.service'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; +import { MockParticipationWebsocketService } from '../../helpers/mocks/service/mock-participation-websocket.service'; +import { MockProgrammingExerciseParticipationService } from '../../helpers/mocks/service/mock-programming-exercise-participation.service'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { BuildLogService } from 'app/exercises/programming/shared/service/build-log.service'; import { FormDateTimePickerModule } from 'app/shared/date-time-picker/date-time-picker.module'; @@ -36,9 +36,9 @@ import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; import { Complaint } from 'app/entities/complaint.model'; import { ComplaintService } from 'app/complaints/complaint.service'; import { ExerciseHintService } from 'app/exercises/shared/exercise-hint/manage/exercise-hint.service'; -import { MockRepositoryFileService } from '../../mocks/service/mock-repository-file.service'; -import { MockExerciseHintService } from '../../mocks/service/mock-exercise-hint.service'; -import { MockNgbModalService } from '../../mocks/service/mock-ngb-modal.service'; +import { MockRepositoryFileService } from '../../helpers/mocks/service/mock-repository-file.service'; +import { MockExerciseHintService } from '../../helpers/mocks/service/mock-exercise-hint.service'; +import { MockNgbModalService } from '../../helpers/mocks/service/mock-ngb-modal.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-editable-instruction.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-editable-instruction.component.spec.ts index 27178b1f1c93..95ac84d4fb60 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-editable-instruction.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-editable-instruction.component.spec.ts @@ -10,12 +10,12 @@ import * as sinonChai from 'sinon-chai'; import { SinonSpy, SinonStub, spy, stub } from 'sinon'; import { ArtemisTestModule } from '../../test.module'; import { ParticipationWebsocketService } from 'app/overview/participation-websocket.service'; -import { MockResultService } from '../../mocks/service/mock-result.service'; -import { MockParticipationWebsocketService } from '../../mocks/service/mock-participation-websocket.service'; +import { MockResultService } from '../../helpers/mocks/service/mock-result.service'; +import { MockParticipationWebsocketService } from '../../helpers/mocks/service/mock-participation-websocket.service'; import { MarkdownEditorComponent } from 'app/shared/markdown-editor/markdown-editor.component'; -import { MockProgrammingExerciseTestCaseService } from '../../mocks/service/mock-programming-exercise-test-case.service'; +import { MockProgrammingExerciseTestCaseService } from '../../helpers/mocks/service/mock-programming-exercise-test-case.service'; import { ArtemisProgrammingExerciseInstructionsEditorModule } from 'app/exercises/programming/manage/instructions-editor/programming-exercise-instructions-editor.module'; -import { triggerChanges } from '../../utils/general.utils'; +import { triggerChanges } from '../../helpers/utils/general.utils'; import { Participation } from 'app/entities/participation/participation.model'; import { ResultService } from 'app/exercises/shared/result/result.service'; import { TemplateProgrammingExerciseParticipation } from 'app/entities/participation/template-programming-exercise-participation.model'; diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-import.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-import.component.spec.ts index 666cf5d4d90e..6dd05f4ffcce 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-import.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-import.component.spec.ts @@ -12,13 +12,13 @@ import { SortByModule } from 'app/shared/pipes/sort-by.module'; import { DifferencePipe } from 'ngx-moment'; import { FeatureToggleModule } from 'app/shared/feature-toggle/feature-toggle.module'; import { FeatureToggleService } from 'app/shared/feature-toggle/feature-toggle.service'; -import { MockFeatureToggleService } from '../../mocks/service/mock-feature-toggle.service'; +import { MockFeatureToggleService } from '../../helpers/mocks/service/mock-feature-toggle.service'; import { ProgrammingExerciseImportComponent } from 'app/exercises/programming/manage/programming-exercise-import.component'; import { ArtemisSharedCommonModule } from 'app/shared/shared-common.module'; import { ProgrammingExercise, ProgrammingLanguage } from 'app/entities/programming-exercise.model'; import { SearchResult } from 'app/shared/table/pageable-table'; import { ButtonComponent } from 'app/shared/components/button.component'; -import { MockProgrammingExercisePagingService } from '../../mocks/service/mock-programming-exercise-paging.service'; +import { MockProgrammingExercisePagingService } from '../../helpers/mocks/service/mock-programming-exercise-paging.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-analysis.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-analysis.component.spec.ts index 8f3c03e34197..bdd4092b7db1 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-analysis.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-analysis.component.spec.ts @@ -12,7 +12,7 @@ import { ArtemisProgrammingExerciseInstructionsEditorModule } from 'app/exercise import { ExerciseHint } from 'app/entities/exercise-hint.model'; import { TaskCommand } from 'app/shared/markdown-editor/domainCommands/programming-exercise/task.command'; import { HttpResponse } from '@angular/common/http'; -import { triggerChanges } from '../../utils/general.utils'; +import { triggerChanges } from '../../helpers/utils/general.utils'; import { ExerciseHintService, IExerciseHintService } from 'app/exercises/shared/exercise-hint/manage/exercise-hint.service'; import { ProgrammingExerciseInstructionAnalysisComponent } from 'app/exercises/programming/manage/instructions-editor/analysis/programming-exercise-instruction-analysis.component'; import { ProgrammingExerciseInstructionAnalysisService } from 'app/exercises/programming/manage/instructions-editor/analysis/programming-exercise-instruction-analysis.service'; diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-step-wizard.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-step-wizard.component.spec.ts index 11df73614022..5b06016db6de 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-step-wizard.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction-step-wizard.component.spec.ts @@ -9,7 +9,7 @@ import * as moment from 'moment'; import { ArtemisTestModule } from '../../test.module'; import { ProgrammingExerciseInstructionStepWizardComponent } from 'app/exercises/programming/shared/instructions-render/step-wizard/programming-exercise-instruction-step-wizard.component'; import { ProgrammingExerciseInstructionService } from 'app/exercises/programming/shared/instructions-render/service/programming-exercise-instruction.service'; -import { triggerChanges } from '../../utils/general.utils'; +import { triggerChanges } from '../../helpers/utils/general.utils'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { Task } from 'app/exercises/programming/shared/instructions-render/task/programming-exercise-task.model'; diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction.component.spec.ts index 7c6046bf76f9..3f91ab3650c6 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instruction.component.spec.ts @@ -12,18 +12,18 @@ import { Observable, of, Subject, Subscription, throwError } from 'rxjs'; import { FaIconComponent } from '@fortawesome/angular-fontawesome'; import { ArtemisTestModule } from '../../test.module'; import { ParticipationWebsocketService } from 'app/overview/participation-websocket.service'; -import { MockResultService } from '../../mocks/service/mock-result.service'; -import { MockRepositoryFileService } from '../../mocks/service/mock-repository-file.service'; -import { problemStatement, problemStatementBubbleSortFailsHtml, problemStatementBubbleSortNotExecutedHtml } from '../../sample/problemStatement.json'; -import { MockNgbModalService } from '../../mocks/service/mock-ngb-modal.service'; +import { MockResultService } from '../../helpers/mocks/service/mock-result.service'; +import { MockRepositoryFileService } from '../../helpers/mocks/service/mock-repository-file.service'; +import { problemStatement, problemStatementBubbleSortFailsHtml, problemStatementBubbleSortNotExecutedHtml } from '../../helpers/sample/problemStatement.json'; +import { MockNgbModalService } from '../../helpers/mocks/service/mock-ngb-modal.service'; import { ProgrammingExerciseInstructionStepWizardComponent } from 'app/exercises/programming/shared/instructions-render/step-wizard/programming-exercise-instruction-step-wizard.component'; import { ProgrammingExerciseInstructionService } from 'app/exercises/programming/shared/instructions-render/service/programming-exercise-instruction.service'; import { ProgrammingExerciseTaskExtensionWrapper } from 'app/exercises/programming/shared/instructions-render/extensions/programming-exercise-task.extension'; import { ProgrammingExercisePlantUmlExtensionWrapper } from 'app/exercises/programming/shared/instructions-render/extensions/programming-exercise-plant-uml.extension'; -import { MockProgrammingExerciseParticipationService } from '../../mocks/service/mock-programming-exercise-participation.service'; +import { MockProgrammingExerciseParticipationService } from '../../helpers/mocks/service/mock-programming-exercise-participation.service'; import { ExerciseHint } from 'app/entities/exercise-hint.model'; import { HttpResponse } from '@angular/common/http'; -import { triggerChanges } from '../../utils/general.utils'; +import { triggerChanges } from '../../helpers/utils/general.utils'; import { LocalStorageService } from 'ngx-webstorage'; import { Participation } from 'app/entities/participation/participation.model'; import { ExerciseHintService, IExerciseHintService } from 'app/exercises/shared/exercise-hint/manage/exercise-hint.service'; @@ -38,9 +38,9 @@ import { Feedback } from 'app/entities/feedback.model'; import { ProgrammingExerciseInstructionComponent } from 'app/exercises/programming/shared/instructions-render/programming-exercise-instruction.component'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; import { ResultDetailComponent } from 'app/shared/result/result-detail.component'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; -import { MockParticipationWebsocketService } from '../../mocks/service/mock-participation-websocket.service'; -import { MockExerciseHintService } from '../../mocks/service/mock-exercise-hint.service'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; +import { MockParticipationWebsocketService } from '../../helpers/mocks/service/mock-participation-websocket.service'; +import { MockExerciseHintService } from '../../helpers/mocks/service/mock-exercise-hint.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-status.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-status.component.spec.ts index 7ef95ae6d294..3c5e35a1d6b9 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-status.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-status.component.spec.ts @@ -8,12 +8,12 @@ import { ArtemisTestModule } from '../../test.module'; import { TranslateModule } from '@ngx-translate/core'; import { By } from '@angular/platform-browser'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; -import { MockCookieService } from '../../mocks/service/mock-cookie.service'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; +import { MockCookieService } from '../../helpers/mocks/service/mock-cookie.service'; import { SinonStub, stub } from 'sinon'; import { Result } from 'app/entities/result.model'; import { ParticipationWebsocketService } from 'app/overview/participation-websocket.service'; -import { triggerChanges } from '../../utils/general.utils'; +import { triggerChanges } from '../../helpers/utils/general.utils'; import { ProgrammingExerciseInstructorStatusComponent } from 'app/exercises/programming/manage/status/programming-exercise-instructor-status.component'; import { ProgrammingExerciseParticipationType } from 'app/entities/programming-exercise-participation.model'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-submission-state.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-submission-state.component.spec.ts index 5ded52f93320..eed64d301e40 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-submission-state.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-instructor-submission-state.component.spec.ts @@ -9,18 +9,18 @@ import { of, Subject } from 'rxjs'; import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; import { ArtemisTestModule } from '../../test.module'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; -import { MockParticipationWebsocketService } from '../../mocks/service/mock-participation-websocket.service'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; +import { MockParticipationWebsocketService } from '../../helpers/mocks/service/mock-participation-websocket.service'; import { ParticipationWebsocketService } from 'app/overview/participation-websocket.service'; import { Exercise } from 'app/entities/exercise.model'; import { ExerciseSubmissionState, ProgrammingSubmissionService, ProgrammingSubmissionState } from 'app/exercises/programming/participate/programming-submission.service'; import { ArtemisProgrammingExerciseActionsModule } from 'app/exercises/programming/shared/actions/programming-exercise-actions.module'; import { ProgrammingExerciseInstructorSubmissionStateComponent } from 'app/exercises/programming/shared/actions/programming-exercise-instructor-submission-state.component'; -import { triggerChanges } from '../../utils/general.utils'; +import { triggerChanges } from '../../helpers/utils/general.utils'; import { BuildRunState, ProgrammingBuildRunService } from 'app/exercises/programming/participate/programming-build-run.service'; -import { MockProgrammingBuildRunService } from '../../mocks/service/mock-programming-build-run.service'; +import { MockProgrammingBuildRunService } from '../../helpers/mocks/service/mock-programming-build-run.service'; import { FeatureToggleService } from 'app/shared/feature-toggle/feature-toggle.service'; -import { MockFeatureToggleService } from '../../mocks/service/mock-feature-toggle.service'; +import { MockFeatureToggleService } from '../../helpers/mocks/service/mock-feature-toggle.service'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; chai.use(sinonChai); diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-manage-test-cases.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-manage-test-cases.component.spec.ts index b0b575656c4a..54517de06b18 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-manage-test-cases.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-manage-test-cases.component.spec.ts @@ -13,25 +13,25 @@ import { AlertService } from 'app/core/alert/alert.service'; import * as chai from 'chai'; import { ArtemisTestModule } from '../../test.module'; import { TranslateModule } from '@ngx-translate/core'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; -import { MockProgrammingExerciseTestCaseService } from '../../mocks/service/mock-programming-exercise-test-case.service'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; +import { MockProgrammingExerciseTestCaseService } from '../../helpers/mocks/service/mock-programming-exercise-test-case.service'; import { ProgrammingExerciseTestCase } from 'app/entities/programming-exercise-test-case.model'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { ArtemisProgrammingExerciseTestCaseModule } from 'app/exercises/programming/manage/test-cases/programming-exercise-test-case.module'; -import { expectElementToBeDisabled, expectElementToBeEnabled, getElement } from '../../utils/general.utils'; +import { expectElementToBeDisabled, expectElementToBeEnabled, getElement } from '../../helpers/utils/general.utils'; import { ProgrammingExerciseWebsocketService } from 'app/exercises/programming/manage/services/programming-exercise-websocket.service'; -import { MockProgrammingExerciseWebsocketService } from '../../mocks/service/mock-programming-exercise-websocket.service'; +import { MockProgrammingExerciseWebsocketService } from '../../helpers/mocks/service/mock-programming-exercise-websocket.service'; import { ProgrammingBuildRunService } from 'app/exercises/programming/participate/programming-build-run.service'; -import { MockProgrammingBuildRunService } from '../../mocks/service/mock-programming-build-run.service'; +import { MockProgrammingBuildRunService } from '../../helpers/mocks/service/mock-programming-build-run.service'; import { FeatureToggleService } from 'app/shared/feature-toggle/feature-toggle.service'; -import { MockFeatureToggleService } from '../../mocks/service/mock-feature-toggle.service'; +import { MockFeatureToggleService } from '../../helpers/mocks/service/mock-feature-toggle.service'; import { EditableField, ProgrammingExerciseManageTestCasesComponent } from 'app/exercises/programming/manage/test-cases/programming-exercise-manage-test-cases.component'; import { ProgrammingExerciseService, ProgrammingExerciseTestCaseStateDTO } from 'app/exercises/programming/manage/services/programming-exercise.service'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; import { ProgrammingExerciseTestCaseService } from 'app/exercises/programming/manage/services/programming-exercise-test-case.service'; -import { MockActivatedRoute } from '../../mocks/activated-route/mock-activated.route'; -import { MockCookieService } from '../../mocks/service/mock-cookie.service'; -import { MockProgrammingExerciseService } from '../../mocks/service/mock-programming-exercise.service'; +import { MockActivatedRoute } from '../../helpers/mocks/activated-route/mock-activated.route'; +import { MockCookieService } from '../../helpers/mocks/service/mock-cookie.service'; +import { MockProgrammingExerciseService } from '../../helpers/mocks/service/mock-programming-exercise.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-trigger-build-button.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-trigger-build-button.component.spec.ts index 9a2a21ea29e8..745ab5569128 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-trigger-build-button.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-trigger-build-button.component.spec.ts @@ -12,15 +12,15 @@ import { of, Subject } from 'rxjs'; import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; import { ArtemisTestModule } from '../../test.module'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; -import { MockParticipationWebsocketService } from '../../mocks/service/mock-participation-websocket.service'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; +import { MockParticipationWebsocketService } from '../../helpers/mocks/service/mock-participation-websocket.service'; import { Result } from 'app/entities/result.model'; import { ParticipationWebsocketService } from 'app/overview/participation-websocket.service'; -import { MockAccountService } from '../../mocks/service/mock-account.service'; +import { MockAccountService } from '../../helpers/mocks/service/mock-account.service'; import { Exercise } from 'app/entities/exercise.model'; import { ProgrammingSubmissionService, ProgrammingSubmissionState, ProgrammingSubmissionStateObj } from 'app/exercises/programming/participate/programming-submission.service'; import { ArtemisProgrammingExerciseActionsModule } from 'app/exercises/programming/shared/actions/programming-exercise-actions.module'; -import { triggerChanges } from '../../utils/general.utils'; +import { triggerChanges } from '../../helpers/utils/general.utils'; import { InitializationState } from 'app/entities/participation/participation.model'; import { ProgrammingExerciseStudentTriggerBuildButtonComponent } from 'app/exercises/programming/shared/actions/programming-exercise-student-trigger-build-button.component'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise.component.spec.ts index c3d196e5f513..77ee0b9ad15b 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise.component.spec.ts @@ -5,16 +5,16 @@ import { of } from 'rxjs'; import { ArtemisTestModule } from '../../test.module'; import { ProgrammingExerciseComponent } from 'app/exercises/programming/manage/programming-exercise.component'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; -import { MockTranslateService } from '../../mocks/service/mock-translate.service'; +import { MockTranslateService } from '../../helpers/mocks/service/mock-translate.service'; import { TranslateService } from '@ngx-translate/core'; import { ActivatedRoute, convertToParamMap } from '@angular/router'; import { Course } from 'app/entities/course.model'; import { OrionConnectorService } from 'app/shared/orion/orion-connector.service'; -import { MockOrionConnectorService } from '../../mocks/service/mock-orion-connector.service'; +import { MockOrionConnectorService } from '../../helpers/mocks/service/mock-orion-connector.service'; import { CourseExerciseService } from 'app/course/manage/course-management.service'; -import { MockCourseExerciseService } from '../../mocks/service/mock-course-exercise.service'; +import { MockCourseExerciseService } from '../../helpers/mocks/service/mock-course-exercise.service'; describe('Component Tests', () => { describe('ProgrammingExercise Management Component', () => { diff --git a/src/test/javascript/spec/component/shared/alert-error.component.spec.ts b/src/test/javascript/spec/component/shared/alert-error.component.spec.ts index 4d7513f0d14d..e9cf8c58b9b1 100644 --- a/src/test/javascript/spec/component/shared/alert-error.component.spec.ts +++ b/src/test/javascript/spec/component/shared/alert-error.component.spec.ts @@ -5,7 +5,7 @@ import { TranslateModule } from '@ngx-translate/core'; import { ArtemisTestModule } from '../../test.module'; import { AlertErrorComponent } from 'app/shared/alert/alert-error.component'; -import { MockAlertService } from '../../mocks/service/mock-alert.service'; +import { MockAlertService } from '../../helpers/mocks/service/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; describe('Component Tests', () => { diff --git a/src/test/javascript/spec/component/shared/button.component.spec.ts b/src/test/javascript/spec/component/shared/button.component.spec.ts index 6b724ff5636e..22d8f2753512 100644 --- a/src/test/javascript/spec/component/shared/button.component.spec.ts +++ b/src/test/javascript/spec/component/shared/button.component.spec.ts @@ -9,9 +9,9 @@ import * as sinonChai from 'sinon-chai'; import { ArtemisTestModule } from '../../test.module'; import { ArtemisSharedComponentModule } from 'app/shared/components/shared-component.module'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; import { FeatureToggleService } from 'app/shared/feature-toggle/feature-toggle.service'; -import { MockFeatureToggleService } from '../../mocks/service/mock-feature-toggle.service'; +import { MockFeatureToggleService } from '../../helpers/mocks/service/mock-feature-toggle.service'; import { ButtonComponent } from 'app/shared/components/button.component'; chai.use(sinonChai); diff --git a/src/test/javascript/spec/component/shared/secured-image.component.spec.ts b/src/test/javascript/spec/component/shared/secured-image.component.spec.ts index d6710b8a57fc..2ee8f7d43e9e 100644 --- a/src/test/javascript/spec/component/shared/secured-image.component.spec.ts +++ b/src/test/javascript/spec/component/shared/secured-image.component.spec.ts @@ -7,8 +7,8 @@ import { SinonStub, stub } from 'sinon'; import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; import { ArtemisTestModule } from '../../test.module'; -import { MockCacheableImageService } from '../../mocks/service/mock-cacheable-image.service'; -import { triggerChanges } from '../../utils/general.utils'; +import { MockCacheableImageService } from '../../helpers/mocks/service/mock-cacheable-image.service'; +import { triggerChanges } from '../../helpers/utils/general.utils'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { UpdatingResultComponent } from 'app/shared/result/updating-result.component'; import { CachingStrategy, ImageLoadingStatus, SecuredImageComponent } from 'app/shared/image/secured-image.component'; diff --git a/src/test/javascript/spec/component/shared/updating-result.component.spec.ts b/src/test/javascript/spec/component/shared/updating-result.component.spec.ts index 11b5291f2961..b8b6d05b885b 100644 --- a/src/test/javascript/spec/component/shared/updating-result.component.spec.ts +++ b/src/test/javascript/spec/component/shared/updating-result.component.spec.ts @@ -14,17 +14,17 @@ import * as sinonChai from 'sinon-chai'; import { ArtemisTestModule } from '../../test.module'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { ParticipationWebsocketService } from 'app/overview/participation-websocket.service'; -import { MockAccountService } from '../../mocks/service/mock-account.service'; +import { MockAccountService } from '../../helpers/mocks/service/mock-account.service'; import { ProgrammingSubmissionService, ProgrammingSubmissionState } from 'app/exercises/programming/participate/programming-submission.service'; -import { MockProgrammingSubmissionService } from '../../mocks/service/mock-programming-submission.service'; -import { triggerChanges } from '../../utils/general.utils'; +import { MockProgrammingSubmissionService } from '../../helpers/mocks/service/mock-programming-submission.service'; +import { triggerChanges } from '../../helpers/utils/general.utils'; import { Exercise, ExerciseType } from 'app/entities/exercise.model'; import { UpdatingResultComponent } from 'app/shared/result/updating-result.component'; import { ResultComponent } from 'app/shared/result/result.component'; import { CodeEditorFileService } from 'app/exercises/programming/shared/code-editor/service/code-editor-file.service'; import { Result } from 'app/entities/result.model'; -import { MockParticipationWebsocketService } from '../../mocks/service/mock-participation-websocket.service'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockParticipationWebsocketService } from '../../helpers/mocks/service/mock-participation-websocket.service'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/component/student-questions/student-questions.component.spec.ts b/src/test/javascript/spec/component/student-questions/student-questions.component.spec.ts index 7a11c6770c4e..0ce6678509b3 100644 --- a/src/test/javascript/spec/component/student-questions/student-questions.component.spec.ts +++ b/src/test/javascript/spec/component/student-questions/student-questions.component.spec.ts @@ -3,7 +3,7 @@ import * as sinonChai from 'sinon-chai'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { TranslateModule } from '@ngx-translate/core'; import { AccountService } from 'app/core/auth/account.service'; -import { MockAccountService } from '../../mocks/service/mock-account.service'; +import { MockAccountService } from '../../helpers/mocks/service/mock-account.service'; import { StudentQuestionsComponent } from 'app/overview/student-questions/student-questions.component'; import { Lecture } from 'app/entities/lecture.model'; import { StudentQuestionAnswer } from 'app/entities/student-question-answer.model'; diff --git a/src/test/javascript/spec/component/table/table-editable-field.component.spec.ts b/src/test/javascript/spec/component/table/table-editable-field.component.spec.ts index 9eeb91eb0efe..67d422a797c8 100644 --- a/src/test/javascript/spec/component/table/table-editable-field.component.spec.ts +++ b/src/test/javascript/spec/component/table/table-editable-field.component.spec.ts @@ -5,7 +5,7 @@ import { DebugElement } from '@angular/core'; import * as chai from 'chai'; import { ArtemisTestModule } from '../../test.module'; import { ArtemisTableModule } from 'app/shared/table/table.module'; -import { triggerChanges } from '../../utils/general.utils'; +import { triggerChanges } from '../../helpers/utils/general.utils'; import { TableEditableFieldComponent } from 'app/shared/table/table-editable-field.component'; const expect = chai.expect; diff --git a/src/test/javascript/spec/component/team/team-update-dialog.component.spec.ts b/src/test/javascript/spec/component/team/team-update-dialog.component.spec.ts index 61145c2d93a2..2890c50b5973 100644 --- a/src/test/javascript/spec/component/team/team-update-dialog.component.spec.ts +++ b/src/test/javascript/spec/component/team/team-update-dialog.component.spec.ts @@ -11,13 +11,13 @@ import { FormsModule } from '@angular/forms'; import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap'; import * as sinon from 'sinon'; import { AlertService } from 'app/core/alert/alert.service'; -import { MockAlertService } from '../../mocks/service/mock-alert.service'; +import { MockAlertService } from '../../helpers/mocks/service/mock-alert.service'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { ArtemisSharedComponentModule } from 'app/shared/components/shared-component.module'; import { ArtemisTeamModule } from 'app/exercises/shared/team/team.module'; -import { mockEmptyTeam, mockExercise, mockNonTeamStudents, mockTeam, MockTeamService, mockTeamStudents } from '../../mocks/service/mock-team.service'; +import { mockEmptyTeam, mockExercise, mockNonTeamStudents, mockTeam, MockTeamService, mockTeamStudents } from '../../helpers/mocks/service/mock-team.service'; import { TeamService } from 'app/exercises/shared/team/team.service'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; chai.use(sinonChai); diff --git a/src/test/javascript/spec/component/team/teams.component.spec.ts b/src/test/javascript/spec/component/team/teams.component.spec.ts index ce8cfbbc7faf..c56e132ec4f0 100644 --- a/src/test/javascript/spec/component/team/teams.component.spec.ts +++ b/src/test/javascript/spec/component/team/teams.component.spec.ts @@ -9,7 +9,7 @@ import { JhiEventManager, NgJhipsterModule } from 'ng-jhipster'; import { FormsModule } from '@angular/forms'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { AlertService } from 'app/core/alert/alert.service'; -import { MockAlertService } from '../../mocks/service/mock-alert.service'; +import { MockAlertService } from '../../helpers/mocks/service/mock-alert.service'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { ArtemisSharedComponentModule } from 'app/shared/components/shared-component.module'; import { ArtemisTeamModule } from 'app/exercises/shared/team/team.module'; @@ -21,19 +21,19 @@ import { DifferencePipe } from 'ngx-moment'; import { SortByPipe } from 'app/shared/pipes/sort-by.pipe'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { CookieService } from 'ngx-cookie-service'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; -import { MockCookieService } from '../../mocks/service/mock-cookie.service'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; +import { MockCookieService } from '../../helpers/mocks/service/mock-cookie.service'; import { ActivatedRoute } from '@angular/router'; import { of } from 'rxjs'; -import { mockTeams, MockTeamService } from '../../mocks/service/mock-team.service'; -import { MockExerciseService } from '../../mocks/service/mock-exercise.service'; +import { mockTeams, MockTeamService } from '../../helpers/mocks/service/mock-team.service'; +import { MockExerciseService } from '../../helpers/mocks/service/mock-exercise.service'; import { teamRoute } from 'app/exercises/shared/team/team.route.ts'; import { RouterTestingModule } from '@angular/router/testing'; import { Router } from '@angular/router'; import { ParticipationService } from 'app/exercises/shared/participation/participation.service'; -import { MockParticipationService } from '../../mocks/service/mock-participation.service'; +import { MockParticipationService } from '../../helpers/mocks/service/mock-participation.service'; import { AccountService } from 'app/core/auth/account.service'; -import { MockAccountService } from '../../mocks/service/mock-account.service'; +import { MockAccountService } from '../../helpers/mocks/service/mock-account.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/component/text-editor/text-editor.component.spec.ts b/src/test/javascript/spec/component/text-editor/text-editor.component.spec.ts index cdce95a0f8fb..b862d6a54ed8 100644 --- a/src/test/javascript/spec/component/text-editor/text-editor.component.spec.ts +++ b/src/test/javascript/spec/component/text-editor/text-editor.component.spec.ts @@ -6,7 +6,7 @@ import { ComponentFixture, fakeAsync, TestBed, tick, flush } from '@angular/core import { AlertService } from 'app/core/alert/alert.service'; import { ArtemisTestModule } from '../../test.module'; import { TranslateModule } from '@ngx-translate/core'; -import { MockTextEditorService } from '../../mocks/service/mock-text-editor.service'; +import { MockTextEditorService } from '../../helpers/mocks/service/mock-text-editor.service'; import { SinonStub, stub } from 'sinon'; import * as sinonChai from 'sinon-chai'; import { TextEditorService } from 'app/exercises/text/participate/text-editor.service'; @@ -14,7 +14,7 @@ import { BehaviorSubject } from 'rxjs'; import { ArtemisSharedModule } from 'app/shared/shared.module'; import { RouterTestingModule } from '@angular/router/testing'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; import { MockComponent } from 'ng-mocks'; import { TextResultComponent } from 'app/exercises/text/participate/text-result/text-result.component'; import { ComplaintInteractionsComponent } from 'app/complaints/complaint-interactions.component'; diff --git a/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.component.spec.ts b/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.component.spec.ts index f15a02511955..1cd90715c4f1 100644 --- a/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.component.spec.ts +++ b/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.component.spec.ts @@ -7,11 +7,11 @@ import * as sinonChai from 'sinon-chai'; import * as moment from 'moment'; import { SinonStub, stub } from 'sinon'; import { ArtemisTestModule } from '../../test.module'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; import { Result } from 'app/entities/result.model'; import { MockComponent } from 'ng-mocks'; import { ArtemisSharedModule } from 'app/shared/shared.module'; -import { MockAlertService } from '../../mocks/service/mock-alert.service'; +import { MockAlertService } from '../../helpers/mocks/service/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; import { ActivatedRoute, Router } from '@angular/router'; import { of, throwError } from 'rxjs'; @@ -21,11 +21,11 @@ import { ResizableInstructionsComponent } from 'app/exercises/text/assess/resiza import { AssessmentDetailComponent } from 'app/assessment/assessment-detail/assessment-detail.component'; import { DebugElement } from '@angular/core'; import { By } from '@angular/platform-browser'; -import { MockAccountService } from '../../mocks/service/mock-account.service'; +import { MockAccountService } from '../../helpers/mocks/service/mock-account.service'; import { textAssessmentRoutes } from 'app/exercises/text/assess/text-assessment.route'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { ComplaintService } from 'app/complaints/complaint.service'; -import { MockComplaintResponse, MockComplaintService } from '../../mocks/service/mock-complaint.service'; +import { MockComplaintResponse, MockComplaintService } from '../../helpers/mocks/service/mock-complaint.service'; import { TranslateModule } from '@ngx-translate/core'; import { TextSubmissionService } from 'app/exercises/text/participate/text-submission.service'; import { ComplaintsForTutorComponent } from 'app/complaints/complaints-for-tutor/complaints-for-tutor.component'; @@ -36,7 +36,7 @@ import { Exercise, ExerciseType } from 'app/entities/exercise.model'; import { TextSubmission } from 'app/entities/text-submission.model'; import { Participation, ParticipationType } from 'app/entities/participation/participation.model'; import { AssessmentType } from 'app/entities/assessment-type.model'; -import { MockActivatedRoute } from '../../mocks/activated-route/mock-activated-route'; +import { MockActivatedRoute } from '../../helpers/mocks/activated-route/mock-activated-route'; import { TextAssessmentsService } from 'app/exercises/text/assess/text-assessments.service'; import { Course } from 'app/entities/course.model'; import { Feedback } from 'app/entities/feedback.model'; diff --git a/src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.component.spec.ts b/src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.component.spec.ts index 360e4fc0b905..a1b769690d19 100644 --- a/src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.component.spec.ts +++ b/src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.component.spec.ts @@ -4,14 +4,14 @@ import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; import { SinonStub, stub } from 'sinon'; import { ArtemisTestModule } from '../../test.module'; -import { MockActivatedRoute } from '../../mocks/activated-route/mock-activated.route'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockActivatedRoute } from '../../helpers/mocks/activated-route/mock-activated.route'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; import { MockComponent } from 'ng-mocks'; import { ArtemisSharedModule } from 'app/shared/shared.module'; -import { MockAlertService } from '../../mocks/service/mock-alert.service'; +import { MockAlertService } from '../../helpers/mocks/service/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; import { ActivatedRoute, Router, RouterModule } from '@angular/router'; -import { MockRouter } from '../../mocks/service/mock-router.service'; +import { MockRouter } from '../../helpers/mocks/service/mock-router.service'; import { of, throwError } from 'rxjs'; import { HttpErrorResponse } from '@angular/common/http'; import { SidePanelComponent } from 'app/shared/side-panel/side-panel.component'; diff --git a/src/test/javascript/spec/component/tutor-dashboard/tutor-participation-graph.component.spec.ts b/src/test/javascript/spec/component/tutor-dashboard/tutor-participation-graph.component.spec.ts index f083a5914696..baee7d3bed7e 100644 --- a/src/test/javascript/spec/component/tutor-dashboard/tutor-participation-graph.component.spec.ts +++ b/src/test/javascript/spec/component/tutor-dashboard/tutor-participation-graph.component.spec.ts @@ -4,7 +4,7 @@ import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; import { ArtemisTestModule } from '../../test.module'; import { ArtemisSharedModule } from 'app/shared/shared.module'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; import { TranslateModule } from '@ngx-translate/core'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { TutorParticipationGraphComponent } from 'app/shared/dashboards/tutor-participation-graph/tutor-participation-graph.component'; diff --git a/src/test/javascript/spec/directive/programming-exercise/build-plan-link.directive.spec.ts b/src/test/javascript/spec/directive/build-plan-link.directive.spec.ts similarity index 95% rename from src/test/javascript/spec/directive/programming-exercise/build-plan-link.directive.spec.ts rename to src/test/javascript/spec/directive/build-plan-link.directive.spec.ts index 0e31355313c2..52c5fe0bb4bb 100644 --- a/src/test/javascript/spec/directive/programming-exercise/build-plan-link.directive.spec.ts +++ b/src/test/javascript/spec/directive/build-plan-link.directive.spec.ts @@ -3,10 +3,10 @@ import * as sinonChai from 'sinon-chai'; import { SinonStub, stub } from 'sinon'; import { Component, DebugElement } from '@angular/core'; import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; -import { ArtemisTestModule } from '../../test.module'; +import { ArtemisTestModule } from '../test.module'; import { ProgrammingExerciseUtilsModule } from 'app/exercises/programming/shared/utils/programming-exercise-utils.module'; import { ProfileService } from 'app/shared/layouts/profiles/profile.service'; -import { MockProfileService } from '../../mocks/service/mock-profile.service'; +import { MockProfileService } from '../helpers/mocks/service/mock-profile.service'; import { BehaviorSubject } from 'rxjs'; import { ProfileInfo } from 'app/shared/layouts/profiles/profile-info.model'; import { By } from '@angular/platform-browser'; diff --git a/src/test/javascript/spec/directive/shared/delete-dialog.directive.spec.ts b/src/test/javascript/spec/directive/delete-dialog.directive.spec.ts similarity index 98% rename from src/test/javascript/spec/directive/shared/delete-dialog.directive.spec.ts rename to src/test/javascript/spec/directive/delete-dialog.directive.spec.ts index 91e206f24ec9..04bb48c5e433 100644 --- a/src/test/javascript/spec/directive/shared/delete-dialog.directive.spec.ts +++ b/src/test/javascript/spec/directive/delete-dialog.directive.spec.ts @@ -3,7 +3,7 @@ import { TranslateModule, TranslateService } from '@ngx-translate/core'; import { Component, DebugElement } from '@angular/core'; import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; -import { ArtemisTestModule } from '../../test.module'; +import { ArtemisTestModule } from '../test.module'; import { By } from '@angular/platform-browser'; import { JhiLanguageHelper } from 'app/core/language/language.helper'; import { JhiAlertService, NgJhipsterModule } from 'ng-jhipster'; diff --git a/src/test/javascript/spec/mocks/activated-route/mock-activated-route-query-param-map.ts b/src/test/javascript/spec/helpers/mocks/activated-route/mock-activated-route-query-param-map.ts similarity index 100% rename from src/test/javascript/spec/mocks/activated-route/mock-activated-route-query-param-map.ts rename to src/test/javascript/spec/helpers/mocks/activated-route/mock-activated-route-query-param-map.ts diff --git a/src/test/javascript/spec/mocks/activated-route/mock-activated-route-snapshot.ts b/src/test/javascript/spec/helpers/mocks/activated-route/mock-activated-route-snapshot.ts similarity index 100% rename from src/test/javascript/spec/mocks/activated-route/mock-activated-route-snapshot.ts rename to src/test/javascript/spec/helpers/mocks/activated-route/mock-activated-route-snapshot.ts diff --git a/src/test/javascript/spec/mocks/activated-route/mock-activated-route.ts b/src/test/javascript/spec/helpers/mocks/activated-route/mock-activated-route.ts similarity index 100% rename from src/test/javascript/spec/mocks/activated-route/mock-activated-route.ts rename to src/test/javascript/spec/helpers/mocks/activated-route/mock-activated-route.ts diff --git a/src/test/javascript/spec/mocks/activated-route/mock-activated.route.ts b/src/test/javascript/spec/helpers/mocks/activated-route/mock-activated.route.ts similarity index 100% rename from src/test/javascript/spec/mocks/activated-route/mock-activated.route.ts rename to src/test/javascript/spec/helpers/mocks/activated-route/mock-activated.route.ts diff --git a/src/test/javascript/spec/mocks/directive/mock-has-any-authority.directive.ts b/src/test/javascript/spec/helpers/mocks/directive/mock-has-any-authority.directive.ts similarity index 100% rename from src/test/javascript/spec/mocks/directive/mock-has-any-authority.directive.ts rename to src/test/javascript/spec/helpers/mocks/directive/mock-has-any-authority.directive.ts diff --git a/src/test/javascript/spec/mocks/service/mock-account.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-account.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-account.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-account.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-active-modal.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-active-modal.service.ts similarity index 84% rename from src/test/javascript/spec/mocks/service/mock-active-modal.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-active-modal.service.ts index f9374458478e..adcccbc9bc09 100644 --- a/src/test/javascript/spec/mocks/service/mock-active-modal.service.ts +++ b/src/test/javascript/spec/helpers/mocks/service/mock-active-modal.service.ts @@ -1,4 +1,4 @@ -import { SpyObject } from '../../helpers/spyobject'; +import { SpyObject } from '../../spyobject'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import Spy = jasmine.Spy; diff --git a/src/test/javascript/spec/mocks/service/mock-alert.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-alert.service.ts similarity index 84% rename from src/test/javascript/spec/mocks/service/mock-alert.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-alert.service.ts index f423645deeea..3d1b926c21bb 100644 --- a/src/test/javascript/spec/mocks/service/mock-alert.service.ts +++ b/src/test/javascript/spec/helpers/mocks/service/mock-alert.service.ts @@ -1,4 +1,4 @@ -import { SpyObject } from '../../helpers/spyobject'; +import { SpyObject } from '../../spyobject'; import { JhiAlert, JhiAlertService } from 'ng-jhipster'; export class MockAlertService extends SpyObject { diff --git a/src/test/javascript/spec/mocks/service/mock-auth-server-provider.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-auth-server-provider.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-auth-server-provider.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-auth-server-provider.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-cacheable-image.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-cacheable-image.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-cacheable-image.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-cacheable-image.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-code-editor-build-log.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-code-editor-build-log.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-code-editor-build-log.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-code-editor-build-log.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-code-editor-conflict-state.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-code-editor-conflict-state.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-code-editor-conflict-state.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-code-editor-conflict-state.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-code-editor-grid.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-code-editor-grid.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-code-editor-grid.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-code-editor-grid.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-code-editor-repository-file.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-code-editor-repository-file.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-code-editor-repository-file.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-code-editor-repository-file.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-code-editor-repository.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-code-editor-repository.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-code-editor-repository.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-code-editor-repository.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-code-editor-session.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-code-editor-session.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-code-editor-session.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-code-editor-session.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-complaint.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-complaint.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-complaint.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-complaint.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-cookie.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-cookie.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-cookie.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-cookie.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-course-exercise.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-course-exercise.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-course-exercise.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-course-exercise.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-course.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-course.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-course.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-course.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-event-manager.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-event-manager.service.ts similarity index 83% rename from src/test/javascript/spec/mocks/service/mock-event-manager.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-event-manager.service.ts index a894b9b3554e..7d9c1611c498 100644 --- a/src/test/javascript/spec/mocks/service/mock-event-manager.service.ts +++ b/src/test/javascript/spec/helpers/mocks/service/mock-event-manager.service.ts @@ -1,4 +1,4 @@ -import { SpyObject } from '../../helpers/spyobject'; +import { SpyObject } from '../../spyobject'; import { JhiEventManager } from 'ng-jhipster'; import Spy = jasmine.Spy; diff --git a/src/test/javascript/spec/mocks/service/mock-exercise-hint.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-exercise-hint.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-exercise-hint.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-exercise-hint.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-exercise.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-exercise.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-exercise.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-exercise.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-feature-toggle.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-feature-toggle.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-feature-toggle.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-feature-toggle.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-file-upload-exercise.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-file-upload-exercise.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-file-upload-exercise.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-file-upload-exercise.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-file-upload-submission.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-file-upload-submission.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-file-upload-submission.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-file-upload-submission.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-http.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-http.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-http.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-http.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-ide-build-and-test.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-ide-build-and-test.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-ide-build-and-test.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-ide-build-and-test.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-language.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-language.service.ts similarity index 95% rename from src/test/javascript/spec/mocks/service/mock-language.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-language.service.ts index e69e10fdc458..9cea996c7498 100644 --- a/src/test/javascript/spec/mocks/service/mock-language.service.ts +++ b/src/test/javascript/spec/helpers/mocks/service/mock-language.service.ts @@ -1,4 +1,4 @@ -import { SpyObject } from '../../helpers/spyobject'; +import { SpyObject } from '../../spyobject'; import { JhiLanguageService } from 'ng-jhipster'; import { JhiLanguageHelper } from 'app/core/language/language.helper'; import { of } from 'rxjs'; diff --git a/src/test/javascript/spec/mocks/service/mock-login.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-login.service.ts similarity index 93% rename from src/test/javascript/spec/mocks/service/mock-login.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-login.service.ts index 9d8da622b95e..94f5706b636b 100644 --- a/src/test/javascript/spec/mocks/service/mock-login.service.ts +++ b/src/test/javascript/spec/helpers/mocks/service/mock-login.service.ts @@ -1,4 +1,4 @@ -import { SpyObject } from '../../helpers/spyobject'; +import { SpyObject } from '../../spyobject'; import { LoginService } from 'app/core/login/login.service'; import Spy = jasmine.Spy; diff --git a/src/test/javascript/spec/mocks/service/mock-ngb-modal.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-ngb-modal.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-ngb-modal.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-ngb-modal.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-notification.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-notification.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-notification.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-notification.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-orion-connector.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-orion-connector.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-orion-connector.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-orion-connector.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-participation-websocket.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-participation-websocket.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-participation-websocket.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-participation-websocket.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-participation.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-participation.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-participation.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-participation.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-principal.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-principal.service.ts similarity index 89% rename from src/test/javascript/spec/mocks/service/mock-principal.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-principal.service.ts index 6496e04ea475..e319bed856cb 100644 --- a/src/test/javascript/spec/mocks/service/mock-principal.service.ts +++ b/src/test/javascript/spec/helpers/mocks/service/mock-principal.service.ts @@ -1,4 +1,4 @@ -import { SpyObject } from '../../helpers/spyobject'; +import { SpyObject } from '../../spyobject'; import { Principal } from 'app/core/auth/principal.service'; import Spy = jasmine.Spy; diff --git a/src/test/javascript/spec/mocks/service/mock-profile.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-profile.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-profile.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-profile.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-programming-build-run.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-programming-build-run.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-programming-build-run.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-programming-build-run.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-programming-exercise-paging.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-programming-exercise-paging.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-programming-exercise-paging.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-programming-exercise-paging.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-programming-exercise-participation.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-programming-exercise-participation.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-programming-exercise-participation.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-programming-exercise-participation.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-programming-exercise-test-case.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-programming-exercise-test-case.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-programming-exercise-test-case.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-programming-exercise-test-case.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-programming-exercise-websocket.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-programming-exercise-websocket.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-programming-exercise-websocket.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-programming-exercise-websocket.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-programming-exercise.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-programming-exercise.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-programming-exercise.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-programming-exercise.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-programming-submission.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-programming-submission.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-programming-submission.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-programming-submission.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-repository-file.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-repository-file.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-repository-file.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-repository-file.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-result.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-result.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-result.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-result.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-route.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-route.service.ts similarity index 92% rename from src/test/javascript/spec/mocks/service/mock-route.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-route.service.ts index 7668eea1dcfe..d9d65dcb8e82 100644 --- a/src/test/javascript/spec/mocks/service/mock-route.service.ts +++ b/src/test/javascript/spec/helpers/mocks/service/mock-route.service.ts @@ -1,5 +1,5 @@ import { ActivatedRoute, Router } from '@angular/router'; -import { SpyObject } from '../../helpers/spyobject'; +import { SpyObject } from '../../spyobject'; import { of } from 'rxjs'; import Spy = jasmine.Spy; diff --git a/src/test/javascript/spec/mocks/service/mock-router.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-router.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-router.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-router.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-state-storage.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-state-storage.service.ts similarity index 90% rename from src/test/javascript/spec/mocks/service/mock-state-storage.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-state-storage.service.ts index a28bdbd49959..eaf076ae773b 100644 --- a/src/test/javascript/spec/mocks/service/mock-state-storage.service.ts +++ b/src/test/javascript/spec/helpers/mocks/service/mock-state-storage.service.ts @@ -1,4 +1,4 @@ -import { SpyObject } from '../../helpers/spyobject'; +import { SpyObject } from '../../spyobject'; import { StateStorageService } from 'app/core/auth/state-storage.service'; import Spy = jasmine.Spy; diff --git a/src/test/javascript/spec/mocks/service/mock-sync-storage.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-sync-storage.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-sync-storage.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-sync-storage.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-team.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-team.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-team.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-team.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-text-editor.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-text-editor.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-text-editor.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-text-editor.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-tracker.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-tracker.service.ts similarity index 79% rename from src/test/javascript/spec/mocks/service/mock-tracker.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-tracker.service.ts index 03b8a44a04b5..04b89d853e35 100644 --- a/src/test/javascript/spec/mocks/service/mock-tracker.service.ts +++ b/src/test/javascript/spec/helpers/mocks/service/mock-tracker.service.ts @@ -1,4 +1,4 @@ -import { SpyObject } from '../../helpers/spyobject'; +import { SpyObject } from '../../spyobject'; import { JhiTrackerService } from 'app/core/tracker/tracker.service'; export class MockTrackerService extends SpyObject { diff --git a/src/test/javascript/spec/mocks/service/mock-translate.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-translate.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-translate.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-translate.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-user.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-user.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-user.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-user.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-websocket.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-websocket.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-websocket.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-websocket.service.ts diff --git a/src/test/javascript/spec/mocks/service/mock-window.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-window.service.ts similarity index 100% rename from src/test/javascript/spec/mocks/service/mock-window.service.ts rename to src/test/javascript/spec/helpers/mocks/service/mock-window.service.ts diff --git a/src/test/javascript/spec/sample/build-logs.ts b/src/test/javascript/spec/helpers/sample/build-logs.ts similarity index 100% rename from src/test/javascript/spec/sample/build-logs.ts rename to src/test/javascript/spec/helpers/sample/build-logs.ts diff --git a/src/test/javascript/spec/sample/problemStatement.json b/src/test/javascript/spec/helpers/sample/problemStatement.json similarity index 100% rename from src/test/javascript/spec/sample/problemStatement.json rename to src/test/javascript/spec/helpers/sample/problemStatement.json diff --git a/src/test/javascript/spec/utils/general.utils.ts b/src/test/javascript/spec/helpers/utils/general.utils.ts similarity index 100% rename from src/test/javascript/spec/utils/general.utils.ts rename to src/test/javascript/spec/helpers/utils/general.utils.ts diff --git a/src/test/javascript/spec/integration/code-editor/code-editor-instructor.integration.spec.ts b/src/test/javascript/spec/integration/code-editor/code-editor-instructor.integration.spec.ts index d573b66d28af..b33412e48d91 100644 --- a/src/test/javascript/spec/integration/code-editor/code-editor-instructor.integration.spec.ts +++ b/src/test/javascript/spec/integration/code-editor/code-editor-instructor.integration.spec.ts @@ -16,15 +16,15 @@ import { ArtemisTestModule } from '../../test.module'; import { ProgrammingExerciseParticipationService } from 'app/exercises/programming/manage/services/programming-exercise-participation.service'; import { ProgrammingExerciseService } from 'app/exercises/programming/manage/services/programming-exercise.service'; import { DomainType, FileType } from 'app/exercises/programming/shared/code-editor/model/code-editor.model'; -import { MockAccountService } from '../../mocks/service/mock-account.service'; -import { MockRouter } from '../../mocks/service/mock-router.service'; -import { problemStatement } from '../../sample/problemStatement.json'; -import { MockProgrammingExerciseParticipationService } from '../../mocks/service/mock-programming-exercise-participation.service'; +import { MockAccountService } from '../../helpers/mocks/service/mock-account.service'; +import { MockRouter } from '../../helpers/mocks/service/mock-router.service'; +import { problemStatement } from '../../helpers/sample/problemStatement.json'; +import { MockProgrammingExerciseParticipationService } from '../../helpers/mocks/service/mock-programming-exercise-participation.service'; import { ExerciseHint } from 'app/entities/exercise-hint.model'; import { DeviceDetectorService } from 'ngx-device-detector'; import { CodeEditorInstructorContainerComponent } from 'app/exercises/programming/manage/code-editor/code-editor-instructor-container.component'; import { ParticipationWebsocketService } from 'app/overview/participation-websocket.service'; -import { MockCourseExerciseService } from '../../mocks/service/mock-course-exercise.service'; +import { MockCourseExerciseService } from '../../helpers/mocks/service/mock-course-exercise.service'; import { ExerciseHintService, IExerciseHintService } from 'app/exercises/shared/exercise-hint/manage/exercise-hint.service'; import { CodeEditorBuildLogService, @@ -40,19 +40,19 @@ import { ParticipationService } from 'app/exercises/shared/participation/partici import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; import { ProgrammingExerciseStudentParticipation } from 'app/entities/participation/programming-exercise-student-participation.model'; import { SolutionProgrammingExerciseParticipation } from 'app/entities/participation/solution-programming-exercise-participation.model'; -import { MockActivatedRoute } from '../../mocks/activated-route/mock-activated.route'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; -import { MockResultService } from '../../mocks/service/mock-result.service'; -import { MockCodeEditorRepositoryService } from '../../mocks/service/mock-code-editor-repository.service'; -import { MockCodeEditorBuildLogService } from '../../mocks/service/mock-code-editor-build-log.service'; -import { MockCodeEditorRepositoryFileService } from '../../mocks/service/mock-code-editor-repository-file.service'; -import { MockCodeEditorSessionService } from '../../mocks/service/mock-code-editor-session.service'; -import { MockParticipationWebsocketService } from '../../mocks/service/mock-participation-websocket.service'; -import { MockParticipationService } from '../../mocks/service/mock-participation.service'; -import { MockProgrammingExerciseService } from '../../mocks/service/mock-programming-exercise.service'; -import { MockExerciseHintService } from '../../mocks/service/mock-exercise-hint.service'; +import { MockActivatedRoute } from '../../helpers/mocks/activated-route/mock-activated.route'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; +import { MockResultService } from '../../helpers/mocks/service/mock-result.service'; +import { MockCodeEditorRepositoryService } from '../../helpers/mocks/service/mock-code-editor-repository.service'; +import { MockCodeEditorBuildLogService } from '../../helpers/mocks/service/mock-code-editor-build-log.service'; +import { MockCodeEditorRepositoryFileService } from '../../helpers/mocks/service/mock-code-editor-repository-file.service'; +import { MockCodeEditorSessionService } from '../../helpers/mocks/service/mock-code-editor-session.service'; +import { MockParticipationWebsocketService } from '../../helpers/mocks/service/mock-participation-websocket.service'; +import { MockParticipationService } from '../../helpers/mocks/service/mock-participation.service'; +import { MockProgrammingExerciseService } from '../../helpers/mocks/service/mock-programming-exercise.service'; +import { MockExerciseHintService } from '../../helpers/mocks/service/mock-exercise-hint.service'; import { JhiWebsocketService } from 'app/core/websocket/websocket.service'; -import { MockWebsocketService } from '../../mocks/service/mock-websocket.service'; +import { MockWebsocketService } from '../../helpers/mocks/service/mock-websocket.service'; import { ArtemisCodeEditorManagementModule } from 'app/exercises/programming/manage/code-editor/code-editor-management.module'; import { CourseExerciseService } from 'app/course/manage/course-management.service'; diff --git a/src/test/javascript/spec/integration/code-editor/code-editor-student.integration.spec.ts b/src/test/javascript/spec/integration/code-editor/code-editor-student.integration.spec.ts index a6b2e2d99538..41bd13eb73ee 100644 --- a/src/test/javascript/spec/integration/code-editor/code-editor-student.integration.spec.ts +++ b/src/test/javascript/spec/integration/code-editor/code-editor-student.integration.spec.ts @@ -17,19 +17,19 @@ import { ArtemisTestModule } from '../../test.module'; import { ParticipationWebsocketService } from 'app/overview/participation-websocket.service'; import { ProgrammingExerciseParticipationService } from 'app/exercises/programming/manage/services/programming-exercise-participation.service'; import { CommitState, DeleteFileChange, DomainType, EditorState, FileType, GitConflictState } from 'app/exercises/programming/shared/code-editor/model/code-editor.model'; -import { buildLogs, extractedBuildLogErrors } from '../../sample/build-logs'; -import { problemStatement } from '../../sample/problemStatement.json'; -import { MockAccountService } from '../../mocks/service/mock-account.service'; -import { MockProgrammingExerciseParticipationService } from '../../mocks/service/mock-programming-exercise-participation.service'; +import { buildLogs, extractedBuildLogErrors } from '../../helpers/sample/build-logs'; +import { problemStatement } from '../../helpers/sample/problemStatement.json'; +import { MockAccountService } from '../../helpers/mocks/service/mock-account.service'; +import { MockProgrammingExerciseParticipationService } from '../../helpers/mocks/service/mock-programming-exercise-participation.service'; import { ProgrammingSubmissionService, ProgrammingSubmissionState, ProgrammingSubmissionStateObj } from 'app/exercises/programming/participate/programming-submission.service'; -import { MockProgrammingSubmissionService } from '../../mocks/service/mock-programming-submission.service'; +import { MockProgrammingSubmissionService } from '../../helpers/mocks/service/mock-programming-submission.service'; import { ExerciseHint } from 'app/entities/exercise-hint.model'; import { DeviceDetectorService } from 'ngx-device-detector'; import { GuidedTourService } from 'app/guided-tour/guided-tour.service'; -import { getElement } from '../../utils/general.utils'; +import { getElement } from '../../helpers/utils/general.utils'; import { GuidedTourMapping } from 'app/guided-tour/guided-tour-setting.model'; import { JhiWebsocketService } from 'app/core/websocket/websocket.service'; -import { MockWebsocketService } from '../../mocks/service/mock-websocket.service'; +import { MockWebsocketService } from '../../helpers/mocks/service/mock-websocket.service'; import { Participation } from 'app/entities/participation/participation.model'; import { BuildLogEntryArray } from 'app/entities/build-log.model'; import { CodeEditorConflictStateService } from 'app/exercises/programming/shared/code-editor/service/code-editor-conflict-state.service'; @@ -48,15 +48,15 @@ import { CodeEditorSessionService } from 'app/exercises/programming/shared/code- import { DomainService } from 'app/exercises/programming/shared/code-editor/service/code-editor-domain.service'; import { ProgrammingSubmission } from 'app/entities/programming-submission.model'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; -import { MockActivatedRoute } from '../../mocks/activated-route/mock-activated.route'; -import { MockParticipationWebsocketService } from '../../mocks/service/mock-participation-websocket.service'; -import { MockSyncStorage } from '../../mocks/service/mock-sync-storage.service'; -import { MockResultService } from '../../mocks/service/mock-result.service'; -import { MockCodeEditorRepositoryService } from '../../mocks/service/mock-code-editor-repository.service'; -import { MockExerciseHintService } from '../../mocks/service/mock-exercise-hint.service'; -import { MockCodeEditorRepositoryFileService } from '../../mocks/service/mock-code-editor-repository-file.service'; -import { MockCodeEditorSessionService } from '../../mocks/service/mock-code-editor-session.service'; -import { MockCodeEditorBuildLogService } from '../../mocks/service/mock-code-editor-build-log.service'; +import { MockActivatedRoute } from '../../helpers/mocks/activated-route/mock-activated.route'; +import { MockParticipationWebsocketService } from '../../helpers/mocks/service/mock-participation-websocket.service'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; +import { MockResultService } from '../../helpers/mocks/service/mock-result.service'; +import { MockCodeEditorRepositoryService } from '../../helpers/mocks/service/mock-code-editor-repository.service'; +import { MockExerciseHintService } from '../../helpers/mocks/service/mock-exercise-hint.service'; +import { MockCodeEditorRepositoryFileService } from '../../helpers/mocks/service/mock-code-editor-repository-file.service'; +import { MockCodeEditorSessionService } from '../../helpers/mocks/service/mock-code-editor-session.service'; +import { MockCodeEditorBuildLogService } from '../../helpers/mocks/service/mock-code-editor-build-log.service'; import { ArtemisProgrammingParticipationModule } from 'app/exercises/programming/participate/programming-participation.module'; chai.use(sinonChai); diff --git a/src/test/javascript/spec/service/account.service.spec.ts b/src/test/javascript/spec/service/account.service.spec.ts index cd0d25006d3a..beb66117c2ad 100644 --- a/src/test/javascript/spec/service/account.service.spec.ts +++ b/src/test/javascript/spec/service/account.service.spec.ts @@ -3,13 +3,13 @@ import * as chai from 'chai'; import { SinonStub, stub } from 'sinon'; import { of } from 'rxjs'; import * as sinonChai from 'sinon-chai'; -import { MockWebsocketService } from '../mocks/service/mock-websocket.service'; -import { MockLanguageService } from '../mocks/service/mock-language.service'; -import { MockHttpService } from '../mocks/service/mock-http.service'; -import { MockFeatureToggleService } from '../mocks/service/mock-feature-toggle.service'; +import { MockWebsocketService } from '../helpers/mocks/service/mock-websocket.service'; +import { MockLanguageService } from '../helpers/mocks/service/mock-language.service'; +import { MockHttpService } from '../helpers/mocks/service/mock-http.service'; +import { MockFeatureToggleService } from '../helpers/mocks/service/mock-feature-toggle.service'; import { User } from 'app/core/user/user.model'; import { AccountService } from 'app/core/auth/account.service'; -import { MockSyncStorage } from '../mocks/service/mock-sync-storage.service'; +import { MockSyncStorage } from '../helpers/mocks/service/mock-sync-storage.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/service/course.service.spec.ts b/src/test/javascript/spec/service/course.service.spec.ts index 40c7e24cf288..1812ecae49de 100644 --- a/src/test/javascript/spec/service/course.service.spec.ts +++ b/src/test/javascript/spec/service/course.service.spec.ts @@ -8,9 +8,9 @@ import * as moment from 'moment'; import { DATE_TIME_FORMAT } from 'app/shared/constants/input.constants'; import { CourseManagementService } from 'app/course/manage/course-management.service'; import { Course } from 'app/entities/course.model'; -import { MockTranslateService } from '../mocks/service/mock-translate.service'; -import { MockSyncStorage } from '../mocks/service/mock-sync-storage.service'; -import { MockRouter } from '../mocks/service/mock-router.service'; +import { MockTranslateService } from '../helpers/mocks/service/mock-translate.service'; +import { MockSyncStorage } from '../helpers/mocks/service/mock-sync-storage.service'; +import { MockRouter } from '../helpers/mocks/service/mock-router.service'; describe('Service Tests', () => { describe('Course Service', () => { diff --git a/src/test/javascript/spec/service/guided-tour.service.spec.ts b/src/test/javascript/spec/service/guided-tour.service.spec.ts index fe34166b0df4..791ad7e1f6cb 100644 --- a/src/test/javascript/spec/service/guided-tour.service.spec.ts +++ b/src/test/javascript/spec/service/guided-tour.service.spec.ts @@ -18,11 +18,11 @@ import { GuidedTourState, Orientation, ResetParticipation, UserInteractionEvent import { GuidedTourComponent } from 'app/guided-tour/guided-tour.component'; import { GuidedTourMapping, GuidedTourSetting } from 'app/guided-tour/guided-tour-setting.model'; import { ModelingTaskTourStep, TextTourStep, UserInterActionTourStep } from 'app/guided-tour/guided-tour-step.model'; -import { MockAccountService } from '../mocks/service/mock-account.service'; +import { MockAccountService } from '../helpers/mocks/service/mock-account.service'; import { AccountService } from 'app/core/auth/account.service'; import { DeviceDetectorService } from 'ngx-device-detector'; import { Course } from 'app/entities/course.model'; -import { MockTranslateService } from '../mocks/service/mock-translate.service'; +import { MockTranslateService } from '../helpers/mocks/service/mock-translate.service'; import { GuidedTourModelingTask, personUML } from 'app/guided-tour/guided-tour-task.model'; import { completedTour } from 'app/guided-tour/tours/general-tour'; import { SinonStub, stub } from 'sinon'; @@ -32,8 +32,8 @@ import { Exercise, ExerciseType } from 'app/entities/exercise.model'; import { InitializationState } from 'app/entities/participation/participation.model'; import { NavbarComponent } from 'app/shared/layouts/navbar/navbar.component'; import { StudentParticipation } from 'app/entities/participation/student-participation.model'; -import { MockSyncStorage } from '../mocks/service/mock-sync-storage.service'; -import { MockCookieService } from '../mocks/service/mock-cookie.service'; +import { MockSyncStorage } from '../helpers/mocks/service/mock-sync-storage.service'; +import { MockCookieService } from '../helpers/mocks/service/mock-cookie.service'; import { CourseManagementService } from 'app/course/manage/course-management.service'; chai.use(sinonChai); diff --git a/src/test/javascript/spec/service/ide-build-and-test.service.spec.ts b/src/test/javascript/spec/service/ide-build-and-test.service.spec.ts index 428c49ec6969..3087f48665d8 100644 --- a/src/test/javascript/spec/service/ide-build-and-test.service.spec.ts +++ b/src/test/javascript/spec/service/ide-build-and-test.service.spec.ts @@ -3,17 +3,17 @@ import * as sinonChai from 'sinon-chai'; import { IProgrammingSubmissionService } from 'app/exercises/programming/participate/programming-submission.service'; import { IParticipationWebsocketService } from 'app/overview/participation-websocket.service'; import { SinonSpy, SinonStub, spy, stub } from 'sinon'; -import { MockProgrammingSubmissionService } from '../mocks/service/mock-programming-submission.service'; +import { MockProgrammingSubmissionService } from '../helpers/mocks/service/mock-programming-submission.service'; import { Result } from 'app/entities/result.model'; import { BehaviorSubject, of } from 'rxjs'; import { Feedback } from 'app/entities/feedback.model'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; import { IBuildLogService } from 'app/exercises/programming/shared/service/build-log.service'; -import { MockParticipationWebsocketService } from '../mocks/service/mock-participation-websocket.service'; -import { MockCodeEditorBuildLogService } from '../mocks/service/mock-code-editor-build-log.service'; +import { MockParticipationWebsocketService } from '../helpers/mocks/service/mock-participation-websocket.service'; +import { MockCodeEditorBuildLogService } from '../helpers/mocks/service/mock-code-editor-build-log.service'; import { OrionBuildAndTestService } from 'app/shared/orion/orion-build-and-test.service'; import { OrionConnectorService } from 'app/shared/orion/orion-connector.service'; -import { MockOrionConnectorService } from '../mocks/service/mock-orion-connector.service'; +import { MockOrionConnectorService } from '../helpers/mocks/service/mock-orion-connector.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/service/login.service.spec.ts b/src/test/javascript/spec/service/login.service.spec.ts index 9467891a455d..aee3d8821a4e 100644 --- a/src/test/javascript/spec/service/login.service.spec.ts +++ b/src/test/javascript/spec/service/login.service.spec.ts @@ -2,16 +2,16 @@ import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; import { SinonStub, stub } from 'sinon'; import { of, throwError } from 'rxjs'; -import { MockWebsocketService } from '../mocks/service/mock-websocket.service'; -import { MockRouter } from '../mocks/service/mock-router.service'; -import { MockAccountService } from '../mocks/service/mock-account.service'; -import { MockAuthServerProviderService } from '../mocks/service/mock-auth-server-provider.service'; -import { MockAlertService } from '../mocks/service/mock-alert.service'; +import { MockWebsocketService } from '../helpers/mocks/service/mock-websocket.service'; +import { MockRouter } from '../helpers/mocks/service/mock-router.service'; +import { MockAccountService } from '../helpers/mocks/service/mock-account.service'; +import { MockAuthServerProviderService } from '../helpers/mocks/service/mock-auth-server-provider.service'; +import { MockAlertService } from '../helpers/mocks/service/mock-alert.service'; import { IAccountService } from 'app/core/auth/account.service'; import { IWebsocketService } from 'app/core/websocket/websocket.service'; import { LoginService } from 'app/core/login/login.service'; import { IAuthServerProvider } from 'app/core/auth/auth-jwt.service'; -import { MockNotificationService } from '../mocks/service/mock-notification.service'; +import { MockNotificationService } from '../helpers/mocks/service/mock-notification.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/service/orion-version-validator.service.spec.ts b/src/test/javascript/spec/service/orion-version-validator.service.spec.ts index df59a6a5b20a..1601be202e98 100644 --- a/src/test/javascript/spec/service/orion-version-validator.service.spec.ts +++ b/src/test/javascript/spec/service/orion-version-validator.service.spec.ts @@ -4,9 +4,9 @@ import { SinonSpy, SinonStub, spy, stub } from 'sinon'; import { OrionVersionValidator } from 'app/shared/orion/outdated-plugin-warning/orion-version-validator.service'; import { ProfileService } from 'app/shared/layouts/profiles/profile.service'; import { Router } from '@angular/router'; -import { MockProfileService } from '../mocks/service/mock-profile.service'; -import { MockWindowRef } from '../mocks/service/mock-window.service'; -import { MockRouter } from '../mocks/service/mock-router.service'; +import { MockProfileService } from '../helpers/mocks/service/mock-profile.service'; +import { MockWindowRef } from '../helpers/mocks/service/mock-window.service'; +import { MockRouter } from '../helpers/mocks/service/mock-router.service'; import { of } from 'rxjs'; import { ProfileInfo } from 'app/shared/layouts/profiles/profile-info.model'; diff --git a/src/test/javascript/spec/service/participation-websocket.service.spec.ts b/src/test/javascript/spec/service/participation-websocket.service.spec.ts index 217bdee2fad9..bf8b3ade39a6 100644 --- a/src/test/javascript/spec/service/participation-websocket.service.spec.ts +++ b/src/test/javascript/spec/service/participation-websocket.service.spec.ts @@ -4,7 +4,7 @@ import { SinonSpy, SinonStub, spy, stub } from 'sinon'; import { BehaviorSubject, Subject } from 'rxjs'; import * as sinonChai from 'sinon-chai'; import { ParticipationWebsocketService } from 'app/overview/participation-websocket.service'; -import { MockWebsocketService } from '../mocks/service/mock-websocket.service'; +import { MockWebsocketService } from '../helpers/mocks/service/mock-websocket.service'; import { Participation } from 'app/entities/participation/participation.model'; import { Result } from 'app/entities/result.model'; import { IWebsocketService } from 'app/core/websocket/websocket.service'; diff --git a/src/test/javascript/spec/service/programming-exercise-instruction-analysis.service.spec.ts b/src/test/javascript/spec/service/programming-exercise-instruction-analysis.service.spec.ts index 3f016a35317a..4e92a76fd1b4 100644 --- a/src/test/javascript/spec/service/programming-exercise-instruction-analysis.service.spec.ts +++ b/src/test/javascript/spec/service/programming-exercise-instruction-analysis.service.spec.ts @@ -1,5 +1,5 @@ -import { problemStatement } from '../sample/problemStatement.json'; -import { MockTranslateService } from '../mocks/service/mock-translate.service'; +import { problemStatement } from '../helpers/sample/problemStatement.json'; +import { MockTranslateService } from '../helpers/mocks/service/mock-translate.service'; import { ExerciseHint } from 'app/entities/exercise-hint.model'; import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; diff --git a/src/test/javascript/spec/service/programming-exercise-test-case.service.spec.ts b/src/test/javascript/spec/service/programming-exercise-test-case.service.spec.ts index d95b34d33d32..45d7de269934 100644 --- a/src/test/javascript/spec/service/programming-exercise-test-case.service.spec.ts +++ b/src/test/javascript/spec/service/programming-exercise-test-case.service.spec.ts @@ -4,10 +4,10 @@ import { SinonSpy, SinonStub, spy, stub } from 'sinon'; import { of, Subject } from 'rxjs'; import { tap } from 'rxjs/operators'; import * as sinonChai from 'sinon-chai'; -import { MockWebsocketService } from '../mocks/service/mock-websocket.service'; +import { MockWebsocketService } from '../helpers/mocks/service/mock-websocket.service'; import { IWebsocketService } from 'app/core/websocket/websocket.service.ts'; import { ProgrammingExerciseTestCaseService } from 'app/exercises/programming/manage/services/programming-exercise-test-case.service'; -import { MockHttpService } from '../mocks/service/mock-http.service'; +import { MockHttpService } from '../helpers/mocks/service/mock-http.service'; import { ProgrammingExerciseTestCase } from 'app/entities/programming-exercise-test-case.model'; import { Result } from 'app/entities/result.model'; diff --git a/src/test/javascript/spec/service/programming-submission.service.spec.ts b/src/test/javascript/spec/service/programming-submission.service.spec.ts index c93036546be1..421f2b3feedb 100644 --- a/src/test/javascript/spec/service/programming-submission.service.spec.ts +++ b/src/test/javascript/spec/service/programming-submission.service.spec.ts @@ -4,8 +4,8 @@ import { SinonStub, spy, stub } from 'sinon'; import { BehaviorSubject, of, Subject } from 'rxjs'; import { range as _range } from 'lodash'; import * as sinonChai from 'sinon-chai'; -import { MockWebsocketService } from '../mocks/service/mock-websocket.service'; -import { MockHttpService } from '../mocks/service/mock-http.service'; +import { MockWebsocketService } from '../helpers/mocks/service/mock-websocket.service'; +import { MockHttpService } from '../helpers/mocks/service/mock-http.service'; import { ExerciseSubmissionState, IProgrammingSubmissionService, @@ -14,13 +14,13 @@ import { ProgrammingSubmissionStateObj, } from 'app/exercises/programming/participate/programming-submission.service'; import { IParticipationWebsocketService } from 'app/overview/participation-websocket.service'; -import { MockAlertService } from '../mocks/service/mock-alert.service'; +import { MockAlertService } from '../helpers/mocks/service/mock-alert.service'; import { Result } from 'app/entities/result.model'; import { SERVER_API_URL } from 'app/app.constants'; import { ProgrammingSubmission } from 'app/entities/programming-submission.model'; import { Submission } from 'app/entities/submission.model'; import { StudentParticipation } from 'app/entities/participation/student-participation.model'; -import { MockParticipationWebsocketService } from '../mocks/service/mock-participation-websocket.service'; +import { MockParticipationWebsocketService } from '../helpers/mocks/service/mock-participation-websocket.service'; chai.use(sinonChai); const expect = chai.expect; diff --git a/src/test/javascript/spec/service/user-route-access.service.spec.ts b/src/test/javascript/spec/service/user-route-access.service.spec.ts index 2b8fa1658b32..c4baba7e489d 100644 --- a/src/test/javascript/spec/service/user-route-access.service.spec.ts +++ b/src/test/javascript/spec/service/user-route-access.service.spec.ts @@ -5,18 +5,18 @@ import { UserRouteAccessService } from 'app/core/auth/user-route-access-service' import { ActivatedRouteSnapshot, Route } from '@angular/router'; import { ArtemisTestModule } from '../test.module'; import { TranslateService } from '@ngx-translate/core'; -import { MockTranslateService } from '../mocks/service/mock-translate.service'; -import { MockSyncStorage } from '../mocks/service/mock-sync-storage.service'; -import { MockCookieService } from '../mocks/service/mock-cookie.service'; +import { MockTranslateService } from '../helpers/mocks/service/mock-translate.service'; +import { MockSyncStorage } from '../helpers/mocks/service/mock-sync-storage.service'; +import { MockCookieService } from '../helpers/mocks/service/mock-cookie.service'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { AccountService } from 'app/core/auth/account.service'; -import { MockAccountService } from '../mocks/service/mock-account.service'; +import { MockAccountService } from '../helpers/mocks/service/mock-account.service'; import { RouterTestingModule } from '@angular/router/testing'; import { CookieService } from 'ngx-cookie-service'; import { DeviceDetectorService } from 'ngx-device-detector'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { Mutable } from '../helpers/mutable'; -import { mockedActivatedRouteSnapshot } from '../mocks/activated-route/mock-activated-route-snapshot'; +import { mockedActivatedRouteSnapshot } from '../helpers/mocks/activated-route/mock-activated-route-snapshot'; import { CourseExerciseDetailsComponent } from 'app/overview/exercise-details/course-exercise-details.component'; chai.use(sinonChai); diff --git a/src/test/javascript/spec/test.module.ts b/src/test/javascript/spec/test.module.ts index 06e75cfa218a..5e28d85aa2c3 100644 --- a/src/test/javascript/spec/test.module.ts +++ b/src/test/javascript/spec/test.module.ts @@ -5,13 +5,13 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { NgbActiveModal, NgbModal, NgbDatepickerConfig } from '@ng-bootstrap/ng-bootstrap'; import { JhiAlertService, JhiDataUtils, JhiDateUtils, JhiEventManager, JhiLanguageService, JhiParseLinks } from 'ng-jhipster'; -import { MockLanguageHelper, MockLanguageService } from './mocks/service/mock-language.service'; +import { MockLanguageHelper, MockLanguageService } from './helpers/mocks/service/mock-language.service'; import { JhiLanguageHelper } from 'app/core/language/language.helper'; import { AccountService } from 'app/core/auth/account.service'; -import { MockAccountService } from './mocks/service/mock-account.service'; -import { MockActivatedRoute, MockRouter } from './mocks/service/mock-route.service'; -import { MockActiveModal } from './mocks/service/mock-active-modal.service'; -import { MockEventManager } from './mocks/service/mock-event-manager.service'; +import { MockAccountService } from './helpers/mocks/service/mock-account.service'; +import { MockActivatedRoute, MockRouter } from './helpers/mocks/service/mock-route.service'; +import { MockActiveModal } from './helpers/mocks/service/mock-active-modal.service'; +import { MockEventManager } from './helpers/mocks/service/mock-event-manager.service'; import { CookieService } from 'ngx-cookie-service'; import { FaIconLibrary, FontAwesomeModule, FaIconComponent } from '@fortawesome/angular-fontawesome'; import { fas } from '@fortawesome/free-solid-svg-icons'; From d3c80aa4941f955daff7ea6962ae768860b2893f Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Fri, 24 Apr 2020 16:20:18 +0200 Subject: [PATCH 098/152] Fix test case in course-detail.component.spec.ts --- .../course/course-detail.component.spec.ts | 71 ++++++++++++------- .../service/mock-course-management.service.ts | 6 ++ 2 files changed, 53 insertions(+), 24 deletions(-) create mode 100644 src/test/javascript/spec/helpers/mocks/service/mock-course-management.service.ts diff --git a/src/test/javascript/spec/component/course/course-detail.component.spec.ts b/src/test/javascript/spec/component/course/course-detail.component.spec.ts index b5de29783694..130cb1255324 100644 --- a/src/test/javascript/spec/component/course/course-detail.component.spec.ts +++ b/src/test/javascript/spec/component/course/course-detail.component.spec.ts @@ -1,39 +1,62 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; import { ActivatedRoute } from '@angular/router'; import { of } from 'rxjs'; +import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { ArtemisTestModule } from '../../test.module'; import { CourseDetailComponent } from 'app/course/manage/course-detail.component'; import { Course } from 'app/entities/course.model'; +import { CourseManagementService } from 'app/course/manage/course-management.service'; +import { MockCourseManagementService } from '../../helpers/mocks/service/mock-course-management.service'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; -describe('Component Tests', () => { - describe('Course Management Detail Component', () => { - let comp: CourseDetailComponent; - let fixture: ComponentFixture; - const route = ({ data: of({ course: new Course(123) }) } as any) as ActivatedRoute; +describe('Course Management Detail Component', () => { + let comp: CourseDetailComponent; + let fixture: ComponentFixture; + let service: CourseManagementService; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [CourseDetailComponent], - providers: [{ provide: ActivatedRoute, useValue: route }], - }) - .overrideTemplate(CourseDetailComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(CourseDetailComponent); - comp = fixture.componentInstance; - }); + const course: Course = { id: 123 } as Course; + const route = ({ params: of({ courseId: course.id }) } as any) as ActivatedRoute; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [CourseDetailComponent], + providers: [ + { provide: ActivatedRoute, useValue: route }, + { provide: LocalStorageService, useClass: MockSyncStorage }, + { provide: SessionStorageService, useClass: MockSyncStorage }, + { provide: CourseManagementService, useClass: MockCourseManagementService }, + ], + }) + .overrideTemplate(CourseDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(CourseDetailComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(CourseManagementService); + }); - describe('OnInit', () => { - it('Should call load all on init', () => { - // GIVEN + describe('OnInit', () => { + it('Should call load on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'find').and.returnValue( + of( + new HttpResponse({ + body: course, + headers, + }), + ), + ); - // WHEN - comp.ngOnInit(); + // WHEN + fixture.detectChanges(); + comp.ngOnInit(); - // THEN - expect(comp.course).toEqual(jasmine.objectContaining({ id: 123 })); - }); + // THEN + expect(service.find).toHaveBeenCalled(); + expect(comp.course).toEqual(jasmine.objectContaining({ id: course.id })); }); }); }); diff --git a/src/test/javascript/spec/helpers/mocks/service/mock-course-management.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-course-management.service.ts new file mode 100644 index 000000000000..522695469df6 --- /dev/null +++ b/src/test/javascript/spec/helpers/mocks/service/mock-course-management.service.ts @@ -0,0 +1,6 @@ +import { Observable } from 'rxjs'; +import { Course } from 'app/entities/course.model'; + +export class MockCourseManagementService { + find = (courseId: number) => Observable.of([{ id: 456 } as Course]); +} From 85052b8e3c2d769e5dfa7f28b22fddf1bdf77d46 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Fri, 24 Apr 2020 17:33:44 +0200 Subject: [PATCH 099/152] Remove unnecessary describe('Component Tests'... from all test suites --- .../account/activate.component.spec.ts | 100 +++-- .../password-reset-finish.component.spec.ts | 204 +++++----- .../password-reset-init.component.spec.ts | 188 +++++----- .../password-strength-bar.component.spec.ts | 70 ++-- .../account/password.component.spec.ts | 128 ++++--- .../account/register.component.spec.ts | 212 ++++++----- .../component/admin/audits.component.spec.ts | 112 +++--- .../admin/configuration.component.spec.ts | 100 +++-- .../component/admin/health.component.spec.ts | 90 +++-- .../component/admin/logs.component.spec.ts | 110 +++--- .../component/admin/metrics.component.spec.ts | 74 ++-- .../user-management-detail.component.spec.ts | 104 +++--- .../user-management-update.component.spec.ts | 162 ++++---- .../course/course-update.component.spec.ts | 100 +++-- .../exercise-hint-detail.component.spec.ts | 51 ++- .../exercise-hint-update.component.spec.ts | 99 +++-- .../exercise-hint.component.spec.ts | 83 ++--- ...e-upload-exercise-detail.component.spec.ts | 84 ++--- ...e-upload-exercise-update.component.spec.ts | 94 +++-- .../file-upload-exercise.component.spec.ts | 66 ++-- ...modeling-exercise-detail.component.spec.ts | 46 ++- ...modeling-exercise-update.component.spec.ts | 94 +++-- .../modeling-exercise.component.spec.ts | 66 ++-- .../modeling-submission.component.spec.ts | 351 +++++++++--------- ...gramming-exercise-detail.component.spec.ts | 46 ++- ...gramming-exercise-update.component.spec.ts | 94 +++-- .../programming-exercise.component.spec.ts | 92 +++-- .../quiz-exercise-detail.component.spec.ts | 46 ++- .../quiz-exercise.component.spec.ts | 66 ++-- .../shared/alert-error.component.spec.ts | 224 ++++++----- .../text-exercise-detail.component.spec.ts | 46 ++- .../text-exercise-update.component.spec.ts | 94 +++-- .../text-exercise.component.spec.ts | 66 ++-- 33 files changed, 1746 insertions(+), 1816 deletions(-) diff --git a/src/test/javascript/spec/component/account/activate.component.spec.ts b/src/test/javascript/spec/component/account/activate.component.spec.ts index 7c92e57eba1f..d97bef67140a 100644 --- a/src/test/javascript/spec/component/account/activate.component.spec.ts +++ b/src/test/javascript/spec/component/account/activate.component.spec.ts @@ -7,66 +7,64 @@ import { MockActivatedRoute } from '../../helpers/mocks/service/mock-route.servi import { ActivateService } from 'app/account/activate/activate.service'; import { ActivateComponent } from 'app/account/activate/activate.component'; -describe('Component Tests', () => { - describe('ActivateComponent', () => { - let comp: ActivateComponent; +describe('ActivateComponent', () => { + let comp: ActivateComponent; - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [ActivateComponent], - providers: [ - { - provide: ActivatedRoute, - useValue: new MockActivatedRoute({ key: 'ABC123' }), - }, - ], - }) - .overrideTemplate(ActivateComponent, '') - .compileComponents(); - })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [ActivateComponent], + providers: [ + { + provide: ActivatedRoute, + useValue: new MockActivatedRoute({ key: 'ABC123' }), + }, + ], + }) + .overrideTemplate(ActivateComponent, '') + .compileComponents(); + })); - beforeEach(() => { - const fixture = TestBed.createComponent(ActivateComponent); - comp = fixture.componentInstance; - }); + beforeEach(() => { + const fixture = TestBed.createComponent(ActivateComponent); + comp = fixture.componentInstance; + }); - it('calls activate.get with the key from params', inject( - [ActivateService], - fakeAsync((service: ActivateService) => { - spyOn(service, 'get').and.returnValue(of()); + it('calls activate.get with the key from params', inject( + [ActivateService], + fakeAsync((service: ActivateService) => { + spyOn(service, 'get').and.returnValue(of()); - comp.ngOnInit(); - tick(); + comp.ngOnInit(); + tick(); - expect(service.get).toHaveBeenCalledWith('ABC123'); - }), - )); + expect(service.get).toHaveBeenCalledWith('ABC123'); + }), + )); - it('should set set success to OK upon successful activation', inject( - [ActivateService], - fakeAsync((service: ActivateService) => { - spyOn(service, 'get').and.returnValue(of({})); + it('should set set success to OK upon successful activation', inject( + [ActivateService], + fakeAsync((service: ActivateService) => { + spyOn(service, 'get').and.returnValue(of({})); - comp.ngOnInit(); - tick(); + comp.ngOnInit(); + tick(); - expect(comp.error).toBe(null); - expect(comp.success).toEqual('OK'); - }), - )); + expect(comp.error).toBe(null); + expect(comp.success).toEqual('OK'); + }), + )); - it('should set set error to ERROR upon activation failure', inject( - [ActivateService], - fakeAsync((service: ActivateService) => { - spyOn(service, 'get').and.returnValue(throwError('ERROR')); + it('should set set error to ERROR upon activation failure', inject( + [ActivateService], + fakeAsync((service: ActivateService) => { + spyOn(service, 'get').and.returnValue(throwError('ERROR')); - comp.ngOnInit(); - tick(); + comp.ngOnInit(); + tick(); - expect(comp.error).toBe('ERROR'); - expect(comp.success).toEqual(null); - }), - )); - }); + expect(comp.error).toBe('ERROR'); + expect(comp.success).toEqual(null); + }), + )); }); diff --git a/src/test/javascript/spec/component/account/password-reset-finish.component.spec.ts b/src/test/javascript/spec/component/account/password-reset-finish.component.spec.ts index 26313e010609..4a4ef710a5f5 100644 --- a/src/test/javascript/spec/component/account/password-reset-finish.component.spec.ts +++ b/src/test/javascript/spec/component/account/password-reset-finish.component.spec.ts @@ -8,112 +8,110 @@ import { PasswordResetFinishComponent } from 'app/account/password-reset/finish/ import { PasswordResetFinishService } from 'app/account/password-reset/finish/password-reset-finish.service'; import { MockActivatedRoute } from '../../helpers/mocks/service/mock-route.service'; -describe('Component Tests', () => { - describe('PasswordResetFinishComponent', () => { - let fixture: ComponentFixture; - let comp: PasswordResetFinishComponent; - - beforeEach(() => { - fixture = TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [PasswordResetFinishComponent], - providers: [ - { - provide: ActivatedRoute, - useValue: new MockActivatedRoute({ key: 'XYZPDQ' }), +describe('PasswordResetFinishComponent', () => { + let fixture: ComponentFixture; + let comp: PasswordResetFinishComponent; + + beforeEach(() => { + fixture = TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [PasswordResetFinishComponent], + providers: [ + { + provide: ActivatedRoute, + useValue: new MockActivatedRoute({ key: 'XYZPDQ' }), + }, + { + provide: Renderer2, + useValue: { + invokeElementMethod() {}, }, - { - provide: Renderer2, - useValue: { - invokeElementMethod() {}, - }, - }, - { - provide: ElementRef, - useValue: new ElementRef(null), - }, - ], - }) - .overrideTemplate(PasswordResetFinishComponent, '') - .createComponent(PasswordResetFinishComponent); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(PasswordResetFinishComponent); - comp = fixture.componentInstance; - comp.ngOnInit(); - }); - - it('should define its initial state', () => { - comp.ngOnInit(); - - expect(comp.keyMissing).toBeFalsy(); - expect(comp.key).toEqual('XYZPDQ'); - expect(comp.resetAccount).toEqual({}); - }); - - it('sets focus after the view has been initialized', inject([ElementRef], (elementRef: ElementRef) => { - const element = fixture.nativeElement; - const node = { - focus() {}, - }; - - elementRef.nativeElement = element; - spyOn(element, 'querySelector').and.returnValue(node); - spyOn(node, 'focus'); - - comp.ngAfterViewInit(); - - expect(element.querySelector).toHaveBeenCalledWith('#password'); - expect(node.focus).toHaveBeenCalled(); - })); - - it('should ensure the two passwords entered match', () => { + }, + { + provide: ElementRef, + useValue: new ElementRef(null), + }, + ], + }) + .overrideTemplate(PasswordResetFinishComponent, '') + .createComponent(PasswordResetFinishComponent); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(PasswordResetFinishComponent); + comp = fixture.componentInstance; + comp.ngOnInit(); + }); + + it('should define its initial state', () => { + comp.ngOnInit(); + + expect(comp.keyMissing).toBeFalsy(); + expect(comp.key).toEqual('XYZPDQ'); + expect(comp.resetAccount).toEqual({}); + }); + + it('sets focus after the view has been initialized', inject([ElementRef], (elementRef: ElementRef) => { + const element = fixture.nativeElement; + const node = { + focus() {}, + }; + + elementRef.nativeElement = element; + spyOn(element, 'querySelector').and.returnValue(node); + spyOn(node, 'focus'); + + comp.ngAfterViewInit(); + + expect(element.querySelector).toHaveBeenCalledWith('#password'); + expect(node.focus).toHaveBeenCalled(); + })); + + it('should ensure the two passwords entered match', () => { + comp.resetAccount.password = 'password'; + comp.confirmPassword = 'non-matching'; + + comp.finishReset(); + + expect(comp.doNotMatch).toEqual('ERROR'); + }); + + it('should update success to OK after resetting password', inject( + [PasswordResetFinishService], + fakeAsync((service: PasswordResetFinishService) => { + spyOn(service, 'save').and.returnValue(of({})); + comp.resetAccount.password = 'password'; - comp.confirmPassword = 'non-matching'; + comp.confirmPassword = 'password'; comp.finishReset(); + tick(); - expect(comp.doNotMatch).toEqual('ERROR'); - }); - - it('should update success to OK after resetting password', inject( - [PasswordResetFinishService], - fakeAsync((service: PasswordResetFinishService) => { - spyOn(service, 'save').and.returnValue(of({})); - - comp.resetAccount.password = 'password'; - comp.confirmPassword = 'password'; - - comp.finishReset(); - tick(); - - expect(service.save).toHaveBeenCalledWith({ - key: 'XYZPDQ', - newPassword: 'password', - }); - expect(comp.success).toEqual('OK'); - }), - )); - - it('should notify of generic error', inject( - [PasswordResetFinishService], - fakeAsync((service: PasswordResetFinishService) => { - spyOn(service, 'save').and.returnValue(throwError('ERROR')); - - comp.resetAccount.password = 'password'; - comp.confirmPassword = 'password'; - - comp.finishReset(); - tick(); - - expect(service.save).toHaveBeenCalledWith({ - key: 'XYZPDQ', - newPassword: 'password', - }); - expect(comp.success).toBeNull(); - expect(comp.error).toEqual('ERROR'); - }), - )); - }); + expect(service.save).toHaveBeenCalledWith({ + key: 'XYZPDQ', + newPassword: 'password', + }); + expect(comp.success).toEqual('OK'); + }), + )); + + it('should notify of generic error', inject( + [PasswordResetFinishService], + fakeAsync((service: PasswordResetFinishService) => { + spyOn(service, 'save').and.returnValue(throwError('ERROR')); + + comp.resetAccount.password = 'password'; + comp.confirmPassword = 'password'; + + comp.finishReset(); + tick(); + + expect(service.save).toHaveBeenCalledWith({ + key: 'XYZPDQ', + newPassword: 'password', + }); + expect(comp.success).toBeNull(); + expect(comp.error).toEqual('ERROR'); + }), + )); }); diff --git a/src/test/javascript/spec/component/account/password-reset-init.component.spec.ts b/src/test/javascript/spec/component/account/password-reset-init.component.spec.ts index 9aced9025fbd..4ee96cc78c89 100644 --- a/src/test/javascript/spec/component/account/password-reset-init.component.spec.ts +++ b/src/test/javascript/spec/component/account/password-reset-init.component.spec.ts @@ -7,101 +7,99 @@ import { PasswordResetInitComponent } from 'app/account/password-reset/init/pass import { PasswordResetInitService } from 'app/account/password-reset/init/password-reset-init.service'; import { EMAIL_NOT_FOUND_TYPE } from 'app/shared/constants/error.constants'; -describe('Component Tests', () => { - describe('PasswordResetInitComponent', () => { - let fixture: ComponentFixture; - let comp: PasswordResetInitComponent; - - beforeEach(() => { - fixture = TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [PasswordResetInitComponent], - providers: [ - { - provide: Renderer2, - useValue: { - invokeElementMethod() {}, - }, +describe('PasswordResetInitComponent', () => { + let fixture: ComponentFixture; + let comp: PasswordResetInitComponent; + + beforeEach(() => { + fixture = TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [PasswordResetInitComponent], + providers: [ + { + provide: Renderer2, + useValue: { + invokeElementMethod() {}, }, - { - provide: ElementRef, - useValue: new ElementRef(null), - }, - ], - }) - .overrideTemplate(PasswordResetInitComponent, '') - .createComponent(PasswordResetInitComponent); - comp = fixture.componentInstance; - comp.ngOnInit(); - }); - - it('should define its initial state', () => { - expect(comp.success).toBeUndefined(); - expect(comp.error).toBeUndefined(); - expect(comp.errorEmailNotExists).toBeUndefined(); - expect(comp.resetAccount).toEqual({}); - }); - - it('sets focus after the view has been initialized', inject([ElementRef], (elementRef: ElementRef) => { - const element = fixture.nativeElement; - const node = { - focus() {}, - }; - - elementRef.nativeElement = element; - spyOn(element, 'querySelector').and.returnValue(node); - spyOn(node, 'focus'); - - comp.ngAfterViewInit(); - - expect(element.querySelector).toHaveBeenCalledWith('#email'); - expect(node.focus).toHaveBeenCalled(); - })); - - it('notifies of success upon successful requestReset', inject([PasswordResetInitService], (service: PasswordResetInitService) => { - spyOn(service, 'save').and.returnValue(of({})); - comp.resetAccount.email = 'user@domain.com'; - - comp.requestReset(); - - expect(service.save).toHaveBeenCalledWith('user@domain.com'); - expect(comp.success).toEqual('OK'); - expect(comp.error).toBeNull(); - expect(comp.errorEmailNotExists).toBeNull(); - })); - - it('notifies of unknown email upon email address not registered/400', inject([PasswordResetInitService], (service: PasswordResetInitService) => { - spyOn(service, 'save').and.returnValue( - throwError({ - status: 400, - error: { type: EMAIL_NOT_FOUND_TYPE }, - }), - ); - comp.resetAccount.email = 'user@domain.com'; - - comp.requestReset(); - - expect(service.save).toHaveBeenCalledWith('user@domain.com'); - expect(comp.success).toBeNull(); - expect(comp.error).toBeNull(); - expect(comp.errorEmailNotExists).toEqual('ERROR'); - })); - - it('notifies of error upon error response', inject([PasswordResetInitService], (service: PasswordResetInitService) => { - spyOn(service, 'save').and.returnValue( - throwError({ - status: 503, - data: 'something else', - }), - ); - comp.resetAccount.email = 'user@domain.com'; - - comp.requestReset(); - - expect(service.save).toHaveBeenCalledWith('user@domain.com'); - expect(comp.success).toBeNull(); - expect(comp.errorEmailNotExists).toBeNull(); - expect(comp.error).toEqual('ERROR'); - })); + }, + { + provide: ElementRef, + useValue: new ElementRef(null), + }, + ], + }) + .overrideTemplate(PasswordResetInitComponent, '') + .createComponent(PasswordResetInitComponent); + comp = fixture.componentInstance; + comp.ngOnInit(); + }); + + it('should define its initial state', () => { + expect(comp.success).toBeUndefined(); + expect(comp.error).toBeUndefined(); + expect(comp.errorEmailNotExists).toBeUndefined(); + expect(comp.resetAccount).toEqual({}); }); + + it('sets focus after the view has been initialized', inject([ElementRef], (elementRef: ElementRef) => { + const element = fixture.nativeElement; + const node = { + focus() {}, + }; + + elementRef.nativeElement = element; + spyOn(element, 'querySelector').and.returnValue(node); + spyOn(node, 'focus'); + + comp.ngAfterViewInit(); + + expect(element.querySelector).toHaveBeenCalledWith('#email'); + expect(node.focus).toHaveBeenCalled(); + })); + + it('notifies of success upon successful requestReset', inject([PasswordResetInitService], (service: PasswordResetInitService) => { + spyOn(service, 'save').and.returnValue(of({})); + comp.resetAccount.email = 'user@domain.com'; + + comp.requestReset(); + + expect(service.save).toHaveBeenCalledWith('user@domain.com'); + expect(comp.success).toEqual('OK'); + expect(comp.error).toBeNull(); + expect(comp.errorEmailNotExists).toBeNull(); + })); + + it('notifies of unknown email upon email address not registered/400', inject([PasswordResetInitService], (service: PasswordResetInitService) => { + spyOn(service, 'save').and.returnValue( + throwError({ + status: 400, + error: { type: EMAIL_NOT_FOUND_TYPE }, + }), + ); + comp.resetAccount.email = 'user@domain.com'; + + comp.requestReset(); + + expect(service.save).toHaveBeenCalledWith('user@domain.com'); + expect(comp.success).toBeNull(); + expect(comp.error).toBeNull(); + expect(comp.errorEmailNotExists).toEqual('ERROR'); + })); + + it('notifies of error upon error response', inject([PasswordResetInitService], (service: PasswordResetInitService) => { + spyOn(service, 'save').and.returnValue( + throwError({ + status: 503, + data: 'something else', + }), + ); + comp.resetAccount.email = 'user@domain.com'; + + comp.requestReset(); + + expect(service.save).toHaveBeenCalledWith('user@domain.com'); + expect(comp.success).toBeNull(); + expect(comp.errorEmailNotExists).toBeNull(); + expect(comp.error).toEqual('ERROR'); + })); }); diff --git a/src/test/javascript/spec/component/account/password-strength-bar.component.spec.ts b/src/test/javascript/spec/component/account/password-strength-bar.component.spec.ts index 73b3f0f5ffbf..1ada36608705 100644 --- a/src/test/javascript/spec/component/account/password-strength-bar.component.spec.ts +++ b/src/test/javascript/spec/component/account/password-strength-bar.component.spec.ts @@ -2,47 +2,45 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { PasswordStrengthBarComponent } from 'app/account/password/password-strength-bar.component'; -describe('Component Tests', () => { - describe('PasswordStrengthBarComponent', () => { - let comp: PasswordStrengthBarComponent; - let fixture: ComponentFixture; +describe('PasswordStrengthBarComponent', () => { + let comp: PasswordStrengthBarComponent; + let fixture: ComponentFixture; - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [PasswordStrengthBarComponent], - }) - .overrideTemplate(PasswordStrengthBarComponent, '') - .compileComponents(); - })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [PasswordStrengthBarComponent], + }) + .overrideTemplate(PasswordStrengthBarComponent, '') + .compileComponents(); + })); - beforeEach(() => { - fixture = TestBed.createComponent(PasswordStrengthBarComponent); - comp = fixture.componentInstance; - }); + beforeEach(() => { + fixture = TestBed.createComponent(PasswordStrengthBarComponent); + comp = fixture.componentInstance; + }); - describe('PasswordStrengthBarComponents', () => { - it('should initialize with default values', () => { - expect(comp.measureStrength('')).toBe(0); - expect(comp.colors).toEqual(['#F00', '#F90', '#FF0', '#9F0', '#0F0']); - expect(comp.getColor(0).idx).toBe(1); - expect(comp.getColor(0).col).toBe(comp.colors[0]); - }); + describe('PasswordStrengthBarComponents', () => { + it('should initialize with default values', () => { + expect(comp.measureStrength('')).toBe(0); + expect(comp.colors).toEqual(['#F00', '#F90', '#FF0', '#9F0', '#0F0']); + expect(comp.getColor(0).idx).toBe(1); + expect(comp.getColor(0).col).toBe(comp.colors[0]); + }); - it('should increase strength upon password value change', () => { - expect(comp.measureStrength('')).toBe(0); - expect(comp.measureStrength('aa')).toBeGreaterThanOrEqual(comp.measureStrength('')); - expect(comp.measureStrength('aa^6')).toBeGreaterThanOrEqual(comp.measureStrength('aa')); - expect(comp.measureStrength('Aa090(**)')).toBeGreaterThanOrEqual(comp.measureStrength('aa^6')); - expect(comp.measureStrength('Aa090(**)+-07365')).toBeGreaterThanOrEqual(comp.measureStrength('Aa090(**)')); - }); + it('should increase strength upon password value change', () => { + expect(comp.measureStrength('')).toBe(0); + expect(comp.measureStrength('aa')).toBeGreaterThanOrEqual(comp.measureStrength('')); + expect(comp.measureStrength('aa^6')).toBeGreaterThanOrEqual(comp.measureStrength('aa')); + expect(comp.measureStrength('Aa090(**)')).toBeGreaterThanOrEqual(comp.measureStrength('aa^6')); + expect(comp.measureStrength('Aa090(**)+-07365')).toBeGreaterThanOrEqual(comp.measureStrength('Aa090(**)')); + }); - it('should change the color based on strength', () => { - expect(comp.getColor(0).col).toBe(comp.colors[0]); - expect(comp.getColor(11).col).toBe(comp.colors[1]); - expect(comp.getColor(22).col).toBe(comp.colors[2]); - expect(comp.getColor(33).col).toBe(comp.colors[3]); - expect(comp.getColor(44).col).toBe(comp.colors[4]); - }); + it('should change the color based on strength', () => { + expect(comp.getColor(0).col).toBe(comp.colors[0]); + expect(comp.getColor(11).col).toBe(comp.colors[1]); + expect(comp.getColor(22).col).toBe(comp.colors[2]); + expect(comp.getColor(33).col).toBe(comp.colors[3]); + expect(comp.getColor(44).col).toBe(comp.colors[4]); }); }); }); diff --git a/src/test/javascript/spec/component/account/password.component.spec.ts b/src/test/javascript/spec/component/account/password.component.spec.ts index 89749d5cd79c..d4219432a4ee 100644 --- a/src/test/javascript/spec/component/account/password.component.spec.ts +++ b/src/test/javascript/spec/component/account/password.component.spec.ts @@ -6,83 +6,81 @@ import { ArtemisTestModule } from '../../test.module'; import { PasswordComponent } from 'app/account/password/password.component'; import { PasswordService } from 'app/account/password/password.service'; -describe('Component Tests', () => { - describe('PasswordComponent', () => { - let comp: PasswordComponent; - let fixture: ComponentFixture; - let service: PasswordService; +describe('PasswordComponent', () => { + let comp: PasswordComponent; + let fixture: ComponentFixture; + let service: PasswordService; - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [PasswordComponent], - }) - .overrideTemplate(PasswordComponent, '') - .compileComponents(); - })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [PasswordComponent], + }) + .overrideTemplate(PasswordComponent, '') + .compileComponents(); + })); - beforeEach(() => { - fixture = TestBed.createComponent(PasswordComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(PasswordService); - }); + beforeEach(() => { + fixture = TestBed.createComponent(PasswordComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(PasswordService); + }); - it('should show error if passwords do not match', () => { - // GIVEN - comp.newPassword = 'password1'; - comp.confirmPassword = 'password2'; - // WHEN - comp.changePassword(); - // THEN - expect(comp.doNotMatch).toBe('ERROR'); - expect(comp.error).toBeNull(); - expect(comp.success).toBeNull(); - }); + it('should show error if passwords do not match', () => { + // GIVEN + comp.newPassword = 'password1'; + comp.confirmPassword = 'password2'; + // WHEN + comp.changePassword(); + // THEN + expect(comp.doNotMatch).toBe('ERROR'); + expect(comp.error).toBeNull(); + expect(comp.success).toBeNull(); + }); - it('should call Auth.changePassword when passwords match', () => { - // GIVEN - const passwordValues = { - currentPassword: 'oldPassword', - newPassword: 'myPassword', - }; + it('should call Auth.changePassword when passwords match', () => { + // GIVEN + const passwordValues = { + currentPassword: 'oldPassword', + newPassword: 'myPassword', + }; - spyOn(service, 'save').and.returnValue(of(new HttpResponse({ body: true }))); - comp.currentPassword = passwordValues.currentPassword; - comp.newPassword = comp.confirmPassword = passwordValues.newPassword; + spyOn(service, 'save').and.returnValue(of(new HttpResponse({ body: true }))); + comp.currentPassword = passwordValues.currentPassword; + comp.newPassword = comp.confirmPassword = passwordValues.newPassword; - // WHEN - comp.changePassword(); + // WHEN + comp.changePassword(); - // THEN - expect(service.save).toHaveBeenCalledWith(passwordValues.newPassword, passwordValues.currentPassword); - }); + // THEN + expect(service.save).toHaveBeenCalledWith(passwordValues.newPassword, passwordValues.currentPassword); + }); - it('should set success to OK upon success', function () { - // GIVEN - spyOn(service, 'save').and.returnValue(of(new HttpResponse({ body: true }))); - comp.newPassword = comp.confirmPassword = 'myPassword'; + it('should set success to OK upon success', function () { + // GIVEN + spyOn(service, 'save').and.returnValue(of(new HttpResponse({ body: true }))); + comp.newPassword = comp.confirmPassword = 'myPassword'; - // WHEN - comp.changePassword(); + // WHEN + comp.changePassword(); - // THEN - expect(comp.doNotMatch).toBeNull(); - expect(comp.error).toBeNull(); - expect(comp.success).toBe('OK'); - }); + // THEN + expect(comp.doNotMatch).toBeNull(); + expect(comp.error).toBeNull(); + expect(comp.success).toBe('OK'); + }); - it('should notify of error if change password fails', function () { - // GIVEN - spyOn(service, 'save').and.returnValue(throwError('ERROR')); - comp.newPassword = comp.confirmPassword = 'myPassword'; + it('should notify of error if change password fails', function () { + // GIVEN + spyOn(service, 'save').and.returnValue(throwError('ERROR')); + comp.newPassword = comp.confirmPassword = 'myPassword'; - // WHEN - comp.changePassword(); + // WHEN + comp.changePassword(); - // THEN - expect(comp.doNotMatch).toBeNull(); - expect(comp.success).toBeNull(); - expect(comp.error).toBe('ERROR'); - }); + // THEN + expect(comp.doNotMatch).toBeNull(); + expect(comp.success).toBeNull(); + expect(comp.error).toBe('ERROR'); }); }); diff --git a/src/test/javascript/spec/component/account/register.component.spec.ts b/src/test/javascript/spec/component/account/register.component.spec.ts index 790f16ea759b..a21605113343 100644 --- a/src/test/javascript/spec/component/account/register.component.spec.ts +++ b/src/test/javascript/spec/component/account/register.component.spec.ts @@ -8,114 +8,112 @@ import { EMAIL_ALREADY_USED_TYPE, LOGIN_ALREADY_USED_TYPE } from 'app/shared/con import { RegisterService } from 'app/account/register/register.service'; import { RegisterComponent } from 'app/account/register/register.component'; -describe('Component Tests', () => { - describe('RegisterComponent', () => { - let fixture: ComponentFixture; - let comp: RegisterComponent; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [RegisterComponent], - }) - .overrideTemplate(RegisterComponent, '') - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(RegisterComponent); - comp = fixture.componentInstance; - comp.ngOnInit(); - }); - - it('should ensure the two passwords entered match', () => { - comp.registerAccount.password = 'password'; - comp.confirmPassword = 'non-matching'; +describe('RegisterComponent', () => { + let fixture: ComponentFixture; + let comp: RegisterComponent; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [RegisterComponent], + }) + .overrideTemplate(RegisterComponent, '') + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(RegisterComponent); + comp = fixture.componentInstance; + comp.ngOnInit(); + }); - comp.register(); + it('should ensure the two passwords entered match', () => { + comp.registerAccount.password = 'password'; + comp.confirmPassword = 'non-matching'; - expect(comp.doNotMatch).toEqual('ERROR'); - }); - - it('should update success to OK after creating an account', inject( - [RegisterService, JhiLanguageService], - fakeAsync((service: RegisterService, mockTranslate: MockLanguageService) => { - spyOn(service, 'save').and.returnValue(of({})); - comp.registerAccount.password = comp.confirmPassword = 'password'; - - comp.register(); - tick(); - - expect(service.save).toHaveBeenCalledWith({ - password: 'password', - langKey: 'en', - }); - expect(comp.success).toEqual(true); - expect(comp.registerAccount.langKey).toEqual('en'); - expect(mockTranslate.getCurrentSpy).toHaveBeenCalled(); - expect(comp.errorUserExists).toBeNull(); - expect(comp.errorEmailExists).toBeNull(); - expect(comp.error).toBeNull(); - }), - )); - - it('should notify of user existence upon 400/login already in use', inject( - [RegisterService], - fakeAsync((service: RegisterService) => { - spyOn(service, 'save').and.returnValue( - throwError({ - status: 400, - error: { type: LOGIN_ALREADY_USED_TYPE }, - }), - ); - comp.registerAccount.password = comp.confirmPassword = 'password'; - - comp.register(); - tick(); - - expect(comp.errorUserExists).toEqual('ERROR'); - expect(comp.errorEmailExists).toBeNull(); - expect(comp.error).toBeNull(); - }), - )); - - it('should notify of email existence upon 400/email address already in use', inject( - [RegisterService], - fakeAsync((service: RegisterService) => { - spyOn(service, 'save').and.returnValue( - throwError({ - status: 400, - error: { type: EMAIL_ALREADY_USED_TYPE }, - }), - ); - comp.registerAccount.password = comp.confirmPassword = 'password'; - - comp.register(); - tick(); - - expect(comp.errorEmailExists).toEqual('ERROR'); - expect(comp.errorUserExists).toBeNull(); - expect(comp.error).toBeNull(); - }), - )); - - it('should notify of generic error', inject( - [RegisterService], - fakeAsync((service: RegisterService) => { - spyOn(service, 'save').and.returnValue( - throwError({ - status: 503, - }), - ); - comp.registerAccount.password = comp.confirmPassword = 'password'; - - comp.register(); - tick(); - - expect(comp.errorUserExists).toBeNull(); - expect(comp.errorEmailExists).toBeNull(); - expect(comp.error).toEqual('ERROR'); - }), - )); + comp.register(); + + expect(comp.doNotMatch).toEqual('ERROR'); }); + + it('should update success to OK after creating an account', inject( + [RegisterService, JhiLanguageService], + fakeAsync((service: RegisterService, mockTranslate: MockLanguageService) => { + spyOn(service, 'save').and.returnValue(of({})); + comp.registerAccount.password = comp.confirmPassword = 'password'; + + comp.register(); + tick(); + + expect(service.save).toHaveBeenCalledWith({ + password: 'password', + langKey: 'en', + }); + expect(comp.success).toEqual(true); + expect(comp.registerAccount.langKey).toEqual('en'); + expect(mockTranslate.getCurrentSpy).toHaveBeenCalled(); + expect(comp.errorUserExists).toBeNull(); + expect(comp.errorEmailExists).toBeNull(); + expect(comp.error).toBeNull(); + }), + )); + + it('should notify of user existence upon 400/login already in use', inject( + [RegisterService], + fakeAsync((service: RegisterService) => { + spyOn(service, 'save').and.returnValue( + throwError({ + status: 400, + error: { type: LOGIN_ALREADY_USED_TYPE }, + }), + ); + comp.registerAccount.password = comp.confirmPassword = 'password'; + + comp.register(); + tick(); + + expect(comp.errorUserExists).toEqual('ERROR'); + expect(comp.errorEmailExists).toBeNull(); + expect(comp.error).toBeNull(); + }), + )); + + it('should notify of email existence upon 400/email address already in use', inject( + [RegisterService], + fakeAsync((service: RegisterService) => { + spyOn(service, 'save').and.returnValue( + throwError({ + status: 400, + error: { type: EMAIL_ALREADY_USED_TYPE }, + }), + ); + comp.registerAccount.password = comp.confirmPassword = 'password'; + + comp.register(); + tick(); + + expect(comp.errorEmailExists).toEqual('ERROR'); + expect(comp.errorUserExists).toBeNull(); + expect(comp.error).toBeNull(); + }), + )); + + it('should notify of generic error', inject( + [RegisterService], + fakeAsync((service: RegisterService) => { + spyOn(service, 'save').and.returnValue( + throwError({ + status: 503, + }), + ); + comp.registerAccount.password = comp.confirmPassword = 'password'; + + comp.register(); + tick(); + + expect(comp.errorUserExists).toBeNull(); + expect(comp.errorEmailExists).toBeNull(); + expect(comp.error).toEqual('ERROR'); + }), + )); }); diff --git a/src/test/javascript/spec/component/admin/audits.component.spec.ts b/src/test/javascript/spec/component/admin/audits.component.spec.ts index 0a132ac6fe36..321c0508090a 100644 --- a/src/test/javascript/spec/component/admin/audits.component.spec.ts +++ b/src/test/javascript/spec/component/admin/audits.component.spec.ts @@ -30,74 +30,72 @@ function getDate(isToday = true) { return `${date.getFullYear()}-${monthString}-${dateString}`; } -describe('Component Tests', () => { - describe('AuditsComponent', () => { - let comp: AuditsComponent; - let fixture: ComponentFixture; - let service: AuditsService; +describe('AuditsComponent', () => { + let comp: AuditsComponent; + let fixture: ComponentFixture; + let service: AuditsService; - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [AuditsComponent], - providers: [AuditsService], - }) - .overrideTemplate(AuditsComponent, '') - .compileComponents(); - })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [AuditsComponent], + providers: [AuditsService], + }) + .overrideTemplate(AuditsComponent, '') + .compileComponents(); + })); - beforeEach(() => { - fixture = TestBed.createComponent(AuditsComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(AuditsService); - }); + beforeEach(() => { + fixture = TestBed.createComponent(AuditsComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(AuditsService); + }); - describe('today function ', () => { - it('should set toDate to current date', () => { - comp.today(); - expect(comp.toDate).toBe(getDate()); - }); + describe('today function ', () => { + it('should set toDate to current date', () => { + comp.today(); + expect(comp.toDate).toBe(getDate()); }); + }); - describe('previousMonth function ', () => { - it('should set fromDate to current date', () => { - comp.previousMonth(); - expect(comp.fromDate).toBe(getDate(false)); - }); + describe('previousMonth function ', () => { + it('should set fromDate to current date', () => { + comp.previousMonth(); + expect(comp.fromDate).toBe(getDate(false)); }); + }); - describe('By default, on init', () => { - it('should set all default values correctly', () => { - fixture.detectChanges(); - expect(comp.toDate).toBe(getDate()); - expect(comp.fromDate).toBe(getDate(false)); - expect(comp.itemsPerPage).toBe(ITEMS_PER_PAGE); - expect(comp.page).toBe(1); - expect(comp.reverse).toBeFalsy(); - }); + describe('By default, on init', () => { + it('should set all default values correctly', () => { + fixture.detectChanges(); + expect(comp.toDate).toBe(getDate()); + expect(comp.fromDate).toBe(getDate(false)); + expect(comp.itemsPerPage).toBe(ITEMS_PER_PAGE); + expect(comp.page).toBe(1); + expect(comp.reverse).toBeFalsy(); }); + }); - describe('OnInit', () => { - it('Should call load all on init', () => { - // GIVEN - const headers = new HttpHeaders().append('link', 'link;link'); - const audit = new Audit({ remoteAddress: '127.0.0.1', sessionId: '123' }, 'user', '20140101', 'AUTHENTICATION_SUCCESS'); - spyOn(service, 'query').and.returnValue( - of( - new HttpResponse({ - body: [audit], - headers, - }), - ), - ); + describe('OnInit', () => { + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + const audit = new Audit({ remoteAddress: '127.0.0.1', sessionId: '123' }, 'user', '20140101', 'AUTHENTICATION_SUCCESS'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [audit], + headers, + }), + ), + ); - // WHEN - comp.ngOnInit(); + // WHEN + comp.ngOnInit(); - // THEN - expect(service.query).toHaveBeenCalled(); - expect(comp.audits[0]).toEqual(jasmine.objectContaining(audit)); - }); + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.audits[0]).toEqual(jasmine.objectContaining(audit)); }); }); }); diff --git a/src/test/javascript/spec/component/admin/configuration.component.spec.ts b/src/test/javascript/spec/component/admin/configuration.component.spec.ts index b3dda0584372..e9cbb05ddf33 100644 --- a/src/test/javascript/spec/component/admin/configuration.component.spec.ts +++ b/src/test/javascript/spec/component/admin/configuration.component.spec.ts @@ -5,64 +5,62 @@ import { ArtemisTestModule } from '../../test.module'; import { JhiConfigurationComponent } from 'app/admin/configuration/configuration.component'; import { JhiConfigurationService } from 'app/admin/configuration/configuration.service'; -describe('Component Tests', () => { - describe('JhiConfigurationComponent', () => { - let comp: JhiConfigurationComponent; - let fixture: ComponentFixture; - let service: JhiConfigurationService; +describe('JhiConfigurationComponent', () => { + let comp: JhiConfigurationComponent; + let fixture: ComponentFixture; + let service: JhiConfigurationService; - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [JhiConfigurationComponent], - providers: [JhiConfigurationService], - }) - .overrideTemplate(JhiConfigurationComponent, '') - .compileComponents(); - })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [JhiConfigurationComponent], + providers: [JhiConfigurationService], + }) + .overrideTemplate(JhiConfigurationComponent, '') + .compileComponents(); + })); - beforeEach(() => { - fixture = TestBed.createComponent(JhiConfigurationComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(JhiConfigurationService); - }); + beforeEach(() => { + fixture = TestBed.createComponent(JhiConfigurationComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(JhiConfigurationService); + }); - describe('OnInit', () => { - it('should set all default values correctly', () => { - expect(comp.configKeys).toEqual([]); - expect(comp.filter).toBe(''); - expect(comp.orderProp).toBe('prefix'); - expect(comp.reverse).toBe(false); - }); - it('Should call load all on init', () => { - // GIVEN - const body = [{ config: 'test', properties: 'test' }, { config: 'test2' }]; - const envConfig = { envConfig: 'test' }; - spyOn(service, 'get').and.returnValue(of(body)); - spyOn(service, 'getEnv').and.returnValue(of(envConfig)); + describe('OnInit', () => { + it('should set all default values correctly', () => { + expect(comp.configKeys).toEqual([]); + expect(comp.filter).toBe(''); + expect(comp.orderProp).toBe('prefix'); + expect(comp.reverse).toBe(false); + }); + it('Should call load all on init', () => { + // GIVEN + const body = [{ config: 'test', properties: 'test' }, { config: 'test2' }]; + const envConfig = { envConfig: 'test' }; + spyOn(service, 'get').and.returnValue(of(body)); + spyOn(service, 'getEnv').and.returnValue(of(envConfig)); - // WHEN - comp.ngOnInit(); + // WHEN + comp.ngOnInit(); - // THEN - expect(service.get).toHaveBeenCalled(); - expect(service.getEnv).toHaveBeenCalled(); - expect(comp.configKeys).toEqual([['0', '1', '2', '3']]); - expect(comp.allConfiguration).toEqual(envConfig); - }); + // THEN + expect(service.get).toHaveBeenCalled(); + expect(service.getEnv).toHaveBeenCalled(); + expect(comp.configKeys).toEqual([['0', '1', '2', '3']]); + expect(comp.allConfiguration).toEqual(envConfig); }); - describe('keys method', () => { - it('should return the keys of an Object', () => { - // GIVEN - const data = { - key1: 'test', - key2: 'test2', - }; + }); + describe('keys method', () => { + it('should return the keys of an Object', () => { + // GIVEN + const data = { + key1: 'test', + key2: 'test2', + }; - // THEN - expect(comp.keys(data)).toEqual(['key1', 'key2']); - expect(comp.keys(undefined)).toEqual([]); - }); + // THEN + expect(comp.keys(data)).toEqual(['key1', 'key2']); + expect(comp.keys(undefined)).toEqual([]); }); }); }); diff --git a/src/test/javascript/spec/component/admin/health.component.spec.ts b/src/test/javascript/spec/component/admin/health.component.spec.ts index 78e2e56230bc..841c8c164dda 100644 --- a/src/test/javascript/spec/component/admin/health.component.spec.ts +++ b/src/test/javascript/spec/component/admin/health.component.spec.ts @@ -6,62 +6,60 @@ import { ArtemisTestModule } from '../../test.module'; import { HealthComponent } from 'app/admin/health/health.component'; import { Health, HealthService } from 'app/admin/health/health.service'; -describe('Component Tests', () => { - describe('HealthComponent', () => { - let comp: HealthComponent; - let fixture: ComponentFixture; - let service: HealthService; +describe('HealthComponent', () => { + let comp: HealthComponent; + let fixture: ComponentFixture; + let service: HealthService; - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [HealthComponent], - }) - .overrideTemplate(HealthComponent, '') - .compileComponents(); - })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [HealthComponent], + }) + .overrideTemplate(HealthComponent, '') + .compileComponents(); + })); - beforeEach(() => { - fixture = TestBed.createComponent(HealthComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(HealthService); - }); + beforeEach(() => { + fixture = TestBed.createComponent(HealthComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(HealthService); + }); - describe('getBadgeClass', () => { - it('should get badge class', () => { - const upBadgeClass = comp.getBadgeClass('UP'); - const downBadgeClass = comp.getBadgeClass('DOWN'); - expect(upBadgeClass).toEqual('badge-success'); - expect(downBadgeClass).toEqual('badge-danger'); - }); + describe('getBadgeClass', () => { + it('should get badge class', () => { + const upBadgeClass = comp.getBadgeClass('UP'); + const downBadgeClass = comp.getBadgeClass('DOWN'); + expect(upBadgeClass).toEqual('badge-success'); + expect(downBadgeClass).toEqual('badge-danger'); }); + }); - describe('refresh', () => { - it('should call refresh on init', () => { - // GIVEN - const health: Health = { status: 'UP', components: { mail: { status: 'UP', details: 'mailDetails' } } }; - spyOn(service, 'checkHealth').and.returnValue(of(health)); + describe('refresh', () => { + it('should call refresh on init', () => { + // GIVEN + const health: Health = { status: 'UP', components: { mail: { status: 'UP', details: 'mailDetails' } } }; + spyOn(service, 'checkHealth').and.returnValue(of(health)); - // WHEN - comp.ngOnInit(); + // WHEN + comp.ngOnInit(); - // THEN - expect(service.checkHealth).toHaveBeenCalled(); - expect(comp.health).toEqual(health); - }); + // THEN + expect(service.checkHealth).toHaveBeenCalled(); + expect(comp.health).toEqual(health); + }); - it('should handle a 503 on refreshing health data', () => { - // GIVEN - const health: Health = { status: 'DOWN', components: { mail: { status: 'DOWN', details: 'mailDetails' } } }; - spyOn(service, 'checkHealth').and.returnValue(throwError(new HttpErrorResponse({ status: 503, error: health }))); + it('should handle a 503 on refreshing health data', () => { + // GIVEN + const health: Health = { status: 'DOWN', components: { mail: { status: 'DOWN', details: 'mailDetails' } } }; + spyOn(service, 'checkHealth').and.returnValue(throwError(new HttpErrorResponse({ status: 503, error: health }))); - // WHEN - comp.refresh(); + // WHEN + comp.refresh(); - // THEN - expect(service.checkHealth).toHaveBeenCalled(); - expect(comp.health).toEqual(health); - }); + // THEN + expect(service.checkHealth).toHaveBeenCalled(); + expect(comp.health).toEqual(health); }); }); }); diff --git a/src/test/javascript/spec/component/admin/logs.component.spec.ts b/src/test/javascript/spec/component/admin/logs.component.spec.ts index 2d553670771c..5c525e762ed2 100644 --- a/src/test/javascript/spec/component/admin/logs.component.spec.ts +++ b/src/test/javascript/spec/component/admin/logs.component.spec.ts @@ -7,70 +7,68 @@ import { LogsComponent } from 'app/admin/logs/logs.component'; import { LogsService } from 'app/admin/logs/logs.service'; import { Log } from 'app/admin/logs/log.model'; -describe('Component Tests', () => { - describe('LogsComponent', () => { - let comp: LogsComponent; - let fixture: ComponentFixture; - let service: LogsService; +describe('LogsComponent', () => { + let comp: LogsComponent; + let fixture: ComponentFixture; + let service: LogsService; - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [LogsComponent], - providers: [LogsService], - }) - .overrideTemplate(LogsComponent, '') - .compileComponents(); - })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [LogsComponent], + providers: [LogsService], + }) + .overrideTemplate(LogsComponent, '') + .compileComponents(); + })); - beforeEach(() => { - fixture = TestBed.createComponent(LogsComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(LogsService); - }); + beforeEach(() => { + fixture = TestBed.createComponent(LogsComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(LogsService); + }); - describe('OnInit', () => { - it('should set all default values correctly', () => { - expect(comp.filter).toBe(''); - expect(comp.orderProp).toBe('name'); - expect(comp.reverse).toBe(false); - }); - it('Should call load all on init', () => { - // GIVEN - const headers = new HttpHeaders().append('link', 'link;link'); - const log = new Log('main', 'WARN'); - spyOn(service, 'findAll').and.returnValue( - of( - new HttpResponse({ - body: [log], - headers, - }), - ), - ); + describe('OnInit', () => { + it('should set all default values correctly', () => { + expect(comp.filter).toBe(''); + expect(comp.orderProp).toBe('name'); + expect(comp.reverse).toBe(false); + }); + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + const log = new Log('main', 'WARN'); + spyOn(service, 'findAll').and.returnValue( + of( + new HttpResponse({ + body: [log], + headers, + }), + ), + ); - // WHEN - comp.ngOnInit(); + // WHEN + comp.ngOnInit(); - // THEN - expect(service.findAll).toHaveBeenCalled(); - expect(comp.loggers[0]).toEqual(jasmine.objectContaining(log)); - }); + // THEN + expect(service.findAll).toHaveBeenCalled(); + expect(comp.loggers[0]).toEqual(jasmine.objectContaining(log)); }); - describe('change log level', () => { - it('should change log level correctly', () => { - // GIVEN - const log = new Log('main', 'ERROR'); - spyOn(service, 'changeLevel').and.returnValue(of(new HttpResponse())); - spyOn(service, 'findAll').and.returnValue(of(new HttpResponse({ body: [log] }))); + }); + describe('change log level', () => { + it('should change log level correctly', () => { + // GIVEN + const log = new Log('main', 'ERROR'); + spyOn(service, 'changeLevel').and.returnValue(of(new HttpResponse())); + spyOn(service, 'findAll').and.returnValue(of(new HttpResponse({ body: [log] }))); - // WHEN - comp.changeLevel('main', 'ERROR'); + // WHEN + comp.changeLevel('main', 'ERROR'); - // THEN - expect(service.changeLevel).toHaveBeenCalled(); - expect(service.findAll).toHaveBeenCalled(); - expect(comp.loggers[0]).toEqual(jasmine.objectContaining(log)); - }); + // THEN + expect(service.changeLevel).toHaveBeenCalled(); + expect(service.findAll).toHaveBeenCalled(); + expect(comp.loggers[0]).toEqual(jasmine.objectContaining(log)); }); }); }); diff --git a/src/test/javascript/spec/component/admin/metrics.component.spec.ts b/src/test/javascript/spec/component/admin/metrics.component.spec.ts index 785c685a2ba9..daa0acc85f0f 100644 --- a/src/test/javascript/spec/component/admin/metrics.component.spec.ts +++ b/src/test/javascript/spec/component/admin/metrics.component.spec.ts @@ -5,50 +5,48 @@ import { ArtemisTestModule } from '../../test.module'; import { JhiMetricsMonitoringComponent } from 'app/admin/metrics/metrics.component'; import { JhiMetricsService } from 'app/admin/metrics/metrics.service'; -describe('Component Tests', () => { - describe('JhiMetricsMonitoringComponent', () => { - let comp: JhiMetricsMonitoringComponent; - let fixture: ComponentFixture; - let service: JhiMetricsService; +describe('JhiMetricsMonitoringComponent', () => { + let comp: JhiMetricsMonitoringComponent; + let fixture: ComponentFixture; + let service: JhiMetricsService; - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [JhiMetricsMonitoringComponent], - }) - .overrideTemplate(JhiMetricsMonitoringComponent, '') - .compileComponents(); - })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [JhiMetricsMonitoringComponent], + }) + .overrideTemplate(JhiMetricsMonitoringComponent, '') + .compileComponents(); + })); - beforeEach(() => { - fixture = TestBed.createComponent(JhiMetricsMonitoringComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(JhiMetricsService); - }); + beforeEach(() => { + fixture = TestBed.createComponent(JhiMetricsMonitoringComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(JhiMetricsService); + }); - describe('refresh', () => { - it('should call refresh on init', () => { - // GIVEN - const response = { - timers: { - service: 'test', - unrelatedKey: 'test', - }, - gauges: { - 'jcache.statistics': { - value: 2, - }, - unrelatedKey: 'test', + describe('refresh', () => { + it('should call refresh on init', () => { + // GIVEN + const response = { + timers: { + service: 'test', + unrelatedKey: 'test', + }, + gauges: { + 'jcache.statistics': { + value: 2, }, - }; - spyOn(service, 'getMetrics').and.returnValue(of(response)); + unrelatedKey: 'test', + }, + }; + spyOn(service, 'getMetrics').and.returnValue(of(response)); - // WHEN - comp.ngOnInit(); + // WHEN + comp.ngOnInit(); - // THEN - expect(service.getMetrics).toHaveBeenCalled(); - }); + // THEN + expect(service.getMetrics).toHaveBeenCalled(); }); }); }); diff --git a/src/test/javascript/spec/component/admin/user-management-detail.component.spec.ts b/src/test/javascript/spec/component/admin/user-management-detail.component.spec.ts index d3ed930ed965..a1a08af7fec9 100644 --- a/src/test/javascript/spec/component/admin/user-management-detail.component.spec.ts +++ b/src/test/javascript/spec/component/admin/user-management-detail.component.spec.ts @@ -6,64 +6,62 @@ import { ArtemisTestModule } from '../../test.module'; import { UserManagementDetailComponent } from 'app/admin/user-management/user-management-detail.component'; import { User } from 'app/core/user/user.model'; -describe('Component Tests', () => { - describe('User Management Detail Component', () => { - let comp: UserManagementDetailComponent; - let fixture: ComponentFixture; - const route = ({ - data: of({ user: new User(1, 'user', 'first', 'last', 'first@last.com', true, 'en', ['ROLE_USER'], 'admin', null, null, null) }), - } as any) as ActivatedRoute; +describe('User Management Detail Component', () => { + let comp: UserManagementDetailComponent; + let fixture: ComponentFixture; + const route = ({ + data: of({ user: new User(1, 'user', 'first', 'last', 'first@last.com', true, 'en', ['ROLE_USER'], 'admin', null, null, null) }), + } as any) as ActivatedRoute; - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [UserManagementDetailComponent], - providers: [ - { - provide: ActivatedRoute, - useValue: route, - }, - ], - }) - .overrideTemplate(UserManagementDetailComponent, '') - .compileComponents(); - })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [UserManagementDetailComponent], + providers: [ + { + provide: ActivatedRoute, + useValue: route, + }, + ], + }) + .overrideTemplate(UserManagementDetailComponent, '') + .compileComponents(); + })); - beforeEach(() => { - fixture = TestBed.createComponent(UserManagementDetailComponent); - comp = fixture.componentInstance; - }); + beforeEach(() => { + fixture = TestBed.createComponent(UserManagementDetailComponent); + comp = fixture.componentInstance; + }); - describe('OnInit', () => { - it('Should call load all on init', () => { - // GIVEN + describe('OnInit', () => { + it('Should call load all on init', () => { + // GIVEN - // WHEN - comp.ngOnInit(); + // WHEN + comp.ngOnInit(); - // THEN - expect(comp.user).toEqual( - jasmine.objectContaining({ - id: 1, - login: 'user', - firstName: 'first', - lastName: 'last', - email: 'first@last.com', - activated: true, - langKey: 'en', - authorities: ['ROLE_USER'], - createdBy: null, - createdDate: null, - lastModifiedBy: null, - lastModifiedDate: null, - password: null, - groups: 'admin', - guidedTourSettings: [], - imageUrl: null, - lastNotificationRead: null, - }), - ); - }); + // THEN + expect(comp.user).toEqual( + jasmine.objectContaining({ + id: 1, + login: 'user', + firstName: 'first', + lastName: 'last', + email: 'first@last.com', + activated: true, + langKey: 'en', + authorities: ['ROLE_USER'], + createdBy: null, + createdDate: null, + lastModifiedBy: null, + lastModifiedDate: null, + password: null, + groups: 'admin', + guidedTourSettings: [], + imageUrl: null, + lastNotificationRead: null, + }), + ); }); }); }); diff --git a/src/test/javascript/spec/component/admin/user-management-update.component.spec.ts b/src/test/javascript/spec/component/admin/user-management-update.component.spec.ts index 18d0dc09f8c6..8255a43c7e53 100644 --- a/src/test/javascript/spec/component/admin/user-management-update.component.spec.ts +++ b/src/test/javascript/spec/component/admin/user-management-update.component.spec.ts @@ -9,96 +9,94 @@ import { User } from 'app/core/user/user.model'; import { JhiLanguageHelper } from 'app/core/language/language.helper'; import { UserService } from 'app/core/user/user.service'; -describe('Component Tests', () => { - describe('User Management Update Component', () => { - let comp: UserManagementUpdateComponent; - let fixture: ComponentFixture; - let service: UserService; - let mockLanguageHelper: any; - const route = ({ - data: of({ user: new User(1, 'user', 'first', 'last', 'first@last.com', true, 'en', ['ROLE_USER'], 'admin', null, null, null) }), - } as any) as ActivatedRoute; +describe('User Management Update Component', () => { + let comp: UserManagementUpdateComponent; + let fixture: ComponentFixture; + let service: UserService; + let mockLanguageHelper: any; + const route = ({ + data: of({ user: new User(1, 'user', 'first', 'last', 'first@last.com', true, 'en', ['ROLE_USER'], 'admin', null, null, null) }), + } as any) as ActivatedRoute; - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [UserManagementUpdateComponent], - providers: [ - { - provide: ActivatedRoute, - useValue: route, - }, - ], - }) - .overrideTemplate(UserManagementUpdateComponent, '') - .compileComponents(); - })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [UserManagementUpdateComponent], + providers: [ + { + provide: ActivatedRoute, + useValue: route, + }, + ], + }) + .overrideTemplate(UserManagementUpdateComponent, '') + .compileComponents(); + })); - beforeEach(() => { - fixture = TestBed.createComponent(UserManagementUpdateComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(UserService); - mockLanguageHelper = fixture.debugElement.injector.get(JhiLanguageHelper); - }); + beforeEach(() => { + fixture = TestBed.createComponent(UserManagementUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(UserService); + mockLanguageHelper = fixture.debugElement.injector.get(JhiLanguageHelper); + }); - describe('OnInit', () => { - it('Should load authorities and language on init', inject( - [], - fakeAsync(() => { - // GIVEN - spyOn(service, 'authorities').and.returnValue(of(['USER'])); + describe('OnInit', () => { + it('Should load authorities and language on init', inject( + [], + fakeAsync(() => { + // GIVEN + spyOn(service, 'authorities').and.returnValue(of(['USER'])); - // WHEN - comp.ngOnInit(); + // WHEN + comp.ngOnInit(); - // THEN - expect(service.authorities).toHaveBeenCalled(); - expect(comp.authorities).toEqual(['USER']); - expect(mockLanguageHelper.getAllSpy).toHaveBeenCalled(); - }), - )); - }); + // THEN + expect(service.authorities).toHaveBeenCalled(); + expect(comp.authorities).toEqual(['USER']); + expect(mockLanguageHelper.getAllSpy).toHaveBeenCalled(); + }), + )); + }); - describe('save', () => { - it('Should call update service on save for existing user', inject( - [], - fakeAsync(() => { - // GIVEN - const entity = new User(123); - spyOn(service, 'update').and.returnValue( - of( - new HttpResponse({ - body: entity, - }), - ), - ); - comp.user = entity; - // WHEN - comp.save(); - tick(); // simulate async + describe('save', () => { + it('Should call update service on save for existing user', inject( + [], + fakeAsync(() => { + // GIVEN + const entity = new User(123); + spyOn(service, 'update').and.returnValue( + of( + new HttpResponse({ + body: entity, + }), + ), + ); + comp.user = entity; + // WHEN + comp.save(); + tick(); // simulate async - // THEN - expect(service.update).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - }), - )); + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + }), + )); - it('Should call create service on save for new user', inject( - [], - fakeAsync(() => { - // GIVEN - const entity = new User(); - spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.user = entity; - // WHEN - comp.save(); - tick(); // simulate async + it('Should call create service on save for new user', inject( + [], + fakeAsync(() => { + // GIVEN + const entity = new User(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.user = entity; + // WHEN + comp.save(); + tick(); // simulate async - // THEN - expect(service.create).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - }), - )); - }); + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + }), + )); }); }); diff --git a/src/test/javascript/spec/component/course/course-update.component.spec.ts b/src/test/javascript/spec/component/course/course-update.component.spec.ts index 9c9c71364db5..5dc34699547c 100644 --- a/src/test/javascript/spec/component/course/course-update.component.spec.ts +++ b/src/test/javascript/spec/component/course/course-update.component.spec.ts @@ -7,56 +7,54 @@ import { CourseUpdateComponent } from 'app/course/manage/course-update.component import { CourseManagementService } from 'app/course/manage/course-management.service'; import { Course } from 'app/entities/course.model'; -describe('Component Tests', () => { - describe('Course Management Update Component', () => { - let comp: CourseUpdateComponent; - let fixture: ComponentFixture; - let service: CourseManagementService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [CourseUpdateComponent], - }) - .overrideTemplate(CourseUpdateComponent, '') - .compileComponents(); - - fixture = TestBed.createComponent(CourseUpdateComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(CourseManagementService); - }); - - describe('save', () => { - it('Should call update service on save for existing entity', fakeAsync(() => { - // GIVEN - const entity = new Course(); - entity.id = 123; - spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.course = entity; - comp.courseForm = { value: entity }; // mocking reactive form - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.update).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - })); - - it('Should call create service on save for new entity', fakeAsync(() => { - // GIVEN - const entity = new Course(); - spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.course = entity; - comp.courseForm = { value: entity }; // mocking reactive form - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.create).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - })); - }); +describe('Course Management Update Component', () => { + let comp: CourseUpdateComponent; + let fixture: ComponentFixture; + let service: CourseManagementService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [CourseUpdateComponent], + }) + .overrideTemplate(CourseUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(CourseUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(CourseManagementService); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', fakeAsync(() => { + // GIVEN + const entity = new Course(); + entity.id = 123; + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.course = entity; + comp.courseForm = { value: entity }; // mocking reactive form + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + + it('Should call create service on save for new entity', fakeAsync(() => { + // GIVEN + const entity = new Course(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.course = entity; + comp.courseForm = { value: entity }; // mocking reactive form + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); }); }); diff --git a/src/test/javascript/spec/component/exercise-hint/exercise-hint-detail.component.spec.ts b/src/test/javascript/spec/component/exercise-hint/exercise-hint-detail.component.spec.ts index 0acafe6c6088..fde2e991660c 100644 --- a/src/test/javascript/spec/component/exercise-hint/exercise-hint-detail.component.spec.ts +++ b/src/test/javascript/spec/component/exercise-hint/exercise-hint-detail.component.spec.ts @@ -1,4 +1,3 @@ -/* tslint:disable max-line-length */ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ActivatedRoute } from '@angular/router'; import { of } from 'rxjs'; @@ -7,36 +6,34 @@ import { ExerciseHintDetailComponent } from 'app/exercises/shared/exercise-hint/ import { ExerciseHint } from 'app/entities/exercise-hint.model'; import { ArtemisTestModule } from '../../test.module'; -describe('Component Tests', () => { - describe('ExerciseHint Management Detail Component', () => { - let comp: ExerciseHintDetailComponent; - let fixture: ComponentFixture; - const exerciseHint = new ExerciseHint(); - exerciseHint.id = 123; - const route = ({ data: of({ exerciseHint }), params: of({ exerciseId: 1 }) } as any) as ActivatedRoute; +describe('ExerciseHint Management Detail Component', () => { + let comp: ExerciseHintDetailComponent; + let fixture: ComponentFixture; + const exerciseHint = new ExerciseHint(); + exerciseHint.id = 123; + const route = ({ data: of({ exerciseHint }), params: of({ exerciseId: 1 }) } as any) as ActivatedRoute; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [ExerciseHintDetailComponent], - providers: [{ provide: ActivatedRoute, useValue: route }], - }) - .overrideTemplate(ExerciseHintDetailComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(ExerciseHintDetailComponent); - comp = fixture.componentInstance; - }); + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [ExerciseHintDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }], + }) + .overrideTemplate(ExerciseHintDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(ExerciseHintDetailComponent); + comp = fixture.componentInstance; + }); - describe('OnInit', () => { - it('Should call load all on init', () => { - // GIVEN + describe('OnInit', () => { + it('Should call load all on init', () => { + // GIVEN - // WHEN - comp.ngOnInit(); + // WHEN + comp.ngOnInit(); - // THEN - expect(comp.exerciseHint).toEqual(jasmine.objectContaining({ id: 123 })); - }); + // THEN + expect(comp.exerciseHint).toEqual(jasmine.objectContaining({ id: 123 })); }); }); }); diff --git a/src/test/javascript/spec/component/exercise-hint/exercise-hint-update.component.spec.ts b/src/test/javascript/spec/component/exercise-hint/exercise-hint-update.component.spec.ts index 739fc921ede2..0d7d3e956ea5 100644 --- a/src/test/javascript/spec/component/exercise-hint/exercise-hint-update.component.spec.ts +++ b/src/test/javascript/spec/component/exercise-hint/exercise-hint-update.component.spec.ts @@ -1,4 +1,3 @@ -/* tslint:disable max-line-length */ import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; import { HttpResponse } from '@angular/common/http'; import { FormBuilder } from '@angular/forms'; @@ -9,55 +8,53 @@ import { ExerciseHintService } from 'app/exercises/shared/exercise-hint/manage/e import { ExerciseHint } from 'app/entities/exercise-hint.model'; import { ArtemisTestModule } from '../../test.module'; -describe('Component Tests', () => { - describe('ExerciseHint Management Update Component', () => { - let comp: ExerciseHintUpdateComponent; - let fixture: ComponentFixture; - let service: ExerciseHintService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [ExerciseHintUpdateComponent], - providers: [FormBuilder], - }) - .overrideTemplate(ExerciseHintUpdateComponent, '') - .compileComponents(); - - fixture = TestBed.createComponent(ExerciseHintUpdateComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ExerciseHintService); - }); - - describe('save', () => { - it('Should call update service on save for existing entity', fakeAsync(() => { - // GIVEN - const entity = new ExerciseHint(); - entity.id = 123; - spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.exerciseHint = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.update).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - })); - - it('Should call create service on save for new entity', fakeAsync(() => { - // GIVEN - const entity = new ExerciseHint(); - spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.exerciseHint = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.create).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - })); - }); +describe('ExerciseHint Management Update Component', () => { + let comp: ExerciseHintUpdateComponent; + let fixture: ComponentFixture; + let service: ExerciseHintService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [ExerciseHintUpdateComponent], + providers: [FormBuilder], + }) + .overrideTemplate(ExerciseHintUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(ExerciseHintUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(ExerciseHintService); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', fakeAsync(() => { + // GIVEN + const entity = new ExerciseHint(); + entity.id = 123; + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.exerciseHint = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + + it('Should call create service on save for new entity', fakeAsync(() => { + // GIVEN + const entity = new ExerciseHint(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.exerciseHint = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); }); }); diff --git a/src/test/javascript/spec/component/exercise-hint/exercise-hint.component.spec.ts b/src/test/javascript/spec/component/exercise-hint/exercise-hint.component.spec.ts index fe92550613d1..ae8cf3ae9922 100644 --- a/src/test/javascript/spec/component/exercise-hint/exercise-hint.component.spec.ts +++ b/src/test/javascript/spec/component/exercise-hint/exercise-hint.component.spec.ts @@ -1,4 +1,3 @@ -/* tslint:disable max-line-length */ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { of } from 'rxjs'; import { HttpHeaders, HttpResponse } from '@angular/common/http'; @@ -8,47 +7,45 @@ import { ExerciseHintService } from 'app/exercises/shared/exercise-hint/manage/e import { ExerciseHint } from 'app/entities/exercise-hint.model'; import { ArtemisTestModule } from '../../test.module'; -describe('Component Tests', () => { - describe('ExerciseHint Management Component', () => { - let comp: ExerciseHintComponent; - let fixture: ComponentFixture; - let service: ExerciseHintService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [ExerciseHintComponent], - providers: [], - }) - .overrideTemplate(ExerciseHintComponent, '') - .compileComponents(); - - fixture = TestBed.createComponent(ExerciseHintComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ExerciseHintService); - }); - - it('Should call load all on init', () => { - // GIVEN - const headers = new HttpHeaders().append('link', 'link;link'); - const hint = new ExerciseHint(); - hint.id = 123; - - spyOn(service, 'findByExerciseId').and.returnValue( - of( - new HttpResponse({ - body: [hint], - headers, - }), - ), - ); - - // WHEN - comp.ngOnInit(); - - // THEN - expect(service.findByExerciseId).toHaveBeenCalled(); - expect(comp.exerciseHints[0]).toEqual(jasmine.objectContaining({ id: 123 })); - }); +describe('ExerciseHint Management Component', () => { + let comp: ExerciseHintComponent; + let fixture: ComponentFixture; + let service: ExerciseHintService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [ExerciseHintComponent], + providers: [], + }) + .overrideTemplate(ExerciseHintComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(ExerciseHintComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(ExerciseHintService); + }); + + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + const hint = new ExerciseHint(); + hint.id = 123; + + spyOn(service, 'findByExerciseId').and.returnValue( + of( + new HttpResponse({ + body: [hint], + headers, + }), + ), + ); + + // WHEN + comp.ngOnInit(); + + // THEN + expect(service.findByExerciseId).toHaveBeenCalled(); + expect(comp.exerciseHints[0]).toEqual(jasmine.objectContaining({ id: 123 })); }); }); diff --git a/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise-detail.component.spec.ts b/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise-detail.component.spec.ts index 803838628bf6..c19a0d6f5792 100644 --- a/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise-detail.component.spec.ts +++ b/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise-detail.component.spec.ts @@ -24,55 +24,53 @@ import { AssessmentInstructionsModule } from 'app/assessment/assessment-instruct chai.use(sinonChai); const expect = chai.expect; -describe('Component Tests', () => { - describe('FileUploadExercise Management Detail Component', () => { - let comp: FileUploadExerciseDetailComponent; - let fixture: ComponentFixture; - let debugElement: DebugElement; +describe('FileUploadExercise Management Detail Component', () => { + let comp: FileUploadExerciseDetailComponent; + let fixture: ComponentFixture; + let debugElement: DebugElement; - const route = ({ - data: of({ fileUploadExercise }), - params: of({ exerciseId: 2 }), - } as any) as ActivatedRoute; + const route = ({ + data: of({ fileUploadExercise }), + params: of({ exerciseId: 2 }), + } as any) as ActivatedRoute; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule, ArtemisSharedModule, ArtemisAssessmentSharedModule, RouterTestingModule, TranslateModule.forRoot(), AssessmentInstructionsModule], - declarations: [FileUploadExerciseDetailComponent], - providers: [ - JhiLanguageHelper, - AlertService, - { provide: ActivatedRoute, useValue: route }, - { provide: FileUploadExerciseService, useClass: MockFileUploadExerciseService }, - { provide: LocalStorageService, useClass: MockSyncStorage }, - { provide: SessionStorageService, useClass: MockSyncStorage }, - { provide: CookieService, useClass: MockCookieService }, - ], - }) - .overrideModule(ArtemisTestModule, { set: { declarations: [], exports: [] } }) - .compileComponents(); - fixture = TestBed.createComponent(FileUploadExerciseDetailComponent); - comp = fixture.componentInstance; - debugElement = fixture.debugElement; - }); + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule, ArtemisSharedModule, ArtemisAssessmentSharedModule, RouterTestingModule, TranslateModule.forRoot(), AssessmentInstructionsModule], + declarations: [FileUploadExerciseDetailComponent], + providers: [ + JhiLanguageHelper, + AlertService, + { provide: ActivatedRoute, useValue: route }, + { provide: FileUploadExerciseService, useClass: MockFileUploadExerciseService }, + { provide: LocalStorageService, useClass: MockSyncStorage }, + { provide: SessionStorageService, useClass: MockSyncStorage }, + { provide: CookieService, useClass: MockCookieService }, + ], + }) + .overrideModule(ArtemisTestModule, { set: { declarations: [], exports: [] } }) + .compileComponents(); + fixture = TestBed.createComponent(FileUploadExerciseDetailComponent); + comp = fixture.componentInstance; + debugElement = fixture.debugElement; + }); - describe('Title should contain exercise id and description list', () => { - it('Should call load all on init', fakeAsync(() => { - comp.ngOnInit(); - tick(); + describe('Title should contain exercise id and description list', () => { + it('Should call load all on init', fakeAsync(() => { + comp.ngOnInit(); + tick(); - expect(comp.fileUploadExercise).to.equal(fileUploadExercise); + expect(comp.fileUploadExercise).to.equal(fileUploadExercise); - fixture.detectChanges(); + fixture.detectChanges(); - const title = debugElement.query(By.css('h2')); - expect(title).to.exist; - const h2: HTMLElement = title.nativeElement; - expect(h2.textContent!.endsWith(fileUploadExercise.id.toString())).to.be.true; + const title = debugElement.query(By.css('h2')); + expect(title).to.exist; + const h2: HTMLElement = title.nativeElement; + expect(h2.textContent!.endsWith(fileUploadExercise.id.toString())).to.be.true; - const descList = debugElement.query(By.css('dl')); - expect(descList).to.exist; - })); - }); + const descList = debugElement.query(By.css('dl')); + expect(descList).to.exist; + })); }); }); diff --git a/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise-update.component.spec.ts b/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise-update.component.spec.ts index 4dde81a2c37e..f84ac7ab9dd3 100644 --- a/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise-update.component.spec.ts +++ b/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise-update.component.spec.ts @@ -7,53 +7,51 @@ import { FileUploadExerciseUpdateComponent } from 'app/exercises/file-upload/man import { FileUploadExerciseService } from 'app/exercises/file-upload/manage/file-upload-exercise.service'; import { FileUploadExercise } from 'app/entities/file-upload-exercise.model'; -describe('Component Tests', () => { - describe('FileUploadExercise Management Update Component', () => { - let comp: FileUploadExerciseUpdateComponent; - let fixture: ComponentFixture; - let service: FileUploadExerciseService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [FileUploadExerciseUpdateComponent], - }) - .overrideTemplate(FileUploadExerciseUpdateComponent, '') - .compileComponents(); - - fixture = TestBed.createComponent(FileUploadExerciseUpdateComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(FileUploadExerciseService); - }); - - describe('save', () => { - it('Should call update service on save for existing entity', fakeAsync(() => { - // GIVEN - const entity = new FileUploadExercise(123); - spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.fileUploadExercise = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.update).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - })); - - it('Should call create service on save for new entity', fakeAsync(() => { - // GIVEN - const entity = new FileUploadExercise(); - spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.fileUploadExercise = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.create).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - })); - }); +describe('FileUploadExercise Management Update Component', () => { + let comp: FileUploadExerciseUpdateComponent; + let fixture: ComponentFixture; + let service: FileUploadExerciseService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [FileUploadExerciseUpdateComponent], + }) + .overrideTemplate(FileUploadExerciseUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(FileUploadExerciseUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(FileUploadExerciseService); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', fakeAsync(() => { + // GIVEN + const entity = new FileUploadExercise(123); + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.fileUploadExercise = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + + it('Should call create service on save for new entity', fakeAsync(() => { + // GIVEN + const entity = new FileUploadExercise(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.fileUploadExercise = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); }); }); diff --git a/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise.component.spec.ts b/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise.component.spec.ts index 653761af2f93..6b36badff668 100644 --- a/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise.component.spec.ts +++ b/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise.component.spec.ts @@ -7,44 +7,42 @@ import { FileUploadExerciseComponent } from 'app/exercises/file-upload/manage/fi import { FileUploadExerciseService } from 'app/exercises/file-upload/manage/file-upload-exercise.service'; import { FileUploadExercise } from 'app/entities/file-upload-exercise.model'; -describe('Component Tests', () => { - describe('FileUploadExercise Management Component', () => { - let comp: FileUploadExerciseComponent; - let fixture: ComponentFixture; - let service: FileUploadExerciseService; +describe('FileUploadExercise Management Component', () => { + let comp: FileUploadExerciseComponent; + let fixture: ComponentFixture; + let service: FileUploadExerciseService; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [FileUploadExerciseComponent], - providers: [], - }) - .overrideTemplate(FileUploadExerciseComponent, '') - .compileComponents(); + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [FileUploadExerciseComponent], + providers: [], + }) + .overrideTemplate(FileUploadExerciseComponent, '') + .compileComponents(); - fixture = TestBed.createComponent(FileUploadExerciseComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(FileUploadExerciseService); - }); + fixture = TestBed.createComponent(FileUploadExerciseComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(FileUploadExerciseService); + }); - it('Should call load all on init', () => { - // GIVEN - const headers = new HttpHeaders().append('link', 'link;link'); - spyOn(service, 'query').and.returnValue( - of( - new HttpResponse({ - body: [new FileUploadExercise(123)], - headers, - }), - ), - ); + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new FileUploadExercise(123)], + headers, + }), + ), + ); - // WHEN - comp.ngOnInit(); + // WHEN + comp.ngOnInit(); - // THEN - expect(service.query).toHaveBeenCalled(); - expect(comp.fileUploadExercises[0]).toEqual(jasmine.objectContaining({ id: 123 })); - }); + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.fileUploadExercises[0]).toEqual(jasmine.objectContaining({ id: 123 })); }); }); diff --git a/src/test/javascript/spec/component/modeling-exercise/modeling-exercise-detail.component.spec.ts b/src/test/javascript/spec/component/modeling-exercise/modeling-exercise-detail.component.spec.ts index 2ea241449d8e..371088024a1b 100644 --- a/src/test/javascript/spec/component/modeling-exercise/modeling-exercise-detail.component.spec.ts +++ b/src/test/javascript/spec/component/modeling-exercise/modeling-exercise-detail.component.spec.ts @@ -6,34 +6,32 @@ import { ArtemisTestModule } from '../../test.module'; import { ModelingExerciseDetailComponent } from 'app/exercises/modeling/manage/modeling-exercise-detail.component'; import { ModelingExercise } from 'app/entities/modeling-exercise.model'; -describe('Component Tests', () => { - describe('ModelingExercise Management Detail Component', () => { - let comp: ModelingExerciseDetailComponent; - let fixture: ComponentFixture; - const route = ({ data: of({ modelingExercise: new ModelingExercise(123) }) } as any) as ActivatedRoute; +describe('ModelingExercise Management Detail Component', () => { + let comp: ModelingExerciseDetailComponent; + let fixture: ComponentFixture; + const route = ({ data: of({ modelingExercise: new ModelingExercise(123) }) } as any) as ActivatedRoute; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [ModelingExerciseDetailComponent], - providers: [{ provide: ActivatedRoute, useValue: route }], - }) - .overrideTemplate(ModelingExerciseDetailComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(ModelingExerciseDetailComponent); - comp = fixture.componentInstance; - }); + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [ModelingExerciseDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }], + }) + .overrideTemplate(ModelingExerciseDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(ModelingExerciseDetailComponent); + comp = fixture.componentInstance; + }); - describe('OnInit', () => { - it('Should call load all on init', () => { - // GIVEN + describe('OnInit', () => { + it('Should call load all on init', () => { + // GIVEN - // WHEN - comp.ngOnInit(); + // WHEN + comp.ngOnInit(); - // THEN - expect(comp.modelingExercise).toEqual(jasmine.objectContaining({ id: 123 })); - }); + // THEN + expect(comp.modelingExercise).toEqual(jasmine.objectContaining({ id: 123 })); }); }); }); diff --git a/src/test/javascript/spec/component/modeling-exercise/modeling-exercise-update.component.spec.ts b/src/test/javascript/spec/component/modeling-exercise/modeling-exercise-update.component.spec.ts index d2f7d1d78593..fda468e73b2d 100644 --- a/src/test/javascript/spec/component/modeling-exercise/modeling-exercise-update.component.spec.ts +++ b/src/test/javascript/spec/component/modeling-exercise/modeling-exercise-update.component.spec.ts @@ -7,53 +7,51 @@ import { ModelingExerciseUpdateComponent } from 'app/exercises/modeling/manage/m import { ModelingExerciseService } from 'app/exercises/modeling/manage/modeling-exercise.service'; import { ModelingExercise } from 'app/entities/modeling-exercise.model'; -describe('Component Tests', () => { - describe('ModelingExercise Management Update Component', () => { - let comp: ModelingExerciseUpdateComponent; - let fixture: ComponentFixture; - let service: ModelingExerciseService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [ModelingExerciseUpdateComponent], - }) - .overrideTemplate(ModelingExerciseUpdateComponent, '') - .compileComponents(); - - fixture = TestBed.createComponent(ModelingExerciseUpdateComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ModelingExerciseService); - }); - - describe('save', () => { - it('Should call update service on save for existing entity', fakeAsync(() => { - // GIVEN - const entity = new ModelingExercise(123); - spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.modelingExercise = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.update).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - })); - - it('Should call create service on save for new entity', fakeAsync(() => { - // GIVEN - const entity = new ModelingExercise(); - spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.modelingExercise = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.create).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - })); - }); +describe('ModelingExercise Management Update Component', () => { + let comp: ModelingExerciseUpdateComponent; + let fixture: ComponentFixture; + let service: ModelingExerciseService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [ModelingExerciseUpdateComponent], + }) + .overrideTemplate(ModelingExerciseUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(ModelingExerciseUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(ModelingExerciseService); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', fakeAsync(() => { + // GIVEN + const entity = new ModelingExercise(123); + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.modelingExercise = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + + it('Should call create service on save for new entity', fakeAsync(() => { + // GIVEN + const entity = new ModelingExercise(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.modelingExercise = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); }); }); diff --git a/src/test/javascript/spec/component/modeling-exercise/modeling-exercise.component.spec.ts b/src/test/javascript/spec/component/modeling-exercise/modeling-exercise.component.spec.ts index 1fc315b39061..d803437a8567 100644 --- a/src/test/javascript/spec/component/modeling-exercise/modeling-exercise.component.spec.ts +++ b/src/test/javascript/spec/component/modeling-exercise/modeling-exercise.component.spec.ts @@ -7,44 +7,42 @@ import { ModelingExerciseComponent } from 'app/exercises/modeling/manage/modelin import { ModelingExerciseService } from 'app/exercises/modeling/manage/modeling-exercise.service'; import { ModelingExercise } from 'app/entities/modeling-exercise.model'; -describe('Component Tests', () => { - describe('ModelingExercise Management Component', () => { - let comp: ModelingExerciseComponent; - let fixture: ComponentFixture; - let service: ModelingExerciseService; +describe('ModelingExercise Management Component', () => { + let comp: ModelingExerciseComponent; + let fixture: ComponentFixture; + let service: ModelingExerciseService; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [ModelingExerciseComponent], - providers: [], - }) - .overrideTemplate(ModelingExerciseComponent, '') - .compileComponents(); + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [ModelingExerciseComponent], + providers: [], + }) + .overrideTemplate(ModelingExerciseComponent, '') + .compileComponents(); - fixture = TestBed.createComponent(ModelingExerciseComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ModelingExerciseService); - }); + fixture = TestBed.createComponent(ModelingExerciseComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(ModelingExerciseService); + }); - it('Should call load all on init', () => { - // GIVEN - const headers = new HttpHeaders().append('link', 'link;link'); - spyOn(service, 'query').and.returnValue( - of( - new HttpResponse({ - body: [new ModelingExercise(123)], - headers, - }), - ), - ); + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new ModelingExercise(123)], + headers, + }), + ), + ); - // WHEN - comp.ngOnInit(); + // WHEN + comp.ngOnInit(); - // THEN - expect(service.query).toHaveBeenCalled(); - expect(comp.modelingExercises[0]).toEqual(jasmine.objectContaining({ id: 123 })); - }); + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.modelingExercises[0]).toEqual(jasmine.objectContaining({ id: 123 })); }); }); diff --git a/src/test/javascript/spec/component/modeling-submission/modeling-submission.component.spec.ts b/src/test/javascript/spec/component/modeling-submission/modeling-submission.component.spec.ts index 663f85915bba..ea6a409bc299 100644 --- a/src/test/javascript/spec/component/modeling-submission/modeling-submission.component.spec.ts +++ b/src/test/javascript/spec/component/modeling-submission/modeling-submission.component.spec.ts @@ -1,4 +1,3 @@ -/* tslint:disable max-line-length */ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { of, throwError } from 'rxjs'; @@ -44,181 +43,179 @@ import { ArtemisHeaderExercisePageWithDetailsModule } from 'app/exercises/shared chai.use(sinonChai); const expect = chai.expect; -describe('Component Tests', () => { - describe('ModelingSubmission Management Component', () => { - let comp: ModelingSubmissionComponent; - let fixture: ComponentFixture; - let debugElement: DebugElement; - let service: ModelingSubmissionService; - let router: Router; - - const route = ({ params: of({ courseId: 5, exerciseId: 22, participationId: 123 }) } as any) as ActivatedRoute; - const participation = new StudentParticipation(); - participation.exercise = new ModelingExercise('ClassDiagram'); - const submission = ({ id: 20, submitted: true, participation }); - const result = { id: 1 } as Result; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ - ArtemisTestModule, - TranslateModule.forRoot(), - ArtemisSharedModule, - ArtemisResultModule, - ArtemisSharedComponentModule, - ModelingAssessmentModule, - ArtemisComplaintsModule, - ArtemisTeamModule, - ArtemisHeaderExercisePageWithDetailsModule, - RouterTestingModule.withRoutes([routes[0]]), - ], - declarations: [ModelingSubmissionComponent, MockComponent(ModelingEditorComponent)], - providers: [ - { provide: AlertService, useClass: MockAlertService }, - { provide: ComplaintService, useClass: MockComplaintService }, - { provide: LocalStorageService, useClass: MockSyncStorage }, - { provide: SessionStorageService, useClass: MockSyncStorage }, - { provide: CookieService, useClass: MockCookieService }, - { provide: ActivatedRoute, useValue: route }, - { provide: ParticipationWebsocketService, useClass: MockParticipationWebsocketService }, - { provide: DeviceDetectorService }, - ], - }) - .overrideModule(ArtemisTestModule, { set: { declarations: [], exports: [] } }) - .compileComponents() - .then(() => { - fixture = TestBed.createComponent(ModelingSubmissionComponent); - comp = fixture.componentInstance; - debugElement = fixture.debugElement; - service = debugElement.injector.get(ModelingSubmissionService); - router = debugElement.injector.get(Router); - // Ignore window scroll - window.scroll = () => { - return false; - }; - }); - }); - - it('Should call load getDataForModelingEditor on init', () => { - // GIVEN - const fake = sinon.fake.returns(of(submission)); - sinon.replace(service, 'getLatestSubmissionForModelingEditor', fake); - - // WHEN - comp.ngOnInit(); - - // THEN - expect(fake).to.have.been.calledOnce; - expect(comp.submission).to.be.include({ id: 20 }); - }); - - it('should allow to submit when exercise due date not set', () => { - // GIVEN - sinon.replace(service, 'getLatestSubmissionForModelingEditor', sinon.fake.returns(of(submission))); - - // WHEN - comp.isLoading = false; - fixture.detectChanges(); - - expect(debugElement.query(By.css('div'))).to.exist; - - const submitButton = debugElement.query(By.css('jhi-button')); - expect(submitButton).to.exist; - expect(submitButton.attributes['ng-reflect-disabled']).to.be.equal('false'); - expect(comp.isActive).to.be.true; - }); - - it('should not allow to submit after the deadline if the initialization date is before the due date', () => { - submission.participation.initializationDate = moment().subtract(2, 'days'); - (submission.participation).exercise.dueDate = moment().subtract(1, 'days'); - sinon.replace(service, 'getLatestSubmissionForModelingEditor', sinon.fake.returns(of(submission))); - - fixture.detectChanges(); - - const submitButton = debugElement.query(By.css('jhi-button')); - expect(submitButton).to.exist; - expect(submitButton.attributes['ng-reflect-disabled']).to.be.equal('true'); - }); - - it('should allow to submit after the deadline if the initialization date is after the due date', () => { - submission.participation.initializationDate = moment().add(1, 'days'); - (submission.participation).exercise.dueDate = moment(); - sinon.replace(service, 'getLatestSubmissionForModelingEditor', sinon.fake.returns(of(submission))); - - fixture.detectChanges(); - - expect(comp.isLate).to.be.true; - const submitButton = debugElement.query(By.css('jhi-button')); - expect(submitButton).to.exist; - expect(submitButton.attributes['ng-reflect-disabled']).to.be.equal('false'); - }); - - it('should not allow to submit if there is a result and no due date', () => { - comp.result = result; - sinon.replace(service, 'getLatestSubmissionForModelingEditor', sinon.fake.returns(of(submission))); - - fixture.detectChanges(); - - const submitButton = debugElement.query(By.css('jhi-button')); - expect(submitButton).to.exist; - expect(submitButton.attributes['ng-reflect-disabled']).to.be.equal('true'); - }); - - it('should get inactive as soon as the due date passes the current date', () => { - (submission.participation).exercise.dueDate = moment().add(1, 'days'); - sinon.replace(service, 'getLatestSubmissionForModelingEditor', sinon.fake.returns(of(submission))); - - fixture.detectChanges(); - comp.participation.initializationDate = moment(); - - expect(comp.isActive).to.be.true; - - comp.modelingExercise.dueDate = moment().subtract(1, 'days'); - - fixture.detectChanges(); - expect(comp.isActive).to.be.false; - }); - - it('should navigate to access denied page on 403 error status', () => { - sinon.replace(service, 'getLatestSubmissionForModelingEditor', sinon.fake.returns(throwError({ status: 403 }))); - const spy = stub(router, 'navigate'); - spy.returns(new Promise(() => true)); - fixture.detectChanges(); - expect(spy.called).to.be.true; - }); - - it('should set correct properties on modeling exercise update when saving', () => { - sinon.replace(service, 'getLatestSubmissionForModelingEditor', sinon.fake.returns(of(submission))); - fixture.detectChanges(); - - const fake = sinon.replace(service, 'update', sinon.fake.returns(of({ body: submission }))); - comp.saveDiagram(); - expect(fake).to.have.been.calledOnce; - expect(comp.submission).to.be.deep.equal(submission); - }); - - it('should set correct properties on modeling exercise create when saving', () => { - fixture.detectChanges(); - - const fake = sinon.replace(service, 'create', sinon.fake.returns(of({ body: submission }))); - comp.modelingExercise = new ModelingExercise('DeploymentDiagram'); - comp.modelingExercise.id = 1; - comp.saveDiagram(); - expect(fake).to.have.been.calledOnce; - expect(comp.submission).to.be.deep.equal(submission); - }); - - it('should set correct properties on modeling exercise create when submitting', () => { - fixture.detectChanges(); - - const modelSubmission = ({ model: '{"elements": [{"id": 1}]}', submitted: true, participation }); - comp.submission = modelSubmission; - const fake = sinon.replace(service, 'create', sinon.fake.returns(of({ body: submission }))); - comp.modelingExercise = new ModelingExercise('DeploymentDiagram'); - comp.modelingExercise.id = 1; - comp.submit(); - expect(fake).to.have.been.calledOnce; - expect(comp.submission).to.be.deep.equal(submission); - }); +describe('ModelingSubmission Management Component', () => { + let comp: ModelingSubmissionComponent; + let fixture: ComponentFixture; + let debugElement: DebugElement; + let service: ModelingSubmissionService; + let router: Router; + + const route = ({ params: of({ courseId: 5, exerciseId: 22, participationId: 123 }) } as any) as ActivatedRoute; + const participation = new StudentParticipation(); + participation.exercise = new ModelingExercise('ClassDiagram'); + const submission = ({ id: 20, submitted: true, participation }); + const result = { id: 1 } as Result; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [ + ArtemisTestModule, + TranslateModule.forRoot(), + ArtemisSharedModule, + ArtemisResultModule, + ArtemisSharedComponentModule, + ModelingAssessmentModule, + ArtemisComplaintsModule, + ArtemisTeamModule, + ArtemisHeaderExercisePageWithDetailsModule, + RouterTestingModule.withRoutes([routes[0]]), + ], + declarations: [ModelingSubmissionComponent, MockComponent(ModelingEditorComponent)], + providers: [ + { provide: AlertService, useClass: MockAlertService }, + { provide: ComplaintService, useClass: MockComplaintService }, + { provide: LocalStorageService, useClass: MockSyncStorage }, + { provide: SessionStorageService, useClass: MockSyncStorage }, + { provide: CookieService, useClass: MockCookieService }, + { provide: ActivatedRoute, useValue: route }, + { provide: ParticipationWebsocketService, useClass: MockParticipationWebsocketService }, + { provide: DeviceDetectorService }, + ], + }) + .overrideModule(ArtemisTestModule, { set: { declarations: [], exports: [] } }) + .compileComponents() + .then(() => { + fixture = TestBed.createComponent(ModelingSubmissionComponent); + comp = fixture.componentInstance; + debugElement = fixture.debugElement; + service = debugElement.injector.get(ModelingSubmissionService); + router = debugElement.injector.get(Router); + // Ignore window scroll + window.scroll = () => { + return false; + }; + }); + }); + + it('Should call load getDataForModelingEditor on init', () => { + // GIVEN + const fake = sinon.fake.returns(of(submission)); + sinon.replace(service, 'getLatestSubmissionForModelingEditor', fake); + + // WHEN + comp.ngOnInit(); + + // THEN + expect(fake).to.have.been.calledOnce; + expect(comp.submission).to.be.include({ id: 20 }); + }); + + it('should allow to submit when exercise due date not set', () => { + // GIVEN + sinon.replace(service, 'getLatestSubmissionForModelingEditor', sinon.fake.returns(of(submission))); + + // WHEN + comp.isLoading = false; + fixture.detectChanges(); + + expect(debugElement.query(By.css('div'))).to.exist; + + const submitButton = debugElement.query(By.css('jhi-button')); + expect(submitButton).to.exist; + expect(submitButton.attributes['ng-reflect-disabled']).to.be.equal('false'); + expect(comp.isActive).to.be.true; + }); + + it('should not allow to submit after the deadline if the initialization date is before the due date', () => { + submission.participation.initializationDate = moment().subtract(2, 'days'); + (submission.participation).exercise.dueDate = moment().subtract(1, 'days'); + sinon.replace(service, 'getLatestSubmissionForModelingEditor', sinon.fake.returns(of(submission))); + + fixture.detectChanges(); + + const submitButton = debugElement.query(By.css('jhi-button')); + expect(submitButton).to.exist; + expect(submitButton.attributes['ng-reflect-disabled']).to.be.equal('true'); + }); + + it('should allow to submit after the deadline if the initialization date is after the due date', () => { + submission.participation.initializationDate = moment().add(1, 'days'); + (submission.participation).exercise.dueDate = moment(); + sinon.replace(service, 'getLatestSubmissionForModelingEditor', sinon.fake.returns(of(submission))); + + fixture.detectChanges(); + + expect(comp.isLate).to.be.true; + const submitButton = debugElement.query(By.css('jhi-button')); + expect(submitButton).to.exist; + expect(submitButton.attributes['ng-reflect-disabled']).to.be.equal('false'); + }); + + it('should not allow to submit if there is a result and no due date', () => { + comp.result = result; + sinon.replace(service, 'getLatestSubmissionForModelingEditor', sinon.fake.returns(of(submission))); + + fixture.detectChanges(); + + const submitButton = debugElement.query(By.css('jhi-button')); + expect(submitButton).to.exist; + expect(submitButton.attributes['ng-reflect-disabled']).to.be.equal('true'); + }); + + it('should get inactive as soon as the due date passes the current date', () => { + (submission.participation).exercise.dueDate = moment().add(1, 'days'); + sinon.replace(service, 'getLatestSubmissionForModelingEditor', sinon.fake.returns(of(submission))); + + fixture.detectChanges(); + comp.participation.initializationDate = moment(); + + expect(comp.isActive).to.be.true; + + comp.modelingExercise.dueDate = moment().subtract(1, 'days'); + + fixture.detectChanges(); + expect(comp.isActive).to.be.false; + }); + + it('should navigate to access denied page on 403 error status', () => { + sinon.replace(service, 'getLatestSubmissionForModelingEditor', sinon.fake.returns(throwError({ status: 403 }))); + const spy = stub(router, 'navigate'); + spy.returns(new Promise(() => true)); + fixture.detectChanges(); + expect(spy.called).to.be.true; + }); + + it('should set correct properties on modeling exercise update when saving', () => { + sinon.replace(service, 'getLatestSubmissionForModelingEditor', sinon.fake.returns(of(submission))); + fixture.detectChanges(); + + const fake = sinon.replace(service, 'update', sinon.fake.returns(of({ body: submission }))); + comp.saveDiagram(); + expect(fake).to.have.been.calledOnce; + expect(comp.submission).to.be.deep.equal(submission); + }); + + it('should set correct properties on modeling exercise create when saving', () => { + fixture.detectChanges(); + + const fake = sinon.replace(service, 'create', sinon.fake.returns(of({ body: submission }))); + comp.modelingExercise = new ModelingExercise('DeploymentDiagram'); + comp.modelingExercise.id = 1; + comp.saveDiagram(); + expect(fake).to.have.been.calledOnce; + expect(comp.submission).to.be.deep.equal(submission); + }); + + it('should set correct properties on modeling exercise create when submitting', () => { + fixture.detectChanges(); + + const modelSubmission = ({ model: '{"elements": [{"id": 1}]}', submitted: true, participation }); + comp.submission = modelSubmission; + const fake = sinon.replace(service, 'create', sinon.fake.returns(of({ body: submission }))); + comp.modelingExercise = new ModelingExercise('DeploymentDiagram'); + comp.modelingExercise.id = 1; + comp.submit(); + expect(fake).to.have.been.calledOnce; + expect(comp.submission).to.be.deep.equal(submission); }); }); diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-detail.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-detail.component.spec.ts index 80e740d93ddc..9c7d63ff96c1 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-detail.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-detail.component.spec.ts @@ -6,34 +6,32 @@ import { ArtemisTestModule } from '../../test.module'; import { ProgrammingExerciseDetailComponent } from 'app/exercises/programming/manage/programming-exercise-detail.component'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; -describe('Component Tests', () => { - describe('ProgrammingExercise Management Detail Component', () => { - let comp: ProgrammingExerciseDetailComponent; - let fixture: ComponentFixture; - const route = ({ data: of({ programmingExercise: new ProgrammingExercise(123) }) } as any) as ActivatedRoute; +describe('ProgrammingExercise Management Detail Component', () => { + let comp: ProgrammingExerciseDetailComponent; + let fixture: ComponentFixture; + const route = ({ data: of({ programmingExercise: new ProgrammingExercise(123) }) } as any) as ActivatedRoute; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [ProgrammingExerciseDetailComponent], - providers: [{ provide: ActivatedRoute, useValue: route }], - }) - .overrideTemplate(ProgrammingExerciseDetailComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(ProgrammingExerciseDetailComponent); - comp = fixture.componentInstance; - }); + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [ProgrammingExerciseDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }], + }) + .overrideTemplate(ProgrammingExerciseDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(ProgrammingExerciseDetailComponent); + comp = fixture.componentInstance; + }); - describe('OnInit', () => { - it('Should call load all on init', () => { - // GIVEN + describe('OnInit', () => { + it('Should call load all on init', () => { + // GIVEN - // WHEN - comp.ngOnInit(); + // WHEN + comp.ngOnInit(); - // THEN - expect(comp.programmingExercise).toEqual(jasmine.objectContaining({ id: 123 })); - }); + // THEN + expect(comp.programmingExercise).toEqual(jasmine.objectContaining({ id: 123 })); }); }); }); diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-update.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-update.component.spec.ts index 58c35513f040..118e7c0058ed 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-update.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-update.component.spec.ts @@ -7,53 +7,51 @@ import { ProgrammingExerciseUpdateComponent } from 'app/exercises/programming/ma import { ProgrammingExerciseService } from 'app/exercises/programming/manage/services/programming-exercise.service'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; -describe('Component Tests', () => { - describe('ProgrammingExercise Management Update Component', () => { - let comp: ProgrammingExerciseUpdateComponent; - let fixture: ComponentFixture; - let service: ProgrammingExerciseService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [ProgrammingExerciseUpdateComponent], - }) - .overrideTemplate(ProgrammingExerciseUpdateComponent, '') - .compileComponents(); - - fixture = TestBed.createComponent(ProgrammingExerciseUpdateComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ProgrammingExerciseService); - }); - - describe('save', () => { - it('Should call update service on save for existing entity', fakeAsync(() => { - // GIVEN - const entity = new ProgrammingExercise(123); - spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.programmingExercise = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.update).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - })); - - it('Should call create service on save for new entity', fakeAsync(() => { - // GIVEN - const entity = new ProgrammingExercise(); - spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.programmingExercise = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.create).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - })); - }); +describe('ProgrammingExercise Management Update Component', () => { + let comp: ProgrammingExerciseUpdateComponent; + let fixture: ComponentFixture; + let service: ProgrammingExerciseService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [ProgrammingExerciseUpdateComponent], + }) + .overrideTemplate(ProgrammingExerciseUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(ProgrammingExerciseUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(ProgrammingExerciseService); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', fakeAsync(() => { + // GIVEN + const entity = new ProgrammingExercise(123); + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.programmingExercise = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + + it('Should call create service on save for new entity', fakeAsync(() => { + // GIVEN + const entity = new ProgrammingExercise(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.programmingExercise = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); }); }); diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise.component.spec.ts index 77ee0b9ad15b..6caee6efecfb 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise.component.spec.ts @@ -16,59 +16,57 @@ import { MockOrionConnectorService } from '../../helpers/mocks/service/mock-orio import { CourseExerciseService } from 'app/course/manage/course-management.service'; import { MockCourseExerciseService } from '../../helpers/mocks/service/mock-course-exercise.service'; -describe('Component Tests', () => { - describe('ProgrammingExercise Management Component', () => { - const course = { id: 123 } as Course; - const programmingExercise = new ProgrammingExercise(course); - programmingExercise.id = 456; +describe('ProgrammingExercise Management Component', () => { + const course = { id: 123 } as Course; + const programmingExercise = new ProgrammingExercise(course); + programmingExercise.id = 456; - let comp: ProgrammingExerciseComponent; - let fixture: ComponentFixture; - let service: CourseExerciseService; + let comp: ProgrammingExerciseComponent; + let fixture: ComponentFixture; + let service: CourseExerciseService; - const route = ({ snapshot: { paramMap: convertToParamMap({ courseId: course.id }) } } as any) as ActivatedRoute; + const route = ({ snapshot: { paramMap: convertToParamMap({ courseId: course.id }) } } as any) as ActivatedRoute; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [ProgrammingExerciseComponent], - providers: [ - { provide: SessionStorageService, useClass: MockSyncStorage }, - { provide: LocalStorageService, useClass: MockSyncStorage }, - { provide: TranslateService, useClass: MockTranslateService }, - { provide: ActivatedRoute, useValue: route }, - { provide: OrionConnectorService, useClass: MockOrionConnectorService }, - { provide: CourseExerciseService, useClass: MockCourseExerciseService }, - ], - }) - .overrideTemplate(ProgrammingExerciseComponent, '') - .compileComponents(); + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [ProgrammingExerciseComponent], + providers: [ + { provide: SessionStorageService, useClass: MockSyncStorage }, + { provide: LocalStorageService, useClass: MockSyncStorage }, + { provide: TranslateService, useClass: MockTranslateService }, + { provide: ActivatedRoute, useValue: route }, + { provide: OrionConnectorService, useClass: MockOrionConnectorService }, + { provide: CourseExerciseService, useClass: MockCourseExerciseService }, + ], + }) + .overrideTemplate(ProgrammingExerciseComponent, '') + .compileComponents(); - fixture = TestBed.createComponent(ProgrammingExerciseComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(CourseExerciseService); - }); + fixture = TestBed.createComponent(ProgrammingExerciseComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(CourseExerciseService); + }); - it('Should call load all on init', () => { - // GIVEN - const headers = new HttpHeaders().append('link', 'link;link'); - spyOn(service, 'findAllProgrammingExercisesForCourse').and.returnValue( - of( - new HttpResponse({ - body: [programmingExercise], - headers, - }), - ), - ); + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'findAllProgrammingExercisesForCourse').and.returnValue( + of( + new HttpResponse({ + body: [programmingExercise], + headers, + }), + ), + ); - // WHEN - comp.course = course; - fixture.detectChanges(); - comp.ngOnInit(); + // WHEN + comp.course = course; + fixture.detectChanges(); + comp.ngOnInit(); - // THEN - expect(service.findAllProgrammingExercisesForCourse).toHaveBeenCalled(); - expect(comp.programmingExercises[0]).toEqual(jasmine.objectContaining({ id: programmingExercise.id })); - }); + // THEN + expect(service.findAllProgrammingExercisesForCourse).toHaveBeenCalled(); + expect(comp.programmingExercises[0]).toEqual(jasmine.objectContaining({ id: programmingExercise.id })); }); }); diff --git a/src/test/javascript/spec/component/quiz-exercise/quiz-exercise-detail.component.spec.ts b/src/test/javascript/spec/component/quiz-exercise/quiz-exercise-detail.component.spec.ts index 438669f5dc89..560b7c1683d9 100644 --- a/src/test/javascript/spec/component/quiz-exercise/quiz-exercise-detail.component.spec.ts +++ b/src/test/javascript/spec/component/quiz-exercise/quiz-exercise-detail.component.spec.ts @@ -6,34 +6,32 @@ import { ArtemisTestModule } from '../../test.module'; import { QuizExerciseDetailComponent } from 'app/exercises/quiz/manage/quiz-exercise-detail.component'; import { QuizExercise } from 'app/entities/quiz/quiz-exercise.model'; -describe('Component Tests', () => { - describe('QuizExercise Management Detail Component', () => { - let comp: QuizExerciseDetailComponent; - let fixture: ComponentFixture; - const route = ({ data: of({ quizExercise: new QuizExercise(123) }) } as any) as ActivatedRoute; +describe('QuizExercise Management Detail Component', () => { + let comp: QuizExerciseDetailComponent; + let fixture: ComponentFixture; + const route = ({ data: of({ quizExercise: new QuizExercise(123) }) } as any) as ActivatedRoute; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [QuizExerciseDetailComponent], - providers: [{ provide: ActivatedRoute, useValue: route }], - }) - .overrideTemplate(QuizExerciseDetailComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(QuizExerciseDetailComponent); - comp = fixture.componentInstance; - }); + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [QuizExerciseDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }], + }) + .overrideTemplate(QuizExerciseDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(QuizExerciseDetailComponent); + comp = fixture.componentInstance; + }); - describe('OnInit', () => { - it('Should call load all on init', () => { - // GIVEN + describe('OnInit', () => { + it('Should call load all on init', () => { + // GIVEN - // WHEN - comp.ngOnInit(); + // WHEN + comp.ngOnInit(); - // THEN - expect(comp.quizExercise).toEqual(jasmine.objectContaining({ id: 123 })); - }); + // THEN + expect(comp.quizExercise).toEqual(jasmine.objectContaining({ id: 123 })); }); }); }); diff --git a/src/test/javascript/spec/component/quiz-exercise/quiz-exercise.component.spec.ts b/src/test/javascript/spec/component/quiz-exercise/quiz-exercise.component.spec.ts index 9e82bb58256b..e6ea5505f7ec 100644 --- a/src/test/javascript/spec/component/quiz-exercise/quiz-exercise.component.spec.ts +++ b/src/test/javascript/spec/component/quiz-exercise/quiz-exercise.component.spec.ts @@ -7,44 +7,42 @@ import { QuizExerciseComponent } from 'app/exercises/quiz/manage/quiz-exercise.c import { QuizExerciseService } from 'app/exercises/quiz/manage/quiz-exercise.service'; import { QuizExercise } from 'app/entities/quiz/quiz-exercise.model'; -describe('Component Tests', () => { - describe('QuizExercise Management Component', () => { - let comp: QuizExerciseComponent; - let fixture: ComponentFixture; - let service: QuizExerciseService; +describe('QuizExercise Management Component', () => { + let comp: QuizExerciseComponent; + let fixture: ComponentFixture; + let service: QuizExerciseService; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [QuizExerciseComponent], - providers: [], - }) - .overrideTemplate(QuizExerciseComponent, '') - .compileComponents(); + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [QuizExerciseComponent], + providers: [], + }) + .overrideTemplate(QuizExerciseComponent, '') + .compileComponents(); - fixture = TestBed.createComponent(QuizExerciseComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(QuizExerciseService); - }); + fixture = TestBed.createComponent(QuizExerciseComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(QuizExerciseService); + }); - it('Should call load all on init', () => { - // GIVEN - const headers = new HttpHeaders().append('link', 'link;link'); - spyOn(service, 'query').and.returnValue( - of( - new HttpResponse({ - body: [new QuizExercise(123)], - headers, - }), - ), - ); + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new QuizExercise(123)], + headers, + }), + ), + ); - // WHEN - comp.ngOnInit(); + // WHEN + comp.ngOnInit(); - // THEN - expect(service.query).toHaveBeenCalled(); - expect(comp.quizExercises[0]).toEqual(jasmine.objectContaining({ id: 123 })); - }); + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.quizExercises[0]).toEqual(jasmine.objectContaining({ id: 123 })); }); }); diff --git a/src/test/javascript/spec/component/shared/alert-error.component.spec.ts b/src/test/javascript/spec/component/shared/alert-error.component.spec.ts index e9cf8c58b9b1..e73190c8e2c2 100644 --- a/src/test/javascript/spec/component/shared/alert-error.component.spec.ts +++ b/src/test/javascript/spec/component/shared/alert-error.component.spec.ts @@ -8,129 +8,127 @@ import { AlertErrorComponent } from 'app/shared/alert/alert-error.component'; import { MockAlertService } from '../../helpers/mocks/service/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; -describe('Component Tests', () => { - describe('Alert Error Component', () => { - let comp: AlertErrorComponent; - let fixture: ComponentFixture; - let eventManager: JhiEventManager; +describe('Alert Error Component', () => { + let comp: AlertErrorComponent; + let fixture: ComponentFixture; + let eventManager: JhiEventManager; - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule, TranslateModule.forRoot()], - declarations: [AlertErrorComponent], - providers: [ - JhiEventManager, - { - provide: AlertService, - useClass: MockAlertService, - }, - ], - }) - .overrideTemplate(AlertErrorComponent, '') - .compileComponents(); - })); + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule, TranslateModule.forRoot()], + declarations: [AlertErrorComponent], + providers: [ + JhiEventManager, + { + provide: AlertService, + useClass: MockAlertService, + }, + ], + }) + .overrideTemplate(AlertErrorComponent, '') + .compileComponents(); + })); - beforeEach(() => { - fixture = TestBed.createComponent(AlertErrorComponent); - comp = fixture.componentInstance; - eventManager = fixture.debugElement.injector.get(JhiEventManager); - }); + beforeEach(() => { + fixture = TestBed.createComponent(AlertErrorComponent); + comp = fixture.componentInstance; + eventManager = fixture.debugElement.injector.get(JhiEventManager); + }); - describe('Error Handling', () => { - it('Should display an alert on status 0', () => { - // GIVEN - eventManager.broadcast({ name: 'artemisApp.httpError', content: { status: 0 } }); - // THEN - expect(comp.alerts.length).toBe(1); - expect(comp.alerts[0].msg).toBe('error.server.not.reachable'); - }); - it('Should display an alert on status 404', () => { - // GIVEN - eventManager.broadcast({ name: 'artemisApp.httpError', content: { status: 404 } }); - // THEN - expect(comp.alerts.length).toBe(1); - expect(comp.alerts[0].msg).toBe('error.url.not.found'); - }); - it('Should display an alert on generic error', () => { - // GIVEN - eventManager.broadcast({ name: 'artemisApp.httpError', content: { error: { message: 'Error Message' } } }); - eventManager.broadcast({ name: 'artemisApp.httpError', content: { error: 'Second Error Message' } }); - // THEN - expect(comp.alerts.length).toBe(2); - expect(comp.alerts[0].msg).toBe('Error Message'); - expect(comp.alerts[1].msg).toBe('Second Error Message'); - }); - it('Should display an alert on status 400 for generic error', () => { - // GIVEN - const response = new HttpErrorResponse({ - url: 'http://localhost:8080/api/foos', - headers: new HttpHeaders(), + describe('Error Handling', () => { + it('Should display an alert on status 0', () => { + // GIVEN + eventManager.broadcast({ name: 'artemisApp.httpError', content: { status: 0 } }); + // THEN + expect(comp.alerts.length).toBe(1); + expect(comp.alerts[0].msg).toBe('error.server.not.reachable'); + }); + it('Should display an alert on status 404', () => { + // GIVEN + eventManager.broadcast({ name: 'artemisApp.httpError', content: { status: 404 } }); + // THEN + expect(comp.alerts.length).toBe(1); + expect(comp.alerts[0].msg).toBe('error.url.not.found'); + }); + it('Should display an alert on generic error', () => { + // GIVEN + eventManager.broadcast({ name: 'artemisApp.httpError', content: { error: { message: 'Error Message' } } }); + eventManager.broadcast({ name: 'artemisApp.httpError', content: { error: 'Second Error Message' } }); + // THEN + expect(comp.alerts.length).toBe(2); + expect(comp.alerts[0].msg).toBe('Error Message'); + expect(comp.alerts[1].msg).toBe('Second Error Message'); + }); + it('Should display an alert on status 400 for generic error', () => { + // GIVEN + const response = new HttpErrorResponse({ + url: 'http://localhost:8080/api/foos', + headers: new HttpHeaders(), + status: 400, + statusText: 'Bad Request', + error: { + type: 'https://www.jhipster.tech/problem/constraint-violation', + title: 'Bad Request', status: 400, - statusText: 'Bad Request', - error: { - type: 'https://www.jhipster.tech/problem/constraint-violation', - title: 'Bad Request', - status: 400, - path: '/api/foos', - message: 'error.validation', - }, - }); - eventManager.broadcast({ name: 'artemisApp.httpError', content: response }); - // THEN - expect(comp.alerts.length).toBe(1); - expect(comp.alerts[0].msg).toBe('error.validation'); + path: '/api/foos', + message: 'error.validation', + }, }); - it('Should display an alert on status 400 for generic error without message', () => { - // GIVEN - const response = new HttpErrorResponse({ - url: 'http://localhost:8080/api/foos', - headers: new HttpHeaders(), - status: 400, - error: 'Bad Request', - }); - eventManager.broadcast({ name: 'artemisApp.httpError', content: response }); - // THEN - expect(comp.alerts.length).toBe(1); - expect(comp.alerts[0].msg).toBe('Bad Request'); + eventManager.broadcast({ name: 'artemisApp.httpError', content: response }); + // THEN + expect(comp.alerts.length).toBe(1); + expect(comp.alerts[0].msg).toBe('error.validation'); + }); + it('Should display an alert on status 400 for generic error without message', () => { + // GIVEN + const response = new HttpErrorResponse({ + url: 'http://localhost:8080/api/foos', + headers: new HttpHeaders(), + status: 400, + error: 'Bad Request', }); - it('Should display an alert on status 400 for invalid parameters', () => { - // GIVEN - const response = new HttpErrorResponse({ - url: 'http://localhost:8080/api/foos', - headers: new HttpHeaders(), + eventManager.broadcast({ name: 'artemisApp.httpError', content: response }); + // THEN + expect(comp.alerts.length).toBe(1); + expect(comp.alerts[0].msg).toBe('Bad Request'); + }); + it('Should display an alert on status 400 for invalid parameters', () => { + // GIVEN + const response = new HttpErrorResponse({ + url: 'http://localhost:8080/api/foos', + headers: new HttpHeaders(), + status: 400, + statusText: 'Bad Request', + error: { + type: 'https://www.jhipster.tech/problem/constraint-violation', + title: 'Method argument not valid', status: 400, - statusText: 'Bad Request', - error: { - type: 'https://www.jhipster.tech/problem/constraint-violation', - title: 'Method argument not valid', - status: 400, - path: '/api/foos', - message: 'error.validation', - fieldErrors: [{ objectName: 'foo', field: 'minField', message: 'Min' }], - }, - }); - eventManager.broadcast({ name: 'artemisApp.httpError', content: response }); - // THEN - expect(comp.alerts.length).toBe(1); - expect(comp.alerts[0].msg).toBe('error.Size'); + path: '/api/foos', + message: 'error.validation', + fieldErrors: [{ objectName: 'foo', field: 'minField', message: 'Min' }], + }, }); - it('Should display an alert on status 400 for error headers', () => { - // GIVEN - const response = new HttpErrorResponse({ - url: 'http://localhost:8080/api/foos', - headers: new HttpHeaders().append('app-error', 'Error Message').append('app-params', 'foo'), + eventManager.broadcast({ name: 'artemisApp.httpError', content: response }); + // THEN + expect(comp.alerts.length).toBe(1); + expect(comp.alerts[0].msg).toBe('error.Size'); + }); + it('Should display an alert on status 400 for error headers', () => { + // GIVEN + const response = new HttpErrorResponse({ + url: 'http://localhost:8080/api/foos', + headers: new HttpHeaders().append('app-error', 'Error Message').append('app-params', 'foo'), + status: 400, + statusText: 'Bad Request', + error: { status: 400, - statusText: 'Bad Request', - error: { - status: 400, - message: 'error.validation', - }, - }); - eventManager.broadcast({ name: 'artemisApp.httpError', content: response }); - // THEN - expect(comp.alerts.length).toBe(1); - expect(comp.alerts[0].msg).toBe('Error Message'); + message: 'error.validation', + }, }); + eventManager.broadcast({ name: 'artemisApp.httpError', content: response }); + // THEN + expect(comp.alerts.length).toBe(1); + expect(comp.alerts[0].msg).toBe('Error Message'); }); }); }); diff --git a/src/test/javascript/spec/component/text-exercise/text-exercise-detail.component.spec.ts b/src/test/javascript/spec/component/text-exercise/text-exercise-detail.component.spec.ts index a9b2287192f1..944e3b98c053 100644 --- a/src/test/javascript/spec/component/text-exercise/text-exercise-detail.component.spec.ts +++ b/src/test/javascript/spec/component/text-exercise/text-exercise-detail.component.spec.ts @@ -6,34 +6,32 @@ import { ArtemisTestModule } from '../../test.module'; import { TextExerciseDetailComponent } from 'app/exercises/text/manage/text-exercise/text-exercise-detail.component'; import { TextExercise } from 'app/entities/text-exercise.model'; -describe('Component Tests', () => { - describe('TextExercise Management Detail Component', () => { - let comp: TextExerciseDetailComponent; - let fixture: ComponentFixture; - const route = ({ data: of({ textExercise: new TextExercise(123) }) } as any) as ActivatedRoute; +describe('TextExercise Management Detail Component', () => { + let comp: TextExerciseDetailComponent; + let fixture: ComponentFixture; + const route = ({ data: of({ textExercise: new TextExercise(123) }) } as any) as ActivatedRoute; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [TextExerciseDetailComponent], - providers: [{ provide: ActivatedRoute, useValue: route }], - }) - .overrideTemplate(TextExerciseDetailComponent, '') - .compileComponents(); - fixture = TestBed.createComponent(TextExerciseDetailComponent); - comp = fixture.componentInstance; - }); + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [TextExerciseDetailComponent], + providers: [{ provide: ActivatedRoute, useValue: route }], + }) + .overrideTemplate(TextExerciseDetailComponent, '') + .compileComponents(); + fixture = TestBed.createComponent(TextExerciseDetailComponent); + comp = fixture.componentInstance; + }); - describe('OnInit', () => { - it('Should call load all on init', () => { - // GIVEN + describe('OnInit', () => { + it('Should call load all on init', () => { + // GIVEN - // WHEN - comp.ngOnInit(); + // WHEN + comp.ngOnInit(); - // THEN - expect(comp.textExercise).toEqual(jasmine.objectContaining({ id: 123 })); - }); + // THEN + expect(comp.textExercise).toEqual(jasmine.objectContaining({ id: 123 })); }); }); }); diff --git a/src/test/javascript/spec/component/text-exercise/text-exercise-update.component.spec.ts b/src/test/javascript/spec/component/text-exercise/text-exercise-update.component.spec.ts index 93c077dac250..fe75b95bdf34 100644 --- a/src/test/javascript/spec/component/text-exercise/text-exercise-update.component.spec.ts +++ b/src/test/javascript/spec/component/text-exercise/text-exercise-update.component.spec.ts @@ -7,53 +7,51 @@ import { TextExerciseUpdateComponent } from 'app/exercises/text/manage/text-exer import { TextExerciseService } from 'app/exercises/text/manage/text-exercise/text-exercise.service'; import { TextExercise } from 'app/entities/text-exercise.model'; -describe('Component Tests', () => { - describe('TextExercise Management Update Component', () => { - let comp: TextExerciseUpdateComponent; - let fixture: ComponentFixture; - let service: TextExerciseService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [TextExerciseUpdateComponent], - }) - .overrideTemplate(TextExerciseUpdateComponent, '') - .compileComponents(); - - fixture = TestBed.createComponent(TextExerciseUpdateComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(TextExerciseService); - }); - - describe('save', () => { - it('Should call update service on save for existing entity', fakeAsync(() => { - // GIVEN - const entity = new TextExercise(123); - spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.textExercise = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.update).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - })); - - it('Should call create service on save for new entity', fakeAsync(() => { - // GIVEN - const entity = new TextExercise(); - spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); - comp.textExercise = entity; - // WHEN - comp.save(); - tick(); // simulate async - - // THEN - expect(service.create).toHaveBeenCalledWith(entity); - expect(comp.isSaving).toEqual(false); - })); - }); +describe('TextExercise Management Update Component', () => { + let comp: TextExerciseUpdateComponent; + let fixture: ComponentFixture; + let service: TextExerciseService; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [TextExerciseUpdateComponent], + }) + .overrideTemplate(TextExerciseUpdateComponent, '') + .compileComponents(); + + fixture = TestBed.createComponent(TextExerciseUpdateComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(TextExerciseService); + }); + + describe('save', () => { + it('Should call update service on save for existing entity', fakeAsync(() => { + // GIVEN + const entity = new TextExercise(123); + spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.textExercise = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.update).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); + + it('Should call create service on save for new entity', fakeAsync(() => { + // GIVEN + const entity = new TextExercise(); + spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + comp.textExercise = entity; + // WHEN + comp.save(); + tick(); // simulate async + + // THEN + expect(service.create).toHaveBeenCalledWith(entity); + expect(comp.isSaving).toEqual(false); + })); }); }); diff --git a/src/test/javascript/spec/component/text-exercise/text-exercise.component.spec.ts b/src/test/javascript/spec/component/text-exercise/text-exercise.component.spec.ts index 881b827da423..44f5af5dc1da 100644 --- a/src/test/javascript/spec/component/text-exercise/text-exercise.component.spec.ts +++ b/src/test/javascript/spec/component/text-exercise/text-exercise.component.spec.ts @@ -7,44 +7,42 @@ import { TextExerciseComponent } from 'app/exercises/text/manage/text-exercise/t import { TextExerciseService } from 'app/exercises/text/manage/text-exercise/text-exercise.service'; import { TextExercise } from 'app/entities/text-exercise.model'; -describe('Component Tests', () => { - describe('TextExercise Management Component', () => { - let comp: TextExerciseComponent; - let fixture: ComponentFixture; - let service: TextExerciseService; +describe('TextExercise Management Component', () => { + let comp: TextExerciseComponent; + let fixture: ComponentFixture; + let service: TextExerciseService; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [ArtemisTestModule], - declarations: [TextExerciseComponent], - providers: [], - }) - .overrideTemplate(TextExerciseComponent, '') - .compileComponents(); + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [ArtemisTestModule], + declarations: [TextExerciseComponent], + providers: [], + }) + .overrideTemplate(TextExerciseComponent, '') + .compileComponents(); - fixture = TestBed.createComponent(TextExerciseComponent); - comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(TextExerciseService); - }); + fixture = TestBed.createComponent(TextExerciseComponent); + comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(TextExerciseService); + }); - it('Should call load all on init', () => { - // GIVEN - const headers = new HttpHeaders().append('link', 'link;link'); - spyOn(service, 'query').and.returnValue( - of( - new HttpResponse({ - body: [new TextExercise(123)], - headers, - }), - ), - ); + it('Should call load all on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'query').and.returnValue( + of( + new HttpResponse({ + body: [new TextExercise(123)], + headers, + }), + ), + ); - // WHEN - comp.ngOnInit(); + // WHEN + comp.ngOnInit(); - // THEN - expect(service.query).toHaveBeenCalled(); - expect(comp.textExercises[0]).toEqual(jasmine.objectContaining({ id: 123 })); - }); + // THEN + expect(service.query).toHaveBeenCalled(); + expect(comp.textExercises[0]).toEqual(jasmine.objectContaining({ id: 123 })); }); }); From 7b8d5d3b01ccf24fc96cbff312e2c48ee95c56c8 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Fri, 24 Apr 2020 17:34:32 +0200 Subject: [PATCH 100/152] Fix new code style issue --- .../exercise-headers/header-participation-page.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/webapp/app/exercises/shared/exercise-headers/header-participation-page.component.ts b/src/main/webapp/app/exercises/shared/exercise-headers/header-participation-page.component.ts index 3d662180d223..c5cce59b44ab 100644 --- a/src/main/webapp/app/exercises/shared/exercise-headers/header-participation-page.component.ts +++ b/src/main/webapp/app/exercises/shared/exercise-headers/header-participation-page.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnChanges, OnInit, SimpleChanges, ViewEncapsulation } from '@angular/core'; +import { Component, Input, OnChanges, OnInit, ViewEncapsulation } from '@angular/core'; import * as moment from 'moment'; import { Exercise, ExerciseCategory, getIcon } from 'app/entities/exercise.model'; import { ExerciseService } from 'app/exercises/shared/exercise/exercise.service'; From 535e30fc80a23d2050928817bc23fa1b8fae5540 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Fri, 24 Apr 2020 17:40:01 +0200 Subject: [PATCH 101/152] Remove unnecessary /* tslint:disable max-line-length */ --- .../participation-submissions-delete-dialog.component.spec.ts | 1 - src/test/javascript/spec/service/text-exercise.service.spec.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/src/test/javascript/spec/component/participation-submission/participation-submissions-delete-dialog.component.spec.ts b/src/test/javascript/spec/component/participation-submission/participation-submissions-delete-dialog.component.spec.ts index 3304c107b5b5..8386d001e4c9 100644 --- a/src/test/javascript/spec/component/participation-submission/participation-submissions-delete-dialog.component.spec.ts +++ b/src/test/javascript/spec/component/participation-submission/participation-submissions-delete-dialog.component.spec.ts @@ -1,4 +1,3 @@ -/* tslint:disable max-line-length */ import { ComponentFixture, fakeAsync, inject, TestBed, tick } from '@angular/core/testing'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { of } from 'rxjs'; diff --git a/src/test/javascript/spec/service/text-exercise.service.spec.ts b/src/test/javascript/spec/service/text-exercise.service.spec.ts index d50c3018d441..0d69cdc88ed3 100644 --- a/src/test/javascript/spec/service/text-exercise.service.spec.ts +++ b/src/test/javascript/spec/service/text-exercise.service.spec.ts @@ -1,4 +1,3 @@ -/* tslint:disable max-line-length */ import { getTestBed, TestBed } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { map, take } from 'rxjs/operators'; From f73d9b4b60af3e39c664b44d6a56c9953de3d75e Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Fri, 24 Apr 2020 17:44:25 +0200 Subject: [PATCH 102/152] Remove unnecessary describe('Service Tests'... from all test suites --- .../spec/service/audits.service.spec.ts | 72 +++-- .../service/configuration.service.spec.ts | 90 +++--- .../spec/service/course.service.spec.ts | 272 +++++++++--------- .../service/exercise-hint.service.spec.ts | 144 +++++----- .../file-upload-exercise.service.spec.ts | 162 ++++++----- .../file-upload-submission.service.spec.ts | 162 ++++++----- .../spec/service/logs.service.spec.ts | 68 +++-- .../spec/service/metrics.service.spec.ts | 68 +++-- .../service/modeling-exercise.service.spec.ts | 170 ++++++----- .../modeling-submission.service.spec.ts | 166 ++++++----- .../service/participation.service.spec.ts | 224 +++++++-------- .../programming-exercise.service.spec.ts | 178 ++++++------ .../service/quiz-exercise.service.spec.ts | 190 ++++++------ .../student-question-answer.service.spec.ts | 144 +++++----- .../service/student-question.service.spec.ts | 102 ++++--- .../service/text-exercise.service.spec.ts | 162 ++++++----- .../service/text-submission.service.spec.ts | 162 ++++++----- .../spec/service/user.service.spec.ts | 84 +++--- 18 files changed, 1292 insertions(+), 1328 deletions(-) diff --git a/src/test/javascript/spec/service/audits.service.spec.ts b/src/test/javascript/spec/service/audits.service.spec.ts index f9867f0551d0..21806d4c672e 100644 --- a/src/test/javascript/spec/service/audits.service.spec.ts +++ b/src/test/javascript/spec/service/audits.service.spec.ts @@ -5,54 +5,52 @@ import { Audit } from 'app/admin/audits/audit.model'; import { SERVER_API_URL } from 'app/app.constants'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; -describe('Service Tests', () => { - describe('Audits Service', () => { - let service: AuditsService; - let httpMock; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - }); +describe('Audits Service', () => { + let service: AuditsService; + let httpMock; - service = TestBed.inject(AuditsService); - httpMock = TestBed.inject(HttpTestingController); + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], }); - afterEach(() => { - httpMock.verify(); - }); + service = TestBed.inject(AuditsService); + httpMock = TestBed.inject(HttpTestingController); + }); - describe('Service methods', () => { - it('should call correct URL', () => { - service.query({}).subscribe(() => {}); + afterEach(() => { + httpMock.verify(); + }); - const req = httpMock.expectOne({ method: 'GET' }); - const resourceUrl = SERVER_API_URL + 'management/audits'; - expect(req.request.url).toEqual(resourceUrl); - }); + describe('Service methods', () => { + it('should call correct URL', () => { + service.query({}).subscribe(() => {}); - it('should return Audits', () => { - const audit = new Audit({ remoteAddress: '127.0.0.1', sessionId: '123' }, 'user', '20140101', 'AUTHENTICATION_SUCCESS'); + const req = httpMock.expectOne({ method: 'GET' }); + const resourceUrl = SERVER_API_URL + 'management/audits'; + expect(req.request.url).toEqual(resourceUrl); + }); - service.query({}).subscribe((received) => { - expect(received.body[0]).toEqual(audit); - }); + it('should return Audits', () => { + const audit = new Audit({ remoteAddress: '127.0.0.1', sessionId: '123' }, 'user', '20140101', 'AUTHENTICATION_SUCCESS'); - const req = httpMock.expectOne({ method: 'GET' }); - req.flush([audit]); + service.query({}).subscribe((received) => { + expect(received.body[0]).toEqual(audit); }); - it('should propagate not found response', () => { - service.query({}).subscribe(null, (_error: any) => { - expect(_error.status).toEqual(404); - }); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush([audit]); + }); + + it('should propagate not found response', () => { + service.query({}).subscribe(null, (_error: any) => { + expect(_error.status).toEqual(404); + }); - const req = httpMock.expectOne({ method: 'GET' }); - req.flush('Invalid request parameters', { - status: 404, - statusText: 'Bad Request', - }); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush('Invalid request parameters', { + status: 404, + statusText: 'Bad Request', }); }); }); diff --git a/src/test/javascript/spec/service/configuration.service.spec.ts b/src/test/javascript/spec/service/configuration.service.spec.ts index 30bb8d0cb64b..668b94240587 100644 --- a/src/test/javascript/spec/service/configuration.service.spec.ts +++ b/src/test/javascript/spec/service/configuration.service.spec.ts @@ -5,63 +5,61 @@ import { SERVER_API_URL } from 'app/app.constants'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { HttpResponse } from '@angular/common/http'; -describe('Service Tests', () => { - describe('Logs Service', () => { - let service: JhiConfigurationService; - let httpMock; +describe('Logs Service', () => { + let service: JhiConfigurationService; + let httpMock; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - }); - - service = TestBed.inject(JhiConfigurationService); - httpMock = TestBed.inject(HttpTestingController); + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], }); - afterEach(() => { - httpMock.verify(); - }); + service = TestBed.inject(JhiConfigurationService); + httpMock = TestBed.inject(HttpTestingController); + }); - describe('Service methods', () => { - it('should call correct URL', () => { - service.get().subscribe(() => {}); + afterEach(() => { + httpMock.verify(); + }); - const req = httpMock.expectOne({ method: 'GET' }); - const resourceUrl = SERVER_API_URL + 'management/configprops'; - expect(req.request.url).toEqual(resourceUrl); - }); + describe('Service methods', () => { + it('should call correct URL', () => { + service.get().subscribe(() => {}); - it('should get the config', () => { - const angularConfig = { - contexts: { - angular: { - beans: ['test2'], - }, - }, - }; - service.get().subscribe((received) => { - expect(received.body[0]).toEqual(angularConfig); - }); + const req = httpMock.expectOne({ method: 'GET' }); + const resourceUrl = SERVER_API_URL + 'management/configprops'; + expect(req.request.url).toEqual(resourceUrl); + }); - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(angularConfig); + it('should get the config', () => { + const angularConfig = { + contexts: { + angular: { + beans: ['test2'], + }, + }, + }; + service.get().subscribe((received) => { + expect(received.body[0]).toEqual(angularConfig); }); - it('should get the env', () => { - const propertySources = new HttpResponse({ - body: [ - { name: 'test1', properties: 'test1' }, - { name: 'test2', properties: 'test2' }, - ], - }); - service.get().subscribe((received) => { - expect(received.body[0]).toEqual(propertySources); - }); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(angularConfig); + }); - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(propertySources); + it('should get the env', () => { + const propertySources = new HttpResponse({ + body: [ + { name: 'test1', properties: 'test1' }, + { name: 'test2', properties: 'test2' }, + ], + }); + service.get().subscribe((received) => { + expect(received.body[0]).toEqual(propertySources); }); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(propertySources); }); }); }); diff --git a/src/test/javascript/spec/service/course.service.spec.ts b/src/test/javascript/spec/service/course.service.spec.ts index 1812ecae49de..1509bfc3b17a 100644 --- a/src/test/javascript/spec/service/course.service.spec.ts +++ b/src/test/javascript/spec/service/course.service.spec.ts @@ -12,153 +12,151 @@ import { MockTranslateService } from '../helpers/mocks/service/mock-translate.se import { MockSyncStorage } from '../helpers/mocks/service/mock-sync-storage.service'; import { MockRouter } from '../helpers/mocks/service/mock-router.service'; -describe('Service Tests', () => { - describe('Course Service', () => { - let injector: TestBed; - let service: CourseManagementService; - let httpMock: HttpTestingController; - let elemDefault: Course; - let currentDate: moment.Moment; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - providers: [ - { provide: Router, useClass: MockRouter }, - { provide: LocalStorageService, useClass: MockSyncStorage }, - { provide: SessionStorageService, useClass: MockSyncStorage }, - { provide: TranslateService, useClass: MockTranslateService }, - ], - }); - injector = getTestBed(); - service = injector.get(CourseManagementService); - httpMock = injector.get(HttpTestingController); - currentDate = moment(); - - elemDefault = new Course(); - elemDefault.id = 0; - elemDefault.title = 'AAAAAAA'; - elemDefault.description = 'AAAAAAA'; - elemDefault.shortName = 'AAAAAAA'; - elemDefault.title = 'AAAAAAA'; - elemDefault.startDate = currentDate; - elemDefault.endDate = currentDate; - elemDefault.complaintsEnabled = false; - elemDefault.studentQuestionsEnabled = false; +describe('Course Service', () => { + let injector: TestBed; + let service: CourseManagementService; + let httpMock: HttpTestingController; + let elemDefault: Course; + let currentDate: moment.Moment; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], + providers: [ + { provide: Router, useClass: MockRouter }, + { provide: LocalStorageService, useClass: MockSyncStorage }, + { provide: SessionStorageService, useClass: MockSyncStorage }, + { provide: TranslateService, useClass: MockTranslateService }, + ], }); + injector = getTestBed(); + service = injector.get(CourseManagementService); + httpMock = injector.get(HttpTestingController); + currentDate = moment(); - describe('Service methods', async () => { - it('should find an element', async () => { - const returnedFromService = Object.assign( - { - startDate: currentDate.format(DATE_TIME_FORMAT), - endDate: currentDate.format(DATE_TIME_FORMAT), - }, - elemDefault, - ); - service - .find(123) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: elemDefault })); - - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify(returnedFromService)); - }); - - it('should create a Course', async () => { - const returnedFromService = Object.assign( - { - id: 0, - startDate: currentDate.format(DATE_TIME_FORMAT), - endDate: currentDate.format(DATE_TIME_FORMAT), - }, - elemDefault, - ); - const expected = Object.assign( - { - startDate: currentDate, - endDate: currentDate, - }, - returnedFromService, - ); - service - .create(new Course()) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); - const req = httpMock.expectOne({ method: 'POST' }); - req.flush(JSON.stringify(returnedFromService)); - }); + elemDefault = new Course(); + elemDefault.id = 0; + elemDefault.title = 'AAAAAAA'; + elemDefault.description = 'AAAAAAA'; + elemDefault.shortName = 'AAAAAAA'; + elemDefault.title = 'AAAAAAA'; + elemDefault.startDate = currentDate; + elemDefault.endDate = currentDate; + elemDefault.complaintsEnabled = false; + elemDefault.studentQuestionsEnabled = false; + }); - it('should update a Course', async () => { - const returnedFromService = Object.assign( - { - title: 'BBBBBB', - studentGroupName: 'BBBBBB', - teachingAssistantGroupName: 'BBBBBB', - instructorGroupName: 'BBBBBB', - startDate: currentDate.format(DATE_TIME_FORMAT), - endDate: currentDate.format(DATE_TIME_FORMAT), - onlineCourse: true, - }, - elemDefault, - ); + describe('Service methods', async () => { + it('should find an element', async () => { + const returnedFromService = Object.assign( + { + startDate: currentDate.format(DATE_TIME_FORMAT), + endDate: currentDate.format(DATE_TIME_FORMAT), + }, + elemDefault, + ); + service + .find(123) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: elemDefault })); - const expected = Object.assign( - { - startDate: currentDate, - endDate: currentDate, - }, - returnedFromService, - ); - service - .update(expected) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); - const req = httpMock.expectOne({ method: 'PUT' }); - req.flush(JSON.stringify(returnedFromService)); - }); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify(returnedFromService)); + }); - it('should return a list of Course', async () => { - const returnedFromService = Object.assign( - { - title: 'BBBBBB', - studentGroupName: 'BBBBBB', - teachingAssistantGroupName: 'BBBBBB', - instructorGroupName: 'BBBBBB', - startDate: currentDate.format(DATE_TIME_FORMAT), - endDate: currentDate.format(DATE_TIME_FORMAT), - onlineCourse: true, - }, - elemDefault, - ); - const expected = Object.assign( - { - startDate: currentDate, - endDate: currentDate, - }, - returnedFromService, - ); - service - .findAll(expected) - .pipe( - take(1), - map((resp) => resp.body), - ) - .subscribe((body) => expect(body).toContainEqual(expected)); - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify([returnedFromService])); - httpMock.verify(); - }); + it('should create a Course', async () => { + const returnedFromService = Object.assign( + { + id: 0, + startDate: currentDate.format(DATE_TIME_FORMAT), + endDate: currentDate.format(DATE_TIME_FORMAT), + }, + elemDefault, + ); + const expected = Object.assign( + { + startDate: currentDate, + endDate: currentDate, + }, + returnedFromService, + ); + service + .create(new Course()) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(JSON.stringify(returnedFromService)); + }); - it('should delete a Course', async () => { - service.delete(123).subscribe((resp) => expect(resp.ok)); + it('should update a Course', async () => { + const returnedFromService = Object.assign( + { + title: 'BBBBBB', + studentGroupName: 'BBBBBB', + teachingAssistantGroupName: 'BBBBBB', + instructorGroupName: 'BBBBBB', + startDate: currentDate.format(DATE_TIME_FORMAT), + endDate: currentDate.format(DATE_TIME_FORMAT), + onlineCourse: true, + }, + elemDefault, + ); - const req = httpMock.expectOne({ method: 'DELETE' }); - req.flush({ status: 200 }); - }); + const expected = Object.assign( + { + startDate: currentDate, + endDate: currentDate, + }, + returnedFromService, + ); + service + .update(expected) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(JSON.stringify(returnedFromService)); }); - afterEach(() => { + it('should return a list of Course', async () => { + const returnedFromService = Object.assign( + { + title: 'BBBBBB', + studentGroupName: 'BBBBBB', + teachingAssistantGroupName: 'BBBBBB', + instructorGroupName: 'BBBBBB', + startDate: currentDate.format(DATE_TIME_FORMAT), + endDate: currentDate.format(DATE_TIME_FORMAT), + onlineCourse: true, + }, + elemDefault, + ); + const expected = Object.assign( + { + startDate: currentDate, + endDate: currentDate, + }, + returnedFromService, + ); + service + .findAll(expected) + .pipe( + take(1), + map((resp) => resp.body), + ) + .subscribe((body) => expect(body).toContainEqual(expected)); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify([returnedFromService])); httpMock.verify(); }); + + it('should delete a Course', async () => { + service.delete(123).subscribe((resp) => expect(resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + }); + }); + + afterEach(() => { + httpMock.verify(); }); }); diff --git a/src/test/javascript/spec/service/exercise-hint.service.spec.ts b/src/test/javascript/spec/service/exercise-hint.service.spec.ts index 27b0c6d19fc1..0191614e3469 100644 --- a/src/test/javascript/spec/service/exercise-hint.service.spec.ts +++ b/src/test/javascript/spec/service/exercise-hint.service.spec.ts @@ -8,89 +8,87 @@ import { ExerciseHint } from 'app/entities/exercise-hint.model'; const expect = chai.expect; -describe('Service Tests', () => { - describe('ExerciseHint Service', () => { - let injector: TestBed; - let service: ExerciseHintService; - let httpMock: HttpTestingController; - let elemDefault: ExerciseHint; - let expectedResult: any; +describe('ExerciseHint Service', () => { + let injector: TestBed; + let service: ExerciseHintService; + let httpMock: HttpTestingController; + let elemDefault: ExerciseHint; + let expectedResult: any; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - }); - expectedResult = {} as HttpResponse; - injector = getTestBed(); - service = injector.get(ExerciseHintService); - httpMock = injector.get(HttpTestingController); - - elemDefault = new ExerciseHint(); - elemDefault.id = 0; - elemDefault.title = 'AAAAAAA'; - elemDefault.content = 'AAAAAAA'; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], }); + expectedResult = {} as HttpResponse; + injector = getTestBed(); + service = injector.get(ExerciseHintService); + httpMock = injector.get(HttpTestingController); - describe('Service methods', () => { - it('should find an element', async () => { - const returnedFromService = Object.assign({}, elemDefault); - service - .find(123) - .pipe(take(1)) - .subscribe((resp) => (expectedResult = resp)); - - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(returnedFromService); - expect(expectedResult.body).to.deep.equal(elemDefault); - }); + elemDefault = new ExerciseHint(); + elemDefault.id = 0; + elemDefault.title = 'AAAAAAA'; + elemDefault.content = 'AAAAAAA'; + }); - it('should create a ExerciseHint', async () => { - const returnedFromService = Object.assign( - { - id: 0, - }, - elemDefault, - ); - const expected = Object.assign({}, returnedFromService); - service - .create(new ExerciseHint()) - .pipe(take(1)) - .subscribe((resp) => (expectedResult = resp)); - const req = httpMock.expectOne({ method: 'POST' }); - req.flush(returnedFromService); - expect(expectedResult.body).to.deep.equal(expected); - }); + describe('Service methods', () => { + it('should find an element', async () => { + const returnedFromService = Object.assign({}, elemDefault); + service + .find(123) + .pipe(take(1)) + .subscribe((resp) => (expectedResult = resp)); - it('should update a ExerciseHint', async () => { - const returnedFromService = Object.assign( - { - title: 'BBBBBB', - content: 'BBBBBB', - }, - elemDefault, - ); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(returnedFromService); + expect(expectedResult.body).to.deep.equal(elemDefault); + }); - const expected = Object.assign({}, returnedFromService); - service - .update(expected) - .pipe(take(1)) - .subscribe((resp) => (expectedResult = resp)); - const req = httpMock.expectOne({ method: 'PUT' }); - req.flush(returnedFromService); - expect(expectedResult.body).to.deep.equal(expected); - }); + it('should create a ExerciseHint', async () => { + const returnedFromService = Object.assign( + { + id: 0, + }, + elemDefault, + ); + const expected = Object.assign({}, returnedFromService); + service + .create(new ExerciseHint()) + .pipe(take(1)) + .subscribe((resp) => (expectedResult = resp)); + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(returnedFromService); + expect(expectedResult.body).to.deep.equal(expected); + }); - it('should delete a ExerciseHint', async () => { - service.delete(123).subscribe((resp) => (expectedResult = resp.ok)); + it('should update a ExerciseHint', async () => { + const returnedFromService = Object.assign( + { + title: 'BBBBBB', + content: 'BBBBBB', + }, + elemDefault, + ); - const req = httpMock.expectOne({ method: 'DELETE' }); - req.flush({ status: 200 }); - expect(expectedResult).to.be.true; - }); + const expected = Object.assign({}, returnedFromService); + service + .update(expected) + .pipe(take(1)) + .subscribe((resp) => (expectedResult = resp)); + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(returnedFromService); + expect(expectedResult.body).to.deep.equal(expected); }); - afterEach(() => { - httpMock.verify(); + it('should delete a ExerciseHint', async () => { + service.delete(123).subscribe((resp) => (expectedResult = resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + expect(expectedResult).to.be.true; }); }); + + afterEach(() => { + httpMock.verify(); + }); }); diff --git a/src/test/javascript/spec/service/file-upload-exercise.service.spec.ts b/src/test/javascript/spec/service/file-upload-exercise.service.spec.ts index 43ac22028f76..3590c82fb231 100644 --- a/src/test/javascript/spec/service/file-upload-exercise.service.spec.ts +++ b/src/test/javascript/spec/service/file-upload-exercise.service.spec.ts @@ -4,98 +4,96 @@ import { map, take } from 'rxjs/operators'; import { FileUploadExerciseService } from 'app/exercises/file-upload/manage/file-upload-exercise.service'; import { FileUploadExercise } from 'app/entities/file-upload-exercise.model'; -describe('Service Tests', () => { - describe('FileUploadExercise Service', () => { - let injector: TestBed; - let service: FileUploadExerciseService; - let httpMock: HttpTestingController; - let elemDefault: FileUploadExercise; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - }); - injector = getTestBed(); - service = injector.get(FileUploadExerciseService); - httpMock = injector.get(HttpTestingController); - - elemDefault = new FileUploadExercise(0); +describe('FileUploadExercise Service', () => { + let injector: TestBed; + let service: FileUploadExerciseService; + let httpMock: HttpTestingController; + let elemDefault: FileUploadExercise; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], }); + injector = getTestBed(); + service = injector.get(FileUploadExerciseService); + httpMock = injector.get(HttpTestingController); - describe('Service methods', async () => { - it('should find an element', async () => { - const returnedFromService = Object.assign({}, elemDefault); - service - .find(123) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: elemDefault })); - - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify(returnedFromService)); - }); - - it('should create a FileUploadExercise', async () => { - const returnedFromService = Object.assign( - { - id: 0, - }, - elemDefault, - ); - const expected = Object.assign({}, returnedFromService); - service - .create(new FileUploadExercise(null)) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); - const req = httpMock.expectOne({ method: 'POST' }); - req.flush(JSON.stringify(returnedFromService)); - }); + elemDefault = new FileUploadExercise(0); + }); - it('should update a FileUploadExercise', async () => { - const returnedFromService = Object.assign( - { - filePattern: 'BBBBBB', - }, - elemDefault, - ); + describe('Service methods', async () => { + it('should find an element', async () => { + const returnedFromService = Object.assign({}, elemDefault); + service + .find(123) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: elemDefault })); - const expected = Object.assign({}, returnedFromService); - service - .update(expected) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); - const req = httpMock.expectOne({ method: 'PUT' }); - req.flush(JSON.stringify(returnedFromService)); - }); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify(returnedFromService)); + }); - it('should return a list of FileUploadExercise', async () => { - const returnedFromService = Object.assign( - { - filePattern: 'BBBBBB', - }, - elemDefault, - ); - const expected = Object.assign({}, returnedFromService); - service - .query(expected) - .pipe( - take(1), - map((resp) => resp.body), - ) - .subscribe((body) => expect(body).toContainEqual(expected)); - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify([returnedFromService])); - httpMock.verify(); - }); + it('should create a FileUploadExercise', async () => { + const returnedFromService = Object.assign( + { + id: 0, + }, + elemDefault, + ); + const expected = Object.assign({}, returnedFromService); + service + .create(new FileUploadExercise(null)) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(JSON.stringify(returnedFromService)); + }); - it('should delete a FileUploadExercise', async () => { - service.delete(123).subscribe((resp) => expect(resp.ok)); + it('should update a FileUploadExercise', async () => { + const returnedFromService = Object.assign( + { + filePattern: 'BBBBBB', + }, + elemDefault, + ); - const req = httpMock.expectOne({ method: 'DELETE' }); - req.flush({ status: 200 }); - }); + const expected = Object.assign({}, returnedFromService); + service + .update(expected) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(JSON.stringify(returnedFromService)); }); - afterEach(() => { + it('should return a list of FileUploadExercise', async () => { + const returnedFromService = Object.assign( + { + filePattern: 'BBBBBB', + }, + elemDefault, + ); + const expected = Object.assign({}, returnedFromService); + service + .query(expected) + .pipe( + take(1), + map((resp) => resp.body), + ) + .subscribe((body) => expect(body).toContainEqual(expected)); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify([returnedFromService])); httpMock.verify(); }); + + it('should delete a FileUploadExercise', async () => { + service.delete(123).subscribe((resp) => expect(resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + }); + }); + + afterEach(() => { + httpMock.verify(); }); }); diff --git a/src/test/javascript/spec/service/file-upload-submission.service.spec.ts b/src/test/javascript/spec/service/file-upload-submission.service.spec.ts index aeb5db84f198..89315e34b065 100644 --- a/src/test/javascript/spec/service/file-upload-submission.service.spec.ts +++ b/src/test/javascript/spec/service/file-upload-submission.service.spec.ts @@ -4,98 +4,96 @@ import { map, take } from 'rxjs/operators'; import { FileUploadSubmissionService } from 'app/exercises/file-upload/participate/file-upload-submission.service'; import { FileUploadSubmission } from 'app/entities/file-upload-submission.model'; -describe('Service Tests', () => { - describe('FileUploadSubmission Service', () => { - let injector: TestBed; - let service: FileUploadSubmissionService; - let httpMock: HttpTestingController; - let elemDefault: FileUploadSubmission; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - }); - injector = getTestBed(); - service = injector.get(FileUploadSubmissionService); - httpMock = injector.get(HttpTestingController); - - elemDefault = new FileUploadSubmission(); +describe('FileUploadSubmission Service', () => { + let injector: TestBed; + let service: FileUploadSubmissionService; + let httpMock: HttpTestingController; + let elemDefault: FileUploadSubmission; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], }); + injector = getTestBed(); + service = injector.get(FileUploadSubmissionService); + httpMock = injector.get(HttpTestingController); - describe('Service methods', async () => { - it('should find an element', async () => { - const returnedFromService = Object.assign({}, elemDefault); - service - .find(123) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: elemDefault })); - - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify(returnedFromService)); - }); - - it('should create a FileUploadSubmission', async () => { - const returnedFromService = Object.assign( - { - id: 0, - }, - elemDefault, - ); - const expected = Object.assign({}, returnedFromService); - service - .create(new FileUploadSubmission(null)) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); - const req = httpMock.expectOne({ method: 'POST' }); - req.flush(JSON.stringify(returnedFromService)); - }); + elemDefault = new FileUploadSubmission(); + }); - it('should update a FileUploadSubmission', async () => { - const returnedFromService = Object.assign( - { - filePath: 'BBBBBB', - }, - elemDefault, - ); + describe('Service methods', async () => { + it('should find an element', async () => { + const returnedFromService = Object.assign({}, elemDefault); + service + .find(123) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: elemDefault })); - const expected = Object.assign({}, returnedFromService); - service - .update(expected) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); - const req = httpMock.expectOne({ method: 'PUT' }); - req.flush(JSON.stringify(returnedFromService)); - }); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify(returnedFromService)); + }); - it('should return a list of FileUploadSubmission', async () => { - const returnedFromService = Object.assign( - { - filePath: 'BBBBBB', - }, - elemDefault, - ); - const expected = Object.assign({}, returnedFromService); - service - .query(expected) - .pipe( - take(1), - map((resp) => resp.body), - ) - .subscribe((body) => expect(body).toContainEqual(expected)); - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify([returnedFromService])); - httpMock.verify(); - }); + it('should create a FileUploadSubmission', async () => { + const returnedFromService = Object.assign( + { + id: 0, + }, + elemDefault, + ); + const expected = Object.assign({}, returnedFromService); + service + .create(new FileUploadSubmission(null)) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(JSON.stringify(returnedFromService)); + }); - it('should delete a FileUploadSubmission', async () => { - service.delete(123).subscribe((resp) => expect(resp.ok)); + it('should update a FileUploadSubmission', async () => { + const returnedFromService = Object.assign( + { + filePath: 'BBBBBB', + }, + elemDefault, + ); - const req = httpMock.expectOne({ method: 'DELETE' }); - req.flush({ status: 200 }); - }); + const expected = Object.assign({}, returnedFromService); + service + .update(expected) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(JSON.stringify(returnedFromService)); }); - afterEach(() => { + it('should return a list of FileUploadSubmission', async () => { + const returnedFromService = Object.assign( + { + filePath: 'BBBBBB', + }, + elemDefault, + ); + const expected = Object.assign({}, returnedFromService); + service + .query(expected) + .pipe( + take(1), + map((resp) => resp.body), + ) + .subscribe((body) => expect(body).toContainEqual(expected)); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify([returnedFromService])); httpMock.verify(); }); + + it('should delete a FileUploadSubmission', async () => { + service.delete(123).subscribe((resp) => expect(resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + }); + }); + + afterEach(() => { + httpMock.verify(); }); }); diff --git a/src/test/javascript/spec/service/logs.service.spec.ts b/src/test/javascript/spec/service/logs.service.spec.ts index 90fddfc143e6..cb5ab300165b 100644 --- a/src/test/javascript/spec/service/logs.service.spec.ts +++ b/src/test/javascript/spec/service/logs.service.spec.ts @@ -5,54 +5,52 @@ import { Log } from 'app/admin/logs/log.model'; import { SERVER_API_URL } from 'app/app.constants'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; -describe('Service Tests', () => { - describe('Logs Service', () => { - let service: LogsService; - let httpMock; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - }); +describe('Logs Service', () => { + let service: LogsService; + let httpMock; - service = TestBed.inject(LogsService); - httpMock = TestBed.inject(HttpTestingController); + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], }); - afterEach(() => { - httpMock.verify(); - }); + service = TestBed.inject(LogsService); + httpMock = TestBed.inject(HttpTestingController); + }); - describe('Service methods', () => { - it('should call correct URL', () => { - service.findAll().subscribe(() => {}); + afterEach(() => { + httpMock.verify(); + }); - const req = httpMock.expectOne({ method: 'GET' }); - const resourceUrl = SERVER_API_URL + 'management/logs'; - expect(req.request.url).toEqual(resourceUrl); - }); + describe('Service methods', () => { + it('should call correct URL', () => { + service.findAll().subscribe(() => {}); - it('should return Logs', () => { - const log = new Log('main', 'ERROR'); + const req = httpMock.expectOne({ method: 'GET' }); + const resourceUrl = SERVER_API_URL + 'management/logs'; + expect(req.request.url).toEqual(resourceUrl); + }); - service.findAll().subscribe((received) => { - expect(received.body[0]).toEqual(log); - }); + it('should return Logs', () => { + const log = new Log('main', 'ERROR'); - const req = httpMock.expectOne({ method: 'GET' }); - req.flush([log]); + service.findAll().subscribe((received) => { + expect(received.body[0]).toEqual(log); }); - it('should change log level', () => { - const log = new Log('main', 'ERROR'); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush([log]); + }); - service.changeLevel(log).subscribe((received) => { - expect(received.body[0]).toEqual(log); - }); + it('should change log level', () => { + const log = new Log('main', 'ERROR'); - const req = httpMock.expectOne({ method: 'PUT' }); - req.flush([log]); + service.changeLevel(log).subscribe((received) => { + expect(received.body[0]).toEqual(log); }); + + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush([log]); }); }); }); diff --git a/src/test/javascript/spec/service/metrics.service.spec.ts b/src/test/javascript/spec/service/metrics.service.spec.ts index dde4b224653c..b0e4d3c68741 100644 --- a/src/test/javascript/spec/service/metrics.service.spec.ts +++ b/src/test/javascript/spec/service/metrics.service.spec.ts @@ -4,54 +4,52 @@ import { JhiMetricsService } from 'app/admin/metrics/metrics.service'; import { SERVER_API_URL } from 'app/app.constants'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; -describe('Service Tests', () => { - describe('Logs Service', () => { - let service: JhiMetricsService; - let httpMock; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - }); +describe('Logs Service', () => { + let service: JhiMetricsService; + let httpMock; - service = TestBed.inject(JhiMetricsService); - httpMock = TestBed.inject(HttpTestingController); + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], }); - afterEach(() => { - httpMock.verify(); - }); + service = TestBed.inject(JhiMetricsService); + httpMock = TestBed.inject(HttpTestingController); + }); - describe('Service methods', () => { - it('should call correct URL', () => { - service.getMetrics().subscribe(() => {}); + afterEach(() => { + httpMock.verify(); + }); - const req = httpMock.expectOne({ method: 'GET' }); - const resourceUrl = SERVER_API_URL + 'management/jhimetrics'; - expect(req.request.url).toEqual(resourceUrl); - }); + describe('Service methods', () => { + it('should call correct URL', () => { + service.getMetrics().subscribe(() => {}); - it('should return Metrics', () => { - const metrics = []; + const req = httpMock.expectOne({ method: 'GET' }); + const resourceUrl = SERVER_API_URL + 'management/jhimetrics'; + expect(req.request.url).toEqual(resourceUrl); + }); - service.getMetrics().subscribe((received) => { - expect(received.body[0]).toEqual(metrics); - }); + it('should return Metrics', () => { + const metrics = []; - const req = httpMock.expectOne({ method: 'GET' }); - req.flush([metrics]); + service.getMetrics().subscribe((received) => { + expect(received.body[0]).toEqual(metrics); }); - it('should return Thread Dump', () => { - const dump = [{ name: 'test1', threadState: 'RUNNABLE' }]; + const req = httpMock.expectOne({ method: 'GET' }); + req.flush([metrics]); + }); - service.threadDump().subscribe((received) => { - expect(received.body[0]).toEqual(dump); - }); + it('should return Thread Dump', () => { + const dump = [{ name: 'test1', threadState: 'RUNNABLE' }]; - const req = httpMock.expectOne({ method: 'GET' }); - req.flush([dump]); + service.threadDump().subscribe((received) => { + expect(received.body[0]).toEqual(dump); }); + + const req = httpMock.expectOne({ method: 'GET' }); + req.flush([dump]); }); }); }); diff --git a/src/test/javascript/spec/service/modeling-exercise.service.spec.ts b/src/test/javascript/spec/service/modeling-exercise.service.spec.ts index d77031074fca..adc47e81432b 100644 --- a/src/test/javascript/spec/service/modeling-exercise.service.spec.ts +++ b/src/test/javascript/spec/service/modeling-exercise.service.spec.ts @@ -4,102 +4,100 @@ import { map, take } from 'rxjs/operators'; import { ModelingExerciseService } from 'app/exercises/modeling/manage/modeling-exercise.service'; import { DiagramType, ModelingExercise } from 'app/entities/modeling-exercise.model'; -describe('Service Tests', () => { - describe('ModelingExercise Service', () => { - let injector: TestBed; - let service: ModelingExerciseService; - let httpMock: HttpTestingController; - let elemDefault: ModelingExercise; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - }); - injector = getTestBed(); - service = injector.get(ModelingExerciseService); - httpMock = injector.get(HttpTestingController); - - elemDefault = new ModelingExercise(DiagramType.ComponentDiagram); +describe('ModelingExercise Service', () => { + let injector: TestBed; + let service: ModelingExerciseService; + let httpMock: HttpTestingController; + let elemDefault: ModelingExercise; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], }); + injector = getTestBed(); + service = injector.get(ModelingExerciseService); + httpMock = injector.get(HttpTestingController); - describe('Service methods', async () => { - it('should find an element', async () => { - const returnedFromService = Object.assign({}, elemDefault); - service - .find(123) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: elemDefault })); - - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify(returnedFromService)); - }); - - it('should create a ModelingExercise', async () => { - const returnedFromService = Object.assign( - { - id: 0, - }, - elemDefault, - ); - const expected = Object.assign({}, returnedFromService); - service - .create(new ModelingExercise(null)) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); - const req = httpMock.expectOne({ method: 'POST' }); - req.flush(JSON.stringify(returnedFromService)); - }); + elemDefault = new ModelingExercise(DiagramType.ComponentDiagram); + }); - it('should update a ModelingExercise', async () => { - const returnedFromService = Object.assign( - { - diagramType: 'BBBBBB', - sampleSolutionModel: 'BBBBBB', - sampleSolutionExplanation: 'BBBBBB', - }, - elemDefault, - ); + describe('Service methods', async () => { + it('should find an element', async () => { + const returnedFromService = Object.assign({}, elemDefault); + service + .find(123) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: elemDefault })); - const expected = Object.assign({}, returnedFromService); - service - .update(expected) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); - const req = httpMock.expectOne({ method: 'PUT' }); - req.flush(JSON.stringify(returnedFromService)); - }); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify(returnedFromService)); + }); - it('should return a list of ModelingExercise', async () => { - const returnedFromService = Object.assign( - { - diagramType: 'BBBBBB', - sampleSolutionModel: 'BBBBBB', - sampleSolutionExplanation: 'BBBBBB', - }, - elemDefault, - ); - const expected = Object.assign({}, returnedFromService); - service - .query(expected) - .pipe( - take(1), - map((resp) => resp.body), - ) - .subscribe((body) => expect(body).toContainEqual(expected)); - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify([returnedFromService])); - httpMock.verify(); - }); + it('should create a ModelingExercise', async () => { + const returnedFromService = Object.assign( + { + id: 0, + }, + elemDefault, + ); + const expected = Object.assign({}, returnedFromService); + service + .create(new ModelingExercise(null)) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(JSON.stringify(returnedFromService)); + }); - it('should delete a ModelingExercise', async () => { - service.delete(123).subscribe((resp) => expect(resp.ok)); + it('should update a ModelingExercise', async () => { + const returnedFromService = Object.assign( + { + diagramType: 'BBBBBB', + sampleSolutionModel: 'BBBBBB', + sampleSolutionExplanation: 'BBBBBB', + }, + elemDefault, + ); - const req = httpMock.expectOne({ method: 'DELETE' }); - req.flush({ status: 200 }); - }); + const expected = Object.assign({}, returnedFromService); + service + .update(expected) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(JSON.stringify(returnedFromService)); }); - afterEach(() => { + it('should return a list of ModelingExercise', async () => { + const returnedFromService = Object.assign( + { + diagramType: 'BBBBBB', + sampleSolutionModel: 'BBBBBB', + sampleSolutionExplanation: 'BBBBBB', + }, + elemDefault, + ); + const expected = Object.assign({}, returnedFromService); + service + .query(expected) + .pipe( + take(1), + map((resp) => resp.body), + ) + .subscribe((body) => expect(body).toContainEqual(expected)); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify([returnedFromService])); httpMock.verify(); }); + + it('should delete a ModelingExercise', async () => { + service.delete(123).subscribe((resp) => expect(resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + }); + }); + + afterEach(() => { + httpMock.verify(); }); }); diff --git a/src/test/javascript/spec/service/modeling-submission.service.spec.ts b/src/test/javascript/spec/service/modeling-submission.service.spec.ts index fbf1f3143a41..8e56ccac6a3c 100644 --- a/src/test/javascript/spec/service/modeling-submission.service.spec.ts +++ b/src/test/javascript/spec/service/modeling-submission.service.spec.ts @@ -4,100 +4,98 @@ import { map, take } from 'rxjs/operators'; import { ModelingSubmissionService } from 'app/exercises/modeling/participate/modeling-submission.service'; import { ModelingSubmission } from 'app/entities/modeling-submission.model'; -describe('Service Tests', () => { - describe('ModelingSubmission Service', () => { - let injector: TestBed; - let service: ModelingSubmissionService; - let httpMock: HttpTestingController; - let elemDefault: ModelingSubmission; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - }); - injector = getTestBed(); - service = injector.get(ModelingSubmissionService); - httpMock = injector.get(HttpTestingController); - - elemDefault = new ModelingSubmission(); +describe('ModelingSubmission Service', () => { + let injector: TestBed; + let service: ModelingSubmissionService; + let httpMock: HttpTestingController; + let elemDefault: ModelingSubmission; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], }); + injector = getTestBed(); + service = injector.get(ModelingSubmissionService); + httpMock = injector.get(HttpTestingController); - describe('Service methods', async () => { - it('should find an element', async () => { - const returnedFromService = Object.assign({}, elemDefault); - service - .find(123) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: elemDefault })); - - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify(returnedFromService)); - }); - - it('should create a ModelingSubmission', async () => { - const returnedFromService = Object.assign( - { - id: 0, - }, - elemDefault, - ); - const expected = Object.assign({}, returnedFromService); - service - .create(new ModelingSubmission(null)) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); - const req = httpMock.expectOne({ method: 'POST' }); - req.flush(JSON.stringify(returnedFromService)); - }); + elemDefault = new ModelingSubmission(); + }); - it('should update a ModelingSubmission', async () => { - const returnedFromService = Object.assign( - { - model: 'BBBBBB', - explanationText: 'BBBBBB', - }, - elemDefault, - ); + describe('Service methods', async () => { + it('should find an element', async () => { + const returnedFromService = Object.assign({}, elemDefault); + service + .find(123) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: elemDefault })); - const expected = Object.assign({}, returnedFromService); - service - .update(expected) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); - const req = httpMock.expectOne({ method: 'PUT' }); - req.flush(JSON.stringify(returnedFromService)); - }); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify(returnedFromService)); + }); - it('should return a list of ModelingSubmission', async () => { - const returnedFromService = Object.assign( - { - model: 'BBBBBB', - explanationText: 'BBBBBB', - }, - elemDefault, - ); - const expected = Object.assign({}, returnedFromService); - service - .query(expected) - .pipe( - take(1), - map((resp) => resp.body), - ) - .subscribe((body) => expect(body).toContainEqual(expected)); - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify([returnedFromService])); - httpMock.verify(); - }); + it('should create a ModelingSubmission', async () => { + const returnedFromService = Object.assign( + { + id: 0, + }, + elemDefault, + ); + const expected = Object.assign({}, returnedFromService); + service + .create(new ModelingSubmission(null)) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(JSON.stringify(returnedFromService)); + }); - it('should delete a ModelingSubmission', async () => { - service.delete(123).subscribe((resp) => expect(resp.ok)); + it('should update a ModelingSubmission', async () => { + const returnedFromService = Object.assign( + { + model: 'BBBBBB', + explanationText: 'BBBBBB', + }, + elemDefault, + ); - const req = httpMock.expectOne({ method: 'DELETE' }); - req.flush({ status: 200 }); - }); + const expected = Object.assign({}, returnedFromService); + service + .update(expected) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(JSON.stringify(returnedFromService)); }); - afterEach(() => { + it('should return a list of ModelingSubmission', async () => { + const returnedFromService = Object.assign( + { + model: 'BBBBBB', + explanationText: 'BBBBBB', + }, + elemDefault, + ); + const expected = Object.assign({}, returnedFromService); + service + .query(expected) + .pipe( + take(1), + map((resp) => resp.body), + ) + .subscribe((body) => expect(body).toContainEqual(expected)); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify([returnedFromService])); httpMock.verify(); }); + + it('should delete a ModelingSubmission', async () => { + service.delete(123).subscribe((resp) => expect(resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + }); + }); + + afterEach(() => { + httpMock.verify(); }); }); diff --git a/src/test/javascript/spec/service/participation.service.spec.ts b/src/test/javascript/spec/service/participation.service.spec.ts index 483a50c33278..9083084aa86a 100644 --- a/src/test/javascript/spec/service/participation.service.spec.ts +++ b/src/test/javascript/spec/service/participation.service.spec.ts @@ -7,129 +7,127 @@ import { ParticipationService } from 'app/exercises/shared/participation/partici import { Participation } from 'app/entities/participation/participation.model'; import { StudentParticipation } from 'app/entities/participation/student-participation.model'; -describe('Service Tests', () => { - describe('Participation Service', () => { - let injector: TestBed; - let service: ParticipationService; - let httpMock: HttpTestingController; - let elemDefault: Participation; - let currentDate: moment.Moment; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - }); - injector = getTestBed(); - service = injector.get(ParticipationService); - httpMock = injector.get(HttpTestingController); - currentDate = moment(); - - elemDefault = new StudentParticipation(); +describe('Participation Service', () => { + let injector: TestBed; + let service: ParticipationService; + let httpMock: HttpTestingController; + let elemDefault: Participation; + let currentDate: moment.Moment; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], }); + injector = getTestBed(); + service = injector.get(ParticipationService); + httpMock = injector.get(HttpTestingController); + currentDate = moment(); - describe('Service methods', async () => { - it('should find an element', async () => { - const returnedFromService = Object.assign( - { - initializationDate: currentDate.format(DATE_TIME_FORMAT), - }, - elemDefault, - ); - service - .find(123) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: elemDefault })); - - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify(returnedFromService)); - }); - - it('should create a Participation', async () => { - const returnedFromService = Object.assign( - { - id: 0, - initializationDate: currentDate.format(DATE_TIME_FORMAT), - }, - elemDefault, - ); - const expected = Object.assign( - { - initializationDate: currentDate, - }, - returnedFromService, - ); - service - .create(new Participation(null)) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); - const req = httpMock.expectOne({ method: 'POST' }); - req.flush(JSON.stringify(returnedFromService)); - }); + elemDefault = new StudentParticipation(); + }); - it('should update a Participation', async () => { - const returnedFromService = Object.assign( - { - repositoryUrl: 'BBBBBB', - buildPlanId: 'BBBBBB', - initializationState: 'BBBBBB', - initializationDate: currentDate.format(DATE_TIME_FORMAT), - presentationScore: 1, - }, - elemDefault, - ); + describe('Service methods', async () => { + it('should find an element', async () => { + const returnedFromService = Object.assign( + { + initializationDate: currentDate.format(DATE_TIME_FORMAT), + }, + elemDefault, + ); + service + .find(123) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: elemDefault })); - const expected = Object.assign( - { - initializationDate: currentDate, - }, - returnedFromService, - ); - service - .update(expected) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); - const req = httpMock.expectOne({ method: 'PUT' }); - req.flush(JSON.stringify(returnedFromService)); - }); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify(returnedFromService)); + }); - it('should return a list of Participation', async () => { - const returnedFromService = Object.assign( - { - repositoryUrl: 'BBBBBB', - buildPlanId: 'BBBBBB', - initializationState: 'BBBBBB', - initializationDate: currentDate.format(DATE_TIME_FORMAT), - presentationScore: 1, - }, - elemDefault, - ); - const expected = Object.assign( - { - initializationDate: currentDate, - }, - returnedFromService, - ); - service - .query(expected) - .pipe( - take(1), - map((resp) => resp.body), - ) - .subscribe((body) => expect(body).toContainEqual(expected)); - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify([returnedFromService])); - httpMock.verify(); - }); + it('should create a Participation', async () => { + const returnedFromService = Object.assign( + { + id: 0, + initializationDate: currentDate.format(DATE_TIME_FORMAT), + }, + elemDefault, + ); + const expected = Object.assign( + { + initializationDate: currentDate, + }, + returnedFromService, + ); + service + .create(new Participation(null)) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(JSON.stringify(returnedFromService)); + }); - it('should delete a Participation', async () => { - service.delete(123).subscribe((resp) => expect(resp.ok)); + it('should update a Participation', async () => { + const returnedFromService = Object.assign( + { + repositoryUrl: 'BBBBBB', + buildPlanId: 'BBBBBB', + initializationState: 'BBBBBB', + initializationDate: currentDate.format(DATE_TIME_FORMAT), + presentationScore: 1, + }, + elemDefault, + ); - const req = httpMock.expectOne({ method: 'DELETE' }); - req.flush({ status: 200 }); - }); + const expected = Object.assign( + { + initializationDate: currentDate, + }, + returnedFromService, + ); + service + .update(expected) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(JSON.stringify(returnedFromService)); }); - afterEach(() => { + it('should return a list of Participation', async () => { + const returnedFromService = Object.assign( + { + repositoryUrl: 'BBBBBB', + buildPlanId: 'BBBBBB', + initializationState: 'BBBBBB', + initializationDate: currentDate.format(DATE_TIME_FORMAT), + presentationScore: 1, + }, + elemDefault, + ); + const expected = Object.assign( + { + initializationDate: currentDate, + }, + returnedFromService, + ); + service + .query(expected) + .pipe( + take(1), + map((resp) => resp.body), + ) + .subscribe((body) => expect(body).toContainEqual(expected)); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify([returnedFromService])); httpMock.verify(); }); + + it('should delete a Participation', async () => { + service.delete(123).subscribe((resp) => expect(resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + }); + }); + + afterEach(() => { + httpMock.verify(); }); }); diff --git a/src/test/javascript/spec/service/programming-exercise.service.spec.ts b/src/test/javascript/spec/service/programming-exercise.service.spec.ts index 9edaac704acd..1946165ea72d 100644 --- a/src/test/javascript/spec/service/programming-exercise.service.spec.ts +++ b/src/test/javascript/spec/service/programming-exercise.service.spec.ts @@ -4,106 +4,104 @@ import { map, take } from 'rxjs/operators'; import { ProgrammingExerciseService } from 'app/exercises/programming/manage/services/programming-exercise.service'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; -describe('Service Tests', () => { - describe('ProgrammingExercise Service', () => { - let injector: TestBed; - let service: ProgrammingExerciseService; - let httpMock: HttpTestingController; - let elemDefault: ProgrammingExercise; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - }); - injector = getTestBed(); - service = injector.get(ProgrammingExerciseService); - httpMock = injector.get(HttpTestingController); - - elemDefault = new ProgrammingExercise(); +describe('ProgrammingExercise Service', () => { + let injector: TestBed; + let service: ProgrammingExerciseService; + let httpMock: HttpTestingController; + let elemDefault: ProgrammingExercise; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], }); + injector = getTestBed(); + service = injector.get(ProgrammingExerciseService); + httpMock = injector.get(HttpTestingController); - describe('Service methods', async () => { - it('should find an element', async () => { - const returnedFromService = Object.assign({}, elemDefault); - service - .find(123) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: elemDefault })); - - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify(returnedFromService)); - }); - - it('should create a ProgrammingExercise', async () => { - const returnedFromService = Object.assign( - { - id: 0, - }, - elemDefault, - ); - const expected = Object.assign({}, returnedFromService); - service - .create(new ProgrammingExercise(null)) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); - const req = httpMock.expectOne({ method: 'POST' }); - req.flush(JSON.stringify(returnedFromService)); - }); + elemDefault = new ProgrammingExercise(); + }); - it('should update a ProgrammingExercise', async () => { - const returnedFromService = Object.assign( - { - templateRepositoryUrl: 'BBBBBB', - solutionRepositoryUrl: 'BBBBBB', - templateBuildPlanId: 'BBBBBB', - publishBuildPlanUrl: true, - allowOnlineEditor: true, - }, - elemDefault, - ); + describe('Service methods', async () => { + it('should find an element', async () => { + const returnedFromService = Object.assign({}, elemDefault); + service + .find(123) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: elemDefault })); - const expected = Object.assign({}, returnedFromService); - service - .update(expected) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); - const req = httpMock.expectOne({ method: 'PUT' }); - req.flush(JSON.stringify(returnedFromService)); - }); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify(returnedFromService)); + }); - it('should return a list of ProgrammingExercise', async () => { - const returnedFromService = Object.assign( - { - templateRepositoryUrl: 'BBBBBB', - solutionRepositoryUrl: 'BBBBBB', - templateBuildPlanId: 'BBBBBB', - publishBuildPlanUrl: true, - allowOnlineEditor: true, - }, - elemDefault, - ); - const expected = Object.assign({}, returnedFromService); - service - .query(expected) - .pipe( - take(1), - map((resp) => resp.body), - ) - .subscribe((body) => expect(body).toContainEqual(expected)); - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify([returnedFromService])); - httpMock.verify(); - }); + it('should create a ProgrammingExercise', async () => { + const returnedFromService = Object.assign( + { + id: 0, + }, + elemDefault, + ); + const expected = Object.assign({}, returnedFromService); + service + .create(new ProgrammingExercise(null)) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(JSON.stringify(returnedFromService)); + }); - it('should delete a ProgrammingExercise', async () => { - service.delete(123).subscribe((resp) => expect(resp.ok)); + it('should update a ProgrammingExercise', async () => { + const returnedFromService = Object.assign( + { + templateRepositoryUrl: 'BBBBBB', + solutionRepositoryUrl: 'BBBBBB', + templateBuildPlanId: 'BBBBBB', + publishBuildPlanUrl: true, + allowOnlineEditor: true, + }, + elemDefault, + ); - const req = httpMock.expectOne({ method: 'DELETE' }); - req.flush({ status: 200 }); - }); + const expected = Object.assign({}, returnedFromService); + service + .update(expected) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(JSON.stringify(returnedFromService)); }); - afterEach(() => { + it('should return a list of ProgrammingExercise', async () => { + const returnedFromService = Object.assign( + { + templateRepositoryUrl: 'BBBBBB', + solutionRepositoryUrl: 'BBBBBB', + templateBuildPlanId: 'BBBBBB', + publishBuildPlanUrl: true, + allowOnlineEditor: true, + }, + elemDefault, + ); + const expected = Object.assign({}, returnedFromService); + service + .query(expected) + .pipe( + take(1), + map((resp) => resp.body), + ) + .subscribe((body) => expect(body).toContainEqual(expected)); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify([returnedFromService])); httpMock.verify(); }); + + it('should delete a ProgrammingExercise', async () => { + service.delete(123).subscribe((resp) => expect(resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + }); + }); + + afterEach(() => { + httpMock.verify(); }); }); diff --git a/src/test/javascript/spec/service/quiz-exercise.service.spec.ts b/src/test/javascript/spec/service/quiz-exercise.service.spec.ts index 848efc9841b3..2b091f5fa98a 100644 --- a/src/test/javascript/spec/service/quiz-exercise.service.spec.ts +++ b/src/test/javascript/spec/service/quiz-exercise.service.spec.ts @@ -5,112 +5,110 @@ import { QuizExerciseService } from 'app/exercises/quiz/manage/quiz-exercise.ser import { QuizExercise } from 'app/entities/quiz/quiz-exercise.model'; import { Course } from 'app/entities/course.model'; -describe('Service Tests', () => { - describe('QuizExercise Service', () => { - let injector: TestBed; - let service: QuizExerciseService; - let httpMock: HttpTestingController; - let elemDefault: QuizExercise; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - }); - injector = getTestBed(); - service = injector.get(QuizExerciseService); - httpMock = injector.get(HttpTestingController); - - elemDefault = new QuizExercise(new Course()); +describe('QuizExercise Service', () => { + let injector: TestBed; + let service: QuizExerciseService; + let httpMock: HttpTestingController; + let elemDefault: QuizExercise; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], }); + injector = getTestBed(); + service = injector.get(QuizExerciseService); + httpMock = injector.get(HttpTestingController); - describe('Service methods', async () => { - it('should find an element', async () => { - const returnedFromService = Object.assign({}, elemDefault); - service - .find(123) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: elemDefault })); - - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify(returnedFromService)); - }); - - it('should create a QuizExercise', async () => { - const returnedFromService = Object.assign( - { - id: 0, - }, - elemDefault, - ); - const expected = Object.assign({}, returnedFromService); - service - .create(new QuizExercise(null)) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); - const req = httpMock.expectOne({ method: 'POST' }); - req.flush(JSON.stringify(returnedFromService)); - }); + elemDefault = new QuizExercise(new Course()); + }); - it('should update a QuizExercise', async () => { - const returnedFromService = Object.assign( - { - description: 'BBBBBB', - explanation: 'BBBBBB', - randomizeQuestionOrder: true, - allowedNumberOfAttempts: 1, - isVisibleBeforeStart: true, - isOpenForPractice: true, - isPlannedToStart: true, - duration: 1, - }, - elemDefault, - ); + describe('Service methods', async () => { + it('should find an element', async () => { + const returnedFromService = Object.assign({}, elemDefault); + service + .find(123) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: elemDefault })); - const expected = Object.assign({}, returnedFromService); - service - .update(expected) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); - const req = httpMock.expectOne({ method: 'PUT' }); - req.flush(JSON.stringify(returnedFromService)); - }); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify(returnedFromService)); + }); - it('should return a list of QuizExercise', async () => { - const returnedFromService = Object.assign( - { - description: 'BBBBBB', - explanation: 'BBBBBB', - randomizeQuestionOrder: true, - allowedNumberOfAttempts: 1, - isVisibleBeforeStart: true, - isOpenForPractice: true, - isPlannedToStart: true, - duration: 1, - }, - elemDefault, - ); - const expected = Object.assign({}, returnedFromService); - service - .query(expected) - .pipe( - take(1), - map((resp) => resp.body), - ) - .subscribe((body) => expect(body).toContainEqual(expected)); - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify([returnedFromService])); - httpMock.verify(); - }); + it('should create a QuizExercise', async () => { + const returnedFromService = Object.assign( + { + id: 0, + }, + elemDefault, + ); + const expected = Object.assign({}, returnedFromService); + service + .create(new QuizExercise(null)) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(JSON.stringify(returnedFromService)); + }); - it('should delete a QuizExercise', async () => { - service.delete(123).subscribe((resp) => expect(resp.ok)); + it('should update a QuizExercise', async () => { + const returnedFromService = Object.assign( + { + description: 'BBBBBB', + explanation: 'BBBBBB', + randomizeQuestionOrder: true, + allowedNumberOfAttempts: 1, + isVisibleBeforeStart: true, + isOpenForPractice: true, + isPlannedToStart: true, + duration: 1, + }, + elemDefault, + ); - const req = httpMock.expectOne({ method: 'DELETE' }); - req.flush({ status: 200 }); - }); + const expected = Object.assign({}, returnedFromService); + service + .update(expected) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(JSON.stringify(returnedFromService)); }); - afterEach(() => { + it('should return a list of QuizExercise', async () => { + const returnedFromService = Object.assign( + { + description: 'BBBBBB', + explanation: 'BBBBBB', + randomizeQuestionOrder: true, + allowedNumberOfAttempts: 1, + isVisibleBeforeStart: true, + isOpenForPractice: true, + isPlannedToStart: true, + duration: 1, + }, + elemDefault, + ); + const expected = Object.assign({}, returnedFromService); + service + .query(expected) + .pipe( + take(1), + map((resp) => resp.body), + ) + .subscribe((body) => expect(body).toContainEqual(expected)); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify([returnedFromService])); httpMock.verify(); }); + + it('should delete a QuizExercise', async () => { + service.delete(123).subscribe((resp) => expect(resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + }); + }); + + afterEach(() => { + httpMock.verify(); }); }); diff --git a/src/test/javascript/spec/service/student-question-answer.service.spec.ts b/src/test/javascript/spec/service/student-question-answer.service.spec.ts index d2b6517ac948..8b1bb3b5227b 100644 --- a/src/test/javascript/spec/service/student-question-answer.service.spec.ts +++ b/src/test/javascript/spec/service/student-question-answer.service.spec.ts @@ -8,89 +8,87 @@ import { StudentQuestionAnswer } from 'app/entities/student-question-answer.mode const expect = chai.expect; -describe('Service Tests', () => { - describe('ExerciseHint Service', () => { - let injector: TestBed; - let service: StudentQuestionAnswerService; - let httpMock: HttpTestingController; - let elemDefault: StudentQuestionAnswer; - let expectedResult: any; +describe('ExerciseHint Service', () => { + let injector: TestBed; + let service: StudentQuestionAnswerService; + let httpMock: HttpTestingController; + let elemDefault: StudentQuestionAnswer; + let expectedResult: any; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - }); - expectedResult = {} as HttpResponse; - injector = getTestBed(); - service = injector.get(StudentQuestionAnswerService); - httpMock = injector.get(HttpTestingController); - - elemDefault = new StudentQuestionAnswer(); - elemDefault.id = 0; - elemDefault.answerDate = null; - elemDefault.answerText = 'This is a test answer'; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], }); + expectedResult = {} as HttpResponse; + injector = getTestBed(); + service = injector.get(StudentQuestionAnswerService); + httpMock = injector.get(HttpTestingController); - describe('Service methods', () => { - it('should find a StudentQuestionAnswer', async () => { - const returnedFromService = { ...elemDefault }; - service - .find(123) - .pipe(take(1)) - .subscribe((resp) => (expectedResult = resp)); - - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(returnedFromService); - expect(expectedResult.body).to.deep.equal(elemDefault); - }); + elemDefault = new StudentQuestionAnswer(); + elemDefault.id = 0; + elemDefault.answerDate = null; + elemDefault.answerText = 'This is a test answer'; + }); - it('should create a StudentQuestionAnswer', async () => { - const returnedFromService = { ...elemDefault, id: 0 }; - const expected = { ...returnedFromService }; - service - .create(new StudentQuestionAnswer()) - .pipe(take(1)) - .subscribe((resp) => (expectedResult = resp)); - const req = httpMock.expectOne({ method: 'POST' }); - req.flush(returnedFromService); - expect(expectedResult.body).to.deep.equal(expected); - }); + describe('Service methods', () => { + it('should find a StudentQuestionAnswer', async () => { + const returnedFromService = { ...elemDefault }; + service + .find(123) + .pipe(take(1)) + .subscribe((resp) => (expectedResult = resp)); - it('should update a StudentQuestionAnswer text field', async () => { - const returnedFromService = { ...elemDefault, answerText: 'This is another test answer' }; - const expected = { ...returnedFromService }; - service - .update(expected) - .pipe(take(1)) - .subscribe((resp) => (expectedResult = resp)); - const req = httpMock.expectOne({ method: 'PUT' }); - req.flush(returnedFromService); - expect(expectedResult.body).to.deep.equal(expected); - }); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(returnedFromService); + expect(expectedResult.body).to.deep.equal(elemDefault); + }); - it('should update a StudentQuestionAnswer tutorApproved field', async () => { - const returnedFromService = { ...elemDefault, tutorApproved: true }; - const expected = { ...returnedFromService }; - service - .update(expected) - .pipe(take(1)) - .subscribe((resp) => (expectedResult = resp)); - const req = httpMock.expectOne({ method: 'PUT' }); - req.flush(returnedFromService); - expect(expectedResult.body).to.deep.equal(expected); - }); + it('should create a StudentQuestionAnswer', async () => { + const returnedFromService = { ...elemDefault, id: 0 }; + const expected = { ...returnedFromService }; + service + .create(new StudentQuestionAnswer()) + .pipe(take(1)) + .subscribe((resp) => (expectedResult = resp)); + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(returnedFromService); + expect(expectedResult.body).to.deep.equal(expected); + }); - it('should delete a StudentQuestionAnswer', async () => { - service.delete(123).subscribe((resp) => (expectedResult = resp.ok)); + it('should update a StudentQuestionAnswer text field', async () => { + const returnedFromService = { ...elemDefault, answerText: 'This is another test answer' }; + const expected = { ...returnedFromService }; + service + .update(expected) + .pipe(take(1)) + .subscribe((resp) => (expectedResult = resp)); + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(returnedFromService); + expect(expectedResult.body).to.deep.equal(expected); + }); - const req = httpMock.expectOne({ method: 'DELETE' }); - req.flush({ status: 200 }); - expect(expectedResult).to.be.true; - }); + it('should update a StudentQuestionAnswer tutorApproved field', async () => { + const returnedFromService = { ...elemDefault, tutorApproved: true }; + const expected = { ...returnedFromService }; + service + .update(expected) + .pipe(take(1)) + .subscribe((resp) => (expectedResult = resp)); + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(returnedFromService); + expect(expectedResult.body).to.deep.equal(expected); }); - afterEach(() => { - httpMock.verify(); + it('should delete a StudentQuestionAnswer', async () => { + service.delete(123).subscribe((resp) => (expectedResult = resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + expect(expectedResult).to.be.true; }); }); + + afterEach(() => { + httpMock.verify(); + }); }); diff --git a/src/test/javascript/spec/service/student-question.service.spec.ts b/src/test/javascript/spec/service/student-question.service.spec.ts index 7d70c08bf88b..fdeba820b88f 100644 --- a/src/test/javascript/spec/service/student-question.service.spec.ts +++ b/src/test/javascript/spec/service/student-question.service.spec.ts @@ -8,66 +8,64 @@ import { StudentQuestion } from 'app/entities/student-question.model'; const expect = chai.expect; -describe('Service Tests', () => { - describe('ExerciseHint Service', () => { - let injector: TestBed; - let service: StudentQuestionService; - let httpMock: HttpTestingController; - let elemDefault: StudentQuestion; - let expectedResult: any; +describe('ExerciseHint Service', () => { + let injector: TestBed; + let service: StudentQuestionService; + let httpMock: HttpTestingController; + let elemDefault: StudentQuestion; + let expectedResult: any; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - }); - expectedResult = {} as HttpResponse; - injector = getTestBed(); - service = injector.get(StudentQuestionService); - httpMock = injector.get(HttpTestingController); - - elemDefault = new StudentQuestion(); - elemDefault.id = 0; - elemDefault.creationDate = null; - elemDefault.questionText = 'This is a test question'; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], }); + expectedResult = {} as HttpResponse; + injector = getTestBed(); + service = injector.get(StudentQuestionService); + httpMock = injector.get(HttpTestingController); - describe('Service methods', () => { - it('should create a StudentQuestion', async () => { - const returnedFromService = { ...elemDefault, id: 0 }; - const expected = { ...returnedFromService }; - service - .create(new StudentQuestion()) - .pipe(take(1)) - .subscribe((resp) => (expectedResult = resp)); - const req = httpMock.expectOne({ method: 'POST' }); - req.flush(returnedFromService); - expect(expectedResult.body).to.deep.equal(expected); - }); - - it('should update a StudentQuestion', async () => { - const returnedFromService = { ...elemDefault, questionText: 'This is another test question' }; + elemDefault = new StudentQuestion(); + elemDefault.id = 0; + elemDefault.creationDate = null; + elemDefault.questionText = 'This is a test question'; + }); - const expected = { ...returnedFromService }; - service - .update(expected) - .pipe(take(1)) - .subscribe((resp) => (expectedResult = resp)); - const req = httpMock.expectOne({ method: 'PUT' }); - req.flush(returnedFromService); - expect(expectedResult.body).to.deep.equal(expected); - }); + describe('Service methods', () => { + it('should create a StudentQuestion', async () => { + const returnedFromService = { ...elemDefault, id: 0 }; + const expected = { ...returnedFromService }; + service + .create(new StudentQuestion()) + .pipe(take(1)) + .subscribe((resp) => (expectedResult = resp)); + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(returnedFromService); + expect(expectedResult.body).to.deep.equal(expected); + }); - it('should delete a StudentQuestion', async () => { - service.delete(123).subscribe((resp) => (expectedResult = resp.ok)); + it('should update a StudentQuestion', async () => { + const returnedFromService = { ...elemDefault, questionText: 'This is another test question' }; - const req = httpMock.expectOne({ method: 'DELETE' }); - req.flush({ status: 200 }); - expect(expectedResult).to.be.true; - }); + const expected = { ...returnedFromService }; + service + .update(expected) + .pipe(take(1)) + .subscribe((resp) => (expectedResult = resp)); + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(returnedFromService); + expect(expectedResult.body).to.deep.equal(expected); }); - afterEach(() => { - httpMock.verify(); + it('should delete a StudentQuestion', async () => { + service.delete(123).subscribe((resp) => (expectedResult = resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + expect(expectedResult).to.be.true; }); }); + + afterEach(() => { + httpMock.verify(); + }); }); diff --git a/src/test/javascript/spec/service/text-exercise.service.spec.ts b/src/test/javascript/spec/service/text-exercise.service.spec.ts index 0d69cdc88ed3..d994f571de4b 100644 --- a/src/test/javascript/spec/service/text-exercise.service.spec.ts +++ b/src/test/javascript/spec/service/text-exercise.service.spec.ts @@ -5,98 +5,96 @@ import { TextExerciseService } from 'app/exercises/text/manage/text-exercise/tex import { TextExercise } from 'app/entities/text-exercise.model'; import { Course } from 'app/entities/course.model'; -describe('Service Tests', () => { - describe('TextExercise Service', () => { - let injector: TestBed; - let service: TextExerciseService; - let httpMock: HttpTestingController; - let elemDefault: TextExercise; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - }); - injector = getTestBed(); - service = injector.get(TextExerciseService); - httpMock = injector.get(HttpTestingController); - - elemDefault = new TextExercise(new Course()); +describe('TextExercise Service', () => { + let injector: TestBed; + let service: TextExerciseService; + let httpMock: HttpTestingController; + let elemDefault: TextExercise; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], }); + injector = getTestBed(); + service = injector.get(TextExerciseService); + httpMock = injector.get(HttpTestingController); - describe('Service methods', async () => { - it('should find an element', async () => { - const returnedFromService = Object.assign({}, elemDefault); - service - .find(123) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: elemDefault })); - - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify(returnedFromService)); - }); - - it('should create a TextExercise', async () => { - const returnedFromService = Object.assign( - { - id: 0, - }, - elemDefault, - ); - const expected = Object.assign({}, returnedFromService); - service - .create(new TextExercise(null)) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); - const req = httpMock.expectOne({ method: 'POST' }); - req.flush(JSON.stringify(returnedFromService)); - }); + elemDefault = new TextExercise(new Course()); + }); - it('should update a TextExercise', async () => { - const returnedFromService = Object.assign( - { - sampleSolution: 'BBBBBB', - }, - elemDefault, - ); + describe('Service methods', async () => { + it('should find an element', async () => { + const returnedFromService = Object.assign({}, elemDefault); + service + .find(123) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: elemDefault })); - const expected = Object.assign({}, returnedFromService); - service - .update(expected) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); - const req = httpMock.expectOne({ method: 'PUT' }); - req.flush(JSON.stringify(returnedFromService)); - }); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify(returnedFromService)); + }); - it('should return a list of TextExercise', async () => { - const returnedFromService = Object.assign( - { - sampleSolution: 'BBBBBB', - }, - elemDefault, - ); - const expected = Object.assign({}, returnedFromService); - service - .query(expected) - .pipe( - take(1), - map((resp) => resp.body), - ) - .subscribe((body) => expect(body).toContainEqual(expected)); - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify([returnedFromService])); - httpMock.verify(); - }); + it('should create a TextExercise', async () => { + const returnedFromService = Object.assign( + { + id: 0, + }, + elemDefault, + ); + const expected = Object.assign({}, returnedFromService); + service + .create(new TextExercise(null)) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(JSON.stringify(returnedFromService)); + }); - it('should delete a TextExercise', async () => { - service.delete(123).subscribe((resp) => expect(resp.ok)); + it('should update a TextExercise', async () => { + const returnedFromService = Object.assign( + { + sampleSolution: 'BBBBBB', + }, + elemDefault, + ); - const req = httpMock.expectOne({ method: 'DELETE' }); - req.flush({ status: 200 }); - }); + const expected = Object.assign({}, returnedFromService); + service + .update(expected) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(JSON.stringify(returnedFromService)); }); - afterEach(() => { + it('should return a list of TextExercise', async () => { + const returnedFromService = Object.assign( + { + sampleSolution: 'BBBBBB', + }, + elemDefault, + ); + const expected = Object.assign({}, returnedFromService); + service + .query(expected) + .pipe( + take(1), + map((resp) => resp.body), + ) + .subscribe((body) => expect(body).toContainEqual(expected)); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify([returnedFromService])); httpMock.verify(); }); + + it('should delete a TextExercise', async () => { + service.delete(123).subscribe((resp) => expect(resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + }); + }); + + afterEach(() => { + httpMock.verify(); }); }); diff --git a/src/test/javascript/spec/service/text-submission.service.spec.ts b/src/test/javascript/spec/service/text-submission.service.spec.ts index 647ffdef45fa..8294d915784f 100644 --- a/src/test/javascript/spec/service/text-submission.service.spec.ts +++ b/src/test/javascript/spec/service/text-submission.service.spec.ts @@ -4,98 +4,96 @@ import { map, take } from 'rxjs/operators'; import { TextSubmissionService } from 'app/exercises/text/participate/text-submission.service'; import { TextSubmission } from 'app/entities/text-submission.model'; -describe('Service Tests', () => { - describe('TextSubmission Service', () => { - let injector: TestBed; - let service: TextSubmissionService; - let httpMock: HttpTestingController; - let elemDefault: TextSubmission; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - }); - injector = getTestBed(); - service = injector.get(TextSubmissionService); - httpMock = injector.get(HttpTestingController); - - elemDefault = new TextSubmission(); +describe('TextSubmission Service', () => { + let injector: TestBed; + let service: TextSubmissionService; + let httpMock: HttpTestingController; + let elemDefault: TextSubmission; + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], }); + injector = getTestBed(); + service = injector.get(TextSubmissionService); + httpMock = injector.get(HttpTestingController); - describe('Service methods', async () => { - it('should find an element', async () => { - const returnedFromService = Object.assign({}, elemDefault); - service - .find(123) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: elemDefault })); - - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify(returnedFromService)); - }); - - it('should create a TextSubmission', async () => { - const returnedFromService = Object.assign( - { - id: 0, - }, - elemDefault, - ); - const expected = Object.assign({}, returnedFromService); - service - .create(new TextSubmission(null)) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); - const req = httpMock.expectOne({ method: 'POST' }); - req.flush(JSON.stringify(returnedFromService)); - }); + elemDefault = new TextSubmission(); + }); - it('should update a TextSubmission', async () => { - const returnedFromService = Object.assign( - { - text: 'BBBBBB', - }, - elemDefault, - ); + describe('Service methods', async () => { + it('should find an element', async () => { + const returnedFromService = Object.assign({}, elemDefault); + service + .find(123) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: elemDefault })); - const expected = Object.assign({}, returnedFromService); - service - .update(expected) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); - const req = httpMock.expectOne({ method: 'PUT' }); - req.flush(JSON.stringify(returnedFromService)); - }); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify(returnedFromService)); + }); - it('should return a list of TextSubmission', async () => { - const returnedFromService = Object.assign( - { - text: 'BBBBBB', - }, - elemDefault, - ); - const expected = Object.assign({}, returnedFromService); - service - .query(expected) - .pipe( - take(1), - map((resp) => resp.body), - ) - .subscribe((body) => expect(body).toContainEqual(expected)); - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify([returnedFromService])); - httpMock.verify(); - }); + it('should create a TextSubmission', async () => { + const returnedFromService = Object.assign( + { + id: 0, + }, + elemDefault, + ); + const expected = Object.assign({}, returnedFromService); + service + .create(new TextSubmission(null)) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'POST' }); + req.flush(JSON.stringify(returnedFromService)); + }); - it('should delete a TextSubmission', async () => { - service.delete(123).subscribe((resp) => expect(resp.ok)); + it('should update a TextSubmission', async () => { + const returnedFromService = Object.assign( + { + text: 'BBBBBB', + }, + elemDefault, + ); - const req = httpMock.expectOne({ method: 'DELETE' }); - req.flush({ status: 200 }); - }); + const expected = Object.assign({}, returnedFromService); + service + .update(expected) + .pipe(take(1)) + .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); + const req = httpMock.expectOne({ method: 'PUT' }); + req.flush(JSON.stringify(returnedFromService)); }); - afterEach(() => { + it('should return a list of TextSubmission', async () => { + const returnedFromService = Object.assign( + { + text: 'BBBBBB', + }, + elemDefault, + ); + const expected = Object.assign({}, returnedFromService); + service + .query(expected) + .pipe( + take(1), + map((resp) => resp.body), + ) + .subscribe((body) => expect(body).toContainEqual(expected)); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(JSON.stringify([returnedFromService])); httpMock.verify(); }); + + it('should delete a TextSubmission', async () => { + service.delete(123).subscribe((resp) => expect(resp.ok)); + + const req = httpMock.expectOne({ method: 'DELETE' }); + req.flush({ status: 200 }); + }); + }); + + afterEach(() => { + httpMock.verify(); }); }); diff --git a/src/test/javascript/spec/service/user.service.spec.ts b/src/test/javascript/spec/service/user.service.spec.ts index a69ddc4f18de..b8c5179920a8 100644 --- a/src/test/javascript/spec/service/user.service.spec.ts +++ b/src/test/javascript/spec/service/user.service.spec.ts @@ -6,61 +6,59 @@ import { UserService } from 'app/core/user/user.service'; import { SERVER_API_URL } from 'app/app.constants'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; -describe('Service Tests', () => { - describe('User Service', () => { - let service: UserService; - let httpMock; +describe('User Service', () => { + let service: UserService; + let httpMock; - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - providers: [JhiDateUtils], - }); - - service = TestBed.inject(UserService); - httpMock = TestBed.inject(HttpTestingController); + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [HttpClientTestingModule], + providers: [JhiDateUtils], }); - afterEach(() => { - httpMock.verify(); - }); + service = TestBed.inject(UserService); + httpMock = TestBed.inject(HttpTestingController); + }); - describe('Service methods', () => { - it('should call correct URL', () => { - service.find('user').subscribe(() => {}); + afterEach(() => { + httpMock.verify(); + }); - const req = httpMock.expectOne({ method: 'GET' }); - const resourceUrl = SERVER_API_URL + 'api/users'; - expect(req.request.url).toEqual(`${resourceUrl}/user`); - }); - it('should return User', () => { - service.find('user').subscribe((received) => { - expect(received.body.login).toEqual('user'); - }); + describe('Service methods', () => { + it('should call correct URL', () => { + service.find('user').subscribe(() => {}); - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(new User(1, 'user')); + const req = httpMock.expectOne({ method: 'GET' }); + const resourceUrl = SERVER_API_URL + 'api/users'; + expect(req.request.url).toEqual(`${resourceUrl}/user`); + }); + it('should return User', () => { + service.find('user').subscribe((received) => { + expect(received.body.login).toEqual('user'); }); - it('should return Authorities', () => { - service.authorities().subscribe((_authorities) => { - expect(_authorities).toEqual(['ROLE_USER', 'ROLE_ADMIN']); - }); - const req = httpMock.expectOne({ method: 'GET' }); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush(new User(1, 'user')); + }); - req.flush(['ROLE_USER', 'ROLE_ADMIN']); + it('should return Authorities', () => { + service.authorities().subscribe((_authorities) => { + expect(_authorities).toEqual(['ROLE_USER', 'ROLE_ADMIN']); }); + const req = httpMock.expectOne({ method: 'GET' }); - it('should propagate not found response', () => { - service.find('user').subscribe(null, (_error: any) => { - expect(_error.status).toEqual(404); - }); + req.flush(['ROLE_USER', 'ROLE_ADMIN']); + }); + + it('should propagate not found response', () => { + service.find('user').subscribe(null, (_error: any) => { + expect(_error.status).toEqual(404); + }); - const req = httpMock.expectOne({ method: 'GET' }); - req.flush('Invalid request parameters', { - status: 404, - statusText: 'Bad Request', - }); + const req = httpMock.expectOne({ method: 'GET' }); + req.flush('Invalid request parameters', { + status: 404, + statusText: 'Bad Request', }); }); }); From 3c78375dcdf0ba4f385e5320c75b4e135f47e16d Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Fri, 24 Apr 2020 18:10:24 +0200 Subject: [PATCH 103/152] Remove duplicated MockRouter class --- .../helpers/mocks/service/mock-route.service.ts | 13 +------------ src/test/javascript/spec/test.module.ts | 3 ++- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/test/javascript/spec/helpers/mocks/service/mock-route.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-route.service.ts index d9d65dcb8e82..8bfc6aa3a7dc 100644 --- a/src/test/javascript/spec/helpers/mocks/service/mock-route.service.ts +++ b/src/test/javascript/spec/helpers/mocks/service/mock-route.service.ts @@ -1,7 +1,5 @@ -import { ActivatedRoute, Router } from '@angular/router'; -import { SpyObject } from '../../spyobject'; +import { ActivatedRoute } from '@angular/router'; import { of } from 'rxjs'; -import Spy = jasmine.Spy; export class MockActivatedRoute extends ActivatedRoute { constructor(parameters?: any) { @@ -18,12 +16,3 @@ export class MockActivatedRoute extends ActivatedRoute { }); } } - -export class MockRouter extends SpyObject { - navigateSpy: Spy; - - constructor() { - super(Router); - this.navigateSpy = this.spy('navigate'); - } -} diff --git a/src/test/javascript/spec/test.module.ts b/src/test/javascript/spec/test.module.ts index 5e28d85aa2c3..089aafaf0f6c 100644 --- a/src/test/javascript/spec/test.module.ts +++ b/src/test/javascript/spec/test.module.ts @@ -9,7 +9,8 @@ import { MockLanguageHelper, MockLanguageService } from './helpers/mocks/service import { JhiLanguageHelper } from 'app/core/language/language.helper'; import { AccountService } from 'app/core/auth/account.service'; import { MockAccountService } from './helpers/mocks/service/mock-account.service'; -import { MockActivatedRoute, MockRouter } from './helpers/mocks/service/mock-route.service'; +import { MockActivatedRoute } from './helpers/mocks/service/mock-route.service'; +import { MockRouter } from './helpers/mocks/service/mock-router.service'; import { MockActiveModal } from './helpers/mocks/service/mock-active-modal.service'; import { MockEventManager } from './helpers/mocks/service/mock-event-manager.service'; import { CookieService } from 'ngx-cookie-service'; From fbe34e9e73cd01be63ab609b29573726c6261b3b Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Fri, 24 Apr 2020 18:12:25 +0200 Subject: [PATCH 104/152] MockRouter is not a service mock --- .../tutor-dashboard/tutor-exercise-dashboard.component.spec.ts | 2 +- .../mocks/{service/mock-router.service.ts => mock-router.ts} | 0 .../code-editor/code-editor-instructor.integration.spec.ts | 2 +- src/test/javascript/spec/service/course.service.spec.ts | 2 +- src/test/javascript/spec/service/login.service.spec.ts | 2 +- .../spec/service/orion-version-validator.service.spec.ts | 2 +- src/test/javascript/spec/test.module.ts | 2 +- 7 files changed, 6 insertions(+), 6 deletions(-) rename src/test/javascript/spec/helpers/mocks/{service/mock-router.service.ts => mock-router.ts} (100%) diff --git a/src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.component.spec.ts b/src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.component.spec.ts index a1b769690d19..4cd8e9a37e2c 100644 --- a/src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.component.spec.ts +++ b/src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.component.spec.ts @@ -11,7 +11,7 @@ import { ArtemisSharedModule } from 'app/shared/shared.module'; import { MockAlertService } from '../../helpers/mocks/service/mock-alert.service'; import { AlertService } from 'app/core/alert/alert.service'; import { ActivatedRoute, Router, RouterModule } from '@angular/router'; -import { MockRouter } from '../../helpers/mocks/service/mock-router.service'; +import { MockRouter } from '../../helpers/mocks/mock-router'; import { of, throwError } from 'rxjs'; import { HttpErrorResponse } from '@angular/common/http'; import { SidePanelComponent } from 'app/shared/side-panel/side-panel.component'; diff --git a/src/test/javascript/spec/helpers/mocks/service/mock-router.service.ts b/src/test/javascript/spec/helpers/mocks/mock-router.ts similarity index 100% rename from src/test/javascript/spec/helpers/mocks/service/mock-router.service.ts rename to src/test/javascript/spec/helpers/mocks/mock-router.ts diff --git a/src/test/javascript/spec/integration/code-editor/code-editor-instructor.integration.spec.ts b/src/test/javascript/spec/integration/code-editor/code-editor-instructor.integration.spec.ts index b33412e48d91..5b0d219f4b6a 100644 --- a/src/test/javascript/spec/integration/code-editor/code-editor-instructor.integration.spec.ts +++ b/src/test/javascript/spec/integration/code-editor/code-editor-instructor.integration.spec.ts @@ -17,7 +17,7 @@ import { ProgrammingExerciseParticipationService } from 'app/exercises/programmi import { ProgrammingExerciseService } from 'app/exercises/programming/manage/services/programming-exercise.service'; import { DomainType, FileType } from 'app/exercises/programming/shared/code-editor/model/code-editor.model'; import { MockAccountService } from '../../helpers/mocks/service/mock-account.service'; -import { MockRouter } from '../../helpers/mocks/service/mock-router.service'; +import { MockRouter } from '../../helpers/mocks/mock-router'; import { problemStatement } from '../../helpers/sample/problemStatement.json'; import { MockProgrammingExerciseParticipationService } from '../../helpers/mocks/service/mock-programming-exercise-participation.service'; import { ExerciseHint } from 'app/entities/exercise-hint.model'; diff --git a/src/test/javascript/spec/service/course.service.spec.ts b/src/test/javascript/spec/service/course.service.spec.ts index 1509bfc3b17a..69298814d08d 100644 --- a/src/test/javascript/spec/service/course.service.spec.ts +++ b/src/test/javascript/spec/service/course.service.spec.ts @@ -10,7 +10,7 @@ import { CourseManagementService } from 'app/course/manage/course-management.ser import { Course } from 'app/entities/course.model'; import { MockTranslateService } from '../helpers/mocks/service/mock-translate.service'; import { MockSyncStorage } from '../helpers/mocks/service/mock-sync-storage.service'; -import { MockRouter } from '../helpers/mocks/service/mock-router.service'; +import { MockRouter } from '../helpers/mocks/mock-router'; describe('Course Service', () => { let injector: TestBed; diff --git a/src/test/javascript/spec/service/login.service.spec.ts b/src/test/javascript/spec/service/login.service.spec.ts index aee3d8821a4e..f83c423da54d 100644 --- a/src/test/javascript/spec/service/login.service.spec.ts +++ b/src/test/javascript/spec/service/login.service.spec.ts @@ -3,7 +3,7 @@ import * as sinonChai from 'sinon-chai'; import { SinonStub, stub } from 'sinon'; import { of, throwError } from 'rxjs'; import { MockWebsocketService } from '../helpers/mocks/service/mock-websocket.service'; -import { MockRouter } from '../helpers/mocks/service/mock-router.service'; +import { MockRouter } from '../helpers/mocks/mock-router'; import { MockAccountService } from '../helpers/mocks/service/mock-account.service'; import { MockAuthServerProviderService } from '../helpers/mocks/service/mock-auth-server-provider.service'; import { MockAlertService } from '../helpers/mocks/service/mock-alert.service'; diff --git a/src/test/javascript/spec/service/orion-version-validator.service.spec.ts b/src/test/javascript/spec/service/orion-version-validator.service.spec.ts index 1601be202e98..ece68e46ac13 100644 --- a/src/test/javascript/spec/service/orion-version-validator.service.spec.ts +++ b/src/test/javascript/spec/service/orion-version-validator.service.spec.ts @@ -6,7 +6,7 @@ import { ProfileService } from 'app/shared/layouts/profiles/profile.service'; import { Router } from '@angular/router'; import { MockProfileService } from '../helpers/mocks/service/mock-profile.service'; import { MockWindowRef } from '../helpers/mocks/service/mock-window.service'; -import { MockRouter } from '../helpers/mocks/service/mock-router.service'; +import { MockRouter } from '../helpers/mocks/mock-router'; import { of } from 'rxjs'; import { ProfileInfo } from 'app/shared/layouts/profiles/profile-info.model'; diff --git a/src/test/javascript/spec/test.module.ts b/src/test/javascript/spec/test.module.ts index 089aafaf0f6c..c1821db8b86a 100644 --- a/src/test/javascript/spec/test.module.ts +++ b/src/test/javascript/spec/test.module.ts @@ -10,7 +10,7 @@ import { JhiLanguageHelper } from 'app/core/language/language.helper'; import { AccountService } from 'app/core/auth/account.service'; import { MockAccountService } from './helpers/mocks/service/mock-account.service'; import { MockActivatedRoute } from './helpers/mocks/service/mock-route.service'; -import { MockRouter } from './helpers/mocks/service/mock-router.service'; +import { MockRouter } from './helpers/mocks/mock-router'; import { MockActiveModal } from './helpers/mocks/service/mock-active-modal.service'; import { MockEventManager } from './helpers/mocks/service/mock-event-manager.service'; import { CookieService } from 'ngx-cookie-service'; From 51b7d183fdb79b8f79151a2f18e27ba23732f269 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Fri, 24 Apr 2020 19:36:53 +0200 Subject: [PATCH 105/152] Remove one of the duplicated MockActivatedRoute implementations --- .../file-upload-assessment.component.spec.ts | 2 +- ...ext-exercise-assessement.component.spec.ts | 501 +++++++++--------- .../activated-route/mock-activated-route.ts | 26 - 3 files changed, 255 insertions(+), 274 deletions(-) delete mode 100644 src/test/javascript/spec/helpers/mocks/activated-route/mock-activated-route.ts diff --git a/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.component.spec.ts b/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.component.spec.ts index 9b739fa79a38..afb5efff8460 100644 --- a/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.component.spec.ts +++ b/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.component.spec.ts @@ -35,7 +35,7 @@ import { ModelingAssessmentModule } from 'app/exercises/modeling/assess/modeling import { routes } from 'app/exercises/file-upload/assess/file-upload-assessment.route'; import { By } from '@angular/platform-browser'; import { throwError } from 'rxjs'; -import { MockActivatedRoute } from '../../helpers/mocks/activated-route/mock-activated-route'; +import { MockActivatedRoute } from '../../helpers/mocks/service/mock-route.service'; import { Participation, ParticipationType } from 'app/entities/participation/participation.model'; chai.use(sinonChai); diff --git a/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.component.spec.ts b/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.component.spec.ts index 1cd90715c4f1..5d80e3cdd6c8 100644 --- a/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.component.spec.ts +++ b/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.component.spec.ts @@ -36,7 +36,6 @@ import { Exercise, ExerciseType } from 'app/entities/exercise.model'; import { TextSubmission } from 'app/entities/text-submission.model'; import { Participation, ParticipationType } from 'app/entities/participation/participation.model'; import { AssessmentType } from 'app/entities/assessment-type.model'; -import { MockActivatedRoute } from '../../helpers/mocks/activated-route/mock-activated-route'; import { TextAssessmentsService } from 'app/exercises/text/assess/text-assessments.service'; import { Course } from 'app/entities/course.model'; import { Feedback } from 'app/entities/feedback.model'; @@ -60,7 +59,6 @@ describe('TextExerciseAssessmentComponent', () => { let updateAssessmentAfterComplaintStub: SinonStub; let debugElement: DebugElement; let router: Router; - const activatedRouteMock: MockActivatedRoute = new MockActivatedRoute(); const exercise = { id: 20, type: ExerciseType.TEXT, assessmentType: AssessmentType.MANUAL } as TextExercise; const participation: Participation = ({ type: ParticipationType.STUDENT, exercise: Exercise }); @@ -93,7 +91,9 @@ describe('TextExerciseAssessmentComponent', () => { const refFeedback = { reference: 'reference', credits: 5 } as Feedback; const refFeedback2 = { reference: 'reference2', credits: 5 } as Feedback; - beforeEach(async () => { + const testBedConfiguration = (routeParamSubmissionId?: string | number) => { + const submissionId = routeParamSubmissionId ? routeParamSubmissionId : 'new'; + const route = ({ params: of({ exerciseId: exercise.id, submissionId }) } as any) as ActivatedRoute; return TestBed.configureTestingModule({ imports: [ArtemisTestModule, ArtemisSharedModule, TranslateModule.forRoot(), RouterTestingModule.withRoutes([textAssessmentRoutes[0]])], declarations: [ @@ -107,12 +107,12 @@ describe('TextExerciseAssessmentComponent', () => { ], providers: [ JhiLanguageHelper, + { provide: ActivatedRoute, useValue: route }, { provide: AlertService, useClass: MockAlertService }, { provide: AccountService, useClass: MockAccountService }, { provide: SessionStorageService, useClass: MockSyncStorage }, { provide: LocalStorageService, useClass: MockSyncStorage }, { provide: ComplaintService, useClass: MockComplaintService }, - { provide: ActivatedRoute, useValue: activatedRouteMock }, ], }) .overrideModule(ArtemisTestModule, { set: { declarations: [], exports: [] } }) @@ -136,7 +136,7 @@ describe('TextExerciseAssessmentComponent', () => { router.initialNavigation(); }); - }); + }; afterEach(() => { getTextSubmissionForExerciseWithoutAssessmentStub.restore(); @@ -147,246 +147,253 @@ describe('TextExerciseAssessmentComponent', () => { updateAssessmentAfterComplaintStub.restore(); }); - it('AssessNextButton should be visible', fakeAsync(() => { - activatedRouteMock.testParams = { exerciseId: 1, submissionId: 'new' }; - getTextSubmissionForExerciseWithoutAssessmentStub.returns(throwError({ status: 404 })); - // set all attributes for comp - comp.ngOnInit(); - tick(); - - // not found state is correctly set on the component - expect(comp.notFound).to.be.true; - - comp.userId = 99; - comp.submission = submission; - comp.result = result; - comp.isAssessor = true; - comp.isAtLeastInstructor = true; - comp.assessmentsAreValid = true; - fixture.detectChanges(); - - // check if assessNextButton is available - const assessNextButton = debugElement.query(By.css('#assessNextButton')); - expect(assessNextButton).to.exist; - })); - - it('Should set the result and participation properly for new submission', fakeAsync(() => { - activatedRouteMock.testParams = { exerciseId: 1, submissionId: 'new' }; - result.hasComplaint = true; - getTextSubmissionForExerciseWithoutAssessmentStub.returns(of(submission)); - comp.ngOnInit(); - tick(); - expect(comp.submission).to.be.deep.equal(submission); - expect(comp.result).to.be.deep.equal(result); - expect(comp.participation).to.be.deep.equal(participation); - expect(comp.isAtLeastInstructor).to.be.true; - expect(comp.complaint).to.be.deep.equal(MockComplaintResponse.body); - })); - - it('Should navigate to tutor dashboard when locked submission limit reached', fakeAsync(() => { - const course = new Course(); - course.id = 1; - exercise.course = course; - comp.exercise = exercise; - activatedRouteMock.testParams = { exerciseId: 1, submissionId: 'new' }; - getTextSubmissionForExerciseWithoutAssessmentStub.returns(throwError({ error: { errorKey: 'lockedSubmissionsLimitReached' } })); - const spy = stub(router, 'navigateByUrl'); - spy.returns(new Promise(() => true)); - comp.ngOnInit(); - tick(); - expect(spy.called).to.be.true; - })); - - it('Should alert error message on error response', fakeAsync(() => { - const course = new Course(); - course.id = 1; - exercise.course = course; - comp.exercise = exercise; - activatedRouteMock.testParams = { exerciseId: 1, submissionId: 'new' }; - getTextSubmissionForExerciseWithoutAssessmentStub.returns(throwError({ headers: { get: () => 'error' } })); - const spy = stub(TestBed.inject(AlertService), 'error'); - spy.returns({ type: 'danger', msg: '' }); - comp.ngOnInit(); - tick(); - expect(spy.called).to.be.true; - })); - - it('Should set the result and participation properly for existing submission', fakeAsync(() => { - activatedRouteMock.testParams = { exerciseId: 1, submissionId: 1 }; - getFeedbackDataForExerciseSubmissionStub.returns(of(participation)); - comp.ngOnInit(); - tick(); - expect(comp.isAtLeastInstructor).to.be.true; - })); - - it('Should invalidate assessment without general and referenced feedback', fakeAsync(() => { - comp.validateAssessment(); - expect(comp.assessmentsAreValid).to.be.false; - expect(comp.totalScore).to.be.equal(0); - })); - - it('Should validate assessment with general feedback', fakeAsync(() => { - const feedback = new Feedback(); - feedback.detailText = 'General Feedback'; - comp.generalFeedback = feedback; - comp.validateAssessment(); - expect(comp.assessmentsAreValid).to.be.true; - expect(comp.totalScore).to.be.equal(0); - })); - - it('Should invalidate assessment with referenced feedback without reference', fakeAsync(() => { - comp.referencedFeedback = [new Feedback()]; - comp.validateAssessment(); - expect(comp.assessmentsAreValid).to.be.false; - expect(comp.invalidError).to.be.equal('artemisApp.textAssessment.error.feedbackReferenceTooLong'); - })); - - it('Should invalidate assessment with referenced feedback with undefined credits', fakeAsync(() => { - const feedback = new Feedback(); - feedback.reference = 'reference'; - comp.referencedFeedback = [feedback]; - comp.validateAssessment(); - expect(comp.assessmentsAreValid).to.be.false; - expect(comp.invalidError).to.be.equal('artemisApp.textAssessment.error.invalidNeedScoreOrFeedback'); - })); - - it('Should invalidate assessment with referenced feedback without credits', fakeAsync(() => { - const feedback = new Feedback(); - feedback.reference = 'reference'; - feedback.credits = null as any; - comp.referencedFeedback = [feedback]; - comp.validateAssessment(); - expect(comp.assessmentsAreValid).to.be.false; - expect(comp.invalidError).to.be.equal('artemisApp.textAssessment.error.invalidScoreMustBeNumber'); - })); - - it('Should validate assessment with referenced feedback with credits', fakeAsync(() => { - comp.referencedFeedback = [refFeedback, refFeedback2]; - comp.validateAssessment(); - expect(comp.assessmentsAreValid).to.be.true; - expect(comp.totalScore).to.be.equal(10); - })); - - it('Should delete assessment', fakeAsync(() => { - comp.referencedFeedback = [refFeedback, refFeedback2]; - comp.referencedTextBlocks = [new TextBlock(), new TextBlock()]; - comp.deleteAssessment(refFeedback); - expect(comp.referencedFeedback.length).to.be.equal(1); - expect(comp.referencedFeedback).to.contain(refFeedback2); - expect(comp.referencedTextBlocks.length).to.be.equal(1); - expect(comp.totalScore).to.be.equal(5); - expect(comp.assessmentsAreValid).to.be.true; - })); - - it('Should add assessment', fakeAsync(() => { - const assessmentText = 'new assessment'; - comp.referencedTextBlocks = []; - comp.addAssessment(assessmentText); - expect(comp.referencedFeedback.length).to.be.equal(1); - expect(comp.referencedFeedback[0].reference).to.be.equal(assessmentText); - expect(comp.referencedFeedback[0].credits).to.be.equal(0); - expect(comp.referencedTextBlocks.length).to.be.equal(1); - })); - - it('Should not save invalid assessments', fakeAsync(() => { - comp.save(); - expect(saveAssessmentStub.called).to.be.false; - })); - - it('Should handle error on save assessment', fakeAsync(() => { - comp.referencedFeedback = [refFeedback]; - comp.result = { id: 1 } as any; - saveAssessmentStub.returns(throwError({ headers: { get: () => 'error' } })); - const spy = stub(TestBed.inject(AlertService), 'error'); - spy.returns({ type: 'danger', msg: '' }); - comp.save(); - tick(); - expect(saveAssessmentStub.called).to.be.true; - })); - - it('Should save valid assessments', fakeAsync(() => { - comp.referencedFeedback = [refFeedback]; - comp.result = { id: 1 } as any; - participation.results = []; - comp.participation = participation; - saveAssessmentStub.returns(of({ body: result })); - comp.save(); - expect(saveAssessmentStub.called).to.be.true; - expect(comp.result).to.be.equal(result); - expect(comp.participation.results[0]).to.be.equal(result); - expect(comp.showResult).to.be.true; - })); - - it('Should submit valid assessments', fakeAsync(() => { - comp.referencedFeedback = [refFeedback]; - comp.result = { id: 1 } as any; - participation.results = []; - comp.participation = participation; - submitAssessmentStub.returns(of({ body: result })); - comp.submit(); - expect(submitAssessmentStub.called).to.be.true; - expect(comp.result).to.be.equal(result); - expect(comp.participation.results[0]).to.be.equal(result); - expect(comp.showResult).to.be.true; - })); - - it('Should not submit without already existing result', fakeAsync(() => { - comp.result = {} as any; - submitAssessmentStub.returns(of({ body: result })); - comp.submit(); - expect(submitAssessmentStub.called).to.be.false; - })); - - it('Should not submit without valid assessments', fakeAsync(() => { - comp.result = { id: 1 } as any; - submitAssessmentStub.returns(of({ body: result })); - comp.submit(); - expect(submitAssessmentStub.called).to.be.false; - })); - - it('Should set predefined text blocks', fakeAsync(() => { - submission.blocks = [{ id: '1' } as TextBlock]; - comp.submission = submission; - const generalFeedback = { id: 1, detailText: 'general' } as Feedback; - const referencedFeedback = { id: 2, referenceId: '1' } as Feedback; - comp.result = { id: 1 } as Result; - getResultWithPredefinedTextblocksStub.returns(of({ body: { submission, feedbacks: [generalFeedback, referencedFeedback] } })); - comp.predefineTextBlocks(); - tick(); - expect(comp.submission.blocks?.length).to.be.equal(1); - expect(comp.generalFeedback).to.be.equal(generalFeedback); - expect(comp.referencedFeedback.length).to.be.equal(1); - expect(comp.referencedFeedback).to.contain(referencedFeedback); - expect(comp.referencedTextBlocks.length).to.be.equal(1); - })); - - it('Should update assessment after complaint', fakeAsync(() => { - comp.referencedFeedback = [refFeedback]; - comp.submission = { id: 2 } as any; - participation.results = []; - comp.participation = participation; - updateAssessmentAfterComplaintStub.returns(of({ body: result })); - comp.onUpdateAssessmentAfterComplaint(new ComplaintResponse()); - expect(updateAssessmentAfterComplaintStub.called).to.be.true; - expect(comp.result).to.be.equal(result); - expect(comp.participation.results[0]).to.be.equal(result); - expect(comp.showResult).to.be.true; - })); - - it('Should not update assessment after complaint when assessments not valid', fakeAsync(() => { - updateAssessmentAfterComplaintStub.returns(of({ body: result })); - comp.onUpdateAssessmentAfterComplaint(new ComplaintResponse()); - expect(updateAssessmentAfterComplaintStub.called).to.be.false; - expect(comp.result).to.be.undefined; - })); - - it('Should handle error on update assessment after complaint', fakeAsync(() => { - comp.referencedFeedback = [refFeedback]; - comp.submission = { id: 2 } as any; - participation.results = []; - updateAssessmentAfterComplaintStub.returns(throwError({})); - comp.onUpdateAssessmentAfterComplaint(new ComplaintResponse()); - expect(updateAssessmentAfterComplaintStub.called).to.be.true; - expect(comp.result).to.be.undefined; - })); + describe('when submissionId router param is `new`', () => { + beforeEach(async () => { + await testBedConfiguration(); + }); + + it('AssessNextButton should be visible', fakeAsync(() => { + getTextSubmissionForExerciseWithoutAssessmentStub.returns(throwError({ status: 404 })); + // set all attributes for comp + comp.ngOnInit(); + tick(); + + // not found state is correctly set on the component + expect(comp.notFound).to.be.true; + + comp.userId = 99; + comp.submission = submission; + comp.result = result; + comp.isAssessor = true; + comp.isAtLeastInstructor = true; + comp.assessmentsAreValid = true; + fixture.detectChanges(); + + // check if assessNextButton is available + const assessNextButton = debugElement.query(By.css('#assessNextButton')); + expect(assessNextButton).to.exist; + })); + + it('Should set the result and participation properly for new submission', fakeAsync(() => { + result.hasComplaint = true; + getTextSubmissionForExerciseWithoutAssessmentStub.returns(of(submission)); + comp.ngOnInit(); + tick(); + expect(comp.submission).to.be.deep.equal(submission); + expect(comp.result).to.be.deep.equal(result); + expect(comp.participation).to.be.deep.equal(participation); + expect(comp.isAtLeastInstructor).to.be.true; + expect(comp.complaint).to.be.deep.equal(MockComplaintResponse.body); + })); + + it('Should navigate to tutor dashboard when locked submission limit reached', fakeAsync(() => { + const course = new Course(); + course.id = 1; + exercise.course = course; + comp.exercise = exercise; + getTextSubmissionForExerciseWithoutAssessmentStub.returns(throwError({ error: { errorKey: 'lockedSubmissionsLimitReached' } })); + const spy = stub(router, 'navigateByUrl'); + spy.returns(new Promise(() => true)); + comp.ngOnInit(); + tick(); + expect(spy.called).to.be.true; + })); + + it('Should alert error message on error response', fakeAsync(() => { + const course = new Course(); + course.id = 1; + exercise.course = course; + comp.exercise = exercise; + getTextSubmissionForExerciseWithoutAssessmentStub.returns(throwError({ headers: { get: () => 'error' } })); + const spy = stub(TestBed.inject(AlertService), 'error'); + spy.returns({ type: 'danger', msg: '' }); + comp.ngOnInit(); + tick(); + expect(spy.called).to.be.true; + })); + + it('Should invalidate assessment without general and referenced feedback', fakeAsync(() => { + comp.validateAssessment(); + expect(comp.assessmentsAreValid).to.be.false; + expect(comp.totalScore).to.be.equal(0); + })); + + it('Should validate assessment with general feedback', fakeAsync(() => { + const feedback = new Feedback(); + feedback.detailText = 'General Feedback'; + comp.generalFeedback = feedback; + comp.validateAssessment(); + expect(comp.assessmentsAreValid).to.be.true; + expect(comp.totalScore).to.be.equal(0); + })); + + it('Should invalidate assessment with referenced feedback without reference', fakeAsync(() => { + comp.referencedFeedback = [new Feedback()]; + comp.validateAssessment(); + expect(comp.assessmentsAreValid).to.be.false; + expect(comp.invalidError).to.be.equal('artemisApp.textAssessment.error.feedbackReferenceTooLong'); + })); + + it('Should invalidate assessment with referenced feedback with undefined credits', fakeAsync(() => { + const feedback = new Feedback(); + feedback.reference = 'reference'; + comp.referencedFeedback = [feedback]; + comp.validateAssessment(); + expect(comp.assessmentsAreValid).to.be.false; + expect(comp.invalidError).to.be.equal('artemisApp.textAssessment.error.invalidNeedScoreOrFeedback'); + })); + + it('Should invalidate assessment with referenced feedback without credits', fakeAsync(() => { + const feedback = new Feedback(); + feedback.reference = 'reference'; + feedback.credits = null as any; + comp.referencedFeedback = [feedback]; + comp.validateAssessment(); + expect(comp.assessmentsAreValid).to.be.false; + expect(comp.invalidError).to.be.equal('artemisApp.textAssessment.error.invalidScoreMustBeNumber'); + })); + + it('Should validate assessment with referenced feedback with credits', fakeAsync(() => { + comp.referencedFeedback = [refFeedback, refFeedback2]; + comp.validateAssessment(); + expect(comp.assessmentsAreValid).to.be.true; + expect(comp.totalScore).to.be.equal(10); + })); + + it('Should delete assessment', fakeAsync(() => { + comp.referencedFeedback = [refFeedback, refFeedback2]; + comp.referencedTextBlocks = [new TextBlock(), new TextBlock()]; + comp.deleteAssessment(refFeedback); + expect(comp.referencedFeedback.length).to.be.equal(1); + expect(comp.referencedFeedback).to.contain(refFeedback2); + expect(comp.referencedTextBlocks.length).to.be.equal(1); + expect(comp.totalScore).to.be.equal(5); + expect(comp.assessmentsAreValid).to.be.true; + })); + + it('Should add assessment', fakeAsync(() => { + const assessmentText = 'new assessment'; + comp.referencedTextBlocks = []; + comp.addAssessment(assessmentText); + expect(comp.referencedFeedback.length).to.be.equal(1); + expect(comp.referencedFeedback[0].reference).to.be.equal(assessmentText); + expect(comp.referencedFeedback[0].credits).to.be.equal(0); + expect(comp.referencedTextBlocks.length).to.be.equal(1); + })); + + it('Should not save invalid assessments', fakeAsync(() => { + comp.save(); + expect(saveAssessmentStub.called).to.be.false; + })); + + it('Should handle error on save assessment', fakeAsync(() => { + comp.referencedFeedback = [refFeedback]; + comp.result = { id: 1 } as any; + saveAssessmentStub.returns(throwError({ headers: { get: () => 'error' } })); + const spy = stub(TestBed.inject(AlertService), 'error'); + spy.returns({ type: 'danger', msg: '' }); + comp.save(); + tick(); + expect(saveAssessmentStub.called).to.be.true; + })); + + it('Should save valid assessments', fakeAsync(() => { + comp.referencedFeedback = [refFeedback]; + comp.result = { id: 1 } as any; + participation.results = []; + comp.participation = participation; + saveAssessmentStub.returns(of({ body: result })); + comp.save(); + expect(saveAssessmentStub.called).to.be.true; + expect(comp.result).to.be.equal(result); + expect(comp.participation.results[0]).to.be.equal(result); + expect(comp.showResult).to.be.true; + })); + + it('Should submit valid assessments', fakeAsync(() => { + comp.referencedFeedback = [refFeedback]; + comp.result = { id: 1 } as any; + participation.results = []; + comp.participation = participation; + submitAssessmentStub.returns(of({ body: result })); + comp.submit(); + expect(submitAssessmentStub.called).to.be.true; + expect(comp.result).to.be.equal(result); + expect(comp.participation.results[0]).to.be.equal(result); + expect(comp.showResult).to.be.true; + })); + + it('Should not submit without already existing result', fakeAsync(() => { + comp.result = {} as any; + submitAssessmentStub.returns(of({ body: result })); + comp.submit(); + expect(submitAssessmentStub.called).to.be.false; + })); + + it('Should not submit without valid assessments', fakeAsync(() => { + comp.result = { id: 1 } as any; + submitAssessmentStub.returns(of({ body: result })); + comp.submit(); + expect(submitAssessmentStub.called).to.be.false; + })); + + it('Should set predefined text blocks', fakeAsync(() => { + submission.blocks = [{ id: '1' } as TextBlock]; + comp.submission = submission; + const generalFeedback = { id: 1, detailText: 'general' } as Feedback; + const referencedFeedback = { id: 2, referenceId: '1' } as Feedback; + comp.result = { id: 1 } as Result; + getResultWithPredefinedTextblocksStub.returns(of({ body: { submission, feedbacks: [generalFeedback, referencedFeedback] } })); + comp.predefineTextBlocks(); + tick(); + expect(comp.submission.blocks?.length).to.be.equal(1); + expect(comp.generalFeedback).to.be.equal(generalFeedback); + expect(comp.referencedFeedback.length).to.be.equal(1); + expect(comp.referencedFeedback).to.contain(referencedFeedback); + expect(comp.referencedTextBlocks.length).to.be.equal(1); + })); + + it('Should update assessment after complaint', fakeAsync(() => { + comp.referencedFeedback = [refFeedback]; + comp.submission = { id: 2 } as any; + participation.results = []; + comp.participation = participation; + updateAssessmentAfterComplaintStub.returns(of({ body: result })); + comp.onUpdateAssessmentAfterComplaint(new ComplaintResponse()); + expect(updateAssessmentAfterComplaintStub.called).to.be.true; + expect(comp.result).to.be.equal(result); + expect(comp.participation.results[0]).to.be.equal(result); + expect(comp.showResult).to.be.true; + })); + + it('Should not update assessment after complaint when assessments not valid', fakeAsync(() => { + updateAssessmentAfterComplaintStub.returns(of({ body: result })); + comp.onUpdateAssessmentAfterComplaint(new ComplaintResponse()); + expect(updateAssessmentAfterComplaintStub.called).to.be.false; + expect(comp.result).to.be.undefined; + })); + + it('Should handle error on update assessment after complaint', fakeAsync(() => { + comp.referencedFeedback = [refFeedback]; + comp.submission = { id: 2 } as any; + participation.results = []; + updateAssessmentAfterComplaintStub.returns(throwError({})); + comp.onUpdateAssessmentAfterComplaint(new ComplaintResponse()); + expect(updateAssessmentAfterComplaintStub.called).to.be.true; + expect(comp.result).to.be.undefined; + })); + }); + + describe('when submissionId router param is 1', () => { + beforeEach(async () => { + await testBedConfiguration(1); + }); + + it('Should set the result and participation properly for existing submission', fakeAsync(() => { + getFeedbackDataForExerciseSubmissionStub.returns(of(participation)); + comp.ngOnInit(); + tick(); + expect(comp.isAtLeastInstructor).to.be.true; + })); + }); }); diff --git a/src/test/javascript/spec/helpers/mocks/activated-route/mock-activated-route.ts b/src/test/javascript/spec/helpers/mocks/activated-route/mock-activated-route.ts deleted file mode 100644 index 8a34fda18f9f..000000000000 --- a/src/test/javascript/spec/helpers/mocks/activated-route/mock-activated-route.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { Params } from '@angular/router'; -import { BehaviorSubject } from 'rxjs'; - -export class MockActivatedRoute { - private innerTestParams?: any; - private subject: BehaviorSubject = new BehaviorSubject(this.testParams); - - params = this.subject.asObservable(); - - constructor(params?: Params) { - if (params) { - this.testParams = params; - } else { - this.testParams = {}; - } - } - - get testParams() { - return this.innerTestParams; - } - - set testParams(params: {}) { - this.innerTestParams = params; - this.subject.next(params); - } -} From aafd9ec94a3edc3d1cde2cc6a421feaacff6154e Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Fri, 24 Apr 2020 19:39:28 +0200 Subject: [PATCH 106/152] Move MockActivatedRoute to correct directory --- .../spec/component/account/activate.component.spec.ts | 2 +- .../component/account/password-reset-finish.component.spec.ts | 2 +- .../file-upload-assessment.component.spec.ts | 2 +- .../list-of-complaints/list-of-complaints.component.spec.ts | 2 +- .../mock-activated-route.ts} | 0 src/test/javascript/spec/test.module.ts | 2 +- 6 files changed, 5 insertions(+), 5 deletions(-) rename src/test/javascript/spec/helpers/mocks/{service/mock-route.service.ts => activated-route/mock-activated-route.ts} (100%) diff --git a/src/test/javascript/spec/component/account/activate.component.spec.ts b/src/test/javascript/spec/component/account/activate.component.spec.ts index d97bef67140a..d69ad94465f9 100644 --- a/src/test/javascript/spec/component/account/activate.component.spec.ts +++ b/src/test/javascript/spec/component/account/activate.component.spec.ts @@ -3,7 +3,7 @@ import { ActivatedRoute } from '@angular/router'; import { of, throwError } from 'rxjs'; import { ArtemisTestModule } from '../../test.module'; -import { MockActivatedRoute } from '../../helpers/mocks/service/mock-route.service'; +import { MockActivatedRoute } from '../../helpers/mocks/activated-route/mock-activated-route'; import { ActivateService } from 'app/account/activate/activate.service'; import { ActivateComponent } from 'app/account/activate/activate.component'; diff --git a/src/test/javascript/spec/component/account/password-reset-finish.component.spec.ts b/src/test/javascript/spec/component/account/password-reset-finish.component.spec.ts index 4a4ef710a5f5..d9a9d6c258c6 100644 --- a/src/test/javascript/spec/component/account/password-reset-finish.component.spec.ts +++ b/src/test/javascript/spec/component/account/password-reset-finish.component.spec.ts @@ -6,7 +6,7 @@ import { ActivatedRoute } from '@angular/router'; import { ArtemisTestModule } from '../../test.module'; import { PasswordResetFinishComponent } from 'app/account/password-reset/finish/password-reset-finish.component'; import { PasswordResetFinishService } from 'app/account/password-reset/finish/password-reset-finish.service'; -import { MockActivatedRoute } from '../../helpers/mocks/service/mock-route.service'; +import { MockActivatedRoute } from '../../helpers/mocks/activated-route/mock-activated-route'; describe('PasswordResetFinishComponent', () => { let fixture: ComponentFixture; diff --git a/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.component.spec.ts b/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.component.spec.ts index afb5efff8460..9b739fa79a38 100644 --- a/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.component.spec.ts +++ b/src/test/javascript/spec/component/file-upload-assessment/file-upload-assessment.component.spec.ts @@ -35,7 +35,7 @@ import { ModelingAssessmentModule } from 'app/exercises/modeling/assess/modeling import { routes } from 'app/exercises/file-upload/assess/file-upload-assessment.route'; import { By } from '@angular/platform-browser'; import { throwError } from 'rxjs'; -import { MockActivatedRoute } from '../../helpers/mocks/service/mock-route.service'; +import { MockActivatedRoute } from '../../helpers/mocks/activated-route/mock-activated-route'; import { Participation, ParticipationType } from 'app/entities/participation/participation.model'; chai.use(sinonChai); diff --git a/src/test/javascript/spec/component/list-of-complaints/list-of-complaints.component.spec.ts b/src/test/javascript/spec/component/list-of-complaints/list-of-complaints.component.spec.ts index 4f69cdfde83c..731d3938a3bc 100644 --- a/src/test/javascript/spec/component/list-of-complaints/list-of-complaints.component.spec.ts +++ b/src/test/javascript/spec/component/list-of-complaints/list-of-complaints.component.spec.ts @@ -9,7 +9,7 @@ import { MockAlertService } from '../../helpers/mocks/service/mock-alert.service import { ComplaintService } from 'app/complaints/complaint.service'; import { DifferencePipe } from 'ngx-moment'; import { ActivatedRoute } from '@angular/router'; -import { MockActivatedRoute } from '../../helpers/mocks/service/mock-route.service'; +import { MockActivatedRoute } from '../../helpers/mocks/activated-route/mock-activated-route'; import { ListOfComplaintsComponent } from 'app/complaints/list-of-complaints/list-of-complaints.component'; describe('ListOfComplaintsComponent', () => { diff --git a/src/test/javascript/spec/helpers/mocks/service/mock-route.service.ts b/src/test/javascript/spec/helpers/mocks/activated-route/mock-activated-route.ts similarity index 100% rename from src/test/javascript/spec/helpers/mocks/service/mock-route.service.ts rename to src/test/javascript/spec/helpers/mocks/activated-route/mock-activated-route.ts diff --git a/src/test/javascript/spec/test.module.ts b/src/test/javascript/spec/test.module.ts index c1821db8b86a..5ac5bbce1990 100644 --- a/src/test/javascript/spec/test.module.ts +++ b/src/test/javascript/spec/test.module.ts @@ -9,7 +9,7 @@ import { MockLanguageHelper, MockLanguageService } from './helpers/mocks/service import { JhiLanguageHelper } from 'app/core/language/language.helper'; import { AccountService } from 'app/core/auth/account.service'; import { MockAccountService } from './helpers/mocks/service/mock-account.service'; -import { MockActivatedRoute } from './helpers/mocks/service/mock-route.service'; +import { MockActivatedRoute } from './helpers/mocks/activated-route/mock-activated-route'; import { MockRouter } from './helpers/mocks/mock-router'; import { MockActiveModal } from './helpers/mocks/service/mock-active-modal.service'; import { MockEventManager } from './helpers/mocks/service/mock-event-manager.service'; From c49ad3c66990d968502b075086e048afd9c3a2c7 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Fri, 24 Apr 2020 20:52:55 +0200 Subject: [PATCH 107/152] Rename mock-activated.route.ts --- .../participation/participation.component.spec.ts | 4 ++-- ...ogramming-exercise-manage-test-cases.component.spec.ts | 6 +++--- .../tutor-exercise-dashboard.component.spec.ts | 4 ++-- ...ted.route.ts => mock-activated-route-with-subjects.ts} | 2 +- .../code-editor-instructor.integration.spec.ts | 8 ++++---- .../code-editor/code-editor-student.integration.spec.ts | 8 ++++---- 6 files changed, 16 insertions(+), 16 deletions(-) rename src/test/javascript/spec/helpers/mocks/activated-route/{mock-activated.route.ts => mock-activated-route-with-subjects.ts} (83%) diff --git a/src/test/javascript/spec/component/participation/participation.component.spec.ts b/src/test/javascript/spec/component/participation/participation.component.spec.ts index 2ccef9e2af3d..45f743db117e 100644 --- a/src/test/javascript/spec/component/participation/participation.component.spec.ts +++ b/src/test/javascript/spec/component/participation/participation.component.spec.ts @@ -5,7 +5,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { ArtemisTestModule } from '../../test.module'; import { ArtemisSharedModule } from 'app/shared/shared.module'; -import { MockActivatedRoute } from '../../helpers/mocks/activated-route/mock-activated.route'; +import { MockActivatedRouteWithSubjects } from '../../helpers/mocks/activated-route/mock-activated-route-with-subjects'; import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; import { ParticipationService } from 'app/exercises/shared/participation/participation.service'; import { ParticipationComponent } from 'app/exercises/shared/participation/participation.component'; @@ -27,7 +27,7 @@ describe('ParticipationComponent', () => { imports: [ArtemisTestModule, ArtemisSharedModule], declarations: [ParticipationComponent], providers: [ - { provide: ActivatedRoute, useClass: MockActivatedRoute }, + { provide: ActivatedRoute, useClass: MockActivatedRouteWithSubjects }, { provide: LocalStorageService, useClass: MockSyncStorage }, { provide: SessionStorageService, useClass: MockSyncStorage }, ], diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-manage-test-cases.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-manage-test-cases.component.spec.ts index 54517de06b18..7b2eb9e445cc 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-manage-test-cases.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-manage-test-cases.component.spec.ts @@ -29,7 +29,7 @@ import { EditableField, ProgrammingExerciseManageTestCasesComponent } from 'app/ import { ProgrammingExerciseService, ProgrammingExerciseTestCaseStateDTO } from 'app/exercises/programming/manage/services/programming-exercise.service'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; import { ProgrammingExerciseTestCaseService } from 'app/exercises/programming/manage/services/programming-exercise-test-case.service'; -import { MockActivatedRoute } from '../../helpers/mocks/activated-route/mock-activated.route'; +import { MockActivatedRouteWithSubjects } from '../../helpers/mocks/activated-route/mock-activated-route-with-subjects'; import { MockCookieService } from '../../helpers/mocks/service/mock-cookie.service'; import { MockProgrammingExerciseService } from '../../helpers/mocks/service/mock-programming-exercise.service'; @@ -128,7 +128,7 @@ describe('ProgrammingExerciseManageTestCasesComponent', () => { { provide: LocalStorageService, useClass: MockSyncStorage }, { provide: SessionStorageService, useClass: MockSyncStorage }, { provide: CookieService, useClass: MockCookieService }, - { provide: ActivatedRoute, useClass: MockActivatedRoute }, + { provide: ActivatedRoute, useClass: MockActivatedRouteWithSubjects }, { provide: FeatureToggleService, useClass: MockFeatureToggleService }, ], }) @@ -155,7 +155,7 @@ describe('ProgrammingExerciseManageTestCasesComponent', () => { routeSubject = new Subject(); // @ts-ignore - (route as MockActivatedRoute).setSubject(routeSubject); + (route as MockActivatedRouteWithSubjects).setSubject(routeSubject); getExerciseTestCaseStateSubject = new Subject(); testCasesChangedSubject = new Subject(); diff --git a/src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.component.spec.ts b/src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.component.spec.ts index 4cd8e9a37e2c..2f33a23c994c 100644 --- a/src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.component.spec.ts +++ b/src/test/javascript/spec/component/tutor-dashboard/tutor-exercise-dashboard.component.spec.ts @@ -4,7 +4,7 @@ import * as chai from 'chai'; import * as sinonChai from 'sinon-chai'; import { SinonStub, stub } from 'sinon'; import { ArtemisTestModule } from '../../test.module'; -import { MockActivatedRoute } from '../../helpers/mocks/activated-route/mock-activated.route'; +import { MockActivatedRouteWithSubjects } from '../../helpers/mocks/activated-route/mock-activated-route-with-subjects'; import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; import { MockComponent } from 'ng-mocks'; import { ArtemisSharedModule } from 'app/shared/shared.module'; @@ -84,7 +84,7 @@ describe('TutorExerciseDashboardComponent', () => { JhiLanguageHelper, DeviceDetectorService, { provide: AlertService, useClass: MockAlertService }, - { provide: ActivatedRoute, useClass: MockActivatedRoute }, + { provide: ActivatedRoute, useClass: MockActivatedRouteWithSubjects }, { provide: Router, useClass: MockRouter }, { provide: LocalStorageService, useClass: MockSyncStorage }, { provide: SessionStorageService, useClass: MockSyncStorage }, diff --git a/src/test/javascript/spec/helpers/mocks/activated-route/mock-activated.route.ts b/src/test/javascript/spec/helpers/mocks/activated-route/mock-activated-route-with-subjects.ts similarity index 83% rename from src/test/javascript/spec/helpers/mocks/activated-route/mock-activated.route.ts rename to src/test/javascript/spec/helpers/mocks/activated-route/mock-activated-route-with-subjects.ts index 615041b93048..28ca21214cc9 100644 --- a/src/test/javascript/spec/helpers/mocks/activated-route/mock-activated.route.ts +++ b/src/test/javascript/spec/helpers/mocks/activated-route/mock-activated-route-with-subjects.ts @@ -1,7 +1,7 @@ import { Subject } from 'rxjs'; import { Params } from '@angular/router'; -export class MockActivatedRoute { +export class MockActivatedRouteWithSubjects { private subject = new Subject(); params = this.subject; diff --git a/src/test/javascript/spec/integration/code-editor/code-editor-instructor.integration.spec.ts b/src/test/javascript/spec/integration/code-editor/code-editor-instructor.integration.spec.ts index 5b0d219f4b6a..ad421e18064a 100644 --- a/src/test/javascript/spec/integration/code-editor/code-editor-instructor.integration.spec.ts +++ b/src/test/javascript/spec/integration/code-editor/code-editor-instructor.integration.spec.ts @@ -40,7 +40,7 @@ import { ParticipationService } from 'app/exercises/shared/participation/partici import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; import { ProgrammingExerciseStudentParticipation } from 'app/entities/participation/programming-exercise-student-participation.model'; import { SolutionProgrammingExerciseParticipation } from 'app/entities/participation/solution-programming-exercise-participation.model'; -import { MockActivatedRoute } from '../../helpers/mocks/activated-route/mock-activated.route'; +import { MockActivatedRouteWithSubjects } from '../../helpers/mocks/activated-route/mock-activated-route-with-subjects'; import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; import { MockResultService } from '../../helpers/mocks/service/mock-result.service'; import { MockCodeEditorRepositoryService } from '../../helpers/mocks/service/mock-code-editor-repository.service'; @@ -109,7 +109,7 @@ describe('CodeEditorInstructorIntegration', () => { DeviceDetectorService, { provide: Router, useClass: MockRouter }, { provide: AccountService, useClass: MockAccountService }, - { provide: ActivatedRoute, useClass: MockActivatedRoute }, + { provide: ActivatedRoute, useClass: MockActivatedRouteWithSubjects }, { provide: SessionStorageService, useClass: MockSyncStorage }, { provide: ResultService, useClass: MockResultService }, { provide: LocalStorageService, useClass: MockSyncStorage }, @@ -153,7 +153,7 @@ describe('CodeEditorInstructorIntegration', () => { routeSubject = new Subject(); // @ts-ignore - (route as MockActivatedRoute).setSubject(routeSubject); + (route as MockActivatedRouteWithSubjects).setSubject(routeSubject); checkIfRepositoryIsCleanStub = stub(codeEditorRepositoryService, 'getStatus'); getRepositoryContentStub = stub(codeEditorRepositoryFileService, 'getRepositoryContent'); @@ -194,7 +194,7 @@ describe('CodeEditorInstructorIntegration', () => { routeSubject = new Subject(); // @ts-ignore - (route as MockActivatedRoute).setSubject(routeSubject); + (route as MockActivatedRouteWithSubjects).setSubject(routeSubject); findWithParticipationsSubject = new Subject<{ body: ProgrammingExercise }>(); findWithParticipationsStub.returns(findWithParticipationsSubject); diff --git a/src/test/javascript/spec/integration/code-editor/code-editor-student.integration.spec.ts b/src/test/javascript/spec/integration/code-editor/code-editor-student.integration.spec.ts index 41bd13eb73ee..d1f7235397bd 100644 --- a/src/test/javascript/spec/integration/code-editor/code-editor-student.integration.spec.ts +++ b/src/test/javascript/spec/integration/code-editor/code-editor-student.integration.spec.ts @@ -48,7 +48,7 @@ import { CodeEditorSessionService } from 'app/exercises/programming/shared/code- import { DomainService } from 'app/exercises/programming/shared/code-editor/service/code-editor-domain.service'; import { ProgrammingSubmission } from 'app/entities/programming-submission.model'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; -import { MockActivatedRoute } from '../../helpers/mocks/activated-route/mock-activated.route'; +import { MockActivatedRouteWithSubjects } from '../../helpers/mocks/activated-route/mock-activated-route-with-subjects'; import { MockParticipationWebsocketService } from '../../helpers/mocks/service/mock-participation-websocket.service'; import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; import { MockResultService } from '../../helpers/mocks/service/mock-result.service'; @@ -111,7 +111,7 @@ describe('CodeEditorStudentIntegration', () => { DeviceDetectorService, CodeEditorConflictStateService, { provide: AccountService, useClass: MockAccountService }, - { provide: ActivatedRoute, useClass: MockActivatedRoute }, + { provide: ActivatedRoute, useClass: MockActivatedRouteWithSubjects }, { provide: JhiWebsocketService, useClass: MockWebsocketService }, { provide: ParticipationWebsocketService, useClass: MockParticipationWebsocketService }, { provide: ProgrammingExerciseParticipationService, useClass: MockProgrammingExerciseParticipationService }, @@ -150,7 +150,7 @@ describe('CodeEditorStudentIntegration', () => { routeSubject = new Subject(); // @ts-ignore - (route as MockActivatedRoute).setSubject(routeSubject); + (route as MockActivatedRouteWithSubjects).setSubject(routeSubject); getLatestPendingSubmissionSubject = new Subject(); @@ -186,7 +186,7 @@ describe('CodeEditorStudentIntegration', () => { routeSubject = new Subject(); // @ts-ignore - (route as MockActivatedRoute).setSubject(routeSubject); + (route as MockActivatedRouteWithSubjects).setSubject(routeSubject); getLatestPendingSubmissionSubject = new Subject(); getLatestPendingSubmissionStub.returns(getLatestPendingSubmissionSubject); From e817d7e031029a864f2784578470bb2031f81990 Mon Sep 17 00:00:00 2001 From: Jonas Petry Date: Sat, 25 Apr 2020 00:22:48 +0200 Subject: [PATCH 108/152] import Mock classes in file-upload-exercise.component.spec.ts --- .../file-upload-exercise.component.spec.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise.component.spec.ts b/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise.component.spec.ts index 6b36badff668..6ead0dec18ee 100644 --- a/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise.component.spec.ts +++ b/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise.component.spec.ts @@ -6,17 +6,27 @@ import { ArtemisTestModule } from '../../test.module'; import { FileUploadExerciseComponent } from 'app/exercises/file-upload/manage/file-upload-exercise.component'; import { FileUploadExerciseService } from 'app/exercises/file-upload/manage/file-upload-exercise.service'; import { FileUploadExercise } from 'app/entities/file-upload-exercise.model'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; +import { MockTranslateService } from '../../helpers/mocks/service/mock-translate.service'; +import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; +import { TranslateService } from '@ngx-translate/core'; +import { Course } from 'app/entities/course.model'; describe('FileUploadExercise Management Component', () => { let comp: FileUploadExerciseComponent; let fixture: ComponentFixture; let service: FileUploadExerciseService; + const course: Course = { id: 123 } as Course; beforeEach(() => { TestBed.configureTestingModule({ imports: [ArtemisTestModule], declarations: [FileUploadExerciseComponent], - providers: [], + providers: [ + { provide: LocalStorageService, useClass: MockSyncStorage }, + { provide: SessionStorageService, useClass: MockSyncStorage }, + { provide: TranslateService, useClass: MockTranslateService }, + ], }) .overrideTemplate(FileUploadExerciseComponent, '') .compileComponents(); @@ -32,7 +42,7 @@ describe('FileUploadExercise Management Component', () => { spyOn(service, 'query').and.returnValue( of( new HttpResponse({ - body: [new FileUploadExercise(123)], + body: [new FileUploadExercise(course)], headers, }), ), From 813b264195cb5fd861246f58848ab128e25d6a5b Mon Sep 17 00:00:00 2001 From: Martin Wauligmann Date: Sat, 25 Apr 2020 00:58:55 +0200 Subject: [PATCH 109/152] Fix programming-exercise.service.spec.ts --- ...ming-exercise-management-routing.module.ts | 2 +- .../programming-exercise.service.spec.ts | 33 ++++++++++++++++--- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/main/webapp/app/exercises/programming/manage/programming-exercise-management-routing.module.ts b/src/main/webapp/app/exercises/programming/manage/programming-exercise-management-routing.module.ts index 322912ee598a..d1a0f302247d 100644 --- a/src/main/webapp/app/exercises/programming/manage/programming-exercise-management-routing.module.ts +++ b/src/main/webapp/app/exercises/programming/manage/programming-exercise-management-routing.module.ts @@ -24,7 +24,7 @@ export class ProgrammingExerciseResolve implements Resolve } } -const routes: Routes = [ +export const routes: Routes = [ { path: ':courseId/programming-exercises/new', component: ProgrammingExerciseUpdateComponent, diff --git a/src/test/javascript/spec/service/programming-exercise.service.spec.ts b/src/test/javascript/spec/service/programming-exercise.service.spec.ts index 1946165ea72d..5c76811530b0 100644 --- a/src/test/javascript/spec/service/programming-exercise.service.spec.ts +++ b/src/test/javascript/spec/service/programming-exercise.service.spec.ts @@ -3,6 +3,17 @@ import { HttpClientTestingModule, HttpTestingController } from '@angular/common/ import { map, take } from 'rxjs/operators'; import { ProgrammingExerciseService } from 'app/exercises/programming/manage/services/programming-exercise.service'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; +import { TranslateService } from '@ngx-translate/core'; +import { MockTranslateService } from '../helpers/mocks/service/mock-translate.service'; +import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; +import { MockSyncStorage } from '../helpers/mocks/service/mock-sync-storage.service'; +import { routes } from 'app/exercises/programming/manage/programming-exercise-management-routing.module'; +import { RouterTestingModule } from '@angular/router/testing'; +import { ArtemisTestModule } from '../test.module'; +import { FormsModule } from '@angular/forms'; +import { ArtemisSharedModule } from 'app/shared/shared.module'; +import { ArtemisSharedComponentModule } from 'app/shared/components/shared-component.module'; +import { ArtemisProgrammingExerciseManagementModule } from 'app/exercises/programming/manage/programming-exercise-management.module'; describe('ProgrammingExercise Service', () => { let injector: TestBed; @@ -11,7 +22,21 @@ describe('ProgrammingExercise Service', () => { let elemDefault: ProgrammingExercise; beforeEach(() => { TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], + imports: [ + HttpClientTestingModule, + RouterTestingModule.withRoutes(routes), + ArtemisTestModule, + FormsModule, + ArtemisSharedModule, + ArtemisSharedComponentModule, + ArtemisProgrammingExerciseManagementModule, + ], + providers: [ + { provide: TranslateService, useClass: MockTranslateService }, + { provide: SessionStorageService, useClass: MockSyncStorage }, + { provide: LocalStorageService, useClass: MockSyncStorage }, + { provide: LocalStorageService, useClass: MockSyncStorage }, + ], }); injector = getTestBed(); service = injector.get(ProgrammingExerciseService); @@ -20,7 +45,7 @@ describe('ProgrammingExercise Service', () => { elemDefault = new ProgrammingExercise(); }); - describe('Service methods', async () => { + describe('Service methods', () => { it('should find an element', async () => { const returnedFromService = Object.assign({}, elemDefault); service @@ -41,7 +66,7 @@ describe('ProgrammingExercise Service', () => { ); const expected = Object.assign({}, returnedFromService); service - .create(new ProgrammingExercise(null)) + .automaticSetup(new ProgrammingExercise()) .pipe(take(1)) .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); const req = httpMock.expectOne({ method: 'POST' }); @@ -94,7 +119,7 @@ describe('ProgrammingExercise Service', () => { }); it('should delete a ProgrammingExercise', async () => { - service.delete(123).subscribe((resp) => expect(resp.ok)); + service.delete(123, false, false).subscribe((resp) => expect(resp.ok)); const req = httpMock.expectOne({ method: 'DELETE' }); req.flush({ status: 200 }); From d4c231dada08fd0d7dc8ab81833f7a49091ea5ad Mon Sep 17 00:00:00 2001 From: Martin Wauligmann Date: Sat, 25 Apr 2020 01:02:27 +0200 Subject: [PATCH 110/152] Fix register.component.spec.ts --- .../spec/component/account/register.component.spec.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/test/javascript/spec/component/account/register.component.spec.ts b/src/test/javascript/spec/component/account/register.component.spec.ts index a21605113343..59866dfbffc9 100644 --- a/src/test/javascript/spec/component/account/register.component.spec.ts +++ b/src/test/javascript/spec/component/account/register.component.spec.ts @@ -45,10 +45,12 @@ describe('RegisterComponent', () => { comp.register(); tick(); - expect(service.save).toHaveBeenCalledWith({ - password: 'password', - langKey: 'en', - }); + expect(service.save).toHaveBeenCalledWith( + expect.objectContaining({ + password: 'password', + langKey: 'en', + }), + ); expect(comp.success).toEqual(true); expect(comp.registerAccount.langKey).toEqual('en'); expect(mockTranslate.getCurrentSpy).toHaveBeenCalled(); From cc635e3a535ac2b4a513415af366c32cd2e81a70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Lei=C3=9F?= Date: Sat, 25 Apr 2020 01:14:18 +0200 Subject: [PATCH 111/152] Fix tests. --- ...gramming-exercise-detail.component.spec.ts | 4 +++- ...gramming-exercise-update.component.spec.ts | 22 +++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-detail.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-detail.component.spec.ts index 9c7d63ff96c1..b5bfcf58ea91 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-detail.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-detail.component.spec.ts @@ -9,7 +9,9 @@ import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; describe('ProgrammingExercise Management Detail Component', () => { let comp: ProgrammingExerciseDetailComponent; let fixture: ComponentFixture; - const route = ({ data: of({ programmingExercise: new ProgrammingExercise(123) }) } as any) as ActivatedRoute; + const programmingExercise = new ProgrammingExercise(); + programmingExercise.id = 123; + const route = ({ data: of({ programmingExercise }) } as any) as ActivatedRoute; beforeEach(() => { TestBed.configureTestingModule({ diff --git a/src/test/javascript/spec/component/programming-exercise/programming-exercise-update.component.spec.ts b/src/test/javascript/spec/component/programming-exercise/programming-exercise-update.component.spec.ts index 118e7c0058ed..38659ea592aa 100644 --- a/src/test/javascript/spec/component/programming-exercise/programming-exercise-update.component.spec.ts +++ b/src/test/javascript/spec/component/programming-exercise/programming-exercise-update.component.spec.ts @@ -1,11 +1,17 @@ import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; import { HttpResponse } from '@angular/common/http'; import { of } from 'rxjs'; +import * as moment from 'moment'; import { ArtemisTestModule } from '../../test.module'; import { ProgrammingExerciseUpdateComponent } from 'app/exercises/programming/manage/update/programming-exercise-update.component'; import { ProgrammingExerciseService } from 'app/exercises/programming/manage/services/programming-exercise.service'; import { ProgrammingExercise } from 'app/entities/programming-exercise.model'; +import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; +import { MockTranslateService } from '../../helpers/mocks/service/mock-translate.service'; +import { TranslateService } from '@ngx-translate/core'; +import { Course } from 'app/entities/course.model'; describe('ProgrammingExercise Management Update Component', () => { let comp: ProgrammingExerciseUpdateComponent; @@ -16,6 +22,11 @@ describe('ProgrammingExercise Management Update Component', () => { TestBed.configureTestingModule({ imports: [ArtemisTestModule], declarations: [ProgrammingExerciseUpdateComponent], + providers: [ + { provide: LocalStorageService, useClass: MockSyncStorage }, + { provide: SessionStorageService, useClass: MockSyncStorage }, + { provide: TranslateService, useClass: MockTranslateService }, + ], }) .overrideTemplate(ProgrammingExerciseUpdateComponent, '') .compileComponents(); @@ -28,7 +39,9 @@ describe('ProgrammingExercise Management Update Component', () => { describe('save', () => { it('Should call update service on save for existing entity', fakeAsync(() => { // GIVEN - const entity = new ProgrammingExercise(123); + const entity = new ProgrammingExercise(new Course()); + entity.id = 123; + entity.releaseDate = moment(); // We will get a warning if we do not set a release date spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); comp.programmingExercise = entity; // WHEN @@ -36,21 +49,22 @@ describe('ProgrammingExercise Management Update Component', () => { tick(); // simulate async // THEN - expect(service.update).toHaveBeenCalledWith(entity); + expect(service.update).toHaveBeenCalledWith(entity, {}); expect(comp.isSaving).toEqual(false); })); it('Should call create service on save for new entity', fakeAsync(() => { // GIVEN const entity = new ProgrammingExercise(); - spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); + entity.releaseDate = moment(); // We will get a warning if we do not set a release date + spyOn(service, 'automaticSetup').and.returnValue(of(new HttpResponse({ body: entity }))); comp.programmingExercise = entity; // WHEN comp.save(); tick(); // simulate async // THEN - expect(service.create).toHaveBeenCalledWith(entity); + expect(service.automaticSetup).toHaveBeenCalledWith(entity); expect(comp.isSaving).toEqual(false); })); }); From f700d4b456ad554264684e3a129398b14e9e3d68 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Sat, 25 Apr 2020 02:03:48 +0200 Subject: [PATCH 112/152] Fix test case in quiz-exercise.component.spec.ts --- .../quiz-exercise.component.spec.ts | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/test/javascript/spec/component/quiz-exercise/quiz-exercise.component.spec.ts b/src/test/javascript/spec/component/quiz-exercise/quiz-exercise.component.spec.ts index e6ea5505f7ec..f57c893b43b1 100644 --- a/src/test/javascript/spec/component/quiz-exercise/quiz-exercise.component.spec.ts +++ b/src/test/javascript/spec/component/quiz-exercise/quiz-exercise.component.spec.ts @@ -1,22 +1,38 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { of } from 'rxjs'; import { HttpHeaders, HttpResponse } from '@angular/common/http'; +import { ActivatedRoute, convertToParamMap } from '@angular/router'; +import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; +import { TranslateService } from '@ngx-translate/core'; import { ArtemisTestModule } from '../../test.module'; import { QuizExerciseComponent } from 'app/exercises/quiz/manage/quiz-exercise.component'; import { QuizExerciseService } from 'app/exercises/quiz/manage/quiz-exercise.service'; import { QuizExercise } from 'app/entities/quiz/quiz-exercise.model'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; +import { MockTranslateService } from '../../helpers/mocks/service/mock-translate.service'; +import { Course } from 'app/entities/course.model'; describe('QuizExercise Management Component', () => { let comp: QuizExerciseComponent; let fixture: ComponentFixture; let service: QuizExerciseService; + const course = { id: 123 } as Course; + const quizExercise = new QuizExercise(course); + quizExercise.id = 456; + const route = ({ snapshot: { paramMap: convertToParamMap({ courseId: course.id }) } } as any) as ActivatedRoute; + beforeEach(() => { TestBed.configureTestingModule({ imports: [ArtemisTestModule], declarations: [QuizExerciseComponent], - providers: [], + providers: [ + { provide: ActivatedRoute, useValue: route }, + { provide: LocalStorageService, useClass: MockSyncStorage }, + { provide: SessionStorageService, useClass: MockSyncStorage }, + { provide: TranslateService, useClass: MockTranslateService }, + ], }) .overrideTemplate(QuizExerciseComponent, '') .compileComponents(); @@ -26,23 +42,24 @@ describe('QuizExercise Management Component', () => { service = fixture.debugElement.injector.get(QuizExerciseService); }); - it('Should call load all on init', () => { + it('Should call loadExercises on init', () => { // GIVEN const headers = new HttpHeaders().append('link', 'link;link'); - spyOn(service, 'query').and.returnValue( + spyOn(service, 'findForCourse').and.returnValue( of( new HttpResponse({ - body: [new QuizExercise(123)], + body: [quizExercise], headers, }), ), ); // WHEN + comp.course = course; comp.ngOnInit(); // THEN - expect(service.query).toHaveBeenCalled(); - expect(comp.quizExercises[0]).toEqual(jasmine.objectContaining({ id: 123 })); + expect(service.findForCourse).toHaveBeenCalled(); + expect(comp.quizExercises[0]).toEqual(quizExercise); }); }); From cd37f0f1cf587ebf77f76079b245ff18ff791ced Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Sat, 25 Apr 2020 02:09:11 +0200 Subject: [PATCH 113/152] Remove duplicated provider for LocalStorageService --- .../javascript/spec/service/programming-exercise.service.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/javascript/spec/service/programming-exercise.service.spec.ts b/src/test/javascript/spec/service/programming-exercise.service.spec.ts index 5c76811530b0..9ca5b25816d9 100644 --- a/src/test/javascript/spec/service/programming-exercise.service.spec.ts +++ b/src/test/javascript/spec/service/programming-exercise.service.spec.ts @@ -35,7 +35,6 @@ describe('ProgrammingExercise Service', () => { { provide: TranslateService, useClass: MockTranslateService }, { provide: SessionStorageService, useClass: MockSyncStorage }, { provide: LocalStorageService, useClass: MockSyncStorage }, - { provide: LocalStorageService, useClass: MockSyncStorage }, ], }); injector = getTestBed(); From 3a14ddadf47ed17de2ca55fd016f45206937208b Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Sat, 25 Apr 2020 02:11:07 +0200 Subject: [PATCH 114/152] Fix test cases in quiz-exercise.service.spec.ts --- .../spec/service/quiz-exercise.service.spec.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/test/javascript/spec/service/quiz-exercise.service.spec.ts b/src/test/javascript/spec/service/quiz-exercise.service.spec.ts index 2b091f5fa98a..2a88f9d9c922 100644 --- a/src/test/javascript/spec/service/quiz-exercise.service.spec.ts +++ b/src/test/javascript/spec/service/quiz-exercise.service.spec.ts @@ -1,9 +1,14 @@ +import { TranslateService } from '@ngx-translate/core'; import { getTestBed, TestBed } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { map, take } from 'rxjs/operators'; +import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { QuizExerciseService } from 'app/exercises/quiz/manage/quiz-exercise.service'; import { QuizExercise } from 'app/entities/quiz/quiz-exercise.model'; import { Course } from 'app/entities/course.model'; +import { MockTranslateService } from '../helpers/mocks/service/mock-translate.service'; +import { MockSyncStorage } from '../helpers/mocks/service/mock-sync-storage.service'; +import { ArtemisTestModule } from '../test.module'; describe('QuizExercise Service', () => { let injector: TestBed; @@ -12,7 +17,11 @@ describe('QuizExercise Service', () => { let elemDefault: QuizExercise; beforeEach(() => { TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], + imports: [ArtemisTestModule, HttpClientTestingModule], + providers: [ + { provide: SessionStorageService, useClass: MockSyncStorage }, + { provide: TranslateService, useClass: MockTranslateService }, + ], }); injector = getTestBed(); service = injector.get(QuizExerciseService); From 326f39b7f830dbc2e47b1299a742f51c5ce08fe0 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Sat, 25 Apr 2020 11:29:04 +0200 Subject: [PATCH 115/152] Fix test case in file-upload-exercise.component.spec.ts --- .../file-upload-exercise.component.spec.ts | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise.component.spec.ts b/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise.component.spec.ts index 6ead0dec18ee..77dea10a4211 100644 --- a/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise.component.spec.ts +++ b/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise.component.spec.ts @@ -1,6 +1,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { of } from 'rxjs'; import { HttpHeaders, HttpResponse } from '@angular/common/http'; +import { ActivatedRoute, convertToParamMap } from '@angular/router'; +import { of } from 'rxjs'; import { ArtemisTestModule } from '../../test.module'; import { FileUploadExerciseComponent } from 'app/exercises/file-upload/manage/file-upload-exercise.component'; @@ -11,18 +12,24 @@ import { MockTranslateService } from '../../helpers/mocks/service/mock-translate import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { TranslateService } from '@ngx-translate/core'; import { Course } from 'app/entities/course.model'; +import { CourseExerciseService } from 'app/course/manage/course-management.service'; describe('FileUploadExercise Management Component', () => { let comp: FileUploadExerciseComponent; let fixture: ComponentFixture; - let service: FileUploadExerciseService; + let service: CourseExerciseService; + const course: Course = { id: 123 } as Course; + const fileUploadExercise = new FileUploadExercise(course); + fileUploadExercise.id = 456; + const route = ({ snapshot: { paramMap: convertToParamMap({ courseId: course.id }) } } as any) as ActivatedRoute; beforeEach(() => { TestBed.configureTestingModule({ imports: [ArtemisTestModule], declarations: [FileUploadExerciseComponent], providers: [ + { provide: ActivatedRoute, useValue: route }, { provide: LocalStorageService, useClass: MockSyncStorage }, { provide: SessionStorageService, useClass: MockSyncStorage }, { provide: TranslateService, useClass: MockTranslateService }, @@ -33,26 +40,27 @@ describe('FileUploadExercise Management Component', () => { fixture = TestBed.createComponent(FileUploadExerciseComponent); comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(FileUploadExerciseService); + service = fixture.debugElement.injector.get(CourseExerciseService); }); - it('Should call load all on init', () => { + it('Should call loadExercises on init', () => { // GIVEN const headers = new HttpHeaders().append('link', 'link;link'); - spyOn(service, 'query').and.returnValue( + spyOn(service, 'findAllFileUploadExercisesForCourse').and.returnValue( of( new HttpResponse({ - body: [new FileUploadExercise(course)], + body: [fileUploadExercise], headers, }), ), ); // WHEN + comp.course = course; comp.ngOnInit(); // THEN - expect(service.query).toHaveBeenCalled(); - expect(comp.fileUploadExercises[0]).toEqual(jasmine.objectContaining({ id: 123 })); + expect(service.findAllFileUploadExercisesForCourse).toHaveBeenCalled(); + expect(comp.fileUploadExercises[0]).toEqual(fileUploadExercise); }); }); From fd219ea1733198caa2ba81b5fb2aec06d2e27acc Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Sat, 25 Apr 2020 11:29:38 +0200 Subject: [PATCH 116/152] Remove unnecessary import from file-upload-exercise.component.spec.ts --- .../file-upload-exercise/file-upload-exercise.component.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise.component.spec.ts b/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise.component.spec.ts index 77dea10a4211..4ae7c29de349 100644 --- a/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise.component.spec.ts +++ b/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise.component.spec.ts @@ -5,7 +5,6 @@ import { of } from 'rxjs'; import { ArtemisTestModule } from '../../test.module'; import { FileUploadExerciseComponent } from 'app/exercises/file-upload/manage/file-upload-exercise.component'; -import { FileUploadExerciseService } from 'app/exercises/file-upload/manage/file-upload-exercise.service'; import { FileUploadExercise } from 'app/entities/file-upload-exercise.model'; import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; import { MockTranslateService } from '../../helpers/mocks/service/mock-translate.service'; From 17552af303440a69e529bf5e503d32f00ce0b803 Mon Sep 17 00:00:00 2001 From: Balazs Czopf Date: Sat, 25 Apr 2020 15:42:45 +0200 Subject: [PATCH 117/152] Fix test case in text-exercise-update.component.spec.ts --- .../text-exercise/text-exercise-update.component.spec.ts | 7 +++++++ .../helpers/mocks/service/mock-text-exercise.service.ts | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 src/test/javascript/spec/helpers/mocks/service/mock-text-exercise.service.ts diff --git a/src/test/javascript/spec/component/text-exercise/text-exercise-update.component.spec.ts b/src/test/javascript/spec/component/text-exercise/text-exercise-update.component.spec.ts index fe75b95bdf34..5cb6e2deaf86 100644 --- a/src/test/javascript/spec/component/text-exercise/text-exercise-update.component.spec.ts +++ b/src/test/javascript/spec/component/text-exercise/text-exercise-update.component.spec.ts @@ -6,6 +6,9 @@ import { ArtemisTestModule } from '../../test.module'; import { TextExerciseUpdateComponent } from 'app/exercises/text/manage/text-exercise/text-exercise-update.component'; import { TextExerciseService } from 'app/exercises/text/manage/text-exercise/text-exercise.service'; import { TextExercise } from 'app/entities/text-exercise.model'; +import { MockTextExerciseService } from '../../helpers/mocks/service/mock-text-exercise.service'; +import { LocalStorageService } from 'ngx-webstorage'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; describe('TextExercise Management Update Component', () => { let comp: TextExerciseUpdateComponent; @@ -15,6 +18,10 @@ describe('TextExercise Management Update Component', () => { beforeEach(() => { TestBed.configureTestingModule({ imports: [ArtemisTestModule], + providers: [ + { provide: TextExerciseService, useClass: MockTextExerciseService }, + { provide: LocalStorageService, useClass: MockSyncStorage }, + ], declarations: [TextExerciseUpdateComponent], }) .overrideTemplate(TextExerciseUpdateComponent, '') diff --git a/src/test/javascript/spec/helpers/mocks/service/mock-text-exercise.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-text-exercise.service.ts new file mode 100644 index 000000000000..e28a05a4cc15 --- /dev/null +++ b/src/test/javascript/spec/helpers/mocks/service/mock-text-exercise.service.ts @@ -0,0 +1,7 @@ +import { Observable } from 'rxjs'; +import { TextExercise } from 'app/entities/text-exercise.model'; + +export class MockTextExerciseService { + create = (textExercise: TextExercise) => Observable.of([{ id: 123 } as TextExercise]); + update = (textExercise: TextExercise, req?: any) => Observable.of([{ id: 456 } as TextExercise]); +} From 935162d98d7b9260c054e4e217dc1e680019dcbc Mon Sep 17 00:00:00 2001 From: Balazs Czopf Date: Sat, 25 Apr 2020 20:18:20 +0200 Subject: [PATCH 118/152] Fix test case in text-exercise-update.component.spec.ts #2 --- .../text-exercise-update.component.spec.ts | 10 +++++----- .../mocks/service/mock-text-exercise.service.ts | 7 ------- 2 files changed, 5 insertions(+), 12 deletions(-) delete mode 100644 src/test/javascript/spec/helpers/mocks/service/mock-text-exercise.service.ts diff --git a/src/test/javascript/spec/component/text-exercise/text-exercise-update.component.spec.ts b/src/test/javascript/spec/component/text-exercise/text-exercise-update.component.spec.ts index 5cb6e2deaf86..1f07590eb749 100644 --- a/src/test/javascript/spec/component/text-exercise/text-exercise-update.component.spec.ts +++ b/src/test/javascript/spec/component/text-exercise/text-exercise-update.component.spec.ts @@ -6,8 +6,7 @@ import { ArtemisTestModule } from '../../test.module'; import { TextExerciseUpdateComponent } from 'app/exercises/text/manage/text-exercise/text-exercise-update.component'; import { TextExerciseService } from 'app/exercises/text/manage/text-exercise/text-exercise.service'; import { TextExercise } from 'app/entities/text-exercise.model'; -import { MockTextExerciseService } from '../../helpers/mocks/service/mock-text-exercise.service'; -import { LocalStorageService } from 'ngx-webstorage'; +import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; describe('TextExercise Management Update Component', () => { @@ -19,8 +18,8 @@ describe('TextExercise Management Update Component', () => { TestBed.configureTestingModule({ imports: [ArtemisTestModule], providers: [ - { provide: TextExerciseService, useClass: MockTextExerciseService }, { provide: LocalStorageService, useClass: MockSyncStorage }, + { provide: SessionStorageService, useClass: MockSyncStorage }, ], declarations: [TextExerciseUpdateComponent], }) @@ -35,7 +34,8 @@ describe('TextExercise Management Update Component', () => { describe('save', () => { it('Should call update service on save for existing entity', fakeAsync(() => { // GIVEN - const entity = new TextExercise(123); + const entity = new TextExercise(); + entity.id = 123; spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); comp.textExercise = entity; // WHEN @@ -43,7 +43,7 @@ describe('TextExercise Management Update Component', () => { tick(); // simulate async // THEN - expect(service.update).toHaveBeenCalledWith(entity); + expect(service.update).toHaveBeenCalledWith(entity, {}); expect(comp.isSaving).toEqual(false); })); diff --git a/src/test/javascript/spec/helpers/mocks/service/mock-text-exercise.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-text-exercise.service.ts deleted file mode 100644 index e28a05a4cc15..000000000000 --- a/src/test/javascript/spec/helpers/mocks/service/mock-text-exercise.service.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { Observable } from 'rxjs'; -import { TextExercise } from 'app/entities/text-exercise.model'; - -export class MockTextExerciseService { - create = (textExercise: TextExercise) => Observable.of([{ id: 123 } as TextExercise]); - update = (textExercise: TextExercise, req?: any) => Observable.of([{ id: 456 } as TextExercise]); -} From 3d56efb0ca85d1e5f3034c200b613da8102d08c5 Mon Sep 17 00:00:00 2001 From: Balazs Czopf Date: Sat, 25 Apr 2020 21:16:48 +0200 Subject: [PATCH 119/152] Fix test case in text-submission.service.spec.ts --- .../participate/text-submission.service.ts | 8 ++-- .../service/text-submission.service.spec.ts | 42 +------------------ 2 files changed, 6 insertions(+), 44 deletions(-) diff --git a/src/main/webapp/app/exercises/text/participate/text-submission.service.ts b/src/main/webapp/app/exercises/text/participate/text-submission.service.ts index 3dbf16ad9991..d81121ecd2fd 100644 --- a/src/main/webapp/app/exercises/text/participate/text-submission.service.ts +++ b/src/main/webapp/app/exercises/text/participate/text-submission.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { HttpClient, HttpResponse } from '@angular/common/http'; import { Observable } from 'rxjs/Observable'; -import { tap } from 'rxjs/operators'; +import { tap, map } from 'rxjs/operators'; import { TextSubmission } from 'app/entities/text-submission.model'; import { createRequestOption } from 'app/shared/util/request-util'; @@ -19,7 +19,7 @@ export class TextSubmissionService { .post(`api/exercises/${exerciseId}/text-submissions`, copy, { observe: 'response', }) - .map((res: EntityResponseType) => TextSubmissionService.convertResponse(res)); + .pipe(map((res: EntityResponseType) => TextSubmissionService.convertResponse(res))); } update(textSubmission: TextSubmission, exerciseId: number): Observable { @@ -29,7 +29,7 @@ export class TextSubmissionService { headers: { 'Content-Type': 'application/json' }, observe: 'response', }) - .map((res: EntityResponseType) => TextSubmissionService.convertResponse(res)); + .pipe(map((res: EntityResponseType) => TextSubmissionService.convertResponse(res))); } getTextSubmissionsForExercise(exerciseId: number, req: { submittedOnly?: boolean; assessedByTutor?: boolean }): Observable> { @@ -39,7 +39,7 @@ export class TextSubmissionService { params: options, observe: 'response', }) - .map((res: HttpResponse) => TextSubmissionService.convertArrayResponse(res)); + .pipe(map((res: HttpResponse) => TextSubmissionService.convertArrayResponse(res))); } getTextSubmissionForExerciseWithoutAssessment(exerciseId: number, lock = false): Observable { diff --git a/src/test/javascript/spec/service/text-submission.service.spec.ts b/src/test/javascript/spec/service/text-submission.service.spec.ts index 8294d915784f..df3b79bb2c58 100644 --- a/src/test/javascript/spec/service/text-submission.service.spec.ts +++ b/src/test/javascript/spec/service/text-submission.service.spec.ts @@ -21,17 +21,6 @@ describe('TextSubmission Service', () => { }); describe('Service methods', async () => { - it('should find an element', async () => { - const returnedFromService = Object.assign({}, elemDefault); - service - .find(123) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: elemDefault })); - - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify(returnedFromService)); - }); - it('should create a TextSubmission', async () => { const returnedFromService = Object.assign( { @@ -43,7 +32,7 @@ describe('TextSubmission Service', () => { service .create(new TextSubmission(null)) .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); + .subscribe((resp: any) => expect(resp).toMatchObject({ body: expected })); const req = httpMock.expectOne({ method: 'POST' }); req.flush(JSON.stringify(returnedFromService)); }); @@ -60,37 +49,10 @@ describe('TextSubmission Service', () => { service .update(expected) .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); + .subscribe((resp: any) => expect(resp).toMatchObject({ body: expected })); const req = httpMock.expectOne({ method: 'PUT' }); req.flush(JSON.stringify(returnedFromService)); }); - - it('should return a list of TextSubmission', async () => { - const returnedFromService = Object.assign( - { - text: 'BBBBBB', - }, - elemDefault, - ); - const expected = Object.assign({}, returnedFromService); - service - .query(expected) - .pipe( - take(1), - map((resp) => resp.body), - ) - .subscribe((body) => expect(body).toContainEqual(expected)); - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify([returnedFromService])); - httpMock.verify(); - }); - - it('should delete a TextSubmission', async () => { - service.delete(123).subscribe((resp) => expect(resp.ok)); - - const req = httpMock.expectOne({ method: 'DELETE' }); - req.flush({ status: 200 }); - }); }); afterEach(() => { From d13998b42edef32cfc13526ede710989cb2c72c3 Mon Sep 17 00:00:00 2001 From: ge72zan Date: Sun, 26 Apr 2020 17:56:40 +0200 Subject: [PATCH 120/152] fix test case in file-upload-exercise-update.component.spec.ts --- .../file-upload-exercise-update.component.spec.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise-update.component.spec.ts b/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise-update.component.spec.ts index f84ac7ab9dd3..ce7efe0f0142 100644 --- a/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise-update.component.spec.ts +++ b/src/test/javascript/spec/component/file-upload-exercise/file-upload-exercise-update.component.spec.ts @@ -6,6 +6,9 @@ import { ArtemisTestModule } from '../../test.module'; import { FileUploadExerciseUpdateComponent } from 'app/exercises/file-upload/manage/file-upload-exercise-update.component'; import { FileUploadExerciseService } from 'app/exercises/file-upload/manage/file-upload-exercise.service'; import { FileUploadExercise } from 'app/entities/file-upload-exercise.model'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; +import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; +import { MockFileUploadExerciseService } from '../../helpers/mocks/service/mock-file-upload-exercise.service'; describe('FileUploadExercise Management Update Component', () => { let comp: FileUploadExerciseUpdateComponent; @@ -16,6 +19,11 @@ describe('FileUploadExercise Management Update Component', () => { TestBed.configureTestingModule({ imports: [ArtemisTestModule], declarations: [FileUploadExerciseUpdateComponent], + providers: [ + { provide: LocalStorageService, useClass: MockSyncStorage }, + { provide: SessionStorageService, useClass: MockSyncStorage }, + { provide: FileUploadExerciseService, useClass: MockFileUploadExerciseService }, + ], }) .overrideTemplate(FileUploadExerciseUpdateComponent, '') .compileComponents(); @@ -28,7 +36,8 @@ describe('FileUploadExercise Management Update Component', () => { describe('save', () => { it('Should call update service on save for existing entity', fakeAsync(() => { // GIVEN - const entity = new FileUploadExercise(123); + const entity = new FileUploadExercise(); + entity.id = 123; spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); comp.fileUploadExercise = entity; // WHEN @@ -36,7 +45,7 @@ describe('FileUploadExercise Management Update Component', () => { tick(); // simulate async // THEN - expect(service.update).toHaveBeenCalledWith(entity); + expect(service.update).toHaveBeenCalledWith(entity, 123); expect(comp.isSaving).toEqual(false); })); From 02f14866872a5e9be2f7c6829298b103eda80d57 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Sun, 26 Apr 2020 18:04:40 +0200 Subject: [PATCH 121/152] Fix test cases in settings.component.spec.ts --- .../account/settings.component.spec.ts | 39 +++++-------------- .../mocks/service/mock-account.service.ts | 1 - 2 files changed, 10 insertions(+), 30 deletions(-) diff --git a/src/test/javascript/spec/component/account/settings.component.spec.ts b/src/test/javascript/spec/component/account/settings.component.spec.ts index 4e5a0e422bdd..3133cf736f8f 100644 --- a/src/test/javascript/spec/component/account/settings.component.spec.ts +++ b/src/test/javascript/spec/component/account/settings.component.spec.ts @@ -11,7 +11,7 @@ import { MockAccountService } from '../../helpers/mocks/service/mock-account.ser describe('SettingsComponent', () => { let comp: SettingsComponent; let fixture: ComponentFixture; - let mockAuth: MockAccountService; + let accountService: AccountService; const accountValues: Account = { firstName: 'John', lastName: 'Doe', @@ -29,7 +29,7 @@ describe('SettingsComponent', () => { TestBed.configureTestingModule({ imports: [ArtemisTestModule], declarations: [SettingsComponent], - providers: [FormBuilder], + providers: [FormBuilder, { provide: AccountService, useClass: MockAccountService }], }) .overrideTemplate(SettingsComponent, '') .compileComponents(); @@ -38,52 +38,33 @@ describe('SettingsComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(SettingsComponent); comp = fixture.componentInstance; - mockAuth = TestBed.get(AccountService); - mockAuth.setIdentityResponse(accountValues); - }); - - it('should send the current identity upon save', () => { - // GIVEN - mockAuth.saveSpy.and.returnValue(of({})); - const settingsFormValues = { - firstName: 'John', - lastName: 'Doe', - email: 'john.doe@mail.com', - langKey: 'en', - }; - - // WHEN - comp.ngOnInit(); - comp.save(); - - // THEN - expect(mockAuth.identitySpy).toHaveBeenCalled(); - expect(mockAuth.saveSpy).toHaveBeenCalledWith(accountValues); - expect(mockAuth.authenticateSpy).toHaveBeenCalledWith(accountValues); - expect(comp.settingsForm.value).toEqual(settingsFormValues); + accountService = TestBed.get(AccountService); + comp.settingsAccount = { langKey: 'en' } as Account; }); it('should notify of success upon successful save', () => { // GIVEN - mockAuth.saveSpy.and.returnValue(of({})); + spyOn(accountService, 'save').and.returnValue(of({})); // WHEN comp.ngOnInit(); comp.save(); // THEN - expect(comp.success).toBe(true); + expect(comp.success).toBe('OK'); + expect(comp.error).toBe(null); }); it('should notify of error upon failed save', () => { // GIVEN - mockAuth.saveSpy.and.returnValue(throwError('ERROR')); + spyOn(accountService, 'save').and.returnValue(throwError('An error message')); // WHEN comp.ngOnInit(); comp.save(); // THEN - expect(comp.success).toBe(false); + expect(comp.success).toBe(null); + expect(comp.error).toBe('ERROR'); }); }); diff --git a/src/test/javascript/spec/helpers/mocks/service/mock-account.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-account.service.ts index a0896fb04af7..d223431de1a4 100644 --- a/src/test/javascript/spec/helpers/mocks/service/mock-account.service.ts +++ b/src/test/javascript/spec/helpers/mocks/service/mock-account.service.ts @@ -18,5 +18,4 @@ export class MockAccountService implements IAccountService { isAuthenticated = () => true; isAdmin = () => true; save = (account: any) => ({} as any); - setIdentityResponse = (account: Account | null) => {}; } From c7b0a4b27a926d719cccec4e4a349ad57baef6ba Mon Sep 17 00:00:00 2001 From: Hanya Elhashemy Date: Sun, 26 Apr 2020 19:25:07 +0200 Subject: [PATCH 122/152] fix quiz-exercise-detail.component.spec.ts tests --- .../quiz-exercise-detail.component.spec.ts | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/test/javascript/spec/component/quiz-exercise/quiz-exercise-detail.component.spec.ts b/src/test/javascript/spec/component/quiz-exercise/quiz-exercise-detail.component.spec.ts index 560b7c1683d9..e3edec7242bf 100644 --- a/src/test/javascript/spec/component/quiz-exercise/quiz-exercise-detail.component.spec.ts +++ b/src/test/javascript/spec/component/quiz-exercise/quiz-exercise-detail.component.spec.ts @@ -1,37 +1,52 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { ActivatedRoute } from '@angular/router'; -import { of } from 'rxjs'; +import { ActivatedRoute, convertToParamMap } from '@angular/router'; import { ArtemisTestModule } from '../../test.module'; import { QuizExerciseDetailComponent } from 'app/exercises/quiz/manage/quiz-exercise-detail.component'; import { QuizExercise } from 'app/entities/quiz/quiz-exercise.model'; +import { CourseExerciseService } from 'app/course/manage/course-management.service'; +import { Course } from 'app/entities/course.model'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; +import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; +import { MockTranslateService } from '../../helpers/mocks/service/mock-translate.service'; +import { TranslateService } from '@ngx-translate/core'; describe('QuizExercise Management Detail Component', () => { + let service: CourseExerciseService; let comp: QuizExerciseDetailComponent; let fixture: ComponentFixture; - const route = ({ data: of({ quizExercise: new QuizExercise(123) }) } as any) as ActivatedRoute; + const course: Course = { id: 123 } as Course; + const quizExercise = new QuizExercise(course); + quizExercise.id = 456; + const route = ({ snapshot: { paramMap: convertToParamMap({ courseId: course.id }) } } as any) as ActivatedRoute; beforeEach(() => { TestBed.configureTestingModule({ imports: [ArtemisTestModule], declarations: [QuizExerciseDetailComponent], - providers: [{ provide: ActivatedRoute, useValue: route }], + providers: [ + { provide: ActivatedRoute, useValue: route }, + { provide: LocalStorageService, useClass: MockSyncStorage }, + { provide: SessionStorageService, useClass: MockSyncStorage }, + { provide: TranslateService, useClass: MockTranslateService }, + ], }) .overrideTemplate(QuizExerciseDetailComponent, '') .compileComponents(); fixture = TestBed.createComponent(QuizExerciseDetailComponent); comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(CourseExerciseService); }); describe('OnInit', () => { - it('Should call load all on init', () => { + it('Should call loadExercises on init', () => { // GIVEN // WHEN + comp.course = course; comp.ngOnInit(); // THEN - expect(comp.quizExercise).toEqual(jasmine.objectContaining({ id: 123 })); }); }); }); From 73fc7e6286446aefcd9b8b74e021a79795b99820 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Sun, 26 Apr 2020 19:48:20 +0200 Subject: [PATCH 123/152] Fix test cases in quiz-exercise-detail.component.spec.ts --- .../quiz-exercise-detail.component.spec.ts | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/test/javascript/spec/component/quiz-exercise/quiz-exercise-detail.component.spec.ts b/src/test/javascript/spec/component/quiz-exercise/quiz-exercise-detail.component.spec.ts index e3edec7242bf..3767741a9df9 100644 --- a/src/test/javascript/spec/component/quiz-exercise/quiz-exercise-detail.component.spec.ts +++ b/src/test/javascript/spec/component/quiz-exercise/quiz-exercise-detail.component.spec.ts @@ -1,24 +1,30 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { HttpResponse } from '@angular/common/http'; import { ActivatedRoute, convertToParamMap } from '@angular/router'; +import { of } from 'rxjs'; import { ArtemisTestModule } from '../../test.module'; import { QuizExerciseDetailComponent } from 'app/exercises/quiz/manage/quiz-exercise-detail.component'; import { QuizExercise } from 'app/entities/quiz/quiz-exercise.model'; -import { CourseExerciseService } from 'app/course/manage/course-management.service'; +import { CourseManagementService } from 'app/course/manage/course-management.service'; import { Course } from 'app/entities/course.model'; import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { MockTranslateService } from '../../helpers/mocks/service/mock-translate.service'; import { TranslateService } from '@ngx-translate/core'; +import { QuizExerciseService } from 'app/exercises/quiz/manage/quiz-exercise.service'; describe('QuizExercise Management Detail Component', () => { - let service: CourseExerciseService; let comp: QuizExerciseDetailComponent; + let courseManagementService: CourseManagementService; + let quizExerciseService: QuizExerciseService; let fixture: ComponentFixture; + const course: Course = { id: 123 } as Course; const quizExercise = new QuizExercise(course); quizExercise.id = 456; - const route = ({ snapshot: { paramMap: convertToParamMap({ courseId: course.id }) } } as any) as ActivatedRoute; + + const route = ({ snapshot: { paramMap: convertToParamMap({ courseId: course.id, exerciseId: quizExercise.id }) } } as any) as ActivatedRoute; beforeEach(() => { TestBed.configureTestingModule({ @@ -35,18 +41,35 @@ describe('QuizExercise Management Detail Component', () => { .compileComponents(); fixture = TestBed.createComponent(QuizExerciseDetailComponent); comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(CourseExerciseService); + courseManagementService = fixture.debugElement.injector.get(CourseManagementService); + quizExerciseService = fixture.debugElement.injector.get(QuizExerciseService); }); describe('OnInit', () => { - it('Should call loadExercises on init', () => { + it('Should call courseExerciseService.find and quizExerciseService.find', () => { // GIVEN + spyOn(courseManagementService, 'find').and.returnValue( + of( + new HttpResponse({ + body: course, + }), + ), + ); + spyOn(quizExerciseService, 'find').and.returnValue( + of( + new HttpResponse({ + body: quizExercise, + }), + ), + ); // WHEN comp.course = course; comp.ngOnInit(); // THEN + expect(courseManagementService.find).toHaveBeenCalled(); + expect(quizExerciseService.find).toHaveBeenCalled(); }); }); }); From 8084ab1df5895c6f5df84ccd3ff9f225105302ef Mon Sep 17 00:00:00 2001 From: F4lka Date: Sun, 26 Apr 2020 21:05:06 +0200 Subject: [PATCH 124/152] fixed text-exercise-detail.component.spec.ts --- .../text-exercise-detail.component.spec.ts | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/test/javascript/spec/component/text-exercise/text-exercise-detail.component.spec.ts b/src/test/javascript/spec/component/text-exercise/text-exercise-detail.component.spec.ts index 944e3b98c053..cc8aa76e3cdc 100644 --- a/src/test/javascript/spec/component/text-exercise/text-exercise-detail.component.spec.ts +++ b/src/test/javascript/spec/component/text-exercise/text-exercise-detail.component.spec.ts @@ -1,15 +1,18 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ActivatedRoute } from '@angular/router'; import { of } from 'rxjs'; - +import { HttpHeaders, HttpResponse } from '@angular/common/http'; import { ArtemisTestModule } from '../../test.module'; import { TextExerciseDetailComponent } from 'app/exercises/text/manage/text-exercise/text-exercise-detail.component'; -import { TextExercise } from 'app/entities/text-exercise.model'; +import { Course } from 'app/entities/course.model'; +import { TextExerciseService } from 'app/exercises/text/manage/text-exercise/text-exercise.service'; describe('TextExercise Management Detail Component', () => { let comp: TextExerciseDetailComponent; let fixture: ComponentFixture; - const route = ({ data: of({ textExercise: new TextExercise(123) }) } as any) as ActivatedRoute; + let service: TextExerciseService; + const course: Course = { id: 123 } as Course; + const route = ({ params: of({ courseId: course.id }) } as any) as ActivatedRoute; beforeEach(() => { TestBed.configureTestingModule({ @@ -21,17 +24,28 @@ describe('TextExercise Management Detail Component', () => { .compileComponents(); fixture = TestBed.createComponent(TextExerciseDetailComponent); comp = fixture.componentInstance; + service = fixture.debugElement.injector.get(TextExerciseService); }); describe('OnInit', () => { it('Should call load all on init', () => { // GIVEN - + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(service, 'find').and.returnValue( + of( + new HttpResponse({ + body: course, + headers, + }), + ), + ); // WHEN + fixture.detectChanges(); comp.ngOnInit(); // THEN - expect(comp.textExercise).toEqual(jasmine.objectContaining({ id: 123 })); + expect(service.find).toHaveBeenCalled(); + expect(comp.textExercise).toEqual(jasmine.objectContaining({ id: course.id })); }); }); }); From 179f26c193644db8e2157a47702e7b36900b294a Mon Sep 17 00:00:00 2001 From: F4lka Date: Sun, 26 Apr 2020 21:30:03 +0200 Subject: [PATCH 125/152] fixed text-exercise.service.spec.ts --- .../spec/service/text-exercise.service.spec.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/test/javascript/spec/service/text-exercise.service.spec.ts b/src/test/javascript/spec/service/text-exercise.service.spec.ts index d994f571de4b..aa6230dd3ed7 100644 --- a/src/test/javascript/spec/service/text-exercise.service.spec.ts +++ b/src/test/javascript/spec/service/text-exercise.service.spec.ts @@ -4,6 +4,12 @@ import { map, take } from 'rxjs/operators'; import { TextExerciseService } from 'app/exercises/text/manage/text-exercise/text-exercise.service'; import { TextExercise } from 'app/entities/text-exercise.model'; import { Course } from 'app/entities/course.model'; +import { MockTranslateService } from '../helpers/mocks/service/mock-translate.service'; +import { TranslateService } from '@ngx-translate/core'; +import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; +import { Router } from '@angular/router'; +import { MockSyncStorage } from '../helpers/mocks/service/mock-sync-storage.service'; +import { MockRouter } from '../helpers/mocks/mock-router'; describe('TextExercise Service', () => { let injector: TestBed; @@ -13,6 +19,12 @@ describe('TextExercise Service', () => { beforeEach(() => { TestBed.configureTestingModule({ imports: [HttpClientTestingModule], + providers: [ + { provide: TranslateService, useClass: MockTranslateService }, + { provide: SessionStorageService, useClass: MockSyncStorage }, + { provide: Router, useClass: MockRouter }, + { provide: LocalStorageService, useClass: MockSyncStorage }, + ], }); injector = getTestBed(); service = injector.get(TextExerciseService); @@ -21,7 +33,7 @@ describe('TextExercise Service', () => { elemDefault = new TextExercise(new Course()); }); - describe('Service methods', async () => { + describe('Service methods', () => { it('should find an element', async () => { const returnedFromService = Object.assign({}, elemDefault); service From 97712827e9a6311cc93b436a977a5505dc69f176 Mon Sep 17 00:00:00 2001 From: Filip Gregurevic Date: Sun, 26 Apr 2020 23:02:24 +0200 Subject: [PATCH 126/152] delete outdated test cases: modeling-submission.service.spec.ts, modeling-exercise.service.spec.ts --- .../service/modeling-exercise.service.spec.ts | 24 +-------------- .../modeling-submission.service.spec.ts | 29 ------------------- 2 files changed, 1 insertion(+), 52 deletions(-) diff --git a/src/test/javascript/spec/service/modeling-exercise.service.spec.ts b/src/test/javascript/spec/service/modeling-exercise.service.spec.ts index adc47e81432b..c90b30e72bc8 100644 --- a/src/test/javascript/spec/service/modeling-exercise.service.spec.ts +++ b/src/test/javascript/spec/service/modeling-exercise.service.spec.ts @@ -41,7 +41,7 @@ describe('ModelingExercise Service', () => { ); const expected = Object.assign({}, returnedFromService); service - .create(new ModelingExercise(null)) + .create(new ModelingExercise(DiagramType.ComponentDiagram)) .pipe(take(1)) .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); const req = httpMock.expectOne({ method: 'POST' }); @@ -67,28 +67,6 @@ describe('ModelingExercise Service', () => { req.flush(JSON.stringify(returnedFromService)); }); - it('should return a list of ModelingExercise', async () => { - const returnedFromService = Object.assign( - { - diagramType: 'BBBBBB', - sampleSolutionModel: 'BBBBBB', - sampleSolutionExplanation: 'BBBBBB', - }, - elemDefault, - ); - const expected = Object.assign({}, returnedFromService); - service - .query(expected) - .pipe( - take(1), - map((resp) => resp.body), - ) - .subscribe((body) => expect(body).toContainEqual(expected)); - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify([returnedFromService])); - httpMock.verify(); - }); - it('should delete a ModelingExercise', async () => { service.delete(123).subscribe((resp) => expect(resp.ok)); diff --git a/src/test/javascript/spec/service/modeling-submission.service.spec.ts b/src/test/javascript/spec/service/modeling-submission.service.spec.ts index 8e56ccac6a3c..82946341bb46 100644 --- a/src/test/javascript/spec/service/modeling-submission.service.spec.ts +++ b/src/test/javascript/spec/service/modeling-submission.service.spec.ts @@ -66,35 +66,6 @@ describe('ModelingSubmission Service', () => { req.flush(JSON.stringify(returnedFromService)); }); - it('should return a list of ModelingSubmission', async () => { - const returnedFromService = Object.assign( - { - model: 'BBBBBB', - explanationText: 'BBBBBB', - }, - elemDefault, - ); - const expected = Object.assign({}, returnedFromService); - service - .query(expected) - .pipe( - take(1), - map((resp) => resp.body), - ) - .subscribe((body) => expect(body).toContainEqual(expected)); - const req = httpMock.expectOne({ method: 'GET' }); - req.flush(JSON.stringify([returnedFromService])); - httpMock.verify(); - }); - - it('should delete a ModelingSubmission', async () => { - service.delete(123).subscribe((resp) => expect(resp.ok)); - - const req = httpMock.expectOne({ method: 'DELETE' }); - req.flush({ status: 200 }); - }); - }); - afterEach(() => { httpMock.verify(); }); From 90ecef7f9b26a19b3fdc7107d97c70e03f42d2e9 Mon Sep 17 00:00:00 2001 From: Filip Gregurevic Date: Sun, 26 Apr 2020 23:33:34 +0200 Subject: [PATCH 127/152] fit new service methods --- .../spec/service/modeling-exercise.service.spec.ts | 2 +- .../spec/service/modeling-submission.service.spec.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/javascript/spec/service/modeling-exercise.service.spec.ts b/src/test/javascript/spec/service/modeling-exercise.service.spec.ts index c90b30e72bc8..86adc52da9ce 100644 --- a/src/test/javascript/spec/service/modeling-exercise.service.spec.ts +++ b/src/test/javascript/spec/service/modeling-exercise.service.spec.ts @@ -1,6 +1,6 @@ import { getTestBed, TestBed } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; -import { map, take } from 'rxjs/operators'; +import { take } from 'rxjs/operators'; import { ModelingExerciseService } from 'app/exercises/modeling/manage/modeling-exercise.service'; import { DiagramType, ModelingExercise } from 'app/entities/modeling-exercise.model'; diff --git a/src/test/javascript/spec/service/modeling-submission.service.spec.ts b/src/test/javascript/spec/service/modeling-submission.service.spec.ts index 82946341bb46..163fd4bc9c7e 100644 --- a/src/test/javascript/spec/service/modeling-submission.service.spec.ts +++ b/src/test/javascript/spec/service/modeling-submission.service.spec.ts @@ -1,6 +1,6 @@ import { getTestBed, TestBed } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; -import { map, take } from 'rxjs/operators'; +import { take } from 'rxjs/operators'; import { ModelingSubmissionService } from 'app/exercises/modeling/participate/modeling-submission.service'; import { ModelingSubmission } from 'app/entities/modeling-submission.model'; @@ -24,7 +24,7 @@ describe('ModelingSubmission Service', () => { it('should find an element', async () => { const returnedFromService = Object.assign({}, elemDefault); service - .find(123) + .getSubmission(123) .pipe(take(1)) .subscribe((resp) => expect(resp).toMatchObject({ body: elemDefault })); @@ -41,7 +41,7 @@ describe('ModelingSubmission Service', () => { ); const expected = Object.assign({}, returnedFromService); service - .create(new ModelingSubmission(null)) + .create(new ModelingSubmission(), 1) .pipe(take(1)) .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); const req = httpMock.expectOne({ method: 'POST' }); @@ -59,7 +59,7 @@ describe('ModelingSubmission Service', () => { const expected = Object.assign({}, returnedFromService); service - .update(expected) + .update(expected, 1) .pipe(take(1)) .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); const req = httpMock.expectOne({ method: 'PUT' }); From d38b5e7c42838636b06f55b9a90292fafeb35261 Mon Sep 17 00:00:00 2001 From: Hanya Elhashemy Date: Mon, 27 Apr 2020 00:12:03 +0200 Subject: [PATCH 128/152] fix participation.service.spec.ts find() test and delete redundant create() test --- .../participation/participation.service.ts | 33 +++++++++++-------- .../service/participation.service.spec.ts | 22 ------------- 2 files changed, 19 insertions(+), 36 deletions(-) diff --git a/src/main/webapp/app/exercises/shared/participation/participation.service.ts b/src/main/webapp/app/exercises/shared/participation/participation.service.ts index a9a2ea5558a6..92fbd022e79b 100644 --- a/src/main/webapp/app/exercises/shared/participation/participation.service.ts +++ b/src/main/webapp/app/exercises/shared/participation/participation.service.ts @@ -2,6 +2,7 @@ import { Injectable } from '@angular/core'; import { HttpClient, HttpResponse } from '@angular/common/http'; import { Observable } from 'rxjs/Observable'; import { SERVER_API_URL } from 'app/app.constants'; +import { map } from 'rxjs/operators'; import * as moment from 'moment'; import { createRequestOption } from 'app/shared/util/request-util'; @@ -25,19 +26,19 @@ export class ParticipationService { const copy = this.convertDateFromClient(participation); return this.http .put(this.resourceUrl, copy, { observe: 'response' }) - .map((res: EntityResponseType) => this.convertDateFromServer(res)); + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); } find(participationId: number): Observable { return this.http .get(`${this.resourceUrl}/${participationId}`, { observe: 'response' }) - .map((res: EntityResponseType) => this.convertDateFromServer(res)); + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); } findWithLatestResult(participationId: number): Observable { return this.http .get(`${this.resourceUrl}/${participationId}/withLatestResult`, { observe: 'response' }) - .map((res: EntityResponseType) => this.convertDateFromServer(res)); + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); } /* @@ -46,12 +47,14 @@ export class ParticipationService { findParticipation(exerciseId: number): Observable { return this.http .get(SERVER_API_URL + `api/exercises/${exerciseId}/participation`, { observe: 'response' }) - .map((res: EntityResponseType) => { - if (typeof res === 'undefined' || res === null) { - return null; - } - return this.convertDateFromServer(res); - }); + .pipe( + map((res: EntityResponseType) => { + if (typeof res === 'undefined' || res === null) { + return null; + } + return this.convertDateFromServer(res); + }), + ); } findAllParticipationsByExercise(exerciseId: number, withLatestResult = false): Observable { @@ -61,7 +64,7 @@ export class ParticipationService { params: options, observe: 'response', }) - .map((res: EntityArrayResponseType) => this.convertDateArrayFromServer(res)); + .pipe(map((res: EntityArrayResponseType) => this.convertDateArrayFromServer(res))); } delete(participationId: number, req?: any): Observable> { @@ -78,13 +81,15 @@ export class ParticipationService { const copy = this.convertDateFromClient(participation); return this.http .put(`${this.resourceUrl}/${participation.id}/cleanupBuildPlan`, copy, { observe: 'response' }) - .map((res: EntityResponseType) => this.convertDateFromServer(res)); + .pipe(map((res: EntityResponseType) => this.convertDateFromServer(res))); } downloadArtifact(participationId: number) { - return this.http.get(`${this.resourceUrl}/${participationId}/buildArtifact`, { responseType: 'blob' }).map((artifact) => { - return artifact; - }); + return this.http.get(`${this.resourceUrl}/${participationId}/buildArtifact`, { responseType: 'blob' }).pipe( + map((artifact) => { + return artifact; + }), + ); } protected convertDateFromClient(participation: StudentParticipation): StudentParticipation { diff --git a/src/test/javascript/spec/service/participation.service.spec.ts b/src/test/javascript/spec/service/participation.service.spec.ts index 9083084aa86a..60b3ac57d145 100644 --- a/src/test/javascript/spec/service/participation.service.spec.ts +++ b/src/test/javascript/spec/service/participation.service.spec.ts @@ -42,28 +42,6 @@ describe('Participation Service', () => { req.flush(JSON.stringify(returnedFromService)); }); - it('should create a Participation', async () => { - const returnedFromService = Object.assign( - { - id: 0, - initializationDate: currentDate.format(DATE_TIME_FORMAT), - }, - elemDefault, - ); - const expected = Object.assign( - { - initializationDate: currentDate, - }, - returnedFromService, - ); - service - .create(new Participation(null)) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); - const req = httpMock.expectOne({ method: 'POST' }); - req.flush(JSON.stringify(returnedFromService)); - }); - it('should update a Participation', async () => { const returnedFromService = Object.assign( { From 6963bcfdc293d3facd837d35c8f0a055410f5972 Mon Sep 17 00:00:00 2001 From: Filip Gregurevic Date: Mon, 27 Apr 2020 00:34:17 +0200 Subject: [PATCH 129/152] fix assigned test suites --- .../modeling/manage/modeling-exercise.route.ts | 2 +- .../participate/modeling-submission.service.ts | 7 ++++--- .../service/modeling-exercise.service.spec.ts | 15 ++++++++++++++- .../service/modeling-submission.service.spec.ts | 2 ++ 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/main/webapp/app/exercises/modeling/manage/modeling-exercise.route.ts b/src/main/webapp/app/exercises/modeling/manage/modeling-exercise.route.ts index 2616f160e1c1..259fb97906ac 100644 --- a/src/main/webapp/app/exercises/modeling/manage/modeling-exercise.route.ts +++ b/src/main/webapp/app/exercises/modeling/manage/modeling-exercise.route.ts @@ -31,7 +31,7 @@ export class ModelingExerciseResolver implements Resolve { } } -const routes: Routes = [ +export const routes: Routes = [ { path: ':courseId/modeling-exercises/new', component: ModelingExerciseUpdateComponent, diff --git a/src/main/webapp/app/exercises/modeling/participate/modeling-submission.service.ts b/src/main/webapp/app/exercises/modeling/participate/modeling-submission.service.ts index b12f05c42418..9206be6a6fef 100644 --- a/src/main/webapp/app/exercises/modeling/participate/modeling-submission.service.ts +++ b/src/main/webapp/app/exercises/modeling/participate/modeling-submission.service.ts @@ -2,6 +2,7 @@ import { Injectable } from '@angular/core'; import { HttpClient, HttpResponse } from '@angular/common/http'; import { Observable } from 'rxjs/Observable'; import { SERVER_API_URL } from 'app/app.constants'; +import { map } from 'rxjs/operators'; import { ModelingSubmission } from 'app/entities/modeling-submission.model'; import { createRequestOption } from 'app/shared/util/request-util'; @@ -21,7 +22,7 @@ export class ModelingSubmissionService { .post(`api/exercises/${exerciseId}/modeling-submissions`, copy, { observe: 'response', }) - .map((res: EntityResponseType) => this.convertResponse(res)); + .pipe(map((res: EntityResponseType) => this.convertResponse(res))); } update(modelingSubmission: ModelingSubmission, exerciseId: number): Observable { @@ -31,7 +32,7 @@ export class ModelingSubmissionService { headers: { 'Content-Type': 'application/json' }, observe: 'response', }) - .map((res: EntityResponseType) => this.convertResponse(res)); + .pipe(map((res: EntityResponseType) => this.convertResponse(res))); } getModelingSubmissionsForExercise(exerciseId: number, req?: any): Observable> { @@ -41,7 +42,7 @@ export class ModelingSubmissionService { params: options, observe: 'response', }) - .map((res: HttpResponse) => this.convertArrayResponse(res)); + .pipe(map((res: HttpResponse) => this.convertArrayResponse(res))); } getModelingSubmissionForExerciseWithoutAssessment(exerciseId: number, lock?: boolean): Observable { diff --git a/src/test/javascript/spec/service/modeling-exercise.service.spec.ts b/src/test/javascript/spec/service/modeling-exercise.service.spec.ts index 86adc52da9ce..bcd2bfcca430 100644 --- a/src/test/javascript/spec/service/modeling-exercise.service.spec.ts +++ b/src/test/javascript/spec/service/modeling-exercise.service.spec.ts @@ -3,15 +3,28 @@ import { HttpClientTestingModule, HttpTestingController } from '@angular/common/ import { take } from 'rxjs/operators'; import { ModelingExerciseService } from 'app/exercises/modeling/manage/modeling-exercise.service'; import { DiagramType, ModelingExercise } from 'app/entities/modeling-exercise.model'; +import { TranslateService } from '@ngx-translate/core'; +import { MockTranslateService } from '../helpers/mocks/service/mock-translate.service'; +import { MockSyncStorage } from '../helpers/mocks/service/mock-sync-storage.service'; +import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; +import { routes } from 'app/exercises/modeling/manage/modeling-exercise.route'; +import { RouterTestingModule } from '@angular/router/testing'; +import { ArtemisModelingExerciseModule } from 'app/exercises/modeling/manage/modeling-exercise.module'; describe('ModelingExercise Service', () => { let injector: TestBed; let service: ModelingExerciseService; let httpMock: HttpTestingController; let elemDefault: ModelingExercise; + beforeEach(() => { TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], + imports: [ArtemisModelingExerciseModule, HttpClientTestingModule, RouterTestingModule.withRoutes(routes)], + providers: [ + { provide: TranslateService, useClass: MockTranslateService }, + { provide: SessionStorageService, useClass: MockSyncStorage }, + { provide: LocalStorageService, useClass: MockSyncStorage }, + ], }); injector = getTestBed(); service = injector.get(ModelingExerciseService); diff --git a/src/test/javascript/spec/service/modeling-submission.service.spec.ts b/src/test/javascript/spec/service/modeling-submission.service.spec.ts index 163fd4bc9c7e..40ca7261a34d 100644 --- a/src/test/javascript/spec/service/modeling-submission.service.spec.ts +++ b/src/test/javascript/spec/service/modeling-submission.service.spec.ts @@ -9,6 +9,7 @@ describe('ModelingSubmission Service', () => { let service: ModelingSubmissionService; let httpMock: HttpTestingController; let elemDefault: ModelingSubmission; + beforeEach(() => { TestBed.configureTestingModule({ imports: [HttpClientTestingModule], @@ -65,6 +66,7 @@ describe('ModelingSubmission Service', () => { const req = httpMock.expectOne({ method: 'PUT' }); req.flush(JSON.stringify(returnedFromService)); }); + }); afterEach(() => { httpMock.verify(); From 87404c54826a1bb21999619c6e719088864c4314 Mon Sep 17 00:00:00 2001 From: Hanya Elhashemy Date: Mon, 27 Apr 2020 00:40:02 +0200 Subject: [PATCH 130/152] fix participation list for exercise test case in participation.service.spec.ts --- src/test/javascript/spec/service/participation.service.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/javascript/spec/service/participation.service.spec.ts b/src/test/javascript/spec/service/participation.service.spec.ts index 60b3ac57d145..207048dbef3b 100644 --- a/src/test/javascript/spec/service/participation.service.spec.ts +++ b/src/test/javascript/spec/service/participation.service.spec.ts @@ -86,7 +86,7 @@ describe('Participation Service', () => { returnedFromService, ); service - .query(expected) + .findAllParticipationsByExercise(expected) .pipe( take(1), map((resp) => resp.body), From 66e73d5026c00c830d4aa6b84941c849bf7a0740 Mon Sep 17 00:00:00 2001 From: Sebastian Jagla Date: Mon, 27 Apr 2020 11:56:46 +0200 Subject: [PATCH 131/152] Fix test case in text-exercise.component.spec.ts --- .../text-exercise.component.spec.ts | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/test/javascript/spec/component/text-exercise/text-exercise.component.spec.ts b/src/test/javascript/spec/component/text-exercise/text-exercise.component.spec.ts index 44f5af5dc1da..58836841e900 100644 --- a/src/test/javascript/spec/component/text-exercise/text-exercise.component.spec.ts +++ b/src/test/javascript/spec/component/text-exercise/text-exercise.component.spec.ts @@ -1,48 +1,63 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { of } from 'rxjs'; import { HttpHeaders, HttpResponse } from '@angular/common/http'; +import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; +import { TranslateService } from '@ngx-translate/core'; +import { ActivatedRoute, convertToParamMap } from '@angular/router'; import { ArtemisTestModule } from '../../test.module'; import { TextExerciseComponent } from 'app/exercises/text/manage/text-exercise/text-exercise.component'; -import { TextExerciseService } from 'app/exercises/text/manage/text-exercise/text-exercise.service'; import { TextExercise } from 'app/entities/text-exercise.model'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; +import { MockTranslateService } from '../../helpers/mocks/service/mock-translate.service'; +import { CourseExerciseService } from 'app/course/manage/course-management.service'; +import { Course } from 'app/entities/course.model'; describe('TextExercise Management Component', () => { let comp: TextExerciseComponent; let fixture: ComponentFixture; - let service: TextExerciseService; + let courseExerciseService: CourseExerciseService; + + const course = { id: 123 } as Course; + const textExercise: TextExercise = { id: 456 } as TextExercise; + const route = ({ snapshot: { paramMap: convertToParamMap({ courseId: course.id }) } } as any) as ActivatedRoute; beforeEach(() => { TestBed.configureTestingModule({ imports: [ArtemisTestModule], declarations: [TextExerciseComponent], - providers: [], + providers: [ + { provide: ActivatedRoute, useValue: route }, + { provide: LocalStorageService, useClass: MockSyncStorage }, + { provide: SessionStorageService, useClass: MockSyncStorage }, + { provide: TranslateService, useClass: MockTranslateService }, + ], }) .overrideTemplate(TextExerciseComponent, '') .compileComponents(); fixture = TestBed.createComponent(TextExerciseComponent); comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(TextExerciseService); + courseExerciseService = fixture.debugElement.injector.get(CourseExerciseService); }); - it('Should call load all on init', () => { + it('Should call loadExercises on init', () => { // GIVEN const headers = new HttpHeaders().append('link', 'link;link'); - spyOn(service, 'query').and.returnValue( + spyOn(courseExerciseService, 'findAllTextExercisesForCourse').and.returnValue( of( new HttpResponse({ - body: [new TextExercise(123)], + body: [textExercise], headers, }), ), ); // WHEN + comp.course = course; comp.ngOnInit(); // THEN - expect(service.query).toHaveBeenCalled(); - expect(comp.textExercises[0]).toEqual(jasmine.objectContaining({ id: 123 })); + expect(courseExerciseService.findAllTextExercisesForCourse).toHaveBeenCalled(); }); }); From 3cb9a2c8bc025cc2845ae637b4262fe26d978fae Mon Sep 17 00:00:00 2001 From: Can Arisan Date: Mon, 27 Apr 2020 14:06:14 +0300 Subject: [PATCH 132/152] Fix 4/5 of the tests in file-upload-exercise.service.spec.ts --- .../service/file-upload-exercise.service.spec.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/test/javascript/spec/service/file-upload-exercise.service.spec.ts b/src/test/javascript/spec/service/file-upload-exercise.service.spec.ts index 3590c82fb231..4e15dbda78f2 100644 --- a/src/test/javascript/spec/service/file-upload-exercise.service.spec.ts +++ b/src/test/javascript/spec/service/file-upload-exercise.service.spec.ts @@ -3,15 +3,27 @@ import { HttpClientTestingModule, HttpTestingController } from '@angular/common/ import { map, take } from 'rxjs/operators'; import { FileUploadExerciseService } from 'app/exercises/file-upload/manage/file-upload-exercise.service'; import { FileUploadExercise } from 'app/entities/file-upload-exercise.model'; +import { ArtemisTestModule } from '../test.module'; +import { MockSyncStorage } from '../helpers/mocks/service/mock-sync-storage.service'; +import { MockTranslateService } from '../helpers/mocks/service/mock-translate.service'; +import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; +import { TranslateService } from '@ngx-translate/core'; +import { Course } from 'app/entities/course.model'; describe('FileUploadExercise Service', () => { let injector: TestBed; let service: FileUploadExerciseService; let httpMock: HttpTestingController; let elemDefault: FileUploadExercise; + beforeEach(() => { TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], + imports: [ArtemisTestModule, HttpClientTestingModule], + providers: [ + { provide: LocalStorageService, useClass: MockSyncStorage }, + { provide: SessionStorageService, useClass: MockSyncStorage }, + { provide: TranslateService, useClass: MockTranslateService }, + ], }); injector = getTestBed(); service = injector.get(FileUploadExerciseService); From 48b7e4219227be1737d68c85fdf74e528b7cf1bb Mon Sep 17 00:00:00 2001 From: Clemens Zuck Date: Mon, 27 Apr 2020 13:22:35 +0200 Subject: [PATCH 133/152] fix testcase in modeling-exercise-update.component.spec.ts --- .../modeling-exercise-update.component.spec.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/test/javascript/spec/component/modeling-exercise/modeling-exercise-update.component.spec.ts b/src/test/javascript/spec/component/modeling-exercise/modeling-exercise-update.component.spec.ts index fda468e73b2d..2c6ed15cba9a 100644 --- a/src/test/javascript/spec/component/modeling-exercise/modeling-exercise-update.component.spec.ts +++ b/src/test/javascript/spec/component/modeling-exercise/modeling-exercise-update.component.spec.ts @@ -5,7 +5,9 @@ import { of } from 'rxjs'; import { ArtemisTestModule } from '../../test.module'; import { ModelingExerciseUpdateComponent } from 'app/exercises/modeling/manage/modeling-exercise-update.component'; import { ModelingExerciseService } from 'app/exercises/modeling/manage/modeling-exercise.service'; -import { ModelingExercise } from 'app/entities/modeling-exercise.model'; +import { ModelingExercise, UMLDiagramType } from 'app/entities/modeling-exercise.model'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; +import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; describe('ModelingExercise Management Update Component', () => { let comp: ModelingExerciseUpdateComponent; @@ -16,6 +18,10 @@ describe('ModelingExercise Management Update Component', () => { TestBed.configureTestingModule({ imports: [ArtemisTestModule], declarations: [ModelingExerciseUpdateComponent], + providers: [ + { provide: LocalStorageService, useClass: MockSyncStorage }, + { provide: SessionStorageService, useClass: MockSyncStorage }, + ], }) .overrideTemplate(ModelingExerciseUpdateComponent, '') .compileComponents(); @@ -28,7 +34,8 @@ describe('ModelingExercise Management Update Component', () => { describe('save', () => { it('Should call update service on save for existing entity', fakeAsync(() => { // GIVEN - const entity = new ModelingExercise(123); + const entity = new ModelingExercise(UMLDiagramType.ActivityDiagram); + entity.id = 123; spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); comp.modelingExercise = entity; // WHEN @@ -36,13 +43,13 @@ describe('ModelingExercise Management Update Component', () => { tick(); // simulate async // THEN - expect(service.update).toHaveBeenCalledWith(entity); + expect(service.update).toHaveBeenCalledWith(entity, {}); expect(comp.isSaving).toEqual(false); })); it('Should call create service on save for new entity', fakeAsync(() => { // GIVEN - const entity = new ModelingExercise(); + const entity = new ModelingExercise(UMLDiagramType.ClassDiagram); spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); comp.modelingExercise = entity; // WHEN From 4052be4d0fd11164de299b242d3c7cb86aefbe49 Mon Sep 17 00:00:00 2001 From: Can Arisan Date: Mon, 27 Apr 2020 14:56:44 +0300 Subject: [PATCH 134/152] WIP file-upload-exercise.service.spec.ts --- .../spec/service/file-upload-exercise.service.spec.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/test/javascript/spec/service/file-upload-exercise.service.spec.ts b/src/test/javascript/spec/service/file-upload-exercise.service.spec.ts index 4e15dbda78f2..a94b29326832 100644 --- a/src/test/javascript/spec/service/file-upload-exercise.service.spec.ts +++ b/src/test/javascript/spec/service/file-upload-exercise.service.spec.ts @@ -1,6 +1,9 @@ import { getTestBed, TestBed } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { map, take } from 'rxjs/operators'; +import { ActivatedRoute, convertToParamMap } from '@angular/router'; +import { of } from 'rxjs'; + import { FileUploadExerciseService } from 'app/exercises/file-upload/manage/file-upload-exercise.service'; import { FileUploadExercise } from 'app/entities/file-upload-exercise.model'; import { ArtemisTestModule } from '../test.module'; @@ -9,6 +12,7 @@ import { MockTranslateService } from '../helpers/mocks/service/mock-translate.se import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { TranslateService } from '@ngx-translate/core'; import { Course } from 'app/entities/course.model'; +import { CourseExerciseService } from 'app/course/manage/course-management.service'; describe('FileUploadExercise Service', () => { let injector: TestBed; @@ -16,10 +20,17 @@ describe('FileUploadExercise Service', () => { let httpMock: HttpTestingController; let elemDefault: FileUploadExercise; + const course: Course = { id: 123 } as Course; + const fileUploadExercise = new FileUploadExercise(course); + fileUploadExercise.id = 456; + fileUploadExercise.filePattern = 'pdf'; + const route = ({ snapshot: { paramMap: convertToParamMap({ courseId: course.id }) } } as any) as ActivatedRoute; + beforeEach(() => { TestBed.configureTestingModule({ imports: [ArtemisTestModule, HttpClientTestingModule], providers: [ + { provide: ActivatedRoute, useValue: route }, { provide: LocalStorageService, useClass: MockSyncStorage }, { provide: SessionStorageService, useClass: MockSyncStorage }, { provide: TranslateService, useClass: MockTranslateService }, From dad89ae6fa455e1648f5952ce3bc0c3e2726a7e3 Mon Sep 17 00:00:00 2001 From: Can Arisan Date: Mon, 27 Apr 2020 15:02:03 +0300 Subject: [PATCH 135/152] Fix last test in file-upload-exercise.service.spec.ts --- .../spec/service/file-upload-exercise.service.spec.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/test/javascript/spec/service/file-upload-exercise.service.spec.ts b/src/test/javascript/spec/service/file-upload-exercise.service.spec.ts index a94b29326832..cc47c02ca93e 100644 --- a/src/test/javascript/spec/service/file-upload-exercise.service.spec.ts +++ b/src/test/javascript/spec/service/file-upload-exercise.service.spec.ts @@ -1,8 +1,6 @@ import { getTestBed, TestBed } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { map, take } from 'rxjs/operators'; -import { ActivatedRoute, convertToParamMap } from '@angular/router'; -import { of } from 'rxjs'; import { FileUploadExerciseService } from 'app/exercises/file-upload/manage/file-upload-exercise.service'; import { FileUploadExercise } from 'app/entities/file-upload-exercise.model'; @@ -12,7 +10,6 @@ import { MockTranslateService } from '../helpers/mocks/service/mock-translate.se import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { TranslateService } from '@ngx-translate/core'; import { Course } from 'app/entities/course.model'; -import { CourseExerciseService } from 'app/course/manage/course-management.service'; describe('FileUploadExercise Service', () => { let injector: TestBed; @@ -24,13 +21,11 @@ describe('FileUploadExercise Service', () => { const fileUploadExercise = new FileUploadExercise(course); fileUploadExercise.id = 456; fileUploadExercise.filePattern = 'pdf'; - const route = ({ snapshot: { paramMap: convertToParamMap({ courseId: course.id }) } } as any) as ActivatedRoute; beforeEach(() => { TestBed.configureTestingModule({ imports: [ArtemisTestModule, HttpClientTestingModule], providers: [ - { provide: ActivatedRoute, useValue: route }, { provide: LocalStorageService, useClass: MockSyncStorage }, { provide: SessionStorageService, useClass: MockSyncStorage }, { provide: TranslateService, useClass: MockTranslateService }, @@ -64,7 +59,7 @@ describe('FileUploadExercise Service', () => { ); const expected = Object.assign({}, returnedFromService); service - .create(new FileUploadExercise(null)) + .create(fileUploadExercise) .pipe(take(1)) .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); const req = httpMock.expectOne({ method: 'POST' }); From 559a8882fd98eb3549bbe63dc5598ab009caa95c Mon Sep 17 00:00:00 2001 From: Clemens Zuck Date: Mon, 27 Apr 2020 15:19:44 +0200 Subject: [PATCH 136/152] fix testcases in modeling-assessment-editor.component.spec.ts --- .../modeling-assessment-editor.component.spec.ts | 16 +++++++++------- .../mocks/service/mock-account.service.ts | 5 ++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/test/javascript/spec/component/modeling-assessment-editor/modeling-assessment-editor.component.spec.ts b/src/test/javascript/spec/component/modeling-assessment-editor/modeling-assessment-editor.component.spec.ts index 8eac57e0b97d..4523643f27ad 100644 --- a/src/test/javascript/spec/component/modeling-assessment-editor/modeling-assessment-editor.component.spec.ts +++ b/src/test/javascript/spec/component/modeling-assessment-editor/modeling-assessment-editor.component.spec.ts @@ -8,14 +8,13 @@ import { ActivatedRoute, convertToParamMap, ParamMap } from '@angular/router'; import { Mutable } from '../../helpers/mutable'; import { BehaviorSubject } from 'rxjs'; import { RouterTestingModule } from '@angular/router/testing'; -import { User } from 'app/core/user/user.model'; import { JhiLanguageHelper } from 'app/core/language/language.helper'; import { AccountService } from 'app/core/auth/account.service'; import { MockAccountService } from '../../helpers/mocks/service/mock-account.service'; import { AssessmentLayoutComponent } from 'app/assessment/assessment-layout/assessment-layout.component'; import { AssessmentHeaderComponent } from 'app/assessment/assessment-header/assessment-header.component'; import { Course } from 'app/entities/course.model'; -import { ModelingExercise } from 'app/entities/modeling-exercise.model'; +import { ModelingExercise, UMLDiagramType } from 'app/entities/modeling-exercise.model'; import { ModelingAssessmentEditorComponent } from 'app/exercises/modeling/assess/modeling-assessment-editor/modeling-assessment-editor.component'; import { ArtemisModelingAssessmentEditorModule } from 'app/exercises/modeling/assess/modeling-assessment-editor/modeling-assessment-editor.module'; @@ -36,8 +35,8 @@ describe('ModelingAssessmentEditorComponent', () => { fixture = TestBed.createComponent(ModelingAssessmentEditorComponent); component = fixture.componentInstance; mockAuth = (fixture.debugElement.injector.get(AccountService) as any) as MockAccountService; - mockAuth.hasAnyAuthorityDirectSpy.and.returnValue(false); - mockAuth.identitySpy.and.returnValue(Promise.resolve(new User())); + mockAuth.hasAnyAuthorityDirect([]); + mockAuth.identity(); fixture.detectChanges(); }); @@ -60,8 +59,10 @@ describe('ModelingAssessmentEditorComponent', () => { }); it('should propagate isAtLeastInstructor', () => { - component.modelingExercise = new ModelingExercise('ClassDiagram', new Course()); - mockAuth.isAtLeastInstructorInCourseSpy.and.returnValue(true); + let course = new Course(); + course.isAtLeastInstructor = true; + component.modelingExercise = new ModelingExercise(UMLDiagramType.ClassDiagram, course); + mockAuth.isAtLeastInstructorInCourse(course); component['checkPermissions'](); fixture.detectChanges(); expect(component.isAtLeastInstructor).toBeTruthy(); @@ -69,7 +70,8 @@ describe('ModelingAssessmentEditorComponent', () => { let assessmentLayoutComponent: AssessmentHeaderComponent = fixture.debugElement.query(By.directive(AssessmentLayoutComponent)).componentInstance; expect(assessmentLayoutComponent.isAtLeastInstructor).toBeTruthy(); - mockAuth.isAtLeastInstructorInCourseSpy.and.returnValue(false); + course.isAtLeastInstructor = false; + mockAuth.isAtLeastInstructorInCourse(course); component['checkPermissions'](); fixture.detectChanges(); expect(component.isAtLeastInstructor).toBeFalsy(); diff --git a/src/test/javascript/spec/helpers/mocks/service/mock-account.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-account.service.ts index d223431de1a4..47cc466932f1 100644 --- a/src/test/javascript/spec/helpers/mocks/service/mock-account.service.ts +++ b/src/test/javascript/spec/helpers/mocks/service/mock-account.service.ts @@ -2,14 +2,13 @@ import { of } from 'rxjs'; import { Course } from 'app/entities/course.model'; import { IAccountService } from 'app/core/auth/account.service'; import { User } from 'app/core/user/user.model'; -import { Account } from 'app/core/user/account.model'; export class MockAccountService implements IAccountService { identity = () => Promise.resolve({ id: 99 } as User); hasAnyAuthority = (authorities: any[]) => Promise.resolve(true); - hasAnyAuthorityDirect = (authorities: any[]) => true; + hasAnyAuthorityDirect = (authorities: any[]) => authorities.length != 0; getAuthenticationState = () => of({ id: 99 } as User); - isAtLeastInstructorInCourse = (course: Course) => true; + isAtLeastInstructorInCourse = (course: Course) => course.isAtLeastInstructor; authenticate = (identity: User | null) => {}; fetch = () => of({ body: { id: 99 } as User } as any); getImageUrl = () => 'blob'; From 3307308fc481322172e1bfdb6c0b167fd24123f7 Mon Sep 17 00:00:00 2001 From: Hanya Elhashemy Date: Mon, 27 Apr 2020 22:39:48 +0200 Subject: [PATCH 137/152] fix test in participation.service.ts --- .../exercises/shared/participation/participation.service.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/webapp/app/exercises/shared/participation/participation.service.ts b/src/main/webapp/app/exercises/shared/participation/participation.service.ts index 92fbd022e79b..a015c0bff179 100644 --- a/src/main/webapp/app/exercises/shared/participation/participation.service.ts +++ b/src/main/webapp/app/exercises/shared/participation/participation.service.ts @@ -94,7 +94,8 @@ export class ParticipationService { protected convertDateFromClient(participation: StudentParticipation): StudentParticipation { const copy: StudentParticipation = Object.assign({}, participation, { - initializationDate: participation.initializationDate != null && moment(participation.initializationDate).isValid() ? participation.initializationDate.toJSON() : null, + initializationDate: + participation.initializationDate != null && moment(participation.initializationDate).isValid() ? JSON.stringify(participation.initializationDate) : null, }); return copy; } From bc4668c667d85573386f5de579796d6a0c2dba88 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Tue, 28 Apr 2020 09:37:01 +0200 Subject: [PATCH 138/152] Fix remaining code style issues --- .../component/account/settings.component.spec.ts | 12 ------------ .../modeling-assessment-editor.component.spec.ts | 2 +- .../helpers/mocks/service/mock-account.service.ts | 2 +- .../spec/service/quiz-exercise.service.spec.ts | 2 +- .../spec/service/text-submission.service.spec.ts | 2 +- 5 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/test/javascript/spec/component/account/settings.component.spec.ts b/src/test/javascript/spec/component/account/settings.component.spec.ts index 3133cf736f8f..9a0ad8c9fd78 100644 --- a/src/test/javascript/spec/component/account/settings.component.spec.ts +++ b/src/test/javascript/spec/component/account/settings.component.spec.ts @@ -12,18 +12,6 @@ describe('SettingsComponent', () => { let comp: SettingsComponent; let fixture: ComponentFixture; let accountService: AccountService; - const accountValues: Account = { - firstName: 'John', - lastName: 'Doe', - activated: true, - email: 'john.doe@mail.com', - name: 'john', - langKey: 'en', - login: 'john', - authorities: [], - imageUrl: '', - guidedTourSettings: [], - }; beforeEach(async(() => { TestBed.configureTestingModule({ diff --git a/src/test/javascript/spec/component/modeling-assessment-editor/modeling-assessment-editor.component.spec.ts b/src/test/javascript/spec/component/modeling-assessment-editor/modeling-assessment-editor.component.spec.ts index 4523643f27ad..816e86c692ca 100644 --- a/src/test/javascript/spec/component/modeling-assessment-editor/modeling-assessment-editor.component.spec.ts +++ b/src/test/javascript/spec/component/modeling-assessment-editor/modeling-assessment-editor.component.spec.ts @@ -59,7 +59,7 @@ describe('ModelingAssessmentEditorComponent', () => { }); it('should propagate isAtLeastInstructor', () => { - let course = new Course(); + const course = new Course(); course.isAtLeastInstructor = true; component.modelingExercise = new ModelingExercise(UMLDiagramType.ClassDiagram, course); mockAuth.isAtLeastInstructorInCourse(course); diff --git a/src/test/javascript/spec/helpers/mocks/service/mock-account.service.ts b/src/test/javascript/spec/helpers/mocks/service/mock-account.service.ts index 47cc466932f1..5138553a6ee4 100644 --- a/src/test/javascript/spec/helpers/mocks/service/mock-account.service.ts +++ b/src/test/javascript/spec/helpers/mocks/service/mock-account.service.ts @@ -6,7 +6,7 @@ import { User } from 'app/core/user/user.model'; export class MockAccountService implements IAccountService { identity = () => Promise.resolve({ id: 99 } as User); hasAnyAuthority = (authorities: any[]) => Promise.resolve(true); - hasAnyAuthorityDirect = (authorities: any[]) => authorities.length != 0; + hasAnyAuthorityDirect = (authorities: any[]) => authorities.length !== 0; getAuthenticationState = () => of({ id: 99 } as User); isAtLeastInstructorInCourse = (course: Course) => course.isAtLeastInstructor; authenticate = (identity: User | null) => {}; diff --git a/src/test/javascript/spec/service/quiz-exercise.service.spec.ts b/src/test/javascript/spec/service/quiz-exercise.service.spec.ts index 2a88f9d9c922..8564269963dd 100644 --- a/src/test/javascript/spec/service/quiz-exercise.service.spec.ts +++ b/src/test/javascript/spec/service/quiz-exercise.service.spec.ts @@ -2,7 +2,7 @@ import { TranslateService } from '@ngx-translate/core'; import { getTestBed, TestBed } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; import { map, take } from 'rxjs/operators'; -import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; +import { SessionStorageService } from 'ngx-webstorage'; import { QuizExerciseService } from 'app/exercises/quiz/manage/quiz-exercise.service'; import { QuizExercise } from 'app/entities/quiz/quiz-exercise.model'; import { Course } from 'app/entities/course.model'; diff --git a/src/test/javascript/spec/service/text-submission.service.spec.ts b/src/test/javascript/spec/service/text-submission.service.spec.ts index df3b79bb2c58..dcdd5952ad5b 100644 --- a/src/test/javascript/spec/service/text-submission.service.spec.ts +++ b/src/test/javascript/spec/service/text-submission.service.spec.ts @@ -1,6 +1,6 @@ import { getTestBed, TestBed } from '@angular/core/testing'; import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; -import { map, take } from 'rxjs/operators'; +import { take } from 'rxjs/operators'; import { TextSubmissionService } from 'app/exercises/text/participate/text-submission.service'; import { TextSubmission } from 'app/entities/text-submission.model'; From 7484858dbb384c5356484ff2125f0f81c7a33623 Mon Sep 17 00:00:00 2001 From: Andi Turdiu Date: Tue, 28 Apr 2020 11:43:31 +0200 Subject: [PATCH 139/152] Import and provide missing LocalStorageService --- .../spec/component/course/course-update.component.spec.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/test/javascript/spec/component/course/course-update.component.spec.ts b/src/test/javascript/spec/component/course/course-update.component.spec.ts index 5dc34699547c..34c1b9cc343d 100644 --- a/src/test/javascript/spec/component/course/course-update.component.spec.ts +++ b/src/test/javascript/spec/component/course/course-update.component.spec.ts @@ -6,6 +6,8 @@ import { ArtemisTestModule } from '../../test.module'; import { CourseUpdateComponent } from 'app/course/manage/course-update.component'; import { CourseManagementService } from 'app/course/manage/course-management.service'; import { Course } from 'app/entities/course.model'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; +import { LocalStorageService } from 'ngx-webstorage'; describe('Course Management Update Component', () => { let comp: CourseUpdateComponent; @@ -15,6 +17,7 @@ describe('Course Management Update Component', () => { beforeEach(() => { TestBed.configureTestingModule({ imports: [ArtemisTestModule], + providers: [{ provide: LocalStorageService, useClass: MockSyncStorage }], declarations: [CourseUpdateComponent], }) .overrideTemplate(CourseUpdateComponent, '') From b937e0e64c961d2bed32726b3a8c2c6b8bd22300 Mon Sep 17 00:00:00 2001 From: Andi Turdiu Date: Tue, 28 Apr 2020 12:04:32 +0200 Subject: [PATCH 140/152] Add sessionStorage mock --- .../spec/component/course/course-update.component.spec.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/test/javascript/spec/component/course/course-update.component.spec.ts b/src/test/javascript/spec/component/course/course-update.component.spec.ts index 34c1b9cc343d..22895b46020f 100644 --- a/src/test/javascript/spec/component/course/course-update.component.spec.ts +++ b/src/test/javascript/spec/component/course/course-update.component.spec.ts @@ -8,6 +8,7 @@ import { CourseManagementService } from 'app/course/manage/course-management.ser import { Course } from 'app/entities/course.model'; import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; import { LocalStorageService } from 'ngx-webstorage'; +import { SessionStorageService } from 'ngx-webstorage'; describe('Course Management Update Component', () => { let comp: CourseUpdateComponent; @@ -17,7 +18,10 @@ describe('Course Management Update Component', () => { beforeEach(() => { TestBed.configureTestingModule({ imports: [ArtemisTestModule], - providers: [{ provide: LocalStorageService, useClass: MockSyncStorage }], + providers: [ + { provide: LocalStorageService, useClass: MockSyncStorage }, + { provide: SessionStorageService, useClass: MockSyncStorage }, + ], declarations: [CourseUpdateComponent], }) .overrideTemplate(CourseUpdateComponent, '') From edf5fb31a4b29e388cb9cecc789b45e4bafa49c1 Mon Sep 17 00:00:00 2001 From: Andi Turdiu Date: Tue, 28 Apr 2020 14:34:13 +0200 Subject: [PATCH 141/152] Fix Failing Tests on course-update.component.spec.ts --- .../course/course-update.component.spec.ts | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/test/javascript/spec/component/course/course-update.component.spec.ts b/src/test/javascript/spec/component/course/course-update.component.spec.ts index 22895b46020f..78ca40f20145 100644 --- a/src/test/javascript/spec/component/course/course-update.component.spec.ts +++ b/src/test/javascript/spec/component/course/course-update.component.spec.ts @@ -1,7 +1,7 @@ import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; import { HttpResponse } from '@angular/common/http'; import { of } from 'rxjs'; - +import { FormControl, FormGroup } from '@angular/forms'; import { ArtemisTestModule } from '../../test.module'; import { CourseUpdateComponent } from 'app/course/manage/course-update.component'; import { CourseManagementService } from 'app/course/manage/course-management.service'; @@ -39,7 +39,18 @@ describe('Course Management Update Component', () => { entity.id = 123; spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity }))); comp.course = entity; - comp.courseForm = { value: entity }; // mocking reactive form + comp.courseForm = new FormGroup({ + id: new FormControl(entity.id), + onlineCourse: new FormControl(entity.onlineCourse), + registrationEnabled: new FormControl(entity.registrationEnabled), + presentationScore: new FormControl(entity.presentationScore), + maxComplaints: new FormControl(entity.maxComplaints), + maxComplaintTimeDays: new FormControl(entity.maxComplaintTimeDays), + complaintsEnabled: new FormControl(entity.complaintsEnabled), + studentQuestionsEnabled: new FormControl(entity.studentQuestionsEnabled), + isAtLeastTutor: new FormControl(entity.isAtLeastTutor), + isAtLeastInstructor: new FormControl(entity.isAtLeastInstructor), + }); // WHEN comp.save(); tick(); // simulate async @@ -54,7 +65,17 @@ describe('Course Management Update Component', () => { const entity = new Course(); spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity }))); comp.course = entity; - comp.courseForm = { value: entity }; // mocking reactive form + comp.courseForm = new FormGroup({ + onlineCourse: new FormControl(entity.onlineCourse), + registrationEnabled: new FormControl(entity.registrationEnabled), + presentationScore: new FormControl(entity.presentationScore), + maxComplaints: new FormControl(entity.maxComplaints), + maxComplaintTimeDays: new FormControl(entity.maxComplaintTimeDays), + complaintsEnabled: new FormControl(entity.complaintsEnabled), + studentQuestionsEnabled: new FormControl(entity.studentQuestionsEnabled), + isAtLeastTutor: new FormControl(entity.isAtLeastTutor), + isAtLeastInstructor: new FormControl(entity.isAtLeastInstructor), + }); // mocking reactive form // WHEN comp.save(); tick(); // simulate async From 40f846e6d4a69c0769a332ba2258d0e1e2181ce6 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Thu, 30 Apr 2020 01:30:08 +0200 Subject: [PATCH 142/152] Fix test cases in course-exercise-row.component.spec.ts --- .../course-exercises/course-exercise-row.component.spec.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/javascript/spec/component/overview/course-exercises/course-exercise-row.component.spec.ts b/src/test/javascript/spec/component/overview/course-exercises/course-exercise-row.component.spec.ts index bc66fd772431..584797e020ed 100644 --- a/src/test/javascript/spec/component/overview/course-exercises/course-exercise-row.component.spec.ts +++ b/src/test/javascript/spec/component/overview/course-exercises/course-exercise-row.component.spec.ts @@ -29,6 +29,7 @@ import { QuizExercise } from 'app/entities/quiz/quiz-exercise.model'; import { CourseExerciseService, CourseManagementService } from 'app/course/manage/course-management.service'; import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; import { MockSyncStorage } from '../../../helpers/mocks/service/mock-sync-storage.service'; +import { Course } from 'app/entities/course.model'; chai.use(sinonChai); const expect = chai.expect; @@ -60,6 +61,7 @@ describe('CourseExerciseRowComponent', () => { .then(() => { fixture = TestBed.createComponent(CourseExerciseRowComponent); comp = fixture.componentInstance; + comp.course = { id: 123, isAtLeastInstructor: true } as Course; debugElement = fixture.debugElement; participationWebsocketService = debugElement.injector.get(ParticipationWebsocketService); getAllParticipationsStub = stub(participationWebsocketService, 'getParticipationForExercise'); From 54b2a05d23f2fc68b83cf05daba80e053cfcab26 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Thu, 30 Apr 2020 01:33:55 +0200 Subject: [PATCH 143/152] Fix test cases in text-submissions-assessment.component.spec.ts --- .../text-submission-assessment.component.spec.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/javascript/spec/component/text-submission-assessment/text-submission-assessment.component.spec.ts b/src/test/javascript/spec/component/text-submission-assessment/text-submission-assessment.component.spec.ts index 11abff2c4a54..453ea82807da 100644 --- a/src/test/javascript/spec/component/text-submission-assessment/text-submission-assessment.component.spec.ts +++ b/src/test/javascript/spec/component/text-submission-assessment/text-submission-assessment.component.spec.ts @@ -24,6 +24,7 @@ import moment = require('moment'); import { StudentParticipation } from 'app/entities/participation/student-participation.model'; import { ActivatedRoute } from '@angular/router'; import { ArtemisConfirmIconModule } from 'app/shared/confirm-icon/confirm-icon.module'; +import { Course } from 'app/entities/course.model'; describe('TextSubmissionAssessmentComponent', () => { let component: TextSubmissionAssessmentComponent; @@ -35,6 +36,7 @@ describe('TextSubmissionAssessmentComponent', () => { type: ExerciseType.TEXT, assessmentType: AssessmentType.MANUAL, problemStatement: '', + course: { id: 123, isAtLeastInstructor: true } as Course, } as TextExercise; const participation: StudentParticipation = ({ type: ParticipationType.STUDENT, From 01a11f1b849d0b56df223593bbb0292f2c0eb700 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Thu, 30 Apr 2020 01:50:43 +0200 Subject: [PATCH 144/152] Fix test case in modeling-exercise.component.spec.ts --- .../modeling-exercise.component.spec.ts | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/test/javascript/spec/component/modeling-exercise/modeling-exercise.component.spec.ts b/src/test/javascript/spec/component/modeling-exercise/modeling-exercise.component.spec.ts index d803437a8567..bb82356180e9 100644 --- a/src/test/javascript/spec/component/modeling-exercise/modeling-exercise.component.spec.ts +++ b/src/test/javascript/spec/component/modeling-exercise/modeling-exercise.component.spec.ts @@ -1,48 +1,65 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { of } from 'rxjs'; import { HttpHeaders, HttpResponse } from '@angular/common/http'; +import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; +import { ActivatedRoute, convertToParamMap } from '@angular/router'; +import { TranslateService } from '@ngx-translate/core'; import { ArtemisTestModule } from '../../test.module'; import { ModelingExerciseComponent } from 'app/exercises/modeling/manage/modeling-exercise.component'; -import { ModelingExerciseService } from 'app/exercises/modeling/manage/modeling-exercise.service'; -import { ModelingExercise } from 'app/entities/modeling-exercise.model'; +import { ModelingExercise, UMLDiagramType } from 'app/entities/modeling-exercise.model'; +import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; +import { MockTranslateService } from '../../helpers/mocks/service/mock-translate.service'; +import { CourseExerciseService } from 'app/course/manage/course-management.service'; +import { Course } from 'app/entities/course.model'; describe('ModelingExercise Management Component', () => { let comp: ModelingExerciseComponent; let fixture: ComponentFixture; - let service: ModelingExerciseService; + let courseExerciseService: CourseExerciseService; + + const course: Course = { id: 123 } as Course; + const modelingExercise = new ModelingExercise(UMLDiagramType.ClassDiagram, course); + modelingExercise.id = 456; + const route = ({ snapshot: { paramMap: convertToParamMap({ courseId: course.id }) } } as any) as ActivatedRoute; beforeEach(() => { TestBed.configureTestingModule({ imports: [ArtemisTestModule], declarations: [ModelingExerciseComponent], - providers: [], + providers: [ + { provide: ActivatedRoute, useValue: route }, + { provide: LocalStorageService, useClass: MockSyncStorage }, + { provide: SessionStorageService, useClass: MockSyncStorage }, + { provide: TranslateService, useClass: MockTranslateService }, + ], }) .overrideTemplate(ModelingExerciseComponent, '') .compileComponents(); fixture = TestBed.createComponent(ModelingExerciseComponent); comp = fixture.componentInstance; - service = fixture.debugElement.injector.get(ModelingExerciseService); + courseExerciseService = fixture.debugElement.injector.get(CourseExerciseService); }); - it('Should call load all on init', () => { + it('Should call loadExercises on init', () => { // GIVEN const headers = new HttpHeaders().append('link', 'link;link'); - spyOn(service, 'query').and.returnValue( + spyOn(courseExerciseService, 'findAllModelingExercisesForCourse').and.returnValue( of( new HttpResponse({ - body: [new ModelingExercise(123)], + body: [modelingExercise], headers, }), ), ); // WHEN + comp.course = course; comp.ngOnInit(); // THEN - expect(service.query).toHaveBeenCalled(); - expect(comp.modelingExercises[0]).toEqual(jasmine.objectContaining({ id: 123 })); + expect(courseExerciseService.findAllModelingExercisesForCourse).toHaveBeenCalled(); + expect(comp.modelingExercises[0]).toEqual(modelingExercise); }); }); From db8deebe5423b37204aa193e7f42cdd5c7045ae1 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Thu, 30 Apr 2020 02:01:53 +0200 Subject: [PATCH 145/152] Fix test case in modeling-exercise-detail.component.spec.ts --- ...modeling-exercise-detail.component.spec.ts | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/test/javascript/spec/component/modeling-exercise/modeling-exercise-detail.component.spec.ts b/src/test/javascript/spec/component/modeling-exercise/modeling-exercise-detail.component.spec.ts index 371088024a1b..1cb12853db43 100644 --- a/src/test/javascript/spec/component/modeling-exercise/modeling-exercise-detail.component.spec.ts +++ b/src/test/javascript/spec/component/modeling-exercise/modeling-exercise-detail.component.spec.ts @@ -1,15 +1,20 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { HttpHeaders, HttpResponse } from '@angular/common/http'; import { ActivatedRoute } from '@angular/router'; import { of } from 'rxjs'; import { ArtemisTestModule } from '../../test.module'; import { ModelingExerciseDetailComponent } from 'app/exercises/modeling/manage/modeling-exercise-detail.component'; import { ModelingExercise } from 'app/entities/modeling-exercise.model'; +import { ModelingExerciseService } from 'app/exercises/modeling/manage/modeling-exercise.service'; describe('ModelingExercise Management Detail Component', () => { let comp: ModelingExerciseDetailComponent; let fixture: ComponentFixture; - const route = ({ data: of({ modelingExercise: new ModelingExercise(123) }) } as any) as ActivatedRoute; + let modelingExerciseService: ModelingExerciseService; + + let modelingExercise = { id: 123 } as ModelingExercise; + const route = ({ params: of({ exerciseId: modelingExercise.id }) } as any) as ActivatedRoute; beforeEach(() => { TestBed.configureTestingModule({ @@ -21,17 +26,26 @@ describe('ModelingExercise Management Detail Component', () => { .compileComponents(); fixture = TestBed.createComponent(ModelingExerciseDetailComponent); comp = fixture.componentInstance; + modelingExerciseService = fixture.debugElement.injector.get(ModelingExerciseService); }); - describe('OnInit', () => { - it('Should call load all on init', () => { - // GIVEN + it('Should load exercise on init', () => { + // GIVEN + const headers = new HttpHeaders().append('link', 'link;link'); + spyOn(modelingExerciseService, 'find').and.returnValue( + of( + new HttpResponse({ + body: modelingExercise, + headers, + }), + ), + ); - // WHEN - comp.ngOnInit(); + // WHEN + comp.ngOnInit(); - // THEN - expect(comp.modelingExercise).toEqual(jasmine.objectContaining({ id: 123 })); - }); + // THEN + expect(modelingExerciseService.find).toHaveBeenCalled(); + expect(comp.modelingExercise).toEqual(modelingExercise); }); }); From 8fae4bd57207ac9e71d524ce144950831299773b Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Thu, 30 Apr 2020 13:12:50 +0200 Subject: [PATCH 146/152] Use newer rxjs pipe syntax in file-upload-submission.service.ts --- .../participate/file-upload-submission.service.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/webapp/app/exercises/file-upload/participate/file-upload-submission.service.ts b/src/main/webapp/app/exercises/file-upload/participate/file-upload-submission.service.ts index 578f5b64743a..a9d273f09dc6 100644 --- a/src/main/webapp/app/exercises/file-upload/participate/file-upload-submission.service.ts +++ b/src/main/webapp/app/exercises/file-upload/participate/file-upload-submission.service.ts @@ -1,8 +1,9 @@ import { Injectable } from '@angular/core'; import { HttpClient, HttpResponse } from '@angular/common/http'; import { Observable } from 'rxjs/Observable'; +import { map } from 'rxjs/operators'; -import { FileUploadSubmission } from '../../../entities/file-upload-submission.model'; +import { FileUploadSubmission } from 'app/entities/file-upload-submission.model'; import { createRequestOption } from 'app/shared/util/request-util'; import { stringifyCircular } from 'app/shared/util/utils'; @@ -28,7 +29,7 @@ export class FileUploadSubmissionService { .post(`api/exercises/${exerciseId}/file-upload-submissions`, formData, { observe: 'response', }) - .map((res: EntityResponseType) => this.convertResponse(res)); + .pipe(map((res: EntityResponseType) => this.convertResponse(res))); } /** @@ -40,7 +41,7 @@ export class FileUploadSubmissionService { .get(`api/file-upload-submissions/${fileUploadSubmissionId}`, { observe: 'response', }) - .map((res: HttpResponse) => this.convertResponse(res)); + .pipe(map((res: HttpResponse) => this.convertResponse(res))); } /** @@ -55,7 +56,7 @@ export class FileUploadSubmissionService { params: options, observe: 'response', }) - .map((res: HttpResponse) => this.convertArrayResponse(res)); + .pipe(map((res: HttpResponse) => this.convertArrayResponse(res))); } /** From df9c7310f8c84c1979b413618352f07daef3fb3a Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Thu, 30 Apr 2020 13:22:34 +0200 Subject: [PATCH 147/152] Fix test cases in file-upload-submission.service.spec.ts --- .../file-upload-submission.service.spec.ts | 35 ++++--------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/src/test/javascript/spec/service/file-upload-submission.service.spec.ts b/src/test/javascript/spec/service/file-upload-submission.service.spec.ts index 89315e34b065..6acd5b141ecc 100644 --- a/src/test/javascript/spec/service/file-upload-submission.service.spec.ts +++ b/src/test/javascript/spec/service/file-upload-submission.service.spec.ts @@ -9,6 +9,7 @@ describe('FileUploadSubmission Service', () => { let service: FileUploadSubmissionService; let httpMock: HttpTestingController; let elemDefault: FileUploadSubmission; + beforeEach(() => { TestBed.configureTestingModule({ imports: [HttpClientTestingModule], @@ -24,7 +25,7 @@ describe('FileUploadSubmission Service', () => { it('should find an element', async () => { const returnedFromService = Object.assign({}, elemDefault); service - .find(123) + .get(123) .pipe(take(1)) .subscribe((resp) => expect(resp).toMatchObject({ body: elemDefault })); @@ -32,7 +33,7 @@ describe('FileUploadSubmission Service', () => { req.flush(JSON.stringify(returnedFromService)); }); - it('should create a FileUploadSubmission', async () => { + it('should create/update a FileUploadSubmission', async () => { const returnedFromService = Object.assign( { id: 0, @@ -41,31 +42,14 @@ describe('FileUploadSubmission Service', () => { ); const expected = Object.assign({}, returnedFromService); service - .create(new FileUploadSubmission(null)) + .update(new FileUploadSubmission(), 1, null) .pipe(take(1)) .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); const req = httpMock.expectOne({ method: 'POST' }); req.flush(JSON.stringify(returnedFromService)); }); - it('should update a FileUploadSubmission', async () => { - const returnedFromService = Object.assign( - { - filePath: 'BBBBBB', - }, - elemDefault, - ); - - const expected = Object.assign({}, returnedFromService); - service - .update(expected) - .pipe(take(1)) - .subscribe((resp) => expect(resp).toMatchObject({ body: expected })); - const req = httpMock.expectOne({ method: 'PUT' }); - req.flush(JSON.stringify(returnedFromService)); - }); - - it('should return a list of FileUploadSubmission', async () => { + it('should return a list of FileUploadSubmission for an exercise', async () => { const returnedFromService = Object.assign( { filePath: 'BBBBBB', @@ -74,7 +58,7 @@ describe('FileUploadSubmission Service', () => { ); const expected = Object.assign({}, returnedFromService); service - .query(expected) + .getFileUploadSubmissionsForExercise(1, expected) .pipe( take(1), map((resp) => resp.body), @@ -84,13 +68,6 @@ describe('FileUploadSubmission Service', () => { req.flush(JSON.stringify([returnedFromService])); httpMock.verify(); }); - - it('should delete a FileUploadSubmission', async () => { - service.delete(123).subscribe((resp) => expect(resp.ok)); - - const req = httpMock.expectOne({ method: 'DELETE' }); - req.flush({ status: 200 }); - }); }); afterEach(() => { From 533390940bac508f251566a2b5ac666fd7a6d4aa Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Thu, 30 Apr 2020 13:32:40 +0200 Subject: [PATCH 148/152] Fix new code style issues --- .../modeling/participate/modeling-submission.component.ts | 1 - .../modeling-exercise-detail.component.spec.ts | 2 +- .../modeling-submission/modeling-submission.component.spec.ts | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/webapp/app/exercises/modeling/participate/modeling-submission.component.ts b/src/main/webapp/app/exercises/modeling/participate/modeling-submission.component.ts index 9d7b1b9e395a..938898acb8f9 100644 --- a/src/main/webapp/app/exercises/modeling/participate/modeling-submission.component.ts +++ b/src/main/webapp/app/exercises/modeling/participate/modeling-submission.component.ts @@ -28,7 +28,6 @@ import { ButtonType } from 'app/shared/components/button.component'; import { participationStatus } from 'app/exercises/shared/exercise/exercise-utils'; import { filter } from 'rxjs/operators'; import { stringifyIgnoringFields } from 'app/shared/util/utils'; -import { Location } from '@angular/common'; import { Subject } from 'rxjs'; @Component({ diff --git a/src/test/javascript/spec/component/modeling-exercise/modeling-exercise-detail.component.spec.ts b/src/test/javascript/spec/component/modeling-exercise/modeling-exercise-detail.component.spec.ts index 1cb12853db43..38b3bd08d34f 100644 --- a/src/test/javascript/spec/component/modeling-exercise/modeling-exercise-detail.component.spec.ts +++ b/src/test/javascript/spec/component/modeling-exercise/modeling-exercise-detail.component.spec.ts @@ -13,7 +13,7 @@ describe('ModelingExercise Management Detail Component', () => { let fixture: ComponentFixture; let modelingExerciseService: ModelingExerciseService; - let modelingExercise = { id: 123 } as ModelingExercise; + const modelingExercise = { id: 123 } as ModelingExercise; const route = ({ params: of({ exerciseId: modelingExercise.id }) } as any) as ActivatedRoute; beforeEach(() => { diff --git a/src/test/javascript/spec/component/modeling-submission/modeling-submission.component.spec.ts b/src/test/javascript/spec/component/modeling-submission/modeling-submission.component.spec.ts index 43cac23a056c..4b253c24de91 100644 --- a/src/test/javascript/spec/component/modeling-submission/modeling-submission.component.spec.ts +++ b/src/test/javascript/spec/component/modeling-submission/modeling-submission.component.spec.ts @@ -185,7 +185,7 @@ describe('Component Tests', () => { it('should navigate to access denied page on 403 error status', () => { sinon.replace(service, 'getLatestSubmissionForModelingEditor', sinon.fake.returns(throwError({ status: 403 }))); const spy = stub(router, 'navigate'); - spy.returns(new Promise((resolve) => true)); + spy.returns(new Promise(() => true)); fixture.detectChanges(); expect(spy.called).to.be.true; }); From 89b035f5a25ac7fd92128c755b7ac00245c37074 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Thu, 30 Apr 2020 15:49:12 +0200 Subject: [PATCH 149/152] Completely remove empty text-assessment.component.ts --- .../webapp/app/exercises/text/assess/text-assessment.component.ts | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/main/webapp/app/exercises/text/assess/text-assessment.component.ts diff --git a/src/main/webapp/app/exercises/text/assess/text-assessment.component.ts b/src/main/webapp/app/exercises/text/assess/text-assessment.component.ts deleted file mode 100644 index e69de29bb2d1..000000000000 From 012100df819f936b36d98674fc7c71d8c152868d Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Thu, 30 Apr 2020 18:39:34 +0200 Subject: [PATCH 150/152] Delete text-exercise-assessment.component.spec.ts as in commit ecc45b84a680621a7535d61353024452dbcad064 --- ...ext-exercise-assessement.component.spec.ts | 399 ------------------ 1 file changed, 399 deletions(-) delete mode 100644 src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.component.spec.ts diff --git a/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.component.spec.ts b/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.component.spec.ts deleted file mode 100644 index 5d80e3cdd6c8..000000000000 --- a/src/test/javascript/spec/component/text-exercise-assessment/text-exercise-assessement.component.spec.ts +++ /dev/null @@ -1,399 +0,0 @@ -import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing'; -import { RouterTestingModule } from '@angular/router/testing'; -import { JhiLanguageHelper } from 'app/core/language/language.helper'; -import { AccountService } from 'app/core/auth/account.service'; -import * as chai from 'chai'; -import * as sinonChai from 'sinon-chai'; -import * as moment from 'moment'; -import { SinonStub, stub } from 'sinon'; -import { ArtemisTestModule } from '../../test.module'; -import { MockSyncStorage } from '../../helpers/mocks/service/mock-sync-storage.service'; -import { Result } from 'app/entities/result.model'; -import { MockComponent } from 'ng-mocks'; -import { ArtemisSharedModule } from 'app/shared/shared.module'; -import { MockAlertService } from '../../helpers/mocks/service/mock-alert.service'; -import { AlertService } from 'app/core/alert/alert.service'; -import { ActivatedRoute, Router } from '@angular/router'; -import { of, throwError } from 'rxjs'; -import { TextAssessmentComponent } from 'app/exercises/text/assess/text-assessment.component'; -import { TextAssessmentEditorComponent } from 'app/exercises/text/assess/text-assessment-editor/text-assessment-editor.component'; -import { ResizableInstructionsComponent } from 'app/exercises/text/assess/resizable-instructions/resizable-instructions.component'; -import { AssessmentDetailComponent } from 'app/assessment/assessment-detail/assessment-detail.component'; -import { DebugElement } from '@angular/core'; -import { By } from '@angular/platform-browser'; -import { MockAccountService } from '../../helpers/mocks/service/mock-account.service'; -import { textAssessmentRoutes } from 'app/exercises/text/assess/text-assessment.route'; -import { LocalStorageService, SessionStorageService } from 'ngx-webstorage'; -import { ComplaintService } from 'app/complaints/complaint.service'; -import { MockComplaintResponse, MockComplaintService } from '../../helpers/mocks/service/mock-complaint.service'; -import { TranslateModule } from '@ngx-translate/core'; -import { TextSubmissionService } from 'app/exercises/text/participate/text-submission.service'; -import { ComplaintsForTutorComponent } from 'app/complaints/complaints-for-tutor/complaints-for-tutor.component'; -import { ResultComponent } from 'app/shared/result/result.component'; -import { Submission, SubmissionExerciseType, SubmissionType } from 'app/entities/submission.model'; -import { TextExercise } from 'app/entities/text-exercise.model'; -import { Exercise, ExerciseType } from 'app/entities/exercise.model'; -import { TextSubmission } from 'app/entities/text-submission.model'; -import { Participation, ParticipationType } from 'app/entities/participation/participation.model'; -import { AssessmentType } from 'app/entities/assessment-type.model'; -import { TextAssessmentsService } from 'app/exercises/text/assess/text-assessments.service'; -import { Course } from 'app/entities/course.model'; -import { Feedback } from 'app/entities/feedback.model'; -import { TextBlock } from 'app/entities/text-block.model'; -import { ComplaintResponse } from 'app/entities/complaint-response.model'; -import { AssessmentGeneralFeedbackComponent } from 'app/assessment/assessment-general-feedback/assessment-general-feedback.component'; - -chai.use(sinonChai); -const expect = chai.expect; - -describe('TextExerciseAssessmentComponent', () => { - let comp: TextAssessmentComponent; - let fixture: ComponentFixture; - let textSubmissionService: TextSubmissionService; - let assessmentsService: TextAssessmentsService; - let getTextSubmissionForExerciseWithoutAssessmentStub: SinonStub; - let getFeedbackDataForExerciseSubmissionStub: SinonStub; - let saveAssessmentStub: SinonStub; - let submitAssessmentStub: SinonStub; - let getResultWithPredefinedTextblocksStub: SinonStub; - let updateAssessmentAfterComplaintStub: SinonStub; - let debugElement: DebugElement; - let router: Router; - - const exercise = { id: 20, type: ExerciseType.TEXT, assessmentType: AssessmentType.MANUAL } as TextExercise; - const participation: Participation = ({ type: ParticipationType.STUDENT, exercise: Exercise }); - const result = ({ - id: 2374, - resultString: '1 of 12 points', - completionDate: moment('2019-07-09T11:51:23.251Z'), - successful: false, - score: 8, - rated: true, - hasFeedback: false, - hasComplaint: false, - submission: Submission, - participation: Participation, - } as unknown) as Result; - const submission = { - submissionExerciseType: SubmissionExerciseType.TEXT, - id: 2278, - submitted: true, - type: SubmissionType.MANUAL, - submissionDate: moment('2019-07-09T10:47:33.244Z'), - text: 'asdfasdfasdfasdf', - participation, - result, - exampleSubmission: false, - language: null, - } as TextSubmission; - submission.participation.submissions = [submission]; - submission.participation.results = [submission.result]; - const refFeedback = { reference: 'reference', credits: 5 } as Feedback; - const refFeedback2 = { reference: 'reference2', credits: 5 } as Feedback; - - const testBedConfiguration = (routeParamSubmissionId?: string | number) => { - const submissionId = routeParamSubmissionId ? routeParamSubmissionId : 'new'; - const route = ({ params: of({ exerciseId: exercise.id, submissionId }) } as any) as ActivatedRoute; - return TestBed.configureTestingModule({ - imports: [ArtemisTestModule, ArtemisSharedModule, TranslateModule.forRoot(), RouterTestingModule.withRoutes([textAssessmentRoutes[0]])], - declarations: [ - TextAssessmentComponent, - MockComponent(ResultComponent), - MockComponent(TextAssessmentEditorComponent), - MockComponent(ResizableInstructionsComponent), - MockComponent(AssessmentDetailComponent), - MockComponent(ComplaintsForTutorComponent), - MockComponent(AssessmentGeneralFeedbackComponent), - ], - providers: [ - JhiLanguageHelper, - { provide: ActivatedRoute, useValue: route }, - { provide: AlertService, useClass: MockAlertService }, - { provide: AccountService, useClass: MockAccountService }, - { provide: SessionStorageService, useClass: MockSyncStorage }, - { provide: LocalStorageService, useClass: MockSyncStorage }, - { provide: ComplaintService, useClass: MockComplaintService }, - ], - }) - .overrideModule(ArtemisTestModule, { set: { declarations: [], exports: [] } }) - .compileComponents() - .then(() => { - fixture = TestBed.createComponent(TextAssessmentComponent); - comp = fixture.componentInstance; - comp.exercise = exercise; - debugElement = fixture.debugElement; - - router = debugElement.injector.get(Router); - textSubmissionService = debugElement.injector.get(TextSubmissionService); - assessmentsService = debugElement.injector.get(TextAssessmentsService); - - getTextSubmissionForExerciseWithoutAssessmentStub = stub(textSubmissionService, 'getTextSubmissionForExerciseWithoutAssessment'); - getFeedbackDataForExerciseSubmissionStub = stub(assessmentsService, 'getFeedbackDataForExerciseSubmission'); - saveAssessmentStub = stub(assessmentsService, 'save'); - submitAssessmentStub = stub(assessmentsService, 'submit'); - getResultWithPredefinedTextblocksStub = stub(assessmentsService, 'getResultWithPredefinedTextblocks'); - updateAssessmentAfterComplaintStub = stub(assessmentsService, 'updateAssessmentAfterComplaint'); - - router.initialNavigation(); - }); - }; - - afterEach(() => { - getTextSubmissionForExerciseWithoutAssessmentStub.restore(); - getFeedbackDataForExerciseSubmissionStub.restore(); - saveAssessmentStub.restore(); - submitAssessmentStub.restore(); - getResultWithPredefinedTextblocksStub.restore(); - updateAssessmentAfterComplaintStub.restore(); - }); - - describe('when submissionId router param is `new`', () => { - beforeEach(async () => { - await testBedConfiguration(); - }); - - it('AssessNextButton should be visible', fakeAsync(() => { - getTextSubmissionForExerciseWithoutAssessmentStub.returns(throwError({ status: 404 })); - // set all attributes for comp - comp.ngOnInit(); - tick(); - - // not found state is correctly set on the component - expect(comp.notFound).to.be.true; - - comp.userId = 99; - comp.submission = submission; - comp.result = result; - comp.isAssessor = true; - comp.isAtLeastInstructor = true; - comp.assessmentsAreValid = true; - fixture.detectChanges(); - - // check if assessNextButton is available - const assessNextButton = debugElement.query(By.css('#assessNextButton')); - expect(assessNextButton).to.exist; - })); - - it('Should set the result and participation properly for new submission', fakeAsync(() => { - result.hasComplaint = true; - getTextSubmissionForExerciseWithoutAssessmentStub.returns(of(submission)); - comp.ngOnInit(); - tick(); - expect(comp.submission).to.be.deep.equal(submission); - expect(comp.result).to.be.deep.equal(result); - expect(comp.participation).to.be.deep.equal(participation); - expect(comp.isAtLeastInstructor).to.be.true; - expect(comp.complaint).to.be.deep.equal(MockComplaintResponse.body); - })); - - it('Should navigate to tutor dashboard when locked submission limit reached', fakeAsync(() => { - const course = new Course(); - course.id = 1; - exercise.course = course; - comp.exercise = exercise; - getTextSubmissionForExerciseWithoutAssessmentStub.returns(throwError({ error: { errorKey: 'lockedSubmissionsLimitReached' } })); - const spy = stub(router, 'navigateByUrl'); - spy.returns(new Promise(() => true)); - comp.ngOnInit(); - tick(); - expect(spy.called).to.be.true; - })); - - it('Should alert error message on error response', fakeAsync(() => { - const course = new Course(); - course.id = 1; - exercise.course = course; - comp.exercise = exercise; - getTextSubmissionForExerciseWithoutAssessmentStub.returns(throwError({ headers: { get: () => 'error' } })); - const spy = stub(TestBed.inject(AlertService), 'error'); - spy.returns({ type: 'danger', msg: '' }); - comp.ngOnInit(); - tick(); - expect(spy.called).to.be.true; - })); - - it('Should invalidate assessment without general and referenced feedback', fakeAsync(() => { - comp.validateAssessment(); - expect(comp.assessmentsAreValid).to.be.false; - expect(comp.totalScore).to.be.equal(0); - })); - - it('Should validate assessment with general feedback', fakeAsync(() => { - const feedback = new Feedback(); - feedback.detailText = 'General Feedback'; - comp.generalFeedback = feedback; - comp.validateAssessment(); - expect(comp.assessmentsAreValid).to.be.true; - expect(comp.totalScore).to.be.equal(0); - })); - - it('Should invalidate assessment with referenced feedback without reference', fakeAsync(() => { - comp.referencedFeedback = [new Feedback()]; - comp.validateAssessment(); - expect(comp.assessmentsAreValid).to.be.false; - expect(comp.invalidError).to.be.equal('artemisApp.textAssessment.error.feedbackReferenceTooLong'); - })); - - it('Should invalidate assessment with referenced feedback with undefined credits', fakeAsync(() => { - const feedback = new Feedback(); - feedback.reference = 'reference'; - comp.referencedFeedback = [feedback]; - comp.validateAssessment(); - expect(comp.assessmentsAreValid).to.be.false; - expect(comp.invalidError).to.be.equal('artemisApp.textAssessment.error.invalidNeedScoreOrFeedback'); - })); - - it('Should invalidate assessment with referenced feedback without credits', fakeAsync(() => { - const feedback = new Feedback(); - feedback.reference = 'reference'; - feedback.credits = null as any; - comp.referencedFeedback = [feedback]; - comp.validateAssessment(); - expect(comp.assessmentsAreValid).to.be.false; - expect(comp.invalidError).to.be.equal('artemisApp.textAssessment.error.invalidScoreMustBeNumber'); - })); - - it('Should validate assessment with referenced feedback with credits', fakeAsync(() => { - comp.referencedFeedback = [refFeedback, refFeedback2]; - comp.validateAssessment(); - expect(comp.assessmentsAreValid).to.be.true; - expect(comp.totalScore).to.be.equal(10); - })); - - it('Should delete assessment', fakeAsync(() => { - comp.referencedFeedback = [refFeedback, refFeedback2]; - comp.referencedTextBlocks = [new TextBlock(), new TextBlock()]; - comp.deleteAssessment(refFeedback); - expect(comp.referencedFeedback.length).to.be.equal(1); - expect(comp.referencedFeedback).to.contain(refFeedback2); - expect(comp.referencedTextBlocks.length).to.be.equal(1); - expect(comp.totalScore).to.be.equal(5); - expect(comp.assessmentsAreValid).to.be.true; - })); - - it('Should add assessment', fakeAsync(() => { - const assessmentText = 'new assessment'; - comp.referencedTextBlocks = []; - comp.addAssessment(assessmentText); - expect(comp.referencedFeedback.length).to.be.equal(1); - expect(comp.referencedFeedback[0].reference).to.be.equal(assessmentText); - expect(comp.referencedFeedback[0].credits).to.be.equal(0); - expect(comp.referencedTextBlocks.length).to.be.equal(1); - })); - - it('Should not save invalid assessments', fakeAsync(() => { - comp.save(); - expect(saveAssessmentStub.called).to.be.false; - })); - - it('Should handle error on save assessment', fakeAsync(() => { - comp.referencedFeedback = [refFeedback]; - comp.result = { id: 1 } as any; - saveAssessmentStub.returns(throwError({ headers: { get: () => 'error' } })); - const spy = stub(TestBed.inject(AlertService), 'error'); - spy.returns({ type: 'danger', msg: '' }); - comp.save(); - tick(); - expect(saveAssessmentStub.called).to.be.true; - })); - - it('Should save valid assessments', fakeAsync(() => { - comp.referencedFeedback = [refFeedback]; - comp.result = { id: 1 } as any; - participation.results = []; - comp.participation = participation; - saveAssessmentStub.returns(of({ body: result })); - comp.save(); - expect(saveAssessmentStub.called).to.be.true; - expect(comp.result).to.be.equal(result); - expect(comp.participation.results[0]).to.be.equal(result); - expect(comp.showResult).to.be.true; - })); - - it('Should submit valid assessments', fakeAsync(() => { - comp.referencedFeedback = [refFeedback]; - comp.result = { id: 1 } as any; - participation.results = []; - comp.participation = participation; - submitAssessmentStub.returns(of({ body: result })); - comp.submit(); - expect(submitAssessmentStub.called).to.be.true; - expect(comp.result).to.be.equal(result); - expect(comp.participation.results[0]).to.be.equal(result); - expect(comp.showResult).to.be.true; - })); - - it('Should not submit without already existing result', fakeAsync(() => { - comp.result = {} as any; - submitAssessmentStub.returns(of({ body: result })); - comp.submit(); - expect(submitAssessmentStub.called).to.be.false; - })); - - it('Should not submit without valid assessments', fakeAsync(() => { - comp.result = { id: 1 } as any; - submitAssessmentStub.returns(of({ body: result })); - comp.submit(); - expect(submitAssessmentStub.called).to.be.false; - })); - - it('Should set predefined text blocks', fakeAsync(() => { - submission.blocks = [{ id: '1' } as TextBlock]; - comp.submission = submission; - const generalFeedback = { id: 1, detailText: 'general' } as Feedback; - const referencedFeedback = { id: 2, referenceId: '1' } as Feedback; - comp.result = { id: 1 } as Result; - getResultWithPredefinedTextblocksStub.returns(of({ body: { submission, feedbacks: [generalFeedback, referencedFeedback] } })); - comp.predefineTextBlocks(); - tick(); - expect(comp.submission.blocks?.length).to.be.equal(1); - expect(comp.generalFeedback).to.be.equal(generalFeedback); - expect(comp.referencedFeedback.length).to.be.equal(1); - expect(comp.referencedFeedback).to.contain(referencedFeedback); - expect(comp.referencedTextBlocks.length).to.be.equal(1); - })); - - it('Should update assessment after complaint', fakeAsync(() => { - comp.referencedFeedback = [refFeedback]; - comp.submission = { id: 2 } as any; - participation.results = []; - comp.participation = participation; - updateAssessmentAfterComplaintStub.returns(of({ body: result })); - comp.onUpdateAssessmentAfterComplaint(new ComplaintResponse()); - expect(updateAssessmentAfterComplaintStub.called).to.be.true; - expect(comp.result).to.be.equal(result); - expect(comp.participation.results[0]).to.be.equal(result); - expect(comp.showResult).to.be.true; - })); - - it('Should not update assessment after complaint when assessments not valid', fakeAsync(() => { - updateAssessmentAfterComplaintStub.returns(of({ body: result })); - comp.onUpdateAssessmentAfterComplaint(new ComplaintResponse()); - expect(updateAssessmentAfterComplaintStub.called).to.be.false; - expect(comp.result).to.be.undefined; - })); - - it('Should handle error on update assessment after complaint', fakeAsync(() => { - comp.referencedFeedback = [refFeedback]; - comp.submission = { id: 2 } as any; - participation.results = []; - updateAssessmentAfterComplaintStub.returns(throwError({})); - comp.onUpdateAssessmentAfterComplaint(new ComplaintResponse()); - expect(updateAssessmentAfterComplaintStub.called).to.be.true; - expect(comp.result).to.be.undefined; - })); - }); - - describe('when submissionId router param is 1', () => { - beforeEach(async () => { - await testBedConfiguration(1); - }); - - it('Should set the result and participation properly for existing submission', fakeAsync(() => { - getFeedbackDataForExerciseSubmissionStub.returns(of(participation)); - comp.ngOnInit(); - tick(); - expect(comp.isAtLeastInstructor).to.be.true; - })); - }); -}); From 6e8f0b52659685474b04587f7a5845293f7b7f2e Mon Sep 17 00:00:00 2001 From: Stephan Krusche Date: Thu, 30 Apr 2020 21:38:30 +0200 Subject: [PATCH 151/152] Apply suggestions from code review --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 0e0f93470c18..67a9cdee7805 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "compare-versions": "3.6.0", "core-js": "3.6.5", "dompurify": "2.0.10", - "eslint-plugin-chai-friendly": "^0.5.0", + "eslint-plugin-chai-friendly": "0.5.0", "export-to-csv": "0.2.1", "franc-min": "5.0.0", "interactjs": "1.9.10", @@ -78,7 +78,7 @@ "sugar": "2.0.6", "ts-jest": "25.4.0", "tslib": "1.11.1", - "tslint-no-unused-expression-chai": "^0.1.4", + "tslint-no-unused-expression-chai": "0.1.4", "webstomp-client": "1.2.6", "yarn": "1.22.4", "zone.js": "0.10.3" @@ -180,7 +180,7 @@ "scripts": { "prettier:format": "prettier --write 'src/{main/webapp,test}/**/*.{json,ts,js,css,scss,html}'", "prettier:check": "prettier --check 'src/{main/webapp,test}/**/*.{json,ts,js,css,scss,html}'", - "lint": "eslint . --ext .ts && yarn run lint:doc", + "lint": "eslint . --ext .ts", "lint:fix": "yarn run lint --fix", "lint:doc": "tslint --config tslint-doc.json --project tsconfig.json -e 'node_modules/**'", "ngc": "ngc -p tsconfig.app.json", From c1ca26f35a3b151b7958b12882d718e11141d7e5 Mon Sep 17 00:00:00 2001 From: Sascha Beele Date: Fri, 1 May 2020 18:52:47 +0200 Subject: [PATCH 152/152] Revert changes in date-time-picker.component --- .../date-time-picker/date-time-picker.component.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/webapp/app/shared/date-time-picker/date-time-picker.component.ts b/src/main/webapp/app/shared/date-time-picker/date-time-picker.component.ts index 4a3d1fb94532..5394004784c2 100644 --- a/src/main/webapp/app/shared/date-time-picker/date-time-picker.component.ts +++ b/src/main/webapp/app/shared/date-time-picker/date-time-picker.component.ts @@ -1,6 +1,7 @@ import { Component, ElementRef, EventEmitter, forwardRef, Input, Output, ViewChild } from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; import { isMoment, Moment } from 'moment'; +import * as moment from 'moment'; @Component({ selector: 'jhi-date-time-picker', @@ -46,7 +47,8 @@ export class FormDateTimePickerComponent implements ControlValueAccessor { @Input() max: Moment; // Dates after this date are not selectable. @Output() valueChange = new EventEmitter(); - _onChange = () => {}; + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _onChange = (val: Moment) => {}; valueChanged() { this.valueChange.emit(); @@ -60,13 +62,14 @@ export class FormDateTimePickerComponent implements ControlValueAccessor { this.value = value; } } - registerOnTouched() {} + // eslint-disable-next-line @typescript-eslint/no-unused-vars + registerOnTouched(fn: any) {} registerOnChange(fn: any) { this._onChange = fn; } updateField(newValue: Moment) { this.value = newValue; - this._onChange(); + this._onChange(moment(this.value)); this.valueChanged(); } }