- Add unit tests for `EditableTableColumn` covering tooltip multiline behavior with `hoverHtml`. - Update tooltip logic to use `isTooltipMultiline` computed property for slot checks. - Adjust `OrderBookingsTable` to fix incorrect usage of `permissionCheckFunction` arguments. - Optimize `RequestQueueProgress` state handling by removing unused visibility logic. - Add unit test to ensure no recursive update errors occur during large request processing.
87 lines
2.2 KiB
JavaScript
87 lines
2.2 KiB
JavaScript
// @vitest-environment jsdom
|
|
import { mount } from "@vue/test-utils";
|
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
import EditableTableColumn from "@/components/displays/buttons/EditableTableColumn.vue";
|
|
|
|
const TooltipStub = {
|
|
name: "BTooltip",
|
|
props: {
|
|
type: String,
|
|
position: String,
|
|
multilined: Boolean,
|
|
square: Boolean,
|
|
},
|
|
template: `
|
|
<div class="tooltip-stub" :data-multilined="String(multilined)">
|
|
<slot></slot>
|
|
<slot name="content"></slot>
|
|
</div>
|
|
`,
|
|
};
|
|
|
|
const createBaseProps = () => ({
|
|
object: {
|
|
id: 1,
|
|
items: "Spot Free",
|
|
},
|
|
loadList: vi.fn(),
|
|
editFunction: vi.fn(() => Promise.resolve()),
|
|
column: "items",
|
|
componentWrapper: "div",
|
|
permissionCheckFunction: () => false,
|
|
});
|
|
|
|
describe("EditableTableColumn", () => {
|
|
afterEach(() => {
|
|
vi.restoreAllMocks();
|
|
});
|
|
|
|
it("passes a boolean true to b-tooltip multilined when hover html is enabled", () => {
|
|
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
|
|
const errorSpy = vi.spyOn(console, "error").mockImplementation(() => {});
|
|
|
|
const wrapper = mount(EditableTableColumn, {
|
|
props: {
|
|
...createBaseProps(),
|
|
hoverHtml: true,
|
|
},
|
|
slots: {
|
|
hoverHtml: "<div>Spot Free\nLastbil</div>",
|
|
},
|
|
global: {
|
|
stubs: {
|
|
"b-tooltip": TooltipStub,
|
|
},
|
|
},
|
|
});
|
|
|
|
expect(wrapper.get(".tooltip-stub").attributes("data-multilined")).toBe("true");
|
|
expect(
|
|
warnSpy.mock.calls.some((call) =>
|
|
call.join(" ").includes('Invalid prop: type check failed for prop "multilined"')
|
|
)
|
|
).toBe(false);
|
|
expect(
|
|
errorSpy.mock.calls.some((call) =>
|
|
call.join(" ").includes('Invalid prop: type check failed for prop "multilined"')
|
|
)
|
|
).toBe(false);
|
|
});
|
|
|
|
it("keeps b-tooltip multilined false when hover html is disabled", () => {
|
|
const wrapper = mount(EditableTableColumn, {
|
|
props: {
|
|
...createBaseProps(),
|
|
hoverHtml: false,
|
|
},
|
|
global: {
|
|
stubs: {
|
|
"b-tooltip": TooltipStub,
|
|
},
|
|
},
|
|
});
|
|
|
|
expect(wrapper.get(".tooltip-stub").attributes("data-multilined")).toBe("false");
|
|
});
|
|
});
|