Skip to content

Commit

Permalink
some final details (#245)
Browse files Browse the repository at this point in the history
* finishing touches

* requested change
  • Loading branch information
masinnae authored and xerbalind committed May 23, 2024
1 parent b78cd93 commit 23dc997
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 43 deletions.
1 change: 0 additions & 1 deletion frontend/src/composables/useNavigations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const main_navigations: NavigationData[] = [
{ icon: "mdi-school-outline", title: "navigation.subjects", goto: "subjects" },
{ icon: "mdi-book-check-outline", title: "navigation.projects", goto: "projects" },
{ icon: "mdi-information-outline", title: "navigation.about", goto: "about" },
{ icon: "mdi-cog-outline", title: "navigation.settings", goto: "settings" },
];

const admin_navigations: NavigationData[] = [
Expand Down
5 changes: 0 additions & 5 deletions frontend/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,6 @@ const router = createRouter({
component: () => import("../views/SubjectRegisterView.vue"),
props: (route) => ({ uuid: String(route.params.uuid) }),
},
{
path: "/settings",
name: "settings",
component: () => import("../views/SettingsView.vue"),
},
{
path: "/admin",
name: "admin",
Expand Down
27 changes: 12 additions & 15 deletions frontend/src/views/ProjectsView.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<template>
<div class="projects">
<TitleContainer :title="$t('project.myProject')" class="titlecontainer">
<v-btn-toggle v-model="activeButton" class="button">
<v-btn value="finished">{{ $t("project.finished") }}</v-btn>
</v-btn-toggle>
</TitleContainer>
<h1 v-if="isLoading">{{ $t("default.loading.loading_page") }}</h1>
<h1 v-else-if="isError || noProjectsFound" class="welcome">
<h1 v-else-if="isError || noProjectsFound" class="projectInfo">
{{ $t("project.not_found") }}
</h1>
<div v-else class="projectInfo">
<TitleContainer :title="$t('project.myProject')">
<v-btn-toggle v-model="activeButton" class="button">
<v-btn value="finished">{{ $t("project.finished") }}</v-btn>
</v-btn-toggle>
</TitleContainer>
<v-divider class="divider" />
<ProjectMiniCard
v-for="project in filteredProjects"
:key="project.id"
Expand All @@ -31,8 +30,6 @@ const { data: projects, isLoading, isError } = useProjectsQuery();
const allProjects = computed(() =>
isLoading.value ? [] : [...projects.value!.as_student, ...projects.value!.as_instructor]
);
const noProjectsFound = computed(() => allProjects.value.length === 0);
const activeButton = ref("notFinished");
const filteredProjects = computed(() => {
Expand All @@ -51,11 +48,15 @@ const filteredProjects = computed(() => {
return sortedProjects.filter((project: Project) => new Date(project.deadline) > now);
}
});
const noProjectsFound = computed(() => filteredProjects.value.length === 0);
</script>

<style scoped>
.project-card {
margin-top: 10px;
.titlecontainer {
margin-top: 40px;
margin-left: 40px;
margin-right: 40px;
}
.projectInfo {
Expand All @@ -72,8 +73,4 @@ const filteredProjects = computed(() => {
.projects {
margin: 15px;
}
.divider {
margin-bottom: 30px;
}
</style>
3 changes: 0 additions & 3 deletions frontend/src/views/SettingsView.vue

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ describe("DeadlineItem",() => {
deadline: new Date(2024, 10, 15),
id: 1
})
},
global: {
stubs: ['router-link']
}
})
it("render item", () => {
expect(wrapper.text()).toContain("testproject")
expect(wrapper.text()).toContain("testsubject")
expect(wrapper.findComponent({name: "router-link"}).exists()).toBeTruthy()
});
})
19 changes: 6 additions & 13 deletions frontend/tests/components/home/listcontent/SubjectItem.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import {ref} from "vue";

const testSubjectInstructorsQuery = {
data: ref([{given_name: "test", surname: "instructor"}]),
isLoading: ref(true),
setLoading(value){
this.isLoading.value = value
}
isLoading: ref(false),
}

vi.mock("@/queries/Subject", () => ({
Expand All @@ -19,16 +16,12 @@ describe("SubjectItem", () => {
const wrapper = mount(SubjectItem, {
props: {
subject: ref({name: "testsubject"})
},
global: {
stubs: ['router-link']
}
})
it("render if loading", () => {
expect(wrapper.text()).toContain("testsubject")
expect(wrapper.findComponent({name: "VSkeletonLoader"}))
});
it("render subject item", async () => {
testSubjectInstructorsQuery.setLoading(false)
await wrapper.vm.$nextTick()
expect(wrapper.text()).toContain("testsubject")
expect(wrapper.text()).toContain("test instructor")
it("render", () => {
expect(wrapper.findComponent({name: 'router-link'}).exists()).toBeTruthy()
});
})
3 changes: 0 additions & 3 deletions frontend/tests/components/navigation/NavBar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ describe("NavBar", () => {
expect(wrapper.find('[data-test="navigation.home"]').exists()).toBeTruthy();
expect(wrapper.find('[data-test="navigation.subjects"]').exists()).toBeTruthy();
expect(wrapper.find('[data-test="navigation.projects"]').exists()).toBeTruthy();
expect(wrapper.find('[data-test="navigation.settings"]').exists()).toBeTruthy();

expect(wrapper.find('[data-test="navigation.admin"]').exists()).toBeFalsy();
expect(wrapper.find('[data-test="navigation.login"]').exists()).toBeFalsy();
Expand All @@ -65,7 +64,6 @@ describe("NavBar", () => {
expect(wrapper.find('[data-test="navigation.home"]').exists()).toBeTruthy();
expect(wrapper.find('[data-test="navigation.subjects"]').exists()).toBeTruthy();
expect(wrapper.find('[data-test="navigation.projects"]').exists()).toBeTruthy();
expect(wrapper.find('[data-test="navigation.settings"]').exists()).toBeTruthy();
expect(wrapper.find('[data-test="navigation.admin"]').exists()).toBeTruthy();

expect(wrapper.find('[data-test="navigation.login"]').exists()).toBeFalsy();
Expand All @@ -85,7 +83,6 @@ describe("NavBar", () => {
expect(wrapper.find('[data-test="navigation.home"]').exists()).toBeFalsy();
expect(wrapper.find('[data-test="navigation.courses"]').exists()).toBeFalsy();
expect(wrapper.find('[data-test="navigation.projects"]').exists()).toBeFalsy();
expect(wrapper.find('[data-test="navigation.settings"]').exists()).toBeFalsy();
expect(wrapper.find('[data-test="navigation.admin"]').exists()).toBeFalsy();
});
});
27 changes: 26 additions & 1 deletion frontend/tests/components/user/SearchTable.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
import { mount } from "@vue/test-utils";
import {expect, describe, it, vi} from "vitest";
import SearchTable from "@/components/user/SearchTable.vue"
import {ref} from "vue";

const mockRouter = {
push: vi.fn(),
};

vi.mock("vue-router", () => ({
useRouter: () => mockRouter,
}));

const testAuthStore = {
isLoggedIn: ref(true),
setLoggedIn(value) {
this.isLoggedIn.value = value;
},
};

vi.mock("@/stores/auth-store", () => ({
useAuthStore: vi.fn(() => testAuthStore),
}));

describe("SearchTable", async () => {
const ResizeObserverMock = vi.fn(() => ({
Expand All @@ -9,7 +29,12 @@ describe("SearchTable", async () => {
disconnect: vi.fn(),
}));
vi.stubGlobal("ResizeObserver", ResizeObserverMock);
const wrapper = mount(SearchTable, {});
const wrapper = mount(SearchTable, {
props: {
search: "test",
users: []
}
});
it("sorts booleans true first", () => {
const instance = wrapper.vm;
const sortBoolFunction = (instance as any).sortBool;
Expand Down
11 changes: 11 additions & 0 deletions frontend/tests/views/GroupsView.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ import {expect, describe, it, vi} from "vitest";
import GroupsView from "@/views/GroupsView.vue"
import {ref} from "vue";

const mockRouter = {
push: vi.fn(),
};

vi.mock("vue-router", () => ({
useRouter: () => mockRouter,
}));

const mockProject = {
name: "testproject"
}
Expand Down Expand Up @@ -95,6 +103,9 @@ describe("GroupsView", () => {
const wrapper = mount(GroupsView, {
props: {
projectId: 1
},
global: {
stubs: ['router-link']
}
});

Expand Down

0 comments on commit 23dc997

Please sign in to comment.