-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Filter system host when is isRequired (#28931)
If a host/folder field is marked as required, then we do not allow/show SYSTEM_HOST ### Proposed Changes * Add isRequired attr to enable filter ### Checklist - [x] Tests - [x] Translations - [x] Security Implications Contemplated (add notes if applicable)
- Loading branch information
Showing
7 changed files
with
104 additions
and
26 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
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
47 changes: 47 additions & 0 deletions
47
...content/src/lib/fields/dot-edit-content-host-folder-field/store/methods/loadSites.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,47 @@ | ||
import { SpyObject, createSpyObject } from '@ngneat/spectator/jest'; | ||
import { signalStore, withState } from '@ngrx/signals'; | ||
import { of } from 'rxjs'; | ||
|
||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { loadSites, SYSTEM_HOST_NAME } from './loadSites'; | ||
|
||
import { DotEditContentService } from '../../../../services/dot-edit-content.service'; | ||
import { TREE_SELECT_SITES_MOCK } from '../../../../utils/mocks'; | ||
import { initialState } from '../host-folder-field.store'; | ||
|
||
describe('rxMethod: loadSites', () => { | ||
let Store = signalStore(withState(initialState)); | ||
let store: InstanceType<typeof Store>; | ||
let service: SpyObject<DotEditContentService>; | ||
|
||
beforeEach(() => { | ||
service = createSpyObject(DotEditContentService); | ||
Store = signalStore(withState(initialState)); | ||
store = new Store(); | ||
}); | ||
|
||
it('should include System Host when isRequired is false.', () => { | ||
service.getSitesTreePath.mockReturnValue(of(TREE_SELECT_SITES_MOCK)); | ||
const rxMethod = TestBed.runInInjectionContext(() => loadSites(store, service)); | ||
const props = { | ||
path: '', | ||
isRequired: false | ||
}; | ||
rxMethod(props); | ||
const hasSystemHost = store.tree().some((item) => item.label === SYSTEM_HOST_NAME); | ||
expect(hasSystemHost).toBe(true); | ||
}); | ||
|
||
it('should not include System Host when isRequired is true.', () => { | ||
service.getSitesTreePath.mockReturnValue(of(TREE_SELECT_SITES_MOCK)); | ||
const rxMethod = TestBed.runInInjectionContext(() => loadSites(store, service)); | ||
const props = { | ||
path: '', | ||
isRequired: true | ||
}; | ||
rxMethod(props); | ||
const hasSystemHost = store.tree().some((item) => item.label === SYSTEM_HOST_NAME); | ||
expect(hasSystemHost).toBe(false); | ||
}); | ||
}); |
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
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