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 committed 2022-07-27 09:22:42 +03:00
1 parent 9f0b9adce8
commit cd5c2c275a
2 files changed
+71 -2

No files matched your search

@@ -1111,9 +1111,74 @@ exports[`cluster/namespaces - edit namespaces from previously opened tab given t
style="flex-basis: 300px;"
>
<div
class="Spinner singleColor center"
data-testid="edit-resource-tab-spinner"
class="EditResource flex column"
>
<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>
@@ -3,6 +3,7 @@
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
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 { getApplicationBuilder } from "../../../renderer/components/test-utils/get-application-builder";
import React from "react";
@@ -146,11 +147,14 @@ describe("cluster/namespaces - edit namespaces from previously opened tab", () =
},
});
// TODO: Figure out why act is needed here. In CI it works without it.
await act(async () => {
await callForNamespaceMock.resolve({
callWasSuccessful: true,
response: someNamespace,
});
});
});
it("renders", () => {
expect(rendered.baseElement).toMatchSnapshot();