123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- import {Client} from 'app/api';
- import {doHealthRequest} from 'app/actionCreators/health';
- describe('Health ActionCreator', function() {
- const api = new Client();
- const organization = TestStubs.Organization();
- const project = TestStubs.Project();
- let mock;
- it('requests timeseries w/o tag', function() {
- mock = MockApiClient.addMockResponse({
- url: '/organizations/org-slug/health/graph/',
- });
- doHealthRequest(api, {
- timeseries: true,
- organization,
- projects: [project.id],
- environments: [],
- topk: 5,
- includePrevious: false,
- period: '7d',
- });
- expect(mock).toHaveBeenCalled();
- expect(mock).toHaveBeenLastCalledWith(
- '/organizations/org-slug/health/graph/',
- expect.objectContaining({
- query: expect.objectContaining({
- project: [project.id],
- environment: [],
- topk: 5,
- includePrevious: false,
- statsPeriod: '7d',
- }),
- })
- );
- });
- it('requests timeseries w/ tag', function() {
- mock = MockApiClient.addMockResponse({
- url: '/organizations/org-slug/health/graph/',
- });
- doHealthRequest(api, {
- timeseries: true,
- organization,
- projects: [project.id],
- environments: [],
- tag: 'release',
- topk: 5,
- includePrevious: false,
- period: '7d',
- });
- expect(mock).toHaveBeenCalled();
- expect(mock).toHaveBeenLastCalledWith(
- '/organizations/org-slug/health/graph/',
- expect.objectContaining({
- query: expect.objectContaining({
- project: [project.id],
- environment: [],
- tag: 'release',
- topk: 5,
- includePrevious: false,
- statsPeriod: '7d',
- }),
- })
- );
- });
- it('requests top', function() {
- mock = MockApiClient.addMockResponse({
- url: '/organizations/org-slug/health/top/',
- });
- doHealthRequest(api, {
- timeseries: false,
- organization,
- projects: [project.id],
- environments: [],
- tag: 'release',
- includePrevious: false,
- period: '7d',
- });
- expect(mock).toHaveBeenCalled();
- expect(mock).toHaveBeenLastCalledWith(
- '/organizations/org-slug/health/top/',
- expect.objectContaining({
- query: expect.objectContaining({
- project: [project.id],
- environment: [],
- tag: 'release',
- includePrevious: false,
- statsPeriod: '7d',
- }),
- })
- );
- });
- it('requests timeseries w/ tag and previous period', function() {
- mock = MockApiClient.addMockResponse({
- url: '/organizations/org-slug/health/graph/',
- });
- doHealthRequest(api, {
- timeseries: true,
- organization,
- projects: [project.id],
- environments: [],
- tag: 'release',
- topk: 5,
- includePrevious: true,
- period: '7d',
- });
- expect(mock).toHaveBeenCalled();
- expect(mock).toHaveBeenLastCalledWith(
- '/organizations/org-slug/health/graph/',
- expect.objectContaining({
- query: expect.objectContaining({
- statsPeriod: '14d',
- }),
- })
- );
- });
- it('requests non-timeseries and previous period', function() {
- mock = MockApiClient.addMockResponse({
- url: '/organizations/org-slug/health/top/',
- });
- doHealthRequest(api, {
- timeseries: false,
- organization,
- projects: [project.id],
- environments: [],
- tag: 'release',
- topk: 5,
- includePrevious: true,
- period: '7d',
- });
- expect(mock).toHaveBeenCalled();
- expect(mock).toHaveBeenLastCalledWith(
- '/organizations/org-slug/health/top/',
- expect.objectContaining({
- query: expect.objectContaining({
- statsPeriod: '7d',
- }),
- })
- );
- });
- });
|