@mattermost/playwright-lib 10.6.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 +214 -0
- package/dist/asset/mattermost-icon_128x128.png +0 -0
- package/dist/browser_context.d.ts +17 -0
- package/dist/browser_context.js +71 -0
- package/dist/browser_context.js.map +1 -0
- package/dist/constant.d.ts +3 -0
- package/dist/constant.js +8 -0
- package/dist/constant.js.map +1 -0
- package/dist/file.d.ts +42 -0
- package/dist/file.js +74 -0
- package/dist/file.js.map +1 -0
- package/dist/flag.d.ts +7 -0
- package/dist/flag.js +76 -0
- package/dist/flag.js.map +1 -0
- package/dist/global_setup.d.ts +3 -0
- package/dist/global_setup.js +173 -0
- package/dist/global_setup.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/mock_browser_api.d.ts +31 -0
- package/dist/mock_browser_api.js +71 -0
- package/dist/mock_browser_api.js.map +1 -0
- package/dist/server/channel.d.ts +12 -0
- package/dist/server/channel.js +25 -0
- package/dist/server/channel.js.map +1 -0
- package/dist/server/client.d.ts +16 -0
- package/dist/server/client.js +39 -0
- package/dist/server/client.js.map +1 -0
- package/dist/server/default_config.d.ts +2 -0
- package/dist/server/default_config.js +755 -0
- package/dist/server/default_config.js.map +1 -0
- package/dist/server/index.d.ts +7 -0
- package/dist/server/init.d.ts +23 -0
- package/dist/server/init.js +73 -0
- package/dist/server/init.js.map +1 -0
- package/dist/server/post.d.ts +2 -0
- package/dist/server/post.js +31 -0
- package/dist/server/post.js.map +1 -0
- package/dist/server/team.d.ts +2 -0
- package/dist/server/team.js +18 -0
- package/dist/server/team.js.map +1 -0
- package/dist/server/user.d.ts +3 -0
- package/dist/server/user.js +33 -0
- package/dist/server/user.js.map +1 -0
- package/dist/test_action.d.ts +4 -0
- package/dist/test_action.js +24 -0
- package/dist/test_action.js.map +1 -0
- package/dist/test_config.d.ts +20 -0
- package/dist/test_config.js +82 -0
- package/dist/test_config.js.map +1 -0
- package/dist/test_fixture.d.ts +72 -0
- package/dist/test_fixture.js +172 -0
- package/dist/test_fixture.js.map +1 -0
- package/dist/types.d.ts +91 -0
- package/dist/ui/components/channels/app_bar.d.ts +7 -0
- package/dist/ui/components/channels/app_bar.js +20 -0
- package/dist/ui/components/channels/app_bar.js.map +1 -0
- package/dist/ui/components/channels/center_view.d.ts +52 -0
- package/dist/ui/components/channels/center_view.js +124 -0
- package/dist/ui/components/channels/center_view.js.map +1 -0
- package/dist/ui/components/channels/delete_post_confirmation_dialog.d.ts +11 -0
- package/dist/ui/components/channels/delete_post_confirmation_dialog.js +35 -0
- package/dist/ui/components/channels/delete_post_confirmation_dialog.js.map +1 -0
- package/dist/ui/components/channels/delete_post_modal.d.ts +8 -0
- package/dist/ui/components/channels/delete_post_modal.js +26 -0
- package/dist/ui/components/channels/delete_post_modal.js.map +1 -0
- package/dist/ui/components/channels/emoji_gif_picker.d.ts +16 -0
- package/dist/ui/components/channels/emoji_gif_picker.js +50 -0
- package/dist/ui/components/channels/emoji_gif_picker.js.map +1 -0
- package/dist/ui/components/channels/find_channels_modal.d.ts +8 -0
- package/dist/ui/components/channels/find_channels_modal.js +22 -0
- package/dist/ui/components/channels/find_channels_modal.js.map +1 -0
- package/dist/ui/components/channels/generic_confirm_modal.d.ts +16 -0
- package/dist/ui/components/channels/generic_confirm_modal.js +40 -0
- package/dist/ui/components/channels/generic_confirm_modal.js.map +1 -0
- package/dist/ui/components/channels/header.d.ts +6 -0
- package/dist/ui/components/channels/header.js +18 -0
- package/dist/ui/components/channels/header.js.map +1 -0
- package/dist/ui/components/channels/message_priority.d.ts +18 -0
- package/dist/ui/components/channels/message_priority.js +66 -0
- package/dist/ui/components/channels/message_priority.js.map +1 -0
- package/dist/ui/components/channels/post.d.ts +29 -0
- package/dist/ui/components/channels/post.js +63 -0
- package/dist/ui/components/channels/post.js.map +1 -0
- package/dist/ui/components/channels/post_create.d.ts +41 -0
- package/dist/ui/components/channels/post_create.js +118 -0
- package/dist/ui/components/channels/post_create.js.map +1 -0
- package/dist/ui/components/channels/post_dot_menu.d.ts +20 -0
- package/dist/ui/components/channels/post_dot_menu.js +47 -0
- package/dist/ui/components/channels/post_dot_menu.js.map +1 -0
- package/dist/ui/components/channels/post_edit.d.ts +21 -0
- package/dist/ui/components/channels/post_edit.js +76 -0
- package/dist/ui/components/channels/post_edit.js.map +1 -0
- package/dist/ui/components/channels/post_menu.d.ts +26 -0
- package/dist/ui/components/channels/post_menu.js +54 -0
- package/dist/ui/components/channels/post_menu.js.map +1 -0
- package/dist/ui/components/channels/post_reminder_menu.d.ts +11 -0
- package/dist/ui/components/channels/post_reminder_menu.js +29 -0
- package/dist/ui/components/channels/post_reminder_menu.js.map +1 -0
- package/dist/ui/components/channels/restore_post_confirmation_dialog.d.ts +10 -0
- package/dist/ui/components/channels/restore_post_confirmation_dialog.js +30 -0
- package/dist/ui/components/channels/restore_post_confirmation_dialog.js.map +1 -0
- package/dist/ui/components/channels/scheduled_draft_menu.d.ts +8 -0
- package/dist/ui/components/channels/scheduled_draft_menu.js +23 -0
- package/dist/ui/components/channels/scheduled_draft_menu.js.map +1 -0
- package/dist/ui/components/channels/scheduled_draft_modal.d.ts +20 -0
- package/dist/ui/components/channels/scheduled_draft_modal.js +84 -0
- package/dist/ui/components/channels/scheduled_draft_modal.js.map +1 -0
- package/dist/ui/components/channels/search_popover.d.ts +15 -0
- package/dist/ui/components/channels/search_popover.js +43 -0
- package/dist/ui/components/channels/search_popover.js.map +1 -0
- package/dist/ui/components/channels/settings/notification_settings.d.ts +13 -0
- package/dist/ui/components/channels/settings/notification_settings.js +41 -0
- package/dist/ui/components/channels/settings/notification_settings.js.map +1 -0
- package/dist/ui/components/channels/settings/settings_modal.d.ts +11 -0
- package/dist/ui/components/channels/settings/settings_modal.js +32 -0
- package/dist/ui/components/channels/settings/settings_modal.js.map +1 -0
- package/dist/ui/components/channels/sidebar_left.d.ts +24 -0
- package/dist/ui/components/channels/sidebar_left.js +54 -0
- package/dist/ui/components/channels/sidebar_left.js.map +1 -0
- package/dist/ui/components/channels/sidebar_right.d.ts +38 -0
- package/dist/ui/components/channels/sidebar_right.js +87 -0
- package/dist/ui/components/channels/sidebar_right.js.map +1 -0
- package/dist/ui/components/channels/thread_footer.d.ts +11 -0
- package/dist/ui/components/channels/thread_footer.js +27 -0
- package/dist/ui/components/channels/thread_footer.js.map +1 -0
- package/dist/ui/components/channels/user_profile_popover.d.ts +7 -0
- package/dist/ui/components/channels/user_profile_popover.js +21 -0
- package/dist/ui/components/channels/user_profile_popover.js.map +1 -0
- package/dist/ui/components/footer.d.ts +11 -0
- package/dist/ui/components/footer.js +28 -0
- package/dist/ui/components/footer.js.map +1 -0
- package/dist/ui/components/global_header.d.ts +15 -0
- package/dist/ui/components/global_header.js +46 -0
- package/dist/ui/components/global_header.js.map +1 -0
- package/dist/ui/components/index.d.ts +73 -0
- package/dist/ui/components/index.js +77 -0
- package/dist/ui/components/index.js.map +1 -0
- package/dist/ui/components/main_header.d.ts +8 -0
- package/dist/ui/components/main_header.js +22 -0
- package/dist/ui/components/main_header.js.map +1 -0
- package/dist/ui/components/system_console/navbar.d.ts +6 -0
- package/dist/ui/components/system_console/navbar.js +18 -0
- package/dist/ui/components/system_console/navbar.js.map +1 -0
- package/dist/ui/components/system_console/sections/system_users/column_toggle_menu.d.ts +22 -0
- package/dist/ui/components/system_console/sections/system_users/column_toggle_menu.js +47 -0
- package/dist/ui/components/system_console/sections/system_users/column_toggle_menu.js.map +1 -0
- package/dist/ui/components/system_console/sections/system_users/feature_discovery.d.ts +10 -0
- package/dist/ui/components/system_console/sections/system_users/feature_discovery.js +24 -0
- package/dist/ui/components/system_console/sections/system_users/feature_discovery.js.map +1 -0
- package/dist/ui/components/system_console/sections/system_users/filter_menu.d.ts +21 -0
- package/dist/ui/components/system_console/sections/system_users/filter_menu.js +42 -0
- package/dist/ui/components/system_console/sections/system_users/filter_menu.js.map +1 -0
- package/dist/ui/components/system_console/sections/system_users/filter_popover.d.ts +30 -0
- package/dist/ui/components/system_console/sections/system_users/filter_popover.js +61 -0
- package/dist/ui/components/system_console/sections/system_users/filter_popover.js.map +1 -0
- package/dist/ui/components/system_console/sections/system_users/mobile_security.d.ts +23 -0
- package/dist/ui/components/system_console/sections/system_users/mobile_security.js +56 -0
- package/dist/ui/components/system_console/sections/system_users/mobile_security.js.map +1 -0
- package/dist/ui/components/system_console/sections/system_users/system_users.d.ts +58 -0
- package/dist/ui/components/system_console/sections/system_users/system_users.js +114 -0
- package/dist/ui/components/system_console/sections/system_users/system_users.js.map +1 -0
- package/dist/ui/components/system_console/sidebar.d.ts +17 -0
- package/dist/ui/components/system_console/sidebar.js +37 -0
- package/dist/ui/components/system_console/sidebar.js.map +1 -0
- package/dist/ui/pages/channels.d.ts +31 -0
- package/dist/ui/pages/channels.js +79 -0
- package/dist/ui/pages/channels.js.map +1 -0
- package/dist/ui/pages/drafts.d.ts +30 -0
- package/dist/ui/pages/drafts.js +114 -0
- package/dist/ui/pages/drafts.js.map +1 -0
- package/dist/ui/pages/index.d.ts +19 -0
- package/dist/ui/pages/index.js +34 -0
- package/dist/ui/pages/index.js.map +1 -0
- package/dist/ui/pages/landing_login.d.ts +11 -0
- package/dist/ui/pages/landing_login.js +36 -0
- package/dist/ui/pages/landing_login.js.map +1 -0
- package/dist/ui/pages/login.d.ts +25 -0
- package/dist/ui/pages/login.js +62 -0
- package/dist/ui/pages/login.js.map +1 -0
- package/dist/ui/pages/reset_password.d.ts +15 -0
- package/dist/ui/pages/reset_password.js +44 -0
- package/dist/ui/pages/reset_password.js.map +1 -0
- package/dist/ui/pages/scheduled_draft.d.ts +38 -0
- package/dist/ui/pages/scheduled_draft.js +144 -0
- package/dist/ui/pages/scheduled_draft.js.map +1 -0
- package/dist/ui/pages/signup.d.ts +31 -0
- package/dist/ui/pages/signup.js +78 -0
- package/dist/ui/pages/signup.js.map +1 -0
- package/dist/ui/pages/system_console.d.ts +26 -0
- package/dist/ui/pages/system_console.js +64 -0
- package/dist/ui/pages/system_console.js.map +1 -0
- package/dist/util.d.ts +29 -0
- package/dist/util.js +51 -0
- package/dist/util.js.map +1 -0
- package/dist/visual/index.d.ts +3 -0
- package/dist/visual/index.js +37 -0
- package/dist/visual/index.js.map +1 -0
- package/dist/visual/percy.d.ts +2 -0
- package/dist/visual/percy.js +23 -0
- package/dist/visual/percy.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var test = require('@playwright/test');
|
|
4
|
+
var client = require('@mattermost/client');
|
|
5
|
+
var util = require('./util.js');
|
|
6
|
+
var client$1 = require('./server/client.js');
|
|
7
|
+
require('./server/default_config.js');
|
|
8
|
+
var init = require('./server/init.js');
|
|
9
|
+
var team = require('./server/team.js');
|
|
10
|
+
var user = require('./server/user.js');
|
|
11
|
+
var test_config = require('./test_config.js');
|
|
12
|
+
|
|
13
|
+
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
14
|
+
// See LICENSE.txt for license information.
|
|
15
|
+
async function baseGlobalSetup() {
|
|
16
|
+
let adminClient;
|
|
17
|
+
let adminUser;
|
|
18
|
+
({ adminClient, adminUser } = await init.getAdminClient({ skipLog: true }));
|
|
19
|
+
if (!adminUser) {
|
|
20
|
+
const firstClient = new client.Client4();
|
|
21
|
+
firstClient.setUrl(test_config.testConfig.baseURL);
|
|
22
|
+
const defaultAdmin = user.getDefaultAdminUser();
|
|
23
|
+
await firstClient.createUser(defaultAdmin, '', '');
|
|
24
|
+
({ client: adminClient, user: adminUser } = await client$1.makeClient(defaultAdmin));
|
|
25
|
+
}
|
|
26
|
+
await sysadminSetup(adminClient, adminUser);
|
|
27
|
+
}
|
|
28
|
+
async function sysadminSetup(client, user) {
|
|
29
|
+
// Ensure admin's email is verified.
|
|
30
|
+
if (!user) {
|
|
31
|
+
await client.verifyUserEmail(client.token);
|
|
32
|
+
}
|
|
33
|
+
// Log license and config info
|
|
34
|
+
await printLicenseInfo(client);
|
|
35
|
+
await printClientInfo(client);
|
|
36
|
+
// Create default team if not present.
|
|
37
|
+
// Otherwise, create other teams and channels other than the default team cna channels (town-square and off-topic).
|
|
38
|
+
const myTeams = await client.getMyTeams();
|
|
39
|
+
const myDefaultTeam = myTeams && myTeams.length > 0 && myTeams.find((team) => team.name === util.defaultTeam.name);
|
|
40
|
+
if (!myDefaultTeam) {
|
|
41
|
+
await client.createTeam(team.createRandomTeam(util.defaultTeam.name, util.defaultTeam.displayName, 'O', false));
|
|
42
|
+
}
|
|
43
|
+
else if (myDefaultTeam && test_config.testConfig.resetBeforeTest) {
|
|
44
|
+
await Promise.all(myTeams.filter((team) => team.name !== util.defaultTeam.name).map((team) => client.deleteTeam(team.id)));
|
|
45
|
+
const myChannels = await client.getMyChannels(myDefaultTeam.id);
|
|
46
|
+
await Promise.all(myChannels
|
|
47
|
+
.filter((channel) => {
|
|
48
|
+
return (channel.team_id === myDefaultTeam.id &&
|
|
49
|
+
channel.name !== 'town-square' &&
|
|
50
|
+
channel.name !== 'off-topic');
|
|
51
|
+
})
|
|
52
|
+
.map((channel) => client.deleteChannel(channel.id)));
|
|
53
|
+
}
|
|
54
|
+
// Set default preferences
|
|
55
|
+
await savePreferences(client, user?.id ?? '');
|
|
56
|
+
// Ensure all products as plugin are installed and active.
|
|
57
|
+
await ensurePluginsLoaded(client);
|
|
58
|
+
// Log plugin details
|
|
59
|
+
await printPluginDetails(client);
|
|
60
|
+
// Ensure server deployment type is as expected
|
|
61
|
+
await ensureServerDeployment(client);
|
|
62
|
+
}
|
|
63
|
+
async function printLicenseInfo(client) {
|
|
64
|
+
const license = await client.getClientLicenseOld();
|
|
65
|
+
// eslint-disable-next-line no-console
|
|
66
|
+
console.log(`Server License:
|
|
67
|
+
- IsLicensed = ${license.IsLicensed}
|
|
68
|
+
- IsTrial = ${license.IsTrial}
|
|
69
|
+
- SkuName = ${license.SkuName}
|
|
70
|
+
- SkuShortName = ${license.SkuShortName}
|
|
71
|
+
- Cloud = ${license.Cloud}
|
|
72
|
+
- Users = ${license.Users}`);
|
|
73
|
+
}
|
|
74
|
+
async function printClientInfo(client) {
|
|
75
|
+
const config = await client.getClientConfigOld();
|
|
76
|
+
// eslint-disable-next-line no-console
|
|
77
|
+
console.log(`Build Info:
|
|
78
|
+
- BuildNumber = ${config.BuildNumber}
|
|
79
|
+
- BuildDate = ${config.BuildDate}
|
|
80
|
+
- Version = ${config.Version}
|
|
81
|
+
- BuildHash = ${config.BuildHash}
|
|
82
|
+
- BuildHashEnterprise = ${config.BuildHashEnterprise}
|
|
83
|
+
- BuildEnterpriseReady = ${config.BuildEnterpriseReady}
|
|
84
|
+
- TelemetryId = ${config.TelemetryId}
|
|
85
|
+
- ServiceEnvironment = ${config.ServiceEnvironment}`);
|
|
86
|
+
const { LogSettings, ServiceSettings } = await client.getConfig();
|
|
87
|
+
// eslint-disable-next-line no-console
|
|
88
|
+
console.log(`Notable Server Config:
|
|
89
|
+
- ServiceSettings.EnableSecurityFixAlert = ${ServiceSettings?.EnableSecurityFixAlert}
|
|
90
|
+
- LogSettings.EnableDiagnostics = ${LogSettings?.EnableDiagnostics}`);
|
|
91
|
+
}
|
|
92
|
+
async function ensurePluginsLoaded(client) {
|
|
93
|
+
const pluginStatus = await client.getPluginStatuses();
|
|
94
|
+
const plugins = await client.getPlugins();
|
|
95
|
+
test_config.testConfig.ensurePluginsInstalled.forEach(async (pluginId) => {
|
|
96
|
+
const isInstalled = pluginStatus.some((plugin) => plugin.plugin_id === pluginId);
|
|
97
|
+
if (!isInstalled) {
|
|
98
|
+
// eslint-disable-next-line no-console
|
|
99
|
+
console.log(`${pluginId} is not installed. Related visual test will fail.`);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const isActive = plugins.active.some((plugin) => plugin.id === pluginId);
|
|
103
|
+
if (!isActive) {
|
|
104
|
+
await client.enablePlugin(pluginId);
|
|
105
|
+
// eslint-disable-next-line no-console
|
|
106
|
+
console.log(`${pluginId} is installed and has been activated.`);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
// eslint-disable-next-line no-console
|
|
110
|
+
console.log(`${pluginId} is installed and active.`);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
async function printPluginDetails(client) {
|
|
115
|
+
const plugins = await client.getPlugins();
|
|
116
|
+
if (plugins.active.length) {
|
|
117
|
+
// eslint-disable-next-line no-console
|
|
118
|
+
console.log('Active plugins:');
|
|
119
|
+
}
|
|
120
|
+
plugins.active.forEach((plugin) => {
|
|
121
|
+
// eslint-disable-next-line no-console
|
|
122
|
+
console.log(` - ${plugin.id}@${plugin.version} | min_server@${plugin.min_server_version}`);
|
|
123
|
+
});
|
|
124
|
+
if (plugins.inactive.length) {
|
|
125
|
+
// eslint-disable-next-line no-console
|
|
126
|
+
console.log('Inactive plugins:');
|
|
127
|
+
}
|
|
128
|
+
plugins.inactive.forEach((plugin) => {
|
|
129
|
+
// eslint-disable-next-line no-console
|
|
130
|
+
console.log(` - ${plugin.id}@${plugin.version} | min_server@${plugin.min_server_version}`);
|
|
131
|
+
});
|
|
132
|
+
// eslint-disable-next-line no-console
|
|
133
|
+
console.log('');
|
|
134
|
+
}
|
|
135
|
+
async function ensureServerDeployment(client) {
|
|
136
|
+
if (test_config.testConfig.haClusterEnabled) {
|
|
137
|
+
const { haClusterNodeCount, haClusterName } = test_config.testConfig;
|
|
138
|
+
const { Enable, ClusterName } = (await client.getConfig()).ClusterSettings;
|
|
139
|
+
test.expect(Enable, Enable ? '' : 'Should have cluster enabled').toBe(true);
|
|
140
|
+
const sameClusterName = ClusterName === haClusterName;
|
|
141
|
+
test.expect(sameClusterName, sameClusterName
|
|
142
|
+
? ''
|
|
143
|
+
: `Should have cluster name set and as expected. Got "${ClusterName}" but expected "${haClusterName}"`).toBe(true);
|
|
144
|
+
const clusterInfo = await client.getClusterStatus();
|
|
145
|
+
const sameCount = clusterInfo?.length === haClusterNodeCount;
|
|
146
|
+
test.expect(sameCount, sameCount
|
|
147
|
+
? ''
|
|
148
|
+
: `Should match number of nodes in a cluster as expected. Got "${clusterInfo?.length}" but expected "${haClusterNodeCount}"`).toBe(true);
|
|
149
|
+
clusterInfo.forEach((info) =>
|
|
150
|
+
// eslint-disable-next-line no-console
|
|
151
|
+
console.log(`hostname: ${info.hostname}, version: ${info.version}, config_hash: ${info.config_hash}`));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async function savePreferences(client, userId) {
|
|
155
|
+
try {
|
|
156
|
+
if (!userId) {
|
|
157
|
+
throw new Error('userId is not defined');
|
|
158
|
+
}
|
|
159
|
+
const preferences = [
|
|
160
|
+
{ user_id: userId, category: 'tutorial_step', name: userId, value: '999' },
|
|
161
|
+
{ user_id: userId, category: 'crt_thread_pane_step', name: userId, value: '999' },
|
|
162
|
+
];
|
|
163
|
+
await client.savePreferences(userId, preferences);
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
// eslint-disable-next-line no-console
|
|
167
|
+
console.log('Error saving preferences', error);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
exports.baseGlobalSetup = baseGlobalSetup;
|
|
172
|
+
exports.ensurePluginsLoaded = ensurePluginsLoaded;
|
|
173
|
+
//# sourceMappingURL=global_setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global_setup.js","sources":["../src/global_setup.ts"],"sourcesContent":["// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.\n// See LICENSE.txt for license information.\n\nimport {expect} from '@playwright/test';\nimport {Client4} from '@mattermost/client';\nimport {UserProfile} from '@mattermost/types/users';\nimport {PluginManifest} from '@mattermost/types/plugins';\nimport {PreferenceType} from '@mattermost/types/preferences';\n\nimport {defaultTeam} from './util';\nimport {createRandomTeam, getAdminClient, getDefaultAdminUser, makeClient} from './server';\nimport {testConfig} from './test_config';\n\nexport async function baseGlobalSetup() {\n let adminClient: Client4;\n let adminUser: UserProfile | null;\n ({adminClient, adminUser} = await getAdminClient({skipLog: true}));\n\n if (!adminUser) {\n const firstClient = new Client4();\n firstClient.setUrl(testConfig.baseURL);\n const defaultAdmin = getDefaultAdminUser();\n await firstClient.createUser(defaultAdmin, '', '');\n\n ({client: adminClient, user: adminUser} = await makeClient(defaultAdmin));\n }\n\n await sysadminSetup(adminClient, adminUser);\n}\n\nasync function sysadminSetup(client: Client4, user: UserProfile | null) {\n // Ensure admin's email is verified.\n if (!user) {\n await client.verifyUserEmail(client.token);\n }\n\n // Log license and config info\n await printLicenseInfo(client);\n await printClientInfo(client);\n\n // Create default team if not present.\n // Otherwise, create other teams and channels other than the default team cna channels (town-square and off-topic).\n const myTeams = await client.getMyTeams();\n const myDefaultTeam = myTeams && myTeams.length > 0 && myTeams.find((team) => team.name === defaultTeam.name);\n if (!myDefaultTeam) {\n await client.createTeam(createRandomTeam(defaultTeam.name, defaultTeam.displayName, 'O', false));\n } else if (myDefaultTeam && testConfig.resetBeforeTest) {\n await Promise.all(\n myTeams.filter((team) => team.name !== defaultTeam.name).map((team) => client.deleteTeam(team.id)),\n );\n\n const myChannels = await client.getMyChannels(myDefaultTeam.id);\n await Promise.all(\n myChannels\n .filter((channel) => {\n return (\n channel.team_id === myDefaultTeam.id &&\n channel.name !== 'town-square' &&\n channel.name !== 'off-topic'\n );\n })\n .map((channel) => client.deleteChannel(channel.id)),\n );\n }\n\n // Set default preferences\n await savePreferences(client, user?.id ?? '');\n\n // Ensure all products as plugin are installed and active.\n await ensurePluginsLoaded(client);\n\n // Log plugin details\n await printPluginDetails(client);\n\n // Ensure server deployment type is as expected\n await ensureServerDeployment(client);\n}\n\nasync function printLicenseInfo(client: Client4) {\n const license = await client.getClientLicenseOld();\n // eslint-disable-next-line no-console\n console.log(`Server License:\n - IsLicensed = ${license.IsLicensed}\n - IsTrial = ${license.IsTrial}\n - SkuName = ${license.SkuName}\n - SkuShortName = ${license.SkuShortName}\n - Cloud = ${license.Cloud}\n - Users = ${license.Users}`);\n}\n\nasync function printClientInfo(client: Client4) {\n const config = await client.getClientConfigOld();\n // eslint-disable-next-line no-console\n console.log(`Build Info:\n - BuildNumber = ${config.BuildNumber}\n - BuildDate = ${config.BuildDate}\n - Version = ${config.Version}\n - BuildHash = ${config.BuildHash}\n - BuildHashEnterprise = ${config.BuildHashEnterprise}\n - BuildEnterpriseReady = ${config.BuildEnterpriseReady}\n - TelemetryId = ${config.TelemetryId}\n - ServiceEnvironment = ${config.ServiceEnvironment}`);\n\n const {LogSettings, ServiceSettings} = await client.getConfig();\n // eslint-disable-next-line no-console\n console.log(`Notable Server Config:\n - ServiceSettings.EnableSecurityFixAlert = ${ServiceSettings?.EnableSecurityFixAlert}\n - LogSettings.EnableDiagnostics = ${LogSettings?.EnableDiagnostics}`);\n}\n\nexport async function ensurePluginsLoaded(client: Client4) {\n const pluginStatus = await client.getPluginStatuses();\n const plugins = await client.getPlugins();\n\n testConfig.ensurePluginsInstalled.forEach(async (pluginId) => {\n const isInstalled = pluginStatus.some((plugin) => plugin.plugin_id === pluginId);\n if (!isInstalled) {\n // eslint-disable-next-line no-console\n console.log(`${pluginId} is not installed. Related visual test will fail.`);\n return;\n }\n\n const isActive = plugins.active.some((plugin: PluginManifest) => plugin.id === pluginId);\n if (!isActive) {\n await client.enablePlugin(pluginId);\n\n // eslint-disable-next-line no-console\n console.log(`${pluginId} is installed and has been activated.`);\n } else {\n // eslint-disable-next-line no-console\n console.log(`${pluginId} is installed and active.`);\n }\n });\n}\n\nasync function printPluginDetails(client: Client4) {\n const plugins = await client.getPlugins();\n\n if (plugins.active.length) {\n // eslint-disable-next-line no-console\n console.log('Active plugins:');\n }\n\n plugins.active.forEach((plugin: PluginManifest) => {\n // eslint-disable-next-line no-console\n console.log(` - ${plugin.id}@${plugin.version} | min_server@${plugin.min_server_version}`);\n });\n\n if (plugins.inactive.length) {\n // eslint-disable-next-line no-console\n console.log('Inactive plugins:');\n }\n\n plugins.inactive.forEach((plugin: PluginManifest) => {\n // eslint-disable-next-line no-console\n console.log(` - ${plugin.id}@${plugin.version} | min_server@${plugin.min_server_version}`);\n });\n\n // eslint-disable-next-line no-console\n console.log('');\n}\n\nasync function ensureServerDeployment(client: Client4) {\n if (testConfig.haClusterEnabled) {\n const {haClusterNodeCount, haClusterName} = testConfig;\n\n const {Enable, ClusterName} = (await client.getConfig()).ClusterSettings;\n expect(Enable, Enable ? '' : 'Should have cluster enabled').toBe(true);\n\n const sameClusterName = ClusterName === haClusterName;\n expect(\n sameClusterName,\n sameClusterName\n ? ''\n : `Should have cluster name set and as expected. Got \"${ClusterName}\" but expected \"${haClusterName}\"`,\n ).toBe(true);\n\n const clusterInfo = await client.getClusterStatus();\n const sameCount = clusterInfo?.length === haClusterNodeCount;\n expect(\n sameCount,\n sameCount\n ? ''\n : `Should match number of nodes in a cluster as expected. Got \"${clusterInfo?.length}\" but expected \"${haClusterNodeCount}\"`,\n ).toBe(true);\n\n clusterInfo.forEach((info) =>\n // eslint-disable-next-line no-console\n console.log(`hostname: ${info.hostname}, version: ${info.version}, config_hash: ${info.config_hash}`),\n );\n }\n}\n\nasync function savePreferences(client: Client4, userId: UserProfile['id']) {\n try {\n if (!userId) {\n throw new Error('userId is not defined');\n }\n\n const preferences: PreferenceType[] = [\n {user_id: userId, category: 'tutorial_step', name: userId, value: '999'},\n {user_id: userId, category: 'crt_thread_pane_step', name: userId, value: '999'},\n ];\n\n await client.savePreferences(userId, preferences);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.log('Error saving preferences', error);\n }\n}\n"],"names":["getAdminClient","Client4","testConfig","getDefaultAdminUser","makeClient","defaultTeam","createRandomTeam","expect"],"mappings":";;;;;;;;;;;;AAAA;AACA;AAYO,eAAe,eAAe,GAAA;AACjC,IAAA,IAAI,WAAoB;AACxB,IAAA,IAAI,SAA6B;AACjC,IAAA,CAAC,EAAC,WAAW,EAAE,SAAS,EAAC,GAAG,MAAMA,mBAAc,CAAC,EAAC,OAA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AAK,EAAE,KAAK,EAAC;AACxE,YAAA,EAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,sBAAsB,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAC;SAClF;QAED,MAAM,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,WAAW,CAAC;;IACnD,OAAO,KAAK,EAAE;;AAEZ,QAAA,OAAO,CAAC,GAAG,CAAC,0BAA0B,EAAE,KAAK,CAAC;;AAEtD;;;;;"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { Client4 } from '@mattermost/client';
|
|
2
|
+
export { test, expect, PlaywrightExtended } from './test_fixture';
|
|
3
|
+
export { testConfig } from './test_config';
|
|
4
|
+
export { baseGlobalSetup } from './global_setup';
|
|
5
|
+
export { TestBrowser } from './browser_context';
|
|
6
|
+
export { getBlobFromAsset, getFileFromAsset } from './file';
|
|
7
|
+
export { duration, wait } from './util';
|
|
8
|
+
export { ChannelsPage, LandingLoginPage, LoginPage, ResetPasswordPage, SignupPage, ScheduledDraftPage, SystemConsolePage, DraftPage, } from './ui/pages';
|
|
9
|
+
export { TestArgs, ScreenshotOptions } from './types';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var client = require('@mattermost/client');
|
|
4
|
+
var test_fixture = require('./test_fixture.js');
|
|
5
|
+
var test_config = require('./test_config.js');
|
|
6
|
+
var global_setup = require('./global_setup.js');
|
|
7
|
+
var browser_context = require('./browser_context.js');
|
|
8
|
+
var file = require('./file.js');
|
|
9
|
+
var util = require('./util.js');
|
|
10
|
+
var channels = require('./ui/pages/channels.js');
|
|
11
|
+
var landing_login = require('./ui/pages/landing_login.js');
|
|
12
|
+
var login = require('./ui/pages/login.js');
|
|
13
|
+
var reset_password = require('./ui/pages/reset_password.js');
|
|
14
|
+
var signup = require('./ui/pages/signup.js');
|
|
15
|
+
var system_console = require('./ui/pages/system_console.js');
|
|
16
|
+
var scheduled_draft = require('./ui/pages/scheduled_draft.js');
|
|
17
|
+
var drafts = require('./ui/pages/drafts.js');
|
|
18
|
+
var test = require('@playwright/test');
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
Object.defineProperty(exports, "Client4", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () { return client.Client4; }
|
|
25
|
+
});
|
|
26
|
+
exports.PlaywrightExtended = test_fixture.PlaywrightExtended;
|
|
27
|
+
exports.test = test_fixture.test;
|
|
28
|
+
exports.testConfig = test_config.testConfig;
|
|
29
|
+
exports.baseGlobalSetup = global_setup.baseGlobalSetup;
|
|
30
|
+
exports.TestBrowser = browser_context.TestBrowser;
|
|
31
|
+
exports.getBlobFromAsset = file.getBlobFromAsset;
|
|
32
|
+
exports.getFileFromAsset = file.getFileFromAsset;
|
|
33
|
+
exports.duration = util.duration;
|
|
34
|
+
exports.wait = util.wait;
|
|
35
|
+
exports.ChannelsPage = channels;
|
|
36
|
+
exports.LandingLoginPage = landing_login;
|
|
37
|
+
exports.LoginPage = login;
|
|
38
|
+
exports.ResetPasswordPage = reset_password;
|
|
39
|
+
exports.SignupPage = signup;
|
|
40
|
+
exports.SystemConsolePage = system_console;
|
|
41
|
+
exports.ScheduledDraftPage = scheduled_draft;
|
|
42
|
+
exports.DraftPage = drafts;
|
|
43
|
+
Object.defineProperty(exports, "expect", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () { return test.expect; }
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Page } from '@playwright/test';
|
|
2
|
+
type NotificationData = {
|
|
3
|
+
title: string;
|
|
4
|
+
} & NotificationOptions;
|
|
5
|
+
declare global {
|
|
6
|
+
interface Window {
|
|
7
|
+
_originalNotification: typeof Notification;
|
|
8
|
+
_notifications: NotificationData[];
|
|
9
|
+
getNotifications: () => NotificationData[];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* `stubNotification` intercepts the Notification API to capture notifications.
|
|
14
|
+
*
|
|
15
|
+
* Note:
|
|
16
|
+
* - Works across browsers and devices, except in headless mode, where stubbing the Notification API is supported only in Firefox and WebKit.
|
|
17
|
+
* - An `Error: page.evaluate: window.getNotifications is not a function` may occur if the `stubNotification` function is called before the page has fully loaded.
|
|
18
|
+
*
|
|
19
|
+
* @param page Page object
|
|
20
|
+
* @param permission Permission setting for notifications, with possible values: "default" | "granted" | "denied". Note: A notification sound may still occur even when set to "denied", as the browser might attempt to trigger system notifications.
|
|
21
|
+
*/
|
|
22
|
+
export declare function stubNotification(page: Page, permission: NotificationPermission): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* `waitForNotification` waits for a specified number of notifications to be received on the page within a given timeout.
|
|
25
|
+
* @param page Page object
|
|
26
|
+
* @param expectedCount Number of notifications to wait for before returning. (default: 1)
|
|
27
|
+
* @param timeout Wait time in milliseconds. (default: 5000ms)
|
|
28
|
+
* @returns An array of notifications received
|
|
29
|
+
*/
|
|
30
|
+
export declare function waitForNotification(page: Page, expectedCount?: number, timeout?: number): Promise<NotificationData[]>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
4
|
+
// See LICENSE.txt for license information.
|
|
5
|
+
/**
|
|
6
|
+
* `stubNotification` intercepts the Notification API to capture notifications.
|
|
7
|
+
*
|
|
8
|
+
* Note:
|
|
9
|
+
* - Works across browsers and devices, except in headless mode, where stubbing the Notification API is supported only in Firefox and WebKit.
|
|
10
|
+
* - An `Error: page.evaluate: window.getNotifications is not a function` may occur if the `stubNotification` function is called before the page has fully loaded.
|
|
11
|
+
*
|
|
12
|
+
* @param page Page object
|
|
13
|
+
* @param permission Permission setting for notifications, with possible values: "default" | "granted" | "denied". Note: A notification sound may still occur even when set to "denied", as the browser might attempt to trigger system notifications.
|
|
14
|
+
*/
|
|
15
|
+
async function stubNotification(page, permission) {
|
|
16
|
+
await page.evaluate((notificationPermission) => {
|
|
17
|
+
// Override the Notification.requestPermission method
|
|
18
|
+
window.Notification.requestPermission = () => Promise.resolve(permission);
|
|
19
|
+
// Copy the original Notification
|
|
20
|
+
if (!window._originalNotification) {
|
|
21
|
+
window._originalNotification = window.Notification;
|
|
22
|
+
}
|
|
23
|
+
// Initialize a list where to capture the notifications
|
|
24
|
+
window._notifications = [];
|
|
25
|
+
// Override the Notification constructor
|
|
26
|
+
class CustomNotification extends window._originalNotification {
|
|
27
|
+
constructor(title, options) {
|
|
28
|
+
super(title, options);
|
|
29
|
+
const notification = { title, ...options };
|
|
30
|
+
window._notifications.push(notification);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// Set static properties and permission status
|
|
34
|
+
Object.defineProperties(CustomNotification, {
|
|
35
|
+
permission: {
|
|
36
|
+
get: () => notificationPermission,
|
|
37
|
+
},
|
|
38
|
+
requestPermission: {
|
|
39
|
+
value: () => Promise.resolve(notificationPermission),
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
// Replace the global Notification with the custom one
|
|
43
|
+
window.Notification = CustomNotification;
|
|
44
|
+
// Method to get all notifications
|
|
45
|
+
window.getNotifications = () => window._notifications;
|
|
46
|
+
}, permission);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* `waitForNotification` waits for a specified number of notifications to be received on the page within a given timeout.
|
|
50
|
+
* @param page Page object
|
|
51
|
+
* @param expectedCount Number of notifications to wait for before returning. (default: 1)
|
|
52
|
+
* @param timeout Wait time in milliseconds. (default: 5000ms)
|
|
53
|
+
* @returns An array of notifications received
|
|
54
|
+
*/
|
|
55
|
+
async function waitForNotification(page, expectedCount = 1, timeout = 5000) {
|
|
56
|
+
const start = Date.now();
|
|
57
|
+
while (Date.now() - start < timeout) {
|
|
58
|
+
const notifications = await page.evaluate(() => window.getNotifications());
|
|
59
|
+
if (notifications.length >= expectedCount) {
|
|
60
|
+
return notifications;
|
|
61
|
+
}
|
|
62
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
63
|
+
}
|
|
64
|
+
// eslint-disable-next-line no-console
|
|
65
|
+
console.error(`Notification not received within the timeout period of ${timeout}ms`);
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
exports.stubNotification = stubNotification;
|
|
70
|
+
exports.waitForNotification = waitForNotification;
|
|
71
|
+
//# sourceMappingURL=mock_browser_api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock_browser_api.js","sources":["../src/mock_browser_api.ts"],"sourcesContent":["// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.\n// See LICENSE.txt for license information.\n\nimport {Page} from '@playwright/test';\n\ntype NotificationData = {title: string} & NotificationOptions;\n\n// Extend the Window interface to add custom properties\ndeclare global {\n interface Window {\n _originalNotification: typeof Notification;\n _notifications: NotificationData[];\n getNotifications: () => NotificationData[];\n }\n}\n\n/**\n * `stubNotification` intercepts the Notification API to capture notifications.\n *\n * Note:\n * - Works across browsers and devices, except in headless mode, where stubbing the Notification API is supported only in Firefox and WebKit.\n * - An `Error: page.evaluate: window.getNotifications is not a function` may occur if the `stubNotification` function is called before the page has fully loaded.\n *\n * @param page Page object\n * @param permission Permission setting for notifications, with possible values: \"default\" | \"granted\" | \"denied\". Note: A notification sound may still occur even when set to \"denied\", as the browser might attempt to trigger system notifications.\n */\nexport async function stubNotification(page: Page, permission: NotificationPermission) {\n await page.evaluate((notificationPermission: NotificationPermission) => {\n // Override the Notification.requestPermission method\n window.Notification.requestPermission = () => Promise.resolve(permission);\n\n // Copy the original Notification\n if (!window._originalNotification) {\n window._originalNotification = window.Notification;\n }\n\n // Initialize a list where to capture the notifications\n window._notifications = [];\n\n // Override the Notification constructor\n class CustomNotification extends window._originalNotification {\n constructor(title: string, options?: NotificationOptions) {\n super(title, options);\n const notification = {title, ...options};\n window._notifications.push(notification);\n }\n }\n\n // Set static properties and permission status\n Object.defineProperties(CustomNotification, {\n permission: {\n get: () => notificationPermission,\n },\n requestPermission: {\n value: () => Promise.resolve(notificationPermission),\n },\n });\n\n // Replace the global Notification with the custom one\n window.Notification = CustomNotification as unknown as typeof Notification;\n\n // Method to get all notifications\n window.getNotifications = () => window._notifications;\n }, permission);\n}\n\n/**\n * `waitForNotification` waits for a specified number of notifications to be received on the page within a given timeout.\n * @param page Page object\n * @param expectedCount Number of notifications to wait for before returning. (default: 1)\n * @param timeout Wait time in milliseconds. (default: 5000ms)\n * @returns An array of notifications received\n */\nexport async function waitForNotification(\n page: Page,\n expectedCount = 1,\n timeout: number = 5000,\n): Promise<NotificationData[]> {\n const start = Date.now();\n while (Date.now() - start < timeout) {\n const notifications = await page.evaluate(() => window.getNotifications());\n if (notifications.length >= expectedCount) {\n return notifications;\n }\n await new Promise((resolve) => setTimeout(resolve, 100));\n }\n // eslint-disable-next-line no-console\n console.error(`Notification not received within the timeout period of ${timeout}ms`);\n return [];\n}\n"],"names":[],"mappings":";;AAAA;AACA;AAeA;;;;;;;;;AASG;AACI,eAAe,gBAAgB,CAAC,IAAU,EAAE,UAAkC,EAAA;AACjF,IAAA,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAC,sBAA8C,KAAI;;AAEnE,QAAA,MAAM,CAAC,YAAY,CAAC,iBAAiB,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC;;AAGzE,QAAA,IAAI,CAAC,MAAM,CAAC,qBAAqB,EAAE;AAC/B,YAAA,MAAM,CAAC,qBAAqB,GAAG,MAAM,CAAC,YAAY;;;AAItD,QAAA,MAAM,CAAC,cAAc,GAAG,E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A,EAAA,CAAI,CAAC;AACpF,IAAA,OAAO,EAAE;AACb;;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Channel, ChannelType } from '@mattermost/types/channels';
|
|
2
|
+
type ChannelInput = {
|
|
3
|
+
teamId: string;
|
|
4
|
+
name: string;
|
|
5
|
+
displayName: string;
|
|
6
|
+
type?: ChannelType;
|
|
7
|
+
purpose?: string;
|
|
8
|
+
header?: string;
|
|
9
|
+
unique?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function createRandomChannel(channelInput: ChannelInput): Channel;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var util = require('../util.js');
|
|
4
|
+
|
|
5
|
+
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
6
|
+
// See LICENSE.txt for license information.
|
|
7
|
+
function createRandomChannel(channelInput) {
|
|
8
|
+
const channel = {
|
|
9
|
+
team_id: channelInput.teamId,
|
|
10
|
+
name: channelInput.name,
|
|
11
|
+
display_name: channelInput.displayName,
|
|
12
|
+
type: channelInput.type || 'O',
|
|
13
|
+
purpose: channelInput.type || '',
|
|
14
|
+
header: channelInput.type || '',
|
|
15
|
+
};
|
|
16
|
+
if (channelInput.unique) {
|
|
17
|
+
const randomSuffix = util.getRandomId();
|
|
18
|
+
channel.name = `${channelInput.name}-${randomSuffix}`;
|
|
19
|
+
channel.display_name = `${channelInput.displayName} ${randomSuffix}`;
|
|
20
|
+
}
|
|
21
|
+
return channel;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
exports.createRandomChannel = createRandomChannel;
|
|
25
|
+
//# sourceMappingURL=channel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.js","sources":["../../src/server/channel.ts"],"sourcesContent":["// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.\n// See LICENSE.txt for license information.\n\nimport {Channel, ChannelType} from '@mattermost/types/channels';\n\nimport {getRandomId} from '@/util';\n\ntype ChannelInput = {\n teamId: string;\n name: string;\n displayName: string;\n type?: ChannelType;\n purpose?: string;\n header?: string;\n unique?: boolean;\n};\n\nexport function createRandomChannel(channelInput: ChannelInput): Channel {\n const channel = {\n team_id: channelInput.teamId,\n name: channelInput.name,\n display_name: channelInput.displayName,\n type: channelInput.type || 'O',\n purpose: channelInput.type || '',\n header: channelInput.type || '',\n };\n\n if (channelInput.unique) {\n const randomSuffix = getRandomId();\n\n channel.name = `${channelInput.name}-${randomSuffix}`;\n channel.display_name = `${channelInput.displayName} ${randomSuffix}`;\n }\n\n return channel as Channel;\n}\n"],"names":["getRandomId"],"mappings":";;;;AAAA;AACA;AAgBM,SAAU,mBAAmB,CAAC,YAA0B,EAAA;AAC1D,IAAA,MAAM,OAAO,GAAG;QACZ,OAAO,EAAE,YAAY,CAAC,MAAM;QAC5B,IAAI,EAAE,YAAY,CAAC,IAAI;QACvB,YAAY,EAAE,YAAY,CAAC,WAAW;AACtC,QAAA,IAAI,EAAE,YAAY,CAAC,IAAI,IAAI,GAAG;AAC9B,QAAA,OAAO,EAAE,YAAY,CAAC,IAAI,IAAI,EAAE;AAChC,QAAA,MAAM,EAAE,YAAY,CAAC,IAAI,IAAI,EAAE;KAClC;AAED,IAAA,IAAI,YAAY,CAAC,MAAM,EAAE;AACrB,QAAA,MAAM,YAAY,GAAGA,gBAAW,EAAE;QAElC,OAAO,CAAC,IAAI,GAAG,CAAG,EAAA,YAAY,CAAC,IAAI,CAAA,CAAA,EAAI,YAAY,CAAA,CAAE;QACrD,OAAO,CAAC,YAAY,GAAG,CAAG,EAAA,YAAY,CAAC,WAAW,CAAA,CAAA,EAAI,YAAY,CAAA,CAAE;;AAGxE,IAAA,OAAO,OAAkB;AAC7B;;;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Client4 } from '@mattermost/client';
|
|
2
|
+
import { UserProfile } from '@mattermost/types/users';
|
|
3
|
+
export declare function makeClient(userRequest?: UserRequest, opts?: {
|
|
4
|
+
useCache?: boolean;
|
|
5
|
+
skipLog?: boolean;
|
|
6
|
+
}): Promise<ClientCache>;
|
|
7
|
+
type UserRequest = {
|
|
8
|
+
username: string;
|
|
9
|
+
email?: string;
|
|
10
|
+
password: string;
|
|
11
|
+
};
|
|
12
|
+
type ClientCache = {
|
|
13
|
+
client: Client4;
|
|
14
|
+
user: UserProfile | null;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var client = require('@mattermost/client');
|
|
4
|
+
var test_config = require('../test_config.js');
|
|
5
|
+
|
|
6
|
+
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
7
|
+
// See LICENSE.txt for license information.
|
|
8
|
+
// Variable to hold cache
|
|
9
|
+
const clients = {};
|
|
10
|
+
async function makeClient(userRequest, opts = { useCache: true, skipLog: false }) {
|
|
11
|
+
const client$1 = new client.Client4();
|
|
12
|
+
client$1.setUrl(test_config.testConfig.baseURL);
|
|
13
|
+
try {
|
|
14
|
+
if (!userRequest) {
|
|
15
|
+
return { client: client$1, user: null };
|
|
16
|
+
}
|
|
17
|
+
const cacheKey = userRequest.username + userRequest.password;
|
|
18
|
+
if (opts?.useCache && clients[cacheKey] != null) {
|
|
19
|
+
return clients[cacheKey];
|
|
20
|
+
}
|
|
21
|
+
const userProfile = await client$1.login(userRequest.username, userRequest.password);
|
|
22
|
+
const user = { ...userProfile, password: userRequest.password };
|
|
23
|
+
if (opts?.useCache) {
|
|
24
|
+
clients[cacheKey] = { client: client$1, user };
|
|
25
|
+
}
|
|
26
|
+
return { client: client$1, user };
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
if (!opts?.skipLog) {
|
|
30
|
+
// log an error for debugging
|
|
31
|
+
// eslint-disable-next-line no-console
|
|
32
|
+
console.log('makeClient', err);
|
|
33
|
+
}
|
|
34
|
+
return { client: client$1, user: null };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
exports.makeClient = makeClient;
|
|
39
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sources":["../../src/server/client.ts"],"sourcesContent":["// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.\n// See LICENSE.txt for license information.\n\nimport {Client4} from '@mattermost/client';\nimport {UserProfile} from '@mattermost/types/users';\n\nimport {testConfig} from '@/test_config';\n\n// Variable to hold cache\nconst clients: Record<string, ClientCache> = {};\n\nexport async function makeClient(\n userRequest?: UserRequest,\n opts: {useCache?: boolean; skipLog?: boolean} = {useCache: true, skipLog: false},\n): Promise<ClientCache> {\n const client = new Client4();\n client.setUrl(testConfig.baseURL);\n\n try {\n if (!userRequest) {\n return {client, user: null};\n }\n\n const cacheKey = userRequest.username + userRequest.password;\n if (opts?.useCache && clients[cacheKey] != null) {\n return clients[cacheKey];\n }\n\n const userProfile = await client.login(userRequest.username, userRequest.password);\n const user = {...userProfile, password: userRequest.password};\n\n if (opts?.useCache) {\n clients[cacheKey] = {client, user};\n }\n\n return {client, user};\n } catch (err) {\n if (!opts?.skipLog) {\n // log an error for debugging\n // eslint-disable-next-line no-console\n console.log('makeClient', err);\n }\n return {client, user: null};\n }\n}\n\n// Client types\n\ntype UserRequest = {\n username: string;\n email?: string;\n password: string;\n};\n\ntype ClientCache = {\n client: Client4;\n user: UserProfile | null;\n};\n"],"names":["client","Client4","testConfig"],"mappings":";;;;;AAAA;AACA;AAOA;AACA,MAAM,OAAO,GAAgC,EAAE;AAExC,eAAe,UAAU,CAC5B,WAAyB,EACzB,IAAA,GAAgD,EAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAC,EAAA;AAEhF,IAAA,MAAMA,QAAM,GAAG,IAAIC,cAAO,EAAE;AAC5B,IAAAD,QAAM,CAAC,MAAM,CAACE,sBAAU,CAAC,OAA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