Skip to content

Commit 94aa4d2

Browse files
authored
Merge pull request #1223 from sha392edu/feature/test-automation
Automated test cases for Topcoder Work Manager - E2E Test Automation - Part 1
2 parents 34a30b0 + e644000 commit 94aa4d2

23 files changed

+6395
-0
lines changed

test-automation/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Work Manager App - E2E Tests
2+
3+
#### Software Required
4+
5+
* Nodejs v15.4.0
6+
* Chrome Browser
7+
8+
#### Installation
9+
10+
- Install Dependencies using command
11+
`npm install`
12+
13+
- To run tests
14+
15+
`cd test-automation`
16+
17+
`npm run test`
18+
19+
- Test results are generated in `test-results/` folder
20+
21+
```
22+
HTML report - TestResult.html
23+
Junit report - junitresults-WorkManagerCreateChallengeTests.xml and junitresults-WorkMangerDashboardPageTests.xml
24+
```
25+
26+
- To view junit reports into html, install xunit-viewer
27+
`npm i -g xunit-viewer`
28+
29+
- HTML report from Junit reports can be generated using this command
30+
`xunit-viewer --results=test-results/ --output=./result.html`
31+
32+
As of now, the tests are running in headless mode. To view the actual chrome browser running the tests, you can remove `--headless` option from `chromeOptions.args` in `config.ts`
33+
34+
#### Test Data:
35+
36+
- Test data are located in `/test-data/test-data.json` file.
37+
38+
#### Configuration details:
39+
40+
- `config.json` holds the data level configuration, like user credentials etc
41+
- `conf.ts` holds the application configuration, like jasmine reporters to be configured, specs to be run etc.

test-automation/conf.ts

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import reporters = require('jasmine-reporters');
2+
import HtmlReporter = require('protractor-beautiful-reporter');
3+
import { BrowserHelper } from 'topcoder-testing-lib';
4+
5+
declare global {
6+
namespace NodeJS {
7+
interface IGlobal {
8+
document: Document;
9+
window: Window;
10+
navigator: Navigator;
11+
forgotPasswordMailListener: any;
12+
registrationMailListener: any;
13+
}
14+
}
15+
}
16+
17+
exports.config = {
18+
setupFilesAfterEnv: ['./jest.setup.js'],
19+
20+
// Capabilities to be passed to the webdriver instance.
21+
capabilities: {
22+
browserName: 'chrome',
23+
chromeOptions: {
24+
args: [
25+
'--headless',
26+
'--disable-gpu',
27+
'--no-sandbox',
28+
'--window-size=1325x744',
29+
'disable-infobars'
30+
],
31+
'excludeSwitches': ['enable-automation'],
32+
prefs: {
33+
'credentials_enable_service': false,
34+
'profile': {
35+
'password_manager_enabled': false
36+
}
37+
}
38+
},
39+
},
40+
41+
directConnect: true,
42+
43+
// Framework to use. Jasmine is recommended.
44+
framework: 'jasmine2',
45+
46+
specs: [
47+
'../temp/test-suites/dashboard-flow/dashboard.spec.js',
48+
'../temp/test-suites/create-challenge-flow/create-challenge.spec.js',
49+
],
50+
51+
// Options to be passed to Jasmine.
52+
jasmineNodeOpts: {
53+
defaultTimeoutInterval: 1200000, // 20 minutes
54+
isVerbose: true,
55+
showColors: true,
56+
},
57+
58+
onPrepare: () => {
59+
BrowserHelper.maximize();
60+
const junitReporter = new reporters.JUnitXmlReporter({
61+
consolidateAll: false,
62+
savePath: 'test-results',
63+
});
64+
jasmine.getEnv().addReporter(junitReporter);
65+
jasmine.getEnv().addReporter(
66+
new HtmlReporter({
67+
baseDirectory: 'test-results',
68+
docName: 'TestResult.html', // Change html report file name
69+
docTitle: 'Test Automation Execution Report', // Add title for the html report
70+
gatherBrowserLogs: true, // Store Browser logs
71+
jsonsSubfolder: 'jsons', // JSONs Subfolder
72+
preserveDirectory: false, // Preserve base directory
73+
screenshotsSubfolder: 'screenshots',
74+
takeScreenShotsForSkippedSpecs: true, // Screenshots for skipped test cases
75+
takeScreenShotsOnlyForFailedSpecs: true, // Screenshots only for failed test cases
76+
}).getJasmine2Reporter()
77+
);
78+
},
79+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"Timeout": {
3+
"FieldVisibility": 15000,
4+
"ElementVisibility": 15000,
5+
"ElementInvisibility": 15000,
6+
"ElementPresence": 15000,
7+
"ElementClickable": 15000,
8+
"PageLoad": 300000,
9+
"ActiveChallengeTimeout": 300000
10+
},
11+
12+
"LoggerErrors": {
13+
"ElementVisibility": "Element did not display within timeout",
14+
"ElementInvisibility": "Element did not become invisible within timeout",
15+
"ElementPresence": "Element was not present within timeout",
16+
"ElementClickable": "Element was not clickable within timeout",
17+
"PageLoad": "Page did not load within timeout"
18+
}
19+
}

test-automation/config/config.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"copilotRole": {
3+
"email": "[email protected]",
4+
"password": "appirio123",
5+
"handle": "TCConnCopilot"
6+
},
7+
"copilotManagerRole": {
8+
"email": "[email protected]",
9+
"password": "appirio123",
10+
"handle": "TCConCopilotMgr"
11+
},
12+
"givenUrl": "https://challenges.topcoder-dev.com/",
13+
"challengeUrl": "https://challenges.topcoder-dev.com/projects/16573/challenges",
14+
"logoutUrl": "https://accounts-auth0.topcoder-dev.com/?logout=true&retUrl=https://connect.topcoder-dev.com",
15+
}

test-automation/logger/logger.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { createLogger, transports } from "winston";
2+
export const logger = createLogger({
3+
transports: [new transports.Console()]
4+
});

0 commit comments

Comments
 (0)