From 6f9dbe4942737f7c221ecb51e146cc54af6d7958 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D8=B9=D8=A8=D8=AF=D8=A7=D9=84=D9=85=D9=86=D8=A7=D9=86?= Date: Thu, 14 Nov 2024 17:36:38 +0500 Subject: [PATCH 1/3] fixed custom mock language 1. remoced gl mock implementation 2. introduced scope variable to access current translation --- client/app/src/app-data.service.ts | 1 + client/app/src/services/helper/mocks.ts | 12 +++--------- .../app/src/services/helper/translation.service.ts | 7 +++++-- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/client/app/src/app-data.service.ts b/client/app/src/app-data.service.ts index 07fce50694..fbd12d6b82 100644 --- a/client/app/src/app-data.service.ts +++ b/client/app/src/app-data.service.ts @@ -9,6 +9,7 @@ import {BehaviorSubject, Observable} from "rxjs"; export class AppDataService { private showLoadingPanelSubject: BehaviorSubject = new BehaviorSubject(false); showLoadingPanel$: Observable = this.showLoadingPanelSubject.asObservable(); + language:string = "en" updateShowLoadingPanel(newValue: boolean) { this.showLoadingPanelSubject.next(newValue); diff --git a/client/app/src/services/helper/mocks.ts b/client/app/src/services/helper/mocks.ts index 3cb58b55b6..acc6c82a87 100644 --- a/client/app/src/services/helper/mocks.ts +++ b/client/app/src/services/helper/mocks.ts @@ -14,13 +14,14 @@ interface Mocks { } class MockEngine { + language: string private mocks: Mocks = {}; private applyMock(mock: Mock): void { const e = document.querySelector(mock.selector) as HTMLElement | null; if (e) { - if (!mock.value || mock.language !== GL.language) { - mock.language = GL.language; + if (!mock.value || mock.language !== this.language) { + mock.language = this.language; if (typeof mock.mock === "function") { mock.value = mock.mock(e); } else { @@ -93,11 +94,4 @@ class MockEngine { } } -const GL = { - language: 'en', - get mockEngine() { - return mockEngine; - } -}; - export const mockEngine = new MockEngine(); \ No newline at end of file diff --git a/client/app/src/services/helper/translation.service.ts b/client/app/src/services/helper/translation.service.ts index 351a51c3f5..566de73c23 100644 --- a/client/app/src/services/helper/translation.service.ts +++ b/client/app/src/services/helper/translation.service.ts @@ -2,7 +2,8 @@ import {BehaviorSubject} from 'rxjs'; import {Injectable, inject} from "@angular/core"; import {TranslateService} from "@ngx-translate/core"; import {UtilsService} from "@app/shared/services/utils.service"; -import {DOCUMENT} from "@angular/common"; +import {AppDataService} from "@app/app-data.service"; +import {mockEngine} from "@app/services/helper/mocks"; @Injectable({ providedIn: "root", @@ -10,7 +11,7 @@ import {DOCUMENT} from "@angular/common"; export class TranslationService { private utilsService = inject(UtilsService); protected translate = inject(TranslateService); - private document = inject(DOCUMENT); + private appDataService = inject(AppDataService); language = ""; @@ -31,6 +32,8 @@ export class TranslationService { this.language = changedLanguage; this.changeLocale(this.language); this.translate.use(this.language).subscribe(() => { + this.appDataService.language = this.language + mockEngine.language = this.language if (callback) { callback(); } From d14f2c9b8ebe82097f8c2d328e68f22e7b362bc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D8=B9=D8=A8=D8=AF=D8=A7=D9=84=D9=85=D9=86=D8=A7=D9=86?= Date: Thu, 14 Nov 2024 23:00:45 +0500 Subject: [PATCH 2/3] test case optimizations File Upload Completion Checks: Ensured files are fully uploaded before further processing. Homepage Header Title Fix: Resolved ID fetch issue. --- client/app/src/pages/admin/settings/tab1/tab1.component.html | 2 +- client/cypress/e2e/11-test-admin-configure-languages.cy.ts | 5 +++-- client/cypress/e2e/15-test-admin-configure-network.cy.ts | 3 +++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/client/app/src/pages/admin/settings/tab1/tab1.component.html b/client/app/src/pages/admin/settings/tab1/tab1.component.html index b95046a889..b753326e86 100644 --- a/client/app/src/pages/admin/settings/tab1/tab1.component.html +++ b/client/app/src/pages/admin/settings/tab1/tab1.component.html @@ -17,7 +17,7 @@
- +
diff --git a/client/cypress/e2e/11-test-admin-configure-languages.cy.ts b/client/cypress/e2e/11-test-admin-configure-languages.cy.ts index b7d69cb8d2..550b74f380 100644 --- a/client/cypress/e2e/11-test-admin-configure-languages.cy.ts +++ b/client/cypress/e2e/11-test-admin-configure-languages.cy.ts @@ -30,7 +30,7 @@ describe("admin configure languages", () => { cy.waitForUrl("/#/admin/settings"); cy.get('#LanguagePickerBox').should('be.visible').find('ng-select').last().click().get('ng-dropdown-panel').contains('Italiano').click(); - cy.get('[name="node.dataModel.header_title_homepage"]').clear().type("TEXT1_IT"); + cy.get('[data-cy="header_title_homepage"]').clear().type("TEXT1_IT"); cy.get('[name="node.dataModel.presentation"]').clear().type("TEXT2_IT"); cy.get('button.btn.btn-primary').eq(0).get("#save_settings").click(); @@ -60,7 +60,8 @@ describe("admin configure languages", () => { cy.visit("/#/admin/settings"); cy.waitForUrl("/#/admin/settings"); cy.get('#LanguagePickerBox').should('be.visible', { timeout: 10000 }).find('ng-select').last().click().get('ng-dropdown-panel').contains('Italian').click(); - cy.get('[name="node.dataModel.header_title_homepage"]').clear(); + cy.get('[data-cy="header_title_homepage"]').clear(); + cy.get('[name="node.dataModel.presentation"]').clear(); cy.get('button.btn.btn-primary').eq(0).get("#save_settings").click(); diff --git a/client/cypress/e2e/15-test-admin-configure-network.cy.ts b/client/cypress/e2e/15-test-admin-configure-network.cy.ts index 9147d95adf..92fcac3a32 100644 --- a/client/cypress/e2e/15-test-admin-configure-network.cy.ts +++ b/client/cypress/e2e/15-test-admin-configure-network.cy.ts @@ -30,18 +30,21 @@ describe("admin configure network", () => { fileName: "key.pem", mimeType: "application/x-pem-file" }, {"force": true}); + cy.get("#deleteKey").should('be.visible') cy.get("div.card.cert input[type=file]").selectFile({ contents: "../backend/globaleaks/tests/data/https/valid/cert.pem", fileName: "cert.pem", mimeType: "application/x-pem-file" }, {"force": true}); + cy.get("#deleteCert").should('be.visible') cy.get("div.card.chain input[type=file]").selectFile({ contents: "../backend/globaleaks/tests/data/https/valid/chain.pem", fileName: "chain.pem" }, {"force": true}); + cy.get("#deleteChain").should('be.visible') cy.get("#deleteChain").click(); cy.get("#modal-action-ok").click(); From cf4a8d413f70415de7163cf72f12015732a3eee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D8=B9=D8=A8=D8=AF=D8=A7=D9=84=D9=85=D9=86=D8=A7=D9=86?= Date: Thu, 14 Nov 2024 23:41:31 +0500 Subject: [PATCH 3/3] cypress admin configure language optimizations --- client/app/src/pages/admin/settings/tab1/tab1.component.html | 2 +- client/cypress/e2e/11-test-admin-configure-languages.cy.ts | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/client/app/src/pages/admin/settings/tab1/tab1.component.html b/client/app/src/pages/admin/settings/tab1/tab1.component.html index b753326e86..b95046a889 100644 --- a/client/app/src/pages/admin/settings/tab1/tab1.component.html +++ b/client/app/src/pages/admin/settings/tab1/tab1.component.html @@ -17,7 +17,7 @@
- +
diff --git a/client/cypress/e2e/11-test-admin-configure-languages.cy.ts b/client/cypress/e2e/11-test-admin-configure-languages.cy.ts index 550b74f380..b7d69cb8d2 100644 --- a/client/cypress/e2e/11-test-admin-configure-languages.cy.ts +++ b/client/cypress/e2e/11-test-admin-configure-languages.cy.ts @@ -30,7 +30,7 @@ describe("admin configure languages", () => { cy.waitForUrl("/#/admin/settings"); cy.get('#LanguagePickerBox').should('be.visible').find('ng-select').last().click().get('ng-dropdown-panel').contains('Italiano').click(); - cy.get('[data-cy="header_title_homepage"]').clear().type("TEXT1_IT"); + cy.get('[name="node.dataModel.header_title_homepage"]').clear().type("TEXT1_IT"); cy.get('[name="node.dataModel.presentation"]').clear().type("TEXT2_IT"); cy.get('button.btn.btn-primary').eq(0).get("#save_settings").click(); @@ -60,8 +60,7 @@ describe("admin configure languages", () => { cy.visit("/#/admin/settings"); cy.waitForUrl("/#/admin/settings"); cy.get('#LanguagePickerBox').should('be.visible', { timeout: 10000 }).find('ng-select').last().click().get('ng-dropdown-panel').contains('Italian').click(); - cy.get('[data-cy="header_title_homepage"]').clear(); - + cy.get('[name="node.dataModel.header_title_homepage"]').clear(); cy.get('[name="node.dataModel.presentation"]').clear(); cy.get('button.btn.btn-primary').eq(0).get("#save_settings").click();