|
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', |
@@ -3093,43 +3109,50 @@ ALL_ENTITIES.forEach(({ key, makeInstance }) => { |
3093 | 3109 | // ── TableColumn-specific extra test ──────────────────────────────────── |
3094 | 3110 |
|
3095 | 3111 | if (key === 'entity_tableColumn') { |
3096 | | - test('Set & update column-level custom property', async ({ page }) => { |
3097 | | - // 5 minutes timeout for this test since it handles all cp types |
3098 | | - test.setTimeout(300000); |
| 3112 | + test.describe('Set & update column-level custom property', async () => { |
| 3113 | + const testData: ColumnsTestData = {} as ColumnsTestData; |
3099 | 3114 |
|
3100 | | - const { apiContext, afterAction } = await getApiContext(page); |
| 3115 | + test.beforeAll(async ({ browser }) => { |
| 3116 | + const { apiContext, afterAction } = await createNewPage(browser); |
3101 | 3117 |
|
3102 | | - const data = await createCustomPropertyForEntity( |
3103 | | - apiContext, |
3104 | | - EntityTypeEndpoint.TableColumn |
3105 | | - ); |
3106 | | - const customPropertyValue = data.customProperties; |
3107 | | - const cleanupUser = data.cleanupUser; |
3108 | | - const users = data.userNames; |
| 3118 | + const data = await createCustomPropertyForEntity( |
| 3119 | + apiContext, |
| 3120 | + EntityTypeEndpoint.TableColumn |
| 3121 | + ); |
| 3122 | + testData.customPropertyValue = data.customProperties; |
| 3123 | + testData.cleanupUser = data.cleanupUser; |
| 3124 | + testData.users = data.userNames; |
3109 | 3125 |
|
3110 | | - const columnFqn = |
3111 | | - tableForColumnTest?.entityResponseData.columns[0] |
3112 | | - .fullyQualifiedName ?? ''; |
3113 | | - const tableFqn = |
3114 | | - tableForColumnTest?.entityResponseData.fullyQualifiedName ?? ''; |
| 3126 | + testData.columnFqn = |
| 3127 | + tableForColumnTest?.entityResponseData.columns[0] |
| 3128 | + .fullyQualifiedName ?? ''; |
| 3129 | + testData.tableFqn = |
| 3130 | + tableForColumnTest?.entityResponseData.fullyQualifiedName ?? ''; |
3115 | 3131 |
|
3116 | | - const properties = Object.values(CustomPropertyTypeByName); |
| 3132 | + await afterAction(); |
| 3133 | + }); |
| 3134 | + |
| 3135 | + test.afterAll(async ({ browser }) => { |
| 3136 | + const { apiContext, afterAction } = await createNewPage(browser); |
| 3137 | + |
| 3138 | + await testData.cleanupUser?.(apiContext); |
| 3139 | + await afterAction(); |
| 3140 | + }); |
3117 | 3141 |
|
3118 | | - for (const type of properties) { |
3119 | | - await test.step(`Set ${type} custom property on column and verify in UI`, async () => { |
| 3142 | + for (const type of Object.values(CustomPropertyTypeByName)) { |
| 3143 | + test(`Set ${type} custom property on column and verify in UI`, async ({ |
| 3144 | + page, |
| 3145 | + }) => { |
3120 | 3146 | await verifyTableColumnCustomPropertyPersistence({ |
3121 | 3147 | page, |
3122 | | - columnFqn, |
3123 | | - tableFqn, |
3124 | | - propertyName: customPropertyValue[type].property.name, |
| 3148 | + columnFqn: testData.columnFqn, |
| 3149 | + tableFqn: testData.tableFqn, |
| 3150 | + propertyName: testData.customPropertyValue[type].property.name, |
3125 | 3151 | propertyType: type, |
3126 | | - users, |
| 3152 | + users: testData.users, |
3127 | 3153 | }); |
3128 | 3154 | }); |
3129 | 3155 | } |
3130 | | - |
3131 | | - await cleanupUser(apiContext); |
3132 | | - await afterAction(); |
3133 | 3156 | }); |
3134 | 3157 | } |
3135 | 3158 |
|
|
0 commit comments