Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BC-8737 - Add missing tests (and more) for video conference feature #3501

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/modules/data/board/Board.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import { createApplicationError } from "@/utils/create-application-error.factory
import { HttpStatusCode } from "@/store/types/http-status-code.enum";
import { useRouter } from "vue-router";
import { useI18n } from "vue-i18n";
import { BoardFeature } from "@/serverApi/v3";

export const useBoardStore = defineStore("boardStore", () => {
const cardStore = useCardStore();
Expand Down Expand Up @@ -364,7 +363,7 @@ export const useBoardStore = defineStore("boardStore", () => {
: board.value.columns[columnIndex - 1].id;
};

const getFeatures = computed((): BoardFeature[] | [] => {
const getFeatures = computed(() => {
if (!board.value) return [];

return board.value.features;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/data/board/BoardFeatures.composable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useBoardStore } from "@data-board";
export const useBoardFeatures = () => {
const { getFeatures } = useBoardStore();

const features: BoardFeature[] = getFeatures;
const features = getFeatures;

const isFeatureEnabled = (feature: BoardFeature) => {
return features.includes(feature);
Expand Down
34 changes: 34 additions & 0 deletions src/modules/data/board/BoardFeatures.composable.unit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { BoardFeature } from "@/serverApi/v3";
import { mountComposable } from "@@/tests/test-utils";
import { useBoardFeatures } from "./BoardFeatures.composable";
import { useBoardStore } from "./Board.store";
import { createMock } from "@golevelup/ts-jest";

jest.mock("./Board.store");
const mockedUseBoardStore = jest.mocked(useBoardStore);

describe("useBoardFeatures", () => {
const setup = (props: BoardFeature[] | []) => {
const mockedUseBoardStoreFeatures = createMock<
ReturnType<typeof useBoardStore>
>({
getFeatures: props,
});
mockedUseBoardStore.mockReturnValue(mockedUseBoardStoreFeatures);
return mountComposable(() => useBoardFeatures(), {});
};

it("should determine if a feature is enabled", () => {
const { isFeatureEnabled } = setup([BoardFeature.Videoconference]);

const result = isFeatureEnabled(BoardFeature.Videoconference);
expect(result).toBe(true);
});

it("should return false when no features are present", () => {
const { isFeatureEnabled } = setup([]);

const result = isFeatureEnabled(BoardFeature.Videoconference);
expect(result).toBe(false);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ import {
createTestingVuetify,
} from "@@/tests/test-utils/setup";
import { BoardMenu } from "@ui-board";
import {
KebabMenuActionDelete,
KebabMenuActionMoveDown,
KebabMenuActionMoveUp,
} from "@ui-kebab-menu";
import { KebabMenuActionMoveDown, KebabMenuActionMoveUp } from "@ui-kebab-menu";
import { VideoConferenceContentElement } from "@feature-board-video-conference-element";
import AuthModule from "@/store/auth";
import { Router, useRoute, useRouter } from "vue-router";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ export const useAddElementDialog = (
if (
envConfigModule.getEnv.FEATURE_COLUMN_BOARD_VIDEOCONFERENCE_ENABLED &&
isVideoConferenceEnabled.value
//TODO: both needed? check if BE checks env var
) {
options.push({
icon: mdiVideoOutline,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
createTestingI18n,
createTestingVuetify,
} from "@@/tests/test-utils/setup";
import { shallowMount } from "@vue/test-utils";
import { VDialog } from "vuetify/lib/components/index.mjs";
import RoomVideoConferenceSection from "./RoomVideoConferenceSection.vue";
import RoomVideoConferenceCard from "@/components/rooms/RoomVideoConferenceCard.vue";
Expand Down
Loading