Fix: Tests lint and src folder (#138)

* Automaticly fixable eslint issues, mostly 3 -> 2 space indentation

* fix: updated plex_userid to camelcase

* Linted and some consistency refactor on middleware

* eslint uses ecmaversion 2020 & allow empty catch rule

* Started linting source files

* Fixed eslint errors & improved a lot of error handling

* Set 2 eslint rules as warning temporarly

* Updated all import statements to be relative

* Updated mocha & nyc, resolved all lint issues in tests/

* Updated mocha & nyc. Removed production config. Updated gitignore

* Updated test commands to omit system tests, no exit code

* Updated test configuration w/ missing keys

* Chai modules defined in package.json & resolved linting errors

* Dockerfile copies development.example -> production.json. Simplified commands

* All api calls from tests use same chaiHttp implementation

Removes a list of fetch alternatives after being replaced by chaiHttp:
 - request
 - request-promise
 - supertest
 - supertest-as-promised

* Tests should use redis (mock) cache, not tmdb sqlite cache

* Disabled test asADeveloperIWantTheServerToStart

* Re-enable tests/system

* Use chaiHttp in asAUserIWantToRequestAMovie.

* Fixed redis expire & mock implmentation

* Replaced all fetch alternatives from source code and package.json

* Pass error from tmdb api back to client as errorMessage

* Updated authentication middleware to handle checks consitenctly

* Prevent assert error when checking request status, returns success 200

* Resolved merge conflicts

* Only build and publish docker container when branch master
This commit is contained in:
2022-08-20 17:41:46 +02:00
committed by GitHub
parent 1815a429b0
commit 628ed52012
44 changed files with 1248 additions and 1592 deletions

View File

@@ -1,18 +1,27 @@
const assert = require('assert');
const createCacheEntry = require('test/helpers/createCacheEntry');
const resetDatabase = require('test/helpers/resetDatabase');
const request = require('supertest-as-promised');
const app = require('src/webserver/app');
const popularMoviesSuccess = require('test/fixtures/popular-movies-success-response.json');
const assert = require("assert");
const chai = require("chai");
const chaiHttp = require("chai-http");
describe('As a user I want to get popular movies', () => {
before(() => resetDatabase());
before(() => createCacheEntry('pm:1', popularMoviesSuccess));
const server = require("../../src/webserver/server");
const resetDatabase = require("../helpers/resetDatabase");
const createCacheEntry = require("../helpers/createCacheEntry");
const popularMoviesSuccess = require("../fixtures/popular-movies-success-response.json");
it('should return 200 with the information', () =>
request(app)
.get('/api/v2/movie/popular')
.expect(200)
.then(response => assert.equal(response.body.results.length, 20))
);
chai.use(chaiHttp);
describe("As a user I want to get popular movies", () => {
beforeEach(() => resetDatabase());
beforeEach(() => createCacheEntry("tmdb/pm:1", popularMoviesSuccess));
it("should return 200 with the information", done => {
chai
.request(server)
.get("/api/v2/movie/popular")
.end((error, response) => {
// console.log(response);
assert.equal(response?.status, 200);
done();
});
});
});