From 58ce2109242ee20a99ed8a10362f601f9b083ecc Mon Sep 17 00:00:00 2001 From: Amir Raminfar Date: Fri, 9 Sep 2022 12:39:41 -0700 Subject: [PATCH] Adds more tests --- assets/modules/i18n.ts | 2 +- e2e/cypress.env.json | 3 +- e2e/cypress/e2e/dozze_auth.cy.js | 14 +++++++ e2e/cypress/e2e/dozze_i18n.cy.js | 17 ++++++++ e2e/cypress/e2e/dozzle_custom_base.cy.js | 15 ++++++++ e2e/docker-compose.yml | 21 +++++++--- e2e/package.json | 4 +- locales/es.yml | 49 ++++++++++++++++++++++++ 8 files changed, 117 insertions(+), 8 deletions(-) create mode 100644 e2e/cypress/e2e/dozze_auth.cy.js create mode 100644 e2e/cypress/e2e/dozze_i18n.cy.js create mode 100644 e2e/cypress/e2e/dozzle_custom_base.cy.js create mode 100644 locales/es.yml diff --git a/assets/modules/i18n.ts b/assets/modules/i18n.ts index 897a8853..9e8f95e5 100644 --- a/assets/modules/i18n.ts +++ b/assets/modules/i18n.ts @@ -12,7 +12,7 @@ export const install = (app: App) => { ); const i18n = createI18n({ legacy: false, - locale: navigator.language, + locale: navigator.language.slice(0, 2), fallbackLocale: "en", messages, }); diff --git a/e2e/cypress.env.json b/e2e/cypress.env.json index af49e1b7..5f7c64d9 100644 --- a/e2e/cypress.env.json +++ b/e2e/cypress.env.json @@ -1,3 +1,4 @@ { - "DOZZLE_DEFAULT": "http://localhost:8080/" + "DOZZLE_DEFAULT": "http://localhost:8080/", + "DOZZLE_AUTH": "http://localhost:8080/" } diff --git a/e2e/cypress/e2e/dozze_auth.cy.js b/e2e/cypress/e2e/dozze_auth.cy.js new file mode 100644 index 00000000..8121e608 --- /dev/null +++ b/e2e/cypress/e2e/dozze_auth.cy.js @@ -0,0 +1,14 @@ +/// + +context("Dozzle default mode", { baseUrl: Cypress.env("DOZZLE_AUTH") }, () => { + beforeEach(() => { + cy.visit("/"); + }); + + it("login screen", () => { + cy.get("input[name=username]").type("foo"); + cy.get("input[name=password]").type("bar"); + cy.get("button[type=submit]").click(); + cy.get("p.menu-label").should("contain", "Containers"); + }); +}); diff --git a/e2e/cypress/e2e/dozze_i18n.cy.js b/e2e/cypress/e2e/dozze_i18n.cy.js new file mode 100644 index 00000000..892cc3b2 --- /dev/null +++ b/e2e/cypress/e2e/dozze_i18n.cy.js @@ -0,0 +1,17 @@ +/// + +context("Dozzle es lang", { baseUrl: Cypress.env("DOZZLE_DEFAULT") }, () => { + beforeEach(() => { + cy.visit("/", { + onBeforeLoad(win) { + Object.defineProperty(win.navigator, "language", { + value: "es_MX", + }); + }, + }); + }); + + it("should find contenedores", () => { + cy.get("p.menu-label").should("contain", "Contenedores"); + }); +}); diff --git a/e2e/cypress/e2e/dozzle_custom_base.cy.js b/e2e/cypress/e2e/dozzle_custom_base.cy.js new file mode 100644 index 00000000..bd5ab0bb --- /dev/null +++ b/e2e/cypress/e2e/dozzle_custom_base.cy.js @@ -0,0 +1,15 @@ +/// + +context("Dozzle custom base", { baseUrl: Cypress.env("DOZZLE_CUSTOM") }, () => { + beforeEach(() => { + cy.visit("/"); + }); + + it("custom base should work", () => { + cy.get("p.menu-label").should("contain", "Containers"); + }); + + it("url should be custom", () => { + cy.url().should("include", "foobarbase"); + }); +}); diff --git a/e2e/docker-compose.yml b/e2e/docker-compose.yml index 76f5ca13..0f0feb5b 100644 --- a/e2e/docker-compose.yml +++ b/e2e/docker-compose.yml @@ -8,8 +8,20 @@ services: - DOZZLE_FILTER=name=custom_base - DOZZLE_BASE=/foobarbase - DOZZLE_NO_ANALYTICS=1 - ports: - - "8080:8080" + image: amir20/dozzle_custom_cache + build: + context: .. + cache_from: + - amir20/dozzle_custom_cache:latest + auth: + container_name: auth + volumes: + - /var/run/docker.sock:/var/run/docker.sock + environment: + - DOZZLE_FILTER=name=auth + - DOZZLE_USERNAME=foo + - DOZZLE_PASSWORD=bar + - DOZZLE_NO_ANALYTICS=1 image: amir20/dozzle_custom_cache build: context: .. @@ -22,8 +34,6 @@ services: environment: - DOZZLE_FILTER=name=dozzle - DOZZLE_NO_ANALYTICS=1 - ports: - - "9090:8080" image: amir20/dozzle_cache:latest build: context: .. @@ -41,7 +51,8 @@ services: - ./cypress.config.ts:/e2e/cypress.config.ts environment: - CYPRESS_DOZZLE_DEFAULT=http://dozzle:8080/ - - CYPRESS_CUSTOM_DEFAULT=http://custom_base:8080/foobarbase + - CYPRESS_DOZZLE_AUTH=http://auth:8080/ + - CYPRESS_DOZZLE_CUSTOM=http://custom_base:8080/foobarbase - CYPRESS_RECORD_KEY=155c3cf8-b2dd-4f5e-9fb3-7635f5b79d4d - COMMIT_INFO_BRANCH=${GITHUB_REF_NAME} - COMMIT_INFO_AUTHOR=${GITHUB_ACTOR} diff --git a/e2e/package.json b/e2e/package.json index 3af2a644..b9b1f6e1 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -1,7 +1,9 @@ { "name": "e2e", "version": "1.0.0", - "scripts": {}, + "scripts": { + "test": "cypress run" + }, "license": "ISC", "dependencies": { "@frsource/cypress-plugin-visual-regression-diff": "^1.9.13", diff --git a/locales/es.yml b/locales/es.yml new file mode 100644 index 00000000..35315e97 --- /dev/null +++ b/locales/es.yml @@ -0,0 +1,49 @@ +toolbar: + clear: Clear + download: Download + search: Search +label: + containers: Contenedores + total-containers: Total Containers + running: Running + total-cpu-usage: Total CPU Usage + total-mem-usage: Total Mem Usage + dozzle-version: Dozzle Version + all: All + password: Password + username: Username +tooltip: + search: Search containers (⌘ + k, ⌃k) + pin-column: Pin as column +error: + page-not-found: This page does not exist. + invalid-auth: Username and password are not valid. +title: + page-not-found: Page not found + login: Authentication Required + settings: Settings +button: + logout: Logout + login: Login +placeholder: + search-containers: Search Containers +settings: + display: Display + small-scrollbars: Use smaller scrollbars + show-timesamps: Show timestamps + soft-wrap: Soft wrap lines + 12-24-format: >- + By default, Dozzle will use your browser's locale to format time. You can + force to 12 or 24 hour style. + font-size: Font size to use for logs + color-scheme: Color scheme + options: Options + show-stopped-containers: Show stopped containers + about: About + search: >- + Enable searching with Dozzle using command+f or + ctrl+f + using-version: You are using Dozzle {version}. + update-available: >- + New version is available! Update to + {nextVersion}.