|
| 1 | +/********************************************************************** |
| 2 | + * Copyright (C) 2023 Red Hat, Inc. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + * |
| 16 | + * SPDX-License-Identifier: Apache-2.0 |
| 17 | + ***********************************************************************/ |
| 18 | + |
| 19 | +import type { Locator, Page } from '@playwright/test'; |
| 20 | +import { expect as playExpect } from '@playwright/test'; |
| 21 | + |
| 22 | +import { BasePage } from './base-page'; |
| 23 | +import { ResourcesPage } from './resources-page'; |
| 24 | + |
| 25 | +export class CreateMachinePage extends BasePage { |
| 26 | + readonly heading: Locator; |
| 27 | + readonly machineNameBox: Locator; |
| 28 | + readonly cpuSlider: Locator; |
| 29 | + readonly memorySlider: Locator; |
| 30 | + readonly diskSlider: Locator; |
| 31 | + readonly imagePathBox: Locator; |
| 32 | + readonly browseImagesButton: Locator; |
| 33 | + readonly rootPriviledgesCheckbox: Locator; |
| 34 | + readonly userModeNetworkingCheckbox: Locator; |
| 35 | + readonly startNowCheckbox: Locator; |
| 36 | + readonly closeButton: Locator; |
| 37 | + readonly createMachineButton: Locator; |
| 38 | + |
| 39 | + constructor(page: Page) { |
| 40 | + super(page); |
| 41 | + this.heading = this.page.getByRole('heading', { name: 'Create Podman Machine' }); |
| 42 | + this.machineNameBox = this.page.getByRole('textbox', { name: 'Name' }); |
| 43 | + this.cpuSlider = this.page.getByRole('slider', { name: 'CPU(s)' }); |
| 44 | + this.memorySlider = this.page.getByRole('slider', { name: 'Memory' }); |
| 45 | + this.diskSlider = this.page.getByRole('slider', { name: 'Disk size' }); |
| 46 | + this.imagePathBox = this.page.getByRole('textbox', { name: 'Image Path (Optional) ' }); |
| 47 | + this.browseImagesButton = this.page.getByRole('button', { name: 'button-Image Path (Optional)' }); |
| 48 | + this.rootPriviledgesCheckbox = this.page.getByRole('checkbox', { name: 'Machine with root priviledges' }); |
| 49 | + this.userModeNetworkingCheckbox = this.page.getByRole('checkbox', { |
| 50 | + name: 'User mode networking (traffic relayed by a user process). See [documentation](https://docs.podman.io/en/latest/markdown/podman-machine-init.1.html#user-mode-networking).', |
| 51 | + }); |
| 52 | + this.startNowCheckbox = this.page.getByRole('checkbox', { name: 'Start the machine now' }); |
| 53 | + this.closeButton = this.page.getByRole('button', { name: 'Close page' }); |
| 54 | + this.createMachineButton = this.page.getByRole('button', { name: 'Create Pod' }); |
| 55 | + } |
| 56 | + |
| 57 | + async createMachine(machineName: string, isRootless: boolean): Promise<ResourcesPage> { |
| 58 | + //can be extended |
| 59 | + await this.machineNameBox.fill(machineName); |
| 60 | + if (!isRootless) { |
| 61 | + await this.rootPriviledgesCheckbox.uncheck(); |
| 62 | + playExpect(this.rootPriviledgesCheckbox.isChecked()).toBeFalsy(); |
| 63 | + } |
| 64 | + |
| 65 | + await this.createMachineButton.click(); |
| 66 | + |
| 67 | + const successfulCreationMessage = this.page.getByLabel('Successful operation'); |
| 68 | + const goBackToResourcesButton = this.page.getByRole('button', { name: 'Go back to resources' }); |
| 69 | + |
| 70 | + await playExpect(successfulCreationMessage).toBeVisible({ timeout: 50000 }); |
| 71 | + await playExpect(goBackToResourcesButton).toBeVisible(); |
| 72 | + await goBackToResourcesButton.click(); |
| 73 | + |
| 74 | + return new ResourcesPage(this.page); |
| 75 | + } |
| 76 | +} |
0 commit comments