tests/playwright: Add Hostname customization test
Adds a Hostname customization test that creates a BP, edits BP, exports and imports it back and verifies the BP content. This test also servers as a template for other customization tests. Includes a refactor of existing helper functions.
This commit is contained in:
parent
91ceaca760
commit
0bddb80e94
10 changed files with 341 additions and 49 deletions
45
playwright/fixtures/cleanup.ts
Normal file
45
playwright/fixtures/cleanup.ts
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import { test as oldTest } from '@playwright/test';
|
||||
|
||||
type WithCleanup = {
|
||||
cleanup: Cleanup;
|
||||
};
|
||||
|
||||
export interface Cleanup {
|
||||
add: (cleanupFn: () => Promise<unknown>) => symbol;
|
||||
runAndAdd: (cleanupFn: () => Promise<unknown>) => Promise<symbol>;
|
||||
remove: (key: symbol) => void;
|
||||
}
|
||||
|
||||
export const test = oldTest.extend<WithCleanup>({
|
||||
// eslint-disable-next-line no-empty-pattern
|
||||
cleanup: async ({}, use) => {
|
||||
const cleanupFns: Map<symbol, () => Promise<unknown>> = new Map();
|
||||
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
await use({
|
||||
add: (cleanupFn) => {
|
||||
const key = Symbol();
|
||||
cleanupFns.set(key, cleanupFn);
|
||||
return key;
|
||||
},
|
||||
runAndAdd: async (cleanupFn) => {
|
||||
await cleanupFn();
|
||||
|
||||
const key = Symbol();
|
||||
cleanupFns.set(key, cleanupFn);
|
||||
return key;
|
||||
},
|
||||
remove: (key) => {
|
||||
cleanupFns.delete(key);
|
||||
},
|
||||
});
|
||||
|
||||
await test.step(
|
||||
'Post-test cleanup',
|
||||
async () => {
|
||||
await Promise.all(Array.from(cleanupFns).map(([, fn]) => fn()));
|
||||
},
|
||||
{ box: true }
|
||||
);
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue