mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-22 09:32:41 +00:00
feat: improved e2e tests
This commit is contained in:
@@ -1,43 +1,86 @@
|
||||
// ***********************************************
|
||||
// This example namespace declaration will help
|
||||
// with Intellisense and code completion in your
|
||||
// IDE or Text Editor.
|
||||
// ***********************************************
|
||||
// declare namespace Cypress {
|
||||
// interface Chainable<Subject = any> {
|
||||
// customCommand(param: any): typeof customCommand;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// function customCommand(param: any): void {
|
||||
// console.warn(param);
|
||||
// }
|
||||
//
|
||||
// NOTE: You can use it like so:
|
||||
// Cypress.Commands.add('customCommand', customCommand);
|
||||
//
|
||||
// ***********************************************
|
||||
// This example commands.js shows you how to
|
||||
// create various custom commands and overwrite
|
||||
// existing commands.
|
||||
//
|
||||
// For more comprehensive examples of custom
|
||||
// commands please read more here:
|
||||
// https://on.cypress.io/custom-commands
|
||||
// ***********************************************
|
||||
//
|
||||
//
|
||||
// -- This is a parent command --
|
||||
// Cypress.Commands.add("login", (email, password) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a child command --
|
||||
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a dual command --
|
||||
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This will overwrite an existing command --
|
||||
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
|
||||
/*
|
||||
* Copyright (C) 2023 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/* eslint-disable @typescript-eslint/no-namespace,@typescript-eslint/no-explicit-any */
|
||||
import type {Component} from '@angular/core';
|
||||
import {
|
||||
interceptBackend,
|
||||
interceptConfig,
|
||||
interceptGet,
|
||||
interceptMultiSearch,
|
||||
interceptSearch,
|
||||
} from './commands/backend';
|
||||
import {component, ng, runInsideAngular, zone} from './commands/angular';
|
||||
import {
|
||||
clearAllSettings,
|
||||
getAllSettings,
|
||||
getSetting,
|
||||
setLocalConfig,
|
||||
setSettings,
|
||||
storage,
|
||||
} from './commands/settings';
|
||||
import {patchSearchPage} from './commands/patches';
|
||||
|
||||
const commands = {
|
||||
interceptConfig,
|
||||
interceptBackend,
|
||||
interceptSearch,
|
||||
interceptMultiSearch,
|
||||
interceptGet,
|
||||
storage,
|
||||
setLocalConfig,
|
||||
setSettings,
|
||||
getSetting,
|
||||
clearAllSettings,
|
||||
getAllSettings,
|
||||
patchSearchPage,
|
||||
ng,
|
||||
zone,
|
||||
};
|
||||
|
||||
const childCommands = {
|
||||
component,
|
||||
runInsideAngular,
|
||||
};
|
||||
|
||||
Cypress.Commands.addAll(commands);
|
||||
Cypress.Commands.addAll({prevSubject: true}, childCommands);
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
namespace Cypress {
|
||||
// items that include generics also have to be defined here separately
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
interface Chainable extends CustomCommands, CustomChildCommands {
|
||||
component<T = Component>(): Cypress.Chainable<T>;
|
||||
|
||||
runInsideAngular<T = any, U = void>(zoneAwareTask: (subject: T) => U): Cypress.Chainable<U>;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type CustomCommands = {
|
||||
[KEY in keyof typeof commands]: (
|
||||
...parameters: Parameters<(typeof commands)[KEY]>
|
||||
) => ChainableReturnType<(typeof commands)[KEY]>;
|
||||
};
|
||||
type OmitFirstArgument<F> = F extends (x: any, ...arguments_: infer P) => infer R
|
||||
? (...arguments_: P) => R
|
||||
: never;
|
||||
type CustomChildCommands = {
|
||||
[KEY in keyof typeof childCommands]: OmitFirstArgument<(typeof childCommands)[KEY]>;
|
||||
};
|
||||
type ChainableReturnType<T extends (...arguments_: any) => any> = ReturnType<T> extends Cypress.Chainable
|
||||
? ReturnType<T>
|
||||
: Cypress.Chainable<null>;
|
||||
|
||||
Reference in New Issue
Block a user