Skip to content

Commit c94e4b3

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 c94e4b3

File tree

14 files changed

+319
-74
lines changed

14 files changed

+319
-74
lines changed

playwright/Customizations/AAP.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,10 @@ test('Create a blueprint with AAP registration customization', async ({
186186
// This is for hosted service only as these features are not available in cockpit plugin
187187
await test.step('Export BP', async (step) => {
188188
step.skip(!isHosted(), 'Exporting is not available in the plugin');
189-
await exportBlueprint(page, blueprintName);
189+
const exportedBP = await exportBlueprint(page);
190+
await cleanup.add(async () => {
191+
await fsPromises.rm(path.dirname(exportedBP), { recursive: true });
192+
});
190193
});
191194

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

playwright/Customizations/Filesystem.spec.ts

Lines changed: 15 additions & 3 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,17 @@ 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
186+
let exportedBP = '';
182187
await test.step('Export BP', async (step) => {
183-
step.skip(!isHosted(), 'Exporting is not available in the plugin');
184-
await exportBlueprint(page, blueprintName);
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('Verify exported BP', async (step) => {
195+
step.skip(isHosted(), 'Only verify the contents of the exported blueprint in cockpit');
196+
await verifyExportedBlueprint(exportedBP, exportedFilesystemBP(blueprintName));
185197
});
186198

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

playwright/Customizations/Firewall.spec.ts

Lines changed: 13 additions & 6 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,17 @@ 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
202+
let exportedBP = '';
198203
await test.step('Export BP', async (step) => {
199-
step.skip(!isHosted(), 'Exporting is not available in the plugin');
200-
await exportBlueprint(page, blueprintName);
204+
exportedBP = await exportBlueprint(page);
205+
await cleanup.add(async () => {
206+
await fsPromises.rm(path.dirname(exportedBP), { recursive: true });
207+
});
201208
});
202209

203-
await test.step('Import BP', async (step) => {
204-
step.skip(!isHosted(), 'Importing is not available in the plugin');
205-
await importBlueprint(page, blueprintName);
210+
await test.step('Verify exported BP', async (step) => {
211+
step.skip(isHosted(), 'Only verify the contents of the exported blueprint in cockpit');
212+
await verifyExportedBlueprint(exportedBP, exportedFirewallBP(blueprintName));
206213
});
207214

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

playwright/Customizations/Hostname.spec.ts

Lines changed: 13 additions & 6 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,17 @@ 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
75+
let exportedBP = '';
7176
await test.step('Export BP', async (step) => {
72-
step.skip(!isHosted(), 'Exporting is not available in the plugin');
73-
await exportBlueprint(page, blueprintName);
77+
exportedBP = await exportBlueprint(page);
78+
await cleanup.add(async () => {
79+
await fsPromises.rm(path.dirname(exportedBP), { recursive: true });
80+
});
7481
});
7582

76-
await test.step('Import BP', async (step) => {
77-
step.skip(!isHosted(), 'Importing is not available in the plugin');
78-
await importBlueprint(page, blueprintName);
83+
await test.step('Verify exported BP', async (step) => {
84+
step.skip(isHosted(), 'Only verify the contents of the exported blueprint in cockpit');
85+
await verifyExportedBlueprint(exportedBP, exportedHostnameBP(blueprintName));
7986
});
8087

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

playwright/Customizations/Kernel.spec.ts

Lines changed: 15 additions & 3 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,17 @@ 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
113+
let exportedBP = '';
109114
await test.step('Export BP', async (step) => {
110-
step.skip(!isHosted(), 'Exporting is not available in the plugin');
111-
await exportBlueprint(page, blueprintName);
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('Verify exported BP', async (step) => {
122+
step.skip(isHosted(), 'Only verify the contents of the exported blueprint in cockpit');
123+
await verifyExportedBlueprint(exportedBP, exportedKernelBP(blueprintName));
112124
});
113125

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

playwright/Customizations/Locale.spec.ts

Lines changed: 13 additions & 6 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,17 @@ 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
133+
let exportedBP = '';
129134
await test.step('Export BP', async (step) => {
130-
step.skip(!isHosted(), 'Exporting is not available in the plugin');
131-
await exportBlueprint(page, blueprintName);
135+
exportedBP = await exportBlueprint(page);
136+
await cleanup.add(async () => {
137+
await fsPromises.rm(path.dirname(exportedBP), { recursive: true });
138+
});
132139
});
133140

134-
await test.step('Import BP', async (step) => {
135-
step.skip(!isHosted(), 'Importing is not available in the plugin');
136-
await importBlueprint(page, blueprintName);
141+
await test.step('Verify exported BP', async (step) => {
142+
step.skip(isHosted(), 'Only verify the contents of the exported blueprint in cockpit');
143+
await verifyExportedBlueprint(exportedBP, exportedLocaleBP(blueprintName));
137144
});
138145

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

playwright/Customizations/OpenSCAP.spec.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +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/cleanup';
5-
import { isHosted } from '../helpers/helpers';
8+
import { isHosted, getHostDistro } from '../helpers/helpers';
69
import { ensureAuthenticated } from '../helpers/login';
710
import { ibFrame, navigateToLandingPage } from '../helpers/navHelpers';
811
import {
@@ -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: 7 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

@@ -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
357359
await test.step('Export blueprint', async (step) => {
358-
step.skip(!isHosted(), 'Exporting is not available in the plugin');
359-
await exportBlueprint(page, blueprintName);
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: 14 additions & 6 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,15 +132,18 @@ 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
135+
136+
let exportedBP = '';
131137
await test.step('Export BP', async (step) => {
132-
step.skip(!isHosted(), 'Exporting is not available in the plugin');
133-
await exportBlueprint(page, blueprintName);
138+
exportedBP = await exportBlueprint(page);
139+
await cleanup.add(async () => {
140+
await fsPromises.rm(path.dirname(exportedBP), { recursive: true });
141+
});
134142
});
135143

136-
await test.step('Import BP', async (step) => {
137-
step.skip(!isHosted(), 'Importing is not available in the plugin');
138-
await importBlueprint(page, blueprintName);
144+
await test.step('Verify exported BP', async (step) => {
145+
step.skip(isHosted(), 'Only verify the contents of the exported blueprint in cockpit');
146+
await verifyExportedBlueprint(exportedBP, exportedSystemdBP(blueprintName));
139147
});
140148

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

playwright/Customizations/Timezone.spec.ts

Lines changed: 15 additions & 3 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,17 @@ 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
110+
let exportedBP = '';
106111
await test.step('Export BP', async (step) => {
107-
step.skip(!isHosted(), 'Exporting is not available in the plugin');
108-
await exportBlueprint(page, blueprintName);
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('Verify exported BP', async (step) => {
119+
step.skip(isHosted(), 'Only verify the contents of the exported blueprint in cockpit');
120+
await verifyExportedBlueprint(exportedBP, exportedTimezoneBP(blueprintName));
109121
});
110122

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

0 commit comments

Comments
 (0)