Skip to content

Commit 16c1ba9

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 a1ccf7b commit 16c1ba9

File tree

13 files changed

+360
-51
lines changed

13 files changed

+360
-51
lines changed

playwright/Customizations/AAP.spec.ts

Lines changed: 7 additions & 1 deletion
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

@@ -186,7 +189,10 @@ test('Create a blueprint with AAP registration customization', async ({
186189
// This is for hosted service only as these features are not available in cockpit plugin
187190
await test.step('Export BP', async (step) => {
188191
step.skip(!isHosted(), 'Exporting is not available in the plugin');
189-
await exportBlueprint(page, blueprintName);
192+
const exportedBP = await exportBlueprint(page);
193+
await cleanup.add(async () => {
194+
await fsPromises.rm(path.dirname(exportedBP), { recursive: true });
195+
});
190196
});
191197

192198
await test.step('Import BP', async (step) => {

playwright/Customizations/Filesystem.spec.ts

Lines changed: 22 additions & 4 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,10 +183,23 @@ 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) => {

playwright/Customizations/Firewall.spec.ts

Lines changed: 22 additions & 4 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,10 +199,23 @@ 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) => {

playwright/Customizations/Hostname.spec.ts

Lines changed: 22 additions & 4 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,10 +72,23 @@ 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) => {

playwright/Customizations/Kernel.spec.ts

Lines changed: 19 additions & 4 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,10 +110,20 @@ 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) => {

playwright/Customizations/Locale.spec.ts

Lines changed: 19 additions & 4 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,10 +130,20 @@ 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) => {

playwright/Customizations/OpenSCAP.spec.ts

Lines changed: 7 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

@@ -171,9 +174,11 @@ 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
175177
await test.step('Export BP', async () => {
176-
await exportBlueprint(page, blueprintName);
178+
const exportedBP = await exportBlueprint(page);
179+
await cleanup.add(async () => {
180+
await fsPromises.rm(path.dirname(exportedBP), { recursive: true });
181+
});
177182
});
178183

179184
await test.step('Import BP', async () => {

playwright/Customizations/Registration.spec.ts

Lines changed: 8 additions & 4 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,10 +356,11 @@ 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+
await test.step('Export blueprint', async () => {
360+
const exportedBP = await exportBlueprint(page);
361+
await cleanup.add(async () => {
362+
await fsPromises.rm(path.dirname(exportedBP), { recursive: true });
363+
});
360364
});
361365

362366
await test.step('Import blueprint', async (step) => {

playwright/Customizations/Systemd.spec.ts

Lines changed: 19 additions & 4 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 { exportedSystemdBP } 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 Systemd customization', async ({
@@ -127,10 +132,20 @@ test('Create a blueprint with Systemd customization', async ({
127132
.click();
128133
});
129134

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

136151
await test.step('Import BP', async (step) => {

playwright/Customizations/Timezone.spec.ts

Lines changed: 22 additions & 4 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 { exportedTimezoneBP } 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 Timezone customization', async ({
@@ -102,10 +107,23 @@ test('Create a blueprint with Timezone customization', async ({
102107
.click();
103108
});
104109

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

111129
await test.step('Import BP', async (step) => {

0 commit comments

Comments
 (0)