From 436e30cf2d4fe4714aa504f3d663651b664ce6c8 Mon Sep 17 00:00:00 2001 From: Reda Al Sulais Date: Thu, 9 Nov 2023 10:48:36 +0300 Subject: [PATCH] update util.ts --- cypress/helpers/util.ts | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/cypress/helpers/util.ts b/cypress/helpers/util.ts index ab29187119d..1dc2035308c 100644 --- a/cypress/helpers/util.ts +++ b/cypress/helpers/util.ts @@ -39,12 +39,12 @@ const convertUtf8ToBase64 = (str: string): string => { */ export const createMermaidUrl = ( diagramStr: string, - options?: CypressMermaidConfig, - api?: boolean + options: CypressMermaidConfig = {}, + api: boolean = false ): string => { const codeObject: CodeObject = { code: diagramStr, - mermaid: options || {}, + mermaid: options, }; const objStr: string = JSON.stringify(codeObject); const url = `http://localhost:9000/${api ? 'xss' : 'e2e'}.html?graph=${convertUtf8ToBase64( @@ -68,14 +68,11 @@ export const createMermaidUrl = ( */ export const openUrlAndVerifyRendering = ( url: string, - options?: CypressMermaidConfig, + options: CypressMermaidConfig = {}, validation?: any ): void => { const useAppli: boolean = Cypress.env('useAppli'); - const name: string = ((options && options.name) || cy.state('runnable').fullTitle()).replace( - /\s+/g, - '-' - ); + const name: string = (options?.name || cy.state('runnable').fullTitle()).replace(/\s+/g, '-'); if (useAppli) { cy.log(`Opening eyes ${Cypress.spec.name} --- ${name}`); @@ -114,8 +111,8 @@ export const openUrlAndVerifyRendering = ( */ export const imgSnapshotTest = ( diagramStr: string, - _options?: CypressMermaidConfig, - api?: boolean, + _options: CypressMermaidConfig = {}, + api: boolean = false, validation?: any ): void => { cy.log(JSON.stringify(_options)); @@ -143,8 +140,8 @@ export const imgSnapshotTest = ( */ export const urlSnapshotTest = ( url: string, - _options?: CypressMermaidConfig, - _api?: boolean, + _options: CypressMermaidConfig = {}, + _api: boolean = false, validation?: any ): void => { const options: CypressMermaidConfig = Object.assign(_options);