mattermost/e2e-tests/cypress/tests/support/client.js
sabril 8bf422d6e2
E2E/Cypress: Upgrade dependencies (#33665)
* upgrade cypress and other dependecies

* fix eslint

* remove axios-retry and update eslint

* fix tests

* fix lint on trailing spaces

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
2025-09-01 14:14:13 +08:00

29 lines
736 B
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {getAdminAccount} from './env';
import {E2EClient} from './client-impl';
const clients = {};
async function makeClient({user = getAdminAccount(), useCache = true} = {}) {
const cacheKey = user.username + user.password;
if (useCache && clients[cacheKey] != null) {
return clients[cacheKey];
}
const client = new E2EClient();
const baseUrl = Cypress.config('baseUrl');
client.setUrl(baseUrl);
await client.login(user.username, user.password);
if (useCache) {
clients[cacheKey] = client;
}
return client;
}
Cypress.Commands.add('makeClient', makeClient);