1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Wrap resolving async stuff with act to make component update properly in all environments

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen 2022-07-26 20:59:52 +03:00
parent 9f0b9adce8
commit cd5c2c275a
No known key found for this signature in database
GPG Key ID: 8C6CFB2FFFE8F68A
2 changed files with 75 additions and 6 deletions

View File

@ -1111,9 +1111,74 @@ exports[`cluster/namespaces - edit namespaces from previously opened tab given t
style="flex-basis: 300px;" style="flex-basis: 300px;"
> >
<div <div
class="Spinner singleColor center" class="EditResource flex column"
data-testid="edit-resource-tab-spinner" >
/> <div
class="InfoPanel flex gaps align-center"
>
<div
class="controls"
>
<div
class="resource-info flex gaps align-center"
>
<span>
Kind:
</span>
<div
class="badge"
>
Namespace
</div>
<span>
Name:
</span>
<div
class="badge"
>
some-name
</div>
<span>
Namespace:
</span>
<div
class="badge"
>
default
</div>
</div>
</div>
<div
class="flex gaps align-center"
/>
<button
class="Button plain"
data-testid="cancel-edit-resource-from-tab-for-some-first-tab-id"
type="button"
>
Cancel
</button>
<button
class="Button active outlined"
data-testid="save-edit-resource-from-tab-for-some-first-tab-id"
type="button"
>
Save
</button>
<button
class="Button primary active"
data-testid="save-and-close-edit-resource-from-tab-for-some-first-tab-id"
type="button"
>
Save & Close
</button>
</div>
<textarea
data-testid="monaco-editor-for-some-first-tab-id"
>
some-saved-configuration
</textarea>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -3,6 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import type { RenderResult } from "@testing-library/react"; import type { RenderResult } from "@testing-library/react";
import { act } from "@testing-library/react";
import type { ApplicationBuilder } from "../../../renderer/components/test-utils/get-application-builder"; import type { ApplicationBuilder } from "../../../renderer/components/test-utils/get-application-builder";
import { getApplicationBuilder } from "../../../renderer/components/test-utils/get-application-builder"; import { getApplicationBuilder } from "../../../renderer/components/test-utils/get-application-builder";
import React from "react"; import React from "react";
@ -146,9 +147,12 @@ describe("cluster/namespaces - edit namespaces from previously opened tab", () =
}, },
}); });
await callForNamespaceMock.resolve({ // TODO: Figure out why act is needed here. In CI it works without it.
callWasSuccessful: true, await act(async () => {
response: someNamespace, await callForNamespaceMock.resolve({
callWasSuccessful: true,
response: someNamespace,
});
}); });
}); });