-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[v14] Make spacing of Connect My Computer status more consistent (#32736
) * Make spacing of Connect My Computer status more consistent * Add server labels to Running story, add ErrorWithAlertAndLogs story * Change copy depending on whether the agent is running * Fix proxyVersion in story Co-authored-by: Grzegorz Zdunek <[email protected]> --------- Co-authored-by: Grzegorz Zdunek <[email protected]>
- Loading branch information
Showing
4 changed files
with
206 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,11 +14,13 @@ | |
* limitations under the License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import React, { useLayoutEffect } from 'react'; | ||
|
||
import { wait } from 'shared/utils/wait'; | ||
|
||
import { makeRootCluster } from 'teleterm/services/tshd/testHelpers'; | ||
import { | ||
makeRootCluster, | ||
makeServer, | ||
makeLabelsList, | ||
} from 'teleterm/services/tshd/testHelpers'; | ||
import { MockAppContextProvider } from 'teleterm/ui/fixtures/MockAppContextProvider'; | ||
import AppContext from 'teleterm/ui/appContext'; | ||
|
||
|
@@ -30,6 +32,7 @@ import { makeRuntimeSettings } from 'teleterm/mainProcess/fixtures/mocks'; | |
import { | ||
AgentCompatibilityError, | ||
ConnectMyComputerContextProvider, | ||
NodeWaitJoinTimeout, | ||
} from '../connectMyComputerContext'; | ||
|
||
import { DocumentConnectMyComputerStatus } from './DocumentConnectMyComputerStatus'; | ||
|
@@ -43,7 +46,45 @@ export function NotStarted() { | |
} | ||
|
||
export function Running() { | ||
return <ShowState agentProcessState={{ status: 'running' }} />; | ||
const appContext = new MockAppContext({ appVersion: '17.0.0' }); | ||
|
||
let agentUpdateListener: (state: AgentProcessState) => void; | ||
appContext.mainProcessClient.subscribeToAgentUpdate = ( | ||
rootClusterUri, | ||
listener | ||
) => { | ||
agentUpdateListener = listener; | ||
return { cleanup: () => undefined }; | ||
}; | ||
appContext.connectMyComputerService.isAgentConfigFileCreated = () => | ||
Promise.resolve(true); | ||
appContext.connectMyComputerService.runAgent = async () => { | ||
agentUpdateListener({ status: 'running' }); | ||
}; | ||
appContext.connectMyComputerService.waitForNodeToJoin = () => | ||
Promise.resolve( | ||
makeServer({ | ||
hostname: 'staging-mac-mini', | ||
labelsList: makeLabelsList({ | ||
hostname: 'staging-mac-mini', | ||
'teleport.dev/connect-my-computer/owner': '[email protected]', | ||
}), | ||
}) | ||
); | ||
|
||
useLayoutEffect(() => { | ||
( | ||
document.querySelector('[data-testid=start-agent]') as HTMLButtonElement | ||
)?.click(); | ||
}); | ||
|
||
return ( | ||
<ShowState | ||
appContext={appContext} | ||
agentProcessState={{ status: 'not-started' }} | ||
proxyVersion="17.0.0" | ||
/> | ||
); | ||
} | ||
|
||
export function Errored() { | ||
|
@@ -84,6 +125,30 @@ export function ExitedUnsuccessfully() { | |
); | ||
} | ||
|
||
export function ErrorWithAlertAndLogs() { | ||
const appContext = new MockAppContext({ appVersion: '17.0.0' }); | ||
|
||
appContext.connectMyComputerService.isAgentConfigFileCreated = () => | ||
Promise.resolve(true); | ||
appContext.connectMyComputerService.waitForNodeToJoin = () => | ||
Promise.reject( | ||
new NodeWaitJoinTimeout( | ||
'teleport: error: unknown short flag -non-existing-flag' | ||
) | ||
); | ||
|
||
return ( | ||
<ShowState | ||
appContext={appContext} | ||
agentProcessState={{ | ||
status: 'not-started', | ||
}} | ||
autoStart={true} | ||
proxyVersion="17.0.0" | ||
/> | ||
); | ||
} | ||
|
||
export function FailedToReadAgentConfigFile() { | ||
const appContext = new MockAppContext(); | ||
appContext.connectMyComputerService.isAgentConfigFileCreated = async () => { | ||
|
@@ -182,40 +247,6 @@ function ShowState(props: { | |
new MockAppContext({ appVersion: cluster.proxyVersion }); | ||
|
||
appContext.mainProcessClient.getAgentState = () => props.agentProcessState; | ||
appContext.mainProcessClient.subscribeToAgentUpdate = ( | ||
rootClusterUri, | ||
listener | ||
) => { | ||
listener(props.agentProcessState); | ||
return { cleanup: () => undefined }; | ||
}; | ||
appContext.connectMyComputerService.runAgent = async () => { | ||
await wait(1_000); | ||
}; | ||
appContext.connectMyComputerService.waitForNodeToJoin = async () => { | ||
if (props.agentProcessState.status === 'running') { | ||
await wait(2_000); | ||
return { | ||
uri: `${cluster.uri}/servers/178ef081-259b-4aa5-a018-449b5ea7e694`, | ||
tunnel: false, | ||
name: '178ef081-259b-4aa5-a018-449b5ea7e694', | ||
hostname: 'staging-mac-mini', | ||
addr: '127.0.0.1:3022', | ||
labelsList: [ | ||
{ | ||
name: 'hostname', | ||
value: 'staging-mac-mini', | ||
}, | ||
{ | ||
name: 'teleport.dev/connect-my-computer', | ||
value: '[email protected]', | ||
}, | ||
], | ||
}; | ||
} | ||
await wait(3_000); | ||
throw new Error('TIMEOUT. Cannot find node.'); | ||
}; | ||
appContext.configService.set('feature.connectMyComputer', true); | ||
appContext.clustersService.state.clusters.set(cluster.uri, cluster); | ||
appContext.workspacesService.setState(draftState => { | ||
|
Oops, something went wrong.