mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
fix(tests): fixes the failing smoke tests
- introduces a fix for the failing tests
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -17,6 +17,7 @@ node_modules
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
env.js
|
||||
/.vscode
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
|
||||
@@ -332,7 +332,12 @@ class Incident extends React.Component {
|
||||
component,
|
||||
location: { pathname },
|
||||
} = this.props;
|
||||
const componentName = component.length > 0 ? component[0].name : null;
|
||||
const componentName =
|
||||
component.length > 0
|
||||
? component[0]
|
||||
? component[0].name
|
||||
: null
|
||||
: null;
|
||||
|
||||
return (
|
||||
<Dashboard ready={this.ready}>
|
||||
|
||||
@@ -180,7 +180,12 @@ class IncidentLog extends React.Component {
|
||||
);
|
||||
|
||||
allIncidents && allIncidents.unshift(projectIncident);
|
||||
const componentName = component.length > 0 ? component[0].name : null;
|
||||
const componentName =
|
||||
component.length > 0
|
||||
? component[0]
|
||||
? component[0].name
|
||||
: null
|
||||
: null;
|
||||
|
||||
return (
|
||||
<Dashboard ready={this.ready}>
|
||||
|
||||
@@ -229,7 +229,12 @@ class DashboardView extends Component {
|
||||
);
|
||||
|
||||
monitors && monitors.unshift(projectMonitor);
|
||||
const componentName = component.length > 0 ? component[0].name : null;
|
||||
const componentName =
|
||||
component.length > 0
|
||||
? component[0]
|
||||
? component[0].name
|
||||
: null
|
||||
: null;
|
||||
|
||||
return (
|
||||
<Dashboard ready={this.ready}>
|
||||
|
||||
@@ -75,7 +75,12 @@ class MonitorView extends React.Component {
|
||||
const subProjectId = this.props.monitor
|
||||
? this.props.monitor.projectId._id || this.props.monitor.projectId
|
||||
: null;
|
||||
const componentName = component.length > 0 ? component[0].name : null;
|
||||
const componentName =
|
||||
component.length > 0
|
||||
? component[0]
|
||||
? component[0].name
|
||||
: null
|
||||
: null;
|
||||
const monitorName = monitor ? monitor.name : null;
|
||||
|
||||
return (
|
||||
|
||||
@@ -4,12 +4,16 @@ const init = require('./test-init');
|
||||
const { Cluster } = require('puppeteer-cluster');
|
||||
|
||||
// parent user credentials
|
||||
const email = utils.generateRandomBusinessEmail();
|
||||
const password = '1234567890';
|
||||
const user = {
|
||||
email: utils.generateRandomBusinessEmail(),
|
||||
password: '1234567890',
|
||||
};
|
||||
|
||||
// sub-project user credentials
|
||||
const newEmail = utils.generateRandomBusinessEmail();
|
||||
const newPassword = '1234567890';
|
||||
const newUser = {
|
||||
email: utils.generateRandomBusinessEmail(),
|
||||
password: '1234567890',
|
||||
};
|
||||
|
||||
const projectName = utils.generateRandomString();
|
||||
const projectMonitorName = utils.generateRandomString();
|
||||
@@ -23,7 +27,7 @@ describe('Incident API With SubProjects', () => {
|
||||
|
||||
let cluster;
|
||||
|
||||
beforeAll(async done => {
|
||||
beforeAll(async () => {
|
||||
jest.setTimeout(500000);
|
||||
|
||||
cluster = await Cluster.launch({
|
||||
@@ -37,53 +41,26 @@ describe('Incident API With SubProjects', () => {
|
||||
throw err;
|
||||
});
|
||||
|
||||
// Register user
|
||||
const task = async ({ page, data }) => {
|
||||
await page.setDefaultTimeout(utils.timeout);
|
||||
const user = {
|
||||
email: data.email,
|
||||
password: data.password,
|
||||
};
|
||||
|
||||
// user
|
||||
return await cluster.execute(null, async ({ page }) => {
|
||||
await init.registerUser(user, page);
|
||||
};
|
||||
|
||||
await cluster.execute(
|
||||
{
|
||||
email: newEmail,
|
||||
password: newPassword,
|
||||
},
|
||||
task
|
||||
);
|
||||
|
||||
await cluster.execute(
|
||||
{
|
||||
email,
|
||||
password,
|
||||
},
|
||||
task
|
||||
);
|
||||
|
||||
done();
|
||||
await init.registerUser(newUser, page);
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(async done => {
|
||||
afterAll(async () => {
|
||||
await cluster.idle();
|
||||
await cluster.close();
|
||||
done();
|
||||
});
|
||||
|
||||
test(
|
||||
'should create an incident in parent project for valid `admin`',
|
||||
async done => {
|
||||
await cluster.execute(null, async ({ page }) => {
|
||||
const user = { email, password };
|
||||
async () => {
|
||||
return await cluster.execute(null, async ({ page }) => {
|
||||
await init.loginUser(user, page);
|
||||
|
||||
await page.goto(utils.DASHBOARD_URL);
|
||||
|
||||
await page.waitForSelector('#AccountSwitcherId');
|
||||
await page.waitForSelector('#AccountSwitcherId', {
|
||||
visible: true,
|
||||
});
|
||||
await page.click('#AccountSwitcherId');
|
||||
await page.waitForSelector('#create-project');
|
||||
await page.click('#create-project');
|
||||
@@ -106,7 +83,7 @@ describe('Incident API With SubProjects', () => {
|
||||
// add new user to sub-project
|
||||
await init.addUserToProject(
|
||||
{
|
||||
email: newEmail,
|
||||
email: newUser.email,
|
||||
role: 'Member',
|
||||
subProjectName,
|
||||
},
|
||||
@@ -148,9 +125,8 @@ describe('Incident API With SubProjects', () => {
|
||||
expect(textContent.toLowerCase()).toEqual(
|
||||
`${projectMonitorName}'s Incident Status`.toLowerCase()
|
||||
);
|
||||
await init.logout(page);
|
||||
});
|
||||
|
||||
done();
|
||||
},
|
||||
operationTimeOut
|
||||
);
|
||||
@@ -158,42 +134,30 @@ describe('Incident API With SubProjects', () => {
|
||||
test(
|
||||
'should not display created incident status in a different component',
|
||||
async () => {
|
||||
expect.assertions(1);
|
||||
return await cluster.execute(
|
||||
{ email, password, projectMonitorName },
|
||||
async ({ page, data }) => {
|
||||
await page.setDefaultTimeout(utils.timeout);
|
||||
const user = {
|
||||
email: data.email,
|
||||
password: data.password,
|
||||
};
|
||||
await init.loginUser(user, page);
|
||||
// Navigate to details page of monitor
|
||||
await init.navigateToComponentDetails(
|
||||
newComponentName,
|
||||
page
|
||||
);
|
||||
return await cluster.execute(null, async ({ page }) => {
|
||||
await init.loginUser(user, page);
|
||||
await page.goto(utils.DASHBOARD_URL, {
|
||||
waitUntil: 'networkidle0',
|
||||
});
|
||||
// Navigate to details page of monitor
|
||||
await init.navigateToComponentDetails(newComponentName, page);
|
||||
|
||||
const incidentTitleSelector = await page.$(
|
||||
'#incident_span_0'
|
||||
);
|
||||
expect(incidentTitleSelector).toBeNull();
|
||||
}
|
||||
);
|
||||
const incidentTitleSelector = await page.$('#incident_span_0');
|
||||
expect(incidentTitleSelector).toBeNull();
|
||||
await init.logout(page);
|
||||
});
|
||||
},
|
||||
operationTimeOut
|
||||
);
|
||||
|
||||
test(
|
||||
'should create an incident in sub-project for sub-project `member`',
|
||||
async done => {
|
||||
await cluster.execute(null, async ({ page }) => {
|
||||
const user = {
|
||||
email: newEmail,
|
||||
password: newPassword,
|
||||
};
|
||||
|
||||
await init.loginUser(user, page);
|
||||
async () => {
|
||||
return await cluster.execute(null, async ({ page }) => {
|
||||
await init.loginUser(newUser, page);
|
||||
await page.goto(utils.DASHBOARD_URL, {
|
||||
waitUntil: 'networkidle0',
|
||||
});
|
||||
// switch to invited project for new user
|
||||
await init.switchProject(projectName, page);
|
||||
// Navigate to details page of monitor
|
||||
@@ -216,23 +180,20 @@ describe('Incident API With SubProjects', () => {
|
||||
expect(textContent.toLowerCase()).toEqual(
|
||||
`${subProjectMonitorName}'s Incident Status`.toLowerCase()
|
||||
);
|
||||
await init.logout(page);
|
||||
});
|
||||
|
||||
done();
|
||||
},
|
||||
operationTimeOut
|
||||
);
|
||||
|
||||
test(
|
||||
'should acknowledge incident in sub-project for sub-project `member`',
|
||||
async done => {
|
||||
await cluster.execute(null, async ({ page }) => {
|
||||
const user = {
|
||||
email: newEmail,
|
||||
password: newPassword,
|
||||
};
|
||||
|
||||
await init.loginUser(user, page);
|
||||
async () => {
|
||||
return await cluster.execute(null, async ({ page }) => {
|
||||
await init.loginUser(newUser, page);
|
||||
await page.goto(utils.DASHBOARD_URL, {
|
||||
waitUntil: 'networkidle0',
|
||||
});
|
||||
// switch to invited project for new user
|
||||
await init.switchProject(projectName, page);
|
||||
// Navigate to details page of component created
|
||||
@@ -246,23 +207,20 @@ describe('Incident API With SubProjects', () => {
|
||||
'#AcknowledgeText_0'
|
||||
);
|
||||
expect(acknowledgeTextSelector).not.toBeNull();
|
||||
await init.logout(page);
|
||||
});
|
||||
|
||||
done();
|
||||
},
|
||||
operationTimeOut
|
||||
);
|
||||
|
||||
test(
|
||||
'should resolve incident in sub-project for sub-project `member`',
|
||||
async done => {
|
||||
await cluster.execute(null, async ({ page }) => {
|
||||
const user = {
|
||||
email: newEmail,
|
||||
password: newPassword,
|
||||
};
|
||||
|
||||
await init.loginUser(user, page);
|
||||
async () => {
|
||||
return await cluster.execute(null, async ({ page }) => {
|
||||
await init.loginUser(newUser, page);
|
||||
await page.goto(utils.DASHBOARD_URL, {
|
||||
waitUntil: 'networkidle0',
|
||||
});
|
||||
// switch to invited project for new user
|
||||
await init.switchProject(projectName, page);
|
||||
// Navigate to details page of component created
|
||||
@@ -274,43 +232,52 @@ describe('Incident API With SubProjects', () => {
|
||||
|
||||
const resolveTextSelector = await page.$('#ResolveText_0');
|
||||
expect(resolveTextSelector).not.toBeNull();
|
||||
await init.logout(page);
|
||||
});
|
||||
|
||||
done();
|
||||
},
|
||||
operationTimeOut
|
||||
);
|
||||
|
||||
test(
|
||||
'should update internal and investigation notes of incident in sub-project',
|
||||
async done => {
|
||||
const investigationNote = utils.generateRandomString();
|
||||
const internalNote = utils.generateRandomString();
|
||||
await cluster.execute(null, async ({ page }) => {
|
||||
const user = {
|
||||
email: newEmail,
|
||||
password: newPassword,
|
||||
};
|
||||
|
||||
await init.loginUser(user, page);
|
||||
async () => {
|
||||
return await cluster.execute(null, async ({ page }) => {
|
||||
const investigationNote = utils.generateRandomString();
|
||||
const internalNote = utils.generateRandomString();
|
||||
await init.loginUser(newUser, page);
|
||||
await page.goto(utils.DASHBOARD_URL, {
|
||||
waitUntil: 'networkidle0',
|
||||
});
|
||||
// switch to invited project for new user
|
||||
await init.switchProject(projectName, page);
|
||||
// Navigate to details page of component created
|
||||
await init.navigateToComponentDetails(componentName, page);
|
||||
// update internal note
|
||||
await page.waitForSelector(
|
||||
`#incident_${subProjectMonitorName}_0`
|
||||
`#incident_${subProjectMonitorName}_0`,
|
||||
{ visible: true }
|
||||
);
|
||||
await page.click(`#incident_${subProjectMonitorName}_0`);
|
||||
await page.waitForSelector('#txtInternalNote');
|
||||
|
||||
await page.waitForSelector('#txtInternalNote', {
|
||||
visible: true,
|
||||
});
|
||||
await page.type('#txtInternalNote', internalNote);
|
||||
await page.waitForSelector('#btnUpdateInternalNote', {
|
||||
visible: true,
|
||||
});
|
||||
await page.click('#btnUpdateInternalNote');
|
||||
await page.waitFor(5000);
|
||||
await page.waitForSelector('#txtInvestigationNote');
|
||||
|
||||
await page.waitForSelector('#txtInvestigationNote', {
|
||||
visible: true,
|
||||
});
|
||||
await page.type('#txtInvestigationNote', investigationNote);
|
||||
await page.waitForSelector('#btnUpdateInvestigationNote', {
|
||||
visible: true,
|
||||
});
|
||||
await page.click('#btnUpdateInvestigationNote');
|
||||
await page.waitFor(5000);
|
||||
|
||||
const internalNoteSelector = await page.$('#txtInternalNote');
|
||||
let internalContent = await internalNoteSelector.getProperty(
|
||||
'textContent'
|
||||
@@ -328,29 +295,26 @@ describe('Incident API With SubProjects', () => {
|
||||
|
||||
investigationContent = await investigationContent.jsonValue();
|
||||
expect(investigationContent).toEqual(investigationNote);
|
||||
await init.logout(page);
|
||||
});
|
||||
|
||||
done();
|
||||
},
|
||||
operationTimeOut
|
||||
);
|
||||
|
||||
test(
|
||||
'should get incident timeline and paginate for incident timeline in sub-project',
|
||||
async done => {
|
||||
const internalNote = utils.generateRandomString();
|
||||
await cluster.execute(null, async ({ page }) => {
|
||||
// await page.setDefaultTimeout(utils.timeout);
|
||||
const user = {
|
||||
email: newEmail,
|
||||
password: newPassword,
|
||||
};
|
||||
|
||||
await init.loginUser(user, page);
|
||||
async () => {
|
||||
return await cluster.execute(null, async ({ page }) => {
|
||||
const internalNote = utils.generateRandomString();
|
||||
await init.loginUser(newUser, page);
|
||||
await page.goto(utils.DASHBOARD_URL, {
|
||||
waitUntil: 'networkidle0',
|
||||
});
|
||||
// switch to invited project for new user
|
||||
await init.switchProject(projectName, page);
|
||||
// Navigate to details page of component created
|
||||
await init.navigateToComponentDetails(componentName, page);
|
||||
await page.waitFor(3000);
|
||||
|
||||
await page.waitForSelector(
|
||||
`#incident_${subProjectMonitorName}_0`
|
||||
@@ -359,96 +323,80 @@ describe('Incident API With SubProjects', () => {
|
||||
|
||||
for (let i = 0; i < 10; i++) {
|
||||
// update internal note
|
||||
await page.waitForSelector('#txtInternalNote');
|
||||
await page.waitForSelector('#txtInternalNote', {
|
||||
visible: true,
|
||||
});
|
||||
await page.type('#txtInternalNote', internalNote);
|
||||
await page.click('#btnUpdateInternalNote');
|
||||
await page.waitFor(5000);
|
||||
await page.waitFor(2000);
|
||||
}
|
||||
|
||||
let incidentTimelineRows = await page.$$('tr.incidentListItem');
|
||||
let countIncidentTimelines = incidentTimelineRows.length;
|
||||
|
||||
expect(countIncidentTimelines).toEqual(10);
|
||||
|
||||
const nextSelector = await page.$('#btnTimelineNext');
|
||||
|
||||
await nextSelector.click();
|
||||
await page.waitFor(5000);
|
||||
await page.waitFor(2000);
|
||||
incidentTimelineRows = await page.$$('tr.incidentListItem');
|
||||
countIncidentTimelines = incidentTimelineRows.length;
|
||||
expect(countIncidentTimelines).toEqual(5);
|
||||
|
||||
const prevSelector = await page.$('#btnTimelinePrev');
|
||||
|
||||
await prevSelector.click();
|
||||
await page.waitFor(5000);
|
||||
await page.waitFor(2000);
|
||||
incidentTimelineRows = await page.$$('tr.incidentListItem');
|
||||
countIncidentTimelines = incidentTimelineRows.length;
|
||||
expect(countIncidentTimelines).toEqual(10);
|
||||
await init.logout(page);
|
||||
});
|
||||
|
||||
done();
|
||||
},
|
||||
operationTimeOut
|
||||
);
|
||||
|
||||
test(
|
||||
'should get list of incidents and paginate for incidents in sub-project',
|
||||
async done => {
|
||||
await cluster.execute(
|
||||
{
|
||||
email: newEmail,
|
||||
password: newPassword,
|
||||
subProjectMonitorName,
|
||||
subProjectName,
|
||||
projectName,
|
||||
counter: 0,
|
||||
limit: 10,
|
||||
},
|
||||
async ({ page, data }) => {
|
||||
const user = {
|
||||
email: data.email,
|
||||
password: data.password,
|
||||
};
|
||||
async () => {
|
||||
return await cluster.execute(null, async ({ page }) => {
|
||||
await init.loginUser(newUser, page);
|
||||
await page.goto(utils.DASHBOARD_URL, {
|
||||
waitUntil: 'networkidle0',
|
||||
});
|
||||
// switch to invited project for new user
|
||||
await init.switchProject(projectName, page);
|
||||
// Navigate to details page of component created
|
||||
await init.navigateToComponentDetails(componentName, page);
|
||||
|
||||
await init.loginUser(user, page);
|
||||
// switch to invited project for new user
|
||||
await init.switchProject(data.projectName, page);
|
||||
// Navigate to details page of component created
|
||||
await init.navigateToComponentDetails(componentName, page);
|
||||
|
||||
for (let i = 0; i < 10; i++) {
|
||||
await init.addIncidentToProject(
|
||||
data.subProjectMonitorName,
|
||||
data.subProjectName,
|
||||
page
|
||||
);
|
||||
}
|
||||
|
||||
let incidentRows = await page.$$('tr.incidentListItem');
|
||||
let countIncidents = incidentRows.length;
|
||||
|
||||
expect(countIncidents).toEqual(10);
|
||||
|
||||
const nextSelector = await page.$('#btnNext');
|
||||
|
||||
await nextSelector.click();
|
||||
await page.waitFor(5000);
|
||||
incidentRows = await page.$$('tr.incidentListItem');
|
||||
countIncidents = incidentRows.length;
|
||||
expect(countIncidents).toEqual(1);
|
||||
|
||||
const prevSelector = await page.$('#btnPrev');
|
||||
|
||||
await prevSelector.click();
|
||||
await page.waitFor(5000);
|
||||
incidentRows = await page.$$('tr.incidentListItem');
|
||||
countIncidents = incidentRows.length;
|
||||
expect(countIncidents).toEqual(10);
|
||||
for (let i = 0; i < 10; i++) {
|
||||
await init.addIncidentToProject(
|
||||
subProjectMonitorName,
|
||||
subProjectName,
|
||||
page
|
||||
);
|
||||
await page.waitFor(2000);
|
||||
}
|
||||
);
|
||||
|
||||
done();
|
||||
let incidentRows = await page.$$('tr.incidentListItem');
|
||||
let countIncidents = incidentRows.length;
|
||||
expect(countIncidents).toEqual(10);
|
||||
|
||||
const nextSelector = await page.$('#btnNext', {
|
||||
visible: true,
|
||||
});
|
||||
await nextSelector.click();
|
||||
incidentRows = await page.$$('tr.incidentListItem');
|
||||
countIncidents = incidentRows.length;
|
||||
expect(countIncidents).toEqual(10);
|
||||
|
||||
const prevSelector = await page.$('#btnPrev');
|
||||
|
||||
await prevSelector.click();
|
||||
await page.waitFor(5000);
|
||||
incidentRows = await page.$$('tr.incidentListItem');
|
||||
countIncidents = incidentRows.length;
|
||||
expect(countIncidents).toEqual(10);
|
||||
await init.logout(page);
|
||||
});
|
||||
},
|
||||
operationTimeOut
|
||||
);
|
||||
|
||||
@@ -43,6 +43,8 @@ describe('Monitor Detail API', () => {
|
||||
// user
|
||||
await init.registerUser(user, page);
|
||||
await init.loginUser(user, page);
|
||||
await page.waitFor(1000);
|
||||
await page.goto(utils.DASHBOARD_URL);
|
||||
// add new monitor to component on parent project
|
||||
await init.addMonitorToComponent(componentName, monitorName, page);
|
||||
});
|
||||
@@ -182,8 +184,7 @@ describe('Monitor Detail API', () => {
|
||||
page.click('#createScheduledEventButton'),
|
||||
]);
|
||||
|
||||
const createdScheduledEventSelector =
|
||||
'#scheduledEventsList .scheduled-event-name';
|
||||
const createdScheduledEventSelector = '.scheduled-event-name';
|
||||
await page.waitFor(5000);
|
||||
|
||||
const createdScheduledEventName = await page.$eval(
|
||||
|
||||
@@ -88,6 +88,7 @@ module.exports = {
|
||||
await page.type('input[name=email]', email);
|
||||
await page.click('input[name=password]');
|
||||
await page.type('input[name=password]', password);
|
||||
await page.waitForSelector('button[type=submit]', { visible: true });
|
||||
await Promise.all([
|
||||
page.waitForNavigation({ waitUntil: 'networkidle0' }),
|
||||
page.click('button[type=submit]'),
|
||||
@@ -95,6 +96,7 @@ module.exports = {
|
||||
},
|
||||
logout: async function(page) {
|
||||
await page.goto(utils.DASHBOARD_URL);
|
||||
await page.waitForSelector('button#profile-menu', { visible: true });
|
||||
await page.click('button#profile-menu');
|
||||
await page.waitForSelector('button#logout-button');
|
||||
await page.click('button#logout-button');
|
||||
@@ -102,13 +104,8 @@ module.exports = {
|
||||
await page.waitFor(3000);
|
||||
},
|
||||
addComponent: async function(component, page, projectName = null) {
|
||||
const componentsMenuItem = await page.$('#components');
|
||||
|
||||
if (componentsMenuItem == null) {
|
||||
// Navigate to Components page
|
||||
await page.goto(utils.DASHBOARD_URL);
|
||||
await page.waitForSelector('#components');
|
||||
}
|
||||
await page.goto(utils.DASHBOARD_URL);
|
||||
await page.waitForSelector('#components', { visible: true });
|
||||
|
||||
await page.click('#components');
|
||||
|
||||
@@ -243,7 +240,7 @@ module.exports = {
|
||||
},
|
||||
switchProject: async function(projectName, page) {
|
||||
await page.goto(utils.DASHBOARD_URL);
|
||||
// await page.waitForSelector('#AccountSwitcherId');
|
||||
await page.waitForSelector('#AccountSwitcherId', { visible: true });
|
||||
await page.click('#AccountSwitcherId');
|
||||
await page.waitFor(2000);
|
||||
await page.waitForSelector(`#accountSwitcher div#${projectName}`);
|
||||
@@ -322,7 +319,8 @@ module.exports = {
|
||||
},
|
||||
addIncidentToProject: async function(monitorName, projectName, page) {
|
||||
const createIncidentSelector = await page.$(
|
||||
`#btnCreateIncident_${projectName}`
|
||||
`#btnCreateIncident_${projectName}`,
|
||||
{ visible: true }
|
||||
);
|
||||
if (createIncidentSelector) {
|
||||
await page.waitForSelector(`#btnCreateIncident_${projectName}`);
|
||||
|
||||
@@ -6,16 +6,21 @@ const { Cluster } = require('puppeteer-cluster');
|
||||
require('should');
|
||||
|
||||
// user credentials
|
||||
const email = utils.generateRandomBusinessEmail();
|
||||
const password = '1234567890';
|
||||
const user = {
|
||||
email: utils.generateRandomBusinessEmail(),
|
||||
password: '1234567890',
|
||||
};
|
||||
|
||||
describe('Enterprise Dashboard API', () => {
|
||||
const operationTimeOut = 100000;
|
||||
let cluster;
|
||||
const monitorName = utils.generateRandomString();
|
||||
const componentName = utils.generateRandomString();
|
||||
|
||||
beforeAll(async done => {
|
||||
beforeAll(async () => {
|
||||
jest.setTimeout(200000);
|
||||
|
||||
const cluster = await Cluster.launch({
|
||||
cluster = await Cluster.launch({
|
||||
concurrency: Cluster.CONCURRENCY_PAGE,
|
||||
puppeteerOptions: utils.puppeteerLaunchConfig,
|
||||
puppeteer,
|
||||
@@ -27,72 +32,41 @@ describe('Enterprise Dashboard API', () => {
|
||||
});
|
||||
|
||||
// Register user
|
||||
await cluster.task(async ({ page, data }) => {
|
||||
const user = {
|
||||
email: data.email,
|
||||
password: data.password,
|
||||
};
|
||||
return await cluster.execute(null, async ({ page }) => {
|
||||
// user
|
||||
await init.registerEnterpriseUser(user, page);
|
||||
await init.loginUser(user, page);
|
||||
});
|
||||
|
||||
await cluster.queue({ email, password });
|
||||
// await cluster.queue({ email, password });
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await cluster.idle();
|
||||
await cluster.close();
|
||||
done();
|
||||
});
|
||||
|
||||
afterAll(async done => {
|
||||
done();
|
||||
});
|
||||
|
||||
const componentName = utils.generateRandomString();
|
||||
|
||||
it(
|
||||
'Should create new monitor with correct details',
|
||||
async done => {
|
||||
const cluster = await Cluster.launch({
|
||||
concurrency: Cluster.CONCURRENCY_PAGE,
|
||||
puppeteerOptions: utils.puppeteerLaunchConfig,
|
||||
puppeteer,
|
||||
timeout: 100000,
|
||||
});
|
||||
|
||||
cluster.on('taskerror', err => {
|
||||
throw err;
|
||||
});
|
||||
|
||||
const monitorName = utils.generateRandomString();
|
||||
|
||||
await cluster.task(async ({ page, data }) => {
|
||||
const user = {
|
||||
email: data.email,
|
||||
password: data.password,
|
||||
};
|
||||
|
||||
await init.loginUser(user, page);
|
||||
|
||||
async () => {
|
||||
return await cluster.execute(null, async ({ page }) => {
|
||||
// Navigate to Components page
|
||||
await page.waitForSelector('#components');
|
||||
await page.click('#components');
|
||||
await page.goto(utils.DASHBOARD_URL);
|
||||
|
||||
// Fill and submit New Component form
|
||||
await page.waitForSelector('#form-new-component');
|
||||
await page.click('input[id=name]');
|
||||
await page.type('input[id=name]', data.componentName);
|
||||
await page.type('input[id=name]', componentName);
|
||||
await page.click('button[type=submit]');
|
||||
|
||||
// Navigate to details page of component created
|
||||
await page.waitForSelector(
|
||||
`#more-details-${data.componentName}`
|
||||
);
|
||||
await page.click(`#more-details-${data.componentName}`);
|
||||
await page.waitForSelector(`#more-details-${componentName}`);
|
||||
await page.click(`#more-details-${componentName}`);
|
||||
await page.waitForSelector('#form-new-monitor');
|
||||
|
||||
// Fill and submit New Monitor form
|
||||
await page.click('input[id=name]');
|
||||
await page.type('input[id=name]', data.monitorName);
|
||||
await page.type('input[id=name]', monitorName);
|
||||
await init.selectByText('#type', 'url', page);
|
||||
await page.waitForSelector('#url');
|
||||
await page.click('#url');
|
||||
@@ -101,52 +75,26 @@ describe('Enterprise Dashboard API', () => {
|
||||
|
||||
let spanElement;
|
||||
spanElement = await page.waitForSelector(
|
||||
`#monitor-title-${data.monitorName}`
|
||||
`#monitor-title-${monitorName}`
|
||||
);
|
||||
spanElement = await spanElement.getProperty('innerText');
|
||||
spanElement = await spanElement.jsonValue();
|
||||
spanElement.should.be.exactly(data.monitorName);
|
||||
spanElement.should.be.exactly(monitorName);
|
||||
});
|
||||
|
||||
cluster.queue({ email, password, componentName, monitorName });
|
||||
await cluster.idle();
|
||||
await cluster.close();
|
||||
done();
|
||||
},
|
||||
operationTimeOut
|
||||
);
|
||||
|
||||
it(
|
||||
'Should not create new monitor when details are incorrect',
|
||||
async done => {
|
||||
const cluster = await Cluster.launch({
|
||||
concurrency: Cluster.CONCURRENCY_PAGE,
|
||||
puppeteerOptions: utils.puppeteerLaunchConfig,
|
||||
puppeteer,
|
||||
timeout: 100000,
|
||||
});
|
||||
|
||||
cluster.on('taskerror', err => {
|
||||
throw err;
|
||||
});
|
||||
|
||||
await cluster.task(async ({ page, data }) => {
|
||||
const user = {
|
||||
email: data.email,
|
||||
password: data.password,
|
||||
};
|
||||
|
||||
await init.loginUser(user, page);
|
||||
|
||||
async () => {
|
||||
return await cluster.execute(null, async ({ page }) => {
|
||||
// Navigate to Components page
|
||||
await page.waitForSelector('#components');
|
||||
await page.click('#components');
|
||||
await page.goto(utils.DASHBOARD_URL);
|
||||
|
||||
// Navigate to details page of component created in previous test
|
||||
await page.waitForSelector(
|
||||
`#more-details-${data.componentName}`
|
||||
);
|
||||
await page.click(`#more-details-${data.componentName}`);
|
||||
await page.waitForSelector(`#more-details-${componentName}`);
|
||||
await page.click(`#more-details-${componentName}`);
|
||||
await page.waitForSelector('#form-new-monitor');
|
||||
|
||||
// Fill and submit New Monitor form
|
||||
@@ -164,11 +112,6 @@ describe('Enterprise Dashboard API', () => {
|
||||
'This field cannot be left blank'
|
||||
);
|
||||
});
|
||||
|
||||
cluster.queue({ email, password, componentName });
|
||||
await cluster.idle();
|
||||
await cluster.close();
|
||||
done();
|
||||
},
|
||||
operationTimeOut
|
||||
);
|
||||
|
||||
@@ -57,17 +57,16 @@ describe('Monitor API', () => {
|
||||
'Should create new component',
|
||||
async () => {
|
||||
// Navigate to Components page
|
||||
await page.waitForSelector('#components');
|
||||
await page.click('#components');
|
||||
await page.goto(utils.DASHBOARD_URL);
|
||||
|
||||
// Fill and submit New Component form
|
||||
await page.waitForSelector('#form-new-component');
|
||||
await page.click('input[id=name]');
|
||||
await page.type('input[id=name]', componentName);
|
||||
await page.click('button[type=submit]');
|
||||
await page.goto(utils.DASHBOARD_URL);
|
||||
|
||||
let spanElement;
|
||||
spanElement = await page.waitForSelector(
|
||||
let spanElement = await page.waitForSelector(
|
||||
`#component-title-${componentName}`
|
||||
);
|
||||
spanElement = await spanElement.getProperty('innerText');
|
||||
|
||||
@@ -10,7 +10,7 @@ user.message = 'Test message';
|
||||
|
||||
const puppeteerLaunchConfig = {
|
||||
headless: true,
|
||||
args: ['--no-sandbox', '--disable-setuid-sandbox'],
|
||||
args: ['--proxy-server=', '--no-sandbox', '--disable-setuid-sandbox'],
|
||||
};
|
||||
|
||||
const HOME_URL = process.env.HOME_URL || 'http://localhost:1444';
|
||||
|
||||
Reference in New Issue
Block a user