mirror of
https://github.com/plankanban/planka.git
synced 2025-07-24 07:39:44 +02:00
test: Add BDD UI tests using Playwright (#911)
This commit is contained in:
parent
4efc3be8d5
commit
096feb35bb
17 changed files with 1260 additions and 120 deletions
57
client/tests/acceptance/testHelpers/apiHelpers.js
Normal file
57
client/tests/acceptance/testHelpers/apiHelpers.js
Normal file
|
@ -0,0 +1,57 @@
|
|||
const axios = require('axios');
|
||||
const config = require('../config');
|
||||
|
||||
async function getXauthToken() {
|
||||
try {
|
||||
const res = await axios.post(
|
||||
`${config.baseUrl}api/access-tokens`,
|
||||
{
|
||||
emailOrUsername: config.adminUser.email,
|
||||
password: config.adminUser.password,
|
||||
},
|
||||
{
|
||||
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(`${config.baseUrl}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(`${config.baseUrl}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