Skip to content

Commit

Permalink
Fix flaky tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aniketkatkar97 committed Sep 24, 2024
1 parent 1bb9112 commit 53e19ce
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const setValueForProperty = async (data: {

case 'enum':
await page.click('#enumValues');
await page.fill('#enumValues', value);
await page.fill('#enumValues', value, { force: true });
await page.press('#enumValues', 'Enter');
await clickOutside(page);
await page.click('[data-testid="inline-save-btn"]');
Expand Down Expand Up @@ -343,12 +343,15 @@ export const createCustomPropertyForEntity = async (
'/api/v1/metadata/types?category=field&limit=20'
);
const properties = await propertiesResponse.json();
const propertyList = properties.data.filter((item) =>
Object.values(CustomPropertyTypeByName).includes(item.name)
const propertyList = properties.data.filter(
(item: { name: CustomPropertyTypeByName }) =>
Object.values(CustomPropertyTypeByName).includes(item.name)
);

const entitySchemaResponse = await apiContext.get(
`/api/v1/metadata/types/name/${ENTITY_PATH[endpoint]}`
`/api/v1/metadata/types/name/${
ENTITY_PATH[endpoint as keyof typeof ENTITY_PATH]
}`
);
const entitySchema = await entitySchemaResponse.json();

Expand All @@ -373,7 +376,7 @@ export const createCustomPropertyForEntity = async (
acc[`user${index + 1}`] = user.getUserName();

return acc;
}, {});
}, {} as Record<string, string>);

// Define an asynchronous function to clean up (delete) all users in the users array
const cleanupUser = async (apiContext: APIRequestContext) => {
Expand Down Expand Up @@ -441,17 +444,23 @@ export const createCustomPropertyForEntity = async (
const customProperty = await customPropertyResponse.json();

// Process the custom properties
customProperties = customProperty.customProperties.reduce((prev, curr) => {
const propertyTypeName = curr.propertyType.name;

return {
...prev,
[propertyTypeName]: {
...getPropertyValues(propertyTypeName, userNames),
property: curr,
},
};
}, {});
customProperties = customProperty.customProperties.reduce(
(
prev: Record<string, string>,
curr: Record<string, Record<string, string>>
) => {
const propertyTypeName = curr.propertyType.name;

return {
...prev,
[propertyTypeName]: {
...getPropertyValues(propertyTypeName, userNames),
property: curr,
},
};
},
{}
);
}

return { customProperties, cleanupUser };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const removeDomain = async (page: Page) => {
await expect(page.getByTestId('no-domain-text')).toContainText('No Domain');
};

export const validateDomainForm = async (page) => {
export const validateDomainForm = async (page: Page) => {
// Error messages
await expect(page.locator('#name_help')).toHaveText('Name is required');
await expect(page.locator('#description_help')).toHaveText(
Expand Down Expand Up @@ -408,7 +408,7 @@ export const createDataProduct = async (
page: Page,
dataProduct: DataProduct['data']
) => {
await page.getByTestId('domain-details-add-button').click();
await page.getByTestId('domain-details-add-button').click({ force: true });
await page.getByRole('menuitem', { name: 'Data Products' }).click();

await expect(page.getByText('Add Data Product')).toBeVisible();
Expand Down

0 comments on commit 53e19ce

Please sign in to comment.