From bf27472cb609ffbee1af349186bef6df0cc17927 Mon Sep 17 00:00:00 2001 From: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com> Date: Sat, 14 Dec 2024 14:55:53 +0530 Subject: [PATCH 1/7] test(e2e): domain ingestion tests support for ingestionBot login in playwright --- .../resources/ui/playwright/e2e/auth.setup.ts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/auth.setup.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/auth.setup.ts index fc6b43f36141..5644ec50bc20 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/e2e/auth.setup.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/auth.setup.ts @@ -22,6 +22,8 @@ import { import { removeOrganizationPolicyAndRole } from '../utils/team'; const adminFile = 'playwright/.auth/admin.json'; +const ingestionBotFile = 'playwright/.auth/ingestionBot.json'; + const initialSetup = async (page: Page) => { const { apiContext, afterAction } = await getApiContext(page); // Update JWT expiry time to 4 hours @@ -51,3 +53,32 @@ setup('authenticate as admin', async ({ page }) => { // End of authentication steps. await page.context().storageState({ path: adminFile }); }); + +setup('authenticate as ingestion bot', async ({ page }) => { + const admin = new AdminClass(); + + // login with admin user + await admin.login(page); + await page.waitForURL('**/my-data'); + + const { apiContext, afterAction } = await getApiContext(page); + + const bot = await apiContext + .get('/api/v1/bots/name/ingestion-bot') + .then((response) => response.json()); + const tokenData = await apiContext + .get(`/api/v1/users/auth-mechanism/${bot.botUser.id}`) + .then((response) => response.json()); + + await page.evaluate((token) => { + // Set a new value for a key in localStorage + localStorage.setItem( + 'om-session', + JSON.stringify({ state: { oidcIdToken: token } }) + ); + }, tokenData.config.JWTToken); + + await page.context().storageState({ path: ingestionBotFile }); + + await afterAction(); +}); From bfb154a3076696957e067f685e59f26ec20efee1 Mon Sep 17 00:00:00 2001 From: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com> Date: Sat, 14 Dec 2024 16:21:25 +0530 Subject: [PATCH 2/7] added tests --- .../ui/playwright/e2e/Pages/Domains.spec.ts | 61 ++++++++++++++++++- .../resources/ui/playwright/e2e/auth.setup.ts | 44 ++++++------- 2 files changed, 81 insertions(+), 24 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Domains.spec.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Domains.spec.ts index 4a6ee2337773..367d185e71c6 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Domains.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Domains.spec.ts @@ -10,7 +10,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import test, { expect } from '@playwright/test'; +import { expect, Page, test as base } from '@playwright/test'; import { Operation } from 'fast-json-patch'; import { get } from 'lodash'; import { SidebarItem } from '../../constant/sidebar'; @@ -18,6 +18,7 @@ import { DataProduct } from '../../support/domain/DataProduct'; import { Domain } from '../../support/domain/Domain'; import { SubDomain } from '../../support/domain/SubDomain'; import { ENTITY_PATH } from '../../support/entity/Entity.interface'; +import { AdminClass } from '../../support/user/AdminClass'; import { UserClass } from '../../support/user/UserClass'; import { performAdminLogin } from '../../utils/admin'; import { getApiContext, redirectToHomePage } from '../../utils/common'; @@ -39,6 +40,48 @@ import { import { sidebarClick } from '../../utils/sidebar'; import { performUserLogin, visitUserProfilePage } from '../../utils/user'; +const test = base.extend<{ + page: Page; + ingestionBotPage: Page; +}>({ + page: async ({ browser }, use) => { + const adminUser = new AdminClass(); + const adminPage = await browser.newPage(); + await adminUser.login(adminPage); + await use(adminPage); + await adminPage.close(); + }, + ingestionBotPage: async ({ browser }, use) => { + const admin = new AdminClass(); + const page = await browser.newPage(); + + // login with admin user + await admin.login(page); + await page.waitForURL('**/my-data'); + + const { apiContext } = await getApiContext(page); + + const bot = await apiContext + .get('/api/v1/bots/name/ingestion-bot') + .then((response) => response.json()); + const tokenData = await apiContext + .get(`/api/v1/users/auth-mechanism/${bot.botUser.id}`) + .then((response) => response.json()); + + await page.evaluate((token) => { + // Set a new value for a key in localStorage + localStorage.setItem( + 'om-session', + JSON.stringify({ state: { oidcIdToken: token } }) + ); + }, tokenData.config.JWTToken); + + // await afterAction(); + await use(page); + await page.close(); + }, +}); + test.describe('Domains', () => { test.use({ storageState: 'playwright/.auth/admin.json' }); @@ -326,7 +369,7 @@ test.describe('Domains Rbac', () => { await afterAction(); }); - test('Domain Rbac', async ({ browser }) => { + test('Domain Rbac', async ({ browser, ingestionBotPage }) => { test.slow(true); const { page, afterAction, apiContext } = await performAdminLogin(browser); @@ -352,6 +395,20 @@ test.describe('Domains Rbac', () => { await addAssetsToDomain(page, domain2.data, domainAssset2); }); + await test.step( + 'Ingestion bot should access domain assigned assets', + async () => { + await redirectToHomePage(ingestionBotPage); + [...domainAssset1, ...domainAssset2].forEach(async (asset) => { + await asset.visitEntityPage(ingestionBotPage); + + await expect( + page.getByTestId('permission-error-placeholder') + ).not.toBeVisible(); + }); + } + ); + await test.step('User with access to multiple domains', async () => { await userPage .getByTestId('domain-dropdown') diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/auth.setup.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/auth.setup.ts index 5644ec50bc20..e8a9ef7185dc 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/e2e/auth.setup.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/auth.setup.ts @@ -54,31 +54,31 @@ setup('authenticate as admin', async ({ page }) => { await page.context().storageState({ path: adminFile }); }); -setup('authenticate as ingestion bot', async ({ page }) => { - const admin = new AdminClass(); +// setup('authenticate as ingestion bot', async ({ page }) => { +// const admin = new AdminClass(); - // login with admin user - await admin.login(page); - await page.waitForURL('**/my-data'); +// // login with admin user +// await admin.login(page); +// await page.waitForURL('**/my-data'); - const { apiContext, afterAction } = await getApiContext(page); +// const { apiContext, afterAction } = await getApiContext(page); - const bot = await apiContext - .get('/api/v1/bots/name/ingestion-bot') - .then((response) => response.json()); - const tokenData = await apiContext - .get(`/api/v1/users/auth-mechanism/${bot.botUser.id}`) - .then((response) => response.json()); +// const bot = await apiContext +// .get('/api/v1/bots/name/ingestion-bot') +// .then((response) => response.json()); +// const tokenData = await apiContext +// .get(`/api/v1/users/auth-mechanism/${bot.botUser.id}`) +// .then((response) => response.json()); - await page.evaluate((token) => { - // Set a new value for a key in localStorage - localStorage.setItem( - 'om-session', - JSON.stringify({ state: { oidcIdToken: token } }) - ); - }, tokenData.config.JWTToken); +// await page.evaluate((token) => { +// // Set a new value for a key in localStorage +// localStorage.setItem( +// 'om-session', +// JSON.stringify({ state: { oidcIdToken: token } }) +// ); +// }, tokenData.config.JWTToken); - await page.context().storageState({ path: ingestionBotFile }); +// await page.context().storageState({ path: ingestionBotFile }); - await afterAction(); -}); +// await afterAction(); +// }); From 0c78114f2c6a2cf2a0cd6fcdceb06bdaccbe19e2 Mon Sep 17 00:00:00 2001 From: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com> Date: Sat, 14 Dec 2024 21:09:29 +0530 Subject: [PATCH 3/7] add ingestion bot tests --- .../playwright/e2e/Flow/IngestionBot.spec.ts | 157 ++++++++++++++++++ .../ui/playwright/e2e/Pages/Domains.spec.ts | 61 +------ 2 files changed, 159 insertions(+), 59 deletions(-) create mode 100644 openmetadata-ui/src/main/resources/ui/playwright/e2e/Flow/IngestionBot.spec.ts diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Flow/IngestionBot.spec.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Flow/IngestionBot.spec.ts new file mode 100644 index 000000000000..f597dd1858e7 --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Flow/IngestionBot.spec.ts @@ -0,0 +1,157 @@ +/* + * Copyright 2024 Collate. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { expect, Page, test as base } from '@playwright/test'; +import { SidebarItem } from '../../constant/sidebar'; +import { Domain } from '../../support/domain/Domain'; +import { AdminClass } from '../../support/user/AdminClass'; +import { performAdminLogin } from '../../utils/admin'; +import { getApiContext, redirectToHomePage } from '../../utils/common'; +import { + addAssetsToDomain, + selectDomain, + setupAssetsForDomain, +} from '../../utils/domain'; +import { sidebarClick } from '../../utils/sidebar'; + +const test = base.extend<{ + page: Page; + ingestionBotPage: Page; +}>({ + page: async ({ browser }, use) => { + const adminUser = new AdminClass(); + const adminPage = await browser.newPage(); + await adminUser.login(adminPage); + await use(adminPage); + await adminPage.close(); + }, + ingestionBotPage: async ({ browser }, use) => { + const admin = new AdminClass(); + const page = await browser.newPage(); + + // login with admin user + await admin.login(page); + await page.waitForURL('**/my-data'); + + const { apiContext } = await getApiContext(page); + + const bot = await apiContext + .get('/api/v1/bots/name/ingestion-bot') + .then((response) => response.json()); + const tokenData = await apiContext + .get(`/api/v1/users/auth-mechanism/${bot.botUser.id}`) + .then((response) => response.json()); + + await page.evaluate((token) => { + // Set a new value for a key in localStorage + localStorage.setItem( + 'om-session', + JSON.stringify({ state: { oidcIdToken: token } }) + ); + }, tokenData.config.JWTToken); + + // await afterAction(); + await use(page); + await page.close(); + }, +}); + +test.describe('Ingestion Bot ', () => { + const domain1 = new Domain(); + const domain2 = new Domain(); + const domain3 = new Domain(); + + test.beforeAll('Setup pre-requests', async ({ browser }) => { + const { apiContext, afterAction, page } = await performAdminLogin(browser); + await redirectToHomePage(page); + await Promise.all([ + domain1.create(apiContext), + domain2.create(apiContext), + domain3.create(apiContext), + ]); + + await afterAction(); + }); + + test.afterAll('Cleanup pre-requests', async ({ browser }) => { + const { apiContext, afterAction } = await performAdminLogin(browser); + await Promise.all([ + domain1.delete(apiContext), + domain2.delete(apiContext), + domain3.delete(apiContext), + ]); + await afterAction(); + }); + + test.beforeEach('Visit entity details page', async ({ page }) => { + await redirectToHomePage(page); + }); + + test('Ingestion bot should be able to access domain specific domain', async ({ + ingestionBotPage, + page, + }) => { + const { assets: domainAsset1, assetCleanup: assetCleanup1 } = + await setupAssetsForDomain(page); + const { assets: domainAsset2, assetCleanup: assetCleanup2 } = + await setupAssetsForDomain(page); + + await test.step('Assign assets to domains', async () => { + // Add assets to domain 1 + await redirectToHomePage(page); + await sidebarClick(page, SidebarItem.DOMAIN); + await selectDomain(page, domain1.data); + await addAssetsToDomain(page, domain1.data, domainAsset1); + + // Add assets to domain 2 + await redirectToHomePage(page); + await sidebarClick(page, SidebarItem.DOMAIN); + await selectDomain(page, domain2.data); + await addAssetsToDomain(page, domain2.data, domainAsset2); + }); + + await test.step( + 'Ingestion bot should access domain assigned assets', + async () => { + await redirectToHomePage(ingestionBotPage); + + // Check if entity page is accessible & it has domain + for (const asset of domainAsset1) { + await asset.visitEntityPage(ingestionBotPage); + + await expect( + page.getByTestId('permission-error-placeholder') + ).not.toBeVisible(); + + await expect(page.getByTestId('domain-link')).toHaveText( + domain1.data.name + ); + } + // Check if entity page is accessible & it has domain + for (const asset of domainAsset2) { + await asset.visitEntityPage(ingestionBotPage); + + await expect( + page.getByTestId('permission-error-placeholder') + ).not.toBeVisible(); + + await expect(page.getByTestId('domain-link')).toHaveText( + domain2.data.name + ); + } + } + ); + + await assetCleanup1(); + await assetCleanup2(); + }); +}); diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Domains.spec.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Domains.spec.ts index 367d185e71c6..d14cc32c7a2f 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Domains.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Domains.spec.ts @@ -10,7 +10,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { expect, Page, test as base } from '@playwright/test'; +import { expect, test } from '@playwright/test'; import { Operation } from 'fast-json-patch'; import { get } from 'lodash'; import { SidebarItem } from '../../constant/sidebar'; @@ -18,7 +18,6 @@ import { DataProduct } from '../../support/domain/DataProduct'; import { Domain } from '../../support/domain/Domain'; import { SubDomain } from '../../support/domain/SubDomain'; import { ENTITY_PATH } from '../../support/entity/Entity.interface'; -import { AdminClass } from '../../support/user/AdminClass'; import { UserClass } from '../../support/user/UserClass'; import { performAdminLogin } from '../../utils/admin'; import { getApiContext, redirectToHomePage } from '../../utils/common'; @@ -40,48 +39,6 @@ import { import { sidebarClick } from '../../utils/sidebar'; import { performUserLogin, visitUserProfilePage } from '../../utils/user'; -const test = base.extend<{ - page: Page; - ingestionBotPage: Page; -}>({ - page: async ({ browser }, use) => { - const adminUser = new AdminClass(); - const adminPage = await browser.newPage(); - await adminUser.login(adminPage); - await use(adminPage); - await adminPage.close(); - }, - ingestionBotPage: async ({ browser }, use) => { - const admin = new AdminClass(); - const page = await browser.newPage(); - - // login with admin user - await admin.login(page); - await page.waitForURL('**/my-data'); - - const { apiContext } = await getApiContext(page); - - const bot = await apiContext - .get('/api/v1/bots/name/ingestion-bot') - .then((response) => response.json()); - const tokenData = await apiContext - .get(`/api/v1/users/auth-mechanism/${bot.botUser.id}`) - .then((response) => response.json()); - - await page.evaluate((token) => { - // Set a new value for a key in localStorage - localStorage.setItem( - 'om-session', - JSON.stringify({ state: { oidcIdToken: token } }) - ); - }, tokenData.config.JWTToken); - - // await afterAction(); - await use(page); - await page.close(); - }, -}); - test.describe('Domains', () => { test.use({ storageState: 'playwright/.auth/admin.json' }); @@ -369,7 +326,7 @@ test.describe('Domains Rbac', () => { await afterAction(); }); - test('Domain Rbac', async ({ browser, ingestionBotPage }) => { + test('Domain Rbac', async ({ browser }) => { test.slow(true); const { page, afterAction, apiContext } = await performAdminLogin(browser); @@ -395,20 +352,6 @@ test.describe('Domains Rbac', () => { await addAssetsToDomain(page, domain2.data, domainAssset2); }); - await test.step( - 'Ingestion bot should access domain assigned assets', - async () => { - await redirectToHomePage(ingestionBotPage); - [...domainAssset1, ...domainAssset2].forEach(async (asset) => { - await asset.visitEntityPage(ingestionBotPage); - - await expect( - page.getByTestId('permission-error-placeholder') - ).not.toBeVisible(); - }); - } - ); - await test.step('User with access to multiple domains', async () => { await userPage .getByTestId('domain-dropdown') From 1c78c70ba2932639f764ecf1c32b6c4e355f8b6b Mon Sep 17 00:00:00 2001 From: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com> Date: Sat, 14 Dec 2024 21:52:45 +0530 Subject: [PATCH 4/7] update bot tests --- .../playwright/e2e/Flow/IngestionBot.spec.ts | 39 +++++++++++++++---- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Flow/IngestionBot.spec.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Flow/IngestionBot.spec.ts index f597dd1858e7..ce4f3cc356d1 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Flow/IngestionBot.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Flow/IngestionBot.spec.ts @@ -11,6 +11,7 @@ * limitations under the License. */ import { expect, Page, test as base } from '@playwright/test'; +import { GlobalSettingOptions } from '../../constant/settings'; import { SidebarItem } from '../../constant/sidebar'; import { Domain } from '../../support/domain/Domain'; import { AdminClass } from '../../support/user/AdminClass'; @@ -21,7 +22,7 @@ import { selectDomain, setupAssetsForDomain, } from '../../utils/domain'; -import { sidebarClick } from '../../utils/sidebar'; +import { settingClick, sidebarClick } from '../../utils/sidebar'; const test = base.extend<{ page: Page; @@ -129,11 +130,11 @@ test.describe('Ingestion Bot ', () => { await asset.visitEntityPage(ingestionBotPage); await expect( - page.getByTestId('permission-error-placeholder') + ingestionBotPage.getByTestId('permission-error-placeholder') ).not.toBeVisible(); - await expect(page.getByTestId('domain-link')).toHaveText( - domain1.data.name + await expect(ingestionBotPage.getByTestId('domain-link')).toHaveText( + domain1.data.displayName ); } // Check if entity page is accessible & it has domain @@ -141,16 +142,40 @@ test.describe('Ingestion Bot ', () => { await asset.visitEntityPage(ingestionBotPage); await expect( - page.getByTestId('permission-error-placeholder') + ingestionBotPage.getByTestId('permission-error-placeholder') ).not.toBeVisible(); - await expect(page.getByTestId('domain-link')).toHaveText( - domain2.data.name + await expect(ingestionBotPage.getByTestId('domain-link')).toHaveText( + domain2.data.displayName ); } } ); + // Need backend change to support this tests + test.fixme( + 'Ingestion bot should able to access services irrespective of domain', + async () => { + await redirectToHomePage(page); + // change domain + await ingestionBotPage.getByTestId('domain-dropdown').click(); + await ingestionBotPage + .locator( + `[data-menu-id*="${domain1.data.name}"] > .ant-dropdown-menu-title-content` + ) + .click(); + + // validate service list + + await settingClick(ingestionBotPage, GlobalSettingOptions.DATABASES); + const rowKeys = await ingestionBotPage.waitForSelector( + '[data-row-key=*]' + ); + + expect(rowKeys).not.toHaveLength(0); + } + ); + await assetCleanup1(); await assetCleanup2(); }); From fbbf519bff34ce5fc64eaa3d033ce25c5a447652 Mon Sep 17 00:00:00 2001 From: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com> Date: Sat, 14 Dec 2024 21:57:22 +0530 Subject: [PATCH 5/7] revert unwanted changes --- .../ui/playwright/e2e/Pages/Domains.spec.ts | 2 +- .../resources/ui/playwright/e2e/auth.setup.ts | 31 ------------------- 2 files changed, 1 insertion(+), 32 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Domains.spec.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Domains.spec.ts index d14cc32c7a2f..4a6ee2337773 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Domains.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Domains.spec.ts @@ -10,7 +10,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { expect, test } from '@playwright/test'; +import test, { expect } from '@playwright/test'; import { Operation } from 'fast-json-patch'; import { get } from 'lodash'; import { SidebarItem } from '../../constant/sidebar'; diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/auth.setup.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/auth.setup.ts index e8a9ef7185dc..fc6b43f36141 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/e2e/auth.setup.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/auth.setup.ts @@ -22,8 +22,6 @@ import { import { removeOrganizationPolicyAndRole } from '../utils/team'; const adminFile = 'playwright/.auth/admin.json'; -const ingestionBotFile = 'playwright/.auth/ingestionBot.json'; - const initialSetup = async (page: Page) => { const { apiContext, afterAction } = await getApiContext(page); // Update JWT expiry time to 4 hours @@ -53,32 +51,3 @@ setup('authenticate as admin', async ({ page }) => { // End of authentication steps. await page.context().storageState({ path: adminFile }); }); - -// setup('authenticate as ingestion bot', async ({ page }) => { -// const admin = new AdminClass(); - -// // login with admin user -// await admin.login(page); -// await page.waitForURL('**/my-data'); - -// const { apiContext, afterAction } = await getApiContext(page); - -// const bot = await apiContext -// .get('/api/v1/bots/name/ingestion-bot') -// .then((response) => response.json()); -// const tokenData = await apiContext -// .get(`/api/v1/users/auth-mechanism/${bot.botUser.id}`) -// .then((response) => response.json()); - -// await page.evaluate((token) => { -// // Set a new value for a key in localStorage -// localStorage.setItem( -// 'om-session', -// JSON.stringify({ state: { oidcIdToken: token } }) -// ); -// }, tokenData.config.JWTToken); - -// await page.context().storageState({ path: ingestionBotFile }); - -// await afterAction(); -// }); From 315e27d5e49770bae0288161f424b1be54674daa Mon Sep 17 00:00:00 2001 From: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com> Date: Sat, 14 Dec 2024 22:00:49 +0530 Subject: [PATCH 6/7] comment skipped test --- .../playwright/e2e/Flow/IngestionBot.spec.ts | 47 +++++++++---------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Flow/IngestionBot.spec.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Flow/IngestionBot.spec.ts index ce4f3cc356d1..2f2eae93c695 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Flow/IngestionBot.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Flow/IngestionBot.spec.ts @@ -11,7 +11,6 @@ * limitations under the License. */ import { expect, Page, test as base } from '@playwright/test'; -import { GlobalSettingOptions } from '../../constant/settings'; import { SidebarItem } from '../../constant/sidebar'; import { Domain } from '../../support/domain/Domain'; import { AdminClass } from '../../support/user/AdminClass'; @@ -22,7 +21,7 @@ import { selectDomain, setupAssetsForDomain, } from '../../utils/domain'; -import { settingClick, sidebarClick } from '../../utils/sidebar'; +import { sidebarClick } from '../../utils/sidebar'; const test = base.extend<{ page: Page; @@ -153,28 +152,28 @@ test.describe('Ingestion Bot ', () => { ); // Need backend change to support this tests - test.fixme( - 'Ingestion bot should able to access services irrespective of domain', - async () => { - await redirectToHomePage(page); - // change domain - await ingestionBotPage.getByTestId('domain-dropdown').click(); - await ingestionBotPage - .locator( - `[data-menu-id*="${domain1.data.name}"] > .ant-dropdown-menu-title-content` - ) - .click(); - - // validate service list - - await settingClick(ingestionBotPage, GlobalSettingOptions.DATABASES); - const rowKeys = await ingestionBotPage.waitForSelector( - '[data-row-key=*]' - ); - - expect(rowKeys).not.toHaveLength(0); - } - ); + // test.fixme( + // 'Ingestion bot should able to access services irrespective of domain', + // async () => { + // await redirectToHomePage(page); + // // change domain + // await ingestionBotPage.getByTestId('domain-dropdown').click(); + // await ingestionBotPage + // .locator( + // `[data-menu-id*="${domain1.data.name}"] > .ant-dropdown-menu-title-content` + // ) + // .click(); + + // // validate service list + + // await settingClick(ingestionBotPage, GlobalSettingOptions.DATABASES); + // const rowKeys = await ingestionBotPage.waitForSelector( + // '[data-row-key=*]' + // ); + + // expect(rowKeys).not.toHaveLength(0); + // } + // ); await assetCleanup1(); await assetCleanup2(); From 18b24a1c1204597615bbec331844ea76a9e480b7 Mon Sep 17 00:00:00 2001 From: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com> Date: Mon, 16 Dec 2024 15:07:05 +0530 Subject: [PATCH 7/7] check for service within domain --- .../playwright/e2e/Flow/IngestionBot.spec.ts | 62 ++++++++++++------- .../resources/ui/playwright/utils/domain.ts | 35 +++++++++++ 2 files changed, 74 insertions(+), 23 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Flow/IngestionBot.spec.ts b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Flow/IngestionBot.spec.ts index 2f2eae93c695..d4d77dbe1026 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/e2e/Flow/IngestionBot.spec.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/e2e/Flow/IngestionBot.spec.ts @@ -18,9 +18,11 @@ import { performAdminLogin } from '../../utils/admin'; import { getApiContext, redirectToHomePage } from '../../utils/common'; import { addAssetsToDomain, + addServicesToDomain, selectDomain, setupAssetsForDomain, } from '../../utils/domain'; +import { visitServiceDetailsPage } from '../../utils/service'; import { sidebarClick } from '../../utils/sidebar'; const test = base.extend<{ @@ -96,6 +98,8 @@ test.describe('Ingestion Bot ', () => { await redirectToHomePage(page); }); + test.slow(); + test('Ingestion bot should be able to access domain specific domain', async ({ ingestionBotPage, page, @@ -151,29 +155,41 @@ test.describe('Ingestion Bot ', () => { } ); - // Need backend change to support this tests - // test.fixme( - // 'Ingestion bot should able to access services irrespective of domain', - // async () => { - // await redirectToHomePage(page); - // // change domain - // await ingestionBotPage.getByTestId('domain-dropdown').click(); - // await ingestionBotPage - // .locator( - // `[data-menu-id*="${domain1.data.name}"] > .ant-dropdown-menu-title-content` - // ) - // .click(); - - // // validate service list - - // await settingClick(ingestionBotPage, GlobalSettingOptions.DATABASES); - // const rowKeys = await ingestionBotPage.waitForSelector( - // '[data-row-key=*]' - // ); - - // expect(rowKeys).not.toHaveLength(0); - // } - // ); + await test.step('Assign services to domains', async () => { + // Add assets to domain 1 + await redirectToHomePage(page); + await sidebarClick(page, SidebarItem.DOMAIN); + await selectDomain(page, domain1.data); + await addServicesToDomain(page, domain1.data, [ + domainAsset1[0].get().service, + ]); + + // Add assets to domain 2 + await redirectToHomePage(page); + await sidebarClick(page, SidebarItem.DOMAIN); + await selectDomain(page, domain2.data); + await addServicesToDomain(page, domain2.data, [ + domainAsset2[0].get().service, + ]); + }); + + await test.step( + 'Ingestion bot should access domain assigned services', + async () => { + await redirectToHomePage(ingestionBotPage); + + // Check if services is searchable and accessible or not + await visitServiceDetailsPage(ingestionBotPage, { + name: domainAsset1[0].get().service.name, + type: domainAsset1[0].serviceCategory, + }); + + // check if service has domain or not + await expect(ingestionBotPage.getByTestId('domain-link')).toHaveText( + domain1.data.displayName + ); + } + ); await assetCleanup1(); await assetCleanup2(); diff --git a/openmetadata-ui/src/main/resources/ui/playwright/utils/domain.ts b/openmetadata-ui/src/main/resources/ui/playwright/utils/domain.ts index 3704966267e1..c114f7cee1be 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/utils/domain.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/utils/domain.ts @@ -320,6 +320,41 @@ export const addAssetsToDomain = async ( await checkAssetsCount(page, assets.length); }; +export const addServicesToDomain = async ( + page: Page, + domain: Domain['data'], + assets: EntityClass[] +) => { + await goToAssetsTab(page, domain); + + await page.getByTestId('domain-details-add-button').click(); + await page.getByRole('menuitem', { name: 'Assets', exact: true }).click(); + + for (const asset of assets) { + const name = get(asset, 'name'); + const fqn = get(asset, 'fullyQualifiedName'); + + const searchRes = page.waitForResponse( + `/api/v1/search/query?q=${name}&index=all&from=0&size=25&*` + ); + await page + .getByTestId('asset-selection-modal') + .getByTestId('searchbar') + .fill(name); + await searchRes; + + await page.locator(`[data-testid="table-data-card_${fqn}"] input`).check(); + } + + const assetsAddRes = page.waitForResponse( + `/api/v1/domains/${encodeURIComponent( + domain.fullyQualifiedName ?? '' + )}/assets/add` + ); + await page.getByTestId('save-btn').click(); + await assetsAddRes; +}; + export const addAssetsToDataProduct = async ( page: Page, dataProduct: DataProduct['data'],