Skip to content

Commit

Permalink
adding functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nina Ciocanu committed Dec 14, 2023
1 parent 275123c commit 59a4330
Show file tree
Hide file tree
Showing 15 changed files with 251 additions and 9 deletions.
20 changes: 12 additions & 8 deletions sandbox/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions test/functional/helpers/constants/configParts/mediaCollection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
Copyright 2023 Adobe. All rights reserved.
This file is licensed to you 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 REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
export default {
mediaCollection: {
channel: "functional tests channel",
playerName: "functional test player"
}
};
17 changes: 17 additions & 0 deletions test/functional/helpers/constants/configParts/orgMediaConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
Copyright 2023 Adobe. All rights reserved.
This file is licensed to you 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 REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
import getBaseConfig from "../../getBaseConfig";

export default getBaseConfig(
"97D1F3F459CE0AD80A495CBE@AdobeOrg",
"27dae196-8c75-4eed-82d1-3895616f85d6"
);
4 changes: 3 additions & 1 deletion test/functional/helpers/createAlloyProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ const commands = [
"appendIdentityToUrl",
"applyPropositions",
"subscribeRulesetItems",
"evaluateRulesets"
"evaluateRulesets",
"createMediaSession",
"sendMediaEvent"
];

export default (instanceName = "alloy") => {
Expand Down
4 changes: 4 additions & 0 deletions test/functional/helpers/networkLogger/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const createNetworkLogger = () => {
const acquireEndpoint = /v1\/identity\/acquire\?configId=/;
const targetDeliveryEndpoint = /rest\/v1\/delivery\?client=/;
const targetMboxJsonEndpoint = /m2\/unifiedjsqeonly\/mbox\/json\?mbox=/;
const mediaEdgeEndpoint = /va\/v1/;

const edgeEndpointLogs = createRequestLogger(edgeEndpoint);
const edgeCollectEndpointLogs = createRequestLogger(edgeCollectEndpoint);
Expand All @@ -44,6 +45,7 @@ const createNetworkLogger = () => {
const targetMboxJsonEndpointLogs = createRequestLogger(
targetMboxJsonEndpoint
);
const mediaEdgeEndpointLogs = createRequestLogger(mediaEdgeEndpoint);

const clearLogs = async () => {
await edgeEndpointLogs.clear();
Expand All @@ -53,6 +55,7 @@ const createNetworkLogger = () => {
await acquireEndpointLogs.clear();
await targetDeliveryEndpointLogs.clear();
await targetMboxJsonEndpointLogs.clear();
await mediaEdgeEndpointLogs.clear();
};

return {
Expand All @@ -65,6 +68,7 @@ const createNetworkLogger = () => {
acquireEndpointLogs,
targetDeliveryEndpointLogs,
targetMboxJsonEndpointLogs,
mediaEdgeEndpointLogs,
clearLogs
};
};
Expand Down
99 changes: 99 additions & 0 deletions test/functional/specs/MediaCollection/MA1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
Copyright 2023 Adobe. All rights reserved.
This file is licensed to you 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 REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
import { t, ClientFunction } from "testcafe";
import createNetworkLogger from "../../helpers/networkLogger";
import { responseStatus } from "../../helpers/assertions/index";
import createFixture from "../../helpers/createFixture";
import {
compose,
orgMainConfigMain,
debugEnabled
} from "../../helpers/constants/configParts";
import getResponseBody from "../../helpers/networkLogger/getResponseBody";
import createResponse from "../../helpers/createResponse";
import { TEST_PAGE as TEST_PAGE_URL } from "../../helpers/constants/url";
import createAlloyProxy from "../../helpers/createAlloyProxy";
import orgMediaConfig from "../../helpers/constants/configParts/orgMediaConfig";
import mediaCollection from "../../helpers/constants/configParts/mediaCollection";

const networkLogger = createNetworkLogger();
const config = compose(orgMediaConfig, mediaCollection);
createFixture({
title: "Implement Media Collection in automatic mode",
url: TEST_PAGE_URL,
requestHooks: [networkLogger.edgeEndpointLogs]
});

test.meta({
ID: "C28757",
SEVERITY: "P0",
TEST_RUN: "Regression"
});

test.only("Test : Implement Media Collection in automatic mode", async () => {
const alloy = createAlloyProxy();
await alloy.configure(config);
const sessionResult = await alloy.createMediaSession({
playerId: "player1",
xdm: {
mediaCollection: {
sessionDetails: {
length: 60,
contentType: "VOD",
name: "test name of the video"
}
}
},
onBeforeMediaEvent: () => {
return {
playhead: 3,
qoeDataDetails: {
bitrate: 1,
droppedFrames: 2,
framesPerSecond: 3,
timeToStart: 4
}
};
}
});
const playEventResult = await alloy.sendMediaEvent({
playerId: "player1",
xdm: {
eventType: "media.play"
}
});
console.log("play", playEventResult);

await responseStatus(networkLogger.edgeEndpointLogs.requests, 200);
await t.expect(networkLogger.edgeEndpointLogs.requests.length).eql(1);

const createSession = networkLogger.edgeEndpointLogs.requests[0];
const requestBody = JSON.parse(createSession.request.body);
await t.expect(requestBody.events[0].xdm.eventType).eql("media.sessionStart");
await t.expect(requestBody.events[0].xdm.mediaCollection.playhead).eql(3);
const response = JSON.parse(
getResponseBody(networkLogger.edgeEndpointLogs.requests[0])
);
const mediaCollectionPayload = createResponse({
content: response
}).getPayloadsByType("media-analytics:new-session");
await t
.expect(mediaCollectionPayload[0].sessionId)
.eql(sessionResult.sessionId);
const playEvent = networkLogger.mediaEdgeEndpointLogs.requests;
console.log("ree", playEvent);
const playEventBody = JSON.parse(playEvent.request.body).events[0];
await t.expect(playEventBody.xdm.mediaCollection.playhead).eql(3);
await t
.expect(playEventBody.xdm.mediaCollection.sessionID)
.eql(sessionResult.sessionId);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
Copyright 2023 Adobe. All rights reserved.
This file is licensed to you 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 REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
Copyright 2023 Adobe. All rights reserved.
This file is licensed to you 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 REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
Copyright 2023 Adobe. All rights reserved.
This file is licensed to you 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 REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
Copyright 2023 Adobe. All rights reserved.
This file is licensed to you 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 REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
Copyright 2023 Adobe. All rights reserved.
This file is licensed to you 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 REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
Copyright 2023 Adobe. All rights reserved.
This file is licensed to you 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 REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
11 changes: 11 additions & 0 deletions test/unit/specs/components/MediaCollection/index.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
Copyright 2023 Adobe. All rights reserved.
This file is licensed to you 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 REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
Copyright 2023 Adobe. All rights reserved.
This file is licensed to you 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 REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
Copyright 2023 Adobe. All rights reserved.
This file is licensed to you 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 REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License.
*/

0 comments on commit 59a4330

Please sign in to comment.