Skip to content
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
1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
},
"dependencies": {
"@mdi/font": "7.4.47",
"axios": "^1.7.3",
"core-js": "^3.37.1",
"roboto-fontface": "*",
"vue": "^3.4.31",
Expand Down
73 changes: 73 additions & 0 deletions client/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 41 additions & 6 deletions client/src/api/axios.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,52 @@
import axios, { AxiosInstance } from 'axios';
import axios, { AxiosInstance } from 'axios'

const AuthClient: AxiosInstance = axios.create({
baseURL: import.meta.env.VITE_APP_ENDPOINT,
baseURL: import.meta.env.VITE_APP_ENDPOINT,
timeout: 1000,
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + localStorage.getItem("token"),
Authorization: 'Bearer ' + localStorage.getItem('token'),
Comment on lines +4 to +8
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to merge your previous PRs to load the changes here instead of re-declared them

},
});
})

const BaseClient: AxiosInstance = axios.create({
baseURL: import.meta.env.VITE_APP_ENDPOINT,
timeout: 1000,
});
})

async function GetPlans (projectId:any) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the type of projectId?

try {
await AuthClient.get(`/test_plan/${projectId}/`)
} catch (error) {
console.error(error)
throw error
}
}

async function CreateNewTestSuite (testSuiteDetails: any, projectId:any) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's define the testSuiteDetails type, when using typescript you need to define all required types, the language name is type script

please apply this to all functions/requests

try {
await AuthClient.post(`/test_suites/${projectId}/`, testSuiteDetails)
} catch (error) {
console.error(error)
throw error
}
}
async function GetTestSuites (projectId:any) {
try {
return await AuthClient.get(`/test_suites/${projectId}/`)
} catch (error) {
console.error(error)
throw error
}
}

async function SearchSuite (projectId:any, keyWord:any) {
try {
await AuthClient.get(`/test_suites/${projectId}/search/${keyWord}/`)
} catch (error) {
console.error(error)
throw error
}
}

export { AuthClient, BaseClient };
export default { AuthClient, BaseClient, GetPlans, CreateNewTestSuite, GetTestSuites, SearchSuite }
3 changes: 1 addition & 2 deletions client/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ export {}
/* prettier-ignore */
declare module 'vue' {
export interface GlobalComponents {
AppFooter: typeof import('./components/AppFooter.vue')['default']
HelloWorld: typeof import('./components/HelloWorld.vue')['default']
NewTestSuite: typeof import('./components/NewTestSuite.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
Test: typeof import('./components/test.vue')['default']
Expand Down
91 changes: 91 additions & 0 deletions client/src/components/NewTestSuite.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<template>
<div class="text-center pa-4">
<!-- this is just to be replaced later on with the + button on click , it opens the dialog.. -->
<v-btn @click="dialog = true">
Open Dialog
</v-btn>

<v-dialog v-model="dialog" max-width="600px">
<v-card>
<v-card-title>New Test Suite</v-card-title>
<v-divider />
<br>
<v-card-subtitle>
<div>
<strong>Title</strong>
<v-text-field v-model="details.title" placeholder="Enter title " />
</div>
<div>
<strong>Test Plan</strong>
<v-select v-model="details.test_plan" :items="plans" label="Select Plan" />
</div>
</v-card-subtitle>
<v-divider />
<v-card-actions>
<v-btn color="info" @click="dialog = false">Close</v-btn>
<v-btn color="success" @click="createTestSuite">Create</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</div>
</template>

<script>
import axios from '@/api/axios'
import { onMounted } from 'vue'

export default {
setup () {
const dialog = ref(false)
const details = ref({
title: '',
test_plan: null,
})

const plans = ref([])

// from where to get the project id???
const fetchPlans = async () => {
try {
plans.value = await axios.GetPlans(projectId)
} catch (error) {
console.error(error)
}
}

const createTestSuite = async () => {
try {
await axios.CreateNewTestSuite(details, projectId)
notifier.notify({
title: 'success',
description: 'test suite created successfully',
showProgressBar: true,
timeout: 7_000,
type: 'success',
Comment on lines +58 to +64
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You understand now, we load it from the backend, you can wrap it for sure

})
} catch (error) {
console.error(error)
notifier.notify({
title: 'Fail',
description: 'Failed to create test suite',
showProgressBar: true,
timeout: 7_000,
type: 'error',
})
}
}

onMounted(() => {
fetchPlans()
})

return {
dialog,
details,
plans,
createTestSuite,
fetchPlans,
}
},
}
</script>
Loading