Skip to content

Commit b1af73c

Browse files
committed
Unit test updates and fixes
1 parent 7720640 commit b1af73c

File tree

9 files changed

+852
-610
lines changed

9 files changed

+852
-610
lines changed

README.md

Lines changed: 137 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -56,28 +56,29 @@ For using with SSL, the options should be as
5656
{
5757
connectionString: '<server>',
5858
ssl: {
59-
cert: '<certificate>',
59+
cert: '<certificate>',
6060
key: '<key>'
6161
}
6262
}
6363
```
6464

6565
The following config paramaters are supported in the test environment defined in `config/test.js` and can be configured in the system environment. Note that the test config inherits all config options present in the default config and adds/overrides some config options.
6666

67-
| Name | Description | Default |
68-
| :----------------------------- | :----------------------------------------: | :------------------------------: | |
69-
| TC_URL | the topcoder development url | https://www.topcoder-dev.com |
70-
| TC_DEV_API_URL | the topcoder development api url | https://api.topcoder-dev.com/v3|
71-
| MAX_RETRY_COUNT | the maximum number of times to re-test before concluding that test failed | https://api.topcoder-dev.com/v3|
72-
| WAIT_TIME | the amount of time in milliseconds to wait before running a re-test | 30000 |
73-
| TC_DIRECT_ID | the topcoder direct id of the repository which is set up with a valid billing account | 7377 |
74-
| TOPCODER_USER_NAME | a valid username for topcoder dev platform | mess |
75-
| HOOK_BASE_URL | the webhook url of topcoder-x-receiver | |
76-
| GITHUB_ACCESS_TOKEN | github personal access token | |
77-
| GITHUB_REPOSITORY_NAME | the name of the repository to create for testing (should not already exist) | |
78-
| GITLAB_USERNAME | gitlab username | |
79-
| GITLAB_PASSWORD | gitlab password | |
80-
| GITLAB_REPOSITORY_NAME | the name of the repository to create for testing (should not already exist) | |
67+
| Name | Description | Default |
68+
|:--|:--|:--|
69+
| TC_URL | the topcoder development url |https://www.topcoder-dev.com |
70+
| TC_DEV_API_URL | the topcoder development api url |https://api.topcoder-dev.com/v3|
71+
| MAX_RETRY_COUNT | the maximum number of times to re-test before concluding that test failed | 17 |
72+
| WAIT_TIME | the amount of time in milliseconds to wait before running a re-test | 60000 |
73+
| TC_DIRECT_ID | the topcoder direct id of the repository which is set up with a valid billing account | 7377 |
74+
| TOPCODER_USER_NAME | a valid username for topcoder dev platform | mess |
75+
| HOOK_BASE_URL | the webhook url of topcoder-x-receiver | |
76+
| GITHUB_ACCESS_TOKEN | github personal access token | |
77+
| GITHUB_REPOSITORY_NAME | the name of the repository to create for testing (should not already exist) | |
78+
| GITLAB_USERNAME | gitlab username | |
79+
| GITLAB_PASSWORD | gitlab password | |
80+
| GITLAB_REPOSITORY_NAME | the name of the repository to create for testing (should already exist) | |
81+
| GITLAB_REPO_URL | the URL of the repository to create for testing (should already exist) | |
8182

8283
## Local Deployment
8384

@@ -103,9 +104,14 @@ Configure the Github access tokens, Gitlab username and password in `config/test
103104

104105
To create a Github personal access token, click on Settings -> Developer settings -> Personal access tokens -> Generate new token -> Provide all permissions.
105106

106-
Configure gitlab username and password.
107+
Configure gitlab username, password, repo name and repo url.
108+
109+
Gitlab Testing:
110+
- Please make sure set repo info via Topcoder-X-UI
111+
112+
Github Testing:
113+
- Do not need set repo info at Topcoder-X-UI
107114

108-
Now provide repository names which do not already exist.
109115

110116
You can then run both github and gitlab tests by using
111117
```
@@ -123,121 +129,136 @@ npm run test:gitlab
123129
## Verification
124130

125131
- create an issue in the repo, you can see the logs in `receiver` and `processor`, the `issue.created` event is generated.
132+
126133
- update an issue in the repo, you can see the logs in `receiver` and `processor`, the `issue.updated` event is generated.
134+
127135
- create a comment on an issue, you can see the logs in `receiver` and `processor`, the `comment.created` event is generated.
136+
128137
- update a comment on an issue, you can see the logs in `receiver` and `processor`, the `comment.updated` event is generated.
138+
129139
- assigned a user to an issue, you can see the logs in `receiver` and `processor`, the `issue.assigned` event is generated.
140+
130141
- unassigned a user to an issue, you can see the logs in `receiver` and `processor`, the `issue.unassigned` event is generated.
142+
131143
- add or remove a label to an issue, you can see the logs in `receiver` and `processor`, the `issue.labelUpdated` event is generated.
144+
132145
- create a pull request, you can see the logs in `receiver` and `processor`, the `pull_request.created` event is generated.
146+
133147
- close a pull request without merge, you can see the logs in `receiver` and `processor`, the `pull_request.closed` event is generated and the `merged` property is `false`.
148+
134149
- merge a pull request, you can see the logs in `receiver` and `processor`, the `pull_request.closed` event is generated and the `merged` property is `true`.
150+
135151
- close an issue in the repo, you can see the logs in `receiver` and `processor`, the `issue.closed` event is generated
136152

153+
154+
137155
### Create a new challenge for a new issue
156+
138157
- Create a new issue in the repo. E.g.
139-
- With the title: [$20] A new issue title
140-
- With the body (Markdown supported):
141-
```
142-
## A new issue body header
143-
144-
A new issue body content with ***bold*** text and a [link](https://github.com/ngoctay/Luettich-test/issues/).
145-
```
146-
- You will see a new project created in the logs if project for that repository is not created already. E.g.
147-
```
148-
debug: new project created with id 11916 for issue 3
149-
```
150-
- Then a new challenge created in the logs. E.g.
151-
```
152-
debug: new challenge created with id 30051089 for issue 3
153-
```
154-
- Wait a minute or 2 for Topcoder internal systems to process the new challenge. You may get an error page `HTTP Status 404` if the internal processing haven't completed yet.
155-
- Visit challenge url to verify the challenge:
156-
```
157-
https://www.topcoder-dev.com/challenge-details/30051089/?type=develop&noncache=true
158-
```
159-
***NOTE***: change 30051089 to the your challenge id created in the previous step
160158

161-
### Update the challenge when the issue was updated
159+
- With the title: [$1] This is a test issue
162160

163-
- Update title of the issue above. E.g.
164-
- With the title: [$50] A new issue title - Updated the prize
165-
- Wait a minute or 2
166-
- Visit the challenge url to verify the updated prize and title
161+
- With the body (Markdown supported):
167162

168-
- Update the body of the issue. E.g.
169-
```
170-
## A new issue body header - Updated
171-
172-
A new issue body content with ***bold*** text and a [link](https://github.com/ngoctay/Luettich-test/issues/). Updated
173-
```
174-
- Wait a minute or 2
175-
- Visit the challenge url to verify the updated body
176-
177-
- Now try to update the title by adding a space after $50: [$50 ] A new issue title - Updated the prize
178-
- The event will be ignored by processor:
179-
```
180-
debug: nothing changed for issue 3
181-
```
182-
183-
- Update the title by removing `[$50 ]`, you'll get an error:
184-
```
185-
error: Error: Cannot parse prize from title: A new issue title - Updated the prize
186-
```
187-
188-
### Process Bidding Comments
189-
- Add/update comment to bid or accept the bid
190-
- To bid on the issue, comment as `/bid $50`. Minimum one space is need between /bid and $ sign. This will trigger `comment.created` or `comment.updated` event based on comment create/edit.
191-
- if comment is bid then an email is sent to the user configured in `ISSUE_BID_EMAIL_RECEIVER` in config file
192-
- To accept bid on the issue, comment as `/accept_bid @username $50`
193-
- if comment is accepting bid then
194-
- title of issue will be changed with accepted bid amount
195-
- issue will be assigned to user `username` if not already assigned
196-
197-
### Issue Assignment
198-
When an user is assigned to an issue then 'issue.assigned' event will be captured and processed as
199-
- processor will get the Topcoder handle for such user using Ragnar self service tool api
200-
- if user is found then the topcoder challenge associated with that issue will be updated as
201-
- topcoder user will be assigned
202-
- if user is not found in mapping
203-
- comment on github/gitlab issue will added as :
204-
```
205-
@username, please sign-up with Topcoder x Self-service tool.
206-
```
207-
- user will be unassigned from issue
208-
209-
### Closing issue
210-
211-
When an issue is closed it will first check if issue has any assignee or not,
212-
213-
- if there is no assignee then simply ignores the issue closed event with message in logger
214-
- if there is an assignee then it will
215-
- first set the current assignee user as challenge assignee,
216-
- activate the challenge with project's billing
217-
- closes the challenge with winner as assignee
218-
- you can verify the challenge closed in OR (link will be commented in same issue in git host)
219-
- issue label will be updated from configured paid and fix accepted label name
220-
- if there is no fix_accepted label or prize is zero then the challenge will cancelled
221-
222-
You can see following logs
223163
```
224-
debug: Looking up TC handle of git user: 82332
225-
debug: Getting the billing account ID for project ID: 15180
226-
debug: Getting project billing detail 15180
227-
debug: assigning the billing account id 70016668 to challenge
228-
debug: Updating challenge 30052019 with {"billingAccountId":70016668,"prizes":[234]}
229-
debug: Getting the topcoder member ID for member name: tonyj
230-
debug: Getting the topcoder member ID for copilot name : tonyj
231-
debug: adding resource to challenge 30052019
232-
debug: resource is added to challenge 30052019 successfully.
233-
debug: adding resource to challenge 30052019
234-
debug: Activating challenge 30052019
235-
debug: Challenge 30052019 is activated successfully.
236-
debug: close challenge with winner tonyj(8547899)
237-
debug: Closing challenge 30052019
238-
debug: Challenge 30052019 is closed successfully.
239-
debug: update issue as paid
240-
debug: Gitlab/Github issue is updated for as paid and fix accepted for 59
164+
This is a description
241165
```
242166

243-
- if issue have already paid label it won't process
167+
- You will see a new comments
168+
169+
Contest https://www.topcoder-dev.com/challenges/30054075 has been created for this ticket.
170+
171+
```This is an automated message for tonyj via Topcoder X```
172+
173+
174+
- Visit challenge url to verify the challenge:
175+
176+
```
177+
https://www.topcoder-dev.com/challenges/30054075
178+
```
179+
180+
### Update the challenge when the issue's prize was updated
181+
182+
- Update prize of the issue
183+
- With the title: [$2] This is a test issue
184+
- Wait a minute or more
185+
- Visit the challenge url to verify the updated prize and title
186+
187+
### Update the challenge when the issue's title was updated
188+
189+
- Update title of the issue
190+
- With the title: [$2] This is an updated test issue
191+
- Wait a minute or more
192+
- Visit the challenge url to verify the updated title
193+
194+
### Update the challenge when the issue's description was updated
195+
196+
- Update description of the issue
197+
- With the title: This is an updated description
198+
- Wait a minute or more
199+
- Visit the challenge url to verify the updated description
200+
201+
### Update the challenge when assigning the ticket
202+
203+
- Assign issue to member
204+
- Wait a minute or more
205+
- ticket added [tcx_Assigned](https://github.com/nauhil/test-unit/labels/tcx_Assigned) and removed [tcx_OpenForPickup](https://github.com/nauhil/test-unit/labels/tcx_OpenForPickup)
206+
- ticket added assignee
207+
- add comments
208+
209+
Contest https://www.topcoder-dev.com/challenges/30054075 has been updated - it has been assigned to tonyj.<br/><br/>```This is an automated message for tonyj via Topcoder X```
210+
211+
- Visit the challenge url to verify registered member
212+
213+
### Update the challenge when assigning the ticket - no mapping exists
214+
215+
- Remove exists assignee
216+
- Remove user mapping data in DB
217+
- Assign issue to member
218+
- Wait a minute or more
219+
- ticket adds commets
220+
221+
@xxx, please sign-up with Topcoder X tool<br/><br/>```This is an automated message for tonyj via Topcoder X```
222+
- ticket removed their assignment
223+
224+
### Update the challenge when unassigning the ticket
225+
226+
- Unassign member of issue
227+
- Wait a minute or more
228+
- Ticket adds comments
229+
Contest https://www.topcoder-dev.com/challenges/30054075 has been updated - tonyj has been unassigned.<br/><br/>```This is an automated message for tonyj via Topcoder X```
230+
- Ticket updated labels
231+
added tcx_OpenForPickup and removed tcx_Assigned labels
232+
- Visit the challenge url to verify no registered member
233+
234+
### Update the challenge when unassigning the ticket - no assigne exists
235+
236+
- Ticket adds tcx_FixAccepted label
237+
- Unassign member of issue
238+
- Close ticket
239+
- Wait a long time
240+
- THIS TEST WILL FAIL as the issue is not reopened if no assignee exists. It is ignored with a log message
241+
242+
### Update the challenge when close the ticket - without tcx_FixAccepted label
243+
244+
- Remove tcx_FixAccepted label
245+
- Assign issue to member
246+
- Close ticket
247+
- Wait a minute or more
248+
- Ticket adds comments
249+
This ticket was not processed for payment. If you would like to process it for payment, please reopen it, add the ```tcx_FixAccepted``` label, and then close it again<br/><br/>```This is an automated message for tonyj via Topcoder X```
250+
- Ticket reopend
251+
- Visit the challenge on TC Direct to verfy chalenge status is Active
252+
253+
254+
### Update the challenge when close the ticket
255+
256+
- Assign issue to member
257+
- Ticket add tcx_FixAccepted label
258+
- Close ticket
259+
- Ticket adds tcx_Paid label
260+
- Ticket adds comments
261+
Payment task has been updated: https://software.topcoder-dev.com/review/actions/ViewProjectDetails?pid=30054000<br/><br/>```This is an automated message for tonyj via Topcoder X```
262+
- Ticket closed comment
263+
- Wait a long time (Challenge status will change to Active and then change to Completed for long time later)
264+
- Visit the challenge on TC Direct to verify challenge status is Active and change to Completed after 17 minute or more

config/test.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,23 @@ const defaultConfig = require('./default');
1313
const testConfig = {
1414
TC_URL: process.env.TC_URL || 'https://www.topcoder-dev.com',
1515
TC_DEV_API_URL: process.env.TC_DEV_API_URL || 'https://api.topcoder-dev.com/v3',
16-
MAX_RETRY_COUNT: process.env.MAX_RETRY_COUNT || 25,
17-
WAIT_TIME: process.env.WAIT_TIME || 30000,
16+
MAX_RETRY_COUNT: process.env.MAX_RETRY_COUNT || 17,
17+
WAIT_TIME: process.env.WAIT_TIME || 60000,
1818
TC_DIRECT_ID: process.env.TC_DIRECT_ID || 7377,
1919
TOPCODER_USER_NAME: process.env.TOPCODER_USER_NAME || 'mess',
2020
HOOK_BASE_URL: process.env.HOOK_BASE_URL || '',
2121
GITHUB_ACCESS_TOKEN: process.env.GITHUB_ACCESS_TOKEN || '',
2222
GITHUB_REPOSITORY_NAME: process.env.GITHUB_REPOSITORY_NAME || '',
2323
GITLAB_USERNAME: process.env.GITLAB_USERNAME || '',
2424
GITLAB_PASSWORD: process.env.GITLAB_PASSWORD || '',
25-
GITLAB_REPOSITORY_NAME: process.env.GITLAB_REPOSITORY_NAME || '',
25+
GITLAB_REPOSITORY_NAME: process.env.GITLAB_REPOSITORY_NAME || 'test-unit',
26+
GITLAB_REPO_URL: process.env.GITLAB_REPO_URL || 'https://gitlab.com/nauhil/test-unit',
27+
LABELS: process.env.LABELS || [{ name: 'tcx_OpenForPickup', color: '428BCA' }, { name: 'tcx_Assigned', color: '004E00' }, { name: 'tcx_ReadyForReview', color: 'D1D100' }, { name: 'tcx_Paid', color: '7F8C8D' }, { name: 'tcx_Feedback', color: 'FF0000' }, { name: 'tcx_FixAccepted', color: '69D100' },
28+
{name:'tcx_NotReady', color: '000000'}],
29+
READY_FOR_REVIEW_ISSUE_LABEL: process.env.READY_FOR_REVIEW_ISSUE_LABEL || 'tcx_ReadyForReview',
30+
ASSIGNED_ISSUE_LABEL: process.env.READY_FOR_REVIEW_ISSUE_LABEL || 'tcx_Assigned',
31+
OPEN_FOR_PICKUP_ISSUE_LABEL: process.env.READY_FOR_REVIEW_ISSUE_LABEL || 'tcx_OpenForPickup',
32+
FIX_ACCEPTED_ISSUE_LABEL: process.env.FIX_ACCEPTED_ISSUE_LABEL || 'tcx_FixAccepted',
2633
};
2734

2835
module.exports = Object.assign(defaultConfig, testConfig);

0 commit comments

Comments
 (0)