Fix some tests, fix linting

This commit is contained in:
Christian Cueni 2024-04-22 08:29:35 +02:00
parent 34512f8db0
commit e0b4a045ce
9 changed files with 59 additions and 50 deletions

View File

@ -85,7 +85,7 @@ function hasActionButton(): boolean {
<div class="flex flex-col space-y-8 bg-white p-6"> <div class="flex flex-col space-y-8 bg-white p-6">
<div class="border-b border-gray-300 pb-8"> <div class="border-b border-gray-300 pb-8">
<div class="flex flex-row items-start justify-between"> <div class="flex flex-row items-start justify-between">
<h3 class="mb-4 text-3xl">{{ courseName }}</h3> <h3 class="mb-4 text-3xl" data-cy="db-course-title">{{ courseName }}</h3>
<a <a
v-if="hasActionButton()" v-if="hasActionButton()"
:href="actionButtonProps.href" :href="actionButtonProps.href"

View File

@ -2,17 +2,19 @@
import type { import type {
AssignmentCompletionMetricsType, AssignmentCompletionMetricsType,
AssignmentStatisticsRecordType, AssignmentStatisticsRecordType,
CourseStatisticsType,
StatisticsCircleDataType,
} from "@/gql/graphql"; } from "@/gql/graphql";
import StatisticFilterList from "@/components/dashboard/StatisticFilterList.vue"; import StatisticFilterList from "@/components/dashboard/StatisticFilterList.vue";
import { getDateString } from "@/components/dueDates/dueDatesUtils"; import { getDateString } from "@/components/dueDates/dueDatesUtils";
import dayjs from "dayjs"; import dayjs from "dayjs";
import ItProgress from "@/components/ui/ItProgress.vue"; import ItProgress from "@/components/ui/ItProgress.vue";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const props = defineProps<{ const props = defineProps<{
courseSlug: string; courseStatistics: CourseStatisticsType;
courseStatistics: any; courseSessionName: (sessionId: string) => string;
courseSessionName: any; circleMeta: (circleId: string) => StatisticsCircleDataType;
circleMeta: any;
}>(); }>();
const assignmentStats = (metrics: AssignmentCompletionMetricsType) => { const assignmentStats = (metrics: AssignmentCompletionMetricsType) => {

View File

@ -1,15 +1,19 @@
<script setup lang="ts"> <script setup lang="ts">
import type { PresenceRecordStatisticsType } from "@/gql/graphql"; import type {
CourseStatisticsType,
PresenceRecordStatisticsType,
StatisticsCircleDataType,
} from "@/gql/graphql";
import StatisticFilterList from "@/components/dashboard/StatisticFilterList.vue"; import StatisticFilterList from "@/components/dashboard/StatisticFilterList.vue";
import ItProgress from "@/components/ui/ItProgress.vue"; import ItProgress from "@/components/ui/ItProgress.vue";
import { getDateString } from "@/components/dueDates/dueDatesUtils"; import { getDateString } from "@/components/dueDates/dueDatesUtils";
import dayjs from "dayjs"; import dayjs from "dayjs";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const props = defineProps<{ const props = defineProps<{
courseSlug: string; courseStatistics: CourseStatisticsType;
courseStatistics: any; courseSessionName: (sessionId: string) => string;
courseSessionName: any; circleMeta: (circleId: string) => StatisticsCircleDataType;
circleMeta: any;
}>(); }>();
const attendanceStats = (present: number, total: number) => { const attendanceStats = (present: number, total: number) => {

View File

@ -1,12 +1,16 @@
<script setup lang="ts"> <script setup lang="ts">
import type { CompetenceRecordStatisticsType } from "@/gql/graphql"; import type {
CompetenceRecordStatisticsType,
CourseStatisticsType,
StatisticsCircleDataType,
} from "@/gql/graphql";
import StatisticFilterList from "@/components/dashboard/StatisticFilterList.vue"; import StatisticFilterList from "@/components/dashboard/StatisticFilterList.vue";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const props = defineProps<{ const props = defineProps<{
courseSlug: string; courseStatistics: CourseStatisticsType;
courseStatistics: any; courseSessionName: (sessionId: string) => string;
courseSessionName: any; circleMeta: (circleId: string) => StatisticsCircleDataType;
circleMeta: any;
}>(); }>();
</script> </script>

View File

@ -1,16 +1,18 @@
<script setup lang="ts"> <script setup lang="ts">
import type { import type {
CourseStatisticsType,
FeedbackStatisticsRecordType, FeedbackStatisticsRecordType,
PresenceRecordStatisticsType, PresenceRecordStatisticsType,
StatisticsCircleDataType,
} from "@/gql/graphql"; } from "@/gql/graphql";
import StatisticFilterList from "@/components/dashboard/StatisticFilterList.vue"; import StatisticFilterList from "@/components/dashboard/StatisticFilterList.vue";
import { getBlendedColorForRating } from "@/utils/ratingToColor"; import { getBlendedColorForRating } from "@/utils/ratingToColor";
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const props = defineProps<{ const props = defineProps<{
courseSlug: string; courseStatistics: CourseStatisticsType;
courseStatistics: any; courseSessionName: (sessionId: string) => string;
courseSessionName: any; circleMeta: (circleId: string) => StatisticsCircleDataType;
circleMeta: any;
}>(); }>();
</script> </script>

View File

@ -387,13 +387,11 @@ router.beforeEach(updateLoggedIn);
router.beforeEach(redirectToLoginIfRequired); router.beforeEach(redirectToLoginIfRequired);
// register after login hooks // register after login hooks
router.beforeEach(async (to, from) => await handleCurrentCourseSession(to)); router.beforeEach(async (to) => await handleCurrentCourseSession(to));
router.beforeEach(async (to, from) => await handleCourseSessionAsQueryParam(to)); router.beforeEach(async (to) => await handleCourseSessionAsQueryParam(to));
// only unset the current course session in the after hook // only unset the current course session in the after hook
router.afterEach( router.afterEach(async (to) => await handleCurrentCourseSession(to, { unset: true }));
async (to, from) => await handleCurrentCourseSession(to, { unset: true })
);
router.beforeEach(addToHistory); router.beforeEach(addToHistory);

View File

@ -2,13 +2,11 @@ import type {
CourseProgressType, CourseProgressType,
CourseStatisticsType, CourseStatisticsType,
DashboardConfigType, DashboardConfigType,
DashboardType,
} from "@/gql/graphql"; } from "@/gql/graphql";
import type { DashboardCourseConfigType } from "@/services/dashboard"; import type { DashboardCourseConfigType } from "@/services/dashboard";
import { import {
fetchDashboardConfig, fetchDashboardConfig,
fetchDashboardConfigv2, fetchDashboardConfigv2,
fetchProgressData,
fetchStatisticData, fetchStatisticData,
} from "@/services/dashboard"; } from "@/services/dashboard";
import { defineStore } from "pinia"; import { defineStore } from "pinia";
@ -27,21 +25,21 @@ export const useDashboardStore = defineStore("dashboard", () => {
ref(null); ref(null);
const loading = ref(false); const loading = ref(false);
const loadDashboardData = async (type: DashboardType, id: string) => { // const loadDashboardData = async (type: DashboardType, id: string) => {
let data; // let data;
switch (type) { // switch (type) {
case "STATISTICS_DASHBOARD": // case "STATISTICS_DASHBOARD":
data = await fetchStatisticData(id); // data = await fetchStatisticData(id);
break; // break;
case "PROGRESS_DASHBOARD": // case "PROGRESS_DASHBOARD":
data = await fetchProgressData(id); // data = await fetchProgressData(id);
break; // break;
default: // default:
return; // return;
} // }
dashBoardDataCache[id] = data; // dashBoardDataCache[id] = data;
currentDashBoardData.value = data; // currentDashBoardData.value = data;
}; // };
const switchAndLoadDashboardConfig = async (config: DashboardConfigType) => { const switchAndLoadDashboardConfig = async (config: DashboardConfigType) => {
currentDashboardConfig.value = config; currentDashboardConfig.value = config;
@ -85,7 +83,6 @@ export const useDashboardStore = defineStore("dashboard", () => {
}; };
const loadStatisticsDatav2 = async (id: string) => { const loadStatisticsDatav2 = async (id: string) => {
console.log("fetching statistics v2 for course ID: ", id);
const data = await fetchStatisticData(id); const data = await fetchStatisticData(id);
dashBoardDataCache[id] = data; dashBoardDataCache[id] = data;
return data; return data;

View File

@ -53,7 +53,7 @@ describe("dashboardSupervisor.cy.js", () => {
}); });
it("contains correct details link", () => { it("contains correct details link", () => {
clickOnDetailsLink("attendance"); clickOnDetailsLink("attendance");
cy.url().should("contain", "/statistic/attendance"); cy.url().should("contain", "/statistic/test-lehrgang/attendance");
// might be improved: roughly check // might be improved: roughly check
// that the correct data is displayed // that the correct data is displayed
@ -70,7 +70,7 @@ describe("dashboardSupervisor.cy.js", () => {
}); });
it("contains correct details link", () => { it("contains correct details link", () => {
clickOnDetailsLink("feedback"); clickOnDetailsLink("feedback");
cy.url().should("contain", "/statistic/feedback"); cy.url().should("contain", "/statistic/test-lehrgang/feedback");
// might be improved: roughly check // might be improved: roughly check
// that the correct data is displayed // that the correct data is displayed
@ -88,7 +88,7 @@ describe("dashboardSupervisor.cy.js", () => {
}); });
it("contains correct details link", () => { it("contains correct details link", () => {
clickOnDetailsLink("competence"); clickOnDetailsLink("competence");
cy.url().should("contain", "/statistic/competence"); cy.url().should("contain", "/statistic/test-lehrgang/competence");
// might be improved: roughly check // might be improved: roughly check
// that the correct data is displayed // that the correct data is displayed

View File

@ -16,17 +16,19 @@ describe("login.cy.js", () => {
cy.get("#username").type("test-student1@example.com"); cy.get("#username").type("test-student1@example.com");
cy.get("#password").type("test"); cy.get("#password").type("test");
cy.get("[data-cy=\"login-button\"]").click(); cy.get('[data-cy="login-button"]').click();
cy.request("/api/core/me").its("status").should("eq", 200); cy.request("/api/core/me").its("status").should("eq", 200);
cy.get("[data-cy=\"dashboard-title\"]").should("contain", "Dashboard"); cy.get('[data-cy="db-course-title"]')
.first()
.should("contain", "Test Lehrgang");
}); });
it("can login with helper function", () => { it("can login with helper function", () => {
login("test-student1@example.com", "test"); login("test-student1@example.com", "test");
cy.visit("/"); cy.visit("/");
cy.request("/api/core/me").its("status").should("eq", 200); cy.request("/api/core/me").its("status").should("eq", 200);
cy.get("[data-cy=\"dashboard-title\"]").should("contain", "Dashboard"); cy.get('[data-cy="dashboard-title"]').should("contain", "Dashboard");
}); });
it("login will redirect to requested page", () => { it("login will redirect to requested page", () => {
@ -36,9 +38,9 @@ describe("login.cy.js", () => {
cy.get("#username").type("test-student1@example.com"); cy.get("#username").type("test-student1@example.com");
cy.get("#password").type("test"); cy.get("#password").type("test");
cy.get("[data-cy=\"login-button\"]").click(); cy.get('[data-cy="login-button"]').click();
cy.get("[data-cy=\"learning-path-title\"]").should( cy.get('[data-cy="learning-path-title"]').should(
"contain", "contain",
"Test Lehrgang" "Test Lehrgang"
); );