From 233c73a82e4e1141b9999fb134e66b4e9e9f10a8 Mon Sep 17 00:00:00 2001 From: Priya Ranjan Singh Date: Thu, 23 Nov 2017 12:36:23 +0530 Subject: [PATCH] add feature to use it for any project --- README.md | 5 ++++- tests/efforts.js | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 76bdd7b..9d406ed 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,9 @@ This project makes the entire effort updating process automated. The way it works is you provide Travis CI with credentials in form of 2 environment variables - `USERNAME` and `PASSWORD` with your actual values for these credentials. Travis CI uses these credentials to login on your behalf and fills -your timesheets. +your timesheets. Advanced usage involves an optional 3rd env variable `PROJECT`, +for which the value is `id` of the [project on Monday in DOM](https://developers.google.com/web/tools/chrome-devtools/inspect-styles/edit-dom#inspect-an-element). +Typical values are `0_0_0_0` & `projectA_0_0_0`. ## Setup Travis CI for scheduled jobs in 5 steps 1. Make a free account or login with an existing account at @@ -24,6 +26,7 @@ in Travis CI: ``` USERNAME: xa123456 PASSWORD: password +PROJECT: 0_7_nonproj (optional) ``` 5. At 5pm on one of these days, [add a cron job](https://docs.travis-ci.com/user/cron-jobs/#Adding-Cron-Jobs) in Travis CI so that it runs a build everyday. diff --git a/tests/efforts.js b/tests/efforts.js index 89a3119..2570c9e 100644 --- a/tests/efforts.js +++ b/tests/efforts.js @@ -1,6 +1,7 @@ this.efforts = (browser) => { const username = process.env.USERNAME; const password = process.env.PASSWORD; + const project = process.env.PROJECT || '0_0_4_0'; const SHORT_INTERVAL = 5000; const LONG_INTERVAL = 10000; @@ -26,7 +27,8 @@ this.efforts = (browser) => { browser.pause(LONG_INTERVAL); if (isAnAllowedDay) { - const nodeSelector = `input[id="${yesterday - 1}_0_4_0"]`; + const projectCodeSuffix = project && project.slice(1); + const nodeSelector = `input[id="${yesterday - 1}${projectCodeSuffix}"]`; browser.waitForElementVisible(nodeSelector, SHORT_INTERVAL); browser.setValue(nodeSelector, '8'); browser.click('#submitdata');