From e5677b592a23fc5b402b004baabf9656c2bd46c1 Mon Sep 17 00:00:00 2001 From: hpathak <hpathak@rocketsoftware.com> Date: Fri, 11 Oct 2024 00:18:18 +0530 Subject: [PATCH] Added test in stcs and vsam tab to read yaml Signed-off-by: hpathak <hpathak@rocketsoftware.com> --- playwright_test/Tests/Stcs.spec.ts | 64 +++++++++++------------------- playwright_test/Tests/Vsam.spec.ts | 29 +++++--------- playwright_test/prepare.js | 2 +- 3 files changed, 35 insertions(+), 60 deletions(-) diff --git a/playwright_test/Tests/Stcs.spec.ts b/playwright_test/Tests/Stcs.spec.ts index f0ac00b4..493890ab 100644 --- a/playwright_test/Tests/Stcs.spec.ts +++ b/playwright_test/Tests/Stcs.spec.ts @@ -9,7 +9,7 @@ import SecurityPage from '../Pages/security.page.ts' import StcsPage from '../Pages/stcs.page.ts' import config from '../utils/config'; import ApfAuthPage from '../Pages/ApfAuth.page'; -import { runSSHCommand } from '../utils/sshUtils'; +import { connectArgs, Script } from '../setup'; let electronApp: ElectronApplication @@ -17,6 +17,7 @@ const STCS_TITLE = 'Stcs' const SECURITY_TITLE = 'Security'; const CERTIFICATE_TITLE = 'Certificates' +const script = new Script(); test.describe('StcsTab', () => { let connectionPage: ConnectionPage; @@ -97,13 +98,14 @@ test.describe('StcsTab', () => { await electronApp.close() }) + test('test title and required fields of page', async ({ page }) => { - const title = await stcsPage.returnTitleOfStcsPage(); - expect(title).toBe(STCS_TITLE); - await expect(stcsPage.zis).toBeTruthy() - await expect(stcsPage.zowe).toBeTruthy() - await expect(stcsPage.aux).toBeTruthy() - await expect(stcsPage.dataset_proclib).toBeTruthy() + const title = await stcsPage.returnTitleOfStcsPage(); + expect(title).toBe(STCS_TITLE); + await expect(stcsPage.zis).toBeTruthy() + await expect(stcsPage.zowe).toBeTruthy() + await expect(stcsPage.aux).toBeTruthy() + await expect(stcsPage.dataset_proclib).toBeTruthy() }) test('test values match with previous step', async ({ page }) => { @@ -121,22 +123,17 @@ test.describe('StcsTab', () => { expect(Aux_Value).toBe(aux_value); }) test('verify yaml updated on zos', async ({ page }) => { - const command = `cat ${process.env.ZOWE_ROOT_DIR}/zowe.yaml`; - - try { - const yaml = await runSSHCommand(command); - expect(yaml).toContain(config.SECURITY_AUX); - expect(yaml).toContain(config.SECURITY_STC_ZOWE); - expect(yaml).toContain(config.SECURITY_STC_ZIS); - } catch (error) { - console.error('Error executing command:', error.message); - } + const result = await script.runCommand(`cat ${process.env.ZOWE_ROOT_DIR}/zowe.yaml`); + await expect(result.details).toContain(config.SECURITY_AUX); + await expect(result.details).toContain(config.SECURITY_STC_ZOWE); + await expect(result.details).toContain(config.SECURITY_STC_ZIS); }); + test('Test view yaml button', async ({ page }) => { - await stcsPage.viewYaml() - await expect(stcsPage.editor_title_element).toBeTruthy(); - await stcsPage.closeButton() + await stcsPage.viewYaml() + await expect(stcsPage.editor_title_element).toBeTruthy(); + await stcsPage.closeButton() }) test('Test view job', async ({ page }) => { @@ -162,19 +159,9 @@ test.describe('StcsTab', () => { test('Test continue to certificate button is disable', async ({ page }) => { const is_ContinueButtonDisable = await stcsPage.isContinueButtonDisable(); - expect(is_ContinueButtonDisable).toBe(true); + await expect(is_ContinueButtonDisable).toBe(true); }) - test('Test yaml should be updated', async ({ page }) => { - await stcsPage.viewYaml(); - await expect(stcsPage.editor_title_element).toBeTruthy(); - const yaml = await stcsPage.read_yaml(); - expect(yaml).toContain(config.SECURITY_AUX); - expect(yaml).toContain(config.SECURITY_STC_ZOWE); - expect(yaml).toContain(config.SECURITY_STC_ZIS); - - }) - test('Test Resume Progress', async ({ page }) => { await stcsPage.click_saveAndClose() await titlePage.clickOnResumeProgress() @@ -194,16 +181,11 @@ test.describe('StcsTab', () => { test('verify stcs applied successfully on zos after initialization', async ({ page }) => { await stcsPage.initializeSTC() - const command = `tsocmd "LISTDS '${config.PROC_LIB}' MEMBERS"`; - - try { - const yaml = await runSSHCommand(command); - expect(yaml).toContain(config.SECURITY_AUX); - expect(yaml).toContain(config.SECURITY_STC_ZOWE); - expect(yaml).toContain(config.SECURITY_STC_ZIS); - } catch (error) { - console.error('Error executing command:', error.message); - } + const result = await script.runCommand(`tsocmd "LISTDS '${config.PROC_LIB}' MEMBERS"`); + await expect(result.details).toContain(config.SECURITY_AUX); + await expect(result.details).toContain(config.SECURITY_STC_ZOWE); + await expect(result.details).toContain(config.SECURITY_STC_ZIS); + // verify all checks are sucessfully checked const isWriteConfig_check_visible = await stcsPage.isWriteConfigGreenCheckVisible(); expect(isWriteConfig_check_visible).toBe(true); diff --git a/playwright_test/Tests/Vsam.spec.ts b/playwright_test/Tests/Vsam.spec.ts index 906b2d98..ef2c5d9d 100644 --- a/playwright_test/Tests/Vsam.spec.ts +++ b/playwright_test/Tests/Vsam.spec.ts @@ -10,7 +10,7 @@ import StcsPage from '../Pages/stcs.page.ts' import config from '../utils/config'; import ApfAuthPage from '../Pages/ApfAuth.page'; import VsamPage from '../Pages/Vsam.page'; -import { runSSHCommand } from '../utils/sshUtils'; +import { connectArgs, Script } from '../setup'; let electronApp: ElectronApplication @@ -18,6 +18,7 @@ const VSAM_TITLE = 'Vsam' const CERTIFICATE_TITLE = 'Certificates'; const LAUNCHCONFIG_TITLE = 'Configuration' const INVALID_ERRORMSG = 'Invalid input. Please enter a valid VSAM dataset name.' +const script = new Script() test.describe('VsamPage', () => { let connectionPage: ConnectionPage; @@ -153,15 +154,11 @@ test.describe('VsamPage', () => { test('Test NONRLS YAML Update on z/OS After Init', async ({ page }) => { await vsamPage.fillVsamDetails('NONRLS',config.VOLUME,'', config.VSAM_DATASET_NAME) await vsamPage.initializeVSAM(); - const command = `cat ${process.env.ZOWE_ROOT_DIR}/zowe.yaml`; - try { - const yaml = await runSSHCommand(command); - expect(yaml).toContain('NONRLS'); - expect(yaml).toContain(config.VOLUME); - expect(yaml).toContain(config.VSAM_DATASET_NAME); - } catch (error) { - console.error('Error executing command:', error.message); - } + const result = await script.runCommand(`cat ${process.env.ZOWE_ROOT_DIR}/zowe.yaml`); + await expect(result.details).toContain('NONRLS'); + await expect(result.details).toContain(config.VOLUME); + await expect(result.details).toContain(config.VSAM_DATASET_NAME); + const isWriteConfig_check_visible = await vsamPage.isWriteConfigGreenCheckVisible(); expect(isWriteConfig_check_visible).toBe(true); const isUploadConfig_check_visible = await vsamPage.isUploadConfigGreenCheckVisible(); @@ -173,14 +170,10 @@ test.describe('VsamPage', () => { test('Verify VSAM dataset was successfully created on z/OS.', async ({ page }) => { await vsamPage.fillVsamDetails('RLS',config.VOLUME,'', config.VSAM_DATASET_NAME) await vsamPage.initializeVSAM(); - const command = `tso "LISTCAT"`; - - try { - const yaml = await runSSHCommand(command); - expect(yaml).toContain(config.VSAM_DATASET_NAME); - } catch (error) { - console.error('Error executing command:', error.message); - } + const result = await script.runCommand(`tso "LISTCAT"`); + + await expect(result.details).toContain(config.VSAM_DATASET_NAME); + }); test('Test save and close and Resume Progress', async ({ page }) => { diff --git a/playwright_test/prepare.js b/playwright_test/prepare.js index 01a7f6b7..5c64d013 100644 --- a/playwright_test/prepare.js +++ b/playwright_test/prepare.js @@ -1,4 +1,4 @@ -const Script = require('./setup.js'); +import { connectArgs, Script } from './setup'; async function prepareEnvironment(options = {}) { const { install = false, remove = false } = options;