Merge branch 'master' into workflow-project

This commit is contained in:
Simon Larsen 2023-04-28 11:47:45 +01:00
commit f300e51c2e
No known key found for this signature in database
GPG Key ID: AB45983AA9C81CDE
5 changed files with 212 additions and 49 deletions

View File

@ -0,0 +1,140 @@
import Color from '../../Types/Color';
import {
Black,
White,
slate,
Purple,
Pink,
Red,
Orange,
Yellow,
Green,
Teal,
Cyan,
VeryLightGrey,
Grey,
LightGrey,
Moroon,
Blue,
} from '../../Types/BrandColors';
describe('Color', () => {
describe('Verify color hex', () => {
it('should create a new instance with the given hex code', () => {
const color: Color = new Color('#123456');
expect(color).toBe(color);
});
});
describe('Black', () => {
it('should be an instance with the hex code of Black', () => {
const color: Color = Black;
expect(Black).toBe(color);
expect(Black.color).toBe('#000000');
});
});
describe('White', () => {
it('should be an instance with the hex code of White', () => {
const color: Color = White;
expect(White).toBe(color);
expect(White.color).toBe('#ffffff');
});
});
describe('slate', () => {
it('should be an instance with the hex code of slate', () => {
const color: Color = slate;
expect(slate).toBe(color);
expect(slate.color).toBe('#564ab1');
});
});
describe('Purple', () => {
it('should be an instance with the hex code of Purple', () => {
const color: Color = Purple;
expect(Purple).toBe(color);
expect(Purple.color).toBe('#6f42c1');
});
});
describe('Pink', () => {
it('should be an instance with the hex code of Pink', () => {
const color: Color = Pink;
expect(Pink).toBe(color);
expect(Pink.color).toBe('#e83e8c');
});
});
describe('Red', () => {
it('should be an instance with the hex code of Red', () => {
const color: Color = Red;
expect(Red).toBe(color);
expect(Red.color).toBe('#fd625e');
});
});
describe('Orange', () => {
it('should be an instance with the hex code of Orange', () => {
const color: Color = Orange;
expect(Orange).toBe(color);
expect(Orange.color).toBe('#f1734f');
});
});
describe('Yellow', () => {
it('should be an instance with the hex code of Yellow', () => {
const color: Color = Yellow;
expect(Yellow).toBe(color);
expect(Yellow.color).toBe('#ffbf53');
});
});
describe('Green', () => {
it('should be an instance with the hex code of Green', () => {
const color: Color = Green;
expect(Green).toBe(color);
expect(Green.color).toBe('#2ab57d');
});
});
describe('Teal', () => {
it('should be an instance with the hex code of Teal', () => {
const color: Color = Teal;
expect(Teal).toBe(color);
expect(Teal.color).toBe('#050505');
});
});
describe('Cyan', () => {
it('should be an instance with the hex code of Cyan', () => {
const color: Color = Cyan;
expect(Cyan).toBe(color);
expect(Cyan.color).toBe('#4ba6ef');
});
});
describe('VeryLightGrey', () => {
it('should be an instance with the hex code of VeryLightGrey', () => {
const color: Color = VeryLightGrey;
expect(VeryLightGrey).toBe(color);
expect(VeryLightGrey.color).toBe('#c2c2c2');
});
});
describe('Grey', () => {
it('should be an instance with the hex code of Grey', () => {
const color: Color = Grey;
expect(Grey).toBe(color);
expect(Grey.color).toBe('#575757');
});
});
describe('LightGrey', () => {
it('should be an instance with the hex code of LightGrey', () => {
const color: Color = LightGrey;
expect(LightGrey).toBe(color);
expect(LightGrey.color).toBe('#908B8B');
});
});
describe('Moroon', () => {
it('should be an instance with the hex code of Moroon', () => {
const color: Color = Moroon;
expect(Moroon).toBe(color);
expect(Moroon.color).toBe('#b70400');
});
});
describe('Blue', () => {
it('should be an instance with the hex code of Blue', () => {
const color: Color = Blue;
expect(Blue).toBe(color);
expect(Blue.color).toBe('#3686be');
});
});
});

View File

@ -0,0 +1,42 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
import EmnptyState from '../../../Components/EmptyState/EmptyState';
import IconProp from 'Common/Types/Icon/IconProp';
describe('EmptyState', () => {
test('renders correctly with all props', () => {
render(
<EmnptyState
title="Empty State Title"
description="This is an empty state description"
icon={IconProp.User}
footer={<div>This is a footer element</div>}
/>
);
const titleElement: HTMLElement = screen.getByText('Empty State Title');
const descriptionElement: HTMLElement =
screen.getByText('Empty State Title');
const iconElement: HTMLElement = screen.getByRole('icon');
const footerElement: HTMLElement = screen.getByText(
'This is a footer element'
);
expect(titleElement).toBeInTheDocument();
expect(descriptionElement).toBeInTheDocument();
expect(iconElement).toBeInTheDocument();
expect(footerElement).toBeInTheDocument();
});
test('renders without an icon', () => {
render(
<EmnptyState
icon={undefined}
title="Title"
description="Description"
/>
);
const title: HTMLElement = screen.getByText('Title');
const description: HTMLElement = screen.getByText('Description');
expect(title).toBeInTheDocument();
expect(description).toBeInTheDocument();
});
});

View File

@ -0,0 +1,16 @@
import React from 'react';
import '@testing-library/jest-dom';
import { screen, render } from '@testing-library/react';
import Component, {
ComponentProps,
} from '../../../Components/Template/Template';
describe('Template Component', () => {
const props: ComponentProps = {
title: 'Template title',
};
it('should render component with the correct title', () => {
render(<Component {...props} />);
expect(screen.getByText(props.title)).toBeInTheDocument();
});
});

View File

@ -728,23 +728,6 @@ export default class ScheduledMaintenance extends BaseModel {
})
public isStatusPageSubscribersNotifiedOnEventScheduled?: boolean = undefined;
@ColumnAccessControl({
create: [],
read: [],
update: [],
})
@TableColumn({
isDefaultValueColumn: true,
type: TableColumnType.Boolean,
title: 'Status Page Subscribers Notified On Ongoing Event',
description: 'Status Page Subscribers Notified On Ongoing Event',
})
@Column({
type: ColumnType.Boolean,
default: false,
})
public isStatusPageSubscribersNotifiedOnEventOngoing?: boolean = undefined;
@ColumnAccessControl({
create: [
Permission.ProjectOwner,

View File

@ -52,42 +52,24 @@ RunCron(
},
});
const ongoingEvents: Array<ScheduledMaintenance> =
await ScheduledMaintenanceService.findBy({
query: {
isStatusPageSubscribersNotifiedOnEventOngoing: false,
startsAt: QueryHelper.lessThan(
OneUptimeDate.getCurrentDate()
),
},
props: {
isRoot: true,
},
limit: LIMIT_MAX,
skip: 0,
select: {
_id: true,
title: true,
description: true,
startsAt: true,
},
populate: {
monitors: {
_id: true,
},
},
});
const totalEvents: Array<ScheduledMaintenance> = [
...ongoingEvents,
...scheduledEvents,
];
for (const event of totalEvents) {
for (const event of scheduledEvents) {
if (!event.monitors || event.monitors.length === 0) {
continue;
}
// update the flag.
await ScheduledMaintenanceService.updateOneById({
id: event.id!,
data: {
isStatusPageSubscribersNotifiedOnEventScheduled: true,
},
props: {
isRoot: true,
ignoreHooks: true,
},
});
// get status page resources from monitors.
const statusPageResources: Array<StatusPageResource> =