-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from Brandawg93/feature-influx
InfluxDB v2 Support
- Loading branch information
Showing
50 changed files
with
1,716 additions
and
724 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,3 +62,6 @@ jobs: | |
env: | ||
USERNAME: admin | ||
PASSWORD: nut_test | ||
NUT_HOST: localhost | ||
NUT_PORT: 3493 | ||
WEB_PORT: 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,8 @@ scripts | |
|
||
dev | ||
|
||
settings.yml | ||
|
||
.next | ||
.swc | ||
test-results | ||
test-results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
helix: { register: jest.fn() }, | ||
dotPulse: { register: jest.fn() }, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { test as setup } from '@playwright/test' | ||
import { YamlSettings } from '@/server/settings' | ||
|
||
setup('create new database', () => { | ||
new YamlSettings('./config/settings.yml') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,68 @@ | ||
import React from 'react' | ||
import { render } from '@testing-library/react' | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query' | ||
import { render, screen } from '@testing-library/react' | ||
import { useQuery } from '@tanstack/react-query' | ||
import Page from '@/app/page' | ||
import { checkSettings } from '@/app/actions' | ||
|
||
const queryClient = new QueryClient() | ||
jest.mock('@tanstack/react-query', () => ({ | ||
useQuery: jest.fn(), | ||
})) | ||
|
||
jest.mock('react-chartjs-2', () => ({ | ||
Line: () => null, | ||
Doughnut: () => null, | ||
})) | ||
|
||
jest.mock('../../../src/app/actions', () => ({ | ||
getDevices: jest.fn(), | ||
checkSettings: jest.fn(), | ||
disconnect: jest.fn(), | ||
})) | ||
|
||
global.fetch = jest.fn(() => | ||
Promise.resolve({ | ||
json: () => Promise.resolve([{ name: '1.0.0' }]), | ||
}) | ||
) as jest.Mock | ||
|
||
describe('Page', () => { | ||
it('renders a heading', () => { | ||
const page = render( | ||
<QueryClientProvider client={queryClient}> | ||
<Page /> | ||
</QueryClientProvider> | ||
) | ||
|
||
expect(page).toBeDefined() | ||
const mockDevicesData = { | ||
devices: [ | ||
{ | ||
name: 'Device1', | ||
description: 'Test Device 1', | ||
vars: { | ||
'ups.status': { value: 'OL' }, | ||
'input.voltage': { value: '230' }, | ||
'input.voltage.nominal': { value: '230' }, | ||
'output.voltage': { value: '230' }, | ||
'ups.realpower': { value: '100' }, | ||
'ups.realpower.nominal': { value: '150' }, | ||
'ups.load': { value: '50' }, | ||
'battery.charge': { value: '80' }, | ||
'battery.runtime': { value: '1200' }, | ||
'ups.mfr': { value: 'Manufacturer' }, | ||
'ups.model': { value: 'Model' }, | ||
'device.serial': { value: '123456' }, | ||
}, | ||
}, | ||
], | ||
updated: '2023-10-01T00:00:00Z', | ||
} | ||
|
||
beforeEach(() => { | ||
;(useQuery as jest.Mock).mockReturnValue({ | ||
isLoading: false, | ||
data: mockDevicesData, | ||
refetch: jest.fn(), | ||
}) | ||
;(checkSettings as jest.Mock).mockResolvedValue(true) | ||
}) | ||
|
||
it('renders a heading', async () => { | ||
render(<Page />) | ||
|
||
const wrapper = await screen.findByTestId('wrapper') | ||
expect(wrapper).toBeInTheDocument() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,82 @@ | ||
import React from 'react' | ||
import { render } from '@testing-library/react' | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query' | ||
|
||
import { render, screen, waitFor } from '@testing-library/react' | ||
import { useQuery } from '@tanstack/react-query' | ||
import Wrapper from '@/client/components/wrapper' | ||
import { LanguageContext } from '@/client/context/language' | ||
import { checkSettings } from '@/app/actions' | ||
|
||
jest.mock('@tanstack/react-query', () => ({ | ||
useQuery: jest.fn(), | ||
})) | ||
|
||
jest.mock('../../../../src/app/actions', () => ({ | ||
getDevices: jest.fn(), | ||
checkSettings: jest.fn(), | ||
disconnect: jest.fn(), | ||
})) | ||
|
||
describe('Wrapper Component', () => { | ||
const mockDevicesData = { | ||
devices: [ | ||
{ | ||
name: 'Device1', | ||
description: 'Test Device 1', | ||
vars: { | ||
'ups.status': { value: 'OL' }, | ||
'input.voltage': { value: '230' }, | ||
'input.voltage.nominal': { value: '230' }, | ||
'output.voltage': { value: '230' }, | ||
'ups.realpower': { value: '100' }, | ||
'ups.realpower.nominal': { value: '150' }, | ||
'ups.load': { value: '50' }, | ||
'battery.charge': { value: '80' }, | ||
'battery.runtime': { value: '1200' }, | ||
'ups.mfr': { value: 'Manufacturer' }, | ||
'ups.model': { value: 'Model' }, | ||
'device.serial': { value: '123456' }, | ||
}, | ||
}, | ||
], | ||
updated: '2023-10-01T00:00:00Z', | ||
} | ||
|
||
beforeEach(() => { | ||
;(useQuery as jest.Mock).mockReturnValue({ | ||
isLoading: false, | ||
data: mockDevicesData, | ||
refetch: jest.fn(), | ||
}) | ||
;(checkSettings as jest.Mock).mockResolvedValue(true) | ||
}) | ||
|
||
it('renders loading state', async () => { | ||
;(useQuery as jest.Mock).mockReturnValue({ | ||
isLoading: true, | ||
data: null, | ||
refetch: jest.fn(), | ||
}) | ||
|
||
render( | ||
<LanguageContext.Provider value='en'> | ||
<Wrapper /> | ||
</LanguageContext.Provider> | ||
) | ||
|
||
const wrapper = await screen.findByTestId('wrapper') | ||
expect(wrapper).toBeInTheDocument() | ||
}) | ||
|
||
const queryClient = new QueryClient() | ||
it('renders error state', async () => { | ||
;(checkSettings as jest.Mock).mockResolvedValue(false) | ||
|
||
describe('Wrapper', () => { | ||
it('renders', () => { | ||
const { getByTestId } = render( | ||
<QueryClientProvider client={queryClient}> | ||
render( | ||
<LanguageContext.Provider value='en'> | ||
<Wrapper /> | ||
</QueryClientProvider> | ||
</LanguageContext.Provider> | ||
) | ||
|
||
expect(getByTestId('wrapper')).toBeInTheDocument() | ||
await waitFor(() => { | ||
expect(screen.getByText('connect.server')).toBeInTheDocument() | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react' | ||
import { render, screen } from '@testing-library/react' | ||
import '@testing-library/jest-dom' | ||
import ThemeProvider from '../../../../src/client/context/theme' | ||
|
||
describe('ThemeProvider', () => { | ||
it('should render children correctly', () => { | ||
render( | ||
<ThemeProvider> | ||
<div data-testid='child'>Hello World</div> | ||
</ThemeProvider> | ||
) | ||
expect(screen.getByTestId('child')).toBeInTheDocument() | ||
}) | ||
|
||
it('should set initial theme based on localStorage', () => { | ||
localStorage.setItem('theme', 'dark') | ||
render( | ||
<ThemeProvider> | ||
<div data-testid='child'>Hello World</div> | ||
</ThemeProvider> | ||
) | ||
expect(document.documentElement.classList.contains('dark')).toBe(true) | ||
}) | ||
}) |
Oops, something went wrong.