Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,22 @@ import { EntityTypeEndpoint } from '../../support/entity/Entity.interface';
import { TableClass } from '../../support/entity/TableClass';
import { TagClass } from '../../support/tag/TagClass';
import {
ACTIVITY_TEST_TIMEOUT,
addTagToTable,
createConversationThread,
createDescriptionActivityEventFromPage,
FEED_ITEM_TIMEOUT,
getActivityFeedItems,
getFeedItemByText,
getTableFqn,
getTableLeafName,
insertActivityEventForTest,
openActivityFeedAndWaitForApi,
patchTableDescription,
THUMBS_UP_EMOJI,
toggleThumbsUpReaction,
visitTableActivityFeed,
waitForActivityEvent,
} from '../../utils/activityAPI';
import { postActivityComment } from '../../utils/activityFeed';
import { performAdminLogin } from '../../utils/admin';
import { createAdminApiContext } from '../../utils/admin';
import { getApiContext, redirectToHomePage, uuid } from '../../utils/common';
import {
addOwner,
Expand All @@ -45,16 +43,16 @@ import { test } from '../fixtures/pages';
// Investigation needed:
// 1. Profile actual event propagation time — measure how long it typically takes from a PATCH/PUT call to the event appearing in /api/v1/activity, then tighten the ceiling.
// 2. If synchronous flushing is not feasible, restructure tests to assert entity state directly via the entity API, seed a pre-built activity event, and verify only that the UI renders it decoupling UI assertions from event latency.
test.describe.fixme(
test.describe(
'Activity API - Entity Changes',
{ tag: [DOMAIN_TAGS.DISCOVERY] },
() => {
let entityChangesTable: TableClass;
let entityChangesTag: TagClass;
let adminDisplayName: string;

test.beforeAll('Setup: create table and tag', async ({ browser }) => {
const { apiContext, afterAction } = await performAdminLogin(browser);
test.beforeAll('Setup: create table and tag', async () => {
const { apiContext, afterAction } = await createAdminApiContext();

entityChangesTable = new TableClass();
entityChangesTag = new TagClass({});
Expand All @@ -79,8 +77,7 @@ test.describe.fixme(
test('creates an activity event when the description is updated', async ({
page,
}) => {
test.setTimeout(ACTIVITY_TEST_TIMEOUT);

test.slow();
const newDescription = `Test description updated at ${Date.now()}`;
const entityFqn = getTableFqn(entityChangesTable);

Expand All @@ -96,7 +93,7 @@ test.describe.fixme(
);
});

await test.step('Verify the description event through API and UI', async () => {
await test.step('Verify event, actor, and entity link through API and UI', async () => {
const descriptionEvent = await waitForActivityEvent({
entityFqn,
eventType: 'DescriptionUpdated',
Expand All @@ -106,22 +103,27 @@ test.describe.fixme(
page,
entityFqn
);
const renderedDescriptionEvent = activityResponse.data?.find(
const renderedEvent = activityResponse.data?.find(
(event) =>
event.eventType === 'DescriptionUpdated' &&
JSON.stringify(event).includes(newDescription)
);
const feedItem = await getFeedItemByText(page, newDescription);
const entityLink = feedItem.locator('a[href*="/table/"]').first();
const href = await entityLink.getAttribute('href');

expect(descriptionEvent).toBeDefined();
expect(renderedDescriptionEvent).toBeDefined();
expect(renderedEvent).toBeDefined();
await expect(feedItem).toContainText(/description/i);
await expect(feedItem).toContainText(adminDisplayName);
await expect(entityLink).toBeVisible();
expect(href).toContain('table');
expect(href).toContain(getTableLeafName(entityChangesTable));
});
});

test('creates an activity event when tags are added', async ({ page }) => {
test.setTimeout(ACTIVITY_TEST_TIMEOUT);

test.slow();
const entityFqn = getTableFqn(entityChangesTable);
const tagDisplayName = entityChangesTag.getTagDisplayName();

Expand Down Expand Up @@ -158,8 +160,7 @@ test.describe.fixme(
});

test('creates an activity event when owner is added', async ({ page }) => {
test.setTimeout(ACTIVITY_TEST_TIMEOUT);

test.slow();
const entityFqn = getTableFqn(entityChangesTable);

await test.step('Add the owner from the entity page', async () => {
Expand Down Expand Up @@ -193,83 +194,36 @@ test.describe.fixme(
await expect(feedItem).toBeVisible({ timeout: FEED_ITEM_TIMEOUT });
});
});

test('shows the actor who made the activity change', async ({ page }) => {
test.setTimeout(ACTIVITY_TEST_TIMEOUT);

const entityFqn = getTableFqn(entityChangesTable);
const uniqueDescription = `Actor test description ${Date.now()}`;

await test.step('Make a table change as the logged-in admin user', async () => {
const { apiContext, afterAction } = await getApiContext(page);

try {
await patchTableDescription(
apiContext,
entityChangesTable,
uniqueDescription
);
} finally {
await afterAction();
}

await waitForActivityEvent({
entityFqn,
eventType: 'DescriptionUpdated',
text: uniqueDescription,
});
});

await test.step('Verify the actor is visible in the matching feed item', async () => {
await visitTableActivityFeed(page, entityChangesTable);

const feedItem = await getFeedItemByText(page, uniqueDescription);

await expect(feedItem).toContainText(adminDisplayName);
});
});

test('links activity items to the correct entity', async ({ page }) => {
test.setTimeout(ACTIVITY_TEST_TIMEOUT);

const description = `Entity link description ${uuid()}`;

await test.step('Create an activity event for the table', async () => {
await createDescriptionActivityEventFromPage(
page,
entityChangesTable,
description
);
});

await test.step('Verify the feed card has the table entity link', async () => {
await visitTableActivityFeed(page, entityChangesTable);

const feedItem = await getFeedItemByText(page, description);
const entityLink = feedItem.locator('a[href*="/table/"]').first();

await expect(entityLink).toBeVisible();

const href = await entityLink.getAttribute('href');

expect(href).toContain('table');
expect(href).toContain(getTableLeafName(entityChangesTable));
});
});
}
);

test.describe.fixme(
test.describe(
'Activity API - Reactions',
{ tag: [DOMAIN_TAGS.DISCOVERY] },
() => {
const reactionsTable = new TableClass();
let reactionsTable: TableClass;
let addReactionFeedText: string;
let removeReactionFeedText: string;

test.beforeAll('Setup: create table and feed items', async () => {
const { apiContext, afterAction } = await createAdminApiContext();

test.beforeAll('Setup: create table', async ({ browser }) => {
const { apiContext, afterAction } = await performAdminLogin(browser);
reactionsTable = new TableClass();
addReactionFeedText = `Test activity for adding reaction ${uuid()}`;
removeReactionFeedText = `Test activity for removing reaction ${uuid()}`;

try {
await reactionsTable.create(apiContext);
await insertActivityEventForTest(
apiContext,
reactionsTable,
addReactionFeedText
);
await insertActivityEventForTest(
apiContext,
reactionsTable,
removeReactionFeedText
);
} finally {
await afterAction();
}
Expand All @@ -281,21 +235,12 @@ test.describe.fixme(
});

test('adds a reaction to a feed item', async ({ page }) => {
test.setTimeout(ACTIVITY_TEST_TIMEOUT);

const description = `Test activity for adding reaction ${uuid()}`;

await test.step('Create and open an activity feed item', async () => {
await createDescriptionActivityEventFromPage(
page,
reactionsTable,
description
);
await test.step('Open the activity feed', async () => {
await visitTableActivityFeed(page, reactionsTable);
});

await test.step('Add thumbs-up reaction and verify it is visible', async () => {
const feedItem = await getFeedItemByText(page, description);
const feedItem = await getFeedItemByText(page, addReactionFeedText);

await toggleThumbsUpReaction(feedItem, page);
await expect(
Expand All @@ -305,21 +250,12 @@ test.describe.fixme(
});

test('removes an existing reaction from a feed item', async ({ page }) => {
test.setTimeout(ACTIVITY_TEST_TIMEOUT);

const description = `Test activity for removing reaction ${uuid()}`;

await test.step('Create and open an activity feed item', async () => {
await createDescriptionActivityEventFromPage(
page,
reactionsTable,
description
);
await test.step('Open the activity feed', async () => {
await visitTableActivityFeed(page, reactionsTable);
});

await test.step('Add and then remove thumbs-up reaction', async () => {
const feedItem = await getFeedItemByText(page, description);
const feedItem = await getFeedItemByText(page, removeReactionFeedText);

await toggleThumbsUpReaction(feedItem, page);
await expect(
Expand All @@ -335,17 +271,33 @@ test.describe.fixme(
}
);

test.describe.fixme(
test.describe(
'Activity API - Comments',
{ tag: [DOMAIN_TAGS.DISCOVERY] },
() => {
const commentsTable = new TableClass();
let commentsTable: TableClass;
let commentFeedText: string;
let layoutFeedText: string;

test.beforeAll('Setup: create table', async ({ browser }) => {
const { apiContext, afterAction } = await performAdminLogin(browser);
test.beforeAll('Setup: create table and feed items', async () => {
const { apiContext, afterAction } = await createAdminApiContext();

commentsTable = new TableClass();
commentFeedText = `Test activity for comments ${uuid()}`;
layoutFeedText = `Test activity detail layout ${uuid()}`;

try {
await commentsTable.create(apiContext);
await insertActivityEventForTest(
apiContext,
commentsTable,
commentFeedText
);
await insertActivityEventForTest(
apiContext,
commentsTable,
layoutFeedText
);
} finally {
await afterAction();
}
Expand All @@ -357,22 +309,14 @@ test.describe.fixme(
});

test('adds a comment to a feed item', async ({ page }) => {
test.setTimeout(ACTIVITY_TEST_TIMEOUT);

const description = `Test activity for comments ${uuid()}`;
const commentText = `Test comment ${uuid()}`;

await test.step('Create and open an activity feed item', async () => {
await createDescriptionActivityEventFromPage(
page,
commentsTable,
description
);
await test.step('Open the activity feed', async () => {
await visitTableActivityFeed(page, commentsTable);
});

await test.step('Open the feed detail and post a comment', async () => {
const feedItem = await getFeedItemByText(page, description);
const feedItem = await getFeedItemByText(page, commentFeedText);

await feedItem.click();
await waitForAllLoadersToDisappear(page);
Expand All @@ -381,21 +325,12 @@ test.describe.fixme(
});

test('shows the activity detail layout', async ({ page }) => {
test.setTimeout(ACTIVITY_TEST_TIMEOUT);

const description = `Test activity detail layout ${uuid()}`;

await test.step('Create and open an activity feed item', async () => {
await createDescriptionActivityEventFromPage(
page,
commentsTable,
description
);
await test.step('Open the activity feed', async () => {
await visitTableActivityFeed(page, commentsTable);
});

await test.step('Open the detail view and verify layout regions', async () => {
const feedItem = await getFeedItemByText(page, description);
const feedItem = await getFeedItemByText(page, layoutFeedText);

await feedItem.click();
await waitForAllLoadersToDisappear(page);
Expand All @@ -411,14 +346,16 @@ test.describe.fixme(
}
);

test.describe.fixme(
test.describe(
'Activity API - Homepage Widget',
{ tag: [DOMAIN_TAGS.DISCOVERY] },
() => {
const homepageTable = new TableClass();
let homepageTable: TableClass;

test.beforeAll('Setup: create table and activity', async () => {
const { apiContext, afterAction } = await createAdminApiContext();

test.beforeAll('Setup: create table and activity', async ({ browser }) => {
const { apiContext, afterAction } = await performAdminLogin(browser);
homepageTable = new TableClass();

try {
await homepageTable.create(apiContext);
Expand Down
Loading
Loading