Skip to content

Commit ceb2140

Browse files
committed
add global teardown's cleanup test notebooks
1 parent c916abb commit ceb2140

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

zeppelin-web-angular/e2e/global-teardown.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,63 @@ async function globalTeardown() {
1717

1818
LoginTestUtil.resetCache();
1919
console.log('✅ Test cache cleared');
20+
21+
// Clean up test notebooks that may have been left behind due to test failures
22+
await cleanupTestNotebooks();
23+
}
24+
25+
async function cleanupTestNotebooks() {
26+
try {
27+
console.log('🗂️ Cleaning up test notebooks...');
28+
29+
const baseURL = process.env.CI ? 'http://localhost:8080' : 'http://localhost:4200';
30+
31+
// Get all notebooks
32+
const response = await fetch(`${baseURL}/api/notebook`);
33+
const data = await response.json();
34+
35+
if (!data.body || !Array.isArray(data.body)) {
36+
console.log('No notebooks found or invalid response format');
37+
return;
38+
}
39+
40+
// Filter notebooks that start with "Test Notebook" (created by createTestNotebook)
41+
const testNotebooks = data.body.filter(
42+
(notebook: { path: string }) => notebook.path && notebook.path.startsWith('/Test Notebook ')
43+
);
44+
45+
if (testNotebooks.length === 0) {
46+
console.log('✅ No test notebooks to clean up');
47+
return;
48+
}
49+
50+
console.log(`Found ${testNotebooks.length} test notebooks to delete`);
51+
52+
// Delete test notebooks
53+
for (const notebook of testNotebooks) {
54+
try {
55+
console.log(`Deleting test notebook: ${notebook.id} (${notebook.path})`);
56+
const deleteResponse = await fetch(`${baseURL}/api/notebook/${notebook.id}`, {
57+
method: 'DELETE'
58+
});
59+
60+
if (deleteResponse.ok) {
61+
console.log(`✅ Deleted: ${notebook.path}`);
62+
} else {
63+
console.warn(`⚠️ Failed to delete ${notebook.path}: ${deleteResponse.status}`);
64+
}
65+
66+
// Small delay to avoid overwhelming the server
67+
await new Promise(resolve => setTimeout(resolve, 50));
68+
} catch (error) {
69+
console.warn(`⚠️ Error deleting notebook ${notebook.id}:`, error);
70+
}
71+
}
72+
73+
console.log('✅ Test notebook cleanup completed');
74+
} catch (error) {
75+
console.warn('⚠️ Failed to cleanup test notebooks:', error);
76+
}
2077
}
2178

2279
export default globalTeardown;

zeppelin-web-angular/e2e/models/home-page.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class HomePage extends BasePage {
4545
this.notebookSection = page.locator('text=Notebook').first();
4646
this.helpSection = page.locator('text=Help').first();
4747
this.communitySection = page.locator('text=Community').first();
48-
this.createNewNoteButton = page.locator('text=Create new Note');
48+
this.createNewNoteButton = page.locator('zeppelin-node-list a').filter({ hasText: 'Create new Note' });
4949
this.importNoteButton = page.locator('text=Import Note');
5050
this.searchInput = page.locator('textbox', { hasText: 'Search' });
5151
this.filterInput = page.locator('input[placeholder*="Filter"]');

0 commit comments

Comments
 (0)