mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-18 13:44:12 +00:00
V2 build (#319)
* chore: build pipeline for v2 * chore: run unit tests * chore: configure sentry build
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
"postinstall": "pnpm addversion",
|
||||
"dev": "set BROWSER=none&&vite",
|
||||
"build": "vite build",
|
||||
"build:local": "NODE_ENV=local vite build",
|
||||
"build:docker": "vite build",
|
||||
"lint": "eslint .",
|
||||
"stylelint": "npx stylelint \"**/*.scss\"\n",
|
||||
@@ -91,6 +92,7 @@
|
||||
"typescript": "^4.9.4",
|
||||
"vite": "^4.0.4",
|
||||
"vite-plugin-svgr": "^2.4.0",
|
||||
"vite-tsconfig-paths": "^4.0.3"
|
||||
"vite-tsconfig-paths": "^4.0.3",
|
||||
"vitest": "^0.29.8"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
|
||||
import TextInput from '../TextInput';
|
||||
|
||||
describe('TextInput component', () => {
|
||||
describe('when given props', () => {
|
||||
// small hack to reset DOM between tests
|
||||
beforeEach(() => {
|
||||
document.getElementsByTagName('html')[0].innerHTML = '';
|
||||
});
|
||||
|
||||
it('renders correctly', () => {
|
||||
const testField = 'title';
|
||||
const testText = 'Test 123';
|
||||
const submitHandler = vi.fn();
|
||||
render(<TextInput field={testField} initialText={testText} submitHandler={submitHandler} />);
|
||||
|
||||
const input = screen.getByTestId('input-textfield');
|
||||
expect(input).toBeInTheDocument();
|
||||
expect(input).toHaveValue(testText);
|
||||
});
|
||||
|
||||
it('Handles renders as textarea', () => {
|
||||
const testField = 'title';
|
||||
const testText = 'Test 123';
|
||||
const submitHandler = vi.fn();
|
||||
render(<TextInput field={testField} initialText={testText} isTextArea submitHandler={submitHandler} />);
|
||||
|
||||
const input = screen.getByTestId('input-textarea');
|
||||
expect(input).toBeInTheDocument();
|
||||
expect(input).toHaveValue(testText);
|
||||
});
|
||||
});
|
||||
|
||||
describe('on status change', () => {
|
||||
// small hack to reset DOM between tests
|
||||
afterEach(() => {
|
||||
document.getElementsByTagName('html')[0].innerHTML = '';
|
||||
});
|
||||
it('calls submitHandler on new value', async () => {
|
||||
const testField = 'title';
|
||||
const testText = 'Test 123';
|
||||
const myTypedString = '456';
|
||||
const expectedString = testText + myTypedString;
|
||||
const submitHandler = vi.fn();
|
||||
render(<TextInput field={testField} initialText={testText} submitHandler={submitHandler} />);
|
||||
|
||||
const input = screen.getByTestId('input-textfield');
|
||||
|
||||
// submit without changing value
|
||||
await userEvent.type(input, '{enter}');
|
||||
expect(submitHandler).not.toHaveBeenCalled();
|
||||
|
||||
// on new value we can submit
|
||||
await userEvent.type(input, myTypedString);
|
||||
expect(input).toHaveValue(expectedString);
|
||||
await userEvent.type(input, '{enter}');
|
||||
expect(submitHandler).toHaveBeenCalledWith(testField, expectedString);
|
||||
});
|
||||
|
||||
it('cleans value before submitting', async () => {
|
||||
const testField = 'title';
|
||||
const myTypedString = ' 456 ';
|
||||
const expectedString = '456';
|
||||
const submitHandler = vi.fn();
|
||||
render(<TextInput field={testField} submitHandler={submitHandler} />);
|
||||
|
||||
const input = screen.getByTestId('input-textfield');
|
||||
|
||||
// on new value we can submit
|
||||
await userEvent.type(input, myTypedString);
|
||||
expect(input).toHaveValue(myTypedString);
|
||||
await userEvent.type(input, '{enter}');
|
||||
expect(submitHandler).toHaveBeenCalledWith(testField, expectedString);
|
||||
});
|
||||
});
|
||||
|
||||
describe('handles edge cases', () => {
|
||||
it('handles undefined value', () => {
|
||||
const testField = 'title';
|
||||
const expected = '';
|
||||
render(<TextInput field={testField} submitHandler={vi.fn()} />);
|
||||
const input = screen.getByTestId('input-textfield');
|
||||
expect(input).toBeInTheDocument();
|
||||
expect(input).toHaveValue(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
// Vitest Snapshot v1
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`cx() > ignores falsy values 1`] = `""`;
|
||||
|
||||
|
||||
@@ -54,13 +54,6 @@ describe('test string from formatDisplay function', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('test formatDisplay handles partial secs', () => {
|
||||
it('test with 1795829', () => {
|
||||
const t = { val: 1795829, result: '00:29:55' };
|
||||
expect(formatDisplay(t.val)).toBe(t.result);
|
||||
});
|
||||
});
|
||||
|
||||
describe('test string from formatDisplay function with hidezero', () => {
|
||||
it('test with null values', () => {
|
||||
const t = { val: null, result: '00:00' };
|
||||
|
||||
@@ -8,7 +8,7 @@ import useUserFields from '../../common/hooks-query/useUserFields';
|
||||
|
||||
import OntimeTable from './OntimeTable';
|
||||
import TableHeader from './TableHeader';
|
||||
import { makeCSV, makeTable } from './utils';
|
||||
import { makeCSV, makeTable } from './tableUtils';
|
||||
|
||||
import style from './Table.module.scss';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Vitest Snapshot v1
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`makeTable() > returns array of arrays with given fields 1`] = `
|
||||
[
|
||||
@@ -10,7 +10,11 @@ exports[`makeTable() > returns array of arrays with given fields 1`] = `
|
||||
"",
|
||||
],
|
||||
[
|
||||
"Event URL",
|
||||
"Public URL",
|
||||
"",
|
||||
],
|
||||
[
|
||||
"Backstage URL",
|
||||
"",
|
||||
],
|
||||
[],
|
||||
@@ -47,51 +51,3 @@ exports[`makeTable() > returns array of arrays with given fields 1`] = `
|
||||
],
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`makeTable() returns array of arrays with given fields 1`] = `
|
||||
Array [
|
||||
Array [
|
||||
"Ontime · Schedule Template",
|
||||
],
|
||||
Array [
|
||||
"Event Name",
|
||||
"",
|
||||
],
|
||||
Array [
|
||||
"Event URL",
|
||||
"",
|
||||
],
|
||||
Array [],
|
||||
Array [
|
||||
"Time Start",
|
||||
"Time End",
|
||||
"Event Title",
|
||||
"Presenter Name",
|
||||
"Event Subtitle",
|
||||
"Is Public? (x)",
|
||||
"Notes",
|
||||
"Colour",
|
||||
"user0:test",
|
||||
],
|
||||
Array [
|
||||
"00:00:00",
|
||||
"00:00:00",
|
||||
"test title 1",
|
||||
"",
|
||||
"",
|
||||
"x",
|
||||
"",
|
||||
"",
|
||||
"test",
|
||||
"test",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
],
|
||||
]
|
||||
`;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { makeCSV, makeTable, parseField } from '../utils';
|
||||
import { makeCSV, makeTable, parseField } from '../tableUtils';
|
||||
|
||||
describe('parseField()', () => {
|
||||
it('returns a string from given millis on timeStart and TimeEnd', () => {
|
||||
|
||||
+2
-4
@@ -23,7 +23,7 @@ export const parseField = (field, data) => {
|
||||
break;
|
||||
}
|
||||
if (typeof data === 'undefined') {
|
||||
return ''
|
||||
return '';
|
||||
}
|
||||
return val;
|
||||
};
|
||||
@@ -78,9 +78,7 @@ export const makeTable = (headerData, tableData, userFields) => {
|
||||
|
||||
for (const field in userFields) {
|
||||
const fieldValue = userFields[field];
|
||||
const displayName = `${field}${
|
||||
fieldValue !== field && fieldValue !== '' ? `:${fieldValue}` : ''
|
||||
}`;
|
||||
const displayName = `${field}${fieldValue !== field && fieldValue !== '' ? `:${fieldValue}` : ''}`;
|
||||
fieldTitles.push(displayName);
|
||||
}
|
||||
|
||||
+14
-10
@@ -6,20 +6,24 @@ import svgrPlugin from 'vite-plugin-svgr';
|
||||
|
||||
import { ONTIME_VERSION } from './src/ONTIME_VERSION';
|
||||
|
||||
const sentryAuthToken = process.env.SENTRY_AUTH_TOKEN;
|
||||
const isLocal = process.env.NODE_ENV === 'local';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
react(),
|
||||
svgrPlugin(),
|
||||
sentryVitePlugin({
|
||||
org: 'carlos-valente',
|
||||
project: 'ontime',
|
||||
include: './build',
|
||||
authToken: '087754a37bb947f2ab738dfa731267ffec52a9f3a14a42f48061e343d0332c2f',
|
||||
release: ONTIME_VERSION,
|
||||
deploy: {
|
||||
env: 'production',
|
||||
},
|
||||
}),
|
||||
!isLocal &&
|
||||
sentryVitePlugin({
|
||||
org: 'get-ontime',
|
||||
project: 'ontime',
|
||||
include: './build',
|
||||
authToken: sentryAuthToken,
|
||||
release: ONTIME_VERSION,
|
||||
deploy: {
|
||||
env: 'production',
|
||||
},
|
||||
}),
|
||||
],
|
||||
server: {
|
||||
port: 3000,
|
||||
|
||||
Reference in New Issue
Block a user