This commit is contained in:
Angel Mendez 2026-02-04 03:03:31 +02:00 committed by GitHub
commit 48333a490c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 26 deletions

View file

@ -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,
};
};
}

View file

@ -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>;
}
}

View file

@ -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;
}
}
}