mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 22:59:07 +00:00
Merge branch 'master' into workflow-project
This commit is contained in:
commit
f300e51c2e
140
Common/Tests/Types/BrandColors.test.ts
Normal file
140
Common/Tests/Types/BrandColors.test.ts
Normal 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');
|
||||
});
|
||||
});
|
||||
});
|
42
CommonUI/src/Tests/Components/EmptyState/EmptyState.test.tsx
Normal file
42
CommonUI/src/Tests/Components/EmptyState/EmptyState.test.tsx
Normal 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();
|
||||
});
|
||||
});
|
16
CommonUI/src/Tests/Components/Template/Template.test.tsx
Normal file
16
CommonUI/src/Tests/Components/Template/Template.test.tsx
Normal 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();
|
||||
});
|
||||
});
|
@ -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,
|
||||
|
@ -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> =
|
||||
|
Loading…
Reference in New Issue
Block a user