Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TEST CAPABILITY] presence TeamJS truly breaking change example #2637

Draft
wants to merge 1 commit into
base: alexneyman/fb-testing-breaking
Choose a base branch
from
Draft
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
48 changes: 16 additions & 32 deletions apps/teams-test-app/e2e-test-data/presence.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"feature": {
"id": "presence",
"version": 2
"version": 3
},
"testCases": [
{
Expand All @@ -15,7 +15,10 @@
"upn": "user@contoso.com"
},
"expectedAlertValue": "getPresence called for user: user@contoso.com",
"expectedTestAppValue": "{\"status\":\"Available\",\"customMessage\":\"Mock presence status\"}"
"expectedTestAppValue": {
"status": "Available",
"customMessage": "Default status message"
}
},
{
"title": "getPresence API Call - Invalid UPN",
Expand All @@ -27,68 +30,49 @@
"expectedTestAppValue": "Error: Error: UPN is required"
},
{
"title": "setPresence API Call - Success",
"title": "setPresence API Call - Success with valid message",
"type": "callResponse",
"boxSelector": "#box_setPresence",
"inputValue": {
"status": "Busy",
"customMessage": "In a meeting"
"customMessage": "In a meeting with clients"
},
"expectedAlertValue": "setPresence called with status: Busy and message: In a meeting",
"expectedAlertValue": "setPresence called with status: Busy and message: In a meeting with clients",
"expectedTestAppValue": "Presence set successfully"
},
{
"title": "setPresence API Call - Success without custom message",
"title": "setPresence API Call - Fail without message",
"type": "callResponse",
"boxSelector": "#box_setPresence",
"inputValue": {
"status": "Available"
},
"expectedAlertValue": "setPresence called with status: Available and message: none",
"expectedTestAppValue": "Presence set successfully"
},
{
"title": "setPresence API Call - Invalid Status",
"type": "callResponse",
"boxSelector": "#box_setPresence",
"inputValue": {
"status": "InvalidStatus"
},
"expectedTestAppValue": "Error: Error: Invalid status value"
"expectedTestAppValue": "Error: Custom message is required and must be at least 5 characters long"
},
{
"title": "setPresence API Call - Invalid Custom Message Type",
"title": "setPresence API Call - Fail with short message",
"type": "callResponse",
"boxSelector": "#box_setPresence",
"inputValue": {
"status": "Available",
"customMessage": 123
},
"expectedTestAppValue": "Error: Error: Error code: 4000, message: Custom message must be a string"
},
{
"title": "getPresence API Call - Whitespace UPN",
"type": "callResponse",
"boxSelector": "#box_getPresence",
"inputValue": {
"upn": " "
"customMessage": "Hi"
},
"expectedTestAppValue": "Error: Error: Error code: 4000, message: UPN cannot be null or empty"
"expectedTestAppValue": "Error: Custom message is required and must be at least 5 characters long"
},
{
"title": "setPresence API Call - Set Out of Office",
"type": "callResponse",
"boxSelector": "#box_setPresence",
"inputValue": {
"status": "OutOfOffice",
"customMessage": "On vacation",
"customMessage": "On vacation until next week",
"outOfOfficeDetails": {
"startTime": "2024-03-20T00:00:00Z",
"endTime": "2024-03-27T00:00:00Z",
"message": "Annual leave - back next week"
}
},
"expectedAlertValue": "setPresence called with status: OutOfOffice and message: On vacation\nOOF from 3/20/2024 to 3/27/2024",
"expectedAlertValue": "setPresence called with status: OutOfOffice and message: On vacation until next week\nOOF from 3/20/2024 to 3/27/2024",
"expectedTestAppValue": "Presence set successfully"
},
{
Expand All @@ -101,7 +85,7 @@
"expectedAlertValue": "getPresence called for user: oof.user@contoso.com",
"expectedTestAppValue": {
"status": "OutOfOffice",
"customMessage": "Mock presence status",
"customMessage": "Out of office until next week",
"outOfOfficeDetails": {
"startTime": "__ANY_STRING__",
"endTime": "__ANY_STRING__",
Expand Down
5 changes: 4 additions & 1 deletion apps/teams-test-app/src/components/PresenceAPIs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const GetPresence = (): React.ReactElement =>
});

const SetPresence = (): React.ReactElement =>
ApiWithTextInput<{ status: presence.PresenceStatus; customMessage?: string }>({
ApiWithTextInput<presence.SetPresenceParams>({
name: 'setPresence',
title: 'Set Presence',
onClick: {
Expand All @@ -43,6 +43,9 @@ const SetPresence = (): React.ReactElement =>
if (!Object.values(presence.PresenceStatus).includes(input.status)) {
throw new Error('Invalid status value');
}
if (!input.customMessage || input.customMessage.length < 5) {
throw new Error('Custom message is required and must be at least 5 characters long');
}
},
submit: async (input) => {
await presence.setPresence(input);
Expand Down
Loading