Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ _This release is scheduled to be released on 2023-10-01._
- Update engine node >=18. v16 reached it's end of life. (#3170)
- Update typescript definition for modules
- Cleaned up nunjuck templates
- Replace node-fetch with internal fetch (#2649)

### Fixed

Expand Down
20 changes: 0 additions & 20 deletions js/fetch.js

This file was deleted.

1 change: 0 additions & 1 deletion js/server_functions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const fs = require("fs");
const path = require("path");
const Log = require("logger");
const fetch = require("./fetch");

/**
* Gets the config.
Expand Down
1 change: 0 additions & 1 deletion modules/default/calendar/calendarfetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
const https = require("https");
const digest = require("digest-fetch");
const ical = require("node-ical");
const fetch = require("fetch");
const Log = require("logger");
const NodeHelper = require("node_helper");
const CalendarFetcherUtils = require("./calendarfetcherutils");
Expand Down
1 change: 0 additions & 1 deletion modules/default/newsfeed/newsfeedfetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
const stream = require("stream");
const FeedMe = require("feedme");
const iconv = require("iconv-lite");
const fetch = require("fetch");
const Log = require("logger");
const NodeHelper = require("node_helper");

Expand Down
10 changes: 7 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"jsdom": "^22.1.0",
"lint-staged": "^14.0.1",
"lodash": "^4.17.21",
"node-fetch": "^2.6.12",
"playwright": "^1.37.1",
"prettier": "^3.0.3",
"sinon": "^15.2.0",
Expand All @@ -85,7 +86,6 @@
"luxon": "^1.28.1",
"module-alias": "^2.2.3",
"moment": "^2.29.4",
"node-fetch": "^2.6.12",
"node-ical": "^0.16.1",
"socket.io": "^4.7.2"
},
Expand All @@ -96,8 +96,7 @@
},
"_moduleAliases": {
"node_helper": "js/node_helper.js",
"logger": "js/logger.js",
"fetch": "js/fetch.js"
"logger": "js/logger.js"
},
"engines": {
"node": ">=18"
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/env_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ describe("App environment", () => {
});

it("get request from http://localhost:8080 should return 200", async () => {
const res = await helpers.fetch("http://localhost:8080");
const res = await fetch("http://localhost:8080");
expect(res.status).toBe(200);
});

it("get request from http://localhost:8080/nothing should return 404", async () => {
const res = await helpers.fetch("http://localhost:8080/nothing");
const res = await fetch("http://localhost:8080/nothing");
expect(res.status).toBe(404);
});

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/fonts_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("All font files from roboto.css should be downloadable", () => {

test.each(fontFiles)("should return 200 HTTP code for file '%s'", async (fontFile) => {
const fontUrl = `http://localhost:8080/fonts/${fontFile}`;
const res = await helpers.fetch(fontUrl);
const res = await fetch(fontUrl);
expect(res.status).toBe(200);
});
});
11 changes: 1 addition & 10 deletions tests/e2e/helpers/global-setup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const jsdom = require("jsdom");
const corefetch = require("fetch");

exports.startApplication = async (configFilename, exec) => {
jest.resetModules();
Expand Down Expand Up @@ -31,7 +30,7 @@ exports.getDocument = () => {
const url = `http://${config.address || "localhost"}:${config.port || "8080"}`;
jsdom.JSDOM.fromURL(url, { resources: "usable", runScripts: "dangerously" }).then((dom) => {
dom.window.name = "jsdom";
dom.window.fetch = corefetch;
dom.window.fetch = fetch;
dom.window.onload = () => {
global.document = dom.window.document;
resolve();
Expand Down Expand Up @@ -80,14 +79,6 @@ exports.waitForAllElements = (selector) => {
});
};

exports.fetch = (url) => {
return new Promise((resolve) => {
corefetch(url).then((res) => {
resolve(res);
});
});
};

exports.testMatch = async (element, regex) => {
const elem = await this.waitForElement(element);
expect(elem).not.toBe(null);
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/ipWhitelist_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe("ipWhitelist directive configuration", () => {
});

it("should return 403", async () => {
const res = await helpers.fetch("http://localhost:8181");
const res = await fetch("http://localhost:8181");
expect(res.status).toBe(403);
});
});
Expand All @@ -24,7 +24,7 @@ describe("ipWhitelist directive configuration", () => {
});

it("should return 200", async () => {
const res = await helpers.fetch("http://localhost:8282");
const res = await fetch("http://localhost:8282");
expect(res.status).toBe(200);
});
});
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/port_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe("port directive configuration", () => {
});

it("should return 200", async () => {
const res = await helpers.fetch("http://localhost:8090");
const res = await fetch("http://localhost:8090");
expect(res.status).toBe(200);
});
});
Expand All @@ -24,7 +24,7 @@ describe("port directive configuration", () => {
});

it("should return 200", async () => {
const res = await helpers.fetch("http://localhost:8100");
const res = await fetch("http://localhost:8100");
expect(res.status).toBe(200);
});
});
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/serveronly_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ describe("App environment", () => {
});

it("get request from http://localhost:8080 should return 200", async () => {
const res = await helpers.fetch("http://localhost:8080");
const res = await fetch("http://localhost:8080");
expect(res.status).toBe(200);
});

it("get request from http://localhost:8080/nothing should return 404", async () => {
const res = await helpers.fetch("http://localhost:8080/nothing");
const res = await fetch("http://localhost:8080/nothing");
expect(res.status).toBe(404);
});
});
2 changes: 1 addition & 1 deletion tests/e2e/template_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe("templated config with port variable", () => {
});

it("should return 200", async () => {
const res = await helpers.fetch("http://localhost:8090");
const res = await fetch("http://localhost:8090");
expect(res.status).toBe(200);
});
});
4 changes: 2 additions & 2 deletions tests/e2e/vendor_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ describe("Vendors", () => {
Object.keys(vendors).forEach((vendor) => {
it(`should return 200 HTTP code for vendor "${vendor}"`, async () => {
const urlVendor = `http://localhost:8080/vendor/${vendors[vendor]}`;
const res = await helpers.fetch(urlVendor);
const res = await fetch(urlVendor);
expect(res.status).toBe(200);
});
});

Object.keys(vendors).forEach((vendor) => {
it(`should return 404 HTTP code for vendor https://localhost/"${vendor}"`, async () => {
const urlVendor = `http://localhost:8080/${vendors[vendor]}`;
const res = await helpers.fetch(urlVendor);
const res = await fetch(urlVendor);
expect(res.status).toBe(404);
});
});
Expand Down
11 changes: 4 additions & 7 deletions tests/unit/functions/server_functions_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@ describe("server_functions tests", () => {
let corsResponse;
let request;

jest.mock("node-fetch");
let nodefetch = require("node-fetch");
let fetchMock;

beforeEach(() => {
nodefetch.mockReset();

fetchResponseHeadersGet = jest.fn(() => {});
fetchResponseHeadersText = jest.fn(() => {});
fetchResponse = {
Expand All @@ -23,10 +19,11 @@ describe("server_functions tests", () => {
},
text: fetchResponseHeadersText
};
jest.mock("node-fetch", () => jest.fn());
nodefetch.mockImplementation(() => fetchResponse);
// eslint-disable-next-line
fetch = jest.fn();
fetch.mockImplementation(() => fetchResponse);

fetchMock = nodefetch;
fetchMock = fetch;

corsResponse = {
set: jest.fn(() => {}),
Expand Down