From fcffac9b83e51d2cfcd1bf11860a88b87c27ed06 Mon Sep 17 00:00:00 2001 From: markuczy <129275100+markuczy@users.noreply.github.com> Date: Wed, 10 Apr 2024 19:50:02 +0200 Subject: [PATCH] fix: show help structure (#59) * refactor: refactor remote components structure * fix: comment out harnesses until tests are ready * fix: removed logs --- src/app/remotes/harnesses/a.harness.ts | 53 ------------------- src/app/remotes/harnesses/i.harness.ts | 41 -------------- .../remotes/harnesses/show-help.harness.ts | 27 ---------- .../remotes/service/helpsRemote.service.ts | 7 --- .../no-help-item/no-help-item.component.html | 0 .../no-help-item/no-help-item.component.scss | 0 .../no-help-item.component.spec.ts | 0 .../no-help-item/no-help-item.component.ts | 0 .../no-help-item}/no-help-item.harness.ts | 0 .../show-help/show-help.component.html | 0 .../show-help/show-help.component.scss | 0 .../show-help/show-help.component.spec.ts | 0 .../show-help/show-help.component.ts | 12 ++--- .../remotes/show-help/show-help.harness.ts | 25 +++++++++ tsconfig.app.json | 2 +- webpack.config.js | 2 +- 16 files changed, 32 insertions(+), 137 deletions(-) delete mode 100644 src/app/remotes/harnesses/a.harness.ts delete mode 100644 src/app/remotes/harnesses/i.harness.ts delete mode 100644 src/app/remotes/harnesses/show-help.harness.ts delete mode 100644 src/app/remotes/service/helpsRemote.service.ts rename src/app/remotes/{components => show-help}/no-help-item/no-help-item.component.html (100%) rename src/app/remotes/{components => show-help}/no-help-item/no-help-item.component.scss (100%) rename src/app/remotes/{components => show-help}/no-help-item/no-help-item.component.spec.ts (100%) rename src/app/remotes/{components => show-help}/no-help-item/no-help-item.component.ts (100%) rename src/app/remotes/{harnesses => show-help/no-help-item}/no-help-item.harness.ts (100%) rename src/app/remotes/{components => }/show-help/show-help.component.html (100%) rename src/app/remotes/{components => }/show-help/show-help.component.scss (100%) rename src/app/remotes/{components => }/show-help/show-help.component.spec.ts (100%) rename src/app/remotes/{components => }/show-help/show-help.component.ts (94%) create mode 100644 src/app/remotes/show-help/show-help.harness.ts diff --git a/src/app/remotes/harnesses/a.harness.ts b/src/app/remotes/harnesses/a.harness.ts deleted file mode 100644 index b577cc9..0000000 --- a/src/app/remotes/harnesses/a.harness.ts +++ /dev/null @@ -1,53 +0,0 @@ -// import { BaseHarnessFilters, ComponentHarness, HarnessPredicate } from '@angular/cdk/testing' - -// export interface AHarnessFilters extends BaseHarnessFilters { -// class?: string -// id?: string -// } - -// export class AHarness extends ComponentHarness { -// static hostSelector = 'a' - -// static with(options: AHarnessFilters): HarnessPredicate { -// return new HarnessPredicate(AHarness, options) -// .addOption('class', options.class, (harness, c) => HarnessPredicate.stringMatches(harness.getByClass(c), c)) -// .addOption('id', options.id, (harness, id) => HarnessPredicate.stringMatches(harness.hasId(id), id)) -// } - -// async getByClass(c: string): Promise { -// return (await (await this.host()).hasClass(c)) ? c : '' -// } - -// async hasId(id: string): Promise { -// return (await (await this.host()).matchesSelector('#' + id)) ? id : '' -// } - -// async checkHasClass(value: string) { -// return await (await this.host()).hasClass(value) -// } - -// async getText(): Promise { -// return await (await this.host()).text() -// } - -// async click() { -// if (!(await this.isDisabled())) { -// await (await this.host()).click() -// } else { -// console.warn('Anchor cannot be clicked, because it is disabled!') -// } -// } - -// async isDisabled(): Promise { -// return await (await this.host()).getProperty('disabled') -// } - -// async getClassList() { -// const host = await this.host() -// const attributeString = await host.getAttribute('class') -// if (attributeString) { -// return attributeString.trim().split(' ') -// } -// return [] -// } -// } diff --git a/src/app/remotes/harnesses/i.harness.ts b/src/app/remotes/harnesses/i.harness.ts deleted file mode 100644 index 642bcde..0000000 --- a/src/app/remotes/harnesses/i.harness.ts +++ /dev/null @@ -1,41 +0,0 @@ -// import { BaseHarnessFilters, ComponentHarness, HarnessPredicate } from '@angular/cdk/testing' - -// export interface IHarnessFilters extends BaseHarnessFilters { -// class?: string -// id?: string -// } - -// export class IHarness extends ComponentHarness { -// static hostSelector = 'i' - -// static with(options: IHarnessFilters): HarnessPredicate { -// return new HarnessPredicate(IHarness, options) -// .addOption('class', options.class, (harness, c) => HarnessPredicate.stringMatches(harness.getByClass(c), c)) -// .addOption('id', options.id, (harness, id) => HarnessPredicate.stringMatches(harness.hasId(id), id)) -// } - -// async getByClass(c: string): Promise { -// return (await (await this.host()).hasClass(c)) ? c : '' -// } - -// async hasId(id: string): Promise { -// return (await (await this.host()).matchesSelector('#' + id)) ? id : '' -// } - -// async checkHasClass(value: string) { -// return await (await this.host()).hasClass(value) -// } - -// async getText(): Promise { -// return await (await this.host()).text() -// } - -// async getClassList() { -// const host = await this.host() -// const attributeString = await host.getAttribute('class') -// if (attributeString) { -// return attributeString.trim().split(' ') -// } -// return [] -// } -// } diff --git a/src/app/remotes/harnesses/show-help.harness.ts b/src/app/remotes/harnesses/show-help.harness.ts deleted file mode 100644 index 458236b..0000000 --- a/src/app/remotes/harnesses/show-help.harness.ts +++ /dev/null @@ -1,27 +0,0 @@ -// import { ComponentHarness } from '@angular/cdk/testing' - -// import { AHarness } from './a.harness' -// import { IHarness } from './i.harness' - -// export class ShowHelpRemoteHarness extends ComponentHarness { -// static hostSelector = 'app-ocx-show-help' - -// getHelpButton = this.locatorForOptional(AHarness.with({ id: 'show-help-button' })) -// getHelpIcon = this.locatorForOptional(IHarness.with({ id: 'show-help-button-icon' })) - -// async getHelpButtonTitle(): Promise { -// return (await (await this.getHelpButton())?.host())?.getAttribute('title') -// } - -// async clickHelpButton() { -// await (await this.getHelpButton())?.click() -// } - -// async hasHelpButtonClass(c: string): Promise { -// return (await (await this.getHelpButton())?.getClassList())?.join('').includes(c) -// } - -// async hasHelpIconClass(c: string): Promise { -// return (await (await this.getHelpIcon())?.getClassList())?.join(' ').includes(c) -// } -// } diff --git a/src/app/remotes/service/helpsRemote.service.ts b/src/app/remotes/service/helpsRemote.service.ts deleted file mode 100644 index e7ace7e..0000000 --- a/src/app/remotes/service/helpsRemote.service.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { Injectable } from '@angular/core' -import { HelpsInternalAPIService } from 'src/app/shared/generated' - -@Injectable({ - providedIn: 'any' -}) -export class HelpsRemoteAPIService extends HelpsInternalAPIService {} diff --git a/src/app/remotes/components/no-help-item/no-help-item.component.html b/src/app/remotes/show-help/no-help-item/no-help-item.component.html similarity index 100% rename from src/app/remotes/components/no-help-item/no-help-item.component.html rename to src/app/remotes/show-help/no-help-item/no-help-item.component.html diff --git a/src/app/remotes/components/no-help-item/no-help-item.component.scss b/src/app/remotes/show-help/no-help-item/no-help-item.component.scss similarity index 100% rename from src/app/remotes/components/no-help-item/no-help-item.component.scss rename to src/app/remotes/show-help/no-help-item/no-help-item.component.scss diff --git a/src/app/remotes/components/no-help-item/no-help-item.component.spec.ts b/src/app/remotes/show-help/no-help-item/no-help-item.component.spec.ts similarity index 100% rename from src/app/remotes/components/no-help-item/no-help-item.component.spec.ts rename to src/app/remotes/show-help/no-help-item/no-help-item.component.spec.ts diff --git a/src/app/remotes/components/no-help-item/no-help-item.component.ts b/src/app/remotes/show-help/no-help-item/no-help-item.component.ts similarity index 100% rename from src/app/remotes/components/no-help-item/no-help-item.component.ts rename to src/app/remotes/show-help/no-help-item/no-help-item.component.ts diff --git a/src/app/remotes/harnesses/no-help-item.harness.ts b/src/app/remotes/show-help/no-help-item/no-help-item.harness.ts similarity index 100% rename from src/app/remotes/harnesses/no-help-item.harness.ts rename to src/app/remotes/show-help/no-help-item/no-help-item.harness.ts diff --git a/src/app/remotes/components/show-help/show-help.component.html b/src/app/remotes/show-help/show-help.component.html similarity index 100% rename from src/app/remotes/components/show-help/show-help.component.html rename to src/app/remotes/show-help/show-help.component.html diff --git a/src/app/remotes/components/show-help/show-help.component.scss b/src/app/remotes/show-help/show-help.component.scss similarity index 100% rename from src/app/remotes/components/show-help/show-help.component.scss rename to src/app/remotes/show-help/show-help.component.scss diff --git a/src/app/remotes/components/show-help/show-help.component.spec.ts b/src/app/remotes/show-help/show-help.component.spec.ts similarity index 100% rename from src/app/remotes/components/show-help/show-help.component.spec.ts rename to src/app/remotes/show-help/show-help.component.spec.ts diff --git a/src/app/remotes/components/show-help/show-help.component.ts b/src/app/remotes/show-help/show-help.component.ts similarity index 94% rename from src/app/remotes/components/show-help/show-help.component.ts rename to src/app/remotes/show-help/show-help.component.ts index bb85fb6..47bf911 100644 --- a/src/app/remotes/components/show-help/show-help.component.ts +++ b/src/app/remotes/show-help/show-help.component.ts @@ -17,9 +17,8 @@ import { import { UserService, AppStateService } from '@onecx/angular-integration-interface' import { createRemoteComponentTranslateLoader } from '@onecx/angular-accelerator' import { PortalMessageService, PortalCoreModule } from '@onecx/portal-integration-angular' -import { NoHelpItemComponent } from '../no-help-item/no-help-item.component' -import { Configuration, Help } from 'src/app/shared/generated' -import { HelpsRemoteAPIService } from '../../service/helpsRemote.service' +import { NoHelpItemComponent } from './no-help-item/no-help-item.component' +import { Configuration, Help, HelpsInternalAPIService } from 'src/app/shared/generated' import { environment } from 'src/environments/environment' import { SharedModule } from 'src/app/shared/shared.module' import { Router } from '@angular/router' @@ -39,11 +38,10 @@ import { Router } from '@angular/router' TranslateModule, SharedModule, PortalCoreModule, - AngularRemoteComponentsModule, - SharedModule + AngularRemoteComponentsModule ], providers: [ - HelpsRemoteAPIService, + HelpsInternalAPIService, DialogService, { provide: BASE_URL, @@ -74,7 +72,7 @@ export class OneCXShowHelpComponent implements ocxRemoteComponent { private appStateService: AppStateService, private userService: UserService, private router: Router, - private helpDataService: HelpsRemoteAPIService, + private helpDataService: HelpsInternalAPIService, private dialogService: DialogService, private portalMessageService: PortalMessageService, private translateService: TranslateService diff --git a/src/app/remotes/show-help/show-help.harness.ts b/src/app/remotes/show-help/show-help.harness.ts new file mode 100644 index 0000000..76c8e3a --- /dev/null +++ b/src/app/remotes/show-help/show-help.harness.ts @@ -0,0 +1,25 @@ +// import { ComponentHarness } from '@angular/cdk/testing' + +// export class OneCXShowHelpHarness extends ComponentHarness { +// static hostSelector = 'app-ocx-show-help' + +// getHelpButton = this.locatorForOptional('#show-help-button') +// getHelpIcon = this.locatorForOptional('#show-help-button-icon') + +// async getHelpButtonTitle(): Promise { +// return await (await this.getHelpButton())?.getAttribute('ng-reflect-text') +// // return (await (await this.getHelpButton())?.host())?.getAttribute('title') +// } + +// async clickHelpButton() { +// await (await this.getHelpButton())?.click() +// } + +// async hasHelpButtonClass(c: string): Promise { +// return (await (await this.getHelpButton())?.getAttribute('class'))?.includes(c) +// } + +// async hasHelpIconClass(c: string): Promise { +// return (await (await this.getHelpIcon())?.getAttribute('class'))?.includes(c) +// } +// } diff --git a/tsconfig.app.json b/tsconfig.app.json index 9d26765..e3901fb 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -11,7 +11,7 @@ "src/main.ts", "src/polyfills.ts", "src/app/onecx-help-remote.module.ts", - "src/app/remotes/components/show-help/show-help.component.ts" + "src/app/remotes/show-help/show-help.component.ts" ], "include": ["src/**/*.ts", "src/**/*.d.ts"], "exclude": ["src/test.ts", "src/test-setup.ts", "src/**/*.spec.ts", "src/**/*.stories.ts", "src/**/*.stories.js"] diff --git a/webpack.config.js b/webpack.config.js index 2647b32..de294b6 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -6,7 +6,7 @@ const config = withModuleFederationPlugin({ filename: 'remoteEntry.js', exposes: { './OneCXHelpModule': 'src/app/onecx-help-remote.module.ts', - './OneCXShowHelpComponent': 'src/app/remotes/components/show-help/show-help.component.ts' + './OneCXShowHelpComponent': 'src/app/remotes/show-help/show-help.component.ts' }, shared: share({ '@angular/core': { singleton: true, requiredVersion: 'auto' },