86 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			86 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import { Page } from "@playwright/test";
 | |
| 
 | |
| export default async function mockGroupsAPI({ page }: { page: Page }): Promise<void> {
 | |
|   page.route('*/**/api/default/groups', async route => {
 | |
|     if (route.request().method() === 'GET') {
 | |
|       const json = [
 | |
|         {
 | |
|           "id": "ee44ffb9-1147-4842-a378-9eaeb0f0871a",
 | |
|           "name": "Pam's family",
 | |
|           "icon": "pi pi-users",
 | |
|           "parent_id": null,
 | |
|           "color": "#ff0000",
 | |
|           "attendance": {
 | |
|             "total": 3,
 | |
|             "considered": 2,
 | |
|             "invited": 1,
 | |
|             "confirmed": 0,
 | |
|             "declined": 0,
 | |
|             "tentative": 0
 | |
|           }
 | |
|         },
 | |
|         {
 | |
|           "id": "c8bda6ca-d8af-4bb8-b2bf-e6ec1c21b1e6",
 | |
|           "name": "Pam's work",
 | |
|           "icon": "pi pi-desktop",
 | |
|           "parent_id": null,
 | |
|           "color": "#00ff00",
 | |
|           "attendance": {
 | |
|             "total": 2,
 | |
|             "considered": 0,
 | |
|             "invited": 0,
 | |
|             "confirmed": 0,
 | |
|             "declined": 0,
 | |
|             "tentative": 2
 | |
|           }
 | |
|         },
 | |
|       ];
 | |
| 
 | |
|       await route.fulfill({ json })
 | |
|     } else if (route.request().method() === 'POST') {
 | |
|       const json = {
 | |
|         "id": "4d55bc34-6f42-4e2e-82a1-71ae32da2466",
 | |
|         "name": "Pam's friends",
 | |
|         "icon": "pi pi-desktop",
 | |
|         "parent_id": null,
 | |
|         "color": "#0000ff",
 | |
|         "attendance": {
 | |
|           "total": 0,
 | |
|           "considered": 0,
 | |
|           "invited": 0,
 | |
|           "confirmed": 0,
 | |
|           "declined": 0,
 | |
|           "tentative": 0
 | |
|         }
 | |
|       }
 | |
| 
 | |
|       await route.fulfill({ json })
 | |
|     }
 | |
|   })
 | |
| 
 | |
|   page.route("*/**/api/default/groups/*", async route => {
 | |
|     if (route.request().method() === 'PUT') {
 | |
|       const json = {
 | |
|         "id": "4d55bc34-6f42-4e2e-82a1-71ae32da2466",
 | |
|         "name": "Pam's best friends",
 | |
|         "icon": "pi pi-desktop",
 | |
|         "parent_id": null,
 | |
|         "color": "#0000ff",
 | |
|         "attendance": {
 | |
|           "total": 0,
 | |
|           "considered": 0,
 | |
|           "invited": 0,
 | |
|           "confirmed": 0,
 | |
|           "declined": 0,
 | |
|           "tentative": 0
 | |
|         }
 | |
|       }
 | |
| 
 | |
|       await route.fulfill({ json });
 | |
|     } else if (route.request().method() === 'DELETE') {
 | |
|       const json = {}
 | |
| 
 | |
|       await route.fulfill({ json });
 | |
|     }
 | |
|   });
 | |
| } |