From 8ab9ac335c31d235171db2cce5a21d80379ebfc6 Mon Sep 17 00:00:00 2001 From: Ben Yackley <61990921+beyackle@users.noreply.github.com> Date: Mon, 29 Jun 2020 16:59:45 -0700 Subject: [PATCH 01/11] split some actions off setSettings --- .../packages/client/src/constants/index.ts | 2 ++ .../client/src/pages/publish/index.tsx | 12 ++++++------ .../pages/setting/dialog-settings/index.tsx | 3 +-- .../pages/setting/runtime-settings/index.tsx | 1 + .../packages/client/src/store/action/eject.ts | 18 ++++++------------ .../client/src/store/action/setting.ts | 19 +++++++++++++++++++ .../src/store/persistence/FilePersistence.ts | 1 + .../client/src/store/reducer/index.ts | 16 ++++++++++++++++ 8 files changed, 52 insertions(+), 20 deletions(-) diff --git a/Composer/packages/client/src/constants/index.ts b/Composer/packages/client/src/constants/index.ts index 28d47e3613..880467e028 100644 --- a/Composer/packages/client/src/constants/index.ts +++ b/Composer/packages/client/src/constants/index.ts @@ -102,6 +102,8 @@ export enum ActionTypes { REMOVE_SKILL_MANIFEST = 'REMOVE_SKILL_MANIFEST', DISPLAY_SKILL_MANIFEST_MODAL = 'DISPLAY_SKILL_MANIFEST_MODAL', DISMISS_SKILL_MANIFEST_MODAL = 'DISMISS_SKILL_MANIFEST_MODAL', + SET_PUBLISH_TARGETS = 'SET_PUBLISH_TARGETS', + SET_RUNTIME_SETTINGS = 'SET_RUNTIME_SETTINGS', } export const Tips = { diff --git a/Composer/packages/client/src/pages/publish/index.tsx b/Composer/packages/client/src/pages/publish/index.tsx index 2d2b375f83..4490b361f8 100644 --- a/Composer/packages/client/src/pages/publish/index.tsx +++ b/Composer/packages/client/src/pages/publish/index.tsx @@ -221,14 +221,14 @@ const Publish: React.FC = (props) => { const savePublishTarget = useCallback( async (name: string, type: string, configuration: string) => { - const target = (settings.publishTargets || []).concat([ + const targets = (settings.publishTargets || []).concat([ { name, type, configuration, }, ]); - await actions.setSettings(projectId, { ...settings, publishTargets: target }); + await actions.setPublishTargets(targets); onSelectTarget(name); }, [settings.publishTargets, projectId, botName] @@ -248,7 +248,7 @@ const Publish: React.FC = (props) => { configuration, }; - await actions.setSettings(projectId, { ...settings, publishTargets: targets }); + await actions.setPublishTargets(targets); onSelectTarget(name); }, @@ -314,7 +314,7 @@ const Publish: React.FC = (props) => { } }); - await actions.setSettings(projectId, { ...settings, publishTargets: updatedPublishTargets }); + await actions.setPublishTargets(updatedPublishTargets); } }, [projectId, selectedTarget, settings.publishTargets] @@ -339,8 +339,8 @@ const Publish: React.FC = (props) => { if (result) { if (settings.publishTargets && settings.publishTargets.length > index) { - const target = settings.publishTargets.slice(0, index).concat(settings.publishTargets.slice(index + 1)); - await actions.setSettings(projectId, { ...settings, publishTargets: target }); + const targets = settings.publishTargets.slice(0, index).concat(settings.publishTargets.slice(index + 1)); + await actions.setPublishTargets(targets); // redirect to all profiles setSelectedTarget(undefined); onSelectTarget('all'); diff --git a/Composer/packages/client/src/pages/setting/dialog-settings/index.tsx b/Composer/packages/client/src/pages/setting/dialog-settings/index.tsx index 42c1bf27c3..a36b9e0f07 100644 --- a/Composer/packages/client/src/pages/setting/dialog-settings/index.tsx +++ b/Composer/packages/client/src/pages/setting/dialog-settings/index.tsx @@ -30,8 +30,7 @@ export const DialogSettings: React.FC = () => { const saveChangeResult = (result) => { try { - const mergedResult = result; - actions.setSettings(projectId, mergedResult); + actions.setSettings(projectId, result); } catch (err) { // eslint-disable-next-line no-console console.error(err.message); diff --git a/Composer/packages/client/src/pages/setting/runtime-settings/index.tsx b/Composer/packages/client/src/pages/setting/runtime-settings/index.tsx index 3c4dd2cd5d..b91b8b0420 100644 --- a/Composer/packages/client/src/pages/setting/runtime-settings/index.tsx +++ b/Composer/packages/client/src/pages/setting/runtime-settings/index.tsx @@ -23,6 +23,7 @@ export const RuntimeSettings: React.FC = () => { const [ejectModalVisible, setEjectModalVisible] = useState(false); const changeEnabled = (_, on) => { + // TODO: CHANGE THIS actions.setSettings(projectId, { ...settings, runtime: { ...settings.runtime, customRuntime: on } }); }; diff --git a/Composer/packages/client/src/store/action/eject.ts b/Composer/packages/client/src/store/action/eject.ts index 2c3d7f8042..279be4bc44 100644 --- a/Composer/packages/client/src/store/action/eject.ts +++ b/Composer/packages/client/src/store/action/eject.ts @@ -5,7 +5,7 @@ import { ActionCreator } from '../types'; import { ActionTypes } from './../../constants/index'; import httpClient from './../../utils/httpUtil'; -import { setSettings } from './setting'; +import { setRuntimeSettings } from './setting'; export const getRuntimeTemplates: ActionCreator = async ({ dispatch }) => { try { @@ -23,23 +23,17 @@ export const getRuntimeTemplates: ActionCreator = async ({ dispatch }) => { }; export const ejectRuntime: ActionCreator = async (store, projectId, name) => { - const { dispatch, getState } = store; + const { dispatch } = store; try { const response = await httpClient.post(`/runtime/eject/${projectId}/${name}`); dispatch({ type: ActionTypes.EJECT_SUCCESS, payload: response.data, }); - if (response.data.settings && response.data.settings.path) { - const { settings: oldsettings } = getState(); - setSettings(store, projectId, { - ...oldsettings, - runtime: { - ...oldsettings.runtime, - customRuntime: true, - path: response.data.settings.path, - command: response.data.settings.startCommand, - }, + if (response.data.settings?.path) { + setRuntimeSettings(store, { + path: response.data.settings.path, + command: response.data.settings.startCommand, }); } } catch (err) { diff --git a/Composer/packages/client/src/store/action/setting.ts b/Composer/packages/client/src/store/action/setting.ts index e3b38ca806..27a5595a93 100644 --- a/Composer/packages/client/src/store/action/setting.ts +++ b/Composer/packages/client/src/store/action/setting.ts @@ -14,3 +14,22 @@ export const setSettings: ActionCreator = async ({ dispatch }, projectId: string }, }); }; + +export const setPublishTarget: ActionCreator = async ({ dispatch }, publishTarget) => { + dispatch({ + type: ActionTypes.SET_PUBLISH_TARGETS, + payload: { + publishTarget, + }, + }); +}; + +export const setRuntimeSettings: ActionCreator = async ({ dispatch }, { path, commands }) => { + dispatch({ + type: ActionTypes.SET_RUNTIME_SETTINGS, + payload: { + path, + commands, + }, + }); +}; diff --git a/Composer/packages/client/src/store/persistence/FilePersistence.ts b/Composer/packages/client/src/store/persistence/FilePersistence.ts index af3787420b..f0ce9132d2 100644 --- a/Composer/packages/client/src/store/persistence/FilePersistence.ts +++ b/Composer/packages/client/src/store/persistence/FilePersistence.ts @@ -25,6 +25,7 @@ const actionType2ChangeType = { [ActionTypes.REMOVE_SKILL_MANIFEST]: { changeType: ChangeType.DELETE, fileExtension: FileExtensions.Manifest }, [ActionTypes.UPDATE_SKILL_MANIFEST]: { changeType: ChangeType.UPDATE, fileExtension: FileExtensions.Manifest }, [ActionTypes.SYNC_ENV_SETTING]: { changeType: ChangeType.UPDATE, fileExtension: FileExtensions.Setting }, + [ActionTypes.SET_PUBLISH_TARGETS]: { changeType: ChangeType.UPDATE, fileExtension: FileExtensions.Setting }, }; class FilePersistence { diff --git a/Composer/packages/client/src/store/reducer/index.ts b/Composer/packages/client/src/store/reducer/index.ts index 9ba0eb1dc1..088d159ba6 100644 --- a/Composer/packages/client/src/store/reducer/index.ts +++ b/Composer/packages/client/src/store/reducer/index.ts @@ -447,6 +447,20 @@ const syncEnvSetting: ReducerFunc = (state, { settings, projectId }) => { return state; }; +const setPublishTargets: ReducerFunc = (state, { publishTarget }) => { + state.publishTargets = publishTarget; + return state; +}; + +const setRuntimeSettings: ReducerFunc = (state, { path, command }) => { + state.settings.runtime = { + customRuntime: true, + path, + command, + }; + return state; +}; + const setTemplateProjects: ReducerFunc = (state, { response } = {}) => { const data = response && response.data; @@ -702,4 +716,6 @@ export const reducer = createReducer({ [ActionTypes.SET_APP_UPDATE_STATUS]: setAppUpdateStatus, [ActionTypes.DISPLAY_SKILL_MANIFEST_MODAL]: displaySkillManifestModal, [ActionTypes.DISMISS_SKILL_MANIFEST_MODAL]: dismissSkillManifestModal, + [ActionTypes.SET_PUBLISH_TARGETS]: setPublishTargets, + [ActionTypes.SET_RUNTIME_SETTINGS]: setRuntimeSettings, }); From cfb445e43b06c7547987bf0b1d7bd36810f9229e Mon Sep 17 00:00:00 2001 From: Ben Yackley <61990921+beyackle@users.noreply.github.com> Date: Tue, 30 Jun 2020 15:30:23 -0700 Subject: [PATCH 02/11] add more actions - eject still not working --- .../packages/client/src/constants/index.ts | 2 ++ .../pages/setting/runtime-settings/index.tsx | 12 +++++----- .../client/src/store/action/setting.ts | 23 +++++++++++++++++-- .../src/store/persistence/FilePersistence.ts | 1 + .../client/src/store/reducer/index.ts | 12 ++++++++++ .../packages/server/src/services/project.ts | 10 ++++---- 6 files changed, 47 insertions(+), 13 deletions(-) diff --git a/Composer/packages/client/src/constants/index.ts b/Composer/packages/client/src/constants/index.ts index 880467e028..56ca676496 100644 --- a/Composer/packages/client/src/constants/index.ts +++ b/Composer/packages/client/src/constants/index.ts @@ -104,6 +104,8 @@ export enum ActionTypes { DISMISS_SKILL_MANIFEST_MODAL = 'DISMISS_SKILL_MANIFEST_MODAL', SET_PUBLISH_TARGETS = 'SET_PUBLISH_TARGETS', SET_RUNTIME_SETTINGS = 'SET_RUNTIME_SETTINGS', + SET_CUSTOM_RUNTIME_TOGGLE = 'SET_CUSTOM_RUNTIME_TOGGLE', + SET_RUNTIME_FIELD = 'SET_RUNTIME_FIELD', } export const Tips = { diff --git a/Composer/packages/client/src/pages/setting/runtime-settings/index.tsx b/Composer/packages/client/src/pages/setting/runtime-settings/index.tsx index b91b8b0420..576e636637 100644 --- a/Composer/packages/client/src/pages/setting/runtime-settings/index.tsx +++ b/Composer/packages/client/src/pages/setting/runtime-settings/index.tsx @@ -18,13 +18,13 @@ import { breathingSpace, runtimeSettingsStyle, runtimeControls, runtimeToggle, c export const RuntimeSettings: React.FC = () => { const { state, actions } = useContext(StoreContext); + const { setCustomRuntime, setRuntimeField } = actions; const { botName, settings, projectId } = state; const [formDataErrors, setFormDataErrors] = useState({ command: '', path: '' }); const [ejectModalVisible, setEjectModalVisible] = useState(false); - const changeEnabled = (_, on) => { - // TODO: CHANGE THIS - actions.setSettings(projectId, { ...settings, runtime: { ...settings.runtime, customRuntime: on } }); + const handleChangeToggle = (_, isOn = false) => { + setCustomRuntime(projectId, isOn); }; const updateSetting = (field) => (e, newValue) => { @@ -35,7 +35,7 @@ export const RuntimeSettings: React.FC = () => { error = 'This is a required field.'; } - actions.setSettings(projectId, { ...settings, runtime: { ...settings.runtime, [field]: newValue } }); + setRuntimeField(projectId, field, newValue); if (valid) { setFormDataErrors({ ...formDataErrors, [field]: '' }); @@ -54,9 +54,9 @@ export const RuntimeSettings: React.FC = () => {
); diff --git a/Composer/packages/client/src/store/action/setting.ts b/Composer/packages/client/src/store/action/setting.ts index 27a5595a93..fac9265f7d 100644 --- a/Composer/packages/client/src/store/action/setting.ts +++ b/Composer/packages/client/src/store/action/setting.ts @@ -15,7 +15,7 @@ export const setSettings: ActionCreator = async ({ dispatch }, projectId: string }); }; -export const setPublishTarget: ActionCreator = async ({ dispatch }, publishTarget) => { +export const setPublishTarget: ActionCreator = async ({ dispatch }, _, publishTarget) => { dispatch({ type: ActionTypes.SET_PUBLISH_TARGETS, payload: { @@ -24,7 +24,7 @@ export const setPublishTarget: ActionCreator = async ({ dispatch }, publishTarge }); }; -export const setRuntimeSettings: ActionCreator = async ({ dispatch }, { path, commands }) => { +export const setRuntimeSettings: ActionCreator = async ({ dispatch }, _, path, commands) => { dispatch({ type: ActionTypes.SET_RUNTIME_SETTINGS, payload: { @@ -33,3 +33,22 @@ export const setRuntimeSettings: ActionCreator = async ({ dispatch }, { path, co }, }); }; + +export const setCustomRuntime: ActionCreator = async ({ dispatch }, _, isOn) => { + dispatch({ + type: ActionTypes.SET_CUSTOM_RUNTIME_TOGGLE, + payload: { + isOn, + }, + }); +}; + +export const setRuntimeField: ActionCreator = async ({ dispatch }, _, field, newValue) => { + dispatch({ + type: ActionTypes.SET_RUNTIME_FIELD, + payload: { + field, + newValue, + }, + }); +}; diff --git a/Composer/packages/client/src/store/persistence/FilePersistence.ts b/Composer/packages/client/src/store/persistence/FilePersistence.ts index f0ce9132d2..a3abf10a25 100644 --- a/Composer/packages/client/src/store/persistence/FilePersistence.ts +++ b/Composer/packages/client/src/store/persistence/FilePersistence.ts @@ -26,6 +26,7 @@ const actionType2ChangeType = { [ActionTypes.UPDATE_SKILL_MANIFEST]: { changeType: ChangeType.UPDATE, fileExtension: FileExtensions.Manifest }, [ActionTypes.SYNC_ENV_SETTING]: { changeType: ChangeType.UPDATE, fileExtension: FileExtensions.Setting }, [ActionTypes.SET_PUBLISH_TARGETS]: { changeType: ChangeType.UPDATE, fileExtension: FileExtensions.Setting }, + [ActionTypes.SET_RUNTIME_SETTINGS]: { changeType: ChangeType.UPDATE, fileExtension: FileExtensions.Setting }, }; class FilePersistence { diff --git a/Composer/packages/client/src/store/reducer/index.ts b/Composer/packages/client/src/store/reducer/index.ts index 088d159ba6..371cec97fd 100644 --- a/Composer/packages/client/src/store/reducer/index.ts +++ b/Composer/packages/client/src/store/reducer/index.ts @@ -461,6 +461,16 @@ const setRuntimeSettings: ReducerFunc = (state, { path, command }) => { return state; }; +const setRuntimeField: ReducerFunc = (state, { field, newValue }) => { + if (state.settings.runtime != null) state.settings.runtime[field] = newValue; + return state; +}; + +const setCustomRuntimeToggle: ReducerFunc = (state, { isOn }) => { + setRuntimeField(state, { field: 'customRuntime', newValue: isOn }); + return state; +}; + const setTemplateProjects: ReducerFunc = (state, { response } = {}) => { const data = response && response.data; @@ -718,4 +728,6 @@ export const reducer = createReducer({ [ActionTypes.DISMISS_SKILL_MANIFEST_MODAL]: dismissSkillManifestModal, [ActionTypes.SET_PUBLISH_TARGETS]: setPublishTargets, [ActionTypes.SET_RUNTIME_SETTINGS]: setRuntimeSettings, + [ActionTypes.SET_CUSTOM_RUNTIME_TOGGLE]: setCustomRuntimeToggle, + [ActionTypes.SET_RUNTIME_FIELD]: setRuntimeField, }); diff --git a/Composer/packages/server/src/services/project.ts b/Composer/packages/server/src/services/project.ts index 1439777a07..73b6ad31bc 100644 --- a/Composer/packages/server/src/services/project.ts +++ b/Composer/packages/server/src/services/project.ts @@ -152,7 +152,7 @@ export class BotProjectService { // TODO: this should be refactored or moved into the BotProject constructor so that it can use user auth amongst other things if (!(await StorageService.checkBlob(locationRef.storageId, locationRef.path, user))) { BotProjectService.deleteRecentProject(locationRef.path); - throw new Error(`file not exist ${locationRef.path}`); + throw new Error(`file ${locationRef.path} does not exist`); } for (const key in BotProjectService.projectLocationMap) { @@ -208,16 +208,16 @@ export class BotProjectService { public static getProjectById = async (projectId: string, user?: UserIdentity): Promise => { BotProjectService.initialize(); + const path = BotProjectService.projectLocationMap[projectId]; - if (!BotProjectService.projectLocationMap?.[projectId]) { - throw new Error('project not found in cache'); + if (path == null) { + throw new Error(`project ${projectId} not found in cache`); } else { - const path = BotProjectService.projectLocationMap[projectId]; // check to make sure the project is still there! if (!(await StorageService.checkBlob('default', path, user))) { BotProjectService.deleteRecentProject(path); BotProjectService.removeProjectIdFromCache(projectId); - throw new Error(`file not exist ${path}`); + throw new Error(`file ${path} does not exist`); } const project = new BotProject({ storageId: 'default', path: path }, user); await project.init(); From e1627f0a1daf2088b5ef78a01fdc60914878150c Mon Sep 17 00:00:00 2001 From: Ben Yackley <61990921+beyackle@users.noreply.github.com> Date: Tue, 30 Jun 2020 17:05:39 -0700 Subject: [PATCH 03/11] fix arguments in eject --- Composer/packages/client/src/store/action/eject.ts | 5 +---- Composer/packages/client/src/store/action/setting.ts | 3 ++- Composer/packages/client/src/store/reducer/index.ts | 4 ++-- Composer/packages/server/src/services/project.ts | 1 + 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Composer/packages/client/src/store/action/eject.ts b/Composer/packages/client/src/store/action/eject.ts index 279be4bc44..e5855fba76 100644 --- a/Composer/packages/client/src/store/action/eject.ts +++ b/Composer/packages/client/src/store/action/eject.ts @@ -31,10 +31,7 @@ export const ejectRuntime: ActionCreator = async (store, projectId, name) => { payload: response.data, }); if (response.data.settings?.path) { - setRuntimeSettings(store, { - path: response.data.settings.path, - command: response.data.settings.startCommand, - }); + setRuntimeSettings(store, projectId, response.data.settings.path, response.data.settings.startCommand); } } catch (err) { dispatch({ diff --git a/Composer/packages/client/src/store/action/setting.ts b/Composer/packages/client/src/store/action/setting.ts index fac9265f7d..778f0cf81f 100644 --- a/Composer/packages/client/src/store/action/setting.ts +++ b/Composer/packages/client/src/store/action/setting.ts @@ -24,10 +24,11 @@ export const setPublishTarget: ActionCreator = async ({ dispatch }, _, publishTa }); }; -export const setRuntimeSettings: ActionCreator = async ({ dispatch }, _, path, commands) => { +export const setRuntimeSettings: ActionCreator = async ({ dispatch }, projectId: string, path, commands) => { dispatch({ type: ActionTypes.SET_RUNTIME_SETTINGS, payload: { + projectId, path, commands, }, diff --git a/Composer/packages/client/src/store/reducer/index.ts b/Composer/packages/client/src/store/reducer/index.ts index 371cec97fd..35583def34 100644 --- a/Composer/packages/client/src/store/reducer/index.ts +++ b/Composer/packages/client/src/store/reducer/index.ts @@ -342,7 +342,7 @@ const saveTemplateId: ReducerFunc = (state, { templateId }) => { const setError: ReducerFunc = (state, payload) => { // if the error originated at the server and the server included message, use it... - if (payload && payload.status && payload.status === 409) { + if (payload?.status?.status === 409) { state.error = { status: 409, message: formatMessage( @@ -351,7 +351,7 @@ const setError: ReducerFunc = (state, payload) => { summary: formatMessage('Modification Rejected'), }; } else { - if (payload && payload.response && payload.response.data && payload.response.data.message) { + if (payload?.response?.data?.message) { state.error = payload.response.data; } else { state.error = payload; diff --git a/Composer/packages/server/src/services/project.ts b/Composer/packages/server/src/services/project.ts index 73b6ad31bc..3a81e05629 100644 --- a/Composer/packages/server/src/services/project.ts +++ b/Composer/packages/server/src/services/project.ts @@ -208,6 +208,7 @@ export class BotProjectService { public static getProjectById = async (projectId: string, user?: UserIdentity): Promise => { BotProjectService.initialize(); + const path = BotProjectService.projectLocationMap[projectId]; if (path == null) { From 7d886de20cfa77618716b99674e50d2fdef1416f Mon Sep 17 00:00:00 2001 From: Ben Yackley <61990921+beyackle@users.noreply.github.com> Date: Mon, 29 Jun 2020 16:59:45 -0700 Subject: [PATCH 04/11] split some actions off setSettings --- Composer/packages/client/src/constants.ts | 2 ++ .../client/src/pages/publish/index.tsx | 12 ++++++------ .../pages/setting/dialog-settings/index.tsx | 3 +-- .../pages/setting/runtime-settings/index.tsx | 1 + .../packages/client/src/store/action/eject.ts | 18 ++++++------------ .../client/src/store/action/setting.ts | 19 +++++++++++++++++++ .../src/store/persistence/FilePersistence.ts | 1 + .../client/src/store/reducer/index.ts | 16 ++++++++++++++++ 8 files changed, 52 insertions(+), 20 deletions(-) diff --git a/Composer/packages/client/src/constants.ts b/Composer/packages/client/src/constants.ts index 28d47e3613..880467e028 100644 --- a/Composer/packages/client/src/constants.ts +++ b/Composer/packages/client/src/constants.ts @@ -102,6 +102,8 @@ export enum ActionTypes { REMOVE_SKILL_MANIFEST = 'REMOVE_SKILL_MANIFEST', DISPLAY_SKILL_MANIFEST_MODAL = 'DISPLAY_SKILL_MANIFEST_MODAL', DISMISS_SKILL_MANIFEST_MODAL = 'DISMISS_SKILL_MANIFEST_MODAL', + SET_PUBLISH_TARGETS = 'SET_PUBLISH_TARGETS', + SET_RUNTIME_SETTINGS = 'SET_RUNTIME_SETTINGS', } export const Tips = { diff --git a/Composer/packages/client/src/pages/publish/index.tsx b/Composer/packages/client/src/pages/publish/index.tsx index 41bf64d9f8..b6276d2683 100644 --- a/Composer/packages/client/src/pages/publish/index.tsx +++ b/Composer/packages/client/src/pages/publish/index.tsx @@ -221,14 +221,14 @@ const Publish: React.FC = (props) => { const savePublishTarget = useCallback( async (name: string, type: string, configuration: string) => { - const target = (settings.publishTargets || []).concat([ + const targets = (settings.publishTargets || []).concat([ { name, type, configuration, }, ]); - await actions.setSettings(projectId, { ...settings, publishTargets: target }); + await actions.setPublishTargets(targets); onSelectTarget(name); }, [settings.publishTargets, projectId, botName] @@ -248,7 +248,7 @@ const Publish: React.FC = (props) => { configuration, }; - await actions.setSettings(projectId, { ...settings, publishTargets: targets }); + await actions.setPublishTargets(targets); onSelectTarget(name); }, @@ -314,7 +314,7 @@ const Publish: React.FC = (props) => { } }); - await actions.setSettings(projectId, { ...settings, publishTargets: updatedPublishTargets }); + await actions.setPublishTargets(updatedPublishTargets); } }, [projectId, selectedTarget, settings.publishTargets] @@ -339,8 +339,8 @@ const Publish: React.FC = (props) => { if (result) { if (settings.publishTargets && settings.publishTargets.length > index) { - const target = settings.publishTargets.slice(0, index).concat(settings.publishTargets.slice(index + 1)); - await actions.setSettings(projectId, { ...settings, publishTargets: target }); + const targets = settings.publishTargets.slice(0, index).concat(settings.publishTargets.slice(index + 1)); + await actions.setPublishTargets(targets); // redirect to all profiles setSelectedTarget(undefined); onSelectTarget('all'); diff --git a/Composer/packages/client/src/pages/setting/dialog-settings/index.tsx b/Composer/packages/client/src/pages/setting/dialog-settings/index.tsx index 36fdf7901e..6ac67a6d1a 100644 --- a/Composer/packages/client/src/pages/setting/dialog-settings/index.tsx +++ b/Composer/packages/client/src/pages/setting/dialog-settings/index.tsx @@ -30,8 +30,7 @@ export const DialogSettings: React.FC = () => { const saveChangeResult = (result) => { try { - const mergedResult = result; - actions.setSettings(projectId, mergedResult); + actions.setSettings(projectId, result); } catch (err) { // eslint-disable-next-line no-console console.error(err.message); diff --git a/Composer/packages/client/src/pages/setting/runtime-settings/index.tsx b/Composer/packages/client/src/pages/setting/runtime-settings/index.tsx index ca3c554e77..d8df04aae3 100644 --- a/Composer/packages/client/src/pages/setting/runtime-settings/index.tsx +++ b/Composer/packages/client/src/pages/setting/runtime-settings/index.tsx @@ -23,6 +23,7 @@ export const RuntimeSettings: React.FC = () => { const [ejectModalVisible, setEjectModalVisible] = useState(false); const changeEnabled = (_, on) => { + // TODO: CHANGE THIS actions.setSettings(projectId, { ...settings, runtime: { ...settings.runtime, customRuntime: on } }); }; diff --git a/Composer/packages/client/src/store/action/eject.ts b/Composer/packages/client/src/store/action/eject.ts index 73512d7d66..9bda9a99ae 100644 --- a/Composer/packages/client/src/store/action/eject.ts +++ b/Composer/packages/client/src/store/action/eject.ts @@ -5,7 +5,7 @@ import { ActionCreator } from '../types'; import { ActionTypes } from '../../constants'; import httpClient from './../../utils/httpUtil'; -import { setSettings } from './setting'; +import { setRuntimeSettings } from './setting'; export const getRuntimeTemplates: ActionCreator = async ({ dispatch }) => { try { @@ -23,23 +23,17 @@ export const getRuntimeTemplates: ActionCreator = async ({ dispatch }) => { }; export const ejectRuntime: ActionCreator = async (store, projectId, name) => { - const { dispatch, getState } = store; + const { dispatch } = store; try { const response = await httpClient.post(`/runtime/eject/${projectId}/${name}`); dispatch({ type: ActionTypes.EJECT_SUCCESS, payload: response.data, }); - if (response.data.settings && response.data.settings.path) { - const { settings: oldsettings } = getState(); - setSettings(store, projectId, { - ...oldsettings, - runtime: { - ...oldsettings.runtime, - customRuntime: true, - path: response.data.settings.path, - command: response.data.settings.startCommand, - }, + if (response.data.settings?.path) { + setRuntimeSettings(store, { + path: response.data.settings.path, + command: response.data.settings.startCommand, }); } } catch (err) { diff --git a/Composer/packages/client/src/store/action/setting.ts b/Composer/packages/client/src/store/action/setting.ts index a756073a6e..e047e2a2b8 100644 --- a/Composer/packages/client/src/store/action/setting.ts +++ b/Composer/packages/client/src/store/action/setting.ts @@ -13,3 +13,22 @@ export const setSettings: ActionCreator = async ({ dispatch }, projectId: string }, }); }; + +export const setPublishTarget: ActionCreator = async ({ dispatch }, publishTarget) => { + dispatch({ + type: ActionTypes.SET_PUBLISH_TARGETS, + payload: { + publishTarget, + }, + }); +}; + +export const setRuntimeSettings: ActionCreator = async ({ dispatch }, { path, commands }) => { + dispatch({ + type: ActionTypes.SET_RUNTIME_SETTINGS, + payload: { + path, + commands, + }, + }); +}; diff --git a/Composer/packages/client/src/store/persistence/FilePersistence.ts b/Composer/packages/client/src/store/persistence/FilePersistence.ts index af3787420b..f0ce9132d2 100644 --- a/Composer/packages/client/src/store/persistence/FilePersistence.ts +++ b/Composer/packages/client/src/store/persistence/FilePersistence.ts @@ -25,6 +25,7 @@ const actionType2ChangeType = { [ActionTypes.REMOVE_SKILL_MANIFEST]: { changeType: ChangeType.DELETE, fileExtension: FileExtensions.Manifest }, [ActionTypes.UPDATE_SKILL_MANIFEST]: { changeType: ChangeType.UPDATE, fileExtension: FileExtensions.Manifest }, [ActionTypes.SYNC_ENV_SETTING]: { changeType: ChangeType.UPDATE, fileExtension: FileExtensions.Setting }, + [ActionTypes.SET_PUBLISH_TARGETS]: { changeType: ChangeType.UPDATE, fileExtension: FileExtensions.Setting }, }; class FilePersistence { diff --git a/Composer/packages/client/src/store/reducer/index.ts b/Composer/packages/client/src/store/reducer/index.ts index 9ba0eb1dc1..088d159ba6 100644 --- a/Composer/packages/client/src/store/reducer/index.ts +++ b/Composer/packages/client/src/store/reducer/index.ts @@ -447,6 +447,20 @@ const syncEnvSetting: ReducerFunc = (state, { settings, projectId }) => { return state; }; +const setPublishTargets: ReducerFunc = (state, { publishTarget }) => { + state.publishTargets = publishTarget; + return state; +}; + +const setRuntimeSettings: ReducerFunc = (state, { path, command }) => { + state.settings.runtime = { + customRuntime: true, + path, + command, + }; + return state; +}; + const setTemplateProjects: ReducerFunc = (state, { response } = {}) => { const data = response && response.data; @@ -702,4 +716,6 @@ export const reducer = createReducer({ [ActionTypes.SET_APP_UPDATE_STATUS]: setAppUpdateStatus, [ActionTypes.DISPLAY_SKILL_MANIFEST_MODAL]: displaySkillManifestModal, [ActionTypes.DISMISS_SKILL_MANIFEST_MODAL]: dismissSkillManifestModal, + [ActionTypes.SET_PUBLISH_TARGETS]: setPublishTargets, + [ActionTypes.SET_RUNTIME_SETTINGS]: setRuntimeSettings, }); From b93e7f13d8598d99c23f88dacffb41f1add4d6e5 Mon Sep 17 00:00:00 2001 From: Ben Yackley <61990921+beyackle@users.noreply.github.com> Date: Tue, 30 Jun 2020 15:30:23 -0700 Subject: [PATCH 05/11] add more actions - eject still not working --- Composer/packages/client/src/constants.ts | 2 ++ .../pages/setting/runtime-settings/index.tsx | 12 +++++----- .../client/src/store/action/setting.ts | 23 +++++++++++++++++-- .../src/store/persistence/FilePersistence.ts | 1 + .../client/src/store/reducer/index.ts | 12 ++++++++++ .../packages/server/src/services/project.ts | 10 ++++---- 6 files changed, 47 insertions(+), 13 deletions(-) diff --git a/Composer/packages/client/src/constants.ts b/Composer/packages/client/src/constants.ts index 880467e028..56ca676496 100644 --- a/Composer/packages/client/src/constants.ts +++ b/Composer/packages/client/src/constants.ts @@ -104,6 +104,8 @@ export enum ActionTypes { DISMISS_SKILL_MANIFEST_MODAL = 'DISMISS_SKILL_MANIFEST_MODAL', SET_PUBLISH_TARGETS = 'SET_PUBLISH_TARGETS', SET_RUNTIME_SETTINGS = 'SET_RUNTIME_SETTINGS', + SET_CUSTOM_RUNTIME_TOGGLE = 'SET_CUSTOM_RUNTIME_TOGGLE', + SET_RUNTIME_FIELD = 'SET_RUNTIME_FIELD', } export const Tips = { diff --git a/Composer/packages/client/src/pages/setting/runtime-settings/index.tsx b/Composer/packages/client/src/pages/setting/runtime-settings/index.tsx index d8df04aae3..a6f7627fd6 100644 --- a/Composer/packages/client/src/pages/setting/runtime-settings/index.tsx +++ b/Composer/packages/client/src/pages/setting/runtime-settings/index.tsx @@ -18,13 +18,13 @@ import { breathingSpace, runtimeSettingsStyle, runtimeControls, runtimeToggle, c export const RuntimeSettings: React.FC = () => { const { state, actions } = useContext(StoreContext); + const { setCustomRuntime, setRuntimeField } = actions; const { botName, settings, projectId } = state; const [formDataErrors, setFormDataErrors] = useState({ command: '', path: '' }); const [ejectModalVisible, setEjectModalVisible] = useState(false); - const changeEnabled = (_, on) => { - // TODO: CHANGE THIS - actions.setSettings(projectId, { ...settings, runtime: { ...settings.runtime, customRuntime: on } }); + const handleChangeToggle = (_, isOn = false) => { + setCustomRuntime(projectId, isOn); }; const updateSetting = (field) => (e, newValue) => { @@ -35,7 +35,7 @@ export const RuntimeSettings: React.FC = () => { error = 'This is a required field.'; } - actions.setSettings(projectId, { ...settings, runtime: { ...settings.runtime, [field]: newValue } }); + setRuntimeField(projectId, field, newValue); if (valid) { setFormDataErrors({ ...formDataErrors, [field]: '' }); @@ -54,9 +54,9 @@ export const RuntimeSettings: React.FC = () => {
); diff --git a/Composer/packages/client/src/store/action/setting.ts b/Composer/packages/client/src/store/action/setting.ts index e047e2a2b8..825221208e 100644 --- a/Composer/packages/client/src/store/action/setting.ts +++ b/Composer/packages/client/src/store/action/setting.ts @@ -14,7 +14,7 @@ export const setSettings: ActionCreator = async ({ dispatch }, projectId: string }); }; -export const setPublishTarget: ActionCreator = async ({ dispatch }, publishTarget) => { +export const setPublishTarget: ActionCreator = async ({ dispatch }, _, publishTarget) => { dispatch({ type: ActionTypes.SET_PUBLISH_TARGETS, payload: { @@ -23,7 +23,7 @@ export const setPublishTarget: ActionCreator = async ({ dispatch }, publishTarge }); }; -export const setRuntimeSettings: ActionCreator = async ({ dispatch }, { path, commands }) => { +export const setRuntimeSettings: ActionCreator = async ({ dispatch }, _, path, commands) => { dispatch({ type: ActionTypes.SET_RUNTIME_SETTINGS, payload: { @@ -32,3 +32,22 @@ export const setRuntimeSettings: ActionCreator = async ({ dispatch }, { path, co }, }); }; + +export const setCustomRuntime: ActionCreator = async ({ dispatch }, _, isOn) => { + dispatch({ + type: ActionTypes.SET_CUSTOM_RUNTIME_TOGGLE, + payload: { + isOn, + }, + }); +}; + +export const setRuntimeField: ActionCreator = async ({ dispatch }, _, field, newValue) => { + dispatch({ + type: ActionTypes.SET_RUNTIME_FIELD, + payload: { + field, + newValue, + }, + }); +}; diff --git a/Composer/packages/client/src/store/persistence/FilePersistence.ts b/Composer/packages/client/src/store/persistence/FilePersistence.ts index f0ce9132d2..a3abf10a25 100644 --- a/Composer/packages/client/src/store/persistence/FilePersistence.ts +++ b/Composer/packages/client/src/store/persistence/FilePersistence.ts @@ -26,6 +26,7 @@ const actionType2ChangeType = { [ActionTypes.UPDATE_SKILL_MANIFEST]: { changeType: ChangeType.UPDATE, fileExtension: FileExtensions.Manifest }, [ActionTypes.SYNC_ENV_SETTING]: { changeType: ChangeType.UPDATE, fileExtension: FileExtensions.Setting }, [ActionTypes.SET_PUBLISH_TARGETS]: { changeType: ChangeType.UPDATE, fileExtension: FileExtensions.Setting }, + [ActionTypes.SET_RUNTIME_SETTINGS]: { changeType: ChangeType.UPDATE, fileExtension: FileExtensions.Setting }, }; class FilePersistence { diff --git a/Composer/packages/client/src/store/reducer/index.ts b/Composer/packages/client/src/store/reducer/index.ts index 088d159ba6..371cec97fd 100644 --- a/Composer/packages/client/src/store/reducer/index.ts +++ b/Composer/packages/client/src/store/reducer/index.ts @@ -461,6 +461,16 @@ const setRuntimeSettings: ReducerFunc = (state, { path, command }) => { return state; }; +const setRuntimeField: ReducerFunc = (state, { field, newValue }) => { + if (state.settings.runtime != null) state.settings.runtime[field] = newValue; + return state; +}; + +const setCustomRuntimeToggle: ReducerFunc = (state, { isOn }) => { + setRuntimeField(state, { field: 'customRuntime', newValue: isOn }); + return state; +}; + const setTemplateProjects: ReducerFunc = (state, { response } = {}) => { const data = response && response.data; @@ -718,4 +728,6 @@ export const reducer = createReducer({ [ActionTypes.DISMISS_SKILL_MANIFEST_MODAL]: dismissSkillManifestModal, [ActionTypes.SET_PUBLISH_TARGETS]: setPublishTargets, [ActionTypes.SET_RUNTIME_SETTINGS]: setRuntimeSettings, + [ActionTypes.SET_CUSTOM_RUNTIME_TOGGLE]: setCustomRuntimeToggle, + [ActionTypes.SET_RUNTIME_FIELD]: setRuntimeField, }); diff --git a/Composer/packages/server/src/services/project.ts b/Composer/packages/server/src/services/project.ts index 1439777a07..73b6ad31bc 100644 --- a/Composer/packages/server/src/services/project.ts +++ b/Composer/packages/server/src/services/project.ts @@ -152,7 +152,7 @@ export class BotProjectService { // TODO: this should be refactored or moved into the BotProject constructor so that it can use user auth amongst other things if (!(await StorageService.checkBlob(locationRef.storageId, locationRef.path, user))) { BotProjectService.deleteRecentProject(locationRef.path); - throw new Error(`file not exist ${locationRef.path}`); + throw new Error(`file ${locationRef.path} does not exist`); } for (const key in BotProjectService.projectLocationMap) { @@ -208,16 +208,16 @@ export class BotProjectService { public static getProjectById = async (projectId: string, user?: UserIdentity): Promise => { BotProjectService.initialize(); + const path = BotProjectService.projectLocationMap[projectId]; - if (!BotProjectService.projectLocationMap?.[projectId]) { - throw new Error('project not found in cache'); + if (path == null) { + throw new Error(`project ${projectId} not found in cache`); } else { - const path = BotProjectService.projectLocationMap[projectId]; // check to make sure the project is still there! if (!(await StorageService.checkBlob('default', path, user))) { BotProjectService.deleteRecentProject(path); BotProjectService.removeProjectIdFromCache(projectId); - throw new Error(`file not exist ${path}`); + throw new Error(`file ${path} does not exist`); } const project = new BotProject({ storageId: 'default', path: path }, user); await project.init(); From 0681d74e8d76babba1c49e9652a1fc7166b02475 Mon Sep 17 00:00:00 2001 From: Ben Yackley <61990921+beyackle@users.noreply.github.com> Date: Tue, 30 Jun 2020 17:05:39 -0700 Subject: [PATCH 06/11] fix arguments in eject --- Composer/packages/client/src/store/action/eject.ts | 5 +---- Composer/packages/client/src/store/action/setting.ts | 3 ++- Composer/packages/client/src/store/reducer/index.ts | 4 ++-- Composer/packages/server/src/services/project.ts | 1 + 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Composer/packages/client/src/store/action/eject.ts b/Composer/packages/client/src/store/action/eject.ts index 9bda9a99ae..2249c81068 100644 --- a/Composer/packages/client/src/store/action/eject.ts +++ b/Composer/packages/client/src/store/action/eject.ts @@ -31,10 +31,7 @@ export const ejectRuntime: ActionCreator = async (store, projectId, name) => { payload: response.data, }); if (response.data.settings?.path) { - setRuntimeSettings(store, { - path: response.data.settings.path, - command: response.data.settings.startCommand, - }); + setRuntimeSettings(store, projectId, response.data.settings.path, response.data.settings.startCommand); } } catch (err) { dispatch({ diff --git a/Composer/packages/client/src/store/action/setting.ts b/Composer/packages/client/src/store/action/setting.ts index 825221208e..db1fca586c 100644 --- a/Composer/packages/client/src/store/action/setting.ts +++ b/Composer/packages/client/src/store/action/setting.ts @@ -23,10 +23,11 @@ export const setPublishTarget: ActionCreator = async ({ dispatch }, _, publishTa }); }; -export const setRuntimeSettings: ActionCreator = async ({ dispatch }, _, path, commands) => { +export const setRuntimeSettings: ActionCreator = async ({ dispatch }, projectId: string, path, commands) => { dispatch({ type: ActionTypes.SET_RUNTIME_SETTINGS, payload: { + projectId, path, commands, }, diff --git a/Composer/packages/client/src/store/reducer/index.ts b/Composer/packages/client/src/store/reducer/index.ts index 371cec97fd..35583def34 100644 --- a/Composer/packages/client/src/store/reducer/index.ts +++ b/Composer/packages/client/src/store/reducer/index.ts @@ -342,7 +342,7 @@ const saveTemplateId: ReducerFunc = (state, { templateId }) => { const setError: ReducerFunc = (state, payload) => { // if the error originated at the server and the server included message, use it... - if (payload && payload.status && payload.status === 409) { + if (payload?.status?.status === 409) { state.error = { status: 409, message: formatMessage( @@ -351,7 +351,7 @@ const setError: ReducerFunc = (state, payload) => { summary: formatMessage('Modification Rejected'), }; } else { - if (payload && payload.response && payload.response.data && payload.response.data.message) { + if (payload?.response?.data?.message) { state.error = payload.response.data; } else { state.error = payload; diff --git a/Composer/packages/server/src/services/project.ts b/Composer/packages/server/src/services/project.ts index 73b6ad31bc..3a81e05629 100644 --- a/Composer/packages/server/src/services/project.ts +++ b/Composer/packages/server/src/services/project.ts @@ -208,6 +208,7 @@ export class BotProjectService { public static getProjectById = async (projectId: string, user?: UserIdentity): Promise => { BotProjectService.initialize(); + const path = BotProjectService.projectLocationMap[projectId]; if (path == null) { From b105584c54e6c163b7abc5421a5e0b42b6840b4b Mon Sep 17 00:00:00 2001 From: Ben Yackley <61990921+beyackle@users.noreply.github.com> Date: Wed, 1 Jul 2020 09:32:09 -0700 Subject: [PATCH 07/11] Update setting.ts --- Composer/packages/client/src/store/action/setting.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Composer/packages/client/src/store/action/setting.ts b/Composer/packages/client/src/store/action/setting.ts index db1fca586c..a25dd321e4 100644 --- a/Composer/packages/client/src/store/action/setting.ts +++ b/Composer/packages/client/src/store/action/setting.ts @@ -23,13 +23,13 @@ export const setPublishTarget: ActionCreator = async ({ dispatch }, _, publishTa }); }; -export const setRuntimeSettings: ActionCreator = async ({ dispatch }, projectId: string, path, commands) => { +export const setRuntimeSettings: ActionCreator = async ({ dispatch }, projectId: string, path, command) => { dispatch({ type: ActionTypes.SET_RUNTIME_SETTINGS, payload: { projectId, path, - commands, + command, }, }); }; From 6448d9945f5a3fd462830bdf572abfa4ee2b0752 Mon Sep 17 00:00:00 2001 From: Ben Yackley <61990921+beyackle@users.noreply.github.com> Date: Wed, 1 Jul 2020 09:59:03 -0700 Subject: [PATCH 08/11] fix some tests --- .../packages/server/__tests__/controllers/project.test.ts | 4 ++-- Composer/packages/server/__tests__/services/project.test.ts | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Composer/packages/server/__tests__/controllers/project.test.ts b/Composer/packages/server/__tests__/controllers/project.test.ts index 336880075b..19facabae8 100644 --- a/Composer/packages/server/__tests__/controllers/project.test.ts +++ b/Composer/packages/server/__tests__/controllers/project.test.ts @@ -84,7 +84,7 @@ describe('get bot project', () => { await ProjectController.getProjectById(mockReq, mockRes); expect(mockRes.status).toHaveBeenCalledWith(404); expect(mockRes.json).toHaveBeenCalledWith({ - message: 'project not found in cache', + message: 'project undefined not found in cache', }); }); @@ -121,7 +121,7 @@ describe('open bot operation', () => { await ProjectController.openProject(mockReq, mockRes); expect(mockRes.status).toHaveBeenCalledWith(400); expect(mockRes.json).toHaveBeenCalledWith({ - message: 'file not exist wrong/path', + message: 'file wrong/path does not exist', }); }); diff --git a/Composer/packages/server/__tests__/services/project.test.ts b/Composer/packages/server/__tests__/services/project.test.ts index d2771a4cd6..088212e577 100644 --- a/Composer/packages/server/__tests__/services/project.test.ts +++ b/Composer/packages/server/__tests__/services/project.test.ts @@ -61,7 +61,10 @@ afterAll(() => { describe('test BotProjectService', () => { it('openProject', async () => { const projectId = await BotProjectService.openProject(location1); - await expect(BotProjectService.getProjectById('123')).rejects.toThrowError('project not found in cache'); + const otherId = '12345.678'; + await expect(BotProjectService.getProjectById(otherId)).rejects.toThrowError( + `project ${otherId} not found in cache` + ); expect((await BotProjectService.getProjectById(projectId)).dir).toBe(projPath); }); From 691ee8413d2a43afb06f866ba48a985a3600a9f8 Mon Sep 17 00:00:00 2001 From: Ben Yackley <61990921+beyackle@users.noreply.github.com> Date: Wed, 1 Jul 2020 12:34:29 -0700 Subject: [PATCH 09/11] Update index.ts --- Composer/packages/client/src/store/reducer/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Composer/packages/client/src/store/reducer/index.ts b/Composer/packages/client/src/store/reducer/index.ts index 35583def34..47f7c44ce7 100644 --- a/Composer/packages/client/src/store/reducer/index.ts +++ b/Composer/packages/client/src/store/reducer/index.ts @@ -342,7 +342,7 @@ const saveTemplateId: ReducerFunc = (state, { templateId }) => { const setError: ReducerFunc = (state, payload) => { // if the error originated at the server and the server included message, use it... - if (payload?.status?.status === 409) { + if (payload?.status === 409) { state.error = { status: 409, message: formatMessage( From fccfc13dfe7cd825131d4f8098600934cbf21eab Mon Sep 17 00:00:00 2001 From: Ben Yackley <61990921+beyackle@users.noreply.github.com> Date: Wed, 1 Jul 2020 12:54:50 -0700 Subject: [PATCH 10/11] move logo-clicking to commands.ts --- Composer/cypress/integration/NotificationPage.spec.ts | 3 --- Composer/cypress/support/commands.ts | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Composer/cypress/integration/NotificationPage.spec.ts b/Composer/cypress/integration/NotificationPage.spec.ts index de9a31bb17..8912de9409 100644 --- a/Composer/cypress/integration/NotificationPage.spec.ts +++ b/Composer/cypress/integration/NotificationPage.spec.ts @@ -44,9 +44,6 @@ context('Notification Page', () => { it('can show dialog expression error ', () => { cy.visitPage('Design'); - // click the logo to clear any stray tooltips from page navigation - cy.findByAltText('Composer Logo').click(); - cy.findByTestId('ProjectTree').within(() => { cy.findByText('WelcomeUser').click(); }); diff --git a/Composer/cypress/support/commands.ts b/Composer/cypress/support/commands.ts index 4b9d179903..87999fef33 100644 --- a/Composer/cypress/support/commands.ts +++ b/Composer/cypress/support/commands.ts @@ -26,6 +26,9 @@ Cypress.Commands.add('withinEditor', (editorName, cb) => { Cypress.Commands.add('visitPage', (page) => { cy.findByTestId(`LeftNav-CommandBarButton${page}`).click(); cy.findByTestId('ActiveLeftNavItem').should('contain', page); + + // click the logo to clear any stray tooltips from page navigation + cy.findByAltText('Composer Logo').click(); }); Cypress.Commands.add('enterTextAndSubmit', (textElement: string, text: string, submitBtn?: string) => { From d4ab56e2c1a8b90f4dd06744d5ad163a2fd68ab1 Mon Sep 17 00:00:00 2001 From: Ben Yackley <61990921+beyackle@users.noreply.github.com> Date: Wed, 1 Jul 2020 14:37:36 -0700 Subject: [PATCH 11/11] Update commands.ts --- Composer/cypress/support/commands.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Composer/cypress/support/commands.ts b/Composer/cypress/support/commands.ts index 87999fef33..4471ed8bd3 100644 --- a/Composer/cypress/support/commands.ts +++ b/Composer/cypress/support/commands.ts @@ -28,7 +28,7 @@ Cypress.Commands.add('visitPage', (page) => { cy.findByTestId('ActiveLeftNavItem').should('contain', page); // click the logo to clear any stray tooltips from page navigation - cy.findByAltText('Composer Logo').click(); + cy.findByAltText('Composer Logo').click({ force: true }); }); Cypress.Commands.add('enterTextAndSubmit', (textElement: string, text: string, submitBtn?: string) => {