Skip to content

Commit

Permalink
fix HistoryView jest; storage button enabled for some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedhamidawan committed Mar 11, 2024
1 parent f79f3eb commit 8b778a5
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion client/src/components/History/HistoryView.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,15 @@ describe("History center panel View", () => {
expect(tags.text()).toContain("tag_1");
expect(tags.text()).toContain("tag_2");
// HistoryCounter
expect(wrapper.find("[data-description='storage dashboard button']").attributes("disabled")).toBeTruthy();
expect(wrapper.find("[data-description='show active items button']").text()).toEqual("8");
expect(wrapper.find("[data-description='include deleted items button']").text()).toEqual("1");
expect(wrapper.find("[data-description='include hidden items button']").text()).toEqual("2");
}

function storageDashboardButtonDisabled(wrapper) {
return wrapper.find("[data-description='storage dashboard button']").attributes("disabled");
}

it("current user's current history", async () => {
const history = create_history("history_1", "user_1", false);
const wrapper = await createWrapper(localVue, "user_1", history);
Expand All @@ -117,6 +120,9 @@ describe("History center panel View", () => {
// parts of the layout that should be similar for all cases
expectCorrectLayout(wrapper);

// storage dashboard button should be enabled
expect(storageDashboardButtonDisabled(wrapper)).toBeFalsy();

// make sure all history items show up
const historyItems = wrapper.findAllComponents(ContentItem);
expect(historyItems.length).toBe(10);
Expand All @@ -138,6 +144,9 @@ describe("History center panel View", () => {
expect(switchButton.exists()).toBe(false);
expect(importButton.attributes("disabled")).toBeFalsy();

// storage dashboard button should be disabled
expect(storageDashboardButtonDisabled(wrapper)).toBeTruthy();

// parts of the layout that should be similar for all cases
expectCorrectLayout(wrapper);
});
Expand All @@ -153,6 +162,9 @@ describe("History center panel View", () => {
expect(switchButton.attributes("disabled")).toBeFalsy();
expect(importButton.exists()).toBe(false);

// storage dashboard button should be enabled
expect(storageDashboardButtonDisabled(wrapper)).toBeFalsy();

// parts of the layout that should be similar for all cases
expectCorrectLayout(wrapper);
});
Expand All @@ -168,6 +180,9 @@ describe("History center panel View", () => {
expect(switchButton.attributes("disabled")).toBeTruthy();
expect(importButton.exists()).toBe(false);

// storage dashboard button should be disabled
expect(storageDashboardButtonDisabled(wrapper)).toBeTruthy();

// instead we have an alert
expect(wrapper.find("[data-description='history state info']").text()).toBe("This history has been purged.");
});
Expand All @@ -183,6 +198,9 @@ describe("History center panel View", () => {
expect(importButton.exists()).toBe(true);
expect(importButton.attributes("disabled")).toBeFalsy();

// storage dashboard button should be disabled
expect(storageDashboardButtonDisabled(wrapper)).toBeTruthy();

expectCorrectLayout(wrapper);
expect(wrapper.find("[data-description='history state info']").exists()).toBe(false);
});
Expand All @@ -198,6 +216,9 @@ describe("History center panel View", () => {
expect(switchButton.attributes("disabled")).toBeTruthy();
expect(importButton.exists()).toBe(false);

// storage dashboard button should be disabled
expect(storageDashboardButtonDisabled(wrapper)).toBeTruthy();

expectCorrectLayout(wrapper);
expect(wrapper.find("[data-description='history state info']").text()).toBe("This history has been archived.");
});
Expand Down

0 comments on commit 8b778a5

Please sign in to comment.