webship-js 1.0.47 → 2.0.0-beta1
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.
- package/.circleci/config.yml +15 -63
- package/.github/workflows/github-actions.yml +7 -37
- package/.gitlab-ci.yml +11 -35
- package/.travis-ci.yml +12 -23
- package/.travis.yml +17 -0
- package/README.md +8 -8
- package/bitbucket-pipelines.yml +3 -7
- package/cucumber.js +36 -0
- package/examples/dynamic-examples.html +1 -2
- package/examples/index.html +0 -1
- package/examples/test--modal-dialogs.html +252 -0
- package/examples/test--when--i-click-text-in-table-row.html +1 -1
- package/examples/test--when--i-scroll-functionality.html +34 -33
- package/examples/test--when--i-scroll-left-right-functionality.html +115 -173
- package/package.json +10 -21
- package/playwright.config.ts +37 -0
- package/tests/assets/test-document.pdf +14 -0
- package/tests/step-definitions/webship-api.js +5 -31
- package/tests/step-definitions/webship.js +849 -2498
- package/tsconfig.json +10 -0
- package/.claude/settings.local.json +0 -10
- package/.eslintignore +0 -3
- package/.eslintrc.json +0 -34
- package/assets/config_templates/circleci-linux-chrome.conf.js +0 -130
- package/assets/config_templates/github-linux-chrome.conf.js +0 -136
- package/dist/nightwatch.conf.dev.js +0 -93
- package/examples/main.js +0 -17
- package/lib/custom-assertions/checkboxChecked.js +0 -87
- package/lib/custom-assertions/elementContainsCss.js +0 -94
- package/lib/custom-assertions/elementContainsText.js +0 -86
- package/lib/custom-assertions/responseStatus.js +0 -31
- package/lib/custom-assertions/shouldVisible.js +0 -8
- package/lib/custom-assertions/textMatching.js +0 -44
- package/lib/custom-commands/checkItem.js +0 -4
- package/lib/custom-commands/clickLink.js +0 -23
- package/lib/custom-commands/fileUpload.js +0 -37
- package/lib/custom-commands/fillTextInput.js +0 -56
- package/lib/custom-commands/press.js +0 -3
- package/lib/custom-commands/selectOption.js +0 -11
- package/lib/custom-commands/uncheckItem.js +0 -4
- package/lib/custom-commands/wait.js +0 -12
- package/nightwatch.conf.js +0 -136
- package/src/index.js +0 -10
- package/steplist.js +0 -245
- package/webpack.config.js +0 -17
- package/webship-init.js +0 -75
package/.circleci/config.yml
CHANGED
|
@@ -10,71 +10,22 @@ defaults: &defaults
|
|
|
10
10
|
commands:
|
|
11
11
|
webship-js-build:
|
|
12
12
|
steps:
|
|
13
|
-
- checkout
|
|
14
|
-
##
|
|
13
|
+
- checkout
|
|
14
|
+
## Useful must have utils.
|
|
15
15
|
- run:
|
|
16
|
-
name:
|
|
16
|
+
name: Useful must have utils
|
|
17
17
|
command: |
|
|
18
18
|
sudo apt -qq update
|
|
19
19
|
sudo apt -qqy upgrade
|
|
20
20
|
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
|
|
21
|
-
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
|
|
22
|
-
## Configure and run the virtual display.
|
|
23
|
-
- run:
|
|
24
|
-
name: Configure and run the virtual display.
|
|
25
|
-
command: Xvfb -ac :99 -screen 0 1600x1200x24 > /dev/null 2>&1
|
|
26
|
-
background: true
|
|
27
21
|
|
|
28
|
-
## Install node js, npm
|
|
22
|
+
## Install node js, npm
|
|
29
23
|
- run:
|
|
30
24
|
name: Install node js
|
|
31
25
|
command: |
|
|
32
26
|
curl -sL https://deb.nodesource.com/setup_20.x | sudo bash -
|
|
33
|
-
sudo apt install -y nodejs
|
|
34
|
-
|
|
35
|
-
- run:
|
|
36
|
-
name: Install Java
|
|
37
|
-
command: |
|
|
38
|
-
sudo apt update
|
|
39
|
-
sudo apt install -y openjdk-11-jre openjdk-11-jre-headless openjdk-11-jdk openjdk-11-jdk-headless
|
|
40
|
-
## Install/Update Google Chrome browser.
|
|
41
|
-
- run:
|
|
42
|
-
name: Install/Update Google Chrome browser
|
|
43
|
-
command: |
|
|
44
|
-
sudo apt install libu2f-udev
|
|
45
|
-
sudo apt-get install libgbm1 libvulkan1 libnss3 libgconf-2-4 libxss1 fonts-liberation libappindicator3-1 libatk-bridge2.0-0 xdg-utils libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libnss3 libxss1 libasound2 libxtst6 xauth
|
|
46
|
-
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
|
|
47
|
-
sudo dpkg -i google-chrome-stable_current_amd64.deb
|
|
48
|
-
sudo apt-get install -f
|
|
49
|
-
rm google-chrome-stable_current_amd64.deb
|
|
50
|
-
sudo chmod +x /usr/bin/google-chrome
|
|
51
|
-
/usr/bin/google-chrome --version
|
|
52
|
-
google-chrome --version
|
|
53
|
-
- run:
|
|
54
|
-
name: Install/Update Chrome Driver
|
|
55
|
-
command: |
|
|
56
|
-
CHROME_VERSION=$(google-chrome --product-version);
|
|
57
|
-
echo $CHROME_VERSION;
|
|
58
|
-
wget https://storage.googleapis.com/chrome-for-testing-public/$CHROME_VERSION/linux64/chromedriver-linux64.zip
|
|
59
|
-
unzip chromedriver-linux64.zip
|
|
60
|
-
sudo chmod +x chromedriver-linux64/chromedriver
|
|
61
|
-
sudo mv -f chromedriver-linux64/chromedriver /usr/bin/
|
|
62
|
-
rm -rf chromedriver-linux64.zip chromedriver-linux64
|
|
63
|
-
chromedriver --version
|
|
64
|
-
- run:
|
|
65
|
-
name: Install Java
|
|
66
|
-
command: |
|
|
67
|
-
sudo apt update
|
|
68
|
-
sudo apt install -y openjdk-11-jre openjdk-11-jre-headless openjdk-11-jdk openjdk-11-jdk-headless
|
|
69
|
-
- run:
|
|
70
|
-
name: Run Selenium Standalone server
|
|
71
|
-
command: |
|
|
72
|
-
export DISPLAY=:99
|
|
73
|
-
if [[ ! -f /home/circleci/selenium-server-4.4.0.jar ]]; then wget -O /home/circleci/selenium-server-4.4.0.jar https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.4.0/selenium-server-4.4.0.jar; fi
|
|
74
|
-
cd /home/circleci/
|
|
75
|
-
java -jar selenium-server-4.4.0.jar standalone --port 4444
|
|
76
|
-
background: true
|
|
77
|
-
|
|
27
|
+
sudo apt install -y nodejs
|
|
28
|
+
|
|
78
29
|
jobs:
|
|
79
30
|
webship-js-testing:
|
|
80
31
|
<<: *defaults
|
|
@@ -85,17 +36,18 @@ jobs:
|
|
|
85
36
|
name: Install npm dependencies
|
|
86
37
|
command: |
|
|
87
38
|
npm install
|
|
88
|
-
##
|
|
39
|
+
## Install Playwright browsers
|
|
89
40
|
- run:
|
|
90
|
-
name:
|
|
41
|
+
name: Install Playwright browsers
|
|
91
42
|
command: |
|
|
92
|
-
|
|
43
|
+
npx playwright install --with-deps chromium
|
|
93
44
|
- run:
|
|
94
45
|
name: Start virtual server
|
|
95
|
-
command:
|
|
96
|
-
export NODE_OPTIONS=--openssl-legacy-provider
|
|
97
|
-
npm start
|
|
46
|
+
command: npm start
|
|
98
47
|
background: true
|
|
48
|
+
- run:
|
|
49
|
+
name: Wait for server
|
|
50
|
+
command: sleep 3
|
|
99
51
|
- run:
|
|
100
52
|
name: Test
|
|
101
53
|
command: |
|
|
@@ -107,6 +59,6 @@ workflows:
|
|
|
107
59
|
- webship-js-testing:
|
|
108
60
|
filters:
|
|
109
61
|
tags:
|
|
110
|
-
only: /^
|
|
62
|
+
only: /^2.0.*/
|
|
111
63
|
branches:
|
|
112
|
-
only: /^
|
|
64
|
+
only: /^2.0.x/
|
|
@@ -8,29 +8,9 @@ jobs:
|
|
|
8
8
|
|
|
9
9
|
env:
|
|
10
10
|
TEST_BASE_URL: http://localhost:8080
|
|
11
|
-
SELENIUM_HOST: http://localhost:4444/wd/hub
|
|
12
11
|
FORCE_COLOR: "1"
|
|
13
12
|
|
|
14
13
|
steps:
|
|
15
|
-
- name: Install/Update Google Chrome browser
|
|
16
|
-
run: |
|
|
17
|
-
sudo apt install libu2f-udev
|
|
18
|
-
sudo apt-get install libappindicator3-1 fonts-liberation libgbm1 libgtk-3-0 xdg-utils
|
|
19
|
-
export CHROME_BIN=/usr/bin/google-chrome
|
|
20
|
-
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
|
|
21
|
-
sudo dpkg -i google-chrome-stable_current_amd64.deb
|
|
22
|
-
rm google-chrome-stable_current_amd64.deb
|
|
23
|
-
|
|
24
|
-
- name: Install/Update Chrome Driver
|
|
25
|
-
run: |
|
|
26
|
-
CHROME_VERSION=$(google-chrome --product-version);
|
|
27
|
-
echo $CHROME_VERSION;
|
|
28
|
-
wget https://storage.googleapis.com/chrome-for-testing-public/$CHROME_VERSION/linux64/chromedriver-linux64.zip
|
|
29
|
-
unzip chromedriver-linux64.zip
|
|
30
|
-
sudo chmod +x chromedriver-linux64/chromedriver
|
|
31
|
-
sudo mv -f chromedriver-linux64/chromedriver /usr/bin/
|
|
32
|
-
rm -rf chromedriver-linux64.zip chromedriver-linux64
|
|
33
|
-
|
|
34
14
|
- name: Checkout repository
|
|
35
15
|
uses: actions/checkout@v3
|
|
36
16
|
|
|
@@ -39,27 +19,17 @@ jobs:
|
|
|
39
19
|
with:
|
|
40
20
|
node-version: '20.x'
|
|
41
21
|
|
|
42
|
-
- name: Install Java
|
|
43
|
-
run: |
|
|
44
|
-
sudo apt update
|
|
45
|
-
sudo apt install -y openjdk-11-jre openjdk-11-jre-headless openjdk-11-jdk openjdk-11-jdk-headless
|
|
46
|
-
|
|
47
|
-
- name: Run Selenium Standalone server
|
|
48
|
-
run: |
|
|
49
|
-
wget https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.4.0/selenium-server-4.4.0.jar
|
|
50
|
-
nohup java -jar selenium-server-4.4.0.jar standalone > selenium.log 2>&1 &
|
|
51
|
-
|
|
52
|
-
|
|
53
22
|
- name: Install dependencies
|
|
54
23
|
run: npm install
|
|
55
24
|
|
|
56
|
-
- name:
|
|
57
|
-
run:
|
|
25
|
+
- name: Install Playwright browsers
|
|
26
|
+
run: npx playwright install --with-deps chromium
|
|
58
27
|
|
|
59
28
|
- name: Start virtual server
|
|
60
|
-
run:
|
|
61
|
-
|
|
62
|
-
|
|
29
|
+
run: npm start &
|
|
30
|
+
|
|
31
|
+
- name: Wait for server
|
|
32
|
+
run: sleep 3
|
|
63
33
|
|
|
64
34
|
- name: Run tests
|
|
65
|
-
run: npm test
|
|
35
|
+
run: npm test
|
package/.gitlab-ci.yml
CHANGED
|
@@ -1,50 +1,26 @@
|
|
|
1
|
-
image:
|
|
2
|
-
|
|
3
|
-
services:
|
|
4
|
-
- name: selenium/standalone-chrome
|
|
5
|
-
alias: selenium
|
|
1
|
+
image: node:20
|
|
6
2
|
|
|
7
3
|
variables:
|
|
8
|
-
NODE_OPTIONS: "--openssl-legacy-provider"
|
|
9
4
|
FORCE_COLOR: "1"
|
|
10
5
|
|
|
11
6
|
before_script:
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
|
|
18
|
-
- sudo apt-get update
|
|
19
|
-
- sudo apt-get install -y openjdk-11-jre openjdk-11-jre-headless openjdk-11-jdk openjdk-11-jdk-headless
|
|
20
|
-
- sudo apt-get install -y libu2f-udev
|
|
21
|
-
- sudo apt-get install -y libappindicator1 fonts-liberation libgbm1 libgtk-3-0 xdg-utils
|
|
22
|
-
- wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
|
|
23
|
-
- sudo dpkg -i google-chrome-stable_current_amd64.deb
|
|
24
|
-
- rm google-chrome-stable_current_amd64.deb
|
|
25
|
-
- CHROME_VERSION=$(google-chrome --product-version)
|
|
26
|
-
- wget https://storage.googleapis.com/chrome-for-testing-public/$CHROME_VERSION/linux64/chromedriver-linux64.zip
|
|
27
|
-
- unzip chromedriver-linux64.zip
|
|
28
|
-
- sudo chmod +x chromedriver-linux64/chromedriver
|
|
29
|
-
- sudo mv -f chromedriver-linux64/chromedriver /usr/bin/
|
|
30
|
-
- rm -rf chromedriver-linux64.zip chromedriver-linux64
|
|
31
|
-
|
|
7
|
+
- apt-get update -qq
|
|
8
|
+
- apt-get upgrade -qqy
|
|
9
|
+
- apt-get install -yqq 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
|
|
10
|
+
- npm install
|
|
11
|
+
- npx playwright install --with-deps chromium
|
|
12
|
+
|
|
32
13
|
stages:
|
|
33
|
-
- build
|
|
34
14
|
- test
|
|
35
15
|
|
|
36
|
-
webship-js-
|
|
37
|
-
stage:
|
|
16
|
+
webship-js-test:
|
|
17
|
+
stage: test
|
|
38
18
|
script:
|
|
39
|
-
- wget https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.4.0/selenium-server-4.4.0.jar
|
|
40
|
-
- nohup java -jar selenium-server-4.4.0.jar standalone > selenium.log 2>&1 &
|
|
41
|
-
- npm install
|
|
42
|
-
- node webship-init -ci circleci -os linux -b chrome
|
|
43
|
-
- export NODE_OPTIONS=--openssl-legacy-provider
|
|
44
19
|
- npm start &
|
|
20
|
+
- sleep 3
|
|
45
21
|
- npm test
|
|
46
22
|
|
|
47
23
|
only:
|
|
48
24
|
refs:
|
|
49
25
|
- tags
|
|
50
|
-
- branches
|
|
26
|
+
- branches
|
package/.travis-ci.yml
CHANGED
|
@@ -1,27 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
language: node_js
|
|
2
|
+
|
|
3
|
+
node_js:
|
|
4
|
+
- "20"
|
|
5
|
+
|
|
7
6
|
before_script:
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
|
|
7
|
+
- npm install
|
|
8
|
+
- npx playwright install --with-deps chromium
|
|
9
|
+
|
|
11
10
|
script:
|
|
12
|
-
-
|
|
13
|
-
|
|
11
|
+
- npm start &
|
|
12
|
+
- npm test
|
|
13
|
+
|
|
14
14
|
cache:
|
|
15
15
|
directories:
|
|
16
|
-
-
|
|
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
|
|
16
|
+
- node_modules
|
package/.travis.yml
ADDED
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# Webship JS
|
|
2
2
|
|
|
3
|
-
[](https://github.com/webship/webship-js/actions)
|
|
4
|
+
[](https://gitlab.com/webship/webship-js/-/pipelines)
|
|
5
|
+
[](https://circleci.com/gh/webship/webship-js/tree/2.0.x)
|
|
6
|
+
[](https://bitbucket.org/webshipco/webship-js/pipelines)
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
Webship-js is an Automated Functional Acceptance Testing tool. Helps to ease and speed the work with the End-to-end testing features in web apps or projects. Utilizing [
|
|
9
|
+
Webship-js is an Automated Functional Acceptance Testing tool. Helps to ease and speed the work with the End-to-end testing features in web apps or projects. Utilizing [Playwright](https://playwright.dev) and [Cucumber-js](https://github.com/cucumber/cucumber-js). Having custom and advanced general step definitions.
|
|
10
10
|
|
|
11
11
|
### Webship-js Documentations
|
|
12
|
-
All you need to know is at [webship-js Docs](https://webship.co/docs/webship-js/
|
|
12
|
+
All you need to know is at [webship-js Docs](https://webship.co/docs/webship-js/2.0.x).
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
## Install webship-js using npm
|
|
@@ -21,11 +21,11 @@ npm install webship-js
|
|
|
21
21
|
## Install files required by the webship-js tool
|
|
22
22
|
|
|
23
23
|
```
|
|
24
|
-
bash <(wget -O - https://raw.githubusercontent.com/webship/wbash/v1/webship-js/
|
|
24
|
+
bash <(wget -O - https://raw.githubusercontent.com/webship/wbash/v1/webship-js/v2/template.sh)
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
## Automated Functional Acceptance Testing
|
|
28
28
|
|
|
29
29
|
```
|
|
30
30
|
npm test
|
|
31
|
-
```
|
|
31
|
+
```
|
package/bitbucket-pipelines.yml
CHANGED
|
@@ -4,15 +4,11 @@ pipelines:
|
|
|
4
4
|
default:
|
|
5
5
|
- step:
|
|
6
6
|
name: Install and Test
|
|
7
|
-
services:
|
|
8
|
-
- selenium
|
|
9
7
|
caches:
|
|
10
8
|
- node
|
|
11
9
|
script:
|
|
12
10
|
- npm install
|
|
11
|
+
- npx playwright install --with-deps chromium
|
|
12
|
+
- npm start &
|
|
13
|
+
- sleep 3
|
|
13
14
|
- FORCE_COLOR=1 npm test
|
|
14
|
-
|
|
15
|
-
definitions:
|
|
16
|
-
services:
|
|
17
|
-
selenium:
|
|
18
|
-
image: selenium/standalone-chrome:latest
|
package/cucumber.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
default: {
|
|
3
|
+
timeout: 30000,
|
|
4
|
+
requireModule: ['ts-node/register'],
|
|
5
|
+
require: [
|
|
6
|
+
'tests/step-definitions/**/*.js',
|
|
7
|
+
],
|
|
8
|
+
paths: ['tests/features/**/*.feature'],
|
|
9
|
+
format: [
|
|
10
|
+
'@cucumber/pretty-formatter',
|
|
11
|
+
'json:tests/reports/cucumber_report.json',
|
|
12
|
+
],
|
|
13
|
+
formatOptions: {
|
|
14
|
+
colorsEnabled: true,
|
|
15
|
+
theme: {
|
|
16
|
+
'feature keyword': ['bold', 'blue'],
|
|
17
|
+
'feature name': ['blue', 'underline'],
|
|
18
|
+
'feature description': ['blueBright'],
|
|
19
|
+
'scenario keyword': ['bold', 'magenta'],
|
|
20
|
+
'scenario name': ['magenta', 'underline'],
|
|
21
|
+
'step keyword': ['bold', 'green'],
|
|
22
|
+
'step text': ['greenBright', 'italic'],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
worldParameters: {
|
|
26
|
+
launchUrl: process.env.LAUNCH_URL || 'http://localhost:8080',
|
|
27
|
+
minWaitTime: {
|
|
28
|
+
page: 3000,
|
|
29
|
+
before_scenario: 0,
|
|
30
|
+
after_scenario: 0,
|
|
31
|
+
before_step: 0,
|
|
32
|
+
after_step: 0,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
@@ -452,7 +452,7 @@
|
|
|
452
452
|
itemCount++;
|
|
453
453
|
document.getElementById('items-list').innerHTML += `<p>Item ${itemCount}</p>`;
|
|
454
454
|
}
|
|
455
|
-
},
|
|
455
|
+
}, 3000);
|
|
456
456
|
}
|
|
457
457
|
});
|
|
458
458
|
|
|
@@ -472,7 +472,6 @@
|
|
|
472
472
|
count++;
|
|
473
473
|
setTimeout(() => {
|
|
474
474
|
document.getElementById('counter').textContent = count;
|
|
475
|
-
document.getElementById('react-app-container').querySelector('p:nth-child(2)').textContent = `Count: ${count}`;
|
|
476
475
|
}, 100);
|
|
477
476
|
}
|
|
478
477
|
|
package/examples/index.html
CHANGED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Modal Dialogs Test</title>
|
|
7
|
+
<style>
|
|
8
|
+
body { font-family: Arial, sans-serif; padding: 20px; }
|
|
9
|
+
button { margin: 5px; padding: 8px 16px; cursor: pointer; border-radius: 4px; border: 1px solid #ccc; }
|
|
10
|
+
.open-settings { background: #6c757d; color: white; border-color: #6c757d; }
|
|
11
|
+
table { border-collapse: collapse; width: 100%; margin: 20px 0; }
|
|
12
|
+
th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
|
|
13
|
+
th { background: #f2f2f2; }
|
|
14
|
+
#notification { margin-top: 10px; padding: 8px; display: none; color: green; }
|
|
15
|
+
|
|
16
|
+
/* Modal overlay */
|
|
17
|
+
.modal-overlay {
|
|
18
|
+
display: none;
|
|
19
|
+
position: fixed;
|
|
20
|
+
top: 0; left: 0; width: 100%; height: 100%;
|
|
21
|
+
background: rgba(0,0,0,0.5);
|
|
22
|
+
z-index: 1000;
|
|
23
|
+
justify-content: center;
|
|
24
|
+
align-items: center;
|
|
25
|
+
}
|
|
26
|
+
.modal-overlay.active {
|
|
27
|
+
display: flex;
|
|
28
|
+
}
|
|
29
|
+
.modal {
|
|
30
|
+
background: white;
|
|
31
|
+
border-radius: 8px;
|
|
32
|
+
padding: 24px;
|
|
33
|
+
max-width: 500px;
|
|
34
|
+
width: 90%;
|
|
35
|
+
position: relative;
|
|
36
|
+
box-shadow: 0 4px 20px rgba(0,0,0,0.3);
|
|
37
|
+
}
|
|
38
|
+
.modal-title { margin: 0 0 16px; font-size: 1.3em; }
|
|
39
|
+
.modal-body { margin-bottom: 16px; }
|
|
40
|
+
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; }
|
|
41
|
+
.modal-footer button { padding: 8px 16px; }
|
|
42
|
+
.btn-primary { background: #007bff; color: white; border-color: #007bff; }
|
|
43
|
+
.btn-danger { background: #dc3545; color: white; border-color: #dc3545; }
|
|
44
|
+
.btn-secondary { background: #6c757d; color: white; border-color: #6c757d; }
|
|
45
|
+
.close {
|
|
46
|
+
position: absolute;
|
|
47
|
+
top: 12px; right: 16px;
|
|
48
|
+
font-size: 1.4em;
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
background: none;
|
|
51
|
+
border: none;
|
|
52
|
+
color: #888;
|
|
53
|
+
}
|
|
54
|
+
.modal-success { color: green; margin-top: 10px; display: none; }
|
|
55
|
+
input[type="text"], input[type="email"], textarea {
|
|
56
|
+
width: 100%; padding: 6px; margin: 4px 0 10px; box-sizing: border-box;
|
|
57
|
+
border: 1px solid #ddd; border-radius: 4px;
|
|
58
|
+
}
|
|
59
|
+
</style>
|
|
60
|
+
</head>
|
|
61
|
+
<body>
|
|
62
|
+
<h1>Modal Dialogs Test Page</h1>
|
|
63
|
+
|
|
64
|
+
<!-- Trigger buttons -->
|
|
65
|
+
<button id="show-welcome-modal" onclick="openModal('welcome-modal')">Show Welcome Modal</button>
|
|
66
|
+
<button class="open-settings" onclick="openModal('settings-modal')">Open Settings</button>
|
|
67
|
+
<button id="contact-form-btn" onclick="openModal('contact-modal')">Contact Form</button>
|
|
68
|
+
<button id="show-modal" onclick="openModal('basic-modal')">Show Modal</button>
|
|
69
|
+
<button id="trigger-modal" onclick="openModal('confirm-modal')">Trigger Modal</button>
|
|
70
|
+
<button id="delete-btn" onclick="openModal('delete-confirmation-modal')">Delete Item</button>
|
|
71
|
+
|
|
72
|
+
<div id="notification">Project deleted successfully</div>
|
|
73
|
+
|
|
74
|
+
<!-- Projects table for modal-error-handling-example -->
|
|
75
|
+
<h2>Projects</h2>
|
|
76
|
+
<table id="projects-table">
|
|
77
|
+
<thead>
|
|
78
|
+
<tr><th>Project</th><th>Status</th><th>Actions</th></tr>
|
|
79
|
+
</thead>
|
|
80
|
+
<tbody>
|
|
81
|
+
<tr>
|
|
82
|
+
<td>Project Alpha</td>
|
|
83
|
+
<td>Active</td>
|
|
84
|
+
<td><button onclick="openDeleteModal('Project Alpha')">Delete</button></td>
|
|
85
|
+
</tr>
|
|
86
|
+
<tr>
|
|
87
|
+
<td>Project Beta</td>
|
|
88
|
+
<td>Active</td>
|
|
89
|
+
<td><button onclick="openDeleteModal('Project Beta')">Delete</button></td>
|
|
90
|
+
</tr>
|
|
91
|
+
</tbody>
|
|
92
|
+
</table>
|
|
93
|
+
|
|
94
|
+
<!-- Welcome Modal -->
|
|
95
|
+
<div id="welcome-modal-overlay" class="modal-overlay" role="dialog" aria-label="Welcome Message">
|
|
96
|
+
<div class="modal" id="welcome-modal">
|
|
97
|
+
<button class="close" onclick="closeModal('welcome-modal-overlay')">×</button>
|
|
98
|
+
<h2 class="modal-title">Welcome Message</h2>
|
|
99
|
+
<div class="modal-body">
|
|
100
|
+
<p>Thank you for joining us!</p>
|
|
101
|
+
<p>We're glad to have you here.</p>
|
|
102
|
+
</div>
|
|
103
|
+
<div class="modal-footer">
|
|
104
|
+
<button class="btn-primary" onclick="closeModal('welcome-modal-overlay')">OK</button>
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
<!-- Settings Modal -->
|
|
110
|
+
<div id="settings-modal-overlay" class="modal-overlay" role="dialog" aria-label="User Settings">
|
|
111
|
+
<div class="modal" id="settings-modal">
|
|
112
|
+
<button class="close" onclick="closeModal('settings-modal-overlay')">×</button>
|
|
113
|
+
<h2 class="modal-title">User Settings</h2>
|
|
114
|
+
<div class="modal-body">
|
|
115
|
+
<label>Username:</label>
|
|
116
|
+
<input type="text" id="username" name="username" placeholder="Enter username">
|
|
117
|
+
<label>Email:</label>
|
|
118
|
+
<input type="email" id="email" name="email" placeholder="Enter email">
|
|
119
|
+
<div class="modal-success" id="settings-success">Settings saved successfully</div>
|
|
120
|
+
</div>
|
|
121
|
+
<div class="modal-footer">
|
|
122
|
+
<button class="btn-primary" onclick="saveSettings()">Save Changes</button>
|
|
123
|
+
<button class="btn-secondary" onclick="closeModal('settings-modal-overlay')">Close</button>
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
|
|
128
|
+
<!-- Contact Modal -->
|
|
129
|
+
<div id="contact-modal-overlay" class="modal-overlay" role="dialog" aria-label="Contact Form">
|
|
130
|
+
<div class="modal" id="contact-modal">
|
|
131
|
+
<button class="close" onclick="closeModal('contact-modal-overlay')">×</button>
|
|
132
|
+
<h2 class="modal-title">Contact Us</h2>
|
|
133
|
+
<div class="modal-body">
|
|
134
|
+
<p>Enter payment details</p>
|
|
135
|
+
<input type="text" id="contact-name" name="contact-name" placeholder="Your name">
|
|
136
|
+
<input type="email" id="contact-email" name="contact-email" placeholder="Your email">
|
|
137
|
+
<textarea id="contact-message" name="contact-message" rows="3" placeholder="Message"></textarea>
|
|
138
|
+
<div class="modal-success" id="contact-success">Message sent successfully</div>
|
|
139
|
+
</div>
|
|
140
|
+
<div class="modal-footer">
|
|
141
|
+
<button class="btn-primary" onclick="submitContact()">Submit</button>
|
|
142
|
+
<button class="btn-secondary" onclick="closeModal('contact-modal-overlay')">Cancel</button>
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
|
|
147
|
+
<!-- Basic Modal -->
|
|
148
|
+
<div id="basic-modal-overlay" class="modal-overlay" role="dialog">
|
|
149
|
+
<div class="modal" id="basic-modal">
|
|
150
|
+
<button class="close" onclick="closeModal('basic-modal-overlay')">×</button>
|
|
151
|
+
<h2 class="modal-title">Welcome</h2>
|
|
152
|
+
<div class="modal-body">
|
|
153
|
+
<p>This is a sample modal dialog</p>
|
|
154
|
+
</div>
|
|
155
|
+
<div class="modal-footer">
|
|
156
|
+
<button class="btn-primary" onclick="closeModal('basic-modal-overlay')">OK</button>
|
|
157
|
+
</div>
|
|
158
|
+
</div>
|
|
159
|
+
</div>
|
|
160
|
+
|
|
161
|
+
<!-- Confirm Modal -->
|
|
162
|
+
<div id="confirm-modal-overlay" class="modal-overlay" role="dialog">
|
|
163
|
+
<div class="modal" id="confirm-modal">
|
|
164
|
+
<button class="close" onclick="closeModal('confirm-modal-overlay')">×</button>
|
|
165
|
+
<h2 class="modal-title">Confirm Action</h2>
|
|
166
|
+
<div class="modal-body">
|
|
167
|
+
<p>Are you sure you want to proceed?</p>
|
|
168
|
+
</div>
|
|
169
|
+
<div class="modal-footer">
|
|
170
|
+
<button class="btn-primary" onclick="closeModal('confirm-modal-overlay')">Confirm</button>
|
|
171
|
+
<button class="btn-secondary" onclick="closeModal('confirm-modal-overlay')">Cancel</button>
|
|
172
|
+
</div>
|
|
173
|
+
</div>
|
|
174
|
+
</div>
|
|
175
|
+
|
|
176
|
+
<!-- Delete Confirmation Modal -->
|
|
177
|
+
<div id="delete-confirmation-modal-overlay" class="modal-overlay" role="dialog">
|
|
178
|
+
<div class="modal" id="delete-confirmation-modal">
|
|
179
|
+
<button class="close" onclick="closeModal('delete-confirmation-modal-overlay')">×</button>
|
|
180
|
+
<h2 class="modal-title">Confirm Delete</h2>
|
|
181
|
+
<div class="modal-body">
|
|
182
|
+
<p>Are you sure you want to delete this item?</p>
|
|
183
|
+
<p>This action cannot be undone</p>
|
|
184
|
+
</div>
|
|
185
|
+
<div class="modal-footer">
|
|
186
|
+
<button class="btn-danger" onclick="confirmDelete()">Yes, Delete</button>
|
|
187
|
+
<button class="btn-secondary" onclick="closeModal('delete-confirmation-modal-overlay')">Cancel</button>
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
</div>
|
|
191
|
+
|
|
192
|
+
<!-- Project Delete Confirmation Modal -->
|
|
193
|
+
<div id="project-delete-modal-overlay" class="modal-overlay" role="dialog">
|
|
194
|
+
<div class="modal" id="project-delete-modal">
|
|
195
|
+
<button class="close" onclick="closeModal('project-delete-modal-overlay')">×</button>
|
|
196
|
+
<h2 class="modal-title">Confirm Delete</h2>
|
|
197
|
+
<div class="modal-body">
|
|
198
|
+
<p id="project-delete-message">Are you sure you want to delete this project?</p>
|
|
199
|
+
</div>
|
|
200
|
+
<div class="modal-footer">
|
|
201
|
+
<button class="btn-danger" onclick="confirmProjectDelete()">Yes, Delete</button>
|
|
202
|
+
<button class="btn-secondary" onclick="closeModal('project-delete-modal-overlay')">Cancel</button>
|
|
203
|
+
</div>
|
|
204
|
+
</div>
|
|
205
|
+
</div>
|
|
206
|
+
|
|
207
|
+
<script>
|
|
208
|
+
var currentProject = '';
|
|
209
|
+
|
|
210
|
+
function openModal(modalId) {
|
|
211
|
+
var overlay = document.getElementById(modalId + '-overlay');
|
|
212
|
+
if (overlay) overlay.classList.add('active');
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function closeModal(overlayId) {
|
|
216
|
+
var overlay = document.getElementById(overlayId);
|
|
217
|
+
if (overlay) overlay.classList.remove('active');
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function openDeleteModal(projectName) {
|
|
221
|
+
currentProject = projectName;
|
|
222
|
+
document.getElementById('project-delete-message').textContent =
|
|
223
|
+
'Are you sure you want to delete ' + projectName + '?';
|
|
224
|
+
openModal('project-delete-modal');
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function confirmDelete() {
|
|
228
|
+
closeModal('delete-confirmation-modal-overlay');
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function confirmProjectDelete() {
|
|
232
|
+
closeModal('project-delete-modal-overlay');
|
|
233
|
+
var n = document.getElementById('notification');
|
|
234
|
+
n.style.display = 'block';
|
|
235
|
+
setTimeout(function() { n.style.display = 'none'; }, 5000);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function saveSettings() {
|
|
239
|
+
var s = document.getElementById('settings-success');
|
|
240
|
+
s.style.display = 'block';
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function submitContact() {
|
|
244
|
+
var s = document.getElementById('contact-success');
|
|
245
|
+
s.style.display = 'block';
|
|
246
|
+
setTimeout(function() {
|
|
247
|
+
closeModal('contact-modal-overlay');
|
|
248
|
+
}, 3000);
|
|
249
|
+
}
|
|
250
|
+
</script>
|
|
251
|
+
</body>
|
|
252
|
+
</html>
|