|
@@ -18,10 +18,9 @@ describe('PageFilters ActionCreators', function () {
|
|
const organization = TestStubs.Organization();
|
|
const organization = TestStubs.Organization();
|
|
|
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
- localStorage.getItem.mockClear();
|
|
|
|
jest.spyOn(PageFiltersStore, 'updateProjects');
|
|
jest.spyOn(PageFiltersStore, 'updateProjects');
|
|
jest.spyOn(PageFiltersStore, 'onInitializeUrlState').mockImplementation();
|
|
jest.spyOn(PageFiltersStore, 'onInitializeUrlState').mockImplementation();
|
|
- PageFiltersStore.updateProjects.mockClear();
|
|
|
|
|
|
+ jest.clearAllMocks();
|
|
});
|
|
});
|
|
|
|
|
|
describe('initializeUrlState', function () {
|
|
describe('initializeUrlState', function () {
|
|
@@ -51,8 +50,9 @@ describe('PageFilters ActionCreators', function () {
|
|
initializeUrlState({
|
|
initializeUrlState({
|
|
organization,
|
|
organization,
|
|
queryParams: {},
|
|
queryParams: {},
|
|
- pathname: '/mock-pathname/',
|
|
|
|
router,
|
|
router,
|
|
|
|
+ memberProjects: [],
|
|
|
|
+ shouldEnforceSingleProject: false,
|
|
});
|
|
});
|
|
|
|
|
|
expect(localStorage.getItem).toHaveBeenCalledWith(
|
|
expect(localStorage.getItem).toHaveBeenCalledWith(
|
|
@@ -82,7 +82,8 @@ describe('PageFilters ActionCreators', function () {
|
|
organization,
|
|
organization,
|
|
queryParams: {},
|
|
queryParams: {},
|
|
skipLoadLastUsed: true,
|
|
skipLoadLastUsed: true,
|
|
- pathname: '/mock-pathname/',
|
|
|
|
|
|
+ memberProjects: [],
|
|
|
|
+ shouldEnforceSingleProject: false,
|
|
router,
|
|
router,
|
|
});
|
|
});
|
|
|
|
|
|
@@ -90,8 +91,8 @@ describe('PageFilters ActionCreators', function () {
|
|
});
|
|
});
|
|
|
|
|
|
it('does not update local storage (persist) when `shouldPersist` is false', async function () {
|
|
it('does not update local storage (persist) when `shouldPersist` is false', async function () {
|
|
- localStorage.setItem.mockClear();
|
|
|
|
- localStorage.getItem.mockReturnValueOnce(
|
|
|
|
|
|
+ jest.clearAllMocks();
|
|
|
|
+ jest.spyOn(localStorage, 'getItem').mockReturnValueOnce(
|
|
JSON.stringify({
|
|
JSON.stringify({
|
|
environments: [],
|
|
environments: [],
|
|
projects: [],
|
|
projects: [],
|
|
@@ -104,6 +105,8 @@ describe('PageFilters ActionCreators', function () {
|
|
queryParams: {},
|
|
queryParams: {},
|
|
shouldPersist: false,
|
|
shouldPersist: false,
|
|
router,
|
|
router,
|
|
|
|
+ memberProjects: [],
|
|
|
|
+ shouldEnforceSingleProject: false,
|
|
});
|
|
});
|
|
|
|
|
|
expect(PageFiltersStore.onInitializeUrlState).toHaveBeenCalledWith(
|
|
expect(PageFiltersStore.onInitializeUrlState).toHaveBeenCalledWith(
|
|
@@ -138,7 +141,8 @@ describe('PageFilters ActionCreators', function () {
|
|
queryParams: {
|
|
queryParams: {
|
|
project: '1',
|
|
project: '1',
|
|
},
|
|
},
|
|
- pathname: '/mock-pathname/',
|
|
|
|
|
|
+ memberProjects: [],
|
|
|
|
+ shouldEnforceSingleProject: false,
|
|
router,
|
|
router,
|
|
});
|
|
});
|
|
expect(PageFiltersStore.onInitializeUrlState).toHaveBeenCalledWith(
|
|
expect(PageFiltersStore.onInitializeUrlState).toHaveBeenCalledWith(
|
|
@@ -161,10 +165,14 @@ describe('PageFilters ActionCreators', function () {
|
|
queryParams: {
|
|
queryParams: {
|
|
project: '1',
|
|
project: '1',
|
|
},
|
|
},
|
|
- pathname: '/mock-pathname/',
|
|
|
|
|
|
+ memberProjects: [],
|
|
|
|
+ shouldEnforceSingleProject: false,
|
|
defaultSelection: {
|
|
defaultSelection: {
|
|
datetime: {
|
|
datetime: {
|
|
period: '3h',
|
|
period: '3h',
|
|
|
|
+ utc: null,
|
|
|
|
+ start: null,
|
|
|
|
+ end: null,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
router,
|
|
router,
|
|
@@ -190,10 +198,14 @@ describe('PageFilters ActionCreators', function () {
|
|
statsPeriod: '1h',
|
|
statsPeriod: '1h',
|
|
project: '1',
|
|
project: '1',
|
|
},
|
|
},
|
|
- pathname: '/mock-pathname/',
|
|
|
|
|
|
+ memberProjects: [],
|
|
|
|
+ shouldEnforceSingleProject: false,
|
|
defaultSelection: {
|
|
defaultSelection: {
|
|
datetime: {
|
|
datetime: {
|
|
period: '24h',
|
|
period: '24h',
|
|
|
|
+ utc: null,
|
|
|
|
+ start: null,
|
|
|
|
+ end: null,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
router,
|
|
router,
|
|
@@ -218,10 +230,14 @@ describe('PageFilters ActionCreators', function () {
|
|
end: '2020-04-21T00:53:38',
|
|
end: '2020-04-21T00:53:38',
|
|
project: '1',
|
|
project: '1',
|
|
},
|
|
},
|
|
- pathname: '/mock-pathname/',
|
|
|
|
|
|
+ memberProjects: [],
|
|
|
|
+ shouldEnforceSingleProject: false,
|
|
defaultSelection: {
|
|
defaultSelection: {
|
|
datetime: {
|
|
datetime: {
|
|
period: '24h',
|
|
period: '24h',
|
|
|
|
+ utc: null,
|
|
|
|
+ start: null,
|
|
|
|
+ end: null,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
router,
|
|
router,
|
|
@@ -245,7 +261,8 @@ describe('PageFilters ActionCreators', function () {
|
|
queryParams: {
|
|
queryParams: {
|
|
project: '1',
|
|
project: '1',
|
|
},
|
|
},
|
|
- pathname: 'mock-pathname',
|
|
|
|
|
|
+ memberProjects: [],
|
|
|
|
+ shouldEnforceSingleProject: false,
|
|
router,
|
|
router,
|
|
});
|
|
});
|
|
|
|
|
|
@@ -279,7 +296,7 @@ describe('PageFilters ActionCreators', function () {
|
|
.spyOn(PageFilterPersistence, 'getPageFilterStorage')
|
|
.spyOn(PageFilterPersistence, 'getPageFilterStorage')
|
|
.mockReturnValueOnce({
|
|
.mockReturnValueOnce({
|
|
state: {
|
|
state: {
|
|
- project: ['1'],
|
|
|
|
|
|
+ project: [1],
|
|
environment: [],
|
|
environment: [],
|
|
start: null,
|
|
start: null,
|
|
end: null,
|
|
end: null,
|
|
@@ -293,8 +310,9 @@ describe('PageFilters ActionCreators', function () {
|
|
initializeUrlState({
|
|
initializeUrlState({
|
|
organization,
|
|
organization,
|
|
queryParams: {},
|
|
queryParams: {},
|
|
- pathname: '/organizations/org-slug/issues/',
|
|
|
|
router,
|
|
router,
|
|
|
|
+ memberProjects: [],
|
|
|
|
+ shouldEnforceSingleProject: false,
|
|
});
|
|
});
|
|
|
|
|
|
// Confirm that query params are not restored from local storage
|
|
// Confirm that query params are not restored from local storage
|
|
@@ -309,7 +327,7 @@ describe('PageFilters ActionCreators', function () {
|
|
.spyOn(PageFilterPersistence, 'getPageFilterStorage')
|
|
.spyOn(PageFilterPersistence, 'getPageFilterStorage')
|
|
.mockReturnValueOnce({
|
|
.mockReturnValueOnce({
|
|
state: {
|
|
state: {
|
|
- project: ['1'],
|
|
|
|
|
|
+ project: [1],
|
|
environment: ['prod'],
|
|
environment: ['prod'],
|
|
start: null,
|
|
start: null,
|
|
end: null,
|
|
end: null,
|
|
@@ -323,8 +341,9 @@ describe('PageFilters ActionCreators', function () {
|
|
initializeUrlState({
|
|
initializeUrlState({
|
|
organization,
|
|
organization,
|
|
queryParams: {},
|
|
queryParams: {},
|
|
- pathname: '/organizations/org-slug/issues/',
|
|
|
|
router,
|
|
router,
|
|
|
|
+ memberProjects: [],
|
|
|
|
+ shouldEnforceSingleProject: false,
|
|
});
|
|
});
|
|
|
|
|
|
// Confirm that only environment is restored from local storage
|
|
// Confirm that only environment is restored from local storage
|
|
@@ -348,11 +367,6 @@ describe('PageFilters ActionCreators', function () {
|
|
expect(PageFiltersStore.updateProjects).toHaveBeenCalledWith([1, 2], null);
|
|
expect(PageFiltersStore.updateProjects).toHaveBeenCalledWith([1, 2], null);
|
|
});
|
|
});
|
|
|
|
|
|
- it('does not update invalid projects', function () {
|
|
|
|
- updateProjects(['1']);
|
|
|
|
- expect(PageFiltersStore.updateProjects).not.toHaveBeenCalled();
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
it('updates history when queries are different', function () {
|
|
it('updates history when queries are different', function () {
|
|
const router = TestStubs.router({
|
|
const router = TestStubs.router({
|
|
location: {
|
|
location: {
|
|
@@ -563,7 +577,7 @@ describe('PageFilters ActionCreators', function () {
|
|
.spyOn(PageFilterPersistence, 'getPageFilterStorage')
|
|
.spyOn(PageFilterPersistence, 'getPageFilterStorage')
|
|
.mockReturnValueOnce({
|
|
.mockReturnValueOnce({
|
|
state: {
|
|
state: {
|
|
- project: ['1'],
|
|
|
|
|
|
+ project: [1],
|
|
environment: [],
|
|
environment: [],
|
|
start: null,
|
|
start: null,
|
|
end: null,
|
|
end: null,
|
|
@@ -573,16 +587,19 @@ describe('PageFilters ActionCreators', function () {
|
|
pinnedFilters: new Set(['projects', 'environments', 'datetime']),
|
|
pinnedFilters: new Set(['projects', 'environments', 'datetime']),
|
|
});
|
|
});
|
|
|
|
|
|
- PageFiltersStore.onInitializeUrlState({
|
|
|
|
- projects: ['2'],
|
|
|
|
- environments: ['prod'],
|
|
|
|
- datetime: {
|
|
|
|
- start: null,
|
|
|
|
- end: null,
|
|
|
|
- period: '1d',
|
|
|
|
- utc: null,
|
|
|
|
|
|
+ PageFiltersStore.onInitializeUrlState(
|
|
|
|
+ {
|
|
|
|
+ projects: [2],
|
|
|
|
+ environments: ['prod'],
|
|
|
|
+ datetime: {
|
|
|
|
+ start: null,
|
|
|
|
+ end: null,
|
|
|
|
+ period: '1d',
|
|
|
|
+ utc: null,
|
|
|
|
+ },
|
|
},
|
|
},
|
|
- });
|
|
|
|
|
|
+ new Set()
|
|
|
|
+ );
|
|
PageFiltersStore.updateDesyncedFilters(
|
|
PageFiltersStore.updateDesyncedFilters(
|
|
new Set(['projects', 'environments', 'datetime'])
|
|
new Set(['projects', 'environments', 'datetime'])
|
|
);
|
|
);
|