16
16
* SPDX-License-Identifier: Apache-2.0
17
17
***********************************************************************/
18
18
19
- import type { Page } from '@playwright/test' ;
20
- import { expect as playExpect , test } from '@playwright/test' ;
21
-
22
19
import { ContainerState } from '../model/core/states' ;
23
20
import type { ContainerInteractiveParams } from '../model/core/types' ;
24
21
import { ContainersPage } from '../model/pages/containers-page' ;
25
22
import { ImageDetailsPage } from '../model/pages/image-details-page' ;
26
23
import type { ImagesPage } from '../model/pages/images-page' ;
27
- import { WelcomePage } from '../model/pages/welcome-page' ;
28
24
import { NavigationBar } from '../model/workbench/navigation' ;
29
- import { PodmanDesktopRunner } from '../runner/podman-desktop-runner ' ;
25
+ import { expect as playExpect , test } from '../utility/fixtures ' ;
30
26
import { deleteContainer , deleteImage } from '../utility/operations' ;
31
27
import { waitForPodmanMachineStartup , waitWhile } from '../utility/wait' ;
32
28
33
- let pdRunner : PodmanDesktopRunner ;
34
- let page : Page ;
35
29
const imageToPull = 'ghcr.io/linuxcontainers/alpine' ;
36
30
const imageTag = 'latest' ;
37
31
const containerToRun = 'alpine-container' ;
38
32
const containerList = [ 'first' , 'second' , 'third' ] ;
39
33
const containerStartParams : ContainerInteractiveParams = { attachTerminal : false } ;
40
34
41
- test . beforeAll ( async ( ) => {
42
- pdRunner = new PodmanDesktopRunner ( ) ;
43
- page = await pdRunner . start ( ) ;
35
+ test . beforeAll ( async ( { pdRunner, welcomePage, page } ) => {
44
36
pdRunner . setVideoAndTraceName ( 'containers-e2e' ) ;
45
- const welcomePage = new WelcomePage ( page ) ;
46
37
await welcomePage . handleWelcomePage ( true ) ;
47
38
await waitForPodmanMachineStartup ( page ) ;
48
39
// wait giving a time to podman desktop to load up
@@ -65,7 +56,7 @@ test.beforeAll(async () => {
65
56
}
66
57
} ) ;
67
58
68
- test . afterAll ( async ( ) => {
59
+ test . afterAll ( async ( { pdRunner , page } ) => {
69
60
test . setTimeout ( 90000 ) ;
70
61
71
62
try {
@@ -83,29 +74,25 @@ test.afterAll(async () => {
83
74
test . describe . serial ( 'Verification of container creation workflow @smoke' , ( ) => {
84
75
test . describe . configure ( { retries : 2 } ) ;
85
76
86
- test ( `Pulling of '${ imageToPull } :${ imageTag } ' image` , async ( ) => {
77
+ test ( `Pulling of '${ imageToPull } :${ imageTag } ' image` , async ( { navigationBar } ) => {
87
78
test . setTimeout ( 90000 ) ;
88
79
89
- const navigationBar = new NavigationBar ( page ) ;
90
80
let images = await navigationBar . openImages ( ) ;
91
81
const pullImagePage = await images . openPullImage ( ) ;
92
82
images = await pullImagePage . pullImage ( imageToPull , imageTag ) ;
93
83
94
84
await playExpect . poll ( async ( ) => await images . waitForImageExists ( imageToPull ) ) . toBeTruthy ( ) ;
95
85
} ) ;
96
86
97
- test ( `Start a container '${ containerToRun } ' from image` , async ( ) => {
98
- const navigationBar = new NavigationBar ( page ) ;
87
+ test ( `Start a container '${ containerToRun } ' from image` , async ( { navigationBar } ) => {
99
88
let images = await navigationBar . openImages ( ) ;
100
89
const imageDetails = await images . openImageDetails ( imageToPull ) ;
101
90
const runImage = await imageDetails . openRunImage ( ) ;
102
- await pdRunner . screenshot ( 'containers-run-image.png' ) ;
103
91
const containers = await runImage . startContainer ( containerToRun , containerStartParams ) ;
104
92
await playExpect ( containers . header ) . toBeVisible ( ) ;
105
93
await playExpect
106
94
. poll ( async ( ) => await containers . containerExists ( containerToRun ) , { timeout : 10000 } )
107
95
. toBeTruthy ( ) ;
108
- await pdRunner . screenshot ( 'containers-container-exists.png' ) ;
109
96
const containerDetails = await containers . openContainersDetails ( containerToRun ) ;
110
97
await playExpect
111
98
. poll ( async ( ) => await containerDetails . getState ( ) , { timeout : 10000 } )
@@ -115,8 +102,7 @@ test.describe.serial('Verification of container creation workflow @smoke', () =>
115
102
playExpect ( await images . getCurrentStatusOfImage ( imageToPull ) ) . toBe ( 'USED' ) ;
116
103
} ) ;
117
104
118
- test ( 'Test navigation between pages' , async ( ) => {
119
- const navigationBar = new NavigationBar ( page ) ;
105
+ test ( 'Test navigation between pages' , async ( { navigationBar } ) => {
120
106
const containers = await navigationBar . openContainers ( ) ;
121
107
122
108
const containersDetails = await containers . openContainersDetails ( containerToRun ) ;
@@ -129,14 +115,12 @@ test.describe.serial('Verification of container creation workflow @smoke', () =>
129
115
await containersDetails . closeButton . click ( ) ;
130
116
await playExpect ( containers . heading ) . toBeVisible ( ) ;
131
117
} ) ;
132
- test ( 'Open a container details' , async ( ) => {
133
- const navigationBar = new NavigationBar ( page ) ;
118
+ test ( 'Open a container details' , async ( { navigationBar } ) => {
134
119
const containers = await navigationBar . openContainers ( ) ;
135
120
const containersDetails = await containers . openContainersDetails ( containerToRun ) ;
136
121
await playExpect ( containersDetails . heading ) . toBeVisible ( ) ;
137
122
await playExpect ( containersDetails . heading ) . toContainText ( containerToRun ) ;
138
123
// test state of container in summary tab
139
- await pdRunner . screenshot ( 'containers-container-details.png' ) ;
140
124
const containerState = await containersDetails . getState ( ) ;
141
125
playExpect ( containerState ) . toContain ( ContainerState . Running ) ;
142
126
// check Logs output
@@ -149,8 +133,7 @@ test.describe.serial('Verification of container creation workflow @smoke', () =>
149
133
await containersDetails . activateTab ( 'Terminal' ) ;
150
134
// TODO: After updating of accessibility of various element in containers pages, we can extend test
151
135
} ) ;
152
- test ( 'Redirecting to image details from a container details' , async ( ) => {
153
- const navigationBar = new NavigationBar ( page ) ;
136
+ test ( 'Redirecting to image details from a container details' , async ( { page, navigationBar } ) => {
154
137
const containers = await navigationBar . openContainers ( ) ;
155
138
const containersDetails = await containers . openContainersDetails ( containerToRun ) ;
156
139
await playExpect ( containersDetails . heading ) . toBeVisible ( ) ;
@@ -161,8 +144,7 @@ test.describe.serial('Verification of container creation workflow @smoke', () =>
161
144
await playExpect ( imageDetails . heading ) . toBeVisible ( ) ;
162
145
await playExpect ( imageDetails . heading ) . toContainText ( imageToPull ) ;
163
146
} ) ;
164
- test ( 'Stopping a container from Container details' , async ( ) => {
165
- const navigationBar = new NavigationBar ( page ) ;
147
+ test ( 'Stopping a container from Container details' , async ( { navigationBar } ) => {
166
148
const containers = await navigationBar . openContainers ( ) ;
167
149
const containersDetails = await containers . openContainersDetails ( containerToRun ) ;
168
150
await playExpect ( containersDetails . heading ) . toBeVisible ( ) ;
@@ -178,8 +160,7 @@ test.describe.serial('Verification of container creation workflow @smoke', () =>
178
160
await playExpect ( startButton ) . toBeVisible ( ) ;
179
161
} ) ;
180
162
181
- test ( `Start a container from the Containers page` , async ( ) => {
182
- const navigationBar = new NavigationBar ( page ) ;
163
+ test ( `Start a container from the Containers page` , async ( { navigationBar } ) => {
183
164
const containers = await navigationBar . openContainers ( ) ;
184
165
const containersDetails = await containers . openContainersDetails ( containerToRun ) ;
185
166
await playExpect ( containersDetails . heading ) . toBeVisible ( ) ;
@@ -196,8 +177,7 @@ test.describe.serial('Verification of container creation workflow @smoke', () =>
196
177
. toContain ( ContainerState . Running ) ;
197
178
} ) ;
198
179
199
- test ( `Stop a container from the Containers page` , async ( ) => {
200
- const navigationBar = new NavigationBar ( page ) ;
180
+ test ( `Stop a container from the Containers page` , async ( { navigationBar } ) => {
201
181
const containers = await navigationBar . openContainers ( ) ;
202
182
const containersDetails = await containers . openContainersDetails ( containerToRun ) ;
203
183
await playExpect ( containersDetails . heading ) . toBeVisible ( ) ;
@@ -214,8 +194,7 @@ test.describe.serial('Verification of container creation workflow @smoke', () =>
214
194
. toContain ( ContainerState . Exited ) ;
215
195
} ) ;
216
196
217
- test ( 'Deleting a container from Container details' , async ( ) => {
218
- const navigationBar = new NavigationBar ( page ) ;
197
+ test ( 'Deleting a container from Container details' , async ( { navigationBar } ) => {
219
198
const containers = await navigationBar . openContainers ( ) ;
220
199
const containersDetails = await containers . openContainersDetails ( containerToRun ) ;
221
200
await playExpect ( containersDetails . heading ) . toContainText ( containerToRun ) ;
@@ -224,9 +203,8 @@ test.describe.serial('Verification of container creation workflow @smoke', () =>
224
203
await playExpect . poll ( async ( ) => await containersPage . containerExists ( containerToRun ) ) . toBeFalsy ( ) ;
225
204
} ) ;
226
205
227
- test ( `Deleting a container from the Containers page` , async ( ) => {
206
+ test ( `Deleting a container from the Containers page` , async ( { navigationBar } ) => {
228
207
//re-start the container from an image
229
- const navigationBar = new NavigationBar ( page ) ;
230
208
let images = await navigationBar . openImages ( ) ;
231
209
const imageDetails = await images . openImageDetails ( imageToPull ) ;
232
210
const runImage = await imageDetails . openRunImage ( ) ;
@@ -235,7 +213,6 @@ test.describe.serial('Verification of container creation workflow @smoke', () =>
235
213
await playExpect
236
214
. poll ( async ( ) => await containers . containerExists ( containerToRun ) , { timeout : 10000 } )
237
215
. toBeTruthy ( ) ;
238
- await pdRunner . screenshot ( 'containers-container-exists.png' ) ;
239
216
const containerDetails = await containers . openContainersDetails ( containerToRun ) ;
240
217
await playExpect
241
218
. poll ( async ( ) => await containerDetails . getState ( ) , { timeout : 10000 } )
@@ -253,10 +230,9 @@ test.describe.serial('Verification of container creation workflow @smoke', () =>
253
230
. toBeFalsy ( ) ;
254
231
} ) ;
255
232
256
- test ( 'Prune containers' , async ( ) => {
233
+ test ( 'Prune containers' , async ( { page , navigationBar } ) => {
257
234
test . setTimeout ( 120000 ) ;
258
235
259
- const navigationBar = new NavigationBar ( page ) ;
260
236
//Start 3 containers
261
237
for ( const container of containerList ) {
262
238
const images = await navigationBar . openImages ( ) ;
0 commit comments