Skip to content

Commit fc64d5a

Browse files
committed
playwright: run blueprint export tests for cockpit-image-builder
Also verify the contents of the exported blueprint. For hosted this is not important as there the exported blueprint is just forwarded from image-builder-crc. But in cockpit-image-builder all blueprint management is handled inside of the plugin itself, thus it is important to verify the contents of the export.
1 parent e6b711a commit fc64d5a

File tree

14 files changed

+392
-75
lines changed

14 files changed

+392
-75
lines changed

playwright/Customizations/AAP.spec.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import * as fsPromises from 'fs/promises';
2+
import * as path from 'path';
3+
14
import { expect } from '@playwright/test';
25
import { v4 as uuidv4 } from 'uuid';
36

@@ -183,15 +186,20 @@ test('Create a blueprint with AAP registration customization', async ({
183186
.getByRole('button', { name: 'Save changes to blueprint' })
184187
.click();
185188
});
189+
190+
let exportedBP = '';
186191
// This is for hosted service only as these features are not available in cockpit plugin
187192
await test.step('Export BP', async (step) => {
188193
step.skip(!isHosted(), 'Exporting is not available in the plugin');
189-
await exportBlueprint(page, blueprintName);
194+
exportedBP = await exportBlueprint(page);
195+
await cleanup.add(async () => {
196+
await fsPromises.rm(path.dirname(exportedBP), { recursive: true });
197+
});
190198
});
191199

192200
await test.step('Import BP', async (step) => {
193201
step.skip(!isHosted(), 'Importing is not available in the plugin');
194-
await importBlueprint(page, blueprintName);
202+
await importBlueprint(page, exportedBP);
195203
});
196204

197205
await test.step('Review imported BP', async (step) => {

playwright/Customizations/Filesystem.spec.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
import * as fsPromises from 'fs/promises';
2+
import * as path from 'path';
3+
14
import { expect } from '@playwright/test';
25
import { v4 as uuidv4 } from 'uuid';
36

47
import { FILE_SYSTEM_CUSTOMIZATION_URL } from '../../src/constants';
58
import { test } from '../fixtures/cleanup';
9+
import { exportedFilesystemBP } from '../fixtures/data/exportBlueprintContents';
610
import { isHosted } from '../helpers/helpers';
711
import { ensureAuthenticated } from '../helpers/login';
812
import {
@@ -18,6 +22,7 @@ import {
1822
fillInImageOutputGuest,
1923
importBlueprint,
2024
registerLater,
25+
verifyExportedBlueprint,
2126
} from '../helpers/wizardHelpers';
2227

2328
test('Create a blueprint with Filesystem customization', async ({
@@ -178,15 +183,28 @@ test('Create a blueprint with Filesystem customization', async ({
178183
.click();
179184
});
180185

181-
// This is for hosted service only as these features are not available in cockpit plugin
182-
await test.step('Export BP', async (step) => {
183-
step.skip(!isHosted(), 'Exporting is not available in the plugin');
184-
await exportBlueprint(page, blueprintName);
186+
let exportedBP = '';
187+
await test.step('Export BP', async () => {
188+
exportedBP = await exportBlueprint(page);
189+
await cleanup.add(async () => {
190+
await fsPromises.rm(path.dirname(exportedBP), { recursive: true });
191+
});
192+
});
193+
194+
await test.step('Review exported BP', async (step) => {
195+
step.skip(
196+
isHosted(),
197+
'Only verify the contents of the exported blueprint in cockpit',
198+
);
199+
await verifyExportedBlueprint(
200+
exportedBP,
201+
exportedFilesystemBP(blueprintName),
202+
);
185203
});
186204

187205
await test.step('Import BP', async (step) => {
188206
step.skip(!isHosted(), 'Importing is not available in the plugin');
189-
await importBlueprint(page, blueprintName);
207+
await importBlueprint(page, exportedBP);
190208
});
191209

192210
await test.step('Review imported BP', async (step) => {

playwright/Customizations/Firewall.spec.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import * as fsPromises from 'fs/promises';
2+
import * as path from 'path';
3+
14
import { expect } from '@playwright/test';
25
import { v4 as uuidv4 } from 'uuid';
36

47
import { test } from '../fixtures/customizations';
8+
import { exportedFirewallBP } from '../fixtures/data/exportBlueprintContents';
59
import { isHosted } from '../helpers/helpers';
610
import { ensureAuthenticated } from '../helpers/login';
711
import {
@@ -17,6 +21,7 @@ import {
1721
fillInImageOutputGuest,
1822
importBlueprint,
1923
registerLater,
24+
verifyExportedBlueprint,
2025
} from '../helpers/wizardHelpers';
2126

2227
test('Create a blueprint with Firewall customization', async ({
@@ -194,15 +199,28 @@ test('Create a blueprint with Firewall customization', async ({
194199
.click();
195200
});
196201

197-
// This is for hosted service only as these features are not available in cockpit plugin
198-
await test.step('Export BP', async (step) => {
199-
step.skip(!isHosted(), 'Exporting is not available in the plugin');
200-
await exportBlueprint(page, blueprintName);
202+
let exportedBP = '';
203+
await test.step('Export BP', async () => {
204+
exportedBP = await exportBlueprint(page);
205+
await cleanup.add(async () => {
206+
await fsPromises.rm(path.dirname(exportedBP), { recursive: true });
207+
});
208+
});
209+
210+
await test.step('Review exported BP', async (step) => {
211+
step.skip(
212+
isHosted(),
213+
'Only verify the contents of the exported blueprint in cockpit',
214+
);
215+
await verifyExportedBlueprint(
216+
exportedBP,
217+
exportedFirewallBP(blueprintName),
218+
);
201219
});
202220

203221
await test.step('Import BP', async (step) => {
204222
step.skip(!isHosted(), 'Importing is not available in the plugin');
205-
await importBlueprint(page, blueprintName);
223+
await importBlueprint(page, exportedBP);
206224
});
207225

208226
await test.step('Review imported BP', async (step) => {

playwright/Customizations/Hostname.spec.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import * as fsPromises from 'fs/promises';
2+
import * as path from 'path';
3+
14
import { expect } from '@playwright/test';
25
import { v4 as uuidv4 } from 'uuid';
36

47
import { test } from '../fixtures/customizations';
8+
import { exportedHostnameBP } from '../fixtures/data/exportBlueprintContents';
59
import { isHosted } from '../helpers/helpers';
610
import { ensureAuthenticated } from '../helpers/login';
711
import {
@@ -17,6 +21,7 @@ import {
1721
fillInImageOutputGuest,
1822
importBlueprint,
1923
registerLater,
24+
verifyExportedBlueprint,
2025
} from '../helpers/wizardHelpers';
2126

2227
test('Create a blueprint with Hostname customization', async ({
@@ -67,15 +72,28 @@ test('Create a blueprint with Hostname customization', async ({
6772
.click();
6873
});
6974

70-
// This is for hosted service only as these features are not available in cockpit plugin
71-
await test.step('Export BP', async (step) => {
72-
step.skip(!isHosted(), 'Exporting is not available in the plugin');
73-
await exportBlueprint(page, blueprintName);
75+
let exportedBP = '';
76+
await test.step('Export BP', async () => {
77+
exportedBP = await exportBlueprint(page);
78+
await cleanup.add(async () => {
79+
await fsPromises.rm(path.dirname(exportedBP), { recursive: true });
80+
});
81+
});
82+
83+
await test.step('Review exported BP', async (step) => {
84+
step.skip(
85+
isHosted(),
86+
'Only verify the contents of the exported blueprint in cockpit',
87+
);
88+
await verifyExportedBlueprint(
89+
exportedBP,
90+
exportedHostnameBP(blueprintName),
91+
);
7492
});
7593

7694
await test.step('Import BP', async (step) => {
7795
step.skip(!isHosted(), 'Importing is not available in the plugin');
78-
await importBlueprint(page, blueprintName);
96+
await importBlueprint(page, exportedBP);
7997
});
8098

8199
await test.step('Review imported BP', async (step) => {

playwright/Customizations/Kernel.spec.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import * as fsPromises from 'fs/promises';
2+
import * as path from 'path';
3+
14
import { expect } from '@playwright/test';
25
import { v4 as uuidv4 } from 'uuid';
36

47
import { test } from '../fixtures/customizations';
8+
import { exportedKernelBP } from '../fixtures/data/exportBlueprintContents';
59
import { isHosted } from '../helpers/helpers';
610
import { ensureAuthenticated } from '../helpers/login';
711
import {
@@ -17,6 +21,7 @@ import {
1721
fillInImageOutputGuest,
1822
importBlueprint,
1923
registerLater,
24+
verifyExportedBlueprint,
2025
} from '../helpers/wizardHelpers';
2126

2227
test('Create a blueprint with Kernel customization', async ({
@@ -105,15 +110,25 @@ test('Create a blueprint with Kernel customization', async ({
105110
.click();
106111
});
107112

108-
// This is for hosted service only as these features are not available in cockpit plugin
109-
await test.step('Export BP', async (step) => {
110-
step.skip(!isHosted(), 'Exporting is not available in the plugin');
111-
await exportBlueprint(page, blueprintName);
113+
let exportedBP = '';
114+
await test.step('Export BP', async () => {
115+
exportedBP = await exportBlueprint(page);
116+
await cleanup.add(async () => {
117+
await fsPromises.rm(path.dirname(exportedBP), { recursive: true });
118+
});
119+
});
120+
121+
await test.step('Review exported BP', async (step) => {
122+
step.skip(
123+
isHosted(),
124+
'Only verify the contents of the exported blueprint in cockpit',
125+
);
126+
await verifyExportedBlueprint(exportedBP, exportedKernelBP(blueprintName));
112127
});
113128

114129
await test.step('Import BP', async (step) => {
115130
step.skip(!isHosted(), 'Importing is not available in the plugin');
116-
await importBlueprint(page, blueprintName);
131+
await importBlueprint(page, exportedBP);
117132
});
118133

119134
await test.step('Review imported BP', async (step) => {

playwright/Customizations/Locale.spec.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import * as fsPromises from 'fs/promises';
2+
import * as path from 'path';
3+
14
import { expect } from '@playwright/test';
25
import { v4 as uuidv4 } from 'uuid';
36

47
import { test } from '../fixtures/customizations';
8+
import { exportedLocaleBP } from '../fixtures/data/exportBlueprintContents';
59
import { isHosted } from '../helpers/helpers';
610
import { ensureAuthenticated } from '../helpers/login';
711
import {
@@ -17,6 +21,7 @@ import {
1721
fillInImageOutputGuest,
1822
importBlueprint,
1923
registerLater,
24+
verifyExportedBlueprint,
2025
} from '../helpers/wizardHelpers';
2126

2227
test('Create a blueprint with Locale customization', async ({
@@ -125,15 +130,25 @@ test('Create a blueprint with Locale customization', async ({
125130
.click();
126131
});
127132

128-
// This is for hosted service only as these features are not available in cockpit plugin
129-
await test.step('Export BP', async (step) => {
130-
step.skip(!isHosted(), 'Exporting is not available in the plugin');
131-
await exportBlueprint(page, blueprintName);
133+
let exportedBP = '';
134+
await test.step('Export BP', async () => {
135+
exportedBP = await exportBlueprint(page);
136+
await cleanup.add(async () => {
137+
await fsPromises.rm(path.dirname(exportedBP), { recursive: true });
138+
});
139+
});
140+
141+
await test.step('Review exported BP', async (step) => {
142+
step.skip(
143+
isHosted(),
144+
'Only verify the contents of the exported blueprint in cockpit',
145+
);
146+
await verifyExportedBlueprint(exportedBP, exportedLocaleBP(blueprintName));
132147
});
133148

134149
await test.step('Import BP', async (step) => {
135150
step.skip(!isHosted(), 'Importing is not available in the plugin');
136-
await importBlueprint(page, blueprintName);
151+
await importBlueprint(page, exportedBP);
137152
});
138153

139154
await test.step('Review imported BP', async (step) => {

playwright/Customizations/OpenSCAP.spec.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import * as fsPromises from 'fs/promises';
2+
import * as path from 'path';
3+
14
import { expect } from '@playwright/test';
25
import { v4 as uuidv4 } from 'uuid';
36

@@ -171,13 +174,16 @@ test('Create a blueprint with OpenSCAP customization', async ({
171174
.click();
172175
});
173176

174-
// This is for hosted service only as these features are not available in cockpit plugin
177+
let exportedBP = '';
175178
await test.step('Export BP', async () => {
176-
await exportBlueprint(page, blueprintName);
179+
exportedBP = await exportBlueprint(page);
180+
await cleanup.add(async () => {
181+
await fsPromises.rm(path.dirname(exportedBP), { recursive: true });
182+
});
177183
});
178184

179185
await test.step('Import BP', async () => {
180-
await importBlueprint(page, blueprintName);
186+
await importBlueprint(page, exportedBP);
181187
});
182188

183189
await test.step('Review imported BP', async () => {

playwright/Customizations/Registration.spec.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import * as fsPromises from 'fs/promises';
2+
import * as path from 'path';
3+
14
import { expect } from '@playwright/test';
25
import { v4 as uuidv4 } from 'uuid';
36

@@ -353,15 +356,17 @@ registrationModes.forEach(
353356
.click();
354357
});
355358

356-
// This is for hosted service only as these features are not available in cockpit plugin
357-
await test.step('Export blueprint', async (step) => {
358-
step.skip(!isHosted(), 'Exporting is not available in the plugin');
359-
await exportBlueprint(page, blueprintName);
359+
let exportedBP = '';
360+
await test.step('Export blueprint', async () => {
361+
exportedBP = await exportBlueprint(page);
362+
await cleanup.add(async () => {
363+
await fsPromises.rm(path.dirname(exportedBP), { recursive: true });
364+
});
360365
});
361366

362367
await test.step('Import blueprint', async (step) => {
363368
step.skip(!isHosted(), 'Importing is not available in the plugin');
364-
await importBlueprint(page, blueprintName);
369+
await importBlueprint(page, exportedBP);
365370
});
366371

367372
await test.step('Verify import does not change registration settings', async (step) => {

0 commit comments

Comments
 (0)