From 011e2d83dcb53ce3625726e5db26235ffed3eef9 Mon Sep 17 00:00:00 2001 From: Mihajlo Medjedovic Date: Tue, 24 Nov 2020 15:19:19 +0100 Subject: [PATCH] fix: computeApi debug override --- sasjs-tests/src/App.test.js | 9 --------- sasjs-tests/src/testSuites/Basic.ts | 11 ++++++----- sasjs-tests/src/testSuites/SasjsRequests.ts | 8 +++++--- src/SASViyaApiClient.ts | 12 ++++++++---- src/SASjs.ts | 2 ++ 5 files changed, 21 insertions(+), 21 deletions(-) delete mode 100644 sasjs-tests/src/App.test.js diff --git a/sasjs-tests/src/App.test.js b/sasjs-tests/src/App.test.js deleted file mode 100644 index 352d7b8..0000000 --- a/sasjs-tests/src/App.test.js +++ /dev/null @@ -1,9 +0,0 @@ -import React from "react"; -import { render } from "@testing-library/react"; -import App from "./App"; - -test("renders learn react link", () => { - const { getByText } = render(); - const linkElement = getByText(/learn react/i); - expect(linkElement).toBeInTheDocument(); -}); diff --git a/sasjs-tests/src/testSuites/Basic.ts b/sasjs-tests/src/testSuites/Basic.ts index b045874..a7f87a9 100644 --- a/sasjs-tests/src/testSuites/Basic.ts +++ b/sasjs-tests/src/testSuites/Basic.ts @@ -3,12 +3,12 @@ import { TestSuite } from "@sasjs/test-framework"; const defaultConfig: SASjsConfig = { serverUrl: window.location.origin, - pathSAS9: "/SASStoredProcess/do", - pathSASViya: "/SASJobExecution", - appLoc: "/Public/seedapp", + pathSAS9: '/SASStoredProcess/do', + pathSASViya: '/SASJobExecution', + appLoc: '/Public/seedapp', serverType: ServerType.SASViya, - debug: true, - contextName: "SAS Job Execution compute context", + debug: false, + contextName: 'SAS Job Execution compute context', useComputeApi: false }; @@ -57,6 +57,7 @@ export const basicTests = ( }, assertion: (sasjsInstance: SASjs) => { const sasjsConfig = sasjsInstance.getSasjsConfig(); + return ( sasjsConfig.serverUrl === defaultConfig.serverUrl && sasjsConfig.pathSAS9 === defaultConfig.pathSAS9 && diff --git a/sasjs-tests/src/testSuites/SasjsRequests.ts b/sasjs-tests/src/testSuites/SasjsRequests.ts index 08b8cf1..4aa063b 100644 --- a/sasjs-tests/src/testSuites/SasjsRequests.ts +++ b/sasjs-tests/src/testSuites/SasjsRequests.ts @@ -23,7 +23,7 @@ export const sasjsRequestTests = (adapter: SASjs): TestSuite => ({ }, { title: "Make error and capture log", - description: "Should make an error and capture log", + description: "Should make an error and capture log, in the same time it is testing if debug override is working", test: async () => { return new Promise(async (resolve, reject) => { adapter @@ -33,12 +33,14 @@ export const sasjsRequestTests = (adapter: SASjs): TestSuite => ({ }) .catch((err) => { let sasRequests = adapter.getSasRequests(); - let makeErrRequest = + let makeErrRequest: any = sasRequests.find((req) => req.serviceLink.includes("makeErr") ) || null; - resolve(!!makeErrRequest); + if (!makeErrRequest) resolve(false) + + resolve(!!(makeErrRequest.logFile && makeErrRequest.logFile.length > 0)); }); }); }, diff --git a/src/SASViyaApiClient.ts b/src/SASViyaApiClient.ts index 8ef99c1..dcf1dd5 100644 --- a/src/SASViyaApiClient.ts +++ b/src/SASViyaApiClient.ts @@ -426,10 +426,10 @@ export class SASViyaApiClient { * @param linesOfCode - an array of code lines to execute. * @param contextName - the context to execute the code in. * @param accessToken - an access token for an authorized user. - * @param sessionId - optional session ID to reuse. * @param data - execution data. * @param debug - when set to true, the log will be returned. * @param expectWebout - when set to true, the automatic _webout fileref will be checked for content, and that content returned. This fileref is used when the Job contains a SASjs web request (as opposed to executing arbitrary SAS code). + * @param waitForResult - when set to true, function will return the session */ public async executeScript( jobPath: string, @@ -437,6 +437,7 @@ export class SASViyaApiClient { contextName: string, accessToken?: string, data = null, + debug: boolean = false, expectWebout = false, waitForResult = true ): Promise { @@ -467,7 +468,7 @@ export class SASViyaApiClient { _OMITTEXTLOG: true } - if (this.debug) { + if (debug) { jobArguments['_OMITTEXTLOG'] = false jobArguments['_OMITSESSIONRESULTS'] = false jobArguments['_DEBUG'] = 131 @@ -535,7 +536,7 @@ export class SASViyaApiClient { return session } - if (this.debug) { + if (debug) { console.log(`Job has been submitted for '${fileName}'.`) console.log( `You can monitor the job progress at '${this.serverUrl}${ @@ -558,7 +559,7 @@ export class SASViyaApiClient { const logLink = currentJob.links.find((l) => l.rel === 'log') - if (this.debug && logLink) { + if (debug && logLink) { log = await this.request( `${this.serverUrl}${logLink.href}/content?limit=10000`, { @@ -633,6 +634,7 @@ export class SASViyaApiClient { contextName, accessToken, data, + debug, false, true ) @@ -953,6 +955,7 @@ export class SASViyaApiClient { public async executeComputeJob( sasJob: string, contextName: string, + debug?: boolean, data?: any, accessToken?: string, waitForResult = true, @@ -1039,6 +1042,7 @@ export class SASViyaApiClient { contextName, accessToken, data, + debug, expectWebout, waitForResult ) diff --git a/src/SASjs.ts b/src/SASjs.ts index ee221aa..494f875 100644 --- a/src/SASjs.ts +++ b/src/SASjs.ts @@ -734,6 +734,7 @@ export default class SASjs { return this.sasViyaApiClient?.executeComputeJob( sasJob, config.contextName, + config.debug, data, accessToken, !!waitForResult, @@ -766,6 +767,7 @@ export default class SASjs { ?.executeComputeJob( sasJob, config.contextName, + config.debug, data, accessToken, waitForResult,