Skip to content

Commit 1388c25

Browse files
committed
chore(tests): rootless machine creation test added
Signed-off-by: Tamara Babalova <[email protected]>
1 parent e4d4208 commit 1388c25

File tree

2 files changed

+150
-0
lines changed

2 files changed

+150
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/**********************************************************************
2+
* Copyright (C) 2024 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+
import * as os from 'node:os';
19+
20+
import type { Page } from '@playwright/test';
21+
import { expect as playExpect } from '@playwright/test';
22+
import { afterAll, beforeAll, beforeEach, describe, test } from 'vitest';
23+
24+
import { CreateMachinePage } from '../model/pages/create-machine-page';
25+
import { ResourcesPage } from '../model/pages/resources-page';
26+
import { ResourcesPodmanConnections } from '../model/pages/resources-podman-connections-page';
27+
import { WelcomePage } from '../model/pages/welcome-page';
28+
import { NavigationBar } from '../model/workbench/navigation';
29+
import { PodmanDesktopRunner } from '../runner/podman-desktop-runner';
30+
import type { RunnerTestContext } from '../testContext/runner-test-context';
31+
import { deletePodmanMachine } from '../utility/operations';
32+
33+
let pdRunner: PodmanDesktopRunner;
34+
let page: Page;
35+
let navBar: NavigationBar;
36+
const PODMAN_MACHINE_NAME: string = 'Podman Machine Rootless';
37+
38+
beforeAll(async () => {
39+
pdRunner = new PodmanDesktopRunner();
40+
page = await pdRunner.start();
41+
pdRunner.setVideoAndTraceName('podman-rootless-machine-e2e');
42+
43+
const welcomePage = new WelcomePage(page);
44+
await welcomePage.handleWelcomePage(true);
45+
navBar = new NavigationBar(page);
46+
});
47+
48+
afterAll(async () => {
49+
await deletePodmanMachine(page, PODMAN_MACHINE_NAME);
50+
await pdRunner.close();
51+
});
52+
53+
beforeEach<RunnerTestContext>(async ctx => {
54+
ctx.pdRunner = pdRunner;
55+
});
56+
57+
describe.skipIf(os.platform() === 'linux')('Rootless Podman machine Verification', async () => {
58+
test('Create a rootless machine', async () => {
59+
await navBar.openSettings();
60+
const resourcesPage = new ResourcesPage(page);
61+
62+
const createMachineButton = resourcesPage.podmanResources.getByRole('button', {
63+
name: 'Create new Podman machine',
64+
});
65+
await createMachineButton.click();
66+
67+
const createMachinePage = new CreateMachinePage(page);
68+
await createMachinePage.createMachine(PODMAN_MACHINE_NAME, false);
69+
70+
const machineBox = new ResourcesPodmanConnections(page, PODMAN_MACHINE_NAME);
71+
const connectionStatus = await machineBox.machineConnectionStatus.allTextContents();
72+
playExpect(connectionStatus[0] === 'RUNNING').toBeTruthy();
73+
});
74+
});

0 commit comments

Comments
 (0)