Skip to content

Commit

Permalink
LPD-30748 Update the segment.spec.ts file with SF
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinicius Lopes authored and brianchandotcom committed Jul 17, 2024
1 parent 5b8bafa commit 9184f16
Showing 1 changed file with 40 additions and 47 deletions.
87 changes: 40 additions & 47 deletions modules/test/playwright/tests/osb-faro-web/segments.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ test('Search the Segment Profile Distribution', async ({apiHelpers, page}) => {
channelName,
});

const date1 = new Date();
const date = new Date();

const generateIndividual = (name) => {
const id = getRandomString();
Expand Down Expand Up @@ -248,7 +248,7 @@ test('Search the Segment Profile Distribution', async ({apiHelpers, page}) => {
applicationId: 'Page',
canonicalUrl: 'https://www.liferay.com',
channelId: channel.id,
eventDate: date1.toISOString(),
eventDate: date.toISOString(),
eventId: 'pageViewed',
title: 'Liferay',
userId: individual.id,
Expand All @@ -262,7 +262,7 @@ test('Search the Segment Profile Distribution', async ({apiHelpers, page}) => {
applicationId: 'Page',
canonicalUrl: 'https://www.liferay.com',
channelId: channel.id,
eventDate: date1.toISOString(),
eventDate: date.toISOString(),
eventId: 'pageViewed',
title: 'Liferay',
userId: individual.id,
Expand All @@ -275,8 +275,8 @@ test('Search the Segment Profile Distribution', async ({apiHelpers, page}) => {
const firstSessions = firstIndividuals.map((individual) => ({
channelId: channel.id,
id: individual.id,
sessionEnd: date1.toISOString(),
sessionStart: date1.toISOString(),
sessionEnd: date.toISOString(),
sessionStart: date.toISOString(),
userId: individual.id,
}));

Expand All @@ -285,8 +285,8 @@ test('Search the Segment Profile Distribution', async ({apiHelpers, page}) => {
const secondSessions = secondIndividuals.map((individual) => ({
channelId: channel.id,
id: individual.id,
sessionEnd: date1.toISOString(),
sessionStart: date1.toISOString(),
sessionEnd: date.toISOString(),
sessionStart: date.toISOString(),
userId: individual.id,
}));

Expand Down Expand Up @@ -373,14 +373,7 @@ test('Segment Composition shows Active and Known individuals', async ({
apiHelpers,
page,
}) => {
const anonymousIdentityID = '87';
const date1 = new Date();
const pageName = 'Liferay - AC Page';
const knownIndividualName = 'ac';
const dynamicSegmentName = 'Test Dynamic Segment';
const staticSegmentName = 'Test Static Segment';
const channelName = 'My Property - ' + getRandomString();

const {channel, project} = await createChannel({
apiHelpers,
channelName,
Expand All @@ -395,6 +388,7 @@ test('Segment Composition shows Active and Known individuals', async ({
};
};

const knownIndividualName = 'ac';
const knownIndividual = [generateIndividual(knownIndividualName)];

await test.step('Create the known individuals directly in the AC database', async () => {
Expand All @@ -404,59 +398,56 @@ test('Segment Composition shows Active and Known individuals', async ({
});
});

const anonymousIdentityID = '87';
const date = new Date();

await test.step('Create an identity for an anonymous directly in the AC database', async () => {
const identities = [
await apiHelpers.jsonWebServicesOSBAsah.createIdentities([
{
createDate: date1.toISOString(),
createDate: date.toISOString(),
id: anonymousIdentityID,
},
];

await apiHelpers.jsonWebServicesOSBAsah.createIdentities(identities);
]);
});

await test.step('Create events for the anonymous and known individual to appear in AC', async () => {
const knownIndividualEvent = knownIndividual.map((individual) => ({
applicationId: 'Page',
canonicalUrl: 'https://www.liferay.com',
channelId: channel.id,
eventDate: date1.toISOString(),
eventId: 'pageViewed',
title: pageName,
userId: individual.id,
}));
const pageName = 'Liferay - AC Page';

await test.step('Create events for the anonymous and known individual to appear in AC', async () => {
await apiHelpers.jsonWebServicesOSBAsah.createEvents(
knownIndividualEvent
knownIndividual.map((individual) => ({
applicationId: 'Page',
canonicalUrl: 'https://www.liferay.com',
channelId: channel.id,
eventDate: date.toISOString(),
eventId: 'pageViewed',
title: pageName,
userId: individual.id,
}))
);

const anonymousIndividualEvents = [
await apiHelpers.jsonWebServicesOSBAsah.createEvents([
{
applicationId: 'Page',
canonicalUrl: 'https://www.liferay.com',
channelId: channel.id,
eventDate: date1.toISOString(),
eventDate: date.toISOString(),
eventId: 'pageViewed',
title: pageName,
userId: anonymousIdentityID,
},
];

await apiHelpers.jsonWebServicesOSBAsah.createEvents(
anonymousIndividualEvents
);
]);
});

await test.step('Create a session for the known individual', async () => {
const sessions = knownIndividual.map((individual) => ({
channelId: channel.id,
id: individual.id,
sessionEnd: date1.toISOString(),
sessionStart: date1.toISOString(),
userId: individual.id,
}));

await apiHelpers.jsonWebServicesOSBAsah.createSessions(sessions);
await apiHelpers.jsonWebServicesOSBAsah.createSessions(
knownIndividual.map((individual) => ({
channelId: channel.id,
id: individual.id,
sessionEnd: date.toISOString(),
sessionStart: date.toISOString(),
userId: individual.id,
}))
);
});

await test.step('Go to Analytics Cloud and Switch the property', async () => {
Expand All @@ -467,6 +458,8 @@ test('Segment Composition shows Active and Known individuals', async ({
});
});

const dynamicSegmentName = 'Test Dynamic Segment';

await test.step('Create dynamic segment', async () => {
await navigateTo({
page,
Expand Down Expand Up @@ -525,7 +518,7 @@ test('Segment Composition shows Active and Known individuals', async ({

await setSegmentName({
page,
segmentName: staticSegmentName,
segmentName: 'Test Static Segment',
});

await addStaticMember({
Expand Down

0 comments on commit 9184f16

Please sign in to comment.