From 1f316b02e4167f5106184fb955b3c246220f6d4a Mon Sep 17 00:00:00 2001 From: abdahmed22 Date: Mon, 26 Aug 2024 09:56:50 +0300 Subject: [PATCH] feature: types & design updates --- client/src/App.vue | 4 +- client/src/api/{clients.ts => axios.ts} | 2 +- client/src/api/projectService.ts | 4 +- client/src/components.d.ts | 3 - .../src/components/projects/ProjectForm.vue | 9 ++- client/src/components/test.vue | 0 client/src/layouts/README.md | 5 -- client/src/layouts/default.vue | 13 ---- client/src/pages/DashboardView.vue | 6 -- client/src/pages/projects/ProjectsView.vue | 16 +++-- client/src/router/index.ts | 1 - client/src/typed-router.d.ts | 1 - client/src/types/types.ts | 69 ++++++++++++++++--- server/test_tracker/views/member.py | 2 +- server/test_tracker/views/project.py | 14 ++-- server/test_tracker/views/requirement.py | 14 ++-- server/test_tracker/views/test_cases.py | 6 +- server/test_tracker/views/test_plan.py | 12 ++-- server/test_tracker/views/test_run.py | 14 ++-- server/test_tracker/views/test_suites.py | 6 +- 20 files changed, 116 insertions(+), 85 deletions(-) rename client/src/api/{clients.ts => axios.ts} (53%) delete mode 100644 client/src/components/test.vue delete mode 100644 client/src/layouts/README.md delete mode 100644 client/src/layouts/default.vue delete mode 100644 client/src/pages/DashboardView.vue diff --git a/client/src/App.vue b/client/src/App.vue index 8714368..965ca31 100644 --- a/client/src/App.vue +++ b/client/src/App.vue @@ -1,7 +1,7 @@ diff --git a/client/src/api/clients.ts b/client/src/api/axios.ts similarity index 53% rename from client/src/api/clients.ts rename to client/src/api/axios.ts index 6cf2a74..655090b 100644 --- a/client/src/api/clients.ts +++ b/client/src/api/axios.ts @@ -5,7 +5,7 @@ export const AuthClient: AxiosInstance = axios.create({ timeout: 1000, headers: { 'Content-Type': 'application/json', - Authorization: 'Bearer ' + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzIzOTk0NzQ5LCJpYXQiOjE3MjM5ODU0NDksImp0aSI6ImRjMWRjMDU1ZTgzZjQ0NGQ4NDU1NTAwMGMyNDUwMTJhIiwidXNlcl9pZCI6NCwiZW1haWwiOiJib3VkaWVAYm91ZGllLmNvbSJ9.OgeODfFg5GxP1QxAAyu2FFlOMx2suAdWvjBtkK5eT0U', + Authorization: localStorage.getItem('token'), }, }) diff --git a/client/src/api/projectService.ts b/client/src/api/projectService.ts index b1b2c6a..f0f2880 100644 --- a/client/src/api/projectService.ts +++ b/client/src/api/projectService.ts @@ -1,4 +1,4 @@ -import { AuthClient } from './clients' +import { AuthClient } from './axios' import { Project } from '@/types/types' export async function postProject (project :Partial) { @@ -8,7 +8,7 @@ export async function postProject (project :Partial) { export async function getProjects (page :number) { return AuthClient.get('/dashboard/projects/', { params: { - cursor: page, + page, }, }) } diff --git a/client/src/components.d.ts b/client/src/components.d.ts index 0835ee0..fc89776 100644 --- a/client/src/components.d.ts +++ b/client/src/components.d.ts @@ -7,11 +7,8 @@ export {} /* prettier-ignore */ declare module 'vue' { export interface GlobalComponents { - AppFooter: typeof import('./components/AppFooter.vue')['default'] - HelloWorld: typeof import('./components/HelloWorld.vue')['default'] ProjectForm: typeof import('./components/projects/ProjectForm.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] - Test: typeof import('./components/test.vue')['default'] } } diff --git a/client/src/components/projects/ProjectForm.vue b/client/src/components/projects/ProjectForm.vue index c0fb4eb..c8d9295 100644 --- a/client/src/components/projects/ProjectForm.vue +++ b/client/src/components/projects/ProjectForm.vue @@ -90,21 +90,24 @@ .then((response: any) => { notifier.notify({ title: 'Success', - description: 'Project created Successfully', + description: response.data.message, showProgressBar: true, timeout: 7_000, type: 'success', }) }) .catch((err: any) => { + let description = 'Can not create project' + if (err.response) { + description = err.response.data.detail + } notifier.notify({ title: 'Fail', - description: 'Can not create project', + description, showProgressBar: true, timeout: 7_000, type: 'error', }) - console.error(err) }) } diff --git a/client/src/components/test.vue b/client/src/components/test.vue deleted file mode 100644 index e69de29..0000000 diff --git a/client/src/layouts/README.md b/client/src/layouts/README.md deleted file mode 100644 index 4016af3..0000000 --- a/client/src/layouts/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Layouts - -Layouts are reusable components that wrap around pages. They are used to provide a consistent look and feel across multiple pages. - -Full documentation for this feature can be found in the Official [vite-plugin-vue-layouts](https://github.com/JohnCampionJr/vite-plugin-vue-layouts) repository. diff --git a/client/src/layouts/default.vue b/client/src/layouts/default.vue deleted file mode 100644 index da5c129..0000000 --- a/client/src/layouts/default.vue +++ /dev/null @@ -1,13 +0,0 @@ - - - diff --git a/client/src/pages/DashboardView.vue b/client/src/pages/DashboardView.vue deleted file mode 100644 index c9b4d21..0000000 --- a/client/src/pages/DashboardView.vue +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/client/src/pages/projects/ProjectsView.vue b/client/src/pages/projects/ProjectsView.vue index 8699ca9..351e7f6 100644 --- a/client/src/pages/projects/ProjectsView.vue +++ b/client/src/pages/projects/ProjectsView.vue @@ -103,17 +103,20 @@ const getPage = async (page: number) => { getProjects(page).then((response: any) => { projects.value = response.data.results - // count.value = response.body.total_count + count.value = response.data.total_count }) .catch((err: any) => { + let description = 'Can not get projects' + if (err.response) { + description = err.response.data.detail + } notifier.notify({ title: 'Fail', - description: 'Can not get projects', + description, showProgressBar: true, timeout: 7_000, type: 'error', }) - console.error(err) }) } @@ -132,14 +135,17 @@ .then((response: any) => { }) .catch((err: any) => { + let description = 'Can not search for projects' + if (err.response) { + description = err.response.data.detail + } notifier.notify({ title: 'Fail', - description: 'Can not search projects', + description, showProgressBar: true, timeout: 7_000, type: 'error', }) - console.error(err) }) } diff --git a/client/src/router/index.ts b/client/src/router/index.ts index 70d5a95..5c6e1ce 100644 --- a/client/src/router/index.ts +++ b/client/src/router/index.ts @@ -10,7 +10,6 @@ import { createRouter, createWebHistory } from 'vue-router/auto' const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), routes: [ - { path: '/', component: () => import('@/pages/DashboardView.vue') }, { path: '/projects/:projectId', name: 'projectDetails', component: () => import('@/pages/projects/ProjectDetailsView.vue'), props: true }, ], }) diff --git a/client/src/typed-router.d.ts b/client/src/typed-router.d.ts index 1e506be..85eff57 100644 --- a/client/src/typed-router.d.ts +++ b/client/src/typed-router.d.ts @@ -18,7 +18,6 @@ declare module 'vue-router/auto-routes' { * Route name map generated by unplugin-vue-router */ export interface RouteNamedMap { - '/DashboardView': RouteRecordInfo<'/DashboardView', '/DashboardView', Record, Record>, '/projects/ProjectDetailsView': RouteRecordInfo<'/projects/ProjectDetailsView', '/projects/ProjectDetailsView', Record, Record>, '/projects/ProjectsView': RouteRecordInfo<'/projects/ProjectsView', '/projects/ProjectsView', Record, Record>, } diff --git a/client/src/types/types.ts b/client/src/types/types.ts index 0e12c9a..a8ce4a8 100644 --- a/client/src/types/types.ts +++ b/client/src/types/types.ts @@ -1,8 +1,59 @@ +enum Status { + NOT_STARTED='not_started', + IN_PROGRESS='in_progress', + COMPLETED='completed', +} + export type Activity = { action: string, date: string, } +export type TestPlan = { + id: number, + modified: string, + created: string, + title: string, + type: string, +} + +export type Requirement = { + id: number, + updated: string, + created: string, + title: string, + requirements: string[], +} + +export type TestSuite = { + id: number, + modified: string, + created: string, + title: string, + number_of_test_cases: number, + test_plan: number, +} + +export type TestRun = { + +} + +export type TestCase = { + id: number, + modified: string, + created: string, + title: string, + testcase_title: string, + requirement: string + last_saved: { + id: number, + full_name: string, + } + test_suite: string, + description: string, + test_steps: string, + expected_result: string, +} export type Project = { id: number, user: string, @@ -10,13 +61,13 @@ export type Project = { modified: string, created: string, activity: Activity[], - total_test_plan: any, - total_requirements_docs: any, - total_suites: any, // update the any to type of each attribute - total_test_runs: any, - incomplete_test_runs_assigned_to_you: any, - people_with_the_most_incomplete_test_runs: any, - title:string, - repo_link:string, - short_description:string, + total_test_plan: TestPlan[], + total_requirements_docs: Requirement[], + total_suites: TestSuite[], + total_test_runs: TestRun[], + incomplete_test_runs_assigned_to_you: TestRun[], + people_with_the_most_incomplete_test_runs: TestRun[], + title: string, + repo_link: string, + short_description: string, } diff --git a/server/test_tracker/views/member.py b/server/test_tracker/views/member.py index 8567a26..ba2f99f 100644 --- a/server/test_tracker/views/member.py +++ b/server/test_tracker/views/member.py @@ -186,7 +186,7 @@ class ProjectMembersAPIView(GenericAPIView): """This class to return all project members""" serializer_class = ProjectTeamSerializer - permission_classes = (HasProjectAccess,) + def get(self, request: Request, project_id: str) -> Response: """Use this endpoint to get all project members""" diff --git a/server/test_tracker/views/project.py b/server/test_tracker/views/project.py index 5e231d7..44e623d 100644 --- a/server/test_tracker/views/project.py +++ b/server/test_tracker/views/project.py @@ -31,7 +31,7 @@ class ProjectsDetailAPIView(GenericAPIView): """ serializer_class = ProjectsSerializer - # permission_classes = (HasProjectAccess,) + # def get(self, request: Request, project_id: str) -> Response: """Return a single project based on the given project id""" @@ -130,7 +130,7 @@ class AddMemberToProjectAPIView(GenericAPIView): Add Member to project """ - # permission_classes = (HasProjectAccess,) + # def put(self, request: Request, project_id: Project, member_id: Member) -> Response: """ @@ -288,7 +288,7 @@ class AccountMembersNotInProjectAPIView(GenericAPIView): Class to get all account members where members not in project """ - permission_classes = (HasProjectAccess,) + serializer_class = ProjectTeamSerializer def get(self, request: Request, project_id: str): @@ -318,7 +318,7 @@ def get(self, request: Request, project_id: str): class TestSuitesSectionAPIView(GenericAPIView): serializer_class = TestSuiteSectionSerializer - permission_classes = (HasProjectAccess,) + def post(self, request: Request, project_id: str): """Post new section, required fields is [Title,]""" @@ -333,7 +333,7 @@ def post(self, request: Request, project_id: str): class GetTestSuitesSectionsAPIView(GenericAPIView): serializer_class = GetTestSuiteSectionSerializer - permission_classes = (HasProjectAccess,) + def get(self, request: Request, project_id: str, test_suite: str) -> Response: """Get all project test suite sections""" @@ -351,7 +351,7 @@ def get(self, request: Request, project_id: str, test_suite: str) -> Response: class DeleteTestSuiteSectionAPIView(GenericAPIView): """Delete a test suite section by its id.""" - permission_classes = (HasProjectAccess,) + def delete(self, request: Request, project_id: str, section_id: str) -> Response: """Delete a section with given id""" @@ -370,7 +370,7 @@ def delete(self, request: Request, project_id: str, section_id: str) -> Response class AddTestCaseToTestSuiteSectionAPIView(GenericAPIView): """Add a test case to test suite section""" - permission_classes = (HasProjectAccess,) + # serializer_class = AddTestCaseToTestSuiteSectionSerializers def put(self, request: Request, project_id: str): diff --git a/server/test_tracker/views/requirement.py b/server/test_tracker/views/requirement.py index dc3172e..6828092 100644 --- a/server/test_tracker/views/requirement.py +++ b/server/test_tracker/views/requirement.py @@ -32,7 +32,7 @@ class PostNewRequirementDocsAPIView(GenericAPIView): """class project requirement view""" serializer_class = RequirementDocsSerializer - permission_classes = (HasProjectAccess,) + def post(self, request: Request, project_id: str) -> Response: """post a new requirement""" @@ -70,7 +70,7 @@ class GetAllRequirementDocsAPIView(GenericAPIView): """class project requirement view""" serializer_class = RequirementDocsSerializer - permission_classes = (HasProjectAccess,) + def get(self, request: Request, project_id: str) -> Response: """ @@ -96,7 +96,7 @@ class project requirement view search on project requirements """ serializer_class = RequirementDocsSerializer - permission_classes = (HasProjectAccess,) + def get(self, request: Request, project_id: str, key_word: str) -> Response: """get all requirements for a project""" @@ -121,7 +121,7 @@ class project requirement view """ serializer_class = RequirementDocsSerializer - permission_classes = (HasProjectAccess,) + def get(self, request: Request, project_id: str, requirement_id: str) -> Response: """Use this endpoint to get requirement detail and sub requirements""" @@ -190,7 +190,7 @@ class RequirementAPIView(GenericAPIView): """This class is a sub requirement for project requirements""" serializer_class = RequirementsSerializer - permission_classes = (HasProjectAccess,) + def post(self, request: Request, project_id: str, requirements_id: str) -> Response: """ @@ -269,7 +269,7 @@ class project requirement view """ serializer_class = RequirementsSerializer - permission_classes = (HasProjectAccess,) + def get( self, @@ -371,7 +371,7 @@ class SearchRequirementsInRequirementDocssAPIView(APIView): Use this endpoint to filter any requirement based on title or description """ - permission_classes = (HasProjectAccess,) + def get(self, request: Request, project_id: str, key_word: str): """ diff --git a/server/test_tracker/views/test_cases.py b/server/test_tracker/views/test_cases.py index 6b1703a..c0fd220 100644 --- a/server/test_tracker/views/test_cases.py +++ b/server/test_tracker/views/test_cases.py @@ -180,7 +180,7 @@ class SearchTestCaseAPIView(GenericAPIView): """ serializer_class = TestCaseSerializer - permission_classes = (HasProjectAccess,) + def get(self, request: Request, project_id: str, key_word: str): """ @@ -201,7 +201,7 @@ class GetAllProjectRequirementsAPIView(GenericAPIView): """Get all of test cases""" serializer_class = RequirementsSerializer - permission_classes = (HasProjectAccess,) + def get(self, request: Request, project_id: str) -> Response: """Method get to get all of test cases based on the test suite""" @@ -221,7 +221,7 @@ class UpdateTestCaseAfterRunAPIView(GenericAPIView): """This class to update the test case by pass bool field""" serializer_class = UpdateTestCaseAfterRunSerializer - permission_classes = (HasProjectAccess,) + def put(self, request: Request, project_id: str, test_case_id: str) -> Response: """Method put to update the test case by pass bool field""" diff --git a/server/test_tracker/views/test_plan.py b/server/test_tracker/views/test_plan.py index f3038fe..aedf42d 100644 --- a/server/test_tracker/views/test_plan.py +++ b/server/test_tracker/views/test_plan.py @@ -28,7 +28,7 @@ class TestPlansAPIView(GenericAPIView): """Create a test plan.""" serializer_class = TestPlanSerializer - """permission_classes = (HasProjectAccess,)""" + """""" def post(self, request: Request, project_id: str) -> Response: """ @@ -82,7 +82,7 @@ class TestPlansDetailAPIView(GenericAPIView): """This class for [GET, UPDATE, DELETE] test plans methods""" serializer_class = TestPlanDetailSerializer - permission_classes = (HasProjectAccess,) + def get(self, request: Request, project_id: str, test_plan_id: str) -> Response: """Get a test plan from the specified project""" @@ -113,7 +113,7 @@ def delete(self, request: Request, project_id: str, test_plan_id: str) -> Respon class UpdateTestPlanAPIView(GenericAPIView): serializer_class = UpdateTestPlanSerializer - permission_classes = (HasProjectAccess,) + def put(self, request: Request, project_id: str, test_plan_id: str) -> Response: """Update test plan title""" @@ -147,7 +147,7 @@ class PostNewTestPlanContentAreaAPIView(GenericAPIView): """ serializer_class = TestPlanTempsSerializer - permission_classes = (HasProjectAccess,) + def post(self, request: Request, project_id: str, test_plan_id: str) -> Response: """Add custom content area to test plan""" @@ -185,7 +185,7 @@ class TestPlanContentAreaAPIView(GenericAPIView): Delete and get test plan content area based on its title """ - permission_classes = (HasProjectAccess,) + serializer_class = TestPlanTempsSerializer def put( @@ -272,7 +272,7 @@ class SearchTestPlanAPIView(GenericAPIView): """ serializer_class = TestPlanDetailSerializer - permission_classes = (HasProjectAccess,) + def get(self, request: Request, project_id: str, key_word: str): """ diff --git a/server/test_tracker/views/test_run.py b/server/test_tracker/views/test_run.py index af72988..b474cc6 100644 --- a/server/test_tracker/views/test_run.py +++ b/server/test_tracker/views/test_run.py @@ -28,7 +28,7 @@ class TestRunAPIView(GenericAPIView): """Class TestRunAPIView to handle test runs endpoints""" serializer_class = TestRunsSerializer - permission_classes = (HasProjectAccess,) + def post(self, request: Request, project_id: str) -> Response: serializer = self.serializer_class(data=request.data) @@ -89,7 +89,7 @@ class TestRunDetailAPIView(GenericAPIView): """Class TestRunAPIView to handle test runs endpoints""" serializer_class = TestRunsSerializer - permission_classes = (HasProjectAccess,) + def get(self, request: Request, project_id: str, test_run_id: str) -> Response: """ @@ -142,7 +142,7 @@ class SearchOnTestRunAPIView(GenericAPIView): """ serializer_class = TestRunsSerializer - permission_classes = (HasProjectAccess,) + def get(self, request: Request, project_id: str) -> Response: """ @@ -176,7 +176,7 @@ def get(self, request: Request, project_id: str) -> Response: class LastWeekTestRunReportSheetAPIView(GenericAPIView): - permission_classes = (HasProjectAccess,) + def get(self, request: Request, project_id: str) -> Response: """ @@ -227,7 +227,7 @@ def get(self, request: Request, project_id: str) -> Response: class RunAllTestCasesAPIView(GenericAPIView): - permission_classes = (HasProjectAccess,) + serializer_class = TestCaseSerializer def get(self, request: Request, project_id: str, test_run_id: str) -> Response: @@ -286,7 +286,7 @@ def put(self, request: Request, project_id: str, test_run_id: str) -> Response: class SetAssignedUserTestRunAPIView(GenericAPIView): - permission_classes = (HasProjectAccess,) + serializer_class = TestRunsSerializer def put(self, request: Request, project_id: str, test_run_id: str) -> Response: @@ -334,7 +334,7 @@ def get(self, request: Request) -> Response: class CompleteTestRunAPIView(GenericAPIView): """Complete test run after run all test cases.""" - permission_classes = (HasProjectAccess,) + def put(self, request: Request, project_id: str, test_run_id: str) -> Response: """We will use this endpoint to complete the test run after running all test cases""" diff --git a/server/test_tracker/views/test_suites.py b/server/test_tracker/views/test_suites.py index 5e0268c..82d3a07 100644 --- a/server/test_tracker/views/test_suites.py +++ b/server/test_tracker/views/test_suites.py @@ -22,7 +22,7 @@ class TestSuitesAPIView(GenericAPIView): """Create a new test suite""" serializer_class = TestSuitesSerializer - permission_classes = (HasProjectAccess,) + def post(self, request: Request, project_id: str) -> Response: """ @@ -74,7 +74,7 @@ class TestSuitesDetailAPIView(GenericAPIView): """Create a new test suite""" serializer_class = TestSuitesDetailSerializer - permission_classes = (HasProjectAccess,) + def put(self, request: Request, project_id: str, test_suite_id: str) -> Response: """ @@ -138,7 +138,7 @@ class SearchTestSuiteAPIView(GenericAPIView): """ serializer_class = TestSuitesSerializer - permission_classes = (HasProjectAccess,) + def get(self, request: Request, project_id: str, key_word: str): """