-
Notifications
You must be signed in to change notification settings - Fork 3
SED-4412 create jest tests for base components #1300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dvladir
wants to merge
33
commits into
master
Choose a base branch
from
SED-4412-create-jest-tests-for-base-components
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
3e00a17
SED-4412 step-icon tests
dvladir dd8f0a1
SED-4412 step-tabs tests
dvladir 0e13014
SED-4412 Trace viewer tests
dvladir 604704a
SED-4412 Errors-list and form field tests
dvladir 2f0149a
SED-4412 Progress bar
dvladir 6bc63c0
SED-4412 Key value component
dvladir 0b4c43a
SED-4412 key-value-inline tests
dvladir bea1757
SED-4412 Pretty print tests
dvladir c83aea8
SED-4412 select tests
dvladir a991f52
SED-4412 Select component tests
dvladir 0647922
Merge branch 'master' into SED-4412-create-jest-tests-for-base-compon…
dvladir ae2021f
SED-4412 Artefact Inline Details header tests
dvladir 1a2a031
SED-4412 Streaming Attachment Indicator component
dvladir bae5a12
SED-4412 AutoShrinkItemValueComponent tests
dvladir 4aa73d9
SED-4412 Cron based components
dvladir c8b959b
SED-4412 Cron unit tests
dvladir f8e4485
SED-4412 Popover component tests
dvladir d4c3c60
Merge branch 'master' into SED-4412-create-jest-tests-for-base-compon…
dvladir 5461995
SED-4412 Custom item renderer
dvladir 41d5ea1
SED-4412 Relative Time Picker
dvladir 3b4ee16
SED-4412 Array Input Component tests
dvladir 7b8e309
SED-4412 Autocomplete input tests
dvladir d0938b7
SED-4412 Preset editor test
dvladir cc50e0e
SED-4412 Editable actions component test
dvladir 55dfb98
SED-4412 Add Field Button component
dvladir 515754f
SED-4412 Resource label component tests
dvladir e514a56
SED-4412 Automation package info tests
dvladir cef0b20
Merge branch 'master' into SED-4412-create-jest-tests-for-base-compon…
dvladir d8526fa
SED-4412 Fix exports
dvladir 91101b4
Merge branch 'master' into SED-4412-create-jest-tests-for-base-compon…
neogucky db00eae
Apply suggestion from @neogucky
neogucky c59ae21
Merge branch 'master' into SED-4412-create-jest-tests-for-base-compon…
neogucky 4b62926
SED-4412 Added some timeouts
neogucky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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
43 changes: 43 additions & 0 deletions
43
...omponents/artefact-inline-details-header/artefact-inline-details-header.component.test.ts
This file contains hidden or 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 { Component, signal } from '@angular/core'; | ||
| import { ArtefactInlineDetailsHeaderComponent } from '@exense/step-core'; | ||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
| import { By } from '@angular/platform-browser'; | ||
|
|
||
| @Component({ | ||
| selector: 'step-artefact-inline-details-header-test', | ||
| imports: [ArtefactInlineDetailsHeaderComponent], | ||
| template: ` | ||
| <step-artefact-inline-details-header [template]="foo" [isVisible]="isVisible()" /> | ||
| <ng-template #foo> | ||
| <div class="testDiv">FOO</div> | ||
| </ng-template> | ||
| `, | ||
| }) | ||
| class ArtefactInlineDetailsHeaderTestComponent { | ||
| readonly isVisible = signal(false); | ||
| } | ||
|
|
||
| describe('ArtefactInlineDetailsHeader', () => { | ||
| let fixture: ComponentFixture<ArtefactInlineDetailsHeaderTestComponent>; | ||
|
|
||
| beforeEach(async () => { | ||
| await TestBed.configureTestingModule({ imports: [ArtefactInlineDetailsHeaderTestComponent] }).compileComponents(); | ||
|
|
||
| fixture = TestBed.createComponent(ArtefactInlineDetailsHeaderTestComponent); | ||
| fixture.detectChanges(); | ||
| await fixture.whenStable(); | ||
| }); | ||
|
|
||
| it('Content visibility', async () => { | ||
| let content = fixture.debugElement.query(By.css('.testDiv')); | ||
| expect(content).toBeNull(); | ||
|
|
||
| fixture.componentInstance.isVisible.set(true); | ||
| fixture.detectChanges(); | ||
| await fixture.whenStable(); | ||
|
|
||
| content = fixture.debugElement.query(By.css('.testDiv')); | ||
| expect(content).not.toBeNull(); | ||
| expect((content.nativeElement as HTMLElement).textContent).toBe('FOO'); | ||
| }); | ||
| }); |
78 changes: 78 additions & 0 deletions
78
...omponents/streaming-attachment-indicator/streaming-attachment-indicator.component.test.ts
This file contains hidden or 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,78 @@ | ||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
| import { | ||
| AttachmentMeta, | ||
| AugmentedResourcesService, | ||
| StreamingAttachmentIndicatorComponent, | ||
| StreamingAttachmentMeta, | ||
| } from '@exense/step-core'; | ||
| import { v4 } from 'uuid'; | ||
| import { By } from '@angular/platform-browser'; | ||
| import { MatProgressSpinner } from '@angular/material/progress-spinner'; | ||
| import { AugmentedStreamingResourcesService } from '../../../../client/augmented/services/augmented-streaming-resources.service'; | ||
|
|
||
| const SIMPLE_ATTACHMENT: AttachmentMeta = { | ||
| name: 'test.jpg', | ||
| mimeType: 'image/jpeg', | ||
| type: 'step.attachment.AttachmentMeta', | ||
| id: v4(), | ||
| }; | ||
|
|
||
| const STREAMING_ATTACHMENT: StreamingAttachmentMeta = { | ||
| name: 'test.txt', | ||
| mimeType: 'plain/text', | ||
| type: 'step.attachments.StreamingAttachmentMeta', | ||
| id: v4(), | ||
| currentNumberOfLines: 10, | ||
| status: 'INITIATED', | ||
| }; | ||
|
|
||
| const IN_PROGRESS_STREAMING_ATTACHMENT: StreamingAttachmentMeta = { | ||
| ...STREAMING_ATTACHMENT, | ||
| status: 'IN_PROGRESS', | ||
| }; | ||
|
|
||
| describe('StreamingAttachmentIndicatorComponent', () => { | ||
| let fixture: ComponentFixture<StreamingAttachmentIndicatorComponent>; | ||
|
|
||
| beforeEach(async () => { | ||
| await TestBed.configureTestingModule({ | ||
| imports: [StreamingAttachmentIndicatorComponent], | ||
| providers: [ | ||
| { | ||
| provide: AugmentedResourcesService, | ||
| useValue: null, | ||
| }, | ||
| { | ||
| provide: AugmentedStreamingResourcesService, | ||
| useValue: null, | ||
| }, | ||
| ], | ||
| }).compileComponents(); | ||
| fixture = TestBed.createComponent(StreamingAttachmentIndicatorComponent); | ||
| fixture.detectChanges(); | ||
| await fixture.whenStable(); | ||
| }); | ||
|
|
||
| it('Check indicator visibility', async () => { | ||
| let indicator = fixture.debugElement.query(By.directive(MatProgressSpinner)); | ||
| expect(indicator).toBeNull(); | ||
|
|
||
| fixture.componentRef.setInput('attachment', SIMPLE_ATTACHMENT); | ||
| fixture.detectChanges(); | ||
| await fixture.whenStable(); | ||
| indicator = fixture.debugElement.query(By.directive(MatProgressSpinner)); | ||
| expect(indicator).toBeNull(); | ||
|
|
||
| fixture.componentRef.setInput('attachment', STREAMING_ATTACHMENT); | ||
| fixture.detectChanges(); | ||
| await fixture.whenStable(); | ||
| indicator = fixture.debugElement.query(By.directive(MatProgressSpinner)); | ||
| expect(indicator).toBeNull(); | ||
|
|
||
| fixture.componentRef.setInput('attachment', IN_PROGRESS_STREAMING_ATTACHMENT); | ||
| fixture.detectChanges(); | ||
| await fixture.whenStable(); | ||
| indicator = fixture.debugElement.query(By.directive(MatProgressSpinner)); | ||
| expect(indicator).not.toBeNull(); | ||
| }); | ||
| }); |
56 changes: 56 additions & 0 deletions
56
...p-core/src/lib/modules/attachments/components/trace-viewer/trace-viewer.component.test.ts
This file contains hidden or 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,56 @@ | ||
| import { TraceViewerComponent } from './trace-viewer.component'; | ||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
| import { APP_HOST } from '../../../../client/_common'; | ||
| import { By } from '@angular/platform-browser'; | ||
| import { ComponentRef } from '@angular/core'; | ||
| import { DOCUMENT } from '@angular/common'; | ||
|
|
||
| describe('Trace Viewer', () => { | ||
| let componentRef: ComponentRef<TraceViewerComponent>; | ||
| let fixture: ComponentFixture<TraceViewerComponent>; | ||
|
|
||
| beforeEach(async () => { | ||
| await TestBed.configureTestingModule({ | ||
| imports: [TraceViewerComponent], | ||
| providers: [ | ||
| { | ||
| provide: APP_HOST, | ||
| useValue: 'https://step.ch', | ||
| }, | ||
| ], | ||
| }).compileComponents(); | ||
|
|
||
| fixture = TestBed.createComponent(TraceViewerComponent); | ||
| componentRef = fixture.componentRef; | ||
| fixture.detectChanges(); | ||
| }); | ||
|
|
||
| it('Initial view', async () => { | ||
| const iframe = fixture.debugElement.query(By.css('iframe')); | ||
| expect(iframe.nativeElement.src).toEqual('https://step.ch/trace-viewer/'); | ||
| }); | ||
|
|
||
| it('Set report url', async () => { | ||
| componentRef.setInput('reportUrl', 'https://step.ch/reports/1'); | ||
| fixture.detectChanges(); | ||
| await fixture.whenStable(); | ||
| const iframe = fixture.debugElement.query(By.css('iframe')); | ||
| expect(iframe.nativeElement.src).toEqual('https://step.ch/trace-viewer/?trace=https://step.ch/reports/1'); | ||
| }); | ||
|
|
||
| it('Oper url', async () => { | ||
| componentRef.setInput('reportUrl', 'https://step.ch/reports/1'); | ||
| fixture.detectChanges(); | ||
| await fixture.whenStable(); | ||
|
|
||
| const doc = TestBed.inject(DOCUMENT); | ||
| const spyWindowOpen = jest.spyOn(doc.defaultView!, 'open').mockImplementation(() => {}); | ||
|
|
||
| expect(spyWindowOpen).not.toHaveBeenCalled(); | ||
| componentRef.instance.openInSeparateTab(); | ||
| expect(spyWindowOpen).toHaveBeenCalledWith( | ||
| 'https://step.ch/trace-viewer/?trace=https://step.ch/reports/1', | ||
| '_blank', | ||
| ); | ||
| }); | ||
| }); |
74 changes: 74 additions & 0 deletions
74
...to-shrink-list/components/auto-shrink-item-value/auto-shrink-item-value.component.test.ts
This file contains hidden or 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,74 @@ | ||
| import { Component, Directive, signal } from '@angular/core'; | ||
| import { KeyValue } from '@angular/common'; | ||
| import { AutoShrinkItemValueComponent } from '@exense/step-core'; | ||
| import { TestBed } from '@angular/core/testing'; | ||
| import { By } from '@angular/platform-browser'; | ||
|
|
||
| @Directive() | ||
| abstract class AutoShrinkItemValueBaseComponent { | ||
| readonly item = signal<KeyValue<string, string>>({ key: '', value: '' }); | ||
| } | ||
|
|
||
| @Component({ | ||
| selector: 'step-auto-shrink-item-value-without-template-test', | ||
| imports: [AutoShrinkItemValueComponent], | ||
| template: ` | ||
| @if (item(); as item) { | ||
| <step-auto-shrink-item-value [item]="item" /> | ||
| } | ||
| `, | ||
| }) | ||
| class AutoShrinkItemValueWithoutTemplateComponent extends AutoShrinkItemValueBaseComponent {} | ||
|
|
||
| @Component({ | ||
| selector: 'step-auto-shrink-item-value-with-template-test', | ||
| imports: [AutoShrinkItemValueComponent], | ||
| template: ` | ||
| @if (item(); as item) { | ||
| <step-auto-shrink-item-value [item]="item" [emptyValueTemplate]="test" /> | ||
| } | ||
| <ng-template #test> | ||
| <div class="test">EMPTY</div> | ||
| </ng-template> | ||
| `, | ||
| }) | ||
| class AutoShrinkItemValueWithTemplateComponent extends AutoShrinkItemValueBaseComponent {} | ||
|
|
||
| describe('AutoShrinkItemValueComponent', () => { | ||
| beforeEach(async () => { | ||
| await TestBed.configureTestingModule({ | ||
| imports: [AutoShrinkItemValueWithoutTemplateComponent, AutoShrinkItemValueWithTemplateComponent], | ||
| }).compileComponents(); | ||
| }); | ||
|
|
||
| it('Without empty template', async () => { | ||
| let fixture = TestBed.createComponent(AutoShrinkItemValueWithoutTemplateComponent); | ||
| fixture.detectChanges(); | ||
| await fixture.whenStable(); | ||
|
|
||
| expect((fixture.nativeElement as HTMLElement).innerText.trim()).toBe(''); | ||
| fixture.componentInstance.item.set({ key: 'foo', value: 'FOO' }); | ||
| fixture.detectChanges(); | ||
| await fixture.whenStable(); | ||
|
|
||
| expect((fixture.nativeElement as HTMLElement).innerText.trim()).toBe('FOO'); | ||
| }); | ||
|
|
||
| it('With empty template', async () => { | ||
| let fixture = TestBed.createComponent(AutoShrinkItemValueWithTemplateComponent); | ||
| fixture.detectChanges(); | ||
| await fixture.whenStable(); | ||
|
|
||
| let emptyContainer = fixture.debugElement.query(By.css('.test')); | ||
| expect(emptyContainer).not.toBeNull(); | ||
| expect((emptyContainer.nativeElement as HTMLElement).innerText).toBe('EMPTY'); | ||
|
|
||
| fixture.componentInstance.item.set({ key: 'foo', value: 'FOO' }); | ||
| fixture.detectChanges(); | ||
| await fixture.whenStable(); | ||
|
|
||
| emptyContainer = fixture.debugElement.query(By.css('.test')); | ||
| expect(emptyContainer).toBeNull(); | ||
| expect((fixture.nativeElement as HTMLElement).innerText.trim()).toBe('FOO'); | ||
| }); | ||
| }); |
4 changes: 1 addition & 3 deletions
4
...-package-common/components/automation-package-info/automation-package-info.component.html
This file contains hidden or 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,3 +1 @@ | ||
| <div> | ||
| {{(automationPackage$ | async)?.attributes?.['name'] ?? ''}} | ||
| </div> | ||
| <div>{{ (automationPackage$ | async)?.attributes?.['name'] ?? '' }}</div> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new devDependency entry is missing a trailing comma, so the file is no longer valid JSON. This will cause
npm install/npm cito fail to parsepackage.json, blocking dependency installation and any scripts that read it.Useful? React with 👍 / 👎.