Skip to content

Commit

Permalink
N21-1679 review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mrikallab committed May 6, 2024
1 parent 5374954 commit d98d05a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 251 deletions.
6 changes: 0 additions & 6 deletions src/components/rooms/RoomExternalToolCard.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ describe("RoomExternalToolCard", () => {
jest
.mocked(useContextExternalToolConfigurationStatus)
.mockReturnValue(useContextExternalToolConfigurationStatusMock);

jest
.mocked(
useContextExternalToolConfigurationStatusMock.determineChipStatusTitle
)
.mockReturnValue("pages.rooms.tools.outdated");
});

afterEach(() => {
Expand Down
9 changes: 3 additions & 6 deletions src/components/rooms/RoomExternalToolCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{{ $t("pages.rooms.tools.deactivated") }}
</WarningChip>
<InfoChip
v-if="isToolIncompleteOperational"
v-if="showAsIncompleteOperational"
data-testId="tool-card-status-incompleteOperational"
>{{ $t("pages.rooms.tools.outdated") }}
</InfoChip>
Expand Down Expand Up @@ -77,8 +77,7 @@ export default defineComponent({
error: launchError,
} = useExternalToolLaunchState();
const { determineChipStatusTitle, isTeacher } =
useContextExternalToolConfigurationStatus();
const { isTeacher } = useContextExternalToolConfigurationStatus();
const handleClick = async () => {
if (!isToolLaunchable.value) {
Expand Down Expand Up @@ -144,7 +143,6 @@ export default defineComponent({
);
});
const loadLaunchRequest = async () => {
if (!isToolLaunchable.value) {
return;
Expand All @@ -164,8 +162,7 @@ export default defineComponent({
isToolOutdated,
isToolDeactivated,
isToolIncomplete,
isToolIncompleteOperational,
toolChipTitle,
showAsIncompleteOperational,
};
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { ContextExternalToolConfigurationStatus } from "./types";
export const useContextExternalToolConfigurationStatus = () => {
const authModule = injectStrict(AUTH_MODULE_KEY);


const determineToolStatusTranslationKey = (
toolConfigStatus: ContextExternalToolConfigurationStatus
): string => {
Expand Down Expand Up @@ -46,7 +45,6 @@ export const useContextExternalToolConfigurationStatus = () => {
};

return {
determineChipStatusTitle,
determineToolStatusTranslationKey,
determineDeactivatedMessage,
isTeacher,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,240 +322,6 @@ describe("ToolConfigurationStatus.composable", () => {
});
});

describe("determineChipStatusTitle", () => {
describe("when user is student", () => {
describe("when tool is incomplete operational", () => {
const setup = () => {
const authModule = createModuleMocks(AuthModule, {
getUserRoles: ["student"],
});

const toolConfigurationStatus =
ContextExternalToolConfigurationStatusFactory.build({
isIncompleteOperationalOnScopeContext: true,
});

const composable = mountComposable(
() => useContextExternalToolConfigurationStatus(),
{
global: {
provide: {
[AUTH_MODULE_KEY.valueOf()]: authModule,
},
},
}
);

return {
toolConfigurationStatus,
...composable,
};
};

it("should return undefined ", () => {
const { determineChipStatusTitle, toolConfigurationStatus } = setup();

const result = determineChipStatusTitle(toolConfigurationStatus);

expect(result).toEqual("pages.rooms.tools.outdated");
});
});

describe("when user is teacher", () => {
describe("when tool is outdated on scope school and context", () => {
const setup = () => {
const authModule = createModuleMocks(AuthModule, {
getUserRoles: ["teacher"],
});

const toolConfigurationStatus =
ContextExternalToolConfigurationStatusFactory.build({
isOutdatedOnScopeSchool: true,
isOutdatedOnScopeContext: true,
});

const composable = mountComposable(
() => useContextExternalToolConfigurationStatus(),
{
global: {
provide: {
[AUTH_MODULE_KEY.valueOf()]: authModule,
},
},
}
);

return {
toolConfigurationStatus,
...composable,
};
};

it("should return translationkey for outdated ", () => {
const { determineChipStatusTitle, toolConfigurationStatus } =
setup();

const result = determineChipStatusTitle(toolConfigurationStatus);

expect(result).toEqual("pages.rooms.tools.outdated");
});
});

describe("when tool is outdated on scope school", () => {
const setup = () => {
const authModule = createModuleMocks(AuthModule, {
getUserRoles: ["teacher"],
});

const toolConfigurationStatus =
ContextExternalToolConfigurationStatusFactory.build({
isOutdatedOnScopeSchool: true,
});

const composable = mountComposable(
() => useContextExternalToolConfigurationStatus(),
{
global: {
provide: {
[AUTH_MODULE_KEY.valueOf()]: authModule,
},
},
}
);

return {
toolConfigurationStatus,
...composable,
};
};

it("should return translationkey for outdated ", () => {
const { determineChipStatusTitle, toolConfigurationStatus } =
setup();

const result = determineChipStatusTitle(toolConfigurationStatus);

expect(result).toEqual("pages.rooms.tools.outdated");
});
});

describe("when tool is outdated on scope context", () => {
const setup = () => {
const authModule = createModuleMocks(AuthModule, {
getUserRoles: ["teacher"],
});

const toolConfigurationStatus =
ContextExternalToolConfigurationStatusFactory.build({
isOutdatedOnScopeContext: true,
});

const composable = mountComposable(
() => useContextExternalToolConfigurationStatus(),
{
global: {
provide: {
[AUTH_MODULE_KEY.valueOf()]: authModule,
},
},
}
);

return {
toolConfigurationStatus,
...composable,
};
};

it("should return translationkey for outdated ", () => {
const { determineChipStatusTitle, toolConfigurationStatus } =
setup();

const result = determineChipStatusTitle(toolConfigurationStatus);

expect(result).toEqual("pages.rooms.tools.outdated");
});
});

describe("when tool is incomplete", () => {
const setup = () => {
const authModule = createModuleMocks(AuthModule, {
getUserRoles: ["teacher"],
});

const toolConfigurationStatus =
ContextExternalToolConfigurationStatusFactory.build({
isIncompleteOnScopeContext: true,
});

const composable = mountComposable(
() => useContextExternalToolConfigurationStatus(),
{
global: {
provide: {
[AUTH_MODULE_KEY.valueOf()]: authModule,
},
},
}
);

return {
toolConfigurationStatus,
...composable,
};
};

it("should return translationkey for outdated ", () => {
const { determineChipStatusTitle, toolConfigurationStatus } =
setup();

const result = determineChipStatusTitle(toolConfigurationStatus);

expect(result).toEqual("pages.rooms.tools.outdated");
});
});

describe("when tool is incomplete operational", () => {
const setup = () => {
const authModule = createModuleMocks(AuthModule, {
getUserRoles: ["teacher"],
});

const toolConfigurationStatus =
ContextExternalToolConfigurationStatusFactory.build({
isIncompleteOperationalOnScopeContext: true,
});

const composable = mountComposable(
() => useContextExternalToolConfigurationStatus(),
{
global: {
provide: {
[AUTH_MODULE_KEY.valueOf()]: authModule,
},
},
}
);

return {
toolConfigurationStatus,
...composable,
};
};

it("should return translationkey for outdated ", () => {
const { determineChipStatusTitle, toolConfigurationStatus } =
setup();

const result = determineChipStatusTitle(toolConfigurationStatus);

expect(result).toEqual("pages.rooms.tools.outdated");
});
});
});
});
});

describe("isTeacher", () => {
describe("when user is teacher", () => {
const setup = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ export default defineComponent({
const isToolLaunchable: ComputedRef<boolean> = computed(
() =>
!displayData.value?.status.isOutdatedOnScopeSchool ||
!displayData.value?.status.isOutdatedOnScopeContext ||
!displayData.value?.status?.isIncompleteOnScopeContext
!displayData.value?.status.isOutdatedOnScopeSchool &&
!displayData.value?.status.isOutdatedOnScopeContext &&
!displayData.value?.status.isIncompleteOnScopeContext
);
const toolConfigurationStatus: ComputedRef<ContextExternalToolConfigurationStatus> =
Expand Down

0 comments on commit d98d05a

Please sign in to comment.