-
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.
Browse files
Browse the repository at this point in the history
* Add server version to cluster * Add components to display compatibility promise * Show compatibility promise on status page * Show compatibility promise on setup page * Rename `serverVersion` -> `proxyVersion`, make all places to use `makeRootCluster`/`makeLeafCluster` * Move `UpgradeAgentSuggestion` to a new file, make it stateless * Return `isAgentCompatible` instead of `isNonCompatibleAgent` from context * Add // DELETE IN comments * Improve copies * Add a story for too old client in Setup * Extract CONNECT_MY_COMPUTER_RELEASE_MAJOR_VERSION * Run prettier * Fix license * Show an error on the CMC icon when the agent is not compatible * Always say "version" before the version number * Adjust tests * Drop "if you wish" from the copies (cherry picked from commit 81c352c)
- Loading branch information
Showing
26 changed files
with
850 additions
and
249 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
125 changes: 125 additions & 0 deletions
125
web/packages/teleterm/src/ui/ConnectMyComputer/CompatibilityPromise.test.tsx
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 |
---|---|---|
@@ -0,0 +1,125 @@ | ||
/** | ||
* Copyright 2023 Gravitational, Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { screen } from '@testing-library/react'; | ||
import { render } from 'design/utils/testing'; | ||
|
||
import { makeRootCluster } from 'teleterm/services/tshd/testHelpers'; | ||
import { makeRuntimeSettings } from 'teleterm/mainProcess/fixtures/mocks'; | ||
import { MockAppContextProvider } from 'teleterm/ui/fixtures/MockAppContextProvider'; | ||
import { MockWorkspaceContextProvider } from 'teleterm/ui/fixtures/MockWorkspaceContextProvider'; | ||
import { MockAppContext } from 'teleterm/ui/fixtures/mocks'; | ||
|
||
import { isAgentCompatible, CompatibilityError } from './CompatibilityPromise'; | ||
|
||
describe('isAgentCompatible', () => { | ||
const testCases = [ | ||
{ | ||
agentVersion: '2.0.0', | ||
proxyVersion: '2.0.0', | ||
isCompatible: true, | ||
}, | ||
{ | ||
agentVersion: '2.1.0', | ||
proxyVersion: '2.0.0', | ||
isCompatible: true, | ||
}, | ||
{ | ||
agentVersion: '3.0.0', | ||
proxyVersion: '2.0.0', | ||
isCompatible: false, | ||
}, | ||
{ | ||
agentVersion: '2.0.0', | ||
proxyVersion: '3.0.0', | ||
isCompatible: true, | ||
}, | ||
{ | ||
agentVersion: '2.0.0', | ||
proxyVersion: '4.0.0', | ||
isCompatible: false, | ||
}, | ||
]; | ||
test.each(testCases)( | ||
'should agent $agentVersion and cluster $proxyVersion be compatible? $isCompatible', | ||
({ agentVersion, proxyVersion, isCompatible }) => { | ||
expect( | ||
isAgentCompatible( | ||
proxyVersion, | ||
makeRuntimeSettings({ appVersion: agentVersion }) | ||
) | ||
).toBe(isCompatible); | ||
} | ||
); | ||
}); | ||
|
||
test('compatibilityError shows app upgrade instructions', async () => { | ||
const agentVersion = '1.0.0'; | ||
const proxyVersion = '3.0.0'; | ||
const appContext = new MockAppContext({ appVersion: agentVersion }); | ||
const cluster = makeRootCluster({ proxyVersion }); | ||
appContext.clustersService.setState(draftState => { | ||
draftState.clusters.set(cluster.uri, cluster); | ||
}); | ||
|
||
render( | ||
<MockAppContextProvider appContext={appContext}> | ||
<MockWorkspaceContextProvider rootClusterUri={cluster.uri}> | ||
<CompatibilityError /> | ||
</MockWorkspaceContextProvider> | ||
</MockAppContextProvider> | ||
); | ||
|
||
await expect( | ||
screen.findByText( | ||
/The cluster is on version 3.0.0 while Teleport Connect is on version 1.0.0./ | ||
) | ||
).resolves.toBeVisible(); | ||
await expect( | ||
screen.findByText(/upgrade the app to 3.x.x/) | ||
).resolves.toBeVisible(); | ||
}); | ||
|
||
test('compatibilityError shows cluster upgrade (and app downgrade) instructions', async () => { | ||
const agentVersion = '15.0.0'; | ||
const proxyVersion = '14.0.0'; | ||
const appContext = new MockAppContext({ appVersion: agentVersion }); | ||
const cluster = makeRootCluster({ proxyVersion }); | ||
appContext.clustersService.setState(draftState => { | ||
draftState.clusters.set(cluster.uri, cluster); | ||
}); | ||
|
||
render( | ||
<MockAppContextProvider appContext={appContext}> | ||
<MockWorkspaceContextProvider rootClusterUri={cluster.uri}> | ||
<CompatibilityError /> | ||
</MockWorkspaceContextProvider> | ||
</MockAppContextProvider> | ||
); | ||
|
||
await expect( | ||
screen.findByText( | ||
/The cluster is on version 14.0.0 while Teleport Connect is on version 15.0.0./ | ||
) | ||
).resolves.toBeVisible(); | ||
await expect( | ||
screen.findByText(/downgrade the app to version 14.1.0/) | ||
).resolves.toBeVisible(); | ||
await expect( | ||
screen.findByText(/upgrade the cluster to version 15.x.x/) | ||
).resolves.toBeVisible(); | ||
}); |
Oops, something went wrong.