const { journey, step, monitor, expect } = require('@elastic/synthetics');
journey('Recorded Journey', async ({ page, params, context }) => {
monitor.use({
id: 'mema_test_cli3', // Should match $KEY
schedule: 10, // Frequency in minutes (should match $FREQUENCY)
});
step('Login', async () => {
await page.goto(${params.baseUrl}/account/login?ReturnUrl=%2F
, { waitUntil: 'networkidle' });
await page.getByPlaceholder('Type your username.').click();
await page.getByPlaceholder('Type your username.').fill(params.elastic_user);
await page.getByPlaceholder('Type your password.').click();
await page.getByPlaceholder('Type your password.').fill(params.elastic_pass);
});
step('Click internal:role=button[name="Sign In"i]', async () => {
await page.getByRole('button', { name: 'Sign In' }).click();
await page.waitForLoadState('networkidle', { timeout: 10000 });
await page.waitForTimeout(2000);
});
step('Home Page', async () => {
await page.getByRole('link', { name: 'Home' }).click();
await page.waitForLoadState('networkidle', { timeout: 10000 });
await page.waitForSelector('body', { state: 'visible', timeout: 10000 });
await page.waitForTimeout(2000);
expect(await page.title()).not.toBe('');
});
step('Events Page', async () => {
await page.goto(${params.baseUrl}/Events.php
, { waitUntil: 'networkidle' });
await page.waitForLoadState('networkidle', { timeout: 10000 });
await page.waitForSelector('body', { state: 'visible', timeout: 10000 });
await page.waitForTimeout(2000);
expect(await page.title()).not.toBe('');
});
step('Archives Page', async () => {
await page.getByRole('link', { name: 'Archives' }).click();
await page.waitForLoadState('networkidle', { timeout: 10000 });
await page.waitForSelector('body', { state: 'visible', timeout: 10000 });
await page.waitForTimeout(2000);
expect(await page.title()).not.toBe('');
});
step('Reports Page', async () => {
await page.getByRole('link', { name: 'Reports' }).click();
await page.waitForLoadState('networkidle', { timeout: 10000 });
await page.waitForSelector('body', { state: 'visible', timeout: 10000 });
await page.waitForTimeout(2000);
expect(await page.title()).not.toBe('');
});
step('Admin Page', async () => {
await page.goto(${params.baseUrl}/Cameras.php
, { waitUntil: 'networkidle' });
await page.waitForLoadState('networkidle', { timeout: 10000 });
await page.waitForSelector('body', { state: 'visible', timeout: 10000 });
await page.waitForTimeout(2000);
expect(await page.title()).not.toBe('');
});
step('Logout', async () => {
await page.getByRole('link', { name: 'elastic synthetic' }).click();
await page.getByRole('link', { name: 'Sign Out' }).click();
await page.frameLocator('iframe[name="mainContent"]').getByRole('link', { name: 'Yes' }).click();
await page.waitForLoadState('networkidle', { timeout: 10000 });
await page.waitForTimeout(2000);
});
module.exports = journey;
});