Skip to content

Commit

Permalink
#13876: change placement of comment and close button in task approval…
Browse files Browse the repository at this point in the history
… workflow (#17044)

* change placment of comment and close button in task approval workflow

* minor change

* playwright test for the close and comment function

* supported ref in activityFeedEditor

* fix playwright test

* added playwright test for data steward

* fix the test for the data streward user

* fix the close button not showing if task has no suggestions and icon fixes

* fix sonar issue

* change glossary and add suggestion button to dropdown button

* fix the glossary failure due to button change

* icon change for add tag and description

* fix glossary cypress failure due to button chnages

* changes as per comments
  • Loading branch information
Ashish8689 committed Jul 22, 2024
1 parent b19b7f5 commit f500e70
Show file tree
Hide file tree
Showing 16 changed files with 790 additions and 164 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,10 @@ const approveGlossaryTermWorkflow = ({ glossary, glossaryTerm }) => {

interceptURL('PUT', '/api/v1/feed/tasks/*/resolve', 'resolveTask');

cy.get('[data-testid="approve-task"]').click();
// approve the task
cy.get(
'[data-testid="glossary-accept-reject-task-dropdown"] .ant-btn-compact-first-item > span'
).click();

verifyResponseStatusCode('@resolveTask', 200);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { UserClass } from '../../support/user/UserClass';
import { checkDescriptionInEditModal } from '../../utils/activityFeed';
import {
createNewPage,
performAdminLogin,
performUserLogin,
redirectToHomePage,
toastNotification,
visitUserProfilePage,
Expand All @@ -27,18 +29,21 @@ import {
TaskDetails,
} from '../../utils/task';

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

const entity = new TableClass();
const user = new UserClass();
const entity2 = new TableClass();
const user1 = new UserClass();
const user2 = new UserClass();

test.describe('Activity feed', () => {
// use the admin user to login
test.use({ storageState: 'playwright/.auth/admin.json' });

test.beforeAll('Setup pre-requests', async ({ browser }) => {
const { apiContext, afterAction } = await createNewPage(browser);

await entity.create(apiContext);
await user.create(apiContext);
await entity2.create(apiContext);
await user1.create(apiContext);

await afterAction();
});
Expand All @@ -50,15 +55,16 @@ test.describe('Activity feed', () => {
test.afterAll('Cleanup', async ({ browser }) => {
const { apiContext, afterAction } = await createNewPage(browser);
await entity.delete(apiContext);
await user.delete(apiContext);
await entity2.delete(apiContext);
await user1.delete(apiContext);

await afterAction();
});

test('Assigned task should appear to task tab', async ({ page }) => {
const value: TaskDetails = {
term: entity.entity.name,
assignee: user.responseData.name,
assignee: user1.responseData.name,
};
await entity.visitEntityPage(page);

Expand Down Expand Up @@ -186,7 +192,7 @@ test.describe('Activity feed', () => {
test('Update Description Task on Columns', async ({ page }) => {
const firstTaskValue: TaskDetails = {
term: entity.entity.name,
assignee: user.responseData.name,
assignee: user1.responseData.name,
description: 'Column Description 1',
columnName: entity.entity.columns[0].name,
oldDescription: entity.entity.columns[0].description,
Expand Down Expand Up @@ -246,4 +252,225 @@ test.describe('Activity feed', () => {

expect(closedTask).toContain('2 Closed');
});

test('Comment and Close Task should work in Task Flow', async ({ page }) => {
const value: TaskDetails = {
term: entity2.entity.name,
assignee: user1.responseData.name,
};
await entity2.visitEntityPage(page);

await page.getByTestId('request-description').click();

await createDescriptionTask(page, value);

// Task 1 - Update Description right panel check
const descriptionTask = await page.getByTestId('task-title').innerText();

expect(descriptionTask).toContain('Request to update description');

// Check the editor send button is not visible and comment button is disabled when no text is added
expect(page.locator('[data-testid="send-button"]')).not.toBeVisible();
expect(
await page.locator('[data-testid="comment-button"]').isDisabled()
).toBeTruthy();

await page.fill(
'[data-testid="editor-wrapper"] .ql-editor',
'Test comment added'
);
const addComment = page.waitForResponse('/api/v1/feed/*/posts');
await page.getByTestId('comment-button').click();
await addComment;

// Close the task from the Button.Group, should throw error when no comment is added.
await page.getByRole('button', { name: 'down' }).click();
await page.waitForSelector('.ant-dropdown', {
state: 'visible',
});

await page.getByRole('menuitem', { name: 'close' }).click();

await toastNotification(page, 'Task cannot be closed without a comment.');

// Close the task from the Button.Group, with comment is added.
await page.fill(
'[data-testid="editor-wrapper"] .ql-editor',
'Closing the task with comment'
);
const commentWithCloseTask = page.waitForResponse(
'/api/v1/feed/tasks/*/close'
);
await page.getByRole('button', { name: 'down' }).click();
await page.waitForSelector('.ant-dropdown', {
state: 'visible',
});
await page.getByRole('menuitem', { name: 'close' }).click();
await commentWithCloseTask;

await toastNotification(page, 'Task closed successfully.');

const openTask = await page.getByTestId('open-task').textContent();

expect(openTask).toContain('0 Open');

const closedTask = await page.getByTestId('closed-task').textContent();

expect(closedTask).toContain('1 Closed');
});
});

test.describe('Activity feed with Data Steward User', () => {
test.slow(true);

test.beforeAll('Setup pre-requests', async ({ browser }) => {
const { afterAction, apiContext } = await performAdminLogin(browser);

await entity.create(apiContext);
await user1.create(apiContext);
await user2.create(apiContext);
await afterAction();
});

test.afterAll('Cleanup', async ({ browser }) => {
const { afterAction, apiContext } = await performAdminLogin(browser);
await entity.delete(apiContext);
await user1.delete(apiContext);
await user2.delete(apiContext);

await afterAction();
});

test('Create and Assign Task', async ({ browser }) => {
const { page: page1, afterAction: afterActionUser1 } =
await performUserLogin(browser, user1);
const { page: page2, afterAction: afterActionUser2 } =
await performUserLogin(browser, user2);

const value: TaskDetails = {
term: entity.entity.name,
assignee: user2.responseData.name,
};

await test.step('Create, Close and Assign Task to User 2', async () => {
await redirectToHomePage(page1);
await entity.visitEntityPage(page1);

// Create 2 task for the same entity, one to close and 2nd for the user2 action
await page1.getByTestId('request-description').click();
await createDescriptionTask(page1, value);

await page1.getByTestId('schema').click();

await page1.getByTestId('request-entity-tags').click();

// create tag task
await createTagTask(page1, { ...value, tag: 'PII.None' });

// Should only see the close and comment button
expect(
await page1.locator('[data-testid="comment-button"]').isDisabled()
).toBeTruthy();
expect(page1.locator('[data-testid="close-button"]')).toBeVisible();
expect(
page1.locator('[data-testid="edit-accept-task-dropdown"]')
).not.toBeVisible();

// Close 1st task
await page1.fill(
'[data-testid="editor-wrapper"] .ql-editor',
'Closing the task with comment'
);
const commentWithCloseTask = page1.waitForResponse(
'/api/v1/feed/tasks/*/close'
);
page1.locator('[data-testid="close-button"]').click();
await commentWithCloseTask;

// TODO: Ashish - Fix the toast notification once issue is resolved from Backend https://github.com/open-metadata/OpenMetadata/issues/17059

// await toastNotification(page1, 'Task closed successfully.');
await toastNotification(
page1,
'An exception with message [Cannot invoke "org.openmetadata.schema.type.EntityReference.getName()" because "owner" is null] was thrown while processing request.'
);

// TODO: Ashish - Enable them once issue is resolved from Backend https://github.com/open-metadata/OpenMetadata/issues/17059
// const openTask = await page1.getByTestId('open-task').textContent();
// expect(openTask).toContain('1 Open');
// const closedTask = await page1.getByTestId('closed-task').textContent();
// expect(closedTask).toContain('1 Closed');

await afterActionUser1();
});

await test.step('Accept Task By User 2', async () => {
await redirectToHomePage(page2);

const taskResponse = page2.waitForResponse(
'/api/v1/feed?type=Task&filterType=OWNER&taskStatus=Open&userId=*'
);

await page2
.getByTestId('activity-feed-widget')
.getByText('Tasks')
.click();

await taskResponse;

await expect(
page2.locator(
'[data-testid="activity-feed-widget"] [data-testid="no-data-placeholder"]'
)
).not.toBeVisible();

const entityPageTaskTab = page2.waitForResponse(
'/api/v1/feed?*&type=Task'
);

const tagsTask = page2.getByTestId('redirect-task-button-link').first();
const tagsTaskContent = await tagsTask.innerText();

expect(tagsTaskContent).toContain('Request tags for');

await tagsTask.click();
await entityPageTaskTab;

// TODO: Ashish - Enable them once issue is resolved from Backend https://github.com/open-metadata/OpenMetadata/issues/17059
// Count for task should be 1 both open and closed

// const openTaskBefore = await page2.getByTestId('open-task').textContent();
// expect(openTaskBefore).toContain('1 Open');

// const closedTaskBefore = await page2
// .getByTestId('closed-task')
// .textContent();
// expect(closedTaskBefore).toContain('1 Closed');

// Should not see the close button
expect(page2.locator('[data-testid="close-button"]')).not.toBeVisible();

expect(
await page2.locator('[data-testid="comment-button"]').isDisabled()
).toBeTruthy();

expect(
page2.locator('[data-testid="edit-accept-task-dropdown"]')
).toBeVisible();

await page2.getByText('Accept Suggestion').click();

await toastNotification(page2, /Task resolved successfully/);

// TODO: Ashish - Enable them once issue is resolved from Backend https://github.com/open-metadata/OpenMetadata/issues/17059
// const openTask = await page2.getByTestId('open-task').textContent();
// expect(openTask).toContain('0 Open');

const closedTask = await page2.getByTestId('closed-task').textContent();

expect(closedTask).toContain('1 Closed');

await afterActionUser2();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export const clickOutside = async (page: Page) => {

export const visitUserProfilePage = async (page: Page) => {
await page.getByTestId('dropdown-profile').click();
await page.waitForSelector('.profile-dropdown', {
await page.waitForSelector('[role="menu"].profile-dropdown', {
state: 'visible',
});
const userResponse = page.waitForResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ export const approveGlossaryTermTask = async (
) => {
await validateGlossaryTermTask(page, term);
const taskResolve = page.waitForResponse('/api/v1/feed/tasks/*/resolve');
await page.click('[data-testid="approve-task"]');
await page.getByRole('button', { name: 'Approve' }).click();
await taskResolve;

// Display toast notification
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f500e70

Please sign in to comment.