Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added State Management Tests #159

Open
wants to merge 8 commits into
base: v2.x/staging
Choose a base branch
from
5 changes: 5 additions & 0 deletions playwright_test/Pages/connection.page.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Page,Locator } from '@playwright/test';

Check failure on line 1 in playwright_test/Pages/connection.page.ts

View workflow job for this annotation

GitHub Actions / lint

missing header

class ConnectionPage{
page: Page;
Expand Down Expand Up @@ -57,6 +57,11 @@
return await this.connectionPageTitle.textContent();
}

async fillPassword(password: string){
await this.page.waitForTimeout(2000);
await this.password.fill(password);
}

async SubmitValidateCredential(){
console.log("Submitting credentials...");
await this.validateCredential.click();
Expand Down
44 changes: 38 additions & 6 deletions playwright_test/Pages/installationType.page.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Page,Locator } from '@playwright/test';

Check failure on line 1 in playwright_test/Pages/installationType.page.ts

View workflow job for this annotation

GitHub Actions / lint

missing header

class InstallationTypePage{
page: Page;
Expand All @@ -17,7 +17,9 @@
validateLocation: Locator;
validateLocationGreenCheck: Locator;
licenseAgreementGreenCheck: Locator;

disagreeLicense: Locator;
installation_Type_Tab: Locator;
continueToUnpaxButton: Locator;

constructor(page: Page) {
this.page = page;
Expand All @@ -27,25 +29,31 @@
this.uploadPax = page.locator("//span[text()='Upload Zowe PAX for offline install']/preceding-sibling::span/input")
this.smpe = page.locator("//span[text()='SMP/E']/preceding-sibling::span/input")
this.licenseAgreement = page.locator("//button[text()='License Agreement']")
this.saveAndClose = page.locator("//button[contains(text(),'Save & close')]")

Check failure on line 32 in playwright_test/Pages/installationType.page.ts

View workflow job for this annotation

GitHub Actions / lint

Mixed spaces and tabs
this.previousStep = page.locator("//button[contains(text(),'Previous step')]")
this.continueToComponentInstallation = page.locator("//button[text()='Continue to Components Installation']")
this.zoweLink = page.locator("//a[@href='zowe.org']")
this.agreeLicense = page.locator("//button[text()='Agree']")
this.disagreeLicense = page.locator("//button[text()='Disagree']")
this.uploadPaxButton = page.locator("//button[text()='Upload PAX']")
this.runtimeDir = page.locator("//label[contains(text(),'Runtime Directory')]//following-sibling::div/input")
this.validateLocation = page.locator("//button[text()= 'Validate location']")
this.validateLocationGreenCheck = page.locator("//button[text()='Validate location']//following-sibling::*[@data-testid='CheckCircleIcon']")
this.licenseAgreementGreenCheck = page.locator("//button[text()='License Agreement']//following-sibling::*[@data-testid='CheckCircleIcon']")
this.retrieveExampleZoweYaml = page.locator("//button[contains(text(),'Retrieve example-zowe.yaml')]")

Check failure on line 43 in playwright_test/Pages/installationType.page.ts

View workflow job for this annotation

GitHub Actions / lint

Mixed spaces and tabs
this.continueCompInstallation = page.locator("//button[contains(text(),'Continue to Components Installation')]")

Check failure on line 44 in playwright_test/Pages/installationType.page.ts

View workflow job for this annotation

GitHub Actions / lint

Mixed spaces and tabs
this.skipUnpaxButton = page.locator("//button[text()='Skip ']")

Check failure on line 45 in playwright_test/Pages/installationType.page.ts

View workflow job for this annotation

GitHub Actions / lint

Mixed spaces and tabs
this.continueToUnpax = page.locator("//button[contains(text(),'Continue to Unpax')]")
this.continueToUnpaxButton = page.locator("//button[contains(text(),'Continue to Unpax')]")
this.SkipUnpax = page.locator('//button[contains(text(),"Skip")]')
this.retrieveExampleZoweYaml= page.locator('//button[contains(text(),"Retrieve example-zowe.yaml")]')
this.click_InitializationStage = page.locator('//span[text()="Initialization"]')
this.installation_Type_Tab = page.locator('//span[text()="Installation Type"]')
}

async clickInstallationTypeTab(){
await this.installation_Type_Tab.click({timeout: 9000})
}

async getInstallationTypePageTitle(){
return await this.pageTitle.textContent({ timeout: 2000 });
}
Expand All @@ -54,10 +62,20 @@
await this.downloadPax.click({timeout: 5000})
}

async isDownloadZowePaxSelected(){
await this.page.waitForTimeout(1000)
return await this.downloadPax.isChecked()
}

async selectUploadZowePax(){
await this.uploadPax.click({timeout: 5000});
}

async isUploadZowePaxSelected(){
await this.page.waitForTimeout(1000)
return await this.uploadPax.isChecked()
}

async selectSmpe(){
await this.smpe.click({timeout: 5000});
}
Expand All @@ -84,19 +102,24 @@
}

private async waitForInstallationPageVisible(): Promise<void> {
const timeout = 1000000;
const interval = 500;
const timeout = 1000000;
const interval = 500;
const endTime = Date.now() + timeout;
while (Date.now() < endTime) {
if (await this.installationPageTitle.isVisible()) {
return;
return;
}
await this.page.waitForTimeout(interval);
}

throw new Error('Timed out waiting for the Installation Page to become visible.');
}

async isSmpeSelected(){
await this.page.waitForTimeout(1000)
return await this.smpe.isChecked()
}

async clickZoweLink(){
await this.zoweLink.click();
}
Expand Down Expand Up @@ -133,6 +156,11 @@
await this.agreeLicense.click({timeout: 5000});
}

async clickDisagreeLicense(){
await this.page.waitForTimeout(1000)
await this.disagreeLicense.click({timeout: 5000});
}

async isLicenseAgreementGreenCheckVisible(){
await this.page.waitForTimeout(5000);
return await this.licenseAgreementGreenCheck.isVisible({timeout: 5000});
Expand All @@ -148,7 +176,7 @@

}

async enterRuntimeDir(runtimeDir: any){

Check warning on line 179 in playwright_test/Pages/installationType.page.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
await this.runtimeDir.clear({timeout: 5000})
await this.runtimeDir.fill(runtimeDir);
}
Expand All @@ -167,18 +195,22 @@
await this.clickAgreeLicense()
}

async uploadZowePaxAndNavigateToInstallationPage(uploadPaxPath: any){

Check warning on line 198 in playwright_test/Pages/installationType.page.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
this.selectUploadZowePax()
await this.uploadPaxButton.setInputFiles(uploadPaxPath)
}

async smpeZowePaxAndNavigateToInstallationPage(runtimeDir: any){

Check warning on line 203 in playwright_test/Pages/installationType.page.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
this.selectSmpe()
this.enterRuntimeDir(runtimeDir)
this.clickValidateLocation()
}
async clickOnContinueToUnpax(){
this.continueToUnpax.click({ timeout: 2000 })
this.continueToUnpaxButton.click({ timeout: 2000 })
}

async isContinueToUnpaxEnabled(){
return await this.continueToUnpaxButton.isEnabled()
}

async clickSkipUnpaxButton(){
Expand Down
32 changes: 25 additions & 7 deletions playwright_test/Pages/planning.page.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Locator, Page } from '@playwright/test';
let page: Page;

Check warning on line 2 in playwright_test/Pages/planning.page.ts

View workflow job for this annotation

GitHub Actions / lint

'page' is defined but never used

class PlanningPage{
page: Page;
Expand Down Expand Up @@ -29,6 +29,7 @@
continueInstallationOptions: Locator;
readyToProceedMessage: Locator;
errorMessage: Locator;
save_and_close: Locator;

constructor(page: Page) {
this.page = page;
Expand Down Expand Up @@ -71,6 +72,11 @@
return await this.planningPageTitle.textContent();
}

async getJobStatement(){
await this.page.waitForTimeout(1000);
return await this.jobStatement.textContent();
}

async click_saveAndClose(){
await this.page.waitForTimeout(5000);
await this.save_and_close.click({ timeout: 2000 })
Expand Down Expand Up @@ -222,6 +228,7 @@
await this.page.waitForTimeout(500);
await this.previousStep.click();
}

private async waitForContinueButtonToBeEnabled(): Promise<boolean> {
const timeout = 100000; // Adjust the timeout as needed
const interval = 500;
Expand All @@ -239,15 +246,27 @@
return false; // Button did not become enabled
}

async clickContinueToInstallation(): Promise<void> {
async clickContinueToInstallation(){
const timeout = 30000;
const interval = 100;
const startTime = Date.now();
const isButtonEnabled = async (): Promise<boolean> => {
return await this.isContinueToInstallationEnabled();
};
while (!(await isButtonEnabled())) {
if (Date.now() - startTime > timeout) {
throw new Error('Timed out waiting for the button to be enabled.');
}
await new Promise(resolve => setTimeout(resolve, interval));
}
await this.continueInstallationOptions.click();
}

async isContinueToInstallationDisabled(){
await this.page.waitForTimeout(500);
return await this.continueInstallationOptions.isDisabled()
}

async isContinueToInstallationEnabled(){
await this.page.waitForTimeout(500);
return await this.continueInstallationOptions.isEnabled()
Expand All @@ -267,8 +286,8 @@
await this.saveAndValidate.click();
await this.page.waitForTimeout(500);
}


async fillPlanningPageWithRequiredFields(runtimeDir: any, workspaceDir: any, extensionDir: any, logDir: any, javaLocation:any,nodejsLocation:any,zOSMFHost:any,zOSMFPort:any,zOSMFAppID:any){
await this.clickSaveValidate();
await this.enterRuntimeDir(runtimeDir);
Expand All @@ -277,11 +296,10 @@
await this.enterExtensionsDir(extensionDir);
await this.enterJavaLocation(javaLocation);
await this.enterNodeJsLocation(nodejsLocation);
//await this.enterZosmfHost(zOSMFHost);
//await this.enterZosmfPort(zOSMFPort);
await this.enterZosmfHost(zOSMFHost);
await this.enterZosmfPort(zOSMFPort);
await this.enterZosmfApplicationId(zOSMFAppID);
await this.page.waitForTimeout(2000);
}

}
export default PlanningPage;
139 changes: 139 additions & 0 deletions playwright_test/Tests/StateManagementInstallationType.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import { test, ElectronApplication, expect, _electron as electron, Page } from '@playwright/test';
import ConnectionPage from '../Pages/connection.page.ts';
import TitlePage from '../Pages/title.page.ts';
import PlanningPage from '../Pages/planning.page.ts';
import InstallationTypePage from '../Pages/installationType.page.ts';
import config from '../utils/config.ts';
let page: Page;

let electronApp: ElectronApplication

test.describe('InstallationTypeTab', () => {
let connectionPage: ConnectionPage;
let titlePage: TitlePage;
let planningPage: PlanningPage;
let installationTypePage: InstallationTypePage;

async function launch_Zen({ 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);
installationTypePage = new InstallationTypePage(page);
await page.waitForTimeout(5000)
}

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

test.afterEach(async () => {
await electronApp.close()
})

test('Test Select Downlad Zowe Pax', async ({ page }) => {
installationTypePage.selectDownloadZowePax()
const is_Download_Zowe_Pax_Selected = await installationTypePage.isDownloadZowePaxSelected();
expect(is_Download_Zowe_Pax_Selected).toBe(true);
await electronApp.close()
await launch_Zen({page})
titlePage.clickOnResumeProgress();
connectionPage.fillPassword(config.SSH_PASSWD)
await page.waitForTimeout(2000);
await connectionPage.SubmitValidateCredential();
installationTypePage.clickInstallationTypeTab();
await page.waitForTimeout(2000);
expect(is_Download_Zowe_Pax_Selected).toBe(true);
})

test('Test Select Upload Zowe Pax', async ({ page }) => {
installationTypePage.selectUploadZowePax()
const is_Upload_Zowe_Pax_Selected = await installationTypePage.isUploadZowePaxSelected();
expect(is_Upload_Zowe_Pax_Selected).toBe(true);
await electronApp.close()
await launch_Zen({page})
titlePage.clickOnResumeProgress();
connectionPage.fillPassword(config.SSH_PASSWD)
await page.waitForTimeout(2000);
await connectionPage.SubmitValidateCredential();
installationTypePage.clickInstallationTypeTab();
await page.waitForTimeout(2000);
expect(is_Upload_Zowe_Pax_Selected).toBe(true);
})

test('Test Select SMPE', async ({ page }) => {
installationTypePage.selectSmpe();
const is_SMPE_Selected = await installationTypePage.isSmpeSelected();
expect(is_SMPE_Selected).toBe(true);
const Is_Continue_Button_Enable = await installationTypePage.isContinueToUnpaxEnabled();
expect(Is_Continue_Button_Enable).toBe(true);
await electronApp.close()
await launch_Zen({page})
titlePage.clickOnResumeProgress();
connectionPage.fillPassword(config.SSH_PASSWD)
await page.waitForTimeout(2000);
await connectionPage.SubmitValidateCredential();
installationTypePage.clickInstallationTypeTab();
await page.waitForTimeout(2000);
expect(is_SMPE_Selected).toBe(true);
expect(Is_Continue_Button_Enable).toBe(true);
})

test('Test Agree License Agreement', async ({ page }) => {
installationTypePage.selectDownloadZowePax()
installationTypePage.clickLicenseAgreement()
installationTypePage.clickAgreeLicense()
const is_GreenCheck_Visible = await installationTypePage.isLicenseAgreementGreenCheckVisible();
expect(is_GreenCheck_Visible).toBe(true);
const Is_Continue_Button_Enable = await installationTypePage.isContinueToUnpaxEnabled();
expect(Is_Continue_Button_Enable).toBe(true);
await electronApp.close()
await launch_Zen({page})
titlePage.clickOnResumeProgress();
connectionPage.fillPassword(config.SSH_PASSWD)
await page.waitForTimeout(2000);
await connectionPage.SubmitValidateCredential();
installationTypePage.clickInstallationTypeTab();
await page.waitForTimeout(2000);
expect(is_GreenCheck_Visible).toBe(true);
expect(Is_Continue_Button_Enable).toBe(true);
})

test('Test Disagree License Agreement', async ({ page }) => {
installationTypePage.selectDownloadZowePax()
installationTypePage.clickLicenseAgreement()
installationTypePage.clickDisagreeLicense()
const is_GreenCheck_Visible = await installationTypePage.isLicenseAgreementGreenCheckVisible();
expect(is_GreenCheck_Visible).toBe(false);
const Is_Continue_Button_Enable = await installationTypePage.isContinueToUnpaxEnabled();
expect(Is_Continue_Button_Enable).toBe(false);
await electronApp.close()
await launch_Zen({page})
titlePage.clickOnResumeProgress();
connectionPage.fillPassword(config.SSH_PASSWD)
await page.waitForTimeout(2000);
await connectionPage.SubmitValidateCredential();
installationTypePage.clickInstallationTypeTab();
await page.waitForTimeout(2000);
expect(is_GreenCheck_Visible).toBe(false);
expect(Is_Continue_Button_Enable).toBe(false);
})
})
Loading
Loading