mirror of
https://github.com/louislam/uptime-kuma.git
synced 2025-06-07 21:42:34 +02:00
Merge branch 'master' into feature/translations-extraction-script
This commit is contained in:
commit
8c1b702410
13 changed files with 98 additions and 29 deletions
4
.github/ISSUE_TEMPLATE/ask-for-help.md
vendored
4
.github/ISSUE_TEMPLATE/ask-for-help.md
vendored
|
@ -9,6 +9,10 @@ assignees: ''
|
|||
**Is it a duplicate question?**
|
||||
Please search in Issues without filters: https://github.com/louislam/uptime-kuma/issues?q=
|
||||
|
||||
|
||||
**Describe your problem**
|
||||
|
||||
|
||||
**Info**
|
||||
Uptime Kuma Version:
|
||||
Using Docker?: Yes/No
|
||||
|
|
7
babel.config.js
Normal file
7
babel.config.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
const config = {};
|
||||
|
||||
if (process.env.TEST_FRONTEND) {
|
||||
config.presets = ["@babel/preset-env"];
|
||||
}
|
||||
|
||||
module.exports = config;
|
5
jest-frontend.config.js
Normal file
5
jest-frontend.config.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
module.exports = {
|
||||
"rootDir": ".",
|
||||
"testRegex": "./test/frontend.spec.js",
|
||||
};
|
||||
|
11
jest.config.js
Normal file
11
jest.config.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
module.exports = {
|
||||
"verbose": true,
|
||||
"preset": "jest-puppeteer",
|
||||
"globals": {
|
||||
"__DEV__": true
|
||||
},
|
||||
"testRegex": "./test/e2e.spec.js",
|
||||
"rootDir": ".",
|
||||
"testTimeout": 30000,
|
||||
};
|
||||
|
14
package.json
14
package.json
|
@ -22,7 +22,8 @@
|
|||
"build": "vite build",
|
||||
"test": "node test/prepare-test-server.js && node server/server.js --port=3002 --data-dir=./data/test/ --test",
|
||||
"test-with-build": "npm run build && npm test",
|
||||
"jest": "node test/prepare-jest.js && jest",
|
||||
"jest": "node test/prepare-jest.js && npm run jest-frontend && jest ",
|
||||
"jest-frontend": "cross-env TEST_FRONTEND=1 jest --config=./jest-frontend.config.js",
|
||||
"tsc": "tsc",
|
||||
"vite-preview-dist": "vite preview --host",
|
||||
"build-docker": "npm run build-docker-debian && npm run build-docker-alpine",
|
||||
|
@ -99,6 +100,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@babel/eslint-parser": "~7.15.7",
|
||||
"@babel/preset-env": "^7.15.8",
|
||||
"@types/bootstrap": "~5.1.6",
|
||||
"@vitejs/plugin-legacy": "~1.6.1",
|
||||
"@vitejs/plugin-vue": "~1.9.2",
|
||||
|
@ -119,15 +121,5 @@
|
|||
"stylelint-config-standard": "~22.0.0",
|
||||
"typescript": "~4.4.3",
|
||||
"vite": "~2.6.4"
|
||||
},
|
||||
"jest": {
|
||||
"verbose": true,
|
||||
"preset": "jest-puppeteer",
|
||||
"globals": {
|
||||
"__DEV__": true
|
||||
},
|
||||
"testRegex": "./test/*.spec.js",
|
||||
"rootDir": ".",
|
||||
"testTimeout": 30000
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,18 +11,18 @@ export default {
|
|||
computed: {
|
||||
color() {
|
||||
if (this.status === 0) {
|
||||
return "danger"
|
||||
return "danger";
|
||||
}
|
||||
|
||||
if (this.status === 1) {
|
||||
return "primary"
|
||||
return "primary";
|
||||
}
|
||||
|
||||
if (this.status === 2) {
|
||||
return "warning"
|
||||
return "warning";
|
||||
}
|
||||
|
||||
return "secondary"
|
||||
return "secondary";
|
||||
},
|
||||
|
||||
text() {
|
||||
|
@ -41,11 +41,11 @@ export default {
|
|||
return this.$t("Unknown");
|
||||
},
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
span {
|
||||
width: 64px;
|
||||
min-width: 64px;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -49,7 +49,10 @@ const languageList = {
|
|||
|
||||
const rtlLangs = ["fa"];
|
||||
|
||||
export const currentLocale = () => localStorage.locale || "en";
|
||||
export const currentLocale = () => localStorage.locale
|
||||
|| languageList[navigator.language] && navigator.language
|
||||
|| languageList[navigator.language.substring(0, 2)] && navigator.language.substring(0, 2)
|
||||
|| "en";
|
||||
|
||||
export const localeDirection = () => {
|
||||
return rtlLangs.includes(currentLocale()) ? "rtl" : "ltr";
|
||||
|
|
|
@ -43,3 +43,9 @@ app.component("Editable", contenteditable);
|
|||
app.component("FontAwesomeIcon", FontAwesomeIcon);
|
||||
|
||||
app.mount("#app");
|
||||
|
||||
// Expose the vue instance for development
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
console.log("Dev Only: window.app is the vue instance");
|
||||
window.app = app._instance;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ class TimeLogger {
|
|||
this.startTime = dayjs().valueOf();
|
||||
}
|
||||
print(name) {
|
||||
if (exports.isDev && process && process.env.TIMELOGGER === "1") {
|
||||
if (exports.isDev && process.env.TIMELOGGER === "1") {
|
||||
console.log(name + ": " + (dayjs().valueOf() - this.startTime) + "ms");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ export class TimeLogger {
|
|||
}
|
||||
|
||||
print(name: string) {
|
||||
if (isDev && process && process.env.TIMELOGGER === "1") {
|
||||
if (isDev && process.env.TIMELOGGER === "1") {
|
||||
console.log(name + ": " + (dayjs().valueOf() - this.startTime) + "ms")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ describe("Init", () => {
|
|||
});
|
||||
|
||||
it(`should be titled "${title}"`, async () => {
|
||||
await expect(page.title()).resolves.toMatch(title);
|
||||
await expect(page.title()).resolves.toEqual(title);
|
||||
});
|
||||
|
||||
// Setup Page
|
||||
|
@ -75,11 +75,11 @@ describe("Init", () => {
|
|||
|
||||
await page.select("#language", "zh-HK");
|
||||
let languageTitle = await page.evaluate(() => document.querySelector("[for=language]").innerText);
|
||||
expect(languageTitle).toMatch("語言");
|
||||
expect(languageTitle).toEqual("語言");
|
||||
|
||||
await page.select("#language", "en");
|
||||
languageTitle = await page.evaluate(() => document.querySelector("[for=language]").innerText);
|
||||
expect(languageTitle).toMatch("Language");
|
||||
expect(languageTitle).toEqual("Language");
|
||||
});
|
||||
|
||||
it("Change Theme", async () => {
|
||||
|
@ -103,21 +103,21 @@ describe("Init", () => {
|
|||
it("Search Engine Visibility", async () => {
|
||||
// Default
|
||||
let res = await axios.get(baseURL + "/robots.txt");
|
||||
expect(res.data).toMatch("Disallow: /");
|
||||
expect(res.data).toContain("Disallow: /");
|
||||
|
||||
// Yes
|
||||
await click(page, "#searchEngineIndexYes");
|
||||
await click(page, "form > div > .btn[type=submit]");
|
||||
await sleep(2000);
|
||||
res = await axios.get(baseURL + "/robots.txt");
|
||||
expect(res.data).not.toMatch("Disallow: /");
|
||||
expect(res.data).not.toContain("Disallow: /");
|
||||
|
||||
// No
|
||||
await click(page, "#searchEngineIndexNo");
|
||||
await click(page, "form > div > .btn[type=submit]");
|
||||
await sleep(2000);
|
||||
res = await axios.get(baseURL + "/robots.txt");
|
||||
expect(res.data).toMatch("Disallow: /");
|
||||
expect(res.data).toContain("Disallow: /");
|
||||
});
|
||||
|
||||
it("Entry Page", async () => {
|
||||
|
@ -218,7 +218,7 @@ describe("Init", () => {
|
|||
await page.goto(baseURL + "/status");
|
||||
});
|
||||
it(`should be titled "${title}"`, async () => {
|
||||
await expect(page.title()).resolves.toMatch(title);
|
||||
await expect(page.title()).resolves.toEqual(title);
|
||||
});
|
||||
});
|
||||
});
|
42
test/frontend.spec.js
Normal file
42
test/frontend.spec.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
// eslint-disable-next-line no-global-assign
|
||||
global.localStorage = {};
|
||||
global.navigator = {
|
||||
language: "en"
|
||||
};
|
||||
|
||||
const { currentLocale } = require("../src/i18n");
|
||||
|
||||
describe("Test i18n.js", () => {
|
||||
|
||||
it("currentLocale()", () => {
|
||||
expect(currentLocale()).toEqual("en");
|
||||
|
||||
navigator.language = "zh-HK";
|
||||
expect(currentLocale()).toEqual("zh-HK");
|
||||
|
||||
// Note that in Safari on iOS prior to 10.2, the country code returned is lowercase: "en-us", "fr-fr" etc.
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/Navigator/language
|
||||
navigator.language = "zh-hk";
|
||||
expect(currentLocale()).toEqual("en");
|
||||
|
||||
navigator.language = "en-US";
|
||||
expect(currentLocale()).toEqual("en");
|
||||
|
||||
navigator.language = "ja-ZZ";
|
||||
expect(currentLocale()).toEqual("ja");
|
||||
|
||||
navigator.language = "zz";
|
||||
expect(currentLocale()).toEqual("en");
|
||||
|
||||
navigator.language = "zz-ZZ";
|
||||
expect(currentLocale()).toEqual("en");
|
||||
|
||||
localStorage.locale = "en";
|
||||
expect(currentLocale()).toEqual("en");
|
||||
|
||||
localStorage.locale = "zh-HK";
|
||||
expect(currentLocale()).toEqual("zh-HK");
|
||||
});
|
||||
|
||||
});
|
||||
|
|
@ -6,5 +6,4 @@ FROM ubuntu
|
|||
# RUN ln -s /usr/bin/nodejs /usr/bin/node
|
||||
# RUN node -v
|
||||
|
||||
COPY ./install.sh .
|
||||
RUN bash install.sh local /opt/uptime-kuma 3000 0.0.0.0
|
||||
RUN curl -o kuma_install.sh http://git.kuma.pet/install.sh && bash kuma_install.sh local /opt/uptime-kuma 3000 0.0.0.0
|
||||
|
|
Loading…
Add table
Reference in a new issue