12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- import { Report, SchedulingFrequency } from '../../types';
- import { getMissingFields } from './validation';
- const testReport: Report = {
- id: 0,
- name: 'Test report',
- recipients: 'test@example.com',
- replyTo: '',
- message: 'Hi, \nPlease find attached a PDF status report. If you have any questions, feel free to contact me!\nBest,',
- dashboardName: '',
- dashboards: [
- {
- dashboard: {
- uid: '7MeksYbmk',
- id: 20,
- name: 'gdev dashboards/Alerting with TestData',
- },
- timeRange: {
- from: '',
- to: '',
- },
- reportVariables: {
- namefilter: 'TestData',
- },
- },
- ],
- schedule: {
- frequency: SchedulingFrequency.Never,
- timeZone: 'Europe/Helsinki',
- },
- formats: ['pdf'],
- options: {
- orientation: 'landscape',
- layout: 'grid',
- timeRange: {
- from: '',
- to: '',
- },
- },
- enableDashboardUrl: true,
- };
- describe('Report validation', () => {
- it('should correctly show that report is valid', () => {
- expect(getMissingFields(testReport)).toBe(false);
- });
- it('should validate missing report name', () => {
- expect(getMissingFields({ ...testReport, name: '' })).toBe(true);
- });
- it('should validate missing report recipients', () => {
- expect(getMissingFields({ ...testReport, recipients: '' })).toBe(true);
- });
- it('should validate missing report dashboard', () => {
- expect(
- getMissingFields({
- ...testReport,
- dashboards: [
- {
- dashboard: undefined,
- timeRange: {
- from: '',
- to: '',
- },
- },
- ],
- })
- ).toBe(true);
- });
- it('should validate empty report formats', () => {
- expect(
- getMissingFields({
- ...testReport,
- formats: [],
- })
- ).toBe(true);
- });
- });
|