mirror of
https://github.com/plankanban/planka.git
synced 2025-07-19 05:09:43 +02:00
add the config.js file
Signed-off-by: nabim777 <nabinalemagar019@gmail.com>
This commit is contained in:
parent
db81ebcc7f
commit
9670bd01f8
4 changed files with 27 additions and 10 deletions
|
@ -3,15 +3,16 @@
|
||||||
const { Before, BeforeAll, AfterAll, After, setDefaultTimeout } = require('@cucumber/cucumber');
|
const { Before, BeforeAll, AfterAll, After, setDefaultTimeout } = require('@cucumber/cucumber');
|
||||||
const { chromium } = require('playwright');
|
const { chromium } = require('playwright');
|
||||||
const { deleteProject } = require('./tests/acceptance/testHelpers/apiHelpers');
|
const { deleteProject } = require('./tests/acceptance/testHelpers/apiHelpers');
|
||||||
|
const config = require('./tests/acceptance/config');
|
||||||
|
|
||||||
setDefaultTimeout(60000);
|
setDefaultTimeout(config.timeout);
|
||||||
|
|
||||||
// launch the browser
|
// launch the browser
|
||||||
BeforeAll(async function () {
|
BeforeAll(async function () {
|
||||||
global.browser = await chromium.launch({
|
global.browser = await chromium.launch({
|
||||||
// makes true for CI
|
// makes true for CI
|
||||||
headless: true,
|
headless: config.headless,
|
||||||
slowMo: 1000,
|
slowMo: config.slowMo,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
12
client/tests/acceptance/config.js
Normal file
12
client/tests/acceptance/config.js
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
module.exports = {
|
||||||
|
// environment
|
||||||
|
adminUser: {
|
||||||
|
email: 'demo@demo.demo',
|
||||||
|
password: 'demo',
|
||||||
|
},
|
||||||
|
baseUrl: process.env.BASE_URL ?? 'http://localhost:1337/',
|
||||||
|
// playwright
|
||||||
|
slowMo: parseInt(process.env.SLOW_MO, 10) || 1000,
|
||||||
|
timeout: parseInt(process.env.TIMEOUT, 10) || 6000,
|
||||||
|
headless: process.env.HEADLESS !== 'true',
|
||||||
|
};
|
|
@ -1,9 +1,12 @@
|
||||||
|
const config = require(`../config`);
|
||||||
|
|
||||||
class LoginPage {
|
class LoginPage {
|
||||||
constructor() {
|
constructor() {
|
||||||
// url
|
// url
|
||||||
this.homeUrl = 'http://localhost:1337';
|
this.homeUrl = config.baseUrl;
|
||||||
this.loginUrl = `${this.homeUrl}/login`;
|
this.loginUrl = `${this.homeUrl}login`;
|
||||||
|
|
||||||
|
// selectors
|
||||||
this.loginButtonSelector = `//i[@class="right arrow icon"]`;
|
this.loginButtonSelector = `//i[@class="right arrow icon"]`;
|
||||||
this.usernameSelector = `//input[@name='emailOrUsername']`;
|
this.usernameSelector = `//input[@name='emailOrUsername']`;
|
||||||
this.passwordSelector = `//input[@name='password']`;
|
this.passwordSelector = `//input[@name='password']`;
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
const config = require('../config');
|
||||||
|
|
||||||
async function getXauthToken() {
|
async function getXauthToken() {
|
||||||
try {
|
try {
|
||||||
const res = await axios.post(
|
const res = await axios.post(
|
||||||
'http://localhost:1337/api/access-tokens',
|
`${config.baseUrl}api/access-tokens`,
|
||||||
{
|
{
|
||||||
emailOrUsername: 'demo',
|
emailOrUsername: config.adminUser.email,
|
||||||
password: 'demo',
|
password: config.adminUser.password,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -22,7 +23,7 @@ async function getXauthToken() {
|
||||||
|
|
||||||
async function getProjectIDs() {
|
async function getProjectIDs() {
|
||||||
try {
|
try {
|
||||||
const res = await axios.get('http://localhost:1337/api/projects', {
|
const res = await axios.get(`${config.baseUrl}api/projects`, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${await getXauthToken()}`,
|
Authorization: `Bearer ${await getXauthToken()}`,
|
||||||
},
|
},
|
||||||
|
@ -38,7 +39,7 @@ async function deleteProject() {
|
||||||
const projectIDs = await getProjectIDs();
|
const projectIDs = await getProjectIDs();
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
projectIDs.map(async (project) => {
|
projectIDs.map(async (project) => {
|
||||||
await axios.delete(`http://localhost:1337/api/projects/${project}`, {
|
await axios.delete(`${config.baseUrl}api/projects/${project}`, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${await getXauthToken()}`,
|
Authorization: `Bearer ${await getXauthToken()}`,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue