|
25 | 25 | * so cleanup always runs in afterAll even when a test fails mid-way. |
26 | 26 | */ |
27 | 27 |
|
28 | | -import { expect, test } from '@playwright/test'; |
| 28 | +import { APIRequestContext, expect, test } from '@playwright/test'; |
29 | 29 | import { CUSTOM_PROPERTIES_ENTITIES } from '../../constant/customProperty'; |
30 | 30 | import { |
31 | 31 | CP_BASE_VALUES, |
@@ -72,6 +72,7 @@ import { |
72 | 72 | import { |
73 | 73 | addCustomPropertiesForEntity, |
74 | 74 | createCustomPropertyForEntity, |
| 75 | + CustomProperty, |
75 | 76 | CustomPropertyTypeByName, |
76 | 77 | deleteCreatedProperty, |
77 | 78 | editCreatedProperty, |
@@ -133,6 +134,21 @@ type CRUDEntity = { |
133 | 134 | makeInstance: (() => AssetTypes | OtherTypes) | null; |
134 | 135 | }; |
135 | 136 |
|
| 137 | +type ColumnsTestData = { |
| 138 | + customPropertyValue: Record< |
| 139 | + string, |
| 140 | + { |
| 141 | + value: string; |
| 142 | + newValue: string; |
| 143 | + property: CustomProperty; |
| 144 | + } |
| 145 | + >; |
| 146 | + cleanupUser: (apiContext: APIRequestContext) => Promise<void>; |
| 147 | + users: Record<string, string>; |
| 148 | + columnFqn: string; |
| 149 | + tableFqn: string; |
| 150 | +}; |
| 151 | + |
136 | 152 | const BASIC_PROPERTIES = [ |
137 | 153 | 'Integer', |
138 | 154 | 'String', |
@@ -3340,43 +3356,50 @@ ALL_ENTITIES.forEach(({ key, makeInstance }) => { |
3340 | 3356 | // ── TableColumn-specific extra test ──────────────────────────────────── |
3341 | 3357 |
|
3342 | 3358 | if (key === 'entity_tableColumn') { |
3343 | | - test('Set & update column-level custom property', async ({ page }) => { |
3344 | | - // 5 minutes timeout for this test since it handles all cp types |
3345 | | - test.setTimeout(300000); |
| 3359 | + test.describe('Set & update column-level custom property', async () => { |
| 3360 | + const testData: ColumnsTestData = {} as ColumnsTestData; |
3346 | 3361 |
|
3347 | | - const { apiContext, afterAction } = await getApiContext(page); |
| 3362 | + test.beforeAll(async ({ browser }) => { |
| 3363 | + const { apiContext, afterAction } = await createNewPage(browser); |
3348 | 3364 |
|
3349 | | - const data = await createCustomPropertyForEntity( |
3350 | | - apiContext, |
3351 | | - EntityTypeEndpoint.TableColumn |
3352 | | - ); |
3353 | | - const customPropertyValue = data.customProperties; |
3354 | | - const cleanupUser = data.cleanupUser; |
3355 | | - const users = data.userNames; |
| 3365 | + const data = await createCustomPropertyForEntity( |
| 3366 | + apiContext, |
| 3367 | + EntityTypeEndpoint.TableColumn |
| 3368 | + ); |
| 3369 | + testData.customPropertyValue = data.customProperties; |
| 3370 | + testData.cleanupUser = data.cleanupUser; |
| 3371 | + testData.users = data.userNames; |
3356 | 3372 |
|
3357 | | - const columnFqn = |
3358 | | - tableForColumnTest?.entityResponseData.columns[0] |
3359 | | - .fullyQualifiedName ?? ''; |
3360 | | - const tableFqn = |
3361 | | - tableForColumnTest?.entityResponseData.fullyQualifiedName ?? ''; |
| 3373 | + testData.columnFqn = |
| 3374 | + tableForColumnTest?.entityResponseData.columns[0] |
| 3375 | + .fullyQualifiedName ?? ''; |
| 3376 | + testData.tableFqn = |
| 3377 | + tableForColumnTest?.entityResponseData.fullyQualifiedName ?? ''; |
3362 | 3378 |
|
3363 | | - const properties = Object.values(CustomPropertyTypeByName); |
| 3379 | + await afterAction(); |
| 3380 | + }); |
| 3381 | + |
| 3382 | + test.afterAll(async ({ browser }) => { |
| 3383 | + const { apiContext, afterAction } = await createNewPage(browser); |
| 3384 | + |
| 3385 | + await testData.cleanupUser?.(apiContext); |
| 3386 | + await afterAction(); |
| 3387 | + }); |
3364 | 3388 |
|
3365 | | - for (const type of properties) { |
3366 | | - await test.step(`Set ${type} custom property on column and verify in UI`, async () => { |
| 3389 | + for (const type of Object.values(CustomPropertyTypeByName)) { |
| 3390 | + test(`Set ${type} custom property on column and verify in UI`, async ({ |
| 3391 | + page, |
| 3392 | + }) => { |
3367 | 3393 | await verifyTableColumnCustomPropertyPersistence({ |
3368 | 3394 | page, |
3369 | | - columnFqn, |
3370 | | - tableFqn, |
3371 | | - propertyName: customPropertyValue[type].property.name, |
| 3395 | + columnFqn: testData.columnFqn, |
| 3396 | + tableFqn: testData.tableFqn, |
| 3397 | + propertyName: testData.customPropertyValue[type].property.name, |
3372 | 3398 | propertyType: type, |
3373 | | - users, |
| 3399 | + users: testData.users, |
3374 | 3400 | }); |
3375 | 3401 | }); |
3376 | 3402 | } |
3377 | | - |
3378 | | - await cleanupUser(apiContext); |
3379 | | - await afterAction(); |
3380 | 3403 | }); |
3381 | 3404 | } |
3382 | 3405 |
|
|
0 commit comments