mirror of
https://github.com/plankanban/planka.git
synced 2025-07-24 15:49:46 +02:00
add test for dashboard
Signed-off-by: nabim777 <nabinalemagar019@gmail.com>
This commit is contained in:
parent
95c8175e8c
commit
db81ebcc7f
6 changed files with 114 additions and 1 deletions
56
client/tests/acceptance/testHelpers/apiHelpers.js
Normal file
56
client/tests/acceptance/testHelpers/apiHelpers.js
Normal file
|
@ -0,0 +1,56 @@
|
|||
const axios = require('axios');
|
||||
|
||||
async function getXauthToken() {
|
||||
try {
|
||||
const res = await axios.post(
|
||||
'http://localhost:1337/api/access-tokens',
|
||||
{
|
||||
emailOrUsername: 'demo',
|
||||
password: 'demo',
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
},
|
||||
);
|
||||
return res.data.item;
|
||||
} catch (error) {
|
||||
return `Error requesting access token: ${error.message}`;
|
||||
}
|
||||
}
|
||||
|
||||
async function getProjectIDs() {
|
||||
try {
|
||||
const res = await axios.get('http://localhost:1337/api/projects', {
|
||||
headers: {
|
||||
Authorization: `Bearer ${await getXauthToken()}`,
|
||||
},
|
||||
});
|
||||
return res.data.items.map((project) => project.id);
|
||||
} catch (error) {
|
||||
return `Error requesting projectIDs: ${error.message}`;
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteProject() {
|
||||
try {
|
||||
const projectIDs = await getProjectIDs();
|
||||
await Promise.all(
|
||||
projectIDs.map(async (project) => {
|
||||
await axios.delete(`http://localhost:1337/api/projects/${project}`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${await getXauthToken()}`,
|
||||
},
|
||||
});
|
||||
}),
|
||||
);
|
||||
return true;
|
||||
} catch (error) {
|
||||
return `Error deleting project: ${error.message}`;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
deleteProject,
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue