Skip to content

Commit

Permalink
#8164 Follow-up: add deployment tests (#8173)
Browse files Browse the repository at this point in the history
* add test for deactivating unassigned mods

* fix type error
  • Loading branch information
mnholtz committed Apr 8, 2024
1 parent 78fc523 commit 21c22fb
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/extensionConsole/pages/deployments/DeploymentsContext.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,40 @@ describe("DeploymentsContext", () => {
expect((options as ModComponentState).extensions).toHaveLength(1);
});

it("automatically deactivates unassigned deployments", async () => {
const { deployment, modDefinition } = activatableDeploymentFactory({});
// Deployment has been unassigned
axiosMock.onPost("/api/deployments/").reply(200, []);

const { getReduxStore } = render(
<DeploymentsProvider>
<Component />
</DeploymentsProvider>,
{
setupRedux(dispatch) {
dispatch(
extensionsSlice.actions.activateMod({
modDefinition,
deployment,
screen: "extensionConsole",
isReactivate: false,
}),
);
},
},
);

await waitFor(() => {
// Initial fetch with unassigned mod
expect(axiosMock.history.post).toHaveLength(2);
});

const {
options: { extensions: activatedModComponents },
} = getReduxStore().getState() as { options: ModComponentState };
expect(activatedModComponents).toHaveLength(0);
});

it("updating deployment reactivates mod that was previously unmanaged for restricted user", async () => {
axiosMock.onGet("/api/me/").reply(200, { flags: ["restricted-uninstall"] });
const { deployment, modDefinition } = activatableDeploymentFactory();
Expand Down

0 comments on commit 21c22fb

Please sign in to comment.