mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
ACS-8639 - [ACC ]Adding a space to the front/end of a tag name during tag creation removes the 'Tag already exists' validation message (#10138)
This commit is contained in:
parent
158baa7cc9
commit
18d81f6307
lib/content-services/src/lib/tag/tags-creator
@ -28,7 +28,7 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { HarnessLoader } from '@angular/cdk/testing';
|
||||
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
|
||||
import { MatProgressSpinnerHarness } from '@angular/material/progress-spinner/testing';
|
||||
import { MatChipOptionHarness } from '@angular/material/chips/testing';
|
||||
import { MatChipHarness } from '@angular/material/chips/testing';
|
||||
|
||||
describe('TagsCreatorComponent', () => {
|
||||
let fixture: ComponentFixture<TagsCreatorComponent>;
|
||||
@ -105,7 +105,7 @@ describe('TagsCreatorComponent', () => {
|
||||
* @returns list of tags
|
||||
*/
|
||||
async function getAddedTags(): Promise<string[]> {
|
||||
const matChipHarness = await loader.getAllHarnesses(MatChipOptionHarness.with({ selector: '.adf-tags-chip' }));
|
||||
const matChipHarness = await loader.getAllHarnesses(MatChipHarness.with({ selector: '.adf-tags-chip' }));
|
||||
const tagElements = [];
|
||||
for (const matChip of matChipHarness) {
|
||||
tagElements.push(await matChip.getText());
|
||||
@ -400,6 +400,23 @@ describe('TagsCreatorComponent', () => {
|
||||
expect(error).toBe('TAG.TAGS_CREATOR.ERRORS.EXISTING_TAG');
|
||||
}));
|
||||
|
||||
it('should show error when duplicated already existing tag with spaces', fakeAsync(() => {
|
||||
const tag = 'Some tag';
|
||||
|
||||
spyOn(tagService, 'findTagByName').and.returnValue(
|
||||
of({
|
||||
entry: {
|
||||
tag,
|
||||
id: 'tag-1'
|
||||
}
|
||||
})
|
||||
);
|
||||
typeTag(tag + ' ');
|
||||
|
||||
const error = getFirstError();
|
||||
expect(error).toBe('TAG.TAGS_CREATOR.ERRORS.EXISTING_TAG');
|
||||
}));
|
||||
|
||||
it('should show error when deleting other Tag1 and Tag2 is typed and already existing tag', fakeAsync(() => {
|
||||
const tag1 = 'Some tag';
|
||||
const tag2 = 'Other tag';
|
||||
|
@ -182,7 +182,13 @@ export class TagsCreatorComponent implements OnInit, OnDestroy {
|
||||
this.tagNameControl.valueChanges
|
||||
.pipe(
|
||||
map((name: string) => name.trim()),
|
||||
distinctUntilChanged(),
|
||||
distinctUntilChanged((previous, current) => {
|
||||
const valueNotChanged = previous === current;
|
||||
if (valueNotChanged) {
|
||||
this.exactTagSet$.next();
|
||||
}
|
||||
return valueNotChanged;
|
||||
}),
|
||||
tap((name: string) => {
|
||||
this._typing = true;
|
||||
if (name) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user