mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Merge branch 'compare-update-and-release-dates' of https://github.com/lensapp/lens into compare-update-and-release-dates
This commit is contained in:
commit
bfb2b89baf
@ -28,6 +28,8 @@ describe("encourage user to update when sufficient time passed since update was
|
|||||||
let quitAndInstallUpdateMock: jest.MockedFunction<() => void>;
|
let quitAndInstallUpdateMock: jest.MockedFunction<() => void>;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
jest.useFakeTimers();
|
||||||
|
|
||||||
applicationBuilder = getApplicationBuilder();
|
applicationBuilder = getApplicationBuilder();
|
||||||
|
|
||||||
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
applicationBuilder.beforeApplicationStart(({ mainDi }) => {
|
||||||
@ -79,96 +81,63 @@ describe("encourage user to update when sufficient time passed since update was
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("when update downloaded", () => {
|
describe("when update downloaded", () => {
|
||||||
|
let button: HTMLElement;
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await checkForPlatformUpdatesMock.resolve({
|
await checkForPlatformUpdatesMock.resolve({
|
||||||
updateWasDiscovered: true,
|
updateWasDiscovered: true,
|
||||||
version: "some-version",
|
version: "some-version",
|
||||||
});
|
});
|
||||||
|
|
||||||
await downloadPlatformUpdateMock.resolve({ downloadWasSuccessful: true });
|
await downloadPlatformUpdateMock.resolve({ downloadWasSuccessful: true });
|
||||||
await processCheckingForUpdatesPromise;
|
await processCheckingForUpdatesPromise;
|
||||||
|
|
||||||
|
button = rendered.getByTestId("update-button");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows update button to help user to update", () => {
|
it("shows update button to help user to update", () => {
|
||||||
const button = rendered.queryByTestId("update-button");
|
|
||||||
|
|
||||||
expect(button).toBeInTheDocument();
|
expect(button).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("has soft emotional indication in the button", () => {
|
it("has soft emotional indication in the button", () => {
|
||||||
const button = rendered.getByTestId("update-button");
|
|
||||||
|
|
||||||
expect(button).toHaveAttribute("data-warning-level", "light");
|
expect(button).toHaveAttribute("data-warning-level", "light");
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when button is clicked", () => {
|
describe("when button is clicked", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
act(() => button.click());
|
||||||
|
});
|
||||||
|
|
||||||
it("shows dropdown with update item", () => {
|
it("shows dropdown with update item", () => {
|
||||||
const button = rendered.queryByTestId("update-button");
|
|
||||||
|
|
||||||
act(() => button?.click());
|
|
||||||
|
|
||||||
expect(rendered.getByTestId("update-lens-menu-item")).toBeInTheDocument();
|
expect(rendered.getByTestId("update-lens-menu-item")).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("when selected update now, restarts the application to update", () => {
|
it("when selected update now, restarts the application to update", () => {
|
||||||
const button = rendered.queryByTestId("update-button");
|
|
||||||
|
|
||||||
act(() => button?.click());
|
|
||||||
|
|
||||||
const updateMenuItem = rendered.getByTestId("update-lens-menu-item");
|
const updateMenuItem = rendered.getByTestId("update-lens-menu-item");
|
||||||
|
|
||||||
act(() => updateMenuItem?.click());
|
act(() => updateMenuItem.click());
|
||||||
|
|
||||||
expect(quitAndInstallUpdateMock).toBeCalled();
|
expect(quitAndInstallUpdateMock).toBeCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("when dropdown closed without clicking update item", () => {
|
it("when dropdown closed without clicking update item, does not restart the application to update", () => {
|
||||||
it("does not restart the application to update", async () => {
|
act(() => button.click());
|
||||||
const button = rendered.queryByTestId("update-button");
|
|
||||||
|
|
||||||
act(() => button?.click());
|
|
||||||
|
|
||||||
act(() => button?.click());
|
|
||||||
|
|
||||||
expect(quitAndInstallUpdateMock).not.toBeCalled();
|
expect(quitAndInstallUpdateMock).not.toBeCalled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
describe("given just enough time passes for medium update encouragement", () => {
|
|
||||||
beforeAll(() => {
|
|
||||||
jest.useFakeTimers();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("has medium emotional indication in the button", () => {
|
|
||||||
const button = rendered.getByTestId("update-button");
|
|
||||||
|
|
||||||
|
it("given just enough time passes for medium update encouragement, has medium emotional indication in the button", () => {
|
||||||
jest.advanceTimersByTime(daysToMilliseconds(22));
|
jest.advanceTimersByTime(daysToMilliseconds(22));
|
||||||
|
|
||||||
expect(button).toHaveAttribute("data-warning-level", "medium");
|
expect(button).toHaveAttribute("data-warning-level", "medium");
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(() => {
|
it("given just enough time passes for severe update encouragement, has severe emotional indication in the button", () => {
|
||||||
jest.useRealTimers();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("given just enough time passes for severe update encouragement", () => {
|
|
||||||
beforeAll(() => {
|
|
||||||
jest.useFakeTimers();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("has severe emotional indication in the button", () => {
|
|
||||||
const button = rendered.getByTestId("update-button");
|
|
||||||
|
|
||||||
jest.advanceTimersByTime(daysToMilliseconds(26));
|
jest.advanceTimersByTime(daysToMilliseconds(26));
|
||||||
|
|
||||||
expect(button).toHaveAttribute("data-warning-level", "high");
|
expect(button).toHaveAttribute("data-warning-level", "high");
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(() => {
|
|
||||||
jest.useRealTimers();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user