From 5cb3f105d7f54a55f92a8711df9dfacffb6c4556 Mon Sep 17 00:00:00 2001 From: Vladimir Lazar <106525396+cbr7@users.noreply.github.com> Date: Fri, 17 May 2024 09:55:55 +0200 Subject: [PATCH] chore(tests): add arch selection for build image (#7221) * chore(tests): add arch selection for build image for e2e tests --- tests/playwright/src/model/core/platforms.ts | 23 ++++++++++ .../src/model/pages/build-image-page.ts | 44 +++++++++++++++++-- 2 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 tests/playwright/src/model/core/platforms.ts diff --git a/tests/playwright/src/model/core/platforms.ts b/tests/playwright/src/model/core/platforms.ts new file mode 100644 index 00000000000..eb5ef76fc2b --- /dev/null +++ b/tests/playwright/src/model/core/platforms.ts @@ -0,0 +1,23 @@ +/********************************************************************** + * Copyright (C) 2024 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ***********************************************************************/ + +export enum ArchitectureType { + Default = 'default', + AMD64 = 'amd64', + ARM64 = 'arm64', +} diff --git a/tests/playwright/src/model/pages/build-image-page.ts b/tests/playwright/src/model/pages/build-image-page.ts index 4fcd0c06bfe..fd527646217 100644 --- a/tests/playwright/src/model/pages/build-image-page.ts +++ b/tests/playwright/src/model/pages/build-image-page.ts @@ -18,6 +18,7 @@ import type { Locator, Page } from '@playwright/test'; import { expect as playExpect } from '@playwright/test'; +import { ArchitectureType } from '../core/platforms'; import { BasePage } from './base-page'; import { ImagesPage } from './images-page'; @@ -29,8 +30,11 @@ export class BuildImagePage extends BasePage { readonly buildButton: Locator; readonly doneButton: Locator; readonly containerFilePathButton: Locator; + readonly platformRegion: Locator; readonly arm64Button: Locator; readonly amd64Button: Locator; + readonly arm64checkbox: Locator; + readonly amd64checkbox: Locator; constructor(page: Page) { super(page); @@ -41,11 +45,19 @@ export class BuildImagePage extends BasePage { this.buildButton = page.getByRole('button', { name: 'Build' }); this.doneButton = page.getByRole('button', { name: 'Done' }); this.containerFilePathButton = page.getByRole('button', { name: 'Browse...' }).first(); - this.arm64Button = page.getByLabel('linux/arm64'); - this.amd64Button = page.getByLabel('linux/amd64'); + this.platformRegion = page.getByRole('region', { name: 'Build Platform Options' }); + this.arm64Button = this.platformRegion.getByLabel('linux/arm64'); + this.amd64Button = this.platformRegion.getByLabel('linux/amd64'); + this.arm64checkbox = this.platformRegion.getByLabel('ARMĀ® aarch64 systems'); + this.amd64checkbox = this.platformRegion.getByLabel('Intel and AMD x86_64 systems'); } - async buildImage(imageName: string, containerFilePath: string, contextDirectory: string): Promise { + async buildImage( + imageName: string, + containerFilePath: string, + contextDirectory: string, + archType = ArchitectureType.Default, + ): Promise { if (!containerFilePath) { throw Error(`Path to containerfile is incorrect or not provided!`); } @@ -58,10 +70,36 @@ export class BuildImagePage extends BasePage { await this.imageNameInput.pressSequentially(imageName, { delay: 50 }); } + if (archType !== ArchitectureType.Default) { + await this.uncheckedAllCheckboxes(); + + switch (archType) { + case ArchitectureType.ARM64: + await this.arm64Button.click(); + await playExpect(this.arm64checkbox).toBeChecked(); + break; + case ArchitectureType.AMD64: + await this.amd64Button.click(); + await playExpect(this.amd64checkbox).toBeChecked(); + break; + } + } + await playExpect(this.buildButton).toBeEnabled(); await this.buildButton.click(); await playExpect(this.doneButton).toBeEnabled({ timeout: 120000 }); await this.doneButton.click(); return new ImagesPage(this.page); } + + async uncheckedAllCheckboxes(): Promise { + if (await this.arm64checkbox.isChecked()) { + await this.arm64Button.click(); + await playExpect(this.arm64checkbox).not.toBeChecked(); + } + if (await this.amd64checkbox.isChecked()) { + await this.amd64Button.click(); + await playExpect(this.amd64checkbox).not.toBeChecked(); + } + } }