Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cuesheet block #355

Merged
merged 4 commits into from
Apr 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions apps/client/src/common/utils/__tests__/dateConfig.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,10 +462,10 @@ describe('millisToDelayString()', () => {
});
describe('converts values in seconds', () => {
it(`shows a simple string with value in seconds`, () => {
expect(millisToDelayString(10000)).toBe('+10sec');
expect(millisToDelayString(10000)).toBe('+10 sec');
});
it(`... and its negative counterpart`, () => {
expect(millisToDelayString(-10000)).toBe('-10sec');
expect(millisToDelayString(-10000)).toBe('-10 sec');
});

const underAMinute = [1, 500, 1000, 6000, 55000, 59999];
Expand All @@ -479,10 +479,10 @@ describe('millisToDelayString()', () => {

describe('converts values in minutes', () => {
it(`shows a simple string with value in minutes`, () => {
expect(millisToDelayString(720000)).toBe('+12min');
expect(millisToDelayString(720000)).toBe('+12 min');
});
it(`... and its negative counterpart`, () => {
expect(millisToDelayString(-720000)).toBe('-12min');
expect(millisToDelayString(-720000)).toBe('-12 min');
});
it(`shows a simple string with value in minutes and seconds`, () => {
expect(millisToDelayString(630000)).toBe('+00:10:30');
Expand Down
4 changes: 2 additions & 2 deletions apps/client/src/common/utils/dateConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ export function millisToDelayString(millis: number | null): undefined | string |
const absMillis = Math.abs(millis);

if (absMillis < mtm) {
return `${isNegative ? '-' : '+'}${formatFromMillis(absMillis, 's')}sec`;
return `${isNegative ? '-' : '+'}${formatFromMillis(absMillis, 's')} sec`;
} else if (absMillis < mth && absMillis % mtm === 0) {
return `${isNegative ? '-' : '+'}${formatFromMillis(absMillis, 'm')}min`;
return `${isNegative ? '-' : '+'}${formatFromMillis(absMillis, 'm')} min`;
} else {
return `${isNegative ? '-' : '+'}${formatFromMillis(absMillis, 'HH:mm:ss')}`;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/client/src/features/table/tableRows/BlockRow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default function BlockRow(props) {
const { row } = props;
return (
<tr {...row.getRowProps()}>
<td className={style.blockCell}>Delay Block</td>
<td className={style.blockCell}>{row.original?.title || 'Block'}</td>
</tr>
);
}
Expand Down
8 changes: 3 additions & 5 deletions apps/client/src/features/table/tableRows/DelayRow.jsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import PropTypes from 'prop-types';

import { millisToMinutes } from '../../../common/utils/dateConfig';
import { millisToDelayString } from '../../../common/utils/dateConfig';

import style from '../Table.module.scss';

export default function DelayRow(props) {
const { row } = props;
const delayVal = row.original.duration;
const minutesDelayed = Math.abs(millisToMinutes(delayVal));
const labelText = `${minutesDelayed} minutes ${delayVal >= 0 ? 'delayed' : 'ahead'}`;
const delayTime = delayVal !== 0 ? millisToDelayString(delayVal) : null;

return (
<tr {...row.getRowProps()}>
<td className={style.delayCell}>{labelText}</td>
<td className={style.delayCell}>{delayTime}</td>
</tr>
);
}

DelayRow.propTypes = {
row: PropTypes.object.isRequired,
};

4 changes: 2 additions & 2 deletions e2e/tests/002-upload-showfile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ test('test', async ({ page }) => {
await page.getByTestId('delay-input').click();
await page
.locator('div')
.filter({ hasText: /^SED\+10minNew start: 10:10:00$/ })
.filter({ hasText: /^SED\+10 minNew start: 10:10:00$/ })
.getByPlaceholder('Start')
.click();
await page.getByText('+10minNew start: 10:10:00').click();
await page.getByText('+10 minNew start: 10:10:00').click();
await page.getByText('Second test event').click();
await page.getByText('Lunch').click();
await page.getByText('Third test event').click();
Expand Down