mirror of
https://github.com/mattermost/mattermost.git
synced 2026-02-03 20:40:00 -05:00
Merge 91c9e1675c into 0263262ef4
This commit is contained in:
commit
48333a490c
3 changed files with 18 additions and 26 deletions
|
|
@ -4,9 +4,10 @@
|
|||
import {Client4} from '@mattermost/client';
|
||||
|
||||
import clientRequest from '../plugins/client_request';
|
||||
import { type Options, type ClientResponse } from '@mattermost/types/client4';
|
||||
|
||||
export class E2EClient extends Client4 {
|
||||
async doFetchWithResponse(url, options) {
|
||||
protected doFetchWithResponse = async (url: string, options: Options): Promise<ClientResponse<any>> => {
|
||||
const {
|
||||
body,
|
||||
headers,
|
||||
|
|
@ -30,6 +31,10 @@ export class E2EClient extends Client4 {
|
|||
this.setUserId(response.data.id);
|
||||
this.setUserRoles(response.data.roles);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
return {
|
||||
response: response as unknown as Response,
|
||||
headers: response.headers,
|
||||
data: response.data,
|
||||
};
|
||||
};
|
||||
}
|
||||
22
e2e-tests/cypress/tests/support/client.d.ts
vendored
22
e2e-tests/cypress/tests/support/client.d.ts
vendored
|
|
@ -1,22 +0,0 @@
|
|||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
/// <reference types="cypress" />
|
||||
|
||||
// ***************************************************************
|
||||
// Each command should be properly documented using JSDoc.
|
||||
// See https://jsdoc.app/index.html for reference.
|
||||
// Basic requirements for documentation are the following:
|
||||
// - Meaningful description
|
||||
// - Specific link to https://api.mattermost.com
|
||||
// - Each parameter with `@params`
|
||||
// - Return value with `@returns`
|
||||
// - Example usage with `@example`
|
||||
// Custom command should follow naming convention of having `api` prefix, e.g. `apiLogin`.
|
||||
// ***************************************************************
|
||||
|
||||
declare namespace Cypress {
|
||||
interface Chainable {
|
||||
makeClient(options?: {user: Pick<UserProfile, 'username' | 'password'>}): Chainable<Client>;
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ import {E2EClient} from './client-impl';
|
|||
|
||||
const clients = {};
|
||||
|
||||
async function makeClient({user = getAdminAccount(), useCache = true} = {}) {
|
||||
async function makeClient({user = getAdminAccount(), useCache = true} = {}): Promise<E2EClient> {
|
||||
const cacheKey = user.username + user.password;
|
||||
if (useCache && clients[cacheKey] != null) {
|
||||
return clients[cacheKey];
|
||||
|
|
@ -27,3 +27,12 @@ async function makeClient({user = getAdminAccount(), useCache = true} = {}) {
|
|||
}
|
||||
|
||||
Cypress.Commands.add('makeClient', makeClient);
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
namespace Cypress {
|
||||
interface Chainable {
|
||||
makeClient: typeof makeClient;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue