mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fixing tests
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
daf7a89e3c
commit
eab854b58c
@ -88,9 +88,13 @@ describe("Extensions", () => {
|
|||||||
ExtensionDiscovery.getInstance().isLoaded = true;
|
ExtensionDiscovery.getInstance().isLoaded = true;
|
||||||
|
|
||||||
const res = render(<><Extensions /><ConfirmDialog /></>);
|
const res = render(<><Extensions /><ConfirmDialog /></>);
|
||||||
|
const table = res.getByTestId("extensions-table");
|
||||||
|
const menuTrigger = table.querySelector("div[role=row]:first-of-type .actions .Icon");
|
||||||
|
|
||||||
expect(res.getByText("Disable").closest("button")).not.toBeDisabled();
|
fireEvent.click(menuTrigger);
|
||||||
expect(res.getByText("Uninstall").closest("button")).not.toBeDisabled();
|
|
||||||
|
expect(res.getByText("Disable")).toHaveAttribute("aria-disabled", "false");
|
||||||
|
expect(res.getByText("Uninstall")).toHaveAttribute("aria-disabled", "false");
|
||||||
|
|
||||||
fireEvent.click(res.getByText("Uninstall"));
|
fireEvent.click(res.getByText("Uninstall"));
|
||||||
|
|
||||||
@ -99,8 +103,9 @@ describe("Extensions", () => {
|
|||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(ExtensionDiscovery.getInstance().uninstallExtension).toHaveBeenCalled();
|
expect(ExtensionDiscovery.getInstance().uninstallExtension).toHaveBeenCalled();
|
||||||
expect(res.getByText("Disable").closest("button")).toBeDisabled();
|
fireEvent.click(menuTrigger);
|
||||||
expect(res.getByText("Uninstall").closest("button")).toBeDisabled();
|
expect(res.getByText("Disable")).toHaveAttribute("aria-disabled", "true");
|
||||||
|
expect(res.getByText("Uninstall")).toHaveAttribute("aria-disabled", "true");
|
||||||
}, {
|
}, {
|
||||||
timeout: 30000,
|
timeout: 30000,
|
||||||
});
|
});
|
||||||
@ -111,7 +116,7 @@ describe("Extensions", () => {
|
|||||||
|
|
||||||
(fse.unlink as jest.MockedFunction<typeof fse.unlink>).mockReturnValue(Promise.resolve() as any);
|
(fse.unlink as jest.MockedFunction<typeof fse.unlink>).mockReturnValue(Promise.resolve() as any);
|
||||||
|
|
||||||
fireEvent.change(res.getByPlaceholderText("Path or URL to an extension package", {
|
fireEvent.change(res.getByPlaceholderText("File path or URL", {
|
||||||
exact: false
|
exact: false
|
||||||
}), {
|
}), {
|
||||||
target: {
|
target: {
|
||||||
@ -134,8 +139,6 @@ describe("Extensions", () => {
|
|||||||
ExtensionDiscovery.getInstance().isLoaded = true;
|
ExtensionDiscovery.getInstance().isLoaded = true;
|
||||||
const { container } = render(<Extensions />);
|
const { container } = render(<Extensions />);
|
||||||
|
|
||||||
waitFor(() =>
|
expect(container.querySelector(".Spinner")).not.toBeInTheDocument();
|
||||||
expect(container.querySelector(".Spinner")).not.toBeInTheDocument()
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -209,6 +209,13 @@ export class ExtensionInstallationStateStore {
|
|||||||
return ExtensionInstallationStateStore.InstallingExtensions.size;
|
return ExtensionInstallationStateStore.InstallingExtensions.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current number of extensions uninstalling
|
||||||
|
*/
|
||||||
|
@computed static get uninstalling(): number {
|
||||||
|
return ExtensionInstallationStateStore.UninstallingExtensions.size;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If there is at least one extension currently installing
|
* If there is at least one extension currently installing
|
||||||
*/
|
*/
|
||||||
@ -216,6 +223,13 @@ export class ExtensionInstallationStateStore {
|
|||||||
return ExtensionInstallationStateStore.installing > 0;
|
return ExtensionInstallationStateStore.installing > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If there is at least one extension currently ininstalling
|
||||||
|
*/
|
||||||
|
@computed static get anyUninstalling(): boolean {
|
||||||
|
return ExtensionInstallationStateStore.uninstalling > 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current number of extensions preinstalling
|
* The current number of extensions preinstalling
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -109,7 +109,7 @@ export const InstalledExtensions = observer(({ extensions, uninstall, enable, di
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
extension: (
|
extension: (
|
||||||
<div className={cssNames("flex items-start", { [styles.frozenRow]: isUninstalling })}>
|
<div className={"flex items-start"}>
|
||||||
<div>
|
<div>
|
||||||
<div className={styles.extensionName}>{name}</div>
|
<div className={styles.extensionName}>{name}</div>
|
||||||
<div className={styles.extensionDescription}>{description}</div>
|
<div className={styles.extensionDescription}>{description}</div>
|
||||||
@ -130,7 +130,7 @@ export const InstalledExtensions = observer(({ extensions, uninstall, enable, di
|
|||||||
onClick={() => disable(id)}
|
onClick={() => disable(id)}
|
||||||
>
|
>
|
||||||
<Icon material="unpublished"/>
|
<Icon material="unpublished"/>
|
||||||
<span className="title">Disable</span>
|
<span className="title" aria-disabled={isUninstalling}>Disable</span>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
) : (
|
) : (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
@ -138,7 +138,7 @@ export const InstalledExtensions = observer(({ extensions, uninstall, enable, di
|
|||||||
onClick={() => enable(id)}
|
onClick={() => enable(id)}
|
||||||
>
|
>
|
||||||
<Icon material="check_circle"/>
|
<Icon material="check_circle"/>
|
||||||
<span className="title">Enable</span>
|
<span className="title" aria-disabled={isUninstalling}>Enable</span>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
)}
|
)}
|
||||||
<MenuItem
|
<MenuItem
|
||||||
@ -146,17 +146,17 @@ export const InstalledExtensions = observer(({ extensions, uninstall, enable, di
|
|||||||
onClick={() => uninstall(extension)}
|
onClick={() => uninstall(extension)}
|
||||||
>
|
>
|
||||||
<Icon material="delete"/>
|
<Icon material="delete"/>
|
||||||
<span className="title">Uninstall</span>
|
<span className="title" aria-disabled={isUninstalling}>Uninstall</span>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
</MenuActions>
|
</MenuActions>
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}, [extensions]
|
}, [extensions, ExtensionInstallationStateStore.anyUninstalling]
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section>
|
<section data-testid="extensions-table">
|
||||||
<List
|
<List
|
||||||
title={<h2 className={styles.title}>Installed extensions</h2>}
|
title={<h2 className={styles.title}>Installed extensions</h2>}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user