Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd1c9f3f

Browse files
committed
Add extra test for unknown latencies
1 parent1305931 commitd1c9f3f

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

‎site/src/contexts/ProxyContext.test.tsx‎

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jest.mock("contexts/useProxyLatency", () => ({
3232

3333
lethardCodedLatencies:Record<string,ProxyLatency.ProxyLatencyReport>={}
3434

35+
// fakeLatency is a helper function to make a Latency report from just a number.
3536
constfakeLatency=(ms:number):ProxyLatency.ProxyLatencyReport=>{
3637
return{
3738
latencyMS:ms,
@@ -164,12 +165,23 @@ const TestingScreen = () => {
164165
}
165166

166167
interfaceProxyContextSelectionTest{
168+
// Regions is the list of regions to return via the "api" response.
167169
regions:Region[]
170+
// storageProxy should be the proxy stored in local storage before the
171+
// component is mounted and context is loaded. This simulates opening a
172+
// new window with a selection saved from before.
168173
storageProxy:Region|undefined
174+
// latencies is the hard coded latencies to return. If empty, no latencies
175+
// are returned.
169176
latencies?:Record<string,ProxyLatency.ProxyLatencyReport>
177+
// afterLoad are actions to take after loading the component, but before
178+
// assertions. This is useful for simulating user actions.
170179
afterLoad?:(user:typeofuserEvent)=>Promise<void>
171180

181+
// Assert these values.
182+
// expProxyID is the proxyID returned to be used.
172183
expProxyID:string
184+
// expUserProxyID is the user's stored selection.
173185
expUserProxyID?:string
174186
}
175187

@@ -301,6 +313,23 @@ describe("ProxyContextSelection", () => {
301313
},
302314
},
303315
],
316+
[
317+
// Excess proxies we do not have are low latency.
318+
// This will probably never happen in production.
319+
"unknown_regions_low_latency",
320+
{
321+
// Default to primary since we have unknowns
322+
expProxyID:MockPrimaryWorkspaceProxy.id,
323+
regions:MockWorkspaceProxies,
324+
storageProxy:MockUnhealthyWildWorkspaceProxy,
325+
expUserProxyID:MockUnhealthyWildWorkspaceProxy.id,
326+
latencies:{
327+
["some"]:fakeLatency(500),
328+
["random"]:fakeLatency(100),
329+
["ids"]:fakeLatency(25),
330+
},
331+
},
332+
],
304333
]as[string,ProxyContextSelectionTest][])(
305334
`%s`,
306335
async(
@@ -317,12 +346,6 @@ describe("ProxyContextSelection", () => {
317346
// Mock the latencies
318347
hardCodedLatencies=latencies
319348

320-
// jest.mock("contexts/useProxyLatency", () => ({
321-
// useProxyLatency: () => {
322-
// return latencies
323-
// },
324-
// }))
325-
326349
// Initial selection if present
327350
if(storageProxy){
328351
saveUserSelectedProxy(storageProxy)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp