From 4bba21a582fc121dbae7c87f6a9286eed638e07e Mon Sep 17 00:00:00 2001 From: hpathak Date: Mon, 2 Dec 2024 23:33:34 +0530 Subject: [PATCH 1/3] Added test for cert option1 Signed-off-by: hpathak --- playwright_test/Pages/certificates.page.ts | 361 ++++++++++++++++++++- playwright_test/Tests/Certificates.spec.ts | 283 ++++++++++++++++ 2 files changed, 636 insertions(+), 8 deletions(-) create mode 100644 playwright_test/Tests/Certificates.spec.ts diff --git a/playwright_test/Pages/certificates.page.ts b/playwright_test/Pages/certificates.page.ts index 12427e5..5814f18 100644 --- a/playwright_test/Pages/certificates.page.ts +++ b/playwright_test/Pages/certificates.page.ts @@ -1,17 +1,362 @@ -import { Page, Locator } from '@playwright/test'; +import { Page,ElectronApplication, Locator,_electron as electron } from '@playwright/test'; +let electronApp: ElectronApplication +import yaml from 'js-yaml'; -class CertificatesPage { +class CertificatesPage{ page: Page; - pageTitle: Locator; + click_CertificatePage: Locator; + CERTIFICATE_TITLE: Locator; + option1: Locator; + option1: Locator; + certificate_type: Locator; + click_dropdown: Locator; + keystore_directory: Locator; + certificate_alias_name: Locator; + keystore_password: Locator; + ca_alias: Locator; + ca_password: Locator; + lock: Locator; + import_keystore: Locator; + import_password: Locator; + import_alias: Locator; + ca_common_name: Locator; + common_name: Locator; + org_unit: Locator; + org_certificate: Locator; + locality_of_cert: Locator; + state_of_cert: Locator; + country_of_cert: Locator; + validity_of_cert: Locator; + san: Locator; + add_button: Locator; + delete_button: Locator; + import_certificate_authorities: Locator; + verify_certificates: Locator; + verify_certificates_dropdown: Locator; + verify_certificate_input: Locator; + skip_button: Locator; + vsamPage_title: Locator; + view_yaml: Locator; + viewJobOutput: Locator; + close_button: Locator; + editor_title_element: Locator; + add_importCert_button: Locator; + confirm_delete_alert: Locator; + dialog_description: locator; + viewAndSubmitJob: locator; + keystore_value: locator; + initcertificates: locator; + keystore_file_key : locator; + trustore_file_key: locator; + pem_certAuth_key: locator; + pem_cert_key: locator; + pem_key: locator; + sanInput: locator; + + + + + constructor(page: Page) { this.page = page; - this.pageTitle = page.locator("//div[@class='MuiBox-root css-la96ob']/div") + this.click_CertificatePage = page.locator('//span[text()="Certificates"]') + this.option1 = page.locator('//span[text()="Option 1"]') + this.option2 = page.locator('//span[text()="Option 2"]') + this.certificate_type = page.locator('//label[text()="Type"]') + this.click_dropdown = page.locator('//button[@title="Open"]') + this.keystore_directory = page.locator('//label[text()="Directory"]') + this.keystore_value = page.locator("//html/body/div[1]/div[2]/div/div[4]/div/form/div/div[2]/div[2]/div[2]/div/div[2]/div/div/div/div[1]/div/div[1]/div/div/input"); + this.certificate_alias_name = page.locator('//label[text()="Name"]') + this.keystore_password = page.locator('//label[text()="Password"]') + this.ca_alias = page.locator('//label[text()="Ca Alias"]') + this.ca_password = page.locator('//label[text()="Ca Password"]') + this.lock = page.locator('//span[text()="Lock"]') + this.import_keystore = page.locator('//label[text()="Keystore"]') + this.import_password = page.locator('//label[text()="Password"]') + this.import_alias = page.locator('//label[text()="Alias"]') + this.ca_common_name = page.locator('//label[text()="Ca Common Name"]') + this.common_name = page.locator('//label[text()="Common Name"]') + this.org_unit = page.locator('//label[text()="Org Unit"]') + this.org_certificate = page.locator('//label[text()="Org"]') + this.locality_of_cert = page.locator('//label[text()="Locality"]') + this.state_of_cert = page.locator('//label[text()="State"]') + this.country_of_cert = page.locator('//label[text()="Country"]') + this.validity_of_cert = page.locator('//label[text()="Validity"]') + this.san = page.locator('//h6[text()="San"]') + this.add_button = page.locator('//button[@aria-label="Add to San button"]') + this.add_importCert_button = page.locator('//button[@aria-label="Add to Import Certificate Authorities button"]') + this.delete_button = page.locator('//button[@aria-label="Delete button"]') + this.import_certificate_authorities = page.locator('//h6[text()="Import Certificate Authorities"]') + this.verify_certificates = page.locator('//p[text()="Verify Certificates"]') + this.verify_certificate_input = page.locator('//div[@aria-haspopup="listbox"]') + this.verify_certificates_dropdown = page.locator('//ul[@aria-labelledby="demo-simple-select-label"]') + this.confirm_delete_alert = page.locator('//h2[text()="Confirm Deletion"]') + this.dialog_description = page.locator('p#alert-dialog-confirmdelete-description') + this.viewAndSubmitJob = page.locator('//button[contains(text(), "View Job Output")]') + this.vsamPage_title = page.locator(' //div[text()="CachingService"]') + this.stcsTitle = page.locator(' //div[text()="Stcs"]') + this.keystore_file_key = page.locator('//div[span/span[@class="mtk22" and text()="keystore"]]/following-sibling::div[2]//span[@class="mtk5"]') + this.trustore_file_key = page.locator('//div[span/span[@class="mtk22" and text()="truststore"]]/following-sibling::div[2]//span[@class="mtk5"]') + this.pem_certAuth_key = page.locator('//div[span/span[@class="mtk22" and text()="pem"]]/following-sibling::div[3]//span[@class="mtk5"]') + this.pem_cert_key = page.locator('//div[span/span[@class="mtk22" and text()="pem"]]/following-sibling::div[2]//span[@class="mtk5"]') + this.pem_key = page.locator('//div[span/span[@class="mtk22" and text()="pem"]]/following-sibling::div[1]//span[@class="mtk5"]') + this.initcertificates = page.locator('//button[contains(text(),"Initialize Zowe Certificates")]') + this.writeConfig_greenCheckXpath = page.locator('//*[@id="box-download-progress-card"][1]') + this.uploadYaml_greenCheckXpath = page.locator('//*[@id="box-download-progress-card"][2]') + this.init_cert_greenCheckXpath = page.locator('//*[@id="box-install-progress-card"]') + this.sanInput = page.locator('//*[@id="container-box-id"]/form/div/div[2]/div[2]/div[5]/table/tbody/tr/td[1]/div/input') + this.click_lockCheckbox = page.locator('//input[@type="checkbox"]') + this.readYaml = page.locator('div.view-lines') + this.previous_step_button = page.locator('//button[contains(text(),"Previous step")]') + this.skip_button = page.locator('//button[contains(text(),"Skip")]') + this.editor_title_element = page.locator('//h2[text()="Editor"]') + this.CERTIFICATE_TITLE = page.locator('//div[text()="Certificates"]') + this.view_yaml = page.locator('//button[contains(text(),"View/Edit Yaml")]') + this.viewJobOutput = page.locator('//button[contains(text(), "View Job Output")]') + this.save_and_close = page.locator('//button[contains(text(),"Save & close")]') + this.previous_step = page.locator('//button[contains(text(),"Previous step")]') + this.close_button = page.locator('//button[contains(text(), "Close")]') + this.continue_CachingService = page.locator('//button[text()="Continue to Caching Service Setup"]') + } + + async movetoCertificatePage(){ + await this.click_CertificatePage.click({timeout: 5000}) + } + + async returnTitleOfCertiPage(){ + const certificate_title = await this.CERTIFICATE_TITLE.textContent(); + return certificate_title; + } + + async verifyCertificatesList(){ + await this.verify_certificate_input.click(); + await this.verify_certificates_dropdown.waitFor({ state: 'visible' }); + const items = await this.verify_certificates_dropdown.locator('li').allTextContents(); + return items; + } + + async select_VerifyCert(verifyCert:string){ + await this.page.waitForTimeout(1000); + await this.verify_certificate_input.click({timeout: 5000}); + await this.page.waitForTimeout(15000); + const itemLocator = this.page.locator(`//li[text()="${verifyCert}"]`); + await itemLocator.waitFor({ state: 'visible' }); + await itemLocator.click(); + } + + async viewYaml(){ + await this.view_yaml.click({ timeout: 5000 }) + } + async closeButton(){ + await this.close_button.click({ timeout: 2000 }) + } + async click_viewJobOutput(){ + await this.viewJobOutput.click({ timeout: 2000 }) + } + async click_previewJob(){ + await this.view_job_output.click({ timeout: 2000 }) + } + async is_skipCertificateButtonEnable(){ + return await this.skip_button.isEnabled({ timeout: 5000 }); + } + async add_SanButton() { + await this.page.evaluate(() => { + window.scrollTo(0, document.body.scrollHeight); + }); + await this.add_button.click({ timeout: 2000 }); + } + + async add_SanButton() { + await this.page.evaluate(() => { + window.scrollTo(0, document.body.scrollHeight); + }); + await this.add_button.click({ timeout: 2000 }); + } + + async add_SanDeleteButton() { + await this.page.evaluate(() => { + window.scrollTo(0, document.body.scrollHeight); + }); + const button = await this.delete_button.first().click({ timeout: 5000 }); + } + + async add_ImportCertDeleteButton() { + await this.page.evaluate(() => { + window.scrollTo(0, document.body.scrollHeight); + }); + const button = await this.delete_button.nth(2).click({ timeout: 5000 }); + } + + async isSanInputVisible(): Promise { + const san_Input = this.sanInput; + return await san_Input.isVisible({ timeout: 5000 }); + } + + async isImportCertInputVisible(): Promise { + const importCertInput = this.ImportCert_Input; + return await importCertInput.isVisible({ timeout: 5000 }); + } + + async add_ImportCertificateButton() { + await this.page.evaluate(() => { + window.scrollTo(0, document.body.scrollHeight); + }); + await this.add_importCert_button.click({ timeout: 2000 }); + } + + async is_deleteAlertVisible(): Promise { + const alertElement = await this.page.locator('div.MuiDialogContent-root p#alert-dialog-confirmdelete-description').first(); + await alertElement.waitFor({ state: 'visible', timeout: 5000 }); + return alertElement.isVisible(); + } + + async Verify_alertText(){ + const description = await this.dialog_description.first().textContent(); + return description; + } + + async accept_declinedAlert(action:string){ + const specificNoButton = this.page.locator(`//button[.='${action}']`).nth(0); + await specificNoButton.click({ timeout: 5000 }) + } + + async click_skipCertificate(){ + await this.skip_button.click({ timeout: 2000 }); + const Vsam_title = await this.vsamPage_title.textContent(); + return Vsam_title; + } + + async isPreviousButtonEnable(){ + return await this.previous_step_button.isEnabled({ timeout: 50000 }); + } + + async returnTitleOfPrevPage(){ + await this.previous_step_button.click({ timeout: 2000 }); + const stcs_title = await this.stcsTitle.textContent(); + return stcs_title; } - async getCertificatesPageTitle() { - await this.page.waitForTimeout(500); - return await this.pageTitle.textContent({ timeout: 2000 }); + async open_monacoEditor(){ + this.view_yaml.click({ timeout: 5000 }) + const editor_title = await this.editor_title_element.textContent(); + return editor_title; + } + + async isContinueButtonDisable(){ + return await this.continue_CachingService.isDisabled({ timeout: 5000 }); + } + + async click_viewAndSubmitJob(){ + await this.viewAndSubmitJob.click({ timeout: 6000 }) + } + async click_saveAndClose(){ + await this.save_and_close.click({ timeout: 2000 }) + } + async get_keystore_value(){ + const keystoreValue = await this.keystore_value.inputValue(); + console.log('value is', keystoreValue) + return keystoreValue; + } + + async isContinueButtonEnabled(){ + return await this.continue_CachingService.isEnabled(); + } + + async initializeCert(){ + await this.initcertificates.click() + await this.waitForContinueButtonToBeEnabled(); + } + + async isWriteConfigGreenCheckVisible(){ + return await this.writeConfig_greenCheckXpath.isVisible({ timeout: 50000 }); + } + async isUploadConfigGreenCheckVisible(){ + return await this.uploadYaml_greenCheckXpath.isVisible({ timeout: 50000 }); + } + async isInitCertGreenCheckVisible(){ + return await this.init_cert_greenCheckXpath.isVisible({ timeout: 50000 }); } + + async Lock_checkbox_Ischecked(){ + await this.click_lockCheckbox.click({ timeout: 5000 }); + + return await this.click_lockCheckbox.isChecked(); + + } + + + private async waitForContinueButtonToBeEnabled(): Promise { + const timeout = 50000000; + const interval = 500; + const endTime = Date.now() + timeout; + while (Date.now() < endTime) { + if (await this.isContinueButtonEnabled()) { + return; + } + await this.page.waitForTimeout(interval); + } + + throw new Error('Continue button was not enabled within the timeout period'); + } + + async read_yaml() { + let previousScrollHeight = 0; + let allText = ''; + + while (true) { + const newText = await this.page.evaluate(() => { + const viewLines = document.querySelectorAll('.view-lines .view-line'); + let text = ''; + viewLines.forEach((line) => { + text += line.textContent + '\n'; + }); + return text; + }); + allText += newText; + await this.page.evaluate(() => { + const editor = document.querySelector('.monaco-scrollable-element.editor-scrollable.vs'); + editor.scrollTop += 100; + }); + await this.page.waitForTimeout(1000); + const currentScrollHeight = await this.page.evaluate(() => { + const editor = document.querySelector('.monaco-scrollable-element.editor-scrollable.vs'); + return editor.scrollHeight; + }); + if (currentScrollHeight === previousScrollHeight) { + break; + } + previousScrollHeight = currentScrollHeight; + } + return allText; + } + + async fillKeystoreDir(dir: string): Promise { + try { + await this.keystore_directory.fill(dir, { timeout: 10000 }); + } catch (error) { + console.error('Error while filling Keystore directory:', error); + throw new Error('Failed to fill Keystore directory'); + } + } + + async updateEditorYaml(keyPath: string, newValue: string): Promise { + const editorLocator = this.page.locator('//*[@id="monaco-editor-container"]/div'); + await editorLocator.click(); + await this.page.keyboard.press('Control+F'); + await this.page.waitForTimeout(500); + + await this.page.keyboard.type(keyPath); + await this.page.waitForTimeout(500); + + await this.page.keyboard.press('Control+H'); + await this.page.waitForTimeout(500); + await this.page.keyboard.type(newValue); + + await this.page.keyboard.press('Control+Alt+Enter'); + await this.page.waitForTimeout(5000); + + console.log(`Replaced all appearances of "${keyPath}" with "${newValue}"`); + } } -export default CertificatesPage; \ No newline at end of file +export default CertificatesPage; diff --git a/playwright_test/Tests/Certificates.spec.ts b/playwright_test/Tests/Certificates.spec.ts new file mode 100644 index 0000000..4b76743 --- /dev/null +++ b/playwright_test/Tests/Certificates.spec.ts @@ -0,0 +1,283 @@ +import { test, ElectronApplication, expect, _electron as electron } from '@playwright/test'; +import { prepareEnvironment } from '../prepare.js'; +import ApfAuthPage from '../Pages/ApfAuth.page'; +import TitlePage from '../Pages/title.page'; +import ConnectionPage from '../Pages/connection.page'; +import PlanningPage from '../Pages/planning.page'; +import InstallationTypePage from '../Pages/installationType.page'; +import InstallationPage from '../Pages/installation.page.ts'; +import NetworkingPage from '../Pages/networking.page'; +import CertificatePage from '../Pages/Certificates.page'; +import config from '../utils/config'; +import { spawn } from 'child_process'; +import path from 'path'; +import { connectArgs, Script } from '../setup'; +let page: Page; + + +let electronApp: ElectronApplication +const CERTIFICATE_TITLE ='Certificates' +const VSAM_TITLE = 'CachingService' +const STCS_TITLE = 'Stcs' +const INSTALLATION_TITLE = 'Installation' +const SECURITY_TITLE = 'Security' +const VERIFY_CERTIFICATE_LIST = ['STRICT', 'NONSTRICT', 'DISABLED'] +const values = [ + config.ZOWE_ROOT_DIR + '/keystore/localhost/localhost.keystore.p12', + config.ZOWE_ROOT_DIR + '/keystore/localhost/localhost.truststore.p12', + config.ZOWE_ROOT_DIR + '/keystore/localhost/localhost.key', + config.ZOWE_ROOT_DIR + '/keystore/localhost/localhost.cer', + config.ZOWE_ROOT_DIR + '/keystore/local_ca/local_ca.cer', + ]; +const script = new Script() + + + +test.beforeAll(async () => { + test.setTimeout(600000); + try { + await prepareEnvironment({ install: true, cleanup: true, remove: false }); + } catch (error) { + console.error('Error during environment preparation:', error); + process.exit(1); + } +}); + + +test.describe('CertificateTab', () => { + let connectionPage: ConnectionPage; + let titlePage : TitlePage; + let apfAuthPage : ApfAuthPage; + let planningPage : PlanningPage; + let installationTypePage : InstallationTypePage; + let installationPage : InstallationPage; + let networkingPage : NetworkingPage; + let certificatePage : CertificatePage; + test.beforeEach(async ({ page }) => { + test.setTimeout(900000); + electronApp = await electron.launch({ args: ['.webpack/main/index.js'] }) + page = await electronApp.firstWindow() + connectionPage = new ConnectionPage(page); + titlePage = new TitlePage(page); + planningPage = new PlanningPage(page) + apfAuthPage = new ApfAuthPage(page); + installationTypePage = new InstallationTypePage(page); + installationPage = new InstallationPage(page); + networkingPage = new NetworkingPage(page); + certificatePage = new CertificatePage(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, + 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 installationPage.clickContinueToNetworkSetup(); + await certificatePage.movetoCertificatePage(); + + }) + + test.afterEach(async () => { + await electronApp.close() + }) + + test('test title of page & required fields', async ({ page }) => { + await page.waitForTimeout(5000); + const title = await certificatePage.returnTitleOfCertiPage(); + expect(title).toBe(CERTIFICATE_TITLE); + await expect(certificatePage.option1).toBeTruthy() + await expect(certificatePage.option2).toBeTruthy() + await expect(certificatePage.keystore_directory).toBeTruthy() + await expect(certificatePage.certificate_alias_name).toBeTruthy() + await expect(certificatePage.keystore_password).toBeTruthy() + await expect(certificatePage.ca_alias).toBeTruthy() + await expect(certificatePage.ca_password).toBeTruthy() + await expect(certificatePage.lock).toBeTruthy() + await expect(certificatePage.import_keystore).toBeTruthy() + await expect(certificatePage.import_password).toBeTruthy() + await expect(certificatePage.import_alias).toBeTruthy() + await expect(certificatePage.ca_common_name).toBeTruthy() + await expect(certificatePage.common_name).toBeTruthy() + await expect(certificatePage.org_unit).toBeTruthy() + await expect(certificatePage.org_certificate).toBeTruthy() + await expect(certificatePage.locality_of_cert).toBeTruthy() + await expect(certificatePage.state_of_cert).toBeTruthy() + await expect(certificatePage.country_of_cert).toBeTruthy() + await expect(certificatePage.validity_of_cert).toBeTruthy() + await expect(certificatePage.san).toBeTruthy() + await expect(certificatePage.import_certificate_authorities).toBeTruthy() + await expect(certificatePage.verify_certificates).toBeTruthy() + }) + + test('Test Skip certificate button is enable', async ({ page }) => { + const isLaunchConfigEnable = await certificatePage.is_skipCertificateButtonEnable(); + expect(isLaunchConfigEnable).toBe(true); + const title = await certificatePage.click_skipCertificate(); + expect(title).toBe(VSAM_TITLE); + }) + test('Test view yaml button', async ({ page }) => { + await certificatePage.viewYaml() + await expect(certificatePage.editor_title_element).toBeTruthy(); + await certificatePage.closeButton() + }) + test('test all available options for verify certificates', async ({ page }) => { + await page.waitForTimeout(5000); + const verifyList = await certificatePage.verifyCertificatesList(); + expect(verifyList).toEqual(VERIFY_CERTIFICATE_LIST); + }) + + test('test verify delete & add san button', async ({ page }) => { + await certificatePage.add_SanButton(); + const isSanInputVisible1 = await certificatePage.isSanInputVisible(); + await expect(isSanInputVisible1).toBe(true); + await certificatePage.add_SanDeleteButton(); + const isVisible = await certificatePage.is_deleteAlertVisible(); + await expect(isVisible).toBe(true); + const alertText = await certificatePage.Verify_alertText(); + expect(alertText).toBe("Are you sure you want to delete the selected entry?"); + await certificatePage.accept_declinedAlert('Yes'); + const isSanInputVisible2 = await certificatePage.isSanInputVisible(); + await expect(isSanInputVisible2).toBe(false); + }); + + test('Click Previous Step and verify that the Previous button is enabled.', async ({ page }) => { + const is_prevButtonEnable = await certificatePage.isPreviousButtonEnable(); + expect(is_prevButtonEnable).toBe(true); + const title = await certificatePage.returnTitleOfPrevPage(); + expect(title).toBe(STCS_TITLE); + }); + + + test('test continue button is disable', async ({ page }) => { + const is_ContinueButtonDisable = await certificatePage.isContinueButtonDisable(); + await expect(is_ContinueButtonDisable).toBe(true); + }); + + + test('Test view job output button', async ({ page }) => { + await certificatePage.click_viewAndSubmitJob() + await expect(certificatePage.editor_title_element).toBeTruthy() + await certificatePage.closeButton() + }); + + + test('Test save and close and Resume Progress', async ({ page }) => { + await certificatePage.fillKeystoreDir(config.ZOWE_ROOT_DIR + '/keystore'); + await page.waitForTimeout(5000); + certificatePage.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 certificatePage.returnTitleOfCertiPage(); + await expect(title).toBe(CERTIFICATE_TITLE); + const keystoreValue = await certificatePage.get_keystore_value(); + await expect(keystoreValue).toBe(config.ZOWE_ROOT_DIR + '/keystore'); + }); + + +test('Test init certificates with NONSTRICT Mode & verify keystore dir created sucessfully', async ({ page }) => { + await script.runCommand(`chmod -R 777 ${process.env.ZOWE_ROOT_DIR}/keystore && + rm -r ${process.env.ZOWE_ROOT_DIR}/keystore`); + await certificatePage.viewYaml(); + await expect(certificatePage.editor_title_element).toBeTruthy(); + await certificatePage.updateEditorYaml('/global/zowe', config.ZOWE_ROOT_DIR); + await certificatePage.closeButton(); + await certificatePage.viewYaml(); + const valueExists = await certificatePage.read_yaml(); + for (const value of values) { + await expect(valueExists).toContain(value); + + } + await certificatePage.closeButton(); + await certificatePage.fillKeystoreDir(`${config.ZOWE_ROOT_DIR}/keystore`); + await certificatePage.select_VerifyCert('NONSTRICT'); + + await certificatePage.initializeCert(); + const isWriteConfigCheckVisible = await certificatePage.isWriteConfigGreenCheckVisible(); + await expect(isWriteConfigCheckVisible).toBe(true); + const isUploadConfigCheckVisible = await certificatePage.isUploadConfigGreenCheckVisible(); + await expect(isUploadConfigCheckVisible).toBe(true); + const isInitCertCheckVisible = await certificatePage.isInitCertGreenCheckVisible(); + await expect(isInitCertCheckVisible).toBe(true); + const is_ContinueButtonDisable = await certificatePage.isContinueButtonDisable(); + await expect(is_ContinueButtonDisable).toBe(false); + const result = await script.runCommand(`ls -lt ${process.env.ZOWE_ROOT_DIR}`); + await expect(result.details).toContain('keystore'); +}); + +test('Test init certificates with Disabled Mode and verify certificates configured sucessfully on Z/os', async ({ page }) => { + await script.runCommand(`chmod -R 777 ${process.env.ZOWE_ROOT_DIR}/keystore && + rm -r ${process.env.ZOWE_ROOT_DIR}/keystore`); + await certificatePage.viewYaml(); + await expect(certificatePage.editor_title_element).toBeTruthy(); + await certificatePage.updateEditorYaml('/global/zowe', config.ZOWE_ROOT_DIR); + await certificatePage.closeButton(); + await certificatePage.viewYaml(); + const valueExists = await certificatePage.read_yaml(); + for (const value of values) { + await expect(valueExists).toContain(value); + + } + await certificatePage.closeButton(); + await certificatePage.fillKeystoreDir(`${config.ZOWE_ROOT_DIR}/keystore`); + await page.waitForTimeout(5000); + await certificatePage.select_VerifyCert('DISABLED'); + + await page.waitForTimeout(5000); + await certificatePage.initializeCert(); + const isWriteConfigCheckVisible = await certificatePage.isWriteConfigGreenCheckVisible(); + await expect(isWriteConfigCheckVisible).toBe(true); + const isUploadConfigCheckVisible = await certificatePage.isUploadConfigGreenCheckVisible(); + await expect(isUploadConfigCheckVisible).toBe(true); + const isInitCertCheckVisible = await certificatePage.isInitCertGreenCheckVisible(); + await expect(isInitCertCheckVisible).toBe(true); + const is_ContinueButtonDisable = await certificatePage.isContinueButtonDisable(); + await expect(is_ContinueButtonDisable).toBe(false); + const result = await script.runCommand(`cat ${process.env.ZOWE_ROOT_DIR}/zowe.yaml`); + for (const value of values) { + await expect(result.details).toContain(value); + } +}); + +test('Test init certificates with Lock keystore dir', async ({ page }) => { + await script.runCommand(`chmod -R 777 ${process.env.ZOWE_ROOT_DIR}/keystore && + rm -r ${process.env.ZOWE_ROOT_DIR}/keystore`); + await certificatePage.viewYaml(); + await expect(certificatePage.editor_title_element).toBeTruthy(); + await certificatePage.updateEditorYaml('/global/zowe', config.ZOWE_ROOT_DIR); + await certificatePage.closeButton(); + await certificatePage.fillKeystoreDir(`${config.ZOWE_ROOT_DIR}/keystore`); + const isChecked = await certificatePage.Lock_checkbox_Ischecked(); + expect(isChecked).toBe(true); + await page.waitForTimeout(5000); + await certificatePage.select_VerifyCert('DISABLED'); + await certificatePage.initializeCert(); + const is_ContinueButtonDisable = await certificatePage.isContinueButtonDisable(); + await expect(is_ContinueButtonDisable).toBe(false); + const result = await script.runCommand(`ls -ld ${process.env.ZOWE_ROOT_DIR}/keystore | awk '{print $1}'`); + await expect(result.details).toContain('dr-x------'); +}); + +}); + From 80d26e0b4b9405ad355d38f4c1681a7278c54273 Mon Sep 17 00:00:00 2001 From: hpathak Date: Mon, 2 Dec 2024 23:37:27 +0530 Subject: [PATCH 2/3] minor change Signed-off-by: hpathak --- playwright_test/Pages/certificates.page.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/playwright_test/Pages/certificates.page.ts b/playwright_test/Pages/certificates.page.ts index 5814f18..ca829ca 100644 --- a/playwright_test/Pages/certificates.page.ts +++ b/playwright_test/Pages/certificates.page.ts @@ -4,6 +4,7 @@ import yaml from 'js-yaml'; class CertificatesPage{ page: Page; + pageTitle: Locator; click_CertificatePage: Locator; CERTIFICATE_TITLE: Locator; option1: Locator; @@ -118,12 +119,18 @@ class CertificatesPage{ this.previous_step = page.locator('//button[contains(text(),"Previous step")]') this.close_button = page.locator('//button[contains(text(), "Close")]') this.continue_CachingService = page.locator('//button[text()="Continue to Caching Service Setup"]') + this.pageTitle = page.locator("//div[@class='MuiBox-root css-la96ob']/div") } async movetoCertificatePage(){ await this.click_CertificatePage.click({timeout: 5000}) } + async getCertificatesPageTitle() { + await this.page.waitForTimeout(500); + return await this.pageTitle.textContent({ timeout: 2000 }); + } + async returnTitleOfCertiPage(){ const certificate_title = await this.CERTIFICATE_TITLE.textContent(); return certificate_title; From 98c4612a6d3d0101c85775bea8838a6b8f7d4605 Mon Sep 17 00:00:00 2001 From: hpathak Date: Thu, 5 Dec 2024 19:49:52 +0530 Subject: [PATCH 3/3] removed unwanted waits Signed-off-by: hpathak --- playwright_test/Tests/Certificates.spec.ts | 165 +++++++++------------ 1 file changed, 74 insertions(+), 91 deletions(-) diff --git a/playwright_test/Tests/Certificates.spec.ts b/playwright_test/Tests/Certificates.spec.ts index 4b76743..647e544 100644 --- a/playwright_test/Tests/Certificates.spec.ts +++ b/playwright_test/Tests/Certificates.spec.ts @@ -102,98 +102,83 @@ test.describe('CertificateTab', () => { await electronApp.close() }) - test('test title of page & required fields', async ({ page }) => { - await page.waitForTimeout(5000); - const title = await certificatePage.returnTitleOfCertiPage(); - expect(title).toBe(CERTIFICATE_TITLE); - await expect(certificatePage.option1).toBeTruthy() - await expect(certificatePage.option2).toBeTruthy() - await expect(certificatePage.keystore_directory).toBeTruthy() - await expect(certificatePage.certificate_alias_name).toBeTruthy() - await expect(certificatePage.keystore_password).toBeTruthy() - await expect(certificatePage.ca_alias).toBeTruthy() - await expect(certificatePage.ca_password).toBeTruthy() - await expect(certificatePage.lock).toBeTruthy() - await expect(certificatePage.import_keystore).toBeTruthy() - await expect(certificatePage.import_password).toBeTruthy() - await expect(certificatePage.import_alias).toBeTruthy() - await expect(certificatePage.ca_common_name).toBeTruthy() - await expect(certificatePage.common_name).toBeTruthy() - await expect(certificatePage.org_unit).toBeTruthy() - await expect(certificatePage.org_certificate).toBeTruthy() - await expect(certificatePage.locality_of_cert).toBeTruthy() - await expect(certificatePage.state_of_cert).toBeTruthy() - await expect(certificatePage.country_of_cert).toBeTruthy() - await expect(certificatePage.validity_of_cert).toBeTruthy() - await expect(certificatePage.san).toBeTruthy() - await expect(certificatePage.import_certificate_authorities).toBeTruthy() - await expect(certificatePage.verify_certificates).toBeTruthy() - }) + test('test title of page & required fields', async ({ page }) => { + const title = await certificatePage.returnTitleOfCertiPage(); + expect(title).toBe(CERTIFICATE_TITLE); + await expect(certificatePage.option1).toBeTruthy() + await expect(certificatePage.option2).toBeTruthy() + await expect(certificatePage.keystore_directory).toBeTruthy() + await expect(certificatePage.certificate_alias_name).toBeTruthy() + await expect(certificatePage.keystore_password).toBeTruthy() + await expect(certificatePage.ca_alias).toBeTruthy() + await expect(certificatePage.ca_password).toBeTruthy() + await expect(certificatePage.lock).toBeTruthy() + await expect(certificatePage.import_keystore).toBeTruthy() + await expect(certificatePage.import_password).toBeTruthy() + await expect(certificatePage.import_alias).toBeTruthy() + await expect(certificatePage.ca_common_name).toBeTruthy() + await expect(certificatePage.common_name).toBeTruthy() + await expect(certificatePage.org_unit).toBeTruthy() + await expect(certificatePage.org_certificate).toBeTruthy() + await expect(certificatePage.locality_of_cert).toBeTruthy() + await expect(certificatePage.state_of_cert).toBeTruthy() + await expect(certificatePage.country_of_cert).toBeTruthy() + await expect(certificatePage.validity_of_cert).toBeTruthy() + await expect(certificatePage.san).toBeTruthy() + await expect(certificatePage.import_certificate_authorities).toBeTruthy() + await expect(certificatePage.verify_certificates).toBeTruthy() + const verifyList = await certificatePage.verifyCertificatesList(); + expect(verifyList).toEqual(VERIFY_CERTIFICATE_LIST); + }) - test('Test Skip certificate button is enable', async ({ page }) => { - const isLaunchConfigEnable = await certificatePage.is_skipCertificateButtonEnable(); - expect(isLaunchConfigEnable).toBe(true); - const title = await certificatePage.click_skipCertificate(); - expect(title).toBe(VSAM_TITLE); - }) - test('Test view yaml button', async ({ page }) => { - await certificatePage.viewYaml() - await expect(certificatePage.editor_title_element).toBeTruthy(); - await certificatePage.closeButton() - }) - test('test all available options for verify certificates', async ({ page }) => { - await page.waitForTimeout(5000); - const verifyList = await certificatePage.verifyCertificatesList(); - expect(verifyList).toEqual(VERIFY_CERTIFICATE_LIST); - }) - - test('test verify delete & add san button', async ({ page }) => { - await certificatePage.add_SanButton(); - const isSanInputVisible1 = await certificatePage.isSanInputVisible(); - await expect(isSanInputVisible1).toBe(true); - await certificatePage.add_SanDeleteButton(); - const isVisible = await certificatePage.is_deleteAlertVisible(); - await expect(isVisible).toBe(true); - const alertText = await certificatePage.Verify_alertText(); - expect(alertText).toBe("Are you sure you want to delete the selected entry?"); - await certificatePage.accept_declinedAlert('Yes'); - const isSanInputVisible2 = await certificatePage.isSanInputVisible(); - await expect(isSanInputVisible2).toBe(false); - }); - - test('Click Previous Step and verify that the Previous button is enabled.', async ({ page }) => { - const is_prevButtonEnable = await certificatePage.isPreviousButtonEnable(); - expect(is_prevButtonEnable).toBe(true); - const title = await certificatePage.returnTitleOfPrevPage(); - expect(title).toBe(STCS_TITLE); - }); - - - test('test continue button is disable', async ({ page }) => { - const is_ContinueButtonDisable = await certificatePage.isContinueButtonDisable(); - await expect(is_ContinueButtonDisable).toBe(true); - }); +test('Test Skip certificate button is enable', async ({ page }) => { + const isLaunchConfigEnable = await certificatePage.is_skipCertificateButtonEnable(); + expect(isLaunchConfigEnable).toBe(true); + const title = await certificatePage.click_skipCertificate(); + expect(title).toBe(VSAM_TITLE); +}) +test('Test view yaml & view job output button', async ({ page }) => { + await certificatePage.viewYaml() + await expect(certificatePage.editor_title_element).toBeTruthy(); + await certificatePage.closeButton() + await certificatePage.click_viewAndSubmitJob() + await expect(certificatePage.editor_title_element).toBeTruthy() + await certificatePage.closeButton() + }) - test('Test view job output button', async ({ page }) => { - await certificatePage.click_viewAndSubmitJob() - await expect(certificatePage.editor_title_element).toBeTruthy() - await certificatePage.closeButton() - }); +test('test verify delete & add san button', async ({ page }) => { + await certificatePage.add_SanButton(); + const isSanInputVisible1 = await certificatePage.isSanInputVisible(); + await expect(isSanInputVisible1).toBe(true); + await certificatePage.add_SanDeleteButton(); + const isVisible = await certificatePage.is_deleteAlertVisible(); + await expect(isVisible).toBe(true); + const alertText = await certificatePage.Verify_alertText(); + expect(alertText).toBe("Are you sure you want to delete the selected entry?"); + await certificatePage.accept_declinedAlert('Yes'); + const isSanInputVisible2 = await certificatePage.isSanInputVisible(); + await expect(isSanInputVisible2).toBe(false); + }); +test('Click Previous Step and verify that the Previous button is enabled.', async ({ page }) => { + const is_prevButtonEnable = await certificatePage.isPreviousButtonEnable(); + expect(is_prevButtonEnable).toBe(true); + const title = await certificatePage.returnTitleOfPrevPage(); + expect(title).toBe(STCS_TITLE); +}); - test('Test save and close and Resume Progress', async ({ page }) => { - await certificatePage.fillKeystoreDir(config.ZOWE_ROOT_DIR + '/keystore'); - await page.waitForTimeout(5000); - certificatePage.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 certificatePage.returnTitleOfCertiPage(); - await expect(title).toBe(CERTIFICATE_TITLE); - const keystoreValue = await certificatePage.get_keystore_value(); - await expect(keystoreValue).toBe(config.ZOWE_ROOT_DIR + '/keystore'); - }); +test('Test save and close and Resume Progress', async ({ page }) => { + await certificatePage.fillKeystoreDir(config.ZOWE_ROOT_DIR + '/keystore'); + certificatePage.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 certificatePage.returnTitleOfCertiPage(); + await expect(title).toBe(CERTIFICATE_TITLE); + const keystoreValue = await certificatePage.get_keystore_value(); + await expect(keystoreValue).toBe(config.ZOWE_ROOT_DIR + '/keystore'); + }); test('Test init certificates with NONSTRICT Mode & verify keystore dir created sucessfully', async ({ page }) => { @@ -212,7 +197,8 @@ test('Test init certificates with NONSTRICT Mode & verify keystore dir created s await certificatePage.closeButton(); await certificatePage.fillKeystoreDir(`${config.ZOWE_ROOT_DIR}/keystore`); await certificatePage.select_VerifyCert('NONSTRICT'); - + const isBtnDisabledBeforeInit = await certificatePage.isContinueButtonDisable(); + await expect(isBtnDisabledBeforeInit).toBe(true); await certificatePage.initializeCert(); const isWriteConfigCheckVisible = await certificatePage.isWriteConfigGreenCheckVisible(); await expect(isWriteConfigCheckVisible).toBe(true); @@ -241,10 +227,8 @@ test('Test init certificates with Disabled Mode and verify certificates configur } await certificatePage.closeButton(); await certificatePage.fillKeystoreDir(`${config.ZOWE_ROOT_DIR}/keystore`); - await page.waitForTimeout(5000); await certificatePage.select_VerifyCert('DISABLED'); - await page.waitForTimeout(5000); await certificatePage.initializeCert(); const isWriteConfigCheckVisible = await certificatePage.isWriteConfigGreenCheckVisible(); await expect(isWriteConfigCheckVisible).toBe(true); @@ -270,7 +254,6 @@ test('Test init certificates with Lock keystore dir', async ({ page }) => { await certificatePage.fillKeystoreDir(`${config.ZOWE_ROOT_DIR}/keystore`); const isChecked = await certificatePage.Lock_checkbox_Ischecked(); expect(isChecked).toBe(true); - await page.waitForTimeout(5000); await certificatePage.select_VerifyCert('DISABLED'); await certificatePage.initializeCert(); const is_ContinueButtonDisable = await certificatePage.isContinueButtonDisable();