From 1a3101950f02aa7948f2f5be9c5eb0f01a26bc47 Mon Sep 17 00:00:00 2001 From: sagar-1310 Date: Thu, 7 Nov 2024 01:50:23 +0530 Subject: [PATCH] Updated tests as per the suggestions Signed-off-by: sagar-1310 --- playwright_test/Pages/certificates.page.ts | 5 +- playwright_test/Pages/common.page.ts | 38 -------------- playwright_test/Pages/review.page.ts | 60 +++++++++++----------- playwright_test/Pages/stcs.page.ts | 4 +- playwright_test/Pages/vsam.page.ts | 6 +-- playwright_test/Tests/Review.spec.ts | 37 ++++++------- 6 files changed, 49 insertions(+), 101 deletions(-) delete mode 100644 playwright_test/Pages/common.page.ts diff --git a/playwright_test/Pages/certificates.page.ts b/playwright_test/Pages/certificates.page.ts index 359c8d4..12427e5 100644 --- a/playwright_test/Pages/certificates.page.ts +++ b/playwright_test/Pages/certificates.page.ts @@ -1,5 +1,4 @@ import { Page, Locator } from '@playwright/test'; -import CommonPage from './common.page'; class CertificatesPage { page: Page; @@ -10,10 +9,8 @@ class CertificatesPage { this.pageTitle = page.locator("//div[@class='MuiBox-root css-la96ob']/div") } - commonPage = new CommonPage(); - async getCertificatesPageTitle() { - await this.commonPage.waitForElement(this.pageTitle) + await this.page.waitForTimeout(500); return await this.pageTitle.textContent({ timeout: 2000 }); } } diff --git a/playwright_test/Pages/common.page.ts b/playwright_test/Pages/common.page.ts deleted file mode 100644 index 0c93fd0..0000000 --- a/playwright_test/Pages/common.page.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { Page, Locator, expect } from '@playwright/test'; - -class CommonPage { - page: Page; - - async getElementValue(element: Locator) { - const elementValue = await element.getAttribute('value') - return elementValue - } - - async isElementHasValue(element: Locator): Promise { - const elementValue = await element.getAttribute('value') - if (elementValue !== null && elementValue !== '') { - return true - } else { - return false - } - } - - async validateElementValue(textBoxLocator: Locator, expectedValue: string): Promise { - const insertedValue = await textBoxLocator.inputValue(); - return insertedValue === expectedValue; - } - - async waitForElement(locator: Locator) { - try { - await this.page.waitForTimeout(1000); - await locator.waitFor({ state: 'visible', timeout: 10000 }); - } catch (error) { - console.error('Error while checking visibility of locator', error); - return false; - } - await this.page.waitForTimeout(2000); - } - -} - -export default CommonPage; \ No newline at end of file diff --git a/playwright_test/Pages/review.page.ts b/playwright_test/Pages/review.page.ts index 7ed00de..efbca43 100644 --- a/playwright_test/Pages/review.page.ts +++ b/playwright_test/Pages/review.page.ts @@ -1,5 +1,4 @@ import { Page, Locator } from '@playwright/test'; -import CommonPage from './common.page'; class ReviewPage { page: Page; @@ -18,8 +17,8 @@ class ReviewPage { cachingServiceTab: Locator; launchConfigTab: Locator; connectionTabSuccessfulIcon: Locator; - planningTabSuccessfulIcon: Locator; - installationTypeTabSuccessfulIcon: Locator; + planningTabPendingIcon: Locator; + installationTypeTabPendingIcon: Locator; initializationTabPendingIcon: Locator; installationTabPendingIcon: Locator; networkingTabPendingIcon: Locator; @@ -34,6 +33,7 @@ class ReviewPage { finishInstallation: Locator; editorTitleElement: Locator; closeEditorButton: Locator; + readOnlyEditor: Locator constructor(page: Page) { this.page = page; @@ -52,8 +52,8 @@ class ReviewPage { this.cachingServiceTab = page.locator("//p[text()='Caching Service']") this.launchConfigTab = page.locator("//p[text()='Launch Config']") this.connectionTabSuccessfulIcon = page.locator("//p[text()='Connection']/following-sibling::*[@data-testid='CheckCircleIcon']") - this.planningTabSuccessfulIcon = page.locator("//p[text()='Planning']/following-sibling::*[@data-testid='CheckCircleIcon']") - this.installationTypeTabSuccessfulIcon = page.locator("//p[text()='Installation Type']/following-sibling::*[@data-testid='CheckCircleIcon']") + this.planningTabPendingIcon = page.locator("//p[text()='Planning']/following-sibling::*[@data-testid='WarningIcon']") + this.installationTypeTabPendingIcon = page.locator("//p[text()='Installation Type']/following-sibling::*[@data-testid='WarningIcon']") this.initializationTabPendingIcon = page.locator("//p[text()='Initialization']/following-sibling::*[@data-testid='WarningIcon']") this.installationTabPendingIcon = page.locator("//p[text()='Installation']/following-sibling::*[@data-testid='WarningIcon']") this.networkingTabPendingIcon = page.locator("//p[text()='Networking']/following-sibling::*[@data-testid='WarningIcon']") @@ -68,123 +68,121 @@ class ReviewPage { this.finishInstallation = page.locator("//button[text()='Finish Installation']") this.editorTitleElement = page.locator("//h2[text()='Editor']") this.closeEditorButton = page.locator("//button[text()='Close']") + this.readOnlyEditor = page.locator("//h2[text()='Editor']/following-sibling::div[1]//div[@class='view-lines monaco-mouse-cursor-text']/div[1]") } - commonPage = new CommonPage(); - async getReviewPageTitle() { - await this.commonPage.waitForElement(this.pageTitle) + await this.page.waitForTimeout(500); return await this.pageTitle.textContent({ timeout: 2000 }); } async clickReviewInstallationTab() { - await this.commonPage.waitForElement(this.reviewInstallationTab) + await this.page.waitForTimeout(500); await this.reviewInstallationTab.click(); } async clickConnectionTab() { - await this.commonPage.waitForElement(this.connectionTab) + await this.page.waitForTimeout(500); await this.connectionTab.click(); } async clickPlanningTab() { - await this.commonPage.waitForElement(this.planningTab) + await this.page.waitForTimeout(500); await this.planningTab.click(); } async clickInstallationTypeTab() { - await this.commonPage.waitForElement(this.installationTypeTab) + await this.page.waitForTimeout(500); await this.installationTypeTab.click(); } async clickInstallationTab() { - await this.commonPage.waitForElement(this.installationTab) + await this.page.waitForTimeout(500); await this.installationTab.click(); } async clickNetworkingTab() { - await this.commonPage.waitForElement(this.networkingTab) + await this.page.waitForTimeout(500); await this.networkingTab.click(); } async clickApfAuthTab() { - await this.commonPage.waitForElement(this.apfAuthTab) + await this.page.waitForTimeout(500); await this.apfAuthTab.click(); } async clickSecurityTab() { - await this.commonPage.waitForElement(this.securityTab) + await this.page.waitForTimeout(500); await this.securityTab.click(); } async clickStcsTab() { - await this.commonPage.waitForElement(this.stcsTab) + await this.page.waitForTimeout(500); await this.stcsTab.click(); } async clickCertificatesTab() { - await this.commonPage.waitForElement(this.certificatesTab) + await this.page.waitForTimeout(500); await this.certificatesTab.click(); } async clickCachingServiceTab() { - await this.commonPage.waitForElement(this.cachingServiceTab) + await this.page.waitForTimeout(500); await this.cachingServiceTab.click(); } async clickLaunchConfigTab() { - await this.commonPage.waitForElement(this.launchConfigTab) + await this.page.waitForTimeout(500); await this.launchConfigTab.click(); } async clickViewEditYaml() { - await this.commonPage.waitForElement(this.viewEditYaml) + await this.page.waitForTimeout(500); await this.viewEditYaml.click(); } async clickViewJobOutput() { - await this.commonPage.waitForElement(this.viewJobOutput) + await this.page.waitForTimeout(500); await this.viewJobOutput.click(); await this.page.waitForTimeout(2000); } async clickSaveAndClose() { - await this.commonPage.waitForElement(this.saveAndClose) + await this.page.waitForTimeout(500); await this.saveAndClose.click({ timeout: 2000 }); } async clickPreviousStep() { - await this.commonPage.waitForElement(this.previousStep) + await this.page.waitForTimeout(500); await this.previousStep.click(); } async clickFinishInstallation() { - await this.commonPage.waitForElement(this.finishInstallation) + await this.page.waitForTimeout(500); await this.finishInstallation.click(); } async isFinishInstallationDisabled() { - await this.commonPage.waitForElement(this.finishInstallation) + await this.page.waitForTimeout(500); return await this.finishInstallation.isDisabled() } async isFinishInstallationEnabled() { - await this.commonPage.waitForElement(this.finishInstallation) + await this.page.waitForTimeout(500); return await this.finishInstallation.isEnabled() } async open_monacoEditor() { - await this.commonPage.waitForElement(this.viewEditYaml) + await this.page.waitForTimeout(500); this.viewEditYaml.click({ timeout: 2000 }) - await this.commonPage.waitForElement(this.editorTitleElement) + await this.page.waitForTimeout(500); const editor_title = await this.editorTitleElement.textContent(); return editor_title; } async clickCloseEditor() { - await this.commonPage.waitForElement(this.closeEditorButton) + await this.page.waitForTimeout(500); await this.closeEditorButton.click(); } - } export default ReviewPage; diff --git a/playwright_test/Pages/stcs.page.ts b/playwright_test/Pages/stcs.page.ts index 5083a6e..d93eec1 100644 --- a/playwright_test/Pages/stcs.page.ts +++ b/playwright_test/Pages/stcs.page.ts @@ -1,5 +1,4 @@ import { Page, Locator } from '@playwright/test'; -import CommonPage from './common.page'; class StcsPage { page: Page; @@ -10,10 +9,9 @@ class StcsPage { this.pageTitle = page.locator("//div[@class='MuiBox-root css-la96ob']/div") } - commonPage = new CommonPage(); async getStcsPageTitle() { - await this.commonPage.waitForElement(this.pageTitle) + await this.page.waitForTimeout(500); return await this.pageTitle.textContent({ timeout: 2000 }); } } diff --git a/playwright_test/Pages/vsam.page.ts b/playwright_test/Pages/vsam.page.ts index 23d060e..543ea86 100644 --- a/playwright_test/Pages/vsam.page.ts +++ b/playwright_test/Pages/vsam.page.ts @@ -1,5 +1,4 @@ import { Page, Locator } from '@playwright/test'; -import CommonPage from './common.page'; class VsamPage { page: Page; @@ -9,11 +8,8 @@ class VsamPage { this.page = page; this.pageTitle = page.locator("//div[@class='MuiBox-root css-la96ob']/div") } - - commonPage = new CommonPage(); - async getVsamPageTitle() { - await this.commonPage.waitForElement(this.pageTitle) + await this.page.waitForTimeout(500); return await this.pageTitle.textContent({ timeout: 2000 }); } } diff --git a/playwright_test/Tests/Review.spec.ts b/playwright_test/Tests/Review.spec.ts index 133ed29..7d197bb 100644 --- a/playwright_test/Tests/Review.spec.ts +++ b/playwright_test/Tests/Review.spec.ts @@ -53,7 +53,7 @@ test.describe('ReviewTab', () => { } }); - test.beforeEach(async ({ page }) => { + test.beforeEach(async ({ page }) => { test.setTimeout(900000); electronApp = await electron.launch({ args: ['.webpack/main/index.js'] }) page = await electronApp.firstWindow() @@ -71,25 +71,10 @@ test.describe('ReviewTab', () => { launchConfigPage = new LaunchConfigPage(page); reviewPage = new ReviewPage(page); titlePage.navigateToConnectionTab() - await connectionPage.fillConnectionDetails(config.SSH_HOST, config.SSH_PORT, config.SSH_USER, config.SSH_PASSWD); + 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.continueToUnpax() - await installationTypePage.skipUnpax() - await page.waitForTimeout(5000); + await page.waitForTimeout(2000); reviewPage.clickReviewInstallationTab(); await page.waitForTimeout(5000); }) @@ -197,8 +182,8 @@ test.describe('ReviewTab', () => { test('Test Successful and Pending Operations Tabs', async ({ page }) => { expect(reviewPage.connectionTabSuccessfulIcon).toBeTruthy() - expect(reviewPage.planningTabSuccessfulIcon).toBeTruthy() - expect(reviewPage.installationTypeTabSuccessfulIcon).toBeTruthy() + expect(reviewPage.planningTabPendingIcon).toBeTruthy() + expect(reviewPage.installationTypeTabPendingIcon).toBeTruthy() expect(reviewPage.installationTabPendingIcon).toBeTruthy() expect(reviewPage.networkingTabPendingIcon).toBeTruthy() expect(reviewPage.apfAuthTabPendingIcon).toBeTruthy() @@ -224,6 +209,18 @@ test.describe('ReviewTab', () => { await page.waitForTimeout(2000); }) + test('Test If you can edit the Yaml', async ({ page }) => { + reviewPage.clickViewEditYaml() + await page.waitForTimeout(2000); + expect(reviewPage.editorTitleElement).toBeTruthy(); + try { + await reviewPage.readOnlyEditor.fill('Trying to update content'); + } catch (error) { + expect(error.message).toContain('Element is not an ,