123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- import {OrganizationFixture} from 'sentry-fixture/organization';
- import TagStore from 'sentry/stores/tagStore';
- describe('TagStore', function () {
- beforeEach(() => {
- TagStore.reset();
- });
- afterEach(() => {});
- describe('loadTagsSuccess()', () => {
- it('should add a new tag with empty values and trigger the new addition', () => {
- jest.spyOn(TagStore, 'trigger');
- TagStore.loadTagsSuccess([
- {
- key: 'mytag',
- name: 'My Custom Tag',
- },
- {key: 'other', name: 'Other'},
- ]);
- const tags = TagStore.getState();
- expect(tags.mytag).toEqual({
- key: 'mytag',
- name: 'My Custom Tag',
- values: [],
- });
- expect(tags.other).toEqual({
- key: 'other',
- name: 'Other',
- values: [],
- });
- expect(TagStore.trigger).toHaveBeenCalledTimes(1);
- });
- });
- describe('getIssueAttributes()', function () {
- it('should populate the has tag with values', () => {
- TagStore.loadTagsSuccess([
- {
- key: 'mytag',
- name: 'My Custom Tag',
- },
- {
- key: 'otherkey',
- name: 'My other tag',
- },
- ]);
- expect(TagStore.getIssueAttributes(OrganizationFixture()).has).toEqual({
- key: 'has',
- name: 'Has Tag',
- values: ['mytag', 'otherkey'],
- predefined: true,
- });
- });
- it('should not overwrite predefined filters', () => {
- TagStore.loadTagsSuccess([
- {
- key: 'is',
- name: 'Custom Assigned To',
- },
- ]);
- const tags = TagStore.getIssueAttributes(OrganizationFixture());
- expect(tags.is).toBeTruthy();
- expect(tags.is.key).toBe('is');
- expect(tags.assigned).toBeTruthy();
- });
- it('should replace ignore with archive', () => {
- TagStore.loadTagsSuccess([
- {
- key: 'is',
- name: 'Custom Assigned To',
- },
- ]);
- const tags = TagStore.getIssueAttributes(OrganizationFixture({}));
- expect(tags.is.values).toContain('archived');
- });
- });
- describe('getIssueTags()', function () {
- it('should have built in, state, and issue attribute tags', () => {
- TagStore.loadTagsSuccess([
- {
- key: 'mytag',
- name: 'My Custom Tag',
- },
- ]);
- const tags = TagStore.getIssueTags(OrganizationFixture());
- // state
- expect(tags.mytag).toBeTruthy();
- expect(tags.mytag.key).toBe('mytag');
- // attribute
- expect(tags.has).toBeTruthy();
- expect(tags.has.key).toBe('has');
- // built in
- expect(tags['device.family']).toBeTruthy();
- expect(tags['device.family'].key).toBe('device.family');
- });
- });
- });
|