Skip to content

Commit

Permalink
add userAgent to report context and add reporter related test
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusrc committed Aug 12, 2018
1 parent cc8c95b commit f50846c
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/reporter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default class Reporter {
screenshots: reportItem.screenshots,
quarantine: reportItem.quarantine,
skipped: reportItem.test.skip,
contexts: reportItem.contexts
contexts: sortBy(reportItem.contexts, 'userAgent')
};
}

Expand Down Expand Up @@ -96,7 +96,7 @@ export default class Reporter {
reportItem.pendingRuns--;
reportItem.unstable = reportItem.unstable || testRun.unstable;
reportItem.errs = reportItem.errs.concat(testRun.errs);
reportItem.contexts = reportItem.contexts.concat(testRun.ctx);
reportItem.contexts = reportItem.contexts.concat(Object.assign({}, testRun.ctx, { userAgent: testRun.browserConnection.userAgent }));

if (!reportItem.pendingRuns) {
if (task.screenshots.hasCapturedFor(testRun.test)) {
Expand Down
149 changes: 131 additions & 18 deletions test/server/reporter-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ describe('Reporter', function () {
errs: [],
quarantine: {
attempts: [['1', '2'], []]
},
ctx: {
account: 'chromeAccountTest1'
}
},

Expand All @@ -131,40 +134,57 @@ describe('Reporter', function () {
errs: [
{ text: 'err1' },
{ text: 'err2' }
]
],
ctx: {
tag: 'chrome'
}
},

//fixture1test3
{
test: testMocks[2],
unstable: false,
browserConnection: browserConnectionMocks[0],
errs: []

errs: [],
ctx: {
logs: [
{
message: 'verify password hint',
browser: 'chrome'
},
{
message: 'verify username hint',
browser: 'chrome',
}
]
}
},

//fixture2test1
{
test: testMocks[3],
unstable: false,
browserConnection: browserConnectionMocks[0],
errs: []
errs: [],
ctx: {}
},

//fixture2test2
{
test: testMocks[4],
unstable: false,
browserConnection: browserConnectionMocks[0],
errs: []
errs: [],
ctx: {}
},

//fixture3test1
{
test: testMocks[5],
unstable: false,
browserConnection: browserConnectionMocks[0],
errs: []
errs: [],
ctx: {}
}
];

Expand All @@ -178,6 +198,9 @@ describe('Reporter', function () {
errs: [],
quarantine: {
attempts: [['1', '2'], []]
},
ctx: {
account: 'firefoxAccountTest1'
}
},

Expand All @@ -187,39 +210,57 @@ describe('Reporter', function () {
unstable: false,
browserConnection: browserConnectionMocks[1],

errs: [{ text: 'err1' }]
errs: [{ text: 'err1' }],
ctx: {
tag: 'firefox'
}
},

//fixture1test3
{
test: testMocks[2],
unstable: false,
browserConnection: browserConnectionMocks[1],
errs: []
errs: [],
ctx: {
logs: [
{
message: 'verify password hint',
browser: 'firefox'
},
{
message: 'verify username hint',
browser: 'firefox',
}
]
}
},

//fixture2test1
{
test: testMocks[3],
unstable: false,
browserConnection: browserConnectionMocks[1],
errs: []
errs: [],
ctx: {}
},

//fixture2test2
{
test: testMocks[4],
unstable: false,
browserConnection: browserConnectionMocks[1],
errs: []
errs: [],
ctx: {}
},

//fixture3test1
{
test: testMocks[5],
unstable: true,
browserConnection: browserConnectionMocks[1],
errs: [{ text: 'err1' }]
errs: [{ text: 'err1' }],
ctx: {}
}
];

Expand Down Expand Up @@ -332,7 +373,17 @@ describe('Reporter', function () {
userAgent: 'chrome',
takenOnFail: false,
quarantineAttempt: 2
}]
}],
contexts: [
{
account: 'chromeAccountTest1',
userAgent: 'Chrome'
},
{
account: 'firefoxAccountTest1',
userAgent: 'Firefox',
}
]
},
{
run: 'run-001'
Expand Down Expand Up @@ -376,7 +427,17 @@ describe('Reporter', function () {
userAgent: 'chrome',
takenOnFail: true,
quarantineAttempt: null
}]
}],
contexts: [
{
tag: 'chrome',
userAgent: 'Chrome'
},
{
tag: 'firefox',
userAgent: 'Firefox'
}
]
},
{
run: 'run-001'
Expand All @@ -394,11 +455,39 @@ describe('Reporter', function () {
skipped: false,
quarantine: null,
screenshotPath: null,
screenshots: []
screenshots: [],
contexts: [
{
logs: [
{
browser: 'chrome',
message: 'verify password hint'
},
{
browser: 'chrome',
message: 'verify username hint'
}
],
userAgent: 'Chrome'
},
{
logs: [
{
browser: 'firefox',
message: 'verify password hint'
},
{
browser: 'firefox',
message: 'verify username hint'
}
],
userAgent: 'Firefox'
}
]
},
{
run: 'run-001'
}
},
]
},
{
Expand All @@ -422,7 +511,15 @@ describe('Reporter', function () {
skipped: false,
quarantine: null,
screenshotPath: null,
screenshots: []
screenshots: [],
contexts: [
{
userAgent: 'Chrome'
},
{
userAgent: 'Firefox'
}
]
},
{
run: 'run-001'
Expand All @@ -440,7 +537,15 @@ describe('Reporter', function () {
skipped: false,
quarantine: null,
screenshotPath: null,
screenshots: []
screenshots: [],
contexts: [
{
userAgent: 'Chrome'
},
{
userAgent: 'Firefox'
}
]
},
{
run: 'run-001'
Expand Down Expand Up @@ -472,7 +577,15 @@ describe('Reporter', function () {
skipped: false,
quarantine: null,
screenshotPath: null,
screenshots: []
screenshots: [],
contexts: [
{
userAgent: 'Chrome'
},
{
userAgent: 'Firefox'
}
]
},
{
run: 'run-001'
Expand Down

0 comments on commit f50846c

Please sign in to comment.