Files
pleno-vue/tests/unit/release-channel-selector.spec.js
T

72 lines
2.0 KiB
JavaScript

// @vitest-environment jsdom
import { afterEach, describe, expect, it } from "vitest";
import { mount } from "@vue/test-utils";
import i18n from "@/i18n";
import ReleaseChannelSelector from "@/components/release/ReleaseChannelSelector.vue";
import { __resetReleaseChannelAvailabilityForTests } from "@/services/releaseChannelAvailability.js";
import { configureReleaseRuntime, __resetReleaseTimelineForTests } from "@/services/releaseTimeline.js";
const configureSelectableChannels = () => {
configureReleaseRuntime({
channel: {
slug: "stable",
name: "Stable",
default_channel: true,
},
available_channels: [
{
channel: {
slug: "stable",
name: "Stable",
default_channel: true,
},
availability: {
configured: true,
missing: [],
status: "ready",
},
},
{
channel: {
slug: "canary",
name: "Canary",
default_channel: false,
},
availability: {
configured: false,
missing: ["release_bundle"],
status: "unconfigured",
},
},
],
});
};
describe("ReleaseChannelSelector", () => {
afterEach(() => {
__resetReleaseChannelAvailabilityForTests();
__resetReleaseTimelineForTests();
});
it("renders available release channels and emits the selected channel", async () => {
configureSelectableChannels();
i18n.global.locale.value = "en";
const wrapper = mount(ReleaseChannelSelector, {
global: {
plugins: [i18n],
},
});
expect(wrapper.find('[data-testid="release-channel-selector"]').exists()).toBe(true);
expect(wrapper.text()).toContain("Stable");
expect(wrapper.text()).toContain("Canary");
expect(wrapper.text()).not.toContain("Release bundle");
await wrapper.find('[data-testid="release-channel-option-canary"]').trigger("click");
expect(wrapper.emitted("select")).toHaveLength(1);
expect(wrapper.emitted("select")[0][0].channelSlug).toBe("canary");
});
});