-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
🍒 Cherry pick from[ #3064 ](#3064) [AB#2195550](https://dev.azure.com/blackbaud/Products/_boards/board/t/SKY%20UX%20Program/Stories/?workitem=2195550) Co-authored-by: Sandhya Raja Sabeson <sandhya.rajasabeson@blackbaud.me>
- Loading branch information
1 parent
4343e0a
commit 37d2e90
Showing
25 changed files
with
962 additions
and
60 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
...de-examples/pages/page/record-page-tabs-layout-demo/record-page-content-component.spec.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,43 @@ | ||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; | ||
import { provideRouter } from '@angular/router'; | ||
import { SkyTabsetHarness } from '@skyux/tabs/testing'; | ||
|
||
import { RecordPageContentComponent } from './record-page-content.component'; | ||
import { RecordPageOverviewTabHarness } from './record-page-overview-tab-harness'; | ||
|
||
describe('Record page content', () => { | ||
async function setupTest(): Promise<{ | ||
recordPageHarness: SkyTabsetHarness; | ||
fixture: ComponentFixture<RecordPageContentComponent>; | ||
}> { | ||
await TestBed.configureTestingModule({ | ||
providers: [provideRouter([])], | ||
}).compileComponents(); | ||
const fixture = TestBed.createComponent(RecordPageContentComponent); | ||
const loader = TestbedHarnessEnvironment.loader(fixture); | ||
|
||
const recordPageHarness = await loader.getHarness(SkyTabsetHarness); | ||
|
||
return { recordPageHarness, fixture }; | ||
} | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [RecordPageContentComponent, NoopAnimationsModule], | ||
}); | ||
}); | ||
|
||
it("should get the overview tab's content harness", async () => { | ||
const { recordPageHarness } = await setupTest(); | ||
|
||
const overviewTabHarness = await ( | ||
await recordPageHarness.getTabContentHarness('Overview') | ||
).queryHarness(RecordPageOverviewTabHarness); | ||
|
||
const overviewBoxes = await overviewTabHarness.getBoxes(); | ||
|
||
expect(overviewBoxes.length).toBe(3); | ||
}); | ||
}); |
10 changes: 10 additions & 0 deletions
10
...code-examples/pages/page/record-page-tabs-layout-demo/record-page-overview-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,10 @@ | ||
import { ComponentHarness } from '@angular/cdk/testing'; | ||
import { SkyBoxHarness } from '@skyux/layout/testing'; | ||
|
||
export class RecordPageOverviewTabHarness extends ComponentHarness { | ||
public static hostSelector = 'app-record-page-overview-tab'; | ||
|
||
public async getBoxes(): Promise<SkyBoxHarness[]> { | ||
return await this.locatorForAll(SkyBoxHarness)(); | ||
} | ||
} |
6 changes: 5 additions & 1 deletion
6
apps/code-examples/src/app/code-examples/tabs/tabs/dynamic-add-close/demo.component.html
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
50 changes: 50 additions & 0 deletions
50
apps/code-examples/src/app/code-examples/tabs/tabs/dynamic-add-close/demo.component.spec.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,50 @@ | ||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { provideRouter } from '@angular/router'; | ||
import { SkyTabsetHarness } from '@skyux/tabs/testing'; | ||
|
||
import { DemoComponent } from './demo.component'; | ||
|
||
describe('Static tabs demo with add and close', () => { | ||
async function setupTest(options: { dataSkyId?: string }): Promise<{ | ||
harness: SkyTabsetHarness; | ||
fixture: ComponentFixture<DemoComponent>; | ||
}> { | ||
await TestBed.configureTestingModule({ | ||
providers: [provideRouter([])], | ||
}).compileComponents(); | ||
const fixture = TestBed.createComponent(DemoComponent); | ||
const loader = TestbedHarnessEnvironment.loader(fixture); | ||
|
||
const harness = await loader.getHarness( | ||
SkyTabsetHarness.with({ dataSkyId: options.dataSkyId }), | ||
); | ||
|
||
return { harness, fixture }; | ||
} | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ imports: [DemoComponent] }); | ||
}); | ||
|
||
it('should set up tabs', async () => { | ||
const { harness } = await setupTest({ dataSkyId: 'tab-demo' }); | ||
|
||
await harness.clickNewTabButton(); | ||
const tabButtonHarnesses = await harness.getTabButtonHarnesses(); | ||
expect(tabButtonHarnesses.length).toBe(4); | ||
|
||
const activeTab = await harness.getActiveTabButton(); | ||
await expectAsync(activeTab?.getTabHeading()).toBeResolvedTo('Tab 1'); | ||
}); | ||
|
||
it('should hide Tab 3 if it is closed', async () => { | ||
const { harness } = await setupTest({ dataSkyId: 'tab-demo' }); | ||
|
||
const tab3Harness = await harness.getTabButtonHarness('Tab 3'); | ||
await tab3Harness.clickRemoveButton(); | ||
|
||
const tabButtons = await harness.getTabButtonHarnesses(); | ||
expect(tabButtons.length).toBe(2); | ||
}); | ||
}); |
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
2 changes: 1 addition & 1 deletion
2
apps/code-examples/src/app/code-examples/tabs/tabs/dynamic/demo.component.html
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
39 changes: 39 additions & 0 deletions
39
apps/code-examples/src/app/code-examples/tabs/tabs/dynamic/demo.component.spec.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,39 @@ | ||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { provideRouter } from '@angular/router'; | ||
import { SkyTabsetHarness } from '@skyux/tabs/testing'; | ||
|
||
import { DemoComponent } from './demo.component'; | ||
|
||
describe('Static tabs demo with add and close', () => { | ||
async function setupTest(options: { dataSkyId?: string }): Promise<{ | ||
harness: SkyTabsetHarness; | ||
fixture: ComponentFixture<DemoComponent>; | ||
}> { | ||
await TestBed.configureTestingModule({ | ||
providers: [provideRouter([])], | ||
}).compileComponents(); | ||
const fixture = TestBed.createComponent(DemoComponent); | ||
const loader = TestbedHarnessEnvironment.loader(fixture); | ||
|
||
const harness = await loader.getHarness( | ||
SkyTabsetHarness.with({ dataSkyId: options.dataSkyId }), | ||
); | ||
|
||
return { harness, fixture }; | ||
} | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ imports: [DemoComponent] }); | ||
}); | ||
|
||
it('should set up tabs', async () => { | ||
const { harness } = await setupTest({ dataSkyId: 'tab-demo' }); | ||
|
||
const tabButtonHarnesses = await harness.getTabButtonHarnesses(); | ||
expect(tabButtonHarnesses.length).toBe(3); | ||
|
||
const activeTab = await harness.getActiveTabButton(); | ||
await expectAsync(activeTab?.getTabHeading()).toBeResolvedTo('Tab 1'); | ||
}); | ||
}); |
6 changes: 5 additions & 1 deletion
6
apps/code-examples/src/app/code-examples/tabs/tabs/static-add-close/demo.component.html
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
54 changes: 54 additions & 0 deletions
54
apps/code-examples/src/app/code-examples/tabs/tabs/static-add-close/demo.component.spec.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,54 @@ | ||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { provideRouter } from '@angular/router'; | ||
import { SkyTabsetHarness } from '@skyux/tabs/testing'; | ||
|
||
import { DemoComponent } from './demo.component'; | ||
|
||
describe('Static tabs demo with add and close', () => { | ||
async function setupTest(options: { dataSkyId?: string }): Promise<{ | ||
harness: SkyTabsetHarness; | ||
fixture: ComponentFixture<DemoComponent>; | ||
}> { | ||
await TestBed.configureTestingModule({ | ||
providers: [provideRouter([])], | ||
}).compileComponents(); | ||
const fixture = TestBed.createComponent(DemoComponent); | ||
const loader = TestbedHarnessEnvironment.loader(fixture); | ||
|
||
const harness = await loader.getHarness( | ||
SkyTabsetHarness.with({ dataSkyId: options.dataSkyId }), | ||
); | ||
|
||
return { harness, fixture }; | ||
} | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ imports: [DemoComponent] }); | ||
}); | ||
|
||
it('should set up tabs', async () => { | ||
const { harness, fixture } = await setupTest({ dataSkyId: 'tab-demo' }); | ||
|
||
const spy = spyOn(fixture.componentInstance, 'onNewTabClick'); | ||
await harness.clickNewTabButton(); | ||
|
||
expect(spy).toHaveBeenCalled(); | ||
|
||
const tabButtonHarnesses = await harness.getTabButtonHarnesses(); | ||
expect(tabButtonHarnesses.length).toBe(3); | ||
|
||
const activeTab = await harness.getActiveTabButton(); | ||
await expectAsync(activeTab?.getTabHeading()).toBeResolvedTo('Tab 1'); | ||
}); | ||
|
||
it('should hide Tab 3 if it is closed', async () => { | ||
const { harness } = await setupTest({ dataSkyId: 'tab-demo' }); | ||
|
||
const tab3Harness = await harness.getTabButtonHarness('Tab 3'); | ||
await tab3Harness.clickRemoveButton(); | ||
|
||
const tabButtons = await harness.getTabButtonHarnesses(); | ||
expect(tabButtons.length).toBe(2); | ||
}); | ||
}); |
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
2 changes: 1 addition & 1 deletion
2
apps/code-examples/src/app/code-examples/tabs/tabs/static/demo.component.html
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
39 changes: 39 additions & 0 deletions
39
apps/code-examples/src/app/code-examples/tabs/tabs/static/demo.component.spec.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,39 @@ | ||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { provideRouter } from '@angular/router'; | ||
import { SkyTabsetHarness } from '@skyux/tabs/testing'; | ||
|
||
import { DemoComponent } from './demo.component'; | ||
|
||
describe('Static tabs demo with add and close', () => { | ||
async function setupTest(options: { dataSkyId?: string }): Promise<{ | ||
harness: SkyTabsetHarness; | ||
fixture: ComponentFixture<DemoComponent>; | ||
}> { | ||
await TestBed.configureTestingModule({ | ||
providers: [provideRouter([])], | ||
}).compileComponents(); | ||
const fixture = TestBed.createComponent(DemoComponent); | ||
const loader = TestbedHarnessEnvironment.loader(fixture); | ||
|
||
const harness = await loader.getHarness( | ||
SkyTabsetHarness.with({ dataSkyId: options.dataSkyId }), | ||
); | ||
|
||
return { harness, fixture }; | ||
} | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ imports: [DemoComponent] }); | ||
}); | ||
|
||
it('should set up tabs', async () => { | ||
const { harness } = await setupTest({ dataSkyId: 'tab-demo' }); | ||
|
||
const tabButtonHarnesses = await harness.getTabButtonHarnesses(); | ||
expect(tabButtonHarnesses.length).toBe(3); | ||
|
||
const activeTab = await harness.getActiveTabButton(); | ||
await expectAsync(activeTab?.getTabHeading()).toBeResolvedTo('Tab 1'); | ||
}); | ||
}); |
58 changes: 11 additions & 47 deletions
58
apps/playground/src/app/components/tabs/tabs/tabs.component.html
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 |
---|---|---|
@@ -1,47 +1,11 @@ | ||
<sky-page> | ||
<div id="screenshot-tabset" style="height: 200px"> | ||
<sky-tabset | ||
permalinkId="sample" | ||
[active]="1" | ||
(newTab)="newTabClick()" | ||
(openTab)="openTabClick()" | ||
> | ||
<sky-tab [disabled]="true" [tabHeading]="'Tab 1'" (close)="closeTab()"> | ||
Tab 1 Content | ||
</sky-tab> | ||
<sky-tab [tabHeading]="'Tab 2'" (close)="closeTab()"> | ||
Tab 2 Content | ||
</sky-tab> | ||
<sky-tab [tabHeading]="'Tab 3'" (close)="closeTab()"> | ||
Tab 3 Content | ||
</sky-tab> | ||
<sky-tab [tabHeading]="'Tab 4'" (close)="closeTab()"> | ||
Tab 4 Content | ||
</sky-tab> | ||
<sky-tab tabHeading="Permanent tab" [tabHeaderCount]="9"> | ||
This tab cannot be closed | ||
</sky-tab> | ||
<sky-tab | ||
permalinkValue="foobar" | ||
tabHeading="Tab 3" | ||
[tabHeaderCount]="144" | ||
(close)="closeTab()" | ||
> | ||
Tab 3 Content | ||
</sky-tab> | ||
</sky-tabset> | ||
</div> | ||
|
||
<div id="screenshot-tabset-long" style="margin-top: 300px; height: 200px"> | ||
<sky-tabset [active]="0"> | ||
<sky-tab | ||
[tabHeading]=" | ||
'Tab 1 Content really really really long tab name you know here is even more header content okay okay okay' | ||
" | ||
> | ||
Tab 1 Content | ||
</sky-tab> | ||
<sky-tab [tabHeading]="'Tab 2'"> Tab 2 Content </sky-tab> | ||
</sky-tabset> | ||
</div> | ||
</sky-page> | ||
<sky-tabset ariaLabel="Tab demonstration" (newTab)="onNewTabClick()"> | ||
<sky-tab [tabHeading]="'Tab 1'" [tabIndexValue]="tabIndexValue"> | ||
Content for Tab 1</sky-tab | ||
> | ||
<sky-tab [tabHeading]="'Tab 2'"> Content for Tab 2 </sky-tab> | ||
@if (showTab3) { | ||
<sky-tab [tabHeading]="'Tab 3'" (close)="showTab3 = false"> | ||
Content for Tab 3 | ||
</sky-tab> | ||
} | ||
</sky-tabset> |
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
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
Oops, something went wrong.