Add first part of the k6 test adding a subscriber
[MAILPOET-4956]
This commit is contained in:
@ -9,5 +9,9 @@ export const adminUsername = 'admin';
|
|||||||
export const adminPassword = 'password';
|
export const adminPassword = 'password';
|
||||||
export const adminEmail = 'test@test.com';
|
export const adminEmail = 'test@test.com';
|
||||||
|
|
||||||
|
export const firstName = 'John';
|
||||||
|
export const lastName = 'Doe';
|
||||||
|
export const defaultListName = 'Newsletter mailing list';
|
||||||
|
|
||||||
export const thinkTimeMin = '1';
|
export const thinkTimeMin = '1';
|
||||||
export const thinkTimeMax = '4';
|
export const thinkTimeMax = '4';
|
||||||
|
@ -5,6 +5,7 @@ import { newsletterListing } from './tests/newsletter-listing.js';
|
|||||||
import { subscribersListing } from './tests/subscribers-listing.js';
|
import { subscribersListing } from './tests/subscribers-listing.js';
|
||||||
import { settingsBasic } from './tests/settings-basic.js';
|
import { settingsBasic } from './tests/settings-basic.js';
|
||||||
import { subscribersFiltering } from './tests/subscribers-filtering.js';
|
import { subscribersFiltering } from './tests/subscribers-filtering.js';
|
||||||
|
import { subscribersAdding } from './tests/subscribers-adding.js';
|
||||||
import { htmlReport } from 'https://raw.githubusercontent.com/benc-uk/k6-reporter/main/dist/bundle.js';
|
import { htmlReport } from 'https://raw.githubusercontent.com/benc-uk/k6-reporter/main/dist/bundle.js';
|
||||||
import { textSummary } from 'https://jslib.k6.io/k6-summary/0.0.1/index.js';
|
import { textSummary } from 'https://jslib.k6.io/k6-summary/0.0.1/index.js';
|
||||||
import { scenario } from './config.js';
|
import { scenario } from './config.js';
|
||||||
@ -60,6 +61,7 @@ export function pullRequests() {
|
|||||||
subscribersListing();
|
subscribersListing();
|
||||||
settingsBasic();
|
settingsBasic();
|
||||||
subscribersFiltering();
|
subscribersFiltering();
|
||||||
|
subscribersAdding();
|
||||||
}
|
}
|
||||||
|
|
||||||
// All the tests ran for a nightly testing
|
// All the tests ran for a nightly testing
|
||||||
|
85
mailpoet/tests/performance/tests/subscribers-adding.js
Normal file
85
mailpoet/tests/performance/tests/subscribers-adding.js
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
/* eslint-disable no-shadow */
|
||||||
|
/* eslint-disable import/no-unresolved */
|
||||||
|
/* eslint-disable import/no-default-export */
|
||||||
|
/**
|
||||||
|
* External dependencies
|
||||||
|
*/
|
||||||
|
import { sleep, check, group } from 'k6';
|
||||||
|
import { chromium } from 'k6/x/browser';
|
||||||
|
import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.1.0/index.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal dependencies
|
||||||
|
*/
|
||||||
|
import {
|
||||||
|
baseURL,
|
||||||
|
thinkTimeMin,
|
||||||
|
thinkTimeMax,
|
||||||
|
headlessSet,
|
||||||
|
timeoutSet,
|
||||||
|
firstName,
|
||||||
|
lastName,
|
||||||
|
defaultListName,
|
||||||
|
} from '../config.js';
|
||||||
|
import { authenticate, selectInSelect2 } from '../utils/helpers.js';
|
||||||
|
/* global Promise */
|
||||||
|
|
||||||
|
export function subscribersAdding() {
|
||||||
|
const browser = chromium.launch({
|
||||||
|
headless: headlessSet,
|
||||||
|
timeout: timeoutSet,
|
||||||
|
});
|
||||||
|
const page = browser.newPage();
|
||||||
|
|
||||||
|
group('Subscribers - Add a new subscriber', function subscribersAdding() {
|
||||||
|
page
|
||||||
|
.goto(`${baseURL}/wp-admin/admin.php?page=mailpoet-subscribers`, {
|
||||||
|
waitUntil: 'networkidle',
|
||||||
|
})
|
||||||
|
|
||||||
|
.then(() => {
|
||||||
|
authenticate(page);
|
||||||
|
})
|
||||||
|
|
||||||
|
.then(() => {
|
||||||
|
return Promise.all([
|
||||||
|
page.waitForNavigation({ waitUntil: 'networkidle' }),
|
||||||
|
]);
|
||||||
|
})
|
||||||
|
|
||||||
|
.then(() => {
|
||||||
|
page
|
||||||
|
.locator('[data-automation-id="add-new-subscribers-button"]')
|
||||||
|
.click();
|
||||||
|
page
|
||||||
|
.locator('input[name="email"]')
|
||||||
|
.type('test+' + Math.floor(Math.random() * 9999 + 1) + '@test.com');
|
||||||
|
page.locator('input[name="first_name"]').type(firstName);
|
||||||
|
page.locator('input[name="last_name"]').type(lastName);
|
||||||
|
selectInSelect2(page, defaultListName);
|
||||||
|
page.locator('button[type="submit"]').click();
|
||||||
|
page.waitForSelector('.mailpoet-listing-no-items');
|
||||||
|
page.waitForSelector('[data-automation-id="filters_subscribed"]');
|
||||||
|
check(page, {
|
||||||
|
'subscribers filter is visible': page
|
||||||
|
.locator('[data-automation-id="listing_filter_segment"]')
|
||||||
|
.isVisible(),
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
.then(() => {
|
||||||
|
// search for added subscriber
|
||||||
|
})
|
||||||
|
|
||||||
|
.finally(() => {
|
||||||
|
page.close();
|
||||||
|
browser.close();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
sleep(randomIntBetween(thinkTimeMin, thinkTimeMax));
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function subscribersAddingTest() {
|
||||||
|
subscribersAdding();
|
||||||
|
}
|
@ -18,3 +18,11 @@ export function authenticate(page) {
|
|||||||
page.locator('input[name="wp-submit"]').click(),
|
page.locator('input[name="wp-submit"]').click(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Select a segment or a list from a select2 search field
|
||||||
|
export function selectInSelect2(page, listName) {
|
||||||
|
// Click and write a list name from a dropdown
|
||||||
|
page.locator('.select2-selection').click();
|
||||||
|
page.locator('.select2-selection').type(listName);
|
||||||
|
page.keyboard.press('Enter');
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user