@mattermost/loadtest-browser-lib 1.31.0-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/simulation_helpers/landing_page.d.ts +4 -0
- package/dist/simulation_helpers/landing_page.d.ts.map +1 -0
- package/dist/simulation_helpers/landing_page.js +23 -0
- package/dist/simulation_helpers/login_page.d.ts +9 -0
- package/dist/simulation_helpers/login_page.d.ts.map +1 -0
- package/dist/simulation_helpers/login_page.js +19 -0
- package/dist/simulation_helpers/select_team_page.d.ts +11 -0
- package/dist/simulation_helpers/select_team_page.d.ts.map +1 -0
- package/dist/simulation_helpers/select_team_page.js +30 -0
- package/dist/types/log.d.ts +10 -0
- package/dist/types/log.d.ts.map +1 -0
- package/dist/types/log.js +3 -0
- package/dist/types/simulation.d.ts +39 -0
- package/dist/types/simulation.d.ts.map +1 -0
- package/dist/types/simulation.js +13 -0
- package/package.json +42 -0
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { BrowserInstance, SimulationRegistryItem } from './types/simulation.js';
|
|
2
|
+
export type { Logger } from './types/log.js';
|
|
3
|
+
export { SessionState } from './types/simulation.js';
|
|
4
|
+
export { performLogin } from './simulation_helpers/login_page.js';
|
|
5
|
+
export { handleLandingPage } from './simulation_helpers/landing_page.js';
|
|
6
|
+
export { performTeamSelection } from './simulation_helpers/select_team_page.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,YAAY,EAAC,eAAe,EAAE,sBAAsB,EAAC,MAAM,uBAAuB,CAAC;AACnF,YAAY,EAAC,MAAM,EAAC,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AAEnD,OAAO,EAAC,YAAY,EAAC,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAC,iBAAiB,EAAC,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAC,oBAAoB,EAAC,MAAM,0CAA0C,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Copyright (c) 2019-present Mattermost, Inc. All Rights Reserved.
|
|
2
|
+
// See LICENSE.txt for license information.
|
|
3
|
+
export { SessionState } from './types/simulation.js';
|
|
4
|
+
export { performLogin } from './simulation_helpers/login_page.js';
|
|
5
|
+
export { handleLandingPage } from './simulation_helpers/landing_page.js';
|
|
6
|
+
export { performTeamSelection } from './simulation_helpers/select_team_page.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"landing_page.d.ts","sourceRoot":"","sources":["../../src/simulation_helpers/landing_page.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,kBAAkB,CAAC;AAG3C,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,iBAAiB,CAAC;AAE5C,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAsB9E"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright (c) 2019-present Mattermost, Inc. All Rights Reserved.
|
|
2
|
+
// See LICENSE.txt for license information.
|
|
3
|
+
import { LandingLoginPage } from '@mattermost/playwright-lib';
|
|
4
|
+
export async function handleLandingPage(page, log) {
|
|
5
|
+
log.info('run--handleLandingPage');
|
|
6
|
+
try {
|
|
7
|
+
const isLandingPage = await page
|
|
8
|
+
.waitForURL((url) => url.pathname.includes('/landing'))
|
|
9
|
+
.then(() => true)
|
|
10
|
+
.catch(() => false);
|
|
11
|
+
if (!isLandingPage) {
|
|
12
|
+
throw new Error('Not on landing page');
|
|
13
|
+
}
|
|
14
|
+
const landingLoginPage = new LandingLoginPage(page);
|
|
15
|
+
await landingLoginPage.toBeVisible();
|
|
16
|
+
await landingLoginPage.viewInBrowserButton.click();
|
|
17
|
+
log.info('pass--handleLandingPage');
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// If checkbox not found, log and skip
|
|
21
|
+
log.info('skip--handleLandingPage');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Page } from '@playwright/test';
|
|
2
|
+
import type { Logger } from '../types/log.js';
|
|
3
|
+
type ExtraArgs = {
|
|
4
|
+
userId: string;
|
|
5
|
+
password: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function performLogin(page: Page, log: Logger, { userId, password }: ExtraArgs): Promise<void>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=login_page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login_page.d.ts","sourceRoot":"","sources":["../../src/simulation_helpers/login_page.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,kBAAkB,CAAC;AAG3C,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,iBAAiB,CAAC;AAE5C,KAAK,SAAS,GAAG;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,wBAAsB,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,EAAC,MAAM,EAAE,QAAQ,EAAC,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAmBxG"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Copyright (c) 2019-present Mattermost, Inc. All Rights Reserved.
|
|
2
|
+
// See LICENSE.txt for license information.
|
|
3
|
+
import { LoginPage } from '@mattermost/playwright-lib';
|
|
4
|
+
export async function performLogin(page, log, { userId, password }) {
|
|
5
|
+
log.info('run--performLogin');
|
|
6
|
+
try {
|
|
7
|
+
const loginPage = new LoginPage(page);
|
|
8
|
+
await loginPage.toBeVisible();
|
|
9
|
+
await loginPage.loginInput.fill(userId);
|
|
10
|
+
await loginPage.passwordInput.waitFor({ state: 'visible' });
|
|
11
|
+
await loginPage.passwordInput.fill(password);
|
|
12
|
+
await loginPage.signInButton.waitFor({ state: 'visible' });
|
|
13
|
+
await loginPage.signInButton.click();
|
|
14
|
+
log.info('pass--performLogin');
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
throw { error, testId: 'performLogin' };
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Page } from '@playwright/test';
|
|
2
|
+
import type { Logger } from '../types/log.js';
|
|
3
|
+
type ExtraArgs = {
|
|
4
|
+
/**
|
|
5
|
+
* If left empty, the first team in the list will be selected.
|
|
6
|
+
*/
|
|
7
|
+
teamName?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function performTeamSelection(page: Page, log: Logger, { teamName }: ExtraArgs): Promise<void>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=select_team_page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select_team_page.d.ts","sourceRoot":"","sources":["../../src/simulation_helpers/select_team_page.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,kBAAkB,CAAC;AAE3C,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,iBAAiB,CAAC;AAE5C,KAAK,SAAS,GAAG;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAsB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,EAAC,QAAQ,EAAC,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CA+BxG"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Copyright (c) 2019-present Mattermost, Inc. All Rights Reserved.
|
|
2
|
+
// See LICENSE.txt for license information.
|
|
3
|
+
export async function performTeamSelection(page, log, { teamName }) {
|
|
4
|
+
log.info('run--performTeamSelection');
|
|
5
|
+
try {
|
|
6
|
+
const isTeamSelectionPage = await page
|
|
7
|
+
.waitForURL((url) => url.pathname.includes('/select_team'))
|
|
8
|
+
.then(() => true)
|
|
9
|
+
.catch(() => false);
|
|
10
|
+
if (!isTeamSelectionPage) {
|
|
11
|
+
throw new Error('Not on team selection page');
|
|
12
|
+
}
|
|
13
|
+
await page.waitForSelector('.signup-team-dir a');
|
|
14
|
+
let teamIconElement;
|
|
15
|
+
if (teamName) {
|
|
16
|
+
teamIconElement = page.locator('.signup-team-dir a').filter({
|
|
17
|
+
has: page.locator('.signup-team-dir__name', { hasText: teamName }),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
teamIconElement = page.locator('.signup-team-dir a').first();
|
|
22
|
+
}
|
|
23
|
+
await teamIconElement.click();
|
|
24
|
+
await page.waitForURL((url) => !url.pathname.includes('/select_team'));
|
|
25
|
+
log.info('pass--performTeamSelection');
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
log.info('skip--performTeamSelection');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/types/log.ts"],"names":[],"mappings":"AAGA,UAAU,QAAQ;IAChB,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;CAC9C;AAED,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,QAAQ,CAAC;IAChB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;CAChB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Browser, BrowserContext, Page } from '@playwright/test';
|
|
2
|
+
import type { Logger } from './log.js';
|
|
3
|
+
export declare enum SessionState {
|
|
4
|
+
CREATING = "creating",// The browser and other instances are being created
|
|
5
|
+
CREATION_FAILED = "creation_failed",// The browser or any other instances failed to be created
|
|
6
|
+
CREATED = "created",// The browser and other instances were created successfully
|
|
7
|
+
STARTED = "started",// The test was started
|
|
8
|
+
STOPPING = "stopping",// The test was stopped by the user
|
|
9
|
+
COMPLETED = "completed",// The test was completed successfully
|
|
10
|
+
FAILED = "failed",// The test failed at any point
|
|
11
|
+
CLEANUP_FAILED = "cleanup_failed"
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Browser instance containing a Playwright page and user credentials.
|
|
15
|
+
* This is the base interface that simulation scenarios receive.
|
|
16
|
+
*/
|
|
17
|
+
export type BrowserInstance = {
|
|
18
|
+
browser: Browser | null;
|
|
19
|
+
context: BrowserContext | null;
|
|
20
|
+
page: Page | null;
|
|
21
|
+
userId: string;
|
|
22
|
+
password: string;
|
|
23
|
+
createdAt: Date;
|
|
24
|
+
state: SessionState;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Registry item type for a browser simulation scenario.
|
|
28
|
+
*/
|
|
29
|
+
export interface SimulationRegistryItem {
|
|
30
|
+
/** Unique identifier for the simulation */
|
|
31
|
+
id: string;
|
|
32
|
+
/** Human-readable name for the simulation */
|
|
33
|
+
name?: string;
|
|
34
|
+
/** Description of what the simulation does */
|
|
35
|
+
description?: string;
|
|
36
|
+
/** The scenario function to execute */
|
|
37
|
+
scenario: (browserInstance: BrowserInstance, serverURL: string, logger: Logger, runInLoop?: boolean) => Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=simulation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simulation.d.ts","sourceRoot":"","sources":["../../src/types/simulation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,OAAO,EAAE,cAAc,EAAE,IAAI,EAAC,MAAM,kBAAkB,CAAC;AAEpE,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAErC,oBAAY,YAAY;IACtB,QAAQ,aAAa,CAAE,oDAAoD;IAC3E,eAAe,oBAAoB,CAAE,0DAA0D;IAC/F,OAAO,YAAY,CAAE,4DAA4D;IACjF,OAAO,YAAY,CAAE,uBAAuB;IAC5C,QAAQ,aAAa,CAAE,mCAAmC;IAC1D,SAAS,cAAc,CAAE,sCAAsC;IAC/D,MAAM,WAAW,CAAE,+BAA+B;IAClD,cAAc,mBAAmB;CAClC;AAED;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,IAAI,CAAC;IAChB,KAAK,EAAE,YAAY,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,2CAA2C;IAC3C,EAAE,EAAE,MAAM,CAAC;IACX,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uCAAuC;IACvC,QAAQ,EAAE,CAAC,eAAe,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvH"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Copyright (c) 2019-present Mattermost, Inc. All Rights Reserved.
|
|
2
|
+
// See LICENSE.txt for license information.
|
|
3
|
+
export var SessionState;
|
|
4
|
+
(function (SessionState) {
|
|
5
|
+
SessionState["CREATING"] = "creating";
|
|
6
|
+
SessionState["CREATION_FAILED"] = "creation_failed";
|
|
7
|
+
SessionState["CREATED"] = "created";
|
|
8
|
+
SessionState["STARTED"] = "started";
|
|
9
|
+
SessionState["STOPPING"] = "stopping";
|
|
10
|
+
SessionState["COMPLETED"] = "completed";
|
|
11
|
+
SessionState["FAILED"] = "failed";
|
|
12
|
+
SessionState["CLEANUP_FAILED"] = "cleanup_failed";
|
|
13
|
+
})(SessionState || (SessionState = {}));
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mattermost/loadtest-browser-lib",
|
|
3
|
+
"version": "1.31.0-0",
|
|
4
|
+
"description": "Shared types, helpers and utilities for Mattermost browser-based load testing simulations using Playwright",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/mattermost/mattermost-load-test-ng.git"
|
|
8
|
+
},
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/mattermost/mattermost-load-test-ng/issues"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/mattermost/mattermost-load-test-ng/tree/master/browser/src/lib#readme",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "dist/index.js",
|
|
15
|
+
"types": "dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=20 || >=22 || >=24",
|
|
30
|
+
"npm": ">=10 || >=11"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"prepare": "tsc"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@mattermost/playwright-lib": "11.4.0-0",
|
|
37
|
+
"@playwright/test": "^1.57.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"typescript": "^5.9.3"
|
|
41
|
+
}
|
|
42
|
+
}
|