Skip to content

Commit

Permalink
draft
Browse files Browse the repository at this point in the history
Signed-off-by: Himani1519 <[email protected]>
  • Loading branch information
Himani1519 committed Sep 20, 2024
1 parent 15c1057 commit b491434
Show file tree
Hide file tree
Showing 2 changed files with 228 additions and 201 deletions.
347 changes: 183 additions & 164 deletions playwright_test/Tests/Stcs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import StcsPage from '../Pages/stcs.page.ts'
import config from '../utils/config';
import ApfAuthPage from '../Pages/ApfAuth.page';
import { runSSHCommand } from '../utils/sshUtils';

const Script = require('../setup.js');
const path = require('path');

let electronApp: ElectronApplication
const STCS_TITLE = 'Stcs'
Expand Down Expand Up @@ -44,178 +45,196 @@ test.describe('StcsTab', () => {
networkingPage = new NetworkingPage(page);
securityPage = new SecurityPage(page);
stcsPage = new StcsPage(page);
titlePage.navigateToConnectionTab()
await connectionPage.fillConnectionDetails(config.SSH_HOST, config.SSH_PORT, config.SSH_USER, config.SSH_PASSWD);
await connectionPage.SubmitValidateCredential();
await connectionPage.clickContinueButton();
await planningPage.fillPlanningPageWithRequiredFields(config.ZOWE_ROOT_DIR,
config.ZOWE_WORKSPACE_DIR,
config.ZOWE_EXTENSION_DIR,
config.ZOWE_LOG_DIR,
'1',
config.JOB_NAME,
config.JOB_PREFIX,
config.JAVA_HOME,
config.NODE_HOME,
config.ZOSMF_HOST,
config.ZOSMF_PORT,
config.ZOSMF_APP_ID
);
await planningPage.clickValidateLocations()
await planningPage.clickContinueToInstallation()
await installationTypePage.downloadZowePaxAndNavigateToInstallationPage()
await installationTypePage.clickOnContinueToUnpax()
await installationTypePage.skipUnpax()
await installationPage.fillAllFields(config.DATASET_PREFIX,
config.PARM_LIB,
config.PROC_LIB,
config.JCL_LIB,
config.LOAD_LIB,
config.AUTH_LOAD_LIB,
config.AUTH_PLUGIN_LIB
)
await installationPage.clickInstallMvsDatasets();
await page.waitForTimeout(2000);
await installationPage.clickContinueToNetworkSetup();
await networkingPage.click_skipNetworking()
await apfAuthPage.click_skipApfAuth()
await page.waitForTimeout(20000);
await securityPage.fillSecurityDetails('RACF',
config.SECURITY_ADMIN,
config.SECURITY_STC,
config.SECURITY_SYSPROG,
config.SECURITY_USER_ZIS,
config.SECURITY_USER_ZOWE,
config.SECURITY_AUX,
config.SECURITY_STC_ZOWE,
config.SECURITY_STC_ZIS
)
await stcsPage.movetoStcsPage()
// titlePage.navigateToConnectionTab()
// await connectionPage.fillConnectionDetails(config.SSH_HOST, config.SSH_PORT, config.SSH_USER, config.SSH_PASSWD);
// await connectionPage.SubmitValidateCredential();
// await connectionPage.clickContinueButton();
// await planningPage.fillPlanningPageWithRequiredFields(config.ZOWE_ROOT_DIR,
// config.ZOWE_WORKSPACE_DIR,
// config.ZOWE_EXTENSION_DIR,
// config.ZOWE_LOG_DIR,
// '1',
// config.JOB_NAME,
// config.JOB_PREFIX,
// config.JAVA_HOME,
// config.NODE_HOME,
// config.ZOSMF_HOST,
// config.ZOSMF_PORT,
// config.ZOSMF_APP_ID
// );
// await planningPage.clickValidateLocations()
// await planningPage.clickContinueToInstallation()
// await installationTypePage.downloadZowePaxAndNavigateToInstallationPage()
// await installationTypePage.clickOnContinueToUnpax()
// await installationTypePage.skipUnpax()
// await installationPage.fillAllFields(config.DATASET_PREFIX,
// config.PARM_LIB,
// config.PROC_LIB,
// config.JCL_LIB,
// config.LOAD_LIB,
// config.AUTH_LOAD_LIB,
// config.AUTH_PLUGIN_LIB
// )
// await installationPage.clickInstallMvsDatasets();
// await page.waitForTimeout(2000);
// await installationPage.clickContinueToNetworkSetup();
// await networkingPage.click_skipNetworking()
// await apfAuthPage.click_skipApfAuth()
// await page.waitForTimeout(20000);
// await securityPage.fillSecurityDetails('RACF',
// config.SECURITY_ADMIN,
// config.SECURITY_STC,
// config.SECURITY_SYSPROG,
// config.SECURITY_USER_ZIS,
// config.SECURITY_USER_ZOWE,
// config.SECURITY_AUX,
// config.SECURITY_STC_ZOWE,
// config.SECURITY_STC_ZIS
// )
// await stcsPage.movetoStcsPage()
})

test.afterEach(async () => {
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()
})

test('test values match with previous step', async ({ page }) => {
const ZoweValue = await stcsPage.get_zowe_value();
const Zis_Value = await stcsPage.get_zis_value();
const Aux_Value = await stcsPage.get_aux_value();
await stcsPage.returnTitleOfPrevPage();
const aux_value = await securityPage.get_aux_value();
const stcZis_value = await securityPage.get_stc_zis_value();
const stcZowe_value = await securityPage.get_stc_zowe_value();
console.log(stcZowe_value,stcZis_value,aux_value)

expect(ZoweValue).toBe(stcZowe_value);
expect(stcZis_value).toBe(Zis_Value);
expect(Aux_Value).toBe(aux_value);
})
test('verify yaml updated on zos', async ({ page }) => {
const command = `cat ${process.env.ZOWE_ROOT_DIR}/zowe.yaml`;
// 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()
// })
//
// test('test values match with previous step', async ({ page }) => {
// const ZoweValue = await stcsPage.get_zowe_value();
// const Zis_Value = await stcsPage.get_zis_value();
// const Aux_Value = await stcsPage.get_aux_value();
// await stcsPage.returnTitleOfPrevPage();
// const aux_value = await securityPage.get_aux_value();
// const stcZis_value = await securityPage.get_stc_zis_value();
// const stcZowe_value = await securityPage.get_stc_zowe_value();
// console.log(stcZowe_value,stcZis_value,aux_value)
//
// expect(ZoweValue).toBe(stcZowe_value);
// expect(stcZis_value).toBe(Zis_Value);
// expect(Aux_Value).toBe(aux_value);
// })
test('verify yaml content on zos', async () => {
// Initialize the Script class with SSH connection details
const scriptRunner = new Script({
host: config.SSH_HOST,
port: config.SSH_PORT,
user: config.SSH_USER,
password: config.SSH_PASSWD,
});

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);
// Construct the shell command to read the YAML file
const yamlFilePath = path.normalize(`${config.ZOWE_ROOT_DIR}/zowe.yaml`); // Adjust path as needed
const shellCommand = `cat ${yamlFilePath}`;
console.log(yamlFilePath)
console.log(shellCommand)

// Run the shell command to read YAML content
const result = await scriptRunner.runShellCommand(shellCommand);

if (result.status) {
console.log('YAML Content:', result.details); // Log the YAML content
} else {
throw new Error(`Failed to read YAML: ${result.details}`); // Error handling
}

} catch (error) {
console.error('Error executing command:', error.message);
console.error('Error during YAML verification:', error);
throw error; // Re-throw to fail the test
}
});

test('Test view yaml button', async ({ page }) => {
await stcsPage.viewYaml()
await expect(stcsPage.editor_title_element).toBeTruthy();
await stcsPage.closeButton()
})

test('Test view job', async ({ page }) => {
await stcsPage.click_previewJob()
await expect(stcsPage.editor_title_element).toBeTruthy()
await stcsPage.closeButton()
})

test('test Previous step button is enabled', async ({ page }) => {
const is_prevButtonEnable = await stcsPage.isPreviousButtonEnable();
expect(is_prevButtonEnable).toBe(true);
const title = await stcsPage.returnTitleOfPrevPage();
expect(title).toBe(SECURITY_TITLE);
})

test('Test Skip Stcs button is enable', async ({ page }) => {
const isSkipStcsEnable = await stcsPage.is_skipStcsButtonEnable();
expect(isSkipStcsEnable).toBe(true);
const certificate_title = await stcsPage.click_skipStcsButton();
expect(certificate_title).toBe(CERTIFICATE_TITLE);
})


test('Test continue to certificate button is disable', async ({ page }) => {
const is_ContinueButtonDisable = await stcsPage.isContinueButtonDisable();
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()
await connectionPage.fillConnectionDetails(config.SSH_HOST, config.SSH_PORT, config.SSH_USER, config.SSH_PASSWD);
await connectionPage.SubmitValidateCredential()
const title = await stcsPage.returnTitleOfStcsPage();
expect(title).toBe(STCS_TITLE);
const ZoweValue = await stcsPage.get_zowe_value();
const Zis_Value = await stcsPage.get_zis_value();
const Aux_Value = await stcsPage.get_aux_value();
const DatasetProclib_Value = await stcsPage.get_datasetProclib_value();
expect(ZoweValue).toBe(config.SECURITY_STC_ZOWE);
expect(Aux_Value).toBe(config.SECURITY_AUX);
expect(Zis_Value).toBe(config.SECURITY_STC_ZIS);
expect(DatasetProclib_Value).toBe(config.PROC_LIB);
})

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);
}
// verify all checks are sucessfully checked
const isWriteConfig_check_visible = await stcsPage.isWriteConfigGreenCheckVisible();
expect(isWriteConfig_check_visible).toBe(true);
const isUploadConfig_check_visible = await stcsPage.isUploadConfigGreenCheckVisible();
expect(isUploadConfig_check_visible).toBe(true);
const isInitStcs_check_visible = await stcsPage.isInitSTCSGreenCheckVisible();
expect(isInitStcs_check_visible).toBe(true);
const is_GreenCheck_Visible = await stcsPage.isStatusChecked();
expect(is_GreenCheck_Visible).toBe(false);
//verify continue Button enabled after init stcs//
const is_ContinueButtonDisable = await stcsPage.isContinueButtonDisable();
expect(is_ContinueButtonDisable).toBe(false);
});
});

// test('Test view yaml button', async ({ page }) => {
// await stcsPage.viewYaml()
// await expect(stcsPage.editor_title_element).toBeTruthy();
// await stcsPage.closeButton()
// })
//
// test('Test view job', async ({ page }) => {
// await stcsPage.click_previewJob()
// await expect(stcsPage.editor_title_element).toBeTruthy()
// await stcsPage.closeButton()
// })
//
// test('test Previous step button is enabled', async ({ page }) => {
// const is_prevButtonEnable = await stcsPage.isPreviousButtonEnable();
// expect(is_prevButtonEnable).toBe(true);
// const title = await stcsPage.returnTitleOfPrevPage();
// expect(title).toBe(SECURITY_TITLE);
// })
//
// test('Test Skip Stcs button is enable', async ({ page }) => {
// const isSkipStcsEnable = await stcsPage.is_skipStcsButtonEnable();
// expect(isSkipStcsEnable).toBe(true);
// const certificate_title = await stcsPage.click_skipStcsButton();
// expect(certificate_title).toBe(CERTIFICATE_TITLE);
// })
//
//
// test('Test continue to certificate button is disable', async ({ page }) => {
// const is_ContinueButtonDisable = await stcsPage.isContinueButtonDisable();
// 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()
// await connectionPage.fillConnectionDetails(config.SSH_HOST, config.SSH_PORT, config.SSH_USER, config.SSH_PASSWD);
// await connectionPage.SubmitValidateCredential()
// const title = await stcsPage.returnTitleOfStcsPage();
// expect(title).toBe(STCS_TITLE);
// const ZoweValue = await stcsPage.get_zowe_value();
// const Zis_Value = await stcsPage.get_zis_value();
// const Aux_Value = await stcsPage.get_aux_value();
// const DatasetProclib_Value = await stcsPage.get_datasetProclib_value();
// expect(ZoweValue).toBe(config.SECURITY_STC_ZOWE);
// expect(Aux_Value).toBe(config.SECURITY_AUX);
// expect(Zis_Value).toBe(config.SECURITY_STC_ZIS);
// expect(DatasetProclib_Value).toBe(config.PROC_LIB);
// })
//
// 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);
// }
// // verify all checks are sucessfully checked
// const isWriteConfig_check_visible = await stcsPage.isWriteConfigGreenCheckVisible();
// expect(isWriteConfig_check_visible).toBe(true);
// const isUploadConfig_check_visible = await stcsPage.isUploadConfigGreenCheckVisible();
// expect(isUploadConfig_check_visible).toBe(true);
// const isInitStcs_check_visible = await stcsPage.isInitSTCSGreenCheckVisible();
// expect(isInitStcs_check_visible).toBe(true);
// const is_GreenCheck_Visible = await stcsPage.isStatusChecked();
// expect(is_GreenCheck_Visible).toBe(false);
// //verify continue Button enabled after init stcs//
// const is_ContinueButtonDisable = await stcsPage.isContinueButtonDisable();
// expect(is_ContinueButtonDisable).toBe(false);
// });

})
Loading

0 comments on commit b491434

Please sign in to comment.