2019-12-07 16:58:52 +05:30
|
|
|
/// <reference types="cypress" />
|
|
|
|
|
2019-12-26 17:48:58 +05:30
|
|
|
type AccountAlias = 'default' | 'default2';
|
|
|
|
|
2019-12-29 20:14:07 +05:30
|
|
|
interface TAccount {
|
|
|
|
id: number;
|
2019-12-26 17:48:58 +05:30
|
|
|
username: string;
|
2019-12-29 17:27:44 +05:30
|
|
|
password: string;
|
2019-12-26 17:48:58 +05:30
|
|
|
email: string;
|
|
|
|
token: string;
|
|
|
|
refreshToken: string;
|
|
|
|
}
|
|
|
|
|
2019-12-07 16:58:52 +05:30
|
|
|
declare namespace Cypress {
|
|
|
|
interface Chainable {
|
|
|
|
/**
|
|
|
|
* Custom command to log in the user
|
|
|
|
*
|
2019-12-28 01:30:13 +05:30
|
|
|
* @example cy.login({ accounts: ['default'] })
|
2019-12-07 16:58:52 +05:30
|
|
|
*/
|
|
|
|
login(options: {
|
2019-12-26 17:48:58 +05:30
|
|
|
accounts: AccountAlias[];
|
2019-12-28 01:30:13 +05:30
|
|
|
/**
|
|
|
|
* defaults to `true`. if `false` — than only api response will
|
|
|
|
* be returned without mutating app state
|
|
|
|
* (useful for custom scenarios such as mocking of other api responses
|
|
|
|
* or checking whether account is registered)
|
|
|
|
*/
|
|
|
|
updateState?: boolean;
|
|
|
|
/**
|
|
|
|
* Whether return raw api response without any conversion. Defaults to: `false`
|
|
|
|
*/
|
2019-12-29 21:56:51 +05:30
|
|
|
rawApiResp?: false;
|
2019-12-29 20:14:07 +05:30
|
|
|
}): Promise<{ accounts: TAccount[] }>;
|
2019-12-29 21:56:51 +05:30
|
|
|
login(options: {
|
|
|
|
accounts: AccountAlias[];
|
|
|
|
updateState?: boolean;
|
|
|
|
rawApiResp: true;
|
|
|
|
}): Promise<{
|
|
|
|
accounts: {
|
|
|
|
success: true;
|
|
|
|
access_token: string;
|
|
|
|
expires_in: number;
|
|
|
|
refresh_token: string;
|
|
|
|
}[];
|
|
|
|
}>;
|
2019-12-26 17:48:58 +05:30
|
|
|
|
|
|
|
getByTestId<S = any>(
|
|
|
|
id: string,
|
|
|
|
options?: Partial<Loggable & Timeoutable & Withinable>,
|
|
|
|
): Chainable<S>;
|
2019-12-07 16:58:52 +05:30
|
|
|
}
|
|
|
|
}
|