zitadel/e2e/cypress/support/api/search.ts
Elio Bischof 51febd7e4e
test(e2e): test authorizations (#4342)
* add specs that cover the b2b demo

* update cypress

* test handling manager roles

* use shared mocha contexts

* use beforeEach instead of before

* improve readability

* improve application test

* remove static waits

* remove old awaitDesired

* test owned project authorizations

* simplify ensure.ts

* test granted projects authz

* disable prevSubject for shouldNotExist

* await non-existence, then expect no error

* update dependencies

* fix tests from scratch

* fix settings tests from scratch

* Apply suggestions from code review

Co-authored-by: Max Peintner <max@caos.ch>

* Implement code review suggestions

* use spread operator

* settings properties must match

* add check settings object

* revert spread operator

Co-authored-by: Max Peintner <max@caos.ch>
2022-10-11 15:29:23 +02:00

33 lines
829 B
TypeScript

import { requestHeaders } from './apiauth';
import { API, Entity, SearchResult } from './types';
export function searchSomething(
api: API,
searchPath: string,
method: string,
mapResult: (body: any) => SearchResult,
orgId?: number,
): Cypress.Chainable<SearchResult> {
return cy
.request({
method: method,
url: searchPath,
headers: requestHeaders(api, orgId),
failOnStatusCode: method == 'POST',
})
.then((res) => {
return mapResult(res.body);
});
}
export function findFromList(find: (entity: Entity) => boolean, idField: string = 'id'): (body: any) => SearchResult {
return (b) => {
const entity = b.result?.find(find);
return {
entity: entity,
sequence: parseInt(<string>b.details.processedSequence),
id: entity?.[idField],
};
};
}