Skip to content

Commit

Permalink
fix: last symbol was sliced at console message
Browse files Browse the repository at this point in the history
  • Loading branch information
alexneo2003 committed Apr 21, 2023
1 parent cc1be26 commit 56c8228
Show file tree
Hide file tree
Showing 5 changed files with 454 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import chalk from 'chalk';
import debug from 'debug';

debug.formatArgs = function (args) {
args[0] = `${chalk.magenta.bold('azure:')} ${args[0].slice(0, -1)}`;
args[0] = `${chalk.magenta.bold('azure:')} ${args[0]}`;
return args;
};

Expand Down
113 changes: 113 additions & 0 deletions tests/reporter/assets/azure-reporter/pointsResponseMapper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
export default function pointsResponseMapper(body) {
/**
* body sample request:
* {
* "pointsFilter": {
* "testcaseIds": [
* 1,
* 2,
* 3
* ],
* }
*/

const { pointsFilter } = body;
const { testcaseIds } = pointsFilter;
const testPointsArray = Array.from({ length: testcaseIds.length }, (_, i) => {
return {
id: 1 + i,
url: 'http://localhost:3000/SampleSample/_apis/test/Plans/4/Suites/6/Points/' + (i + 1 * 3),
assignedTo: {
displayName: 'Alex',
id: '230e55b4-9e71-6a10-a0fa-777777777',
},
automated: false,
configuration: {
id: '1',
name: 'Windows 10',
},
lastTestRun: {
id: '238',
},
lastResult: {
id: (100000 + i).toString(),
},
outcome: 'Passed',
state: 'Completed',
lastResultState: 'Completed',
suite: {
id: '6',
},
testCase: {
id: testcaseIds[i],
},
testPlan: {
id: '4',
},
workItemProperties: [
{
workItem: {
key: 'Microsoft.VSTS.TCM.AutomationStatus',
value: 'Not Automated',
},
},
],
};
});

return {
points: testPointsArray,
pointsFilter,
};
}

/**
* response sample:
* {
"points": [
{
"id": 1,
"url": "http://localhost:3000/SampleSample/_apis/test/Plans/4/Suites/6/Points/1",
"assignedTo": {
"displayName": "Alex",
"id": "230e55b4-9e71-6a10-a0fa-777777777"
},
"automated": false,
"configuration": {
"id": "1",
"name": "Windows 10"
},
"lastTestRun": {
"id": "238"
},
"lastResult": {
"id": "100000"
},
"outcome": "Passed",
"state": "Completed",
"lastResultState": "Completed",
"suite": {
"id": "6"
},
"testCase": {
"id": "3"
},
"testPlan": {
"id": "4"
},
"workItemProperties": [
{
"workItem": {
"key": "Microsoft.VSTS.TCM.AutomationStatus",
"value": "Not Automated"
}
}
]
}
],
"pointsFilter": {
"testcaseIds": [3]
}
}
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
export default function testResultsByQueryResponseMapping(body) {
return {
fields: [''],
results: body.results.map((_, i) => {
return {
id: (100000 + i).toString(),
configuration: {
id: '1',
},
project: {
id: '40067afb-7d94-4832-8565-a31e3427ecd3',
},
durationInMs: 7787,
outcome: 'Failed',
revision: 1,
state: 'Completed',
testCase: {
id: '3',
name: 'Should page opened',
},
testPoint: {
id: (1 + i).toString(),
},
testRun: {
id: '627',
name: '',
},
lastUpdatedDate: '2023-04-07T08:59:13.010Z',
priority: 2,
errorMessage:
'[3,8] Awaiting for user input: expect(received).toHaveTitle(expected)\n\nExpected pattern: /Getting started/\nReceived string: "Installation | Playwright"\nCall log:\n - expect.toHaveTitle with timeout 5000ms\n - waiting for locator(':root')\n - locator resolved to <html lang="en" dir="ltr" data-theme="light" data-rh="…>…</html>\n - unexpected value "Installation | Playwright"\n - waiting for locator(':root')\n - locator resolved to <html lang="en" dir="ltr" data-theme="light" data-rh="…>…</html>\n - unexpected value "Installation | Playwright"\n - locator resolved to <html lang="en" dir="ltr" data-theme="light" data-rh="…>…</html>\n - unexpected value "Installation | Playwright"\n - locator resolved to <html lang="en" dir="ltr" data-theme="light" data-rh="…>…</html>\n - unexpected value "Installation | Playwright"\n - locator resolved to <html lang="en" dir="ltr" data-theme="light" data-rh="…>…</html>\n - unexpected value "Installation | Playwright"\n - locator resolved to <html lang="en" dir="ltr" data-theme="light" data-rh="…>…</html>\n - unexpected value "Installation | Playwright"\n - locator resolved to <html lang="en" dir="ltr" data-theme="light" data-rh="…>…</html>\n - unexpected value "Installation | Playwright"\n - locator resolved to <html lang="en" dir="ltr" data-theme="light" data-rh="…>…</html>\n - unexpected value "Installation | Playwright"\n - locator resolved to <html lang="en" dir="ltr" data-theme="light" data-rh="…>…</html>\n - unexpected value "Installation | Playwright"\n',
createdDate: '2023-04-07T08:59:13.010Z',
failureType: 'None',
testCaseTitle: 'Should page opened',
testCaseRevision: 3,
customFields: [],
testCaseReferenceId: 36418281,
owner: {
displayName: 'Alex Neo',
url: 'https://spsprodweu5.vssps.visualstudio.com/Ad6c695e8-17f3-43da-936c-f9416e2e490d/_apis/Identities/230e55b4-9e71-6a10-a0fa-780a87894418',
_links: {
avatar: {
href: 'https://dev.azure.com/alex-neo/_apis/GraphProfile/MemberAvatars/msa.MjMwZTU1YjQtOWU3MS03YTEwLWEwZmEtNzgwYTg3ODk0NDE4',
},
},
id: '230e55b4-9e71-6a10-a0fa-780a87894418',
uniqueName: 'alex.dev.play@gmail.com',
imageUrl:
'https://dev.azure.com/alex-neo/_apis/GraphProfile/MemberAvatars/msa.MjMwZTU1YjQtOWU3MS03YTEwLWEwZmEtNzgwYTg3ODk0NDE4',
descriptor: 'msa.MjMwZTU1YjQtOWU3MS03YTEwLWEwZmEtNzgwYTg3ODk0NDE4',
},
runBy: {
displayName: 'Alex Neo',
url: 'https://spsprodweu5.vssps.visualstudio.com/Ad6c695e8-17f3-43da-936c-f9416e2e490d/_apis/Identities/230e55b4-9e71-6a10-a0fa-780a87894418',
_links: {
avatar: {
href: 'https://dev.azure.com/alex-neo/_apis/GraphProfile/MemberAvatars/msa.MjMwZTU1YjQtOWU3MS03YTEwLWEwZmEtNzgwYTg3ODk0NDE4',
},
},
id: '230e55b4-9e71-6a10-a0fa-780a87894418',
uniqueName: 'alex.dev.play@gmail.com',
imageUrl:
'https://dev.azure.com/alex-neo/_apis/GraphProfile/MemberAvatars/msa.MjMwZTU1YjQtOWU3MS03YTEwLWEwZmEtNzgwYTg3ODk0NDE4',
descriptor: 'msa.MjMwZTU1YjQtOWU3MS03YTEwLWEwZmEtNzgwYTg3ODk0NDE4',
},
lastUpdatedBy: {
displayName: 'Alex Neo',
url: 'https://spsprodweu5.vssps.visualstudio.com/Ad6c695e8-17f3-43da-936c-f9416e2e490d/_apis/Identities/230e55b4-9e71-6a10-a0fa-780a87894418',
_links: {
avatar: {
href: 'https://dev.azure.com/alex-neo/_apis/GraphProfile/MemberAvatars/msa.MjMwZTU1YjQtOWU3MS03YTEwLWEwZmEtNzgwYTg3ODk0NDE4',
},
},
id: '230e55b4-9e71-6a10-a0fa-780a87894418',
uniqueName: 'alex.dev.play@gmail.com',
imageUrl:
'https://dev.azure.com/alex-neo/_apis/GraphProfile/MemberAvatars/msa.MjMwZTU1YjQtOWU3MS03YTEwLWEwZmEtNzgwYTg3ODk0NDE4',
descriptor: 'msa.MjMwZTU1YjQtOWU3MS03YTEwLWEwZmEtNzgwYTg3ODk0NDE4',
},
};
}),
};
}

/**
* body sample:
* {
"fields": [
""
],
"results": [
{
"id": "100000",
"testRun": {
"id": "150"
}
},
{
"id": "100001",
"testRun": {
"id": "150"
}
},
{
"id": "100002",
"testRun": {
"id": "150"
}
},
{
"id": "100003",
"testRun": {
"id": "150"
}
},
{
"id": "100004",
"testRun": {
"id": "150"
}
}
]
}
*/

/**
* response sample:
* {
"count": 1,
"value": [
{
"id": 100001,
"project": {},
"outcome": "Passed",
"testRun": {
"id": "150"
},
"priority": 0,
"url": "",
"lastUpdatedBy": {
"displayName": null,
"id": null
}
}
]
}
*/
65 changes: 65 additions & 0 deletions tests/reporter/assets/azure-reporter/testRunResultsMapper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
export default function testRunResultsMapper(body) {
return {
count: body.length,
value: body.map((_, i) => {
return {
id: (100000 + i).toString(),
project: {},
outcome: 'Passed',
testRun: {
id: '150',
},
priority: 0,
url: '',
lastUpdatedBy: {
displayName: null,
id: null,
},
};
}),
};
}

/**
* body sample:
* [
{
"testPoint": {
"id": "3"
},
"outcome": "Passed",
"state": "Completed",
"durationInMs": 11
},
{
"testPoint": {
"id": "4"
},
"outcome": "Passed",
"state": "Completed",
"durationInMs": 2
},
*/

/**
* response sample:
* {
"count": 1,
"value": [
{
"id": 100001,
"project": {},
"outcome": "Passed",
"testRun": {
"id": "150"
},
"priority": 0,
"url": "",
"lastUpdatedBy": {
"displayName": null,
"id": null
}
}
]
}
*/
Loading

0 comments on commit 56c8228

Please sign in to comment.