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

[O2B-1227] Add tags to RC daily log template #1537

Merged
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
2 changes: 1 addition & 1 deletion lib/database/seeders/20200511151010-tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module.exports = {
{ text: 'SLIMOS' },
{ text: 'QC' },
{ text: 'PDP' },
{ text: 'TEST-TAG-9' },
{ text: 'p2info' },
{ text: 'TEST-TAG-10' },
{ text: 'TEST-TAG-11' },
{ text: 'TEST-TAG-12' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
getStartOfYear,
getWeeksCount,
MONTH_NAMES,
} from '../../../../utilities/dateUtils.js';
} from '../../../../utilities/dateUtils.mjs';
import { formatTimeRange } from '../../../common/formatting/formatTimeRange.js';
import { timeRangeInput } from '../../../common/form/inputs/TimeRangeInputComponent.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
import { h } from '/js/src/index.js';
import { iconX } from '/js/src/icons.js';
import { MILLISECONDS_IN_ONE_DAY } from '../../../../utilities/dateUtils.js';
import { MILLISECONDS_IN_ONE_DAY } from '../../../../utilities/dateUtils.mjs';
import { formatTimestampForDateTimeInput } from '../../../../utilities/formatting/dateTimeInputFormatters.mjs';
import { StatefulComponent } from '../../StatefulComponent.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,21 @@ export const getStartOfWeek = (week, year) => {
return new Date(startOfFirstWeekTimestamp + (week - 1) * MILLISECONDS_IN_ONE_WEEK);
};

/**
* Format a date in its full format, for example `Monday January 1, 2024`
*
* @param {Date} date the date to format
* @return {string} the formatted date
*/
export const formatFullDate = (date) => {
const year = date.getFullYear();
const day = date.getDate();
const dayOfWeek = date.toLocaleString('en', { weekday: 'long' });
const month = date.toLocaleString('en', { month: 'long' });

return `${dayOfWeek} ${month} ${day}, ${year}`;
};

export const MONTH_NAMES = [
'January',
'February',
Expand Down
27 changes: 0 additions & 27 deletions lib/public/utilities/formatting/formatFullDate.js

This file was deleted.

2 changes: 1 addition & 1 deletion lib/public/utilities/formatting/formatTimestamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import { h } from '/js/src/index.js';
import { userPreferencesStore } from '../userPreferencesStore.js';
import { getLocaleDateAndTime } from '../dateUtils.js';
import { getLocaleDateAndTime } from '../dateUtils.mjs';

/**
* Format the given timestamp in the common format, i.e. en-GB locale with short date and medium time
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { markdownInput } from '../../../components/common/markdown/markdown.js';
import spinner from '../../../components/common/spinner.js';
import { frontLink } from '../../../components/common/navigation/frontLink.js';
import { creationFormComponent } from '../../../components/common/form/creationFormComponent.js';
import { getLocaleDateAndTime } from '../../../utilities/dateUtils.js';
import { getLocaleDateAndTime } from '../../../utilities/dateUtils.mjs';
import { eosFormEcsSpecificPart } from './typeSpecific/eosFormEcsSpecificPart.js';
import { ShiftTypes } from '../../../domain/enums/ShiftTypes.js';
import { eosFormQcPdpSpecificPart } from './typeSpecific/eosFormQcPdpSpecificPart.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
*/

import { Observable, RemoteData } from '/js/src/index.js';
import { getLocaleDateAndTime, getStartOfDay, MILLISECONDS_IN_ONE_DAY } from '../../../../utilities/dateUtils.js';
import { formatFullDate, getLocaleDateAndTime, getStartOfDay, MILLISECONDS_IN_ONE_DAY } from '../../../../utilities/dateUtils.mjs';
import { buildUrl } from '../../../../utilities/fetch/buildUrl.js';
import { getRemoteData } from '../../../../utilities/fetch/getRemoteData.js';
import {
AliceMagnetsConfigurationSnapshotsForm,
} from '../../../../components/common/form/magnetsConfiguration/AliceMagnetsConfigurationSnapshotsForm.js';
import { detectorsProvider } from '../../../../services/detectors/detectorsProvider.js';
import { formatFullDate } from '../../../../utilities/formatting/formatFullDate.js';
import { formatPercentage } from '../../../../utilities/formatting/formatPercentage.js';
import { formatTimeAndEfficiencyLoss } from '../../../../utilities/formatting/formatTimeAndEfficiencyLoss.js';
import { ObservableData } from '../../../../utilities/ObservableData.js';

/**
* @typedef RcDailyMeetingTemplateFormData
Expand Down Expand Up @@ -427,4 +427,13 @@
.map(([label, logs]) => [`* ${label}: `, ...logs.map(formatLogLine)].join('\n'))
.join('\n');
}

/**
* Return an observable data of tags to select
*
* @return {ObservableData} tags observable data
*/
get tags$() {
return new ObservableData(['p2info', 'RC']);

Check warning on line 437 in lib/public/views/Logs/Create/templates/RcDailyMeetingTemplate.js

View check run for this annotation

Codecov / codecov/patch

lib/public/views/Logs/Create/templates/RcDailyMeetingTemplate.js#L436-L437

Added lines #L436 - L437 were not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export const rcDailyMeetingConfiguration = (creationModel, template) => {
markdownInput(
template.formData.alicePlans,
{
id: 'lhc-plans',
id: 'alice-plans',
onchange: (e) => template.patchFormData({ alicePlans: e.target.value }),
class: 'flex-grow',
},
Expand Down Expand Up @@ -134,9 +134,9 @@ export const rcDailyMeetingConfiguration = (creationModel, template) => {
h(PanelComponent, [
h(LabelPanelHeaderComponent, 'Last 24h'),
markdownInput(
template.formData.alicePlans,
template.formData.access,
{
id: 'lhc-plans',
id: 'access',
onchange: (e) => template.patchFormData({ access: e.target.value }),
class: 'flex-grow',
},
Expand All @@ -151,6 +151,7 @@ export const rcDailyMeetingConfiguration = (creationModel, template) => {
Success: (logs) => markdownInput(
logs,
{
id: 'central-systems-services-logs',
onchange: (e) => {
template.systemsLogs = RemoteData.success(e.target.value);
},
Expand All @@ -169,6 +170,7 @@ export const rcDailyMeetingConfiguration = (creationModel, template) => {
Success: (logs) => markdownInput(
logs,
{
id: 'detectors-logs',
onchange: (e) => {
template.detectorsLogs = RemoteData.success(e.target.value);
},
Expand All @@ -184,7 +186,7 @@ export const rcDailyMeetingConfiguration = (creationModel, template) => {
markdownInput(
template.formData.pendingRequests,
{
id: 'lhc-plans',
id: 'pending-requests',
onchange: (e) => template.patchFormData({ pendingRequests: e.target.value }),
class: 'flex-grow',
},
Expand All @@ -194,9 +196,9 @@ export const rcDailyMeetingConfiguration = (creationModel, template) => {
h('h4', 'AOB'),
h(PanelComponent, [
markdownInput(
template.formData.alicePlans,
template.formData.aob,
{
id: 'lhc-plans',
id: 'aob',
onchange: (e) => template.patchFormData({ aob: e.target.value }),
class: 'flex-grow',
},
Expand Down
2 changes: 1 addition & 1 deletion lib/public/views/Runs/format/formatRunEnd.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import { formatTimestamp } from '../../../utilities/formatting/formatTimestamp.js';
import { iconWarning, h } from '/js/src/index.js';
import { getLocaleDateAndTime } from '../../../utilities/dateUtils.js';
import { getLocaleDateAndTime } from '../../../utilities/dateUtils.mjs';
import { tooltip } from '../../../components/common/popover/tooltip.js';
import { TriggerValue } from '../../../domain/enums/TriggerValue.js';

Expand Down
2 changes: 1 addition & 1 deletion lib/public/views/Runs/format/formatRunStart.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import { formatTimestamp } from '../../../utilities/formatting/formatTimestamp.js';
import { iconWarning, h } from '/js/src/index.js';
import { getLocaleDateAndTime } from '../../../utilities/dateUtils.js';
import { getLocaleDateAndTime } from '../../../utilities/dateUtils.mjs';
import { tooltip } from '../../../components/common/popover/tooltip.js';
import { TriggerValue } from '../../../domain/enums/TriggerValue.js';

Expand Down
2 changes: 1 addition & 1 deletion lib/public/views/Statistics/StatisticsPageModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { TabbedPanelModel } from '../../components/TabbedPanel/TabbedPanelModel.
import { buildUrl } from '../../utilities/fetch/buildUrl.js';
import { RemoteDataSource } from '../../utilities/fetch/RemoteDataSource.js';
import { TimeRangeInputModel } from '../../components/Filters/common/filters/TimeRangeInputModel.js';
import { getStartOfDay, getStartOfYear, MILLISECONDS_IN_ONE_DAY } from '../../utilities/dateUtils.js';
import { getStartOfDay, getStartOfYear, MILLISECONDS_IN_ONE_DAY } from '../../utilities/dateUtils.mjs';
import { ObservableData } from '../../utilities/ObservableData.js';

export const STATISTICS_PANELS_KEYS = {
Expand Down
2 changes: 1 addition & 1 deletion test/api/tags.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports = () => {
const response = await request(server).get('/api/tags?filter[partialText]=-TAG-');
expect(response.status).to.equal(200);
expect(response.body.data).to.be.an('array');
expect(response.body.data.length).to.equal(33);
expect(response.body.data.length).to.equal(32);
});

it('should return 204 if no tags match partial search', async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/lib/usecases/tag/GetAllTagsUseCase.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ module.exports = () => {
({ tags } = await new GetAllTagsUseCase().execute(getAllTagsDto));

expect(tags).to.be.an('array');
expect(tags).to.have.lengthOf(33);
expect(tags).to.have.lengthOf(32);
expect(tags.every((tag) => tag.text.includes('-TAG-'))).to.be.true;

getAllTagsDto.query = { filter: { partialText: 'DO-NOT-EXISTS' } };
Expand Down
151 changes: 150 additions & 1 deletion test/public/logs/create.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
* granted to it by virtue of its status as an Intergovernmental Organization
* or submit itself to any jurisdiction.
*/

const chai = require('chai');
const { defaultBefore, defaultAfter, goToPage, expectInputValue } = require('../defaults');
const path = require('path');
Expand Down Expand Up @@ -542,4 +541,154 @@ ${actions}\
expect(tags).to.lengthOf(3);
expect(tags).to.have.members(['oncall', `${shifterPosition} Shifter`, detectorOrSubsystem]);
});

it('should successfully switch to RC daily log template', async () => {
await goToPage(page, 'log-create');

// Log template is the first select of the page
await page.waitForSelector('select');
await page.select('select', 'rc-daily-meeting');

// Expect the inputs to be there
await page.waitForSelector('#lhc-plans', { timeout: 500 });

const lhcPlans = 'LHC\nPlans';
await pressElement(page, '#lhc-plans ~ .CodeMirror');
await page.keyboard.type(lhcPlans);

await pressElement(page, '#magnets-add');

const { formatTimestampForDateTimeInput } = await import('../../../lib/public/utilities/formatting/dateTimeInputFormatters.mjs');
const { getLocaleDateAndTime, formatFullDate } = await import('../../../lib/public/utilities/dateUtils.mjs');

const magnetTimestamp = new Date() - 10000;
const { date: magnetDate, time: magnetTime } = formatTimestampForDateTimeInput(magnetTimestamp, true);

await fillInput(page, '#magnets-0 > div > div > input:nth-of-type(1)', magnetDate, ['change']);
await fillInput(page, '#magnets-0 > div > div > input:nth-of-type(2)', magnetTime, ['change']);
await page.focus('#magnets-0 > div > input:nth-of-type(1)');
await page.keyboard.type('solenoid-0');
await page.focus('#magnets-0 > div > input:nth-of-type(2)');
await page.keyboard.type('dipole-0');

const alicePlans = 'Alice\nPlans';
await pressElement(page, '#alice-plans ~ .CodeMirror');
await page.keyboard.type(alicePlans);

const access = 'Access\nLast 24h';
await pressElement(page, '#access ~ .CodeMirror');
await page.keyboard.type(access);

const pendingRequests = 'Pending\nRequests';
await pressElement(page, '#pending-requests ~ .CodeMirror');
await page.keyboard.type(pendingRequests);

const aob = 'Any other\nBusiness';
await pressElement(page, '#aob ~ .CodeMirror');
await page.keyboard.type(aob);

await pressElement(page, '#send:not([disabled])');

await page.waitForNavigation();
const expectedTitle = `RC Daily Meeting Minutes ${getLocaleDateAndTime(Date.now()).date}`;
await expectInnerText(page, 'h2', expectedTitle);

const lastLog = await getLastLog();
const magnetDateTime = getLocaleDateAndTime(magnetTimestamp);
expect(lastLog.title).to.equal(expectedTitle);
// Sometimes, browser adds \r to the request to comply with text form data encoding

/*
* Expect 2 fills: 6 and 123123123, fill 6 because 123123123 has been created during previous tests, hence ending fill 6, and
* 123123123 is ended because fill 123123 is created a bit later (both in CreateLhcFillUseCase.test.js)
*
* On call log is created for DCS system right before this test and appear in `Central systems/services`
*
* Detector quality is changed for detector CPV twice in UpdateRunUseCase
*/
expect(lastLog.text
.replaceAll('\r', ''))
.to.equal(`\
# RC Daily Meeting Minutes
Date: ${formatFullDate(new Date())}

## LHC

### Last 24h

Fill 6 (Single_12b_8_1024_8_2018)
* Beam type: null
* Stable beam start: 1565262000000
* Stable beam end: 1565305200000
* Duration: 43200
* Efficiency: 41.67%
* Time to first run: 03:00:00 (25.00%)

Fill 123123123 (schemename)
* Beam type: Pb-Pb
* Stable beam start: 1647961200000
* Stable beam end: 1647961200000
* Duration: 600
* Efficiency: 0.00%
* Time to first run: 00:00:00 (0.00%)

### Plans
${lhcPlans}

## ALICE

### Last 24h

#### Magnets
[${magnetDateTime.date}, ${magnetDateTime.time}] L3 = solenoid-0, Dipole = dipole-0

### Plans
${alicePlans}

## Runs to be checked
Runs | ACO | CPV | CTP | EMC | FDD | FIT | FT0 | FV0 | HMP | ITS | MCH | MFT | MID | PHS | TOF | TPC | TRD | ZDC
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---

## Access
${access}

## Central systems/services
* ECS and FLP:
* CRU:
* Bookkeeping:
* EOS:
* Event display:
* EPN:
* PDP:
* QC:
* CTP:
* DCS:
* [Short description of the issue - Call on-call for DCS](http://localhost:4000?page=log-detail&id=147)
* LHC_IF:

## Detectors
* FIT:
* ITS:
* MFT:
* MCH:
* MID:
* PHOS:
* CPV:
* [Detector(s) quality for run 1 has been changed](http://localhost:4000?page=log-detail&id=138)
* [Detector(s) quality for run 1 has been changed](http://localhost:4000?page=log-detail&id=137)
* TOF:
* TPC:
* TRD:
* ZDC:

## Pending request
${pendingRequests}

## AOB
${aob}\
`);
const tags = lastLog.tags.map(({ text }) => text);
expect(tags).to.lengthOf(2);
expect(tags).to.have.members(['p2info', 'RC']);
});
};
Loading
Loading