forked from onecx/onecx-portal-ui-libs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: menu harnesses enhancements (onecx#260)
* feat: menu harnesses enchanced * feat: removed external check from harnesses * feat: further menu harness enchancements
- Loading branch information
Showing
10 changed files
with
112 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
libs/angular-testing/src/lib/harnesses/menu-item-with-icon.harness.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { MenuItemHarness } from './menu-item.harness' | ||
|
||
export class MenuItemWithIconHarness extends MenuItemHarness { | ||
async hasIcon(icon: string): Promise<boolean | undefined> { | ||
const classList = await (await this.locatorForOptional('i')())?.getAttribute('class') | ||
return classList?.includes(icon) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
libs/angular-testing/src/lib/harnesses/primeng/p-accordion-tab.harness.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { ComponentHarness } from '@angular/cdk/testing' | ||
|
||
export class PAccordionTabHarness extends ComponentHarness { | ||
static hostSelector = 'p-accordiontab' | ||
|
||
getButton = this.locatorFor('a.p-accordion-header-link') | ||
|
||
async expand() { | ||
await (await this.getButton()).click() | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
libs/angular-testing/src/lib/harnesses/primeng/p-accordion.harness.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ComponentHarness } from '@angular/cdk/testing' | ||
import { PAccordionTabHarness } from './p-accordion-tab.harness' | ||
|
||
export class PAccordionHarness extends ComponentHarness { | ||
static hostSelector = 'p-accordion' | ||
|
||
getAllAccordionTabs = this.locatorForAll(PAccordionTabHarness) | ||
} |
27 changes: 27 additions & 0 deletions
27
libs/angular-testing/src/lib/harnesses/primeng/p-menu-item.harness.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { ComponentHarness } from '@angular/cdk/testing' | ||
import { SpanHarness } from '../span.harness' | ||
|
||
export class PMenuItemHarness extends ComponentHarness { | ||
static hostSelector = 'li.p-menuitem' | ||
|
||
getAnchor = this.locatorFor('a') | ||
getChildren = this.locatorForAll(PMenuItemHarness) | ||
getIconSpan = this.locatorForOptional(SpanHarness.with({ class: 'p-menuitem-icon' })) | ||
|
||
async getText(): Promise<string> { | ||
return await (await this.getAnchor()).text() | ||
} | ||
|
||
async hasIcon(icon: string): Promise<boolean | undefined> { | ||
const classList = await (await (await this.getIconSpan())?.host())?.getAttribute('class') | ||
return classList?.includes(icon) | ||
} | ||
|
||
async click() { | ||
return await (await this.getAnchor()).click() | ||
} | ||
|
||
async getLink(): Promise<string | null> { | ||
return await (await this.getAnchor()).getAttribute('href') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
libs/angular-testing/src/lib/harnesses/primeng/p-menubar.harness.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ComponentHarness } from '@angular/cdk/testing' | ||
import { PMenuItemHarness } from './p-menu-item.harness' | ||
|
||
export class PMenuBarHarness extends ComponentHarness { | ||
static hostSelector = 'p-menubar' | ||
|
||
getAllMenuItems = this.locatorForAll(PMenuItemHarness) | ||
} |
28 changes: 28 additions & 0 deletions
28
libs/angular-testing/src/lib/harnesses/primeng/p-panelmenu-item.harness.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { ComponentHarness } from '@angular/cdk/testing' | ||
import { SpanHarness } from '../span.harness' | ||
import { PMenuItemHarness } from './p-menu-item.harness' | ||
|
||
export class PanelMenuItemHarness extends ComponentHarness { | ||
static hostSelector = 'div.p-panelmenu-panel' | ||
|
||
getAnchor = this.locatorFor('a') | ||
getChildren = this.locatorForAll(PMenuItemHarness) | ||
getIconSpan = this.locatorForOptional(SpanHarness.with({ class: 'p-menuitem-icon' })) | ||
|
||
async getText(): Promise<string> { | ||
return await (await this.getAnchor()).text() | ||
} | ||
|
||
async hasIcon(icon: string): Promise<boolean | undefined> { | ||
const classList = await (await (await this.getIconSpan())?.host())?.getAttribute('class') | ||
return classList?.includes(icon) | ||
} | ||
|
||
async click() { | ||
await (await this.getAnchor()).click() | ||
} | ||
|
||
async getLink(): Promise<string | null> { | ||
return await (await this.getAnchor()).getAttribute('href') | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
libs/angular-testing/src/lib/harnesses/primeng/p-panelmenu.harness.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ComponentHarness } from '@angular/cdk/testing' | ||
import { PanelMenuItemHarness } from './p-panelmenu-item.harness' | ||
|
||
export class PPanelMenuHarness extends ComponentHarness { | ||
static hostSelector = 'p-panelmenu' | ||
|
||
getAllPanels = this.locatorForAll(PanelMenuItemHarness) | ||
} |