Skip to content

Commit

Permalink
testing search RBAC
Browse files Browse the repository at this point in the history
  • Loading branch information
chirag-madlani committed Sep 25, 2024
1 parent 17757bf commit 1d33d5d
Show file tree
Hide file tree
Showing 4 changed files with 175 additions and 155 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export enum GlobalSettingOptions {
DATA_PRODUCTS = 'dataProducts',
DASHBOARD_DATA_MODEL = 'dashboardDataModels',
METRICS = 'metrics',
SEARCH_RBAC = 'search-rbac',
}

export const SETTINGS_OPTIONS_PATH = {
Expand Down Expand Up @@ -189,6 +190,11 @@ export const SETTINGS_OPTIONS_PATH = {
GlobalSettingsMenuCategory.CUSTOM_PROPERTIES,
`${GlobalSettingsMenuCategory.CUSTOM_PROPERTIES}.${GlobalSettingOptions.GLOSSARY_TERM}`,
],

[GlobalSettingOptions.SEARCH_RBAC]: [
GlobalSettingsMenuCategory.ACCESS,
`${GlobalSettingsMenuCategory.ACCESS}.${GlobalSettingOptions.SEARCH_RBAC}`,
],
};

export const SETTING_CUSTOM_PROPERTIES_PATH = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,22 @@ test.describe.serial('Persona operations', () => {

await page.locator(descriptionBox).fill(PERSONA_DETAILS.description);

const userResponse = page.waitForResponse('/api/v1/users?*');
const userListResponse = page.waitForResponse(
'/api/v1/users?limit=*&isBot=false*'
);
await page.getByTestId('add-users').click();
await userResponse;
await userListResponse;

await page.waitForSelector('[data-testid="selectable-list"]');
await page.waitForSelector('[data-testid="loader"]', { state: 'detached' });

const searchUser = page.waitForResponse(
`/api/v1/search/query?q=*${encodeURIComponent(
user.responseData.displayName
)}*`
);
await page.getByTestId('searchbar').fill(user.responseData.displayName);

await searchUser;

await page
.getByRole('listitem', { name: user.responseData.displayName })
.click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,188 +27,192 @@ import { settingClick } from '../../utils/sidebar';

test.use({ storageState: 'playwright/.auth/admin.json' });

test.describe.serial('Data Insight settings page should work properly', () => {
test.beforeEach(async ({ page }) => {
await redirectToHomePage(page);

const appsResponse = page.waitForResponse(
`/api/v1/apps?limit=15&include=non-deleted`
);

await settingClick(page, GlobalSettingOptions.APPLICATIONS);
await appsResponse;
});

test('Edit data insight application', async ({ page }) => {
const appResponse = page.waitForResponse(
`/api/v1/apps/name/DataInsightsApplication?fields=owners%2Cpipelines&include=all`
);

// Click on the config button
await page.click(
'[data-testid="data-insights-application-card"] [data-testid="config-btn"]'
);

await appResponse;

// Click on the edit button
await page.getByTestId('edit-button').click();

// Select cron type
await page.getByTestId('cron-type').click();
await page.click('.rc-virtual-list [title="Day"]');

// Select hour
await page.click('[data-testid="hour-options"]');
await page.click('#hour-select_list + .rc-virtual-list [title="06"]');
test.describe.serial(
'Data Insight settings page should work properly',
{ tag: '@data-insight' },
() => {
test.beforeEach(async ({ page }) => {
await redirectToHomePage(page);

const appsResponse = page.waitForResponse(
`/api/v1/apps?limit=15&include=non-deleted`
);

// Select minute
await page.click('[data-testid="minute-options"]');
await page.click('#minute-select_list + .rc-virtual-list [title="00"]');
await settingClick(page, GlobalSettingOptions.APPLICATIONS);
await appsResponse;
});

// Click on deploy button
await page.click('.ant-modal-body [data-testid="deploy-button"]');
test('Edit data insight application', async ({ page }) => {
const appResponse = page.waitForResponse(
`/api/v1/apps/name/DataInsightsApplication?fields=owners%2Cpipelines&include=all`
);

await toastNotification(page, 'Schedule saved successfully');
// Click on the config button
await page.click(
'[data-testid="data-insights-application-card"] [data-testid="config-btn"]'
);

// Verify cron string
await expect(page.locator('[data-testid="cron-string"]')).toContainText(
'At 06:00 AM'
);
});
await appResponse;

test('Uninstall application', async ({ page }) => {
const appResponse = page.waitForResponse(
`/api/v1/apps/name/DataInsightsApplication?fields=*`
);
// Click on the edit button
await page.getByTestId('edit-button').click();

// Click on the config button
await page.click(
'[data-testid="data-insights-application-card"] [data-testid="config-btn"]'
);
// Select cron type
await page.getByTestId('cron-type').click();
await page.click('.rc-virtual-list [title="Day"]');

await appResponse;
// Select hour
await page.click('[data-testid="hour-options"]');
await page.click('#hour-select_list + .rc-virtual-list [title="06"]');

// Click on the manage button
await page.click('[data-testid="manage-button"]');
// Select minute
await page.click('[data-testid="minute-options"]');
await page.click('#minute-select_list + .rc-virtual-list [title="00"]');

// Click on the uninstall button
await page.click('[data-testid="uninstall-button-title"]');
// Click on deploy button
await page.click('.ant-modal-body [data-testid="deploy-button"]');

// Click on the save button
await page.click('[data-testid="save-button"]');
await toastNotification(page, 'Schedule saved successfully');

await toastNotification(page, 'Application uninstalled successfully');
// Verify cron string
await expect(page.locator('[data-testid="cron-string"]')).toContainText(
'At 06:00 AM'
);
});

await expect(
page.locator('[data-testid="data-insights-application-card"]')
).toBeHidden();
});
test('Uninstall application', async ({ page }) => {
const appResponse = page.waitForResponse(
`/api/v1/apps/name/DataInsightsApplication?fields=*`
);

test('Install application', async ({ page }) => {
// Click on the add application button
await page.click('[data-testid="add-application"]');
// Click on the config button
await page.click(
'[data-testid="data-insights-application-card"] [data-testid="config-btn"]'
);

// Click on the config button
await page.click(
'[data-testid="data-insights-application-card"] [data-testid="config-btn"]'
);
await appResponse;

// Click on the install application button
await page.click('[data-testid="install-application"]');
// Click on the manage button
await page.click('[data-testid="manage-button"]');

// Click on the save button
await page.click('[data-testid="save-button"]');
// Click on the uninstall button
await page.click('[data-testid="uninstall-button-title"]');

// Enable backfill configuration
await page.click('#root\\/backfillConfiguration\\/enabled');
// Click on the save button
await page.click('[data-testid="save-button"]');

// Set start and end dates
const startDate = customFormatDateTime(getCurrentMillis(), 'yyyy-MM-dd');
const endDate = customFormatDateTime(
getEpochMillisForFutureDays(5),
'yyyy-MM-dd'
);
await page.fill('#root\\/backfillConfiguration\\/startDate', startDate);
await page.fill('#root\\/backfillConfiguration\\/endDate', endDate);
await toastNotification(page, 'Application uninstalled successfully');

// Submit the form
await page.click('[data-testid="submit-btn"]');
await expect(
page.locator('[data-testid="data-insights-application-card"]')
).toBeHidden();
});

// Set cron type
await page.click('[data-testid="cron-type"]');
await page.click('.rc-virtual-list [title="Day"]');
test('Install application', async ({ page }) => {
// Click on the add application button
await page.click('[data-testid="add-application"]');

await expect(
page.locator('[data-testid="cron-type"] .ant-select-selection-item')
).toHaveText('Day');
// Click on the config button
await page.click(
'[data-testid="data-insights-application-card"] [data-testid="config-btn"]'
);

// Click on the deploy button
await page.click('[data-testid="deploy-button"]');
// Click on the install application button
await page.click('[data-testid="install-application"]');

// Verify the application card is visible
// Click on the save button
await page.click('[data-testid="save-button"]');

await expect(
page.locator('[data-testid="data-insights-application-card"]')
).toBeVisible();
});
// Enable backfill configuration
await page.click('#root\\/backfillConfiguration\\/enabled');

if (process.env.PLAYWRIGHT_IS_OSS) {
test('Run application', async ({ page }) => {
const appResponse = page.waitForResponse(
`/api/v1/apps/name/DataInsightsApplication?fields=*`
// Set start and end dates
const startDate = customFormatDateTime(getCurrentMillis(), 'yyyy-MM-dd');
const endDate = customFormatDateTime(
getEpochMillisForFutureDays(5),
'yyyy-MM-dd'
);
await page.fill('#root\\/backfillConfiguration\\/startDate', startDate);
await page.fill('#root\\/backfillConfiguration\\/endDate', endDate);

// Click on the config button
await page.click(
'[data-testid="data-insights-application-card"] [data-testid="config-btn"]'
);
// Submit the form
await page.click('[data-testid="submit-btn"]');

await appResponse;
// Set cron type
await page.click('[data-testid="cron-type"]');
await page.click('.rc-virtual-list [title="Day"]');

// Click on the run now button
await page.click('[data-testid="run-now-button"]');

const { apiContext } = await getApiContext(page);

await page.waitForTimeout(2000);

// Check data insight success status (assuming this is a custom function you need to implement)
await expect
.poll(
async () => {
const response = await apiContext
.get(
'/api/v1/apps/name/DataInsightsApplication/status?offset=0&limit=1'
)
.then((res) => res.json());

return response.data[0].status;
},
{
// Custom expect message for reporting, optional.
message: 'Wait for the pipeline to be successful',
timeout: 60_000,
intervals: [5_000, 10_000],
}
)
.toBe('success');

// update page
await page.reload();

// Click on the logs button
await page.click('[data-testid="logs"]');

// Verify the stats component contains 'Success'
await expect(
page.locator('[data-testid="stats-component"]')
).toContainText('Success');
page.locator('[data-testid="cron-type"] .ant-select-selection-item')
).toHaveText('Day');

// Click on the deploy button
await page.click('[data-testid="deploy-button"]');

// Verify the application card is visible

// Verify the app entity stats history table is visible
await expect(
page.locator('[data-testid="app-entity-stats-history-table"]')
page.locator('[data-testid="data-insights-application-card"]')
).toBeVisible();
});

if (process.env.PLAYWRIGHT_IS_OSS) {
test('Run application', async ({ page }) => {
const appResponse = page.waitForResponse(
`/api/v1/apps/name/DataInsightsApplication?fields=*`
);

// Click on the config button
await page.click(
'[data-testid="data-insights-application-card"] [data-testid="config-btn"]'
);

await appResponse;

// Click on the run now button
await page.click('[data-testid="run-now-button"]');

const { apiContext } = await getApiContext(page);

await page.waitForTimeout(2000);

// Check data insight success status (assuming this is a custom function you need to implement)
await expect
.poll(
async () => {
const response = await apiContext
.get(
'/api/v1/apps/name/DataInsightsApplication/status?offset=0&limit=1'
)
.then((res) => res.json());

return response.data[0].status;
},
{
// Custom expect message for reporting, optional.
message: 'Wait for the pipeline to be successful',
timeout: 60_000,
intervals: [5_000, 10_000],
}
)
.toBe('success');

// update page
await page.reload();

// Click on the logs button
await page.click('[data-testid="logs"]');

// Verify the stats component contains 'Success'
await expect(
page.locator('[data-testid="stats-component"]')
).toContainText('Success');

// Verify the app entity stats history table is visible
await expect(
page.locator('[data-testid="app-entity-stats-history-table"]')
).toBeVisible();
});
}
}
});
);
Loading

0 comments on commit 1d33d5d

Please sign in to comment.