forked from podman-desktop/podman-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpodman-machine-onboarding.spec.ts
215 lines (188 loc) · 10.8 KB
/
podman-machine-onboarding.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
209
210
211
212
213
214
215
/**********************************************************************
* 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 * as os from 'node:os';
import type { Locator, Page } from '@playwright/test';
import type { DashboardPage } from '../model/pages/dashboard-page';
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 type { SettingsBar } from '../model/pages/settings-bar';
import { expect as playExpect, test } from '../utility/fixtures';
import { deletePodmanMachine } from '../utility/operations';
import { isLinux, isMac } from '../utility/platform';
import { waitForPodmanMachineStartup } from '../utility/wait';
const PODMAN_MACHINE_STARTUP_TIMEOUT: number = 360_000;
const PODMAN_FULL_STARTUP_TIMEOUT = PODMAN_MACHINE_STARTUP_TIMEOUT + 30000;
const PODMAN_MACHINE_NAME: string = 'podman-machine-default';
const RESOURCE_NAME: string = 'podman';
let dashboardPage: DashboardPage;
let resourcesPage: ResourcesPage;
let settingsBar: SettingsBar;
let podmanOnboardingPage: PodmanOnboardingPage;
let notificationPodmanSetup: Locator;
test.skip(isLinux, 'Tests suite should not run on Linux platform');
test.skip(
isMac,
'Due to issue https://github.com/containers/podman-desktop/issues/8984 which causes problems on cicd on macOs this test suite is deactived on macs until a fix is provided',
);
test.beforeAll(async ({ runner, welcomePage, page }) => {
test.setTimeout(120_000);
runner.setVideoAndTraceName('podman-machine-e2e');
await welcomePage.handleWelcomePage(true);
// Delete machine if it already exists
if (
(process.env.TEST_PODMAN_MACHINE !== undefined && process.env.TEST_PODMAN_MACHINE === 'true') ||
(process.env.MACHINE_CLEANUP !== undefined && process.env.MACHINE_CLEANUP === 'true')
) {
await waitForPodmanMachineStartup(page);
await deletePodmanMachine(page, PODMAN_MACHINE_NAME);
}
});
test.afterAll(async ({ runner }) => {
test.setTimeout(120000);
await runner.close();
});
test.describe.serial('Podman Machine verification', () => {
test.describe.serial('Podman Machine onboarding workflow', () => {
test('Setup Podman push notification is present', async ({ navigationBar }) => {
dashboardPage = await navigationBar.openDashboard();
await playExpect(dashboardPage.mainPage).toBeVisible();
await playExpect(dashboardPage.notificationsBox).toBeVisible();
notificationPodmanSetup = dashboardPage.notificationsBox
.getByRole('region', { name: 'id:' })
.filter({ hasText: 'Podman needs to be set up' });
await playExpect(notificationPodmanSetup).toBeVisible();
});
test.describe.serial('Onboarding navigation', () => {
test('Open Podman Machine Onboarding through Setup Notification', async ({ page }) => {
await notificationPodmanSetup.getByTitle('Set up Podman').click();
podmanOnboardingPage = await checkPodmanMachineOnboardingPage(page);
});
test('Return to Dashboard', async ({ navigationBar }) => {
dashboardPage = await navigationBar.openDashboard();
await playExpect(dashboardPage.mainPage).toBeVisible();
});
test('Re-Open Podman Machine Onboarding through Settings Resources page', async ({ page, navigationBar }) => {
settingsBar = await navigationBar.openSettings();
await settingsBar.resourcesTab.click();
resourcesPage = new ResourcesPage(page);
await playExpect.poll(async () => await resourcesPage.resourceCardIsVisible(RESOURCE_NAME)).toBeTruthy();
const podmanResourceCard = new ResourceConnectionCardPage(page, RESOURCE_NAME);
const setupButton = podmanResourceCard.setupButton;
await setupButton.click();
podmanOnboardingPage = await checkPodmanMachineOnboardingPage(page);
});
});
test('Verify Podman Autostart is enabled and proceed to next page', async () => {
await playExpect(podmanOnboardingPage.podmanAutostartToggle).toBeChecked();
await podmanOnboardingPage.nextStepButton.click();
});
test('Expect no machine created message and proceed to next page', async () => {
await playExpect(podmanOnboardingPage.onboardingStatusMessage).toHaveText(
`We could not find any Podman machine. Let's create one!`,
{ timeout: 20_000 },
);
await podmanOnboardingPage.nextStepButton.click();
});
test('Verify default podman machine settings', async () => {
await playExpect(podmanOnboardingPage.createMachinePageTitle).toHaveText(`Create a Podman machine`);
await playExpect(podmanOnboardingPage.machineCreationForm.podmanMachineConfiguration).toBeVisible();
await playExpect(podmanOnboardingPage.machineCreationForm.podmanMachineName).toHaveValue(
'podman-machine-default',
);
await playExpect(podmanOnboardingPage.machineCreationForm.imagePathBox).toHaveValue('');
await playExpect(podmanOnboardingPage.machineCreationForm.rootPriviledgesCheckbox).toBeChecked();
await playExpect(podmanOnboardingPage.machineCreationForm.startNowCheckbox).toBeChecked();
if (os.platform() === 'win32') {
await playExpect(podmanOnboardingPage.machineCreationForm.userModeNetworkingCheckbox).not.toBeChecked();
} else {
await playExpect(podmanOnboardingPage.machineCreationForm.podmanMachineCPUs).toBeVisible();
await playExpect(podmanOnboardingPage.machineCreationForm.podmanMachineMemory).toBeVisible();
await playExpect(podmanOnboardingPage.machineCreationForm.podmanMachineDiskSize).toBeVisible();
}
});
});
test.describe.serial('Podman Machine creation and operations', () => {
test.skip(process.env.TEST_PODMAN_MACHINE !== 'true');
test('Create a default Podman machine', async () => {
test.setTimeout(PODMAN_FULL_STARTUP_TIMEOUT);
await podmanOnboardingPage.machineCreationForm.createMachineButton.click();
await playExpect(podmanOnboardingPage.podmanMachineShowLogsButton).toBeVisible();
await podmanOnboardingPage.podmanMachineShowLogsButton.click();
await playExpect(podmanOnboardingPage.onboardingStatusMessage).toBeVisible({
timeout: PODMAN_MACHINE_STARTUP_TIMEOUT,
});
await playExpect(podmanOnboardingPage.onboardingStatusMessage).toHaveText('Podman installed');
await podmanOnboardingPage.nextStepButton.click();
});
test.describe.serial('Podman machine operations', () => {
test.describe.configure({ timeout: 120000 });
test('Open podman machine details', async ({ page, navigationBar }) => {
dashboardPage = await navigationBar.openDashboard();
await playExpect(dashboardPage.mainPage).toBeVisible();
settingsBar = await navigationBar.openSettings();
await settingsBar.resourcesTab.click();
resourcesPage = new ResourcesPage(page);
await playExpect.poll(async () => await resourcesPage.resourceCardIsVisible(RESOURCE_NAME)).toBeTruthy();
const resourcesPodmanConnections = new ResourceConnectionCardPage(page, RESOURCE_NAME, PODMAN_MACHINE_NAME);
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();
const podmanMachineDetails = new PodmanMachineDetails(page, PODMAN_MACHINE_NAME);
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();
});
test('Podman machine operations - STOP', async ({ page }) => {
const podmanMachineDetails = new PodmanMachineDetails(page, PODMAN_MACHINE_NAME);
await playExpect(podmanMachineDetails.podmanMachineStatus).toHaveText('RUNNING', { timeout: 50_000 });
await playExpect(podmanMachineDetails.podmanMachineStopButton).toBeEnabled();
await podmanMachineDetails.podmanMachineStopButton.click();
await playExpect(podmanMachineDetails.podmanMachineStatus).toHaveText('OFF', { timeout: 50_000 });
});
test('Podman machine operations - START', async ({ page }) => {
const podmanMachineDetails = new PodmanMachineDetails(page, PODMAN_MACHINE_NAME);
await playExpect(podmanMachineDetails.podmanMachineStartButton).toBeEnabled();
await podmanMachineDetails.podmanMachineStartButton.click();
await playExpect(podmanMachineDetails.podmanMachineStatus).toHaveText('RUNNING', { timeout: 50_000 });
});
test('Podman machine operations - RESTART', async ({ page }) => {
const podmanMachineDetails = new PodmanMachineDetails(page, PODMAN_MACHINE_NAME);
await playExpect(podmanMachineDetails.podmanMachineRestartButton).toBeEnabled();
await podmanMachineDetails.podmanMachineRestartButton.click();
await playExpect(podmanMachineDetails.podmanMachineStatus).toHaveText('OFF', { timeout: 50_000 });
await playExpect(podmanMachineDetails.podmanMachineStatus).toHaveText('RUNNING', { timeout: 50_000 });
});
});
});
test('Clean Up Podman Machine', async ({ page }) => {
test.skip(process.env.MACHINE_CLEANUP !== 'true', 'Machine cleanup is disabled');
await deletePodmanMachine(page, 'Podman Machine');
});
});
async function checkPodmanMachineOnboardingPage(page: Page): Promise<PodmanOnboardingPage> {
const onboardingPage = new PodmanOnboardingPage(page);
await playExpect(onboardingPage.header).toBeVisible();
await playExpect(onboardingPage.mainPage).toBeVisible();
return onboardingPage;
}