forked from podman-desktop/podman-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpodman-machine-tests.spec.ts
208 lines (179 loc) · 9.6 KB
/
podman-machine-tests.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/**********************************************************************
* 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
***********************************************************************/
import { PodmanMachineDetails } from '../model/pages/podman-machine-details-page';
import { PodmanOnboardingPage } from '../model/pages/podman-onboarding-page';
import { ResourceConnectionCardPage } from '../model/pages/resource-connection-card-page';
import { ResourcesPage } from '../model/pages/resources-page';
import { expect as playExpect, test } from '../utility/fixtures';
import { deletePodmanMachine, handleConfirmationDialog } from '../utility/operations';
import { isLinux } from '../utility/platform';
import { waitForPodmanMachineStartup } from '../utility/wait';
const DEFAULT_PODMAN_MACHINE = 'Podman Machine';
const DEFAULT_PODMAN_MACHINE_VISIBLE = 'podman-machine-default';
const ROOTLESS_PODMAN_MACHINE_VISIBLE = 'podman-machine-rootless';
const ROOTLESS_PODMAN_MACHINE = 'Podman Machine rootless';
const RESOURCE_NAME = 'podman';
test.skip(isLinux, 'Tests suite should not run on Linux platform');
test.beforeAll(async ({ runner, welcomePage, page }) => {
runner.setVideoAndTraceName('podman-machine-tests');
await welcomePage.handleWelcomePage(true);
await waitForPodmanMachineStartup(page);
});
test.afterAll(async ({ runner }) => {
await runner.close();
});
test.describe.serial(`Podman machine switching validation `, () => {
test('Check data for available Podman Machine and stop machine', async ({ page, navigationBar }) => {
await test.step('Open resources page', async () => {
const settingsBar = await navigationBar.openSettings();
await settingsBar.resourcesTab.click();
});
await test.step('Check default podman machine', async () => {
const resourcesPage = new ResourcesPage(page);
await playExpect(resourcesPage.heading).toBeVisible();
await playExpect.poll(async () => await resourcesPage.resourceCardIsVisible(RESOURCE_NAME)).toBeTruthy();
const resourcesPodmanConnections = new ResourceConnectionCardPage(
page,
RESOURCE_NAME,
DEFAULT_PODMAN_MACHINE_VISIBLE,
);
await playExpect(resourcesPodmanConnections.providerConnections).toBeVisible({ timeout: 10_000 });
await playExpect(resourcesPodmanConnections.resourceElement).toBeVisible({ timeout: 20_000 });
await playExpect(resourcesPodmanConnections.resourceElementDetailsButton).toBeVisible();
await resourcesPodmanConnections.resourceElementDetailsButton.click();
});
await test.step('Check default podman machine details', async () => {
const podmanMachineDetails = new PodmanMachineDetails(page, DEFAULT_PODMAN_MACHINE);
await test.step('Ensure default podman machine is RUNNING', async () => {
await playExpect(podmanMachineDetails.podmanMachineStatus).toBeVisible();
await playExpect(podmanMachineDetails.podmanMachineConnectionActions).toBeVisible();
await playExpect(podmanMachineDetails.podmanMachineStartButton).toBeVisible();
await playExpect(podmanMachineDetails.podmanMachineRestartButton).toBeVisible();
await playExpect(podmanMachineDetails.podmanMachineStopButton).toBeVisible();
await playExpect(podmanMachineDetails.podmanMachineDeleteButton).toBeVisible();
await playExpect(podmanMachineDetails.podmanMachineStatus).toHaveText('RUNNING', { timeout: 50_000 });
});
await test.step('Stop default podman machine', async () => {
await playExpect(podmanMachineDetails.podmanMachineStopButton).toBeEnabled();
await podmanMachineDetails.podmanMachineStopButton.click();
await playExpect(podmanMachineDetails.podmanMachineStatus).toHaveText('OFF', { timeout: 50_000 });
});
});
});
test('Create rootless podman machine', async ({ page, navigationBar }) => {
test.setTimeout(200_000);
await test.step('Open resources page', async () => {
const dashboard = await navigationBar.openDashboard();
await playExpect(dashboard.heading).toBeVisible();
const settingsBar = await navigationBar.openSettings();
await settingsBar.resourcesTab.click();
});
const resourcesPage = new ResourcesPage(page);
await test.step('Go to create new podman machine page', async () => {
await playExpect(resourcesPage.heading).toBeVisible();
await playExpect.poll(async () => await resourcesPage.resourceCardIsVisible(RESOURCE_NAME)).toBeTruthy();
await resourcesPage.goToCreateNewResourcePage(RESOURCE_NAME);
});
const podmanMachineCreatePage = new PodmanOnboardingPage(page);
await test.step('Create podman machine', async () => {
await podmanMachineCreatePage.machineCreationForm.setupAndCreateMachine(
ROOTLESS_PODMAN_MACHINE_VISIBLE,
false,
false,
false,
);
await playExpect(podmanMachineCreatePage.goBackButton).toBeEnabled({ timeout: 180_000 });
await podmanMachineCreatePage.goBackButton.click();
});
await playExpect(resourcesPage.heading).toBeVisible();
});
test('Switch to rootless podman machine', async ({ page }) => {
await test.step('Go to rootless podman machine details page', async () => {
const resourcesPodmanConnections = new ResourceConnectionCardPage(
page,
RESOURCE_NAME,
ROOTLESS_PODMAN_MACHINE_VISIBLE,
);
await playExpect(resourcesPodmanConnections.resourceElementDetailsButton).toBeVisible({ timeout: 30_000 });
await resourcesPodmanConnections.resourceElementDetailsButton.click();
});
await test.step('Check rootless podman machine details', async () => {
const podmanMachineDetails = new PodmanMachineDetails(page, ROOTLESS_PODMAN_MACHINE);
await test.step('Ensure rootless podman machine is OFF', async () => {
await playExpect(podmanMachineDetails.podmanMachineName).toBeVisible();
await playExpect(podmanMachineDetails.podmanMachineStatus).toHaveText('OFF');
});
await test.step('Start rootless podman machine', async () => {
await playExpect(podmanMachineDetails.podmanMachineStartButton).toBeEnabled();
await podmanMachineDetails.podmanMachineStartButton.click();
await playExpect(podmanMachineDetails.podmanMachineStatus).toHaveText('RUNNING', { timeout: 50_000 });
});
await handleConfirmationDialog(page, 'Podman', true, 'Yes');
await handleConfirmationDialog(page, 'Podman', true, 'OK');
});
});
test('Stop rootless podman machine', async ({ page }) => {
const podmanMachineDetails = new PodmanMachineDetails(page, ROOTLESS_PODMAN_MACHINE);
await test.step('Ensure rootless podman machine is RUNNING', async () => {
await playExpect(podmanMachineDetails.podmanMachineName).toBeVisible();
await playExpect(podmanMachineDetails.podmanMachineStatus).toHaveText('RUNNING');
});
await test.step('Stop rootless podman machine', async () => {
await playExpect(podmanMachineDetails.podmanMachineStopButton).toBeEnabled();
await podmanMachineDetails.podmanMachineStopButton.click();
await playExpect(podmanMachineDetails.podmanMachineStatus).toHaveText('OFF', { timeout: 50_000 });
});
});
test('Restart default podman machine', async ({ page, navigationBar }) => {
await test.step('Open resources page', async () => {
const dashboard = await navigationBar.openDashboard();
await playExpect(dashboard.heading).toBeVisible();
const settingsBar = await navigationBar.openSettings();
await settingsBar.resourcesTab.click();
});
await test.step('Go to default podman machine details page', async () => {
const resourcesPage = new ResourcesPage(page);
await playExpect(resourcesPage.heading).toBeVisible();
await playExpect.poll(async () => await resourcesPage.resourceCardIsVisible(RESOURCE_NAME)).toBeTruthy();
const resourcesPodmanConnections = new ResourceConnectionCardPage(
page,
RESOURCE_NAME,
DEFAULT_PODMAN_MACHINE_VISIBLE,
);
await playExpect(resourcesPodmanConnections.resourceElementDetailsButton).toBeVisible();
await resourcesPodmanConnections.resourceElementDetailsButton.click();
});
await test.step('Turn default podman machine on', async () => {
const podmanMachineDetails = new PodmanMachineDetails(page, DEFAULT_PODMAN_MACHINE);
await playExpect(podmanMachineDetails.podmanMachineStartButton).toBeEnabled();
await podmanMachineDetails.podmanMachineStartButton.click();
await playExpect(podmanMachineDetails.podmanMachineStatus).toHaveText('RUNNING', { timeout: 50_000 });
await handleConfirmationDialog(page, 'Podman', true, 'Yes');
await handleConfirmationDialog(page, 'Podman', true, 'OK');
});
});
test('Clean up rootless podman machine', async ({ page }) => {
await deletePodmanMachine(page, ROOTLESS_PODMAN_MACHINE_VISIBLE);
try {
await handleConfirmationDialog(page, 'Podman', true, 'Yes');
await handleConfirmationDialog(page, 'Podman', true, 'OK');
} catch (error) {
console.log('No handling dialog displayed', error);
}
});
});