Skip to content

Commit a3e5190

Browse files
authored
Playwright: Fix users.spec default persona test (open-metadata#23820)
* Playwright: Fix users.spec default persona test * minor fix * minor fix * minor fix
1 parent 50dbe6f commit a3e5190

File tree

1 file changed

+42
-43
lines changed
  • openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages

1 file changed

+42
-43
lines changed

openmetadata-ui/src/main/resources/ui/playwright/e2e/Pages/Users.spec.ts

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,8 @@ test.describe('User Profile Feed Interactions', () => {
535535

536536
test.describe('User Profile Dropdown Persona Interactions', () => {
537537
test.beforeAll('Prerequisites', async ({ adminPage }) => {
538+
test.slow(true);
539+
538540
// First, add personas to the user profile for testing
539541
await visitOwnProfilePage(adminPage);
540542
await adminPage.waitForSelector('[data-testid="persona-details-card"]');
@@ -707,7 +709,7 @@ test.describe('User Profile Dropdown Persona Interactions', () => {
707709
.allTextContents();
708710

709711
// Verify first one contains the default persona name
710-
expect(personaTexts[0]).toContain(persona1.data.displayName);
712+
expect(personaTexts[0]).toContain(persona1.responseData.displayName);
711713
}
712714
});
713715

@@ -879,7 +881,7 @@ test.describe('User Profile Dropdown Persona Interactions', () => {
879881
.locator('.ant-typography')
880882
.textContent();
881883

882-
expect(newDefaultPersonaText).toContain(persona2.data.displayName);
884+
expect(newDefaultPersonaText).toContain(persona2.responseData.displayName);
883885
expect(newDefaultPersonaText).not.toBe(originalDefaultPersonaText);
884886

885887
await expect(
@@ -950,10 +952,43 @@ test.describe('User Profile Dropdown Persona Interactions', () => {
950952
});
951953
});
952954

953-
test.describe.serial('User Profile Persona Interactions', () => {
955+
test.describe('User Profile Persona Interactions', () => {
956+
test.beforeEach(async ({ browser }) => {
957+
const { apiContext, afterAction } = await performAdminLogin(browser);
958+
959+
// Patch admin user to add personas
960+
await adminUser.patch({
961+
apiContext,
962+
patchData: [
963+
{
964+
op: 'add',
965+
path: '/personas',
966+
value: [
967+
{
968+
id: persona1.responseData.id,
969+
type: 'persona',
970+
name: persona1.responseData.name,
971+
fullyQualifiedName: persona1.responseData.fullyQualifiedName,
972+
},
973+
{
974+
id: persona2.responseData.id,
975+
type: 'persona',
976+
name: persona2.responseData.name,
977+
fullyQualifiedName: persona2.responseData.fullyQualifiedName,
978+
},
979+
],
980+
},
981+
],
982+
});
983+
984+
await afterAction();
985+
});
986+
954987
test('Should add, remove, and navigate to persona pages for Personas section', async ({
955988
adminPage,
956989
}) => {
990+
test.slow(true);
991+
957992
await redirectToHomePage(adminPage);
958993
await visitOwnProfilePage(adminPage);
959994

@@ -1024,50 +1059,14 @@ test.describe.serial('User Profile Persona Interactions', () => {
10241059
test('Should add, remove, and navigate to persona pages for Default Persona section', async ({
10251060
adminPage,
10261061
}) => {
1062+
test.slow(true);
1063+
10271064
await redirectToHomePage(adminPage);
10281065
await visitOwnProfilePage(adminPage);
10291066

10301067
// Wait for the persona card to be visible
10311068
await adminPage.waitForSelector('[data-testid="persona-details-card"]');
10321069

1033-
// First, add some personas to the user so we can select a default persona
1034-
await test.step('Add personas to user profile first', async () => {
1035-
// Click edit button for Personas section (regular personas, not default)
1036-
await adminPage
1037-
.locator('[data-testid="edit-user-persona"]')
1038-
.first()
1039-
.click();
1040-
1041-
// Wait for persona popover and select multiple personas
1042-
await adminPage.waitForSelector('[data-testid="persona-select-list"]');
1043-
await adminPage.locator('[data-testid="persona-select-list"]').click();
1044-
1045-
// Wait for dropdown to open and options to be visible
1046-
await adminPage.waitForSelector('.ant-select-dropdown', {
1047-
state: 'visible',
1048-
});
1049-
1050-
// Select multiple personas - try test IDs first, fallback to role selectors
1051-
const persona1OptionTestId = adminPage.getByTestId(
1052-
`${persona1.data.displayName}-option`
1053-
);
1054-
1055-
await persona1OptionTestId.click();
1056-
1057-
const persona2OptionTestId = adminPage.getByTestId(
1058-
`${persona2.data.displayName}-option`
1059-
);
1060-
1061-
await persona2OptionTestId.click();
1062-
1063-
const personaEditResponse = adminPage.waitForResponse('/api/v1/users/*');
1064-
// Save the changes
1065-
await adminPage
1066-
.locator('[data-testid="user-profile-persona-edit-save"]')
1067-
.click();
1068-
await personaEditResponse;
1069-
});
1070-
10711070
// Test adding default persona
10721071
await test.step('Add default persona to user profile', async () => {
10731072
// Click edit button for Default Persona section using specific test ID
@@ -1093,7 +1092,7 @@ test.describe.serial('User Profile Persona Interactions', () => {
10931092

10941093
// Select specific persona for default - try test ID first, fallback to role selector
10951094
const defaultPersonaOptionTestId = adminPage.getByTestId(
1096-
`${persona1.data.displayName}-option`
1095+
`${persona1.responseData.displayName}-option`
10971096
);
10981097

10991098
await defaultPersonaOptionTestId.click();
@@ -1109,7 +1108,7 @@ test.describe.serial('User Profile Persona Interactions', () => {
11091108
// Check that success notification appears with correct message
11101109
await toastNotification(
11111110
adminPage,
1112-
`Your Default Persona changed to ${persona1.data.displayName}`
1111+
`Your Default Persona changed to ${persona1.responseData.displayName}`
11131112
);
11141113

11151114
await adminPage.waitForSelector(

0 commit comments

Comments
 (0)