diff --git a/.github/workflows/ci-e2e.yml b/.github/workflows/ci-e2e.yml index 6bcb6b1b6..6be47f922 100644 --- a/.github/workflows/ci-e2e.yml +++ b/.github/workflows/ci-e2e.yml @@ -8,7 +8,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.8'] + python-version: ['3.10'] node-version: ['14'] e2e: ['a', 'b'] env: diff --git a/client/components/Coverages/CoverageArrayInput.tsx b/client/components/Coverages/CoverageArrayInput.tsx index 4855e850d..74842d7c7 100644 --- a/client/components/Coverages/CoverageArrayInput.tsx +++ b/client/components/Coverages/CoverageArrayInput.tsx @@ -9,7 +9,6 @@ import { ICoverageProvider, IEventItem, IFile, IG2ContentType, IGenre, - IKeyword, IPlanningCoverageItem, IPlanningItem, IPlanningNewsCoverageStatus, } from '../../interfaces'; @@ -22,9 +21,10 @@ import * as selectors from '../../selectors'; import {InputArray} from '../UI/Form'; import {CoverageEditor} from './CoverageEditor'; import {CoverageAddButton} from './CoverageAddButton'; +import planningActions from '../../actions/planning/api'; -interface IProps { +interface IOwnProps { field: string; addButtonText?: string; // defaults to 'Add a coverage' item: IPlanningItem; @@ -38,39 +38,43 @@ interface IProps { originalCount?: number; message: string | {[key: string]: any}; event?: IEventItem; - preferredCoverageDesks: {[key: string]: string}; getRef?(field: string, value: IPlanningCoverageItem): React.RefObject; testId?: string; editorType: EDITOR_TYPE; - // Redux state + onChange(field: string, value: any): void; + popupContainer(): HTMLElement; + onPopupOpen(): void; + onPopupClose(): void; + createUploadLink(file: IFile): void; + notifyValidationErrors(errors: Array): void; +} + +interface IReduxStateProps { users: Array; desks: Array; genres: Array; coverageProviders: Array; priorities: Array; - keywords: Array; contentTypes: Array; newsCoverageStatus: Array; formProfile: ICoverageFormProfile; planningAllowScheduledUpdates: boolean; coverageAddAdvancedMode: boolean; defaultDesk: IDesk; +} - onChange(field: string, value: any): void; - popupContainer(): HTMLElement; - onPopupOpen(): void; - onPopupClose(): void; - createUploadLink(file: IFile): void; +interface IReduxDispatchProps { uploadFiles(files: Array>): Promise>; - notifyValidationErrors(errors: Array): void; } +type IProps = IOwnProps & IReduxStateProps & IReduxDispatchProps; + interface IState { openCoverageIds: Array; } -const mapStateToProps = (state) => ({ +const mapStateToProps = (state): IReduxStateProps => ({ users: selectors.general.users(state), desks: selectors.general.desks(state), genres: state.genres, @@ -84,6 +88,10 @@ const mapStateToProps = (state) => ({ defaultDesk: selectors.general.defaultDesk(state), }); +const mapDispatchToProps = (dispatch): IReduxDispatchProps => ({ + uploadFiles: (files) => dispatch(planningActions.uploadFiles({files: files})), +}); + class CoverageArrayInputComponent extends React.Component { constructor(props) { super(props); @@ -156,7 +164,6 @@ class CoverageArrayInputComponent extends React.Component { popupContainer, onPopupOpen, onPopupClose, - preferredCoverageDesks, item, navigation, useLocalNavigation, @@ -197,7 +204,6 @@ class CoverageArrayInputComponent extends React.Component { defaultDesk, onPopupOpen, onPopupClose, - preferredCoverageDesks, newsCoverageStatus, field, value, @@ -227,7 +233,6 @@ class CoverageArrayInputComponent extends React.Component { diff={item} navigation={coverageNavigation} openCoverageIds={this.state.openCoverageIds} - preferredCoverageDesks={preferredCoverageDesks} getRef={this.props.getRef} editorType={editorType} {...props} @@ -236,4 +241,7 @@ class CoverageArrayInputComponent extends React.Component { } } -export const CoverageArrayInput = connect(mapStateToProps)(CoverageArrayInputComponent); +export const CoverageArrayInput = connect( + mapStateToProps, + mapDispatchToProps, +)(CoverageArrayInputComponent); diff --git a/client/components/Events/EventDateTime.tsx b/client/components/Events/EventDateTime.tsx index 0ae46d122..e61e70b0d 100644 --- a/client/components/Events/EventDateTime.tsx +++ b/client/components/Events/EventDateTime.tsx @@ -82,6 +82,7 @@ export class EventDateTime extends React.PureComponent { date={start} {...commonProps} withTime={false} + testId="event-start-date" /> )} {gettext('All day')} @@ -95,9 +96,11 @@ export class EventDateTime extends React.PureComponent { )} {showDash && <>–} @@ -106,6 +109,7 @@ export class EventDateTime extends React.PureComponent { withYear={withYear} isEndEventDateTime={true} date={end} + testId="event-end-date" {...commonProps} /> {isRemoteTimeZone && ( diff --git a/client/components/Events/EventDateTimeColumn.tsx b/client/components/Events/EventDateTimeColumn.tsx index 0e63fa10c..fc342a56f 100644 --- a/client/components/Events/EventDateTimeColumn.tsx +++ b/client/components/Events/EventDateTimeColumn.tsx @@ -52,6 +52,7 @@ export class EventDateTimeColumn extends React.PureComponent { withYear={!isThisYear} withTime={false} date={start} + testId="event-start-date" {...commonProps} /> {!multiDay ? null : ( @@ -62,13 +63,14 @@ export class EventDateTimeColumn extends React.PureComponent { withYear={!isThisYear} withTime={false} date={end} + testId="event-end-date" {...commonProps} /> )} {!isRemoteTimeZone ? null : ( ( - + {tzCode} ) @@ -85,6 +87,7 @@ export class EventDateTimeColumn extends React.PureComponent { withDate={false} withYear={false} date={start} + testId="event-start-date" {...commonProps} /> – @@ -92,6 +95,7 @@ export class EventDateTimeColumn extends React.PureComponent { withDate={false} withYear={false} date={end} + testId="event-end-date" {...commonProps} /> diff --git a/client/components/Events/EventEditor/index.tsx b/client/components/Events/EventEditor/index.tsx index 162253c0c..8295477b2 100644 --- a/client/components/Events/EventEditor/index.tsx +++ b/client/components/Events/EventEditor/index.tsx @@ -121,6 +121,8 @@ class EventEditorComponent extends React.PureComponent { start: value['dates.start'], end: value['dates.end'], tz: value['dates.tz'], + all_day: value['dates.all_day'], + no_end_time: value['dates.no_end_time'], }); this.props.onChangeHandler(value); diff --git a/client/components/Main/EditorPanel.tsx b/client/components/Main/EditorPanel.tsx index 651341482..808d547ce 100644 --- a/client/components/Main/EditorPanel.tsx +++ b/client/components/Main/EditorPanel.tsx @@ -26,7 +26,6 @@ const mapStateToProps = (state: IPlanningAppState) => ({ newsCoverageStatus: selectors.general.newsCoverageStatus(state), contentTypes: selectors.general.contentTypes(state), defaultDesk: selectors.general.defaultDesk(state), - preferredCoverageDesks: get(selectors.general.preferredCoverageDesks(state), 'desks'), associatedPlannings: selectors.events.getRelatedPlannings(state), associatedEvents: selectors.events.planningEditAssociatedEvents(state), currentWorkspace: selectors.general.currentWorkspace(state), @@ -53,7 +52,6 @@ const mapStateToPropsModal = (state) => ({ inModalView: !!selectors.forms.currentItemIdModal(state), contentTypes: selectors.general.contentTypes(state), defaultDesk: selectors.general.defaultDesk(state), - preferredCoverageDesks: get(selectors.general.preferredCoverageDesks(state), 'desks'), associatedPlannings: selectors.events.getRelatedPlanningsForModalEvent(state), associatedEvents: selectors.events.planningEditAssociatedEventsModal(state), currentWorkspace: selectors.general.currentWorkspace(state), diff --git a/client/components/Main/ItemEditor/ItemManager.ts b/client/components/Main/ItemEditor/ItemManager.ts index 0e401ef25..2b2fd570d 100644 --- a/client/components/Main/ItemEditor/ItemManager.ts +++ b/client/components/Main/ItemEditor/ItemManager.ts @@ -27,6 +27,7 @@ import * as actions from '../../../actions'; import {EditorComponent} from './Editor'; import {AutoSave} from './AutoSave'; import {EditorGroup} from '../../Editor/EditorGroup'; +import * as selectors from '../../../selectors'; export class ItemManager { @@ -863,13 +864,16 @@ export class ItemManager { } addCoverage(g2ContentType) { + const state = planningApi.redux.store.getState(); + const preferredCoverageDesks = selectors.general.preferredCoverageDesks(state)?.desks ?? {}; + const newCoverage = planningUtils.defaultCoverageValues( this.props.newsCoverageStatus, this.state.initialValues, this.props.associatedEvents?.[0] ?? null, // TAG: MULTIPLE_PRIMARY_EVENTS g2ContentType, this.props.defaultDesk, - this.props.preferredCoverageDesks + preferredCoverageDesks, ); this.editor.onChangeHandler( diff --git a/client/components/Main/ItemEditor/tests/ItemManager_test.ts b/client/components/Main/ItemEditor/tests/ItemManager_test.ts index f7a84c536..8a90eb041 100644 --- a/client/components/Main/ItemEditor/tests/ItemManager_test.ts +++ b/client/components/Main/ItemEditor/tests/ItemManager_test.ts @@ -89,7 +89,6 @@ describe('components.Main.ItemManager', () => { inModalView: false, newsCoverageStatus: null, defaultDesk: null, - preferredCoverageDesks: null, onCancel: null, occurStatuses: testData.vocabularies.eventoccurstatus, diff --git a/client/components/Planning/PlanningEditor/index.tsx b/client/components/Planning/PlanningEditor/index.tsx index eeafed9f9..8e160047b 100644 --- a/client/components/Planning/PlanningEditor/index.tsx +++ b/client/components/Planning/PlanningEditor/index.tsx @@ -55,7 +55,6 @@ interface IProps { user: IUser['_id']; contentTypes: Array; defaultDesk?: IDesk; - preferredCoverageDesks: {[key: string]: string}; files: Array; lockedItems: ILockedItems; @@ -87,7 +86,6 @@ const mapStateToProps = (state) => ({ desk: selectors.general.currentDeskId(state), user: selectors.general.currentUserId(state), defaultDesk: selectors.general.defaultDesk(state), - preferredCoverageDesks: get(selectors.general.preferredCoverageDesks(state), 'desks'), files: selectors.general.files(state), contentTypes: selectors.general.contentTypes(state), formProfile: selectors.forms.planningProfile(state), @@ -406,7 +404,6 @@ class PlanningEditorComponent extends React.Component { originalCount: this.props.item?.coverages?.length ?? 0, message: this.props.message, event: this.props.event, // TAG: MULTIPLE_PRIMARY_EVENTS - preferredCoverageDesks: this.props.preferredCoverageDesks, defaultValue: [], files: this.props.files, uploadFiles: this.props.uploadFiles, diff --git a/client/components/UI/DateTime.tsx b/client/components/UI/DateTime.tsx index 9c279a45c..f3065a2c7 100644 --- a/client/components/UI/DateTime.tsx +++ b/client/components/UI/DateTime.tsx @@ -19,6 +19,7 @@ interface IPropsDateTime { isEndEventDateTime?: boolean, noEndTime?: boolean, multiDay?: boolean, + testId?: string, } /** @@ -37,6 +38,7 @@ function DateTime({ isEndEventDateTime, noEndTime, multiDay, + testId, }: IPropsDateTime) { const {gettext} = superdeskApi.localization; const dateFormat = appConfig.planning.dateformat; @@ -78,7 +80,7 @@ function DateTime({ const tz = timeUtils.getTimeZoneAbbreviation(date.format('z')) + ' '; return ( -