webship-js 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,102 @@
1
+ version: 2.1
2
+ defaults: &defaults
3
+ docker:
4
+ - image: cimg/base:stable-20.04
5
+ auth:
6
+ username: mydockerhub-user
7
+ password: $DOCKERHUB_PASSWORD # context / project UI env-var reference
8
+ commands:
9
+ webship-js-build:
10
+ steps:
11
+ - checkout
12
+ ## Usefull must have utils.
13
+ - run:
14
+ name: Usefull must have utils
15
+ command: |
16
+ sudo apt -qq update
17
+ sudo apt -qqy upgrade
18
+ sudo apt -yqq install vim links lynx git diffutils htop curl wget p7zip-full unzip zip sed gcc g++ make libfreetype6-dev libaio1 libaio-dev libonig-dev libpng-dev
19
+ sudo apt -yqq install xvfb libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 libnss3
20
+
21
+ ## Configure and run the virtual display.
22
+ - run:
23
+ name: Configure and run the virtual display.
24
+ command: Xvfb -ac :99 -screen 0 1600x1200x24 > /dev/null 2>&1
25
+ background: true
26
+
27
+ ## Install node js, npm, yarn, and gulp
28
+ - run:
29
+ name: Install node js
30
+ command: |
31
+ curl -sL https://deb.nodesource.com/setup_16.x | sudo bash -
32
+ sudo apt install -y nodejs
33
+ sudo npm install -g yarn
34
+
35
+ ## Install Java.
36
+ - run:
37
+ name: Install Java
38
+ command: |
39
+ sudo apt update
40
+ sudo apt install -y openjdk-11-jre openjdk-11-jre-headless openjdk-11-jdk openjdk-11-jdk-headless
41
+
42
+ ## Install/Update Google Chrome browser.
43
+ - run:
44
+ name: Install/Update Google Chrome browser
45
+ command: |
46
+ sudo apt-get install libappindicator1 fonts-liberation libgbm1 libgtk-3-0 xdg-utils
47
+ export CHROME_BIN=/usr/bin/google-chrome
48
+ wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
49
+ sudo dpkg -i google-chrome-stable_current_amd64.deb
50
+ rm google-chrome-stable_current_amd64.deb
51
+
52
+ ## Install/Update Chrome Driver.
53
+ - run:
54
+ name: Install/Update Chrome Driver
55
+ command: |
56
+ CHROME_DRIVER_VERSION=$(wget -qO- chromedriver.storage.googleapis.com/LATEST_RELEASE);
57
+ echo $CHROME_DRIVER_VERSION;
58
+ wget http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip
59
+ unzip chromedriver_linux64.zip
60
+ sudo chmod +x chromedriver
61
+ sudo mv -f chromedriver /usr/bin/
62
+ rm chromedriver_linux64.zip
63
+
64
+ ## Setup Apache2
65
+ - run:
66
+ name: Setup Apache2
67
+ command: |
68
+ sudo apt install -yqq apache2
69
+
70
+ ## Run Selenium Standalone server.
71
+ - run:
72
+ name: Run Selenium Standalone server
73
+ command: |
74
+ if [[ ! -f /home/circleci/selenium-server-standalone-3.141.59.jar ]]; then wget -O /home/circleci/selenium-server-standalone-3.141.59.jar https://github.com/SeleniumHQ/selenium/releases/download/selenium-3.141.59/selenium-server-standalone-3.141.59.jar; fi
75
+ cd /home/circleci/
76
+ java -jar selenium-server-standalone-3.141.59.jar -port 4444
77
+ background: true
78
+
79
+ jobs:
80
+ webship-js-testing:
81
+ <<: *defaults
82
+ steps:
83
+ - webship-js-build
84
+ ## Automated Functional Acceptance Testing
85
+ - run:
86
+ name: Automated Functional Acceptance Testing
87
+ no_output_timeout: 30m
88
+ command: |
89
+ yarn install
90
+ yarn test
91
+
92
+ workflows:
93
+ version: 2
94
+ webship-js-workflow:
95
+ jobs:
96
+ - webship-js-testing:
97
+ filters:
98
+ tags:
99
+ only: /^1.0.*/
100
+ branches:
101
+ only: /^1.0.x/
102
+
@@ -1,4 +1,4 @@
1
- name: Webship-js CI
1
+ name: Github Actions
2
2
 
3
3
  on: [push]
4
4
 
package/.gitlab-ci.yml CHANGED
@@ -1,28 +1,51 @@
1
- image: node:8.10
1
+ image: node:16
2
+
2
3
  stages:
3
- - deploy
4
- - confidence-check
5
- deploy_terraform:
6
- stage: deploy
4
+ - check
5
+
6
+ check:
7
+ stage: check
7
8
  script:
8
- # Your Review App deployment scripts - for a working example please check https://gitlab.com/Flockademic/Flockademic/blob/5a45f1c2412e93810fab50e2dab8949e2d0633c7/.gitlab-ci.yml#L315
9
- - echo
10
- e2e:firefox:
11
- stage: confidence-check
12
- services:
13
- - selenium/standalone-firefox
14
- script:
15
- - npm run confidence-check --host=selenium__standalone-firefox
16
- e2e:chrome:
17
- stage: confidence-check
18
- services:
19
- - selenium/standalone-chrome
20
- script:
21
- - npm run confidence-check --host=selenium__standalone-chrome
22
-
23
- test:
24
- stage: test
25
- dependencies:
26
- - npm
27
- script:
28
- - npm test
9
+ # Dependencies for chromedriver, https://gist.github.com/mikesmullin/2636776#gistcomment-1742414
10
+ # Otherwise we get this error: "error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory"
11
+ - apt-get update -q -y
12
+ - apt-get --yes install libnss3
13
+ - apt-get --yes install libgconf-2-4
14
+
15
+ # Install chrome
16
+ # Based off of
17
+ # - https://gitlab.com/gitlab-org/gitlab-build-images/blob/9dadb28021f15913a49897126a0cd6ab0149e44f/scripts/install-chrome
18
+ # - https://askubuntu.com/a/510186/196148
19
+ #
20
+ # Add key
21
+ - curl -sS -L https://dl.google.com/linux/linux_signing_key.pub | apt-key add -
22
+ # Add repo
23
+ - echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list
24
+ - apt-get update -q -y
25
+ - apt-get install -y google-chrome-stable
26
+
27
+ - npm install chromedriver -g
28
+ - npm install nightwatch -g
29
+ - npm install https://gitlab.com/gitlab-org/gitlab-selenium-server.git -g
30
+ - which chromedriver
31
+ # The `&` at the end causes it to run in the background and not block the following commands
32
+ - nohup chromedriver --port=4444 --url-base=wd/hub &
33
+ - nohup gitlab-selenium-server &
34
+ # Install cucumber & pretty formatter .
35
+ - npm i @cucumber/cucumber
36
+ - npm i @cucumber/pretty-formatter
37
+
38
+ # Run your tests
39
+ - npm test
40
+
41
+ # Show the logs for the GitLab Selenium Server service
42
+ - mkdir -p selenium/ && curl -s http://localhost:4545/logs.tar.gz | tar -xvzf - -C selenium/
43
+ - mkdir -p selenium/ && curl http://localhost:4545/server-log --output selenium/server-log.txt
44
+ artifacts:
45
+ when: always
46
+ paths:
47
+ - selenium/
48
+ variables:
49
+ SELENIUM_REMOTE_URL: http://localhost:4545/wd/hub
50
+ GITLAB_TARGET_SELENIUM_REMOTE_URL: http://localhost:4444/wd/hub
51
+
package/.travis-ci.yml ADDED
@@ -0,0 +1,27 @@
1
+ dist: trusty
2
+ language: java
3
+
4
+ jdk:
5
+ - openjdk-11-jre
6
+
7
+ before_script:
8
+ - docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-firefox:4.0.0-rc-1-prerelease-20210618
9
+ - docker ps
10
+
11
+ script:
12
+ - mvn clean install -DsuiteXmlFile=testng.xml -Dbrowser=GRID_FIREFOX -DgridHubURL=http://localhost:4444/wd/hub
13
+
14
+ cache:
15
+ directories:
16
+ - .autoconf
17
+ - $HOME/.m2
18
+
19
+ deploy:
20
+ provider: releases
21
+ api_key: ${api_key}
22
+ skip_cleanup: true
23
+ file: [ "target/surefire-reports/emailable-report.html",
24
+ "target/surefire-reports/index.html" ]
25
+ on:
26
+ all_branches: true
27
+ tags: false
package/README.md CHANGED
@@ -1,10 +1,89 @@
1
1
  # Webship JS
2
2
 
3
- [![Webship-js CI](https://github.com/webship/webship-js/actions/workflows/github-actions.yml/badge.svg?branch=1.0.x)](https://github.com/webship/webship-js/actions)
4
-
3
+ [![Github Actions](https://github.com/webship/webship-js/actions/workflows/github-actions.yml/badge.svg?branch=1.0.x)](https://github.com/webship/webship-js/actions)
4
+ [![CircleCI](https://circleci.com/gh/webship/webship-js/tree/1.0.x.svg?style=svg)](https://circleci.com/gh/webship/webship-js/tree/1.0.x) CircleCI
5
+ [![Gitlab CI](https://gitlab.com/webship/webship-js/badges/1.0.x/pipeline.svg?job=karma&key_text=Gitlab+CI&key_width=60)](https://gitlab.com/webship/webship-js/-/pipelines)
5
6
 
6
7
  Webship JS has a ready step definitions for automated functional testing.
7
8
 
8
9
  ### Using:
9
- * Nightwatch.js
10
- * Cucumber-js
10
+ * [Cucumber-js](https://github.com/cucumber/cucumber-js)
11
+ * [Nightwatch.js](https://github.com/nightwatchjs/nightwatch)
12
+
13
+
14
+ ### Webship-js Documentations
15
+ All you need to know about [webship-js Docs](https://webship.gitbook.io/webship-js-docs/).
16
+
17
+
18
+ ## How to configure your project to test using webship-js steps
19
+
20
+ ### Install node js and yarn
21
+
22
+ ```
23
+ sudo apt install nodejs
24
+ sudo npm install yarn
25
+ ```
26
+
27
+ ### Install Java
28
+
29
+ ```
30
+ sudo apt install java
31
+ ```
32
+
33
+ ### Download Latest Chrome Driver
34
+
35
+ ```
36
+ CHROME_DRIVER_VERSION=$(wget -qO- chromedriver.storage.googleapis.com/LATEST_RELEASE);
37
+ echo $CHROME_DRIVER_VERSION;
38
+ wget http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip
39
+ unzip chromedriver_linux64.zip
40
+ chmod +x chromedriver
41
+ mkdir -p $HOME/.composer/vendor/bin
42
+ mv -f chromedriver $HOME/.composer/vendor/bin/
43
+ rm chromedriver_linux64.zip
44
+ ```
45
+
46
+ ### Install/Update Chrome Driver
47
+
48
+ ```
49
+ export CHROME_BIN=/usr/bin/google-chrome
50
+ wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
51
+ sudo apt-get clean
52
+ sudo apt-get update
53
+ sudo apt-get install dpkg
54
+ sudo dpkg -i google-chrome-stable_current_amd64.deb
55
+ rm google-chrome-stable_current_amd64.deb
56
+ google-chrome --version
57
+ ```
58
+
59
+ ### Run selenium standalone server
60
+
61
+ ```
62
+ cd ~
63
+ wget https://github.com/SeleniumHQ/selenium/releases/download/selenium-3.141.59/selenium-server-standalone-3.141.59.jar
64
+ java -jar selenium-server-standalone-3.141.59.jar -port 4444
65
+ ```
66
+
67
+ ## How to install using Yarn
68
+
69
+ ```
70
+ yarn add webship-js
71
+ ```
72
+
73
+ ## How to install using NPM
74
+
75
+ ```
76
+ npm install webship-js
77
+ ```
78
+
79
+ ## Automated Functional Acceptance Testing
80
+
81
+ ```
82
+ yarn test
83
+ ```
84
+
85
+ Or
86
+
87
+ ```
88
+ npm test
89
+ ```
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ conf = require("./../nightwatch.conf.js");
5
+ const FoldersPath = conf.src_folders;
6
+
7
+ // console.log(process.argv);
8
+
9
+ for(var i=2; i<process.argv.length; i++)
10
+ FoldersPath.push(process.argv[i]);
11
+
12
+ FoldersPath.forEach(Folder_Path => {
13
+
14
+ fs.readdir(Folder_Path, function (err, files) {
15
+
16
+ if (err) {
17
+ return console.log('Unable to scan directory: ' + err);
18
+ }
19
+
20
+ files.forEach(file => {
21
+ fs.readFile('./' + Folder_Path + '/' + file, 'utf8', (err, data) => {
22
+ if(err){
23
+ throw new Error(err);
24
+ }
25
+ const SplitByLine_Arr = data.split("\n");
26
+ const Trim_Arr = SplitByLine_Arr.map(element => {
27
+ return element.trim();
28
+ });
29
+ const StartWith_Arr = Trim_Arr.filter(StartWith);
30
+ const Steps_Arr = CleanStepsList(StartWith_Arr);
31
+
32
+ Steps_Arr.forEach(element => {
33
+ console.log(element);
34
+ });
35
+ });
36
+ });
37
+ });
38
+ });
39
+
40
+ /**
41
+ * Start with Function.
42
+ *
43
+ * Return list of array items start with (Given, Then, When,*).
44
+ *
45
+ * @param ArrLine
46
+ * @returns array
47
+ */
48
+ function StartWith(ArrLine) {
49
+ return (ArrLine.startsWith('Given')
50
+ || ArrLine.startsWith('Then')
51
+ || ArrLine.startsWith('When')
52
+ || ArrLine.startsWith('*'));
53
+ }
54
+
55
+ /**
56
+ * Clean Steps List
57
+ *
58
+ * Return list of array items cleand from unreadable chars
59
+ *
60
+ * @param ListArr
61
+ * @returns
62
+ */
63
+ function CleanStepsList(ListArr) {
64
+ var StepComment = '';
65
+ var NewArr = Array();
66
+
67
+ ListArr.forEach((element, index) => {
68
+
69
+ if(element.startsWith("* ")){
70
+ StepComment = StepComment + element.substring(2) + '\r\n';
71
+ }
72
+ else if(element.startsWith("/**") || element.startsWith("*/")){
73
+
74
+ }
75
+ else
76
+ {
77
+ const Filter1 = element.split("$/");
78
+ const Filter2 = Filter1[0].replace("(/^", ' ');
79
+
80
+ NewArr.push(Filter2 + '\r\n' + StepComment);
81
+ StepComment = '';
82
+ }
83
+
84
+ });
85
+ return NewArr;
86
+ }
87
+
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+
5
+ conf = require("./../nightwatch.conf.js");
6
+ var FoldersPath = conf.src_folders;
7
+
8
+ for(var i=2; i<process.argv.length; i++)
9
+ FoldersPath.push(process.argv[i]);
10
+
11
+ FoldersPath.forEach(Folder_Path => {
12
+
13
+ fs.readdir(Folder_Path, function (err, files) {
14
+
15
+ if (err) {
16
+ return console.log('Unable to scan directory: ' + err);
17
+ }
18
+
19
+ files.forEach(file => {
20
+ fs.readFile('./' + Folder_Path + '/' + file, 'utf8', (err, data) => {
21
+ if(err){
22
+ throw new Error(err);
23
+ }
24
+ const SplitByLine_Arr = data.split("\n");
25
+ const Trim_Arr = SplitByLine_Arr.map(element => {
26
+ return element.trim();
27
+ });
28
+ const StartWith_Arr = Trim_Arr.filter(StartWith);
29
+ const Steps_Arr = CleanStepsList(StartWith_Arr);
30
+
31
+ Steps_Arr.forEach(element => {
32
+ console.log(element);
33
+ });
34
+ });
35
+ });
36
+ });
37
+ });
38
+
39
+ /**
40
+ * Start with Function.
41
+ *
42
+ * Return list of array items start with (Given, Then, When).
43
+ *
44
+ * @param ArrLine
45
+ * @returns array
46
+ */
47
+ function StartWith(ArrLine) {
48
+ return (ArrLine.startsWith('Given')
49
+ || ArrLine.startsWith('Then')
50
+ || ArrLine.startsWith('When'));
51
+ }
52
+
53
+ /**
54
+ * Clean Steps List
55
+ *
56
+ * Return list of array items cleand from unreadable chars
57
+ *
58
+ * @param ListArr
59
+ * @returns
60
+ */
61
+ function CleanStepsList(ListArr) {
62
+ ListArr.forEach((element, index) => {
63
+ const Filter1 = element.split("$/");
64
+ const Filter2 = Filter1[0].replace("(/^", ' ');
65
+
66
+ ListArr[index] = Filter2;
67
+ });
68
+ return Arr;
69
+ }
70
+
@@ -0,0 +1,37 @@
1
+ # Template NodeJS build
2
+
3
+ # This template allows you to validate your NodeJS code.
4
+ # The workflow allows running tests and code linting on the default branch.
5
+
6
+ image: node:16
7
+
8
+ pipelines:
9
+ default:
10
+ - parallel:
11
+ - step:
12
+ name: selenium linting
13
+ script:
14
+ - docker version
15
+ - docker pull selenium/hub:latest
16
+ - docker pull selenium/standalone-chrome
17
+ - docker run -d -p 4444:4444 --name selenium-hub selenium/hub
18
+ - docker run --link selenium-hub:hub selenium/node-chrome
19
+ - chmod +x $DRIVERPATH
20
+ - mvn compiler:compile test allure:report
21
+ services:
22
+ - docker
23
+ caches:
24
+ - node
25
+ - step:
26
+ name: Build and Test
27
+ max-time: 3
28
+ script:
29
+ - sleep 1m
30
+ - yarn install
31
+ - yarn run test
32
+ caches:
33
+ - node
34
+
35
+
36
+ options:
37
+ docker: true
@@ -40,7 +40,7 @@ module.exports = {
40
40
 
41
41
  test_settings: {
42
42
  default: {
43
- launch_url: "http://webshipjs.test",
43
+ launch_url: "http://webship.co",
44
44
  selenium_port: 4444,
45
45
  selenium_host: "127.0.0.1",
46
46
  silent: true,
@@ -57,6 +57,7 @@ module.exports = {
57
57
  // w3c:false tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78)
58
58
  w3c: false,
59
59
  args: [
60
+ '--headless',
60
61
  '--start-maximized',
61
62
  '--disable-gpu',
62
63
  '--window-size=1600,1200',
@@ -72,8 +73,8 @@ module.exports = {
72
73
  '--incognito',
73
74
  '--disable-infobars',
74
75
  '--remote-debugging-port=9222',
75
- '--allowed-ips=159.89.4.58',
76
- '--whitelisted-ips=159.89.4.58',
76
+ '--allowed-ips=*',
77
+ '--whitelisted-ips=*',
77
78
  '--allow-insecure-localhost'
78
79
  ]
79
80
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "webship-js",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Webship JS automated functional testing.",
5
5
  "main": "index.js",
6
6
  "directories": {
7
7
  "test": "test"
8
8
  },
9
9
  "scripts": {
10
- "test": "nightwatch --format @cucumber/pretty-formatter --format json:./tests/reports/cucumber-report-$( date '+%Y-%m-%d_%H-%M' ).json --format html:./tests/reports/cucumber-report-$( date '+%Y-%m-%d_%H-%M' ).html"
10
+ "test": "nightwatch --format @cucumber/pretty-formatter --format-options '{\"colorsEnabled\": true}' --format-options '{\"theme\": {\"feature keyword\":[\"bold\",\"blue\"],\"feature name\":[\"blue\",\"underline\"],\"feature description\":[\"blueBright\"],\"scenario keyword\":[\"bold\",\"magenta\"],\"scenario name\":[\"magenta\",\"underline\"],\"step keyword\":[\"bold\",\"green\"],\"step text\":[\"greenBright\",\"italic\"]}}' --format json:./tests/reports/cucumber-report-$( date '+%Y-%m-%d_%H-%M' ).json --format html:./tests/reports/cucumber-report-$( date '+%Y-%m-%d_%H-%M' ).html"
11
11
  },
12
12
  "repository": {
13
13
  "type": "git",
@@ -21,11 +21,11 @@
21
21
  "homepage": "https://github.com/webship/webship-js",
22
22
  "dependencies": {
23
23
  "@cucumber/cucumber": "*",
24
- "chromedriver": "*",
25
24
  "@cucumber/pretty-formatter": "^1.0.0-alpha.2",
25
+ "chromedriver": "*",
26
26
  "eslint": "^7.32.0",
27
- "mocha": "^9.1.3",
28
27
  "geckodriver": "*",
28
+ "mocha": "^9.1.3",
29
29
  "nightwatch": "^2.1.7"
30
30
  }
31
31
  }
@@ -2,6 +2,10 @@ const {Given} = require('@cucumber/cucumber');
2
2
  const {When, Before} = require('@cucumber/cucumber');
3
3
  const {Then} = require('@cucumber/cucumber');
4
4
 
5
+ /**
6
+ * some description
7
+ * for first given function
8
+ */
5
9
  Given(/^I go to "([^"]*)?"$/, function(url) {
6
10
  return browser.url(url);
7
11
  });
@@ -13,3 +17,5 @@ Then(/^I should( not)* see "([^"]*)?"$/, function(negativeCase, expectedText) {
13
17
 
14
18
  return browser.assert.textContains('body', expectedText);
15
19
  });
20
+
21
+