Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge website code from nightwatch-www repo #288

Merged
merged 4 commits into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
51 changes: 51 additions & 0 deletions .github/workflows/deploy-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build and Deploy

on:
push:
branches:
- 'preview'
- 'versions/3.0-complete'

jobs:
build:
runs-on: ubuntu-latest
env:
BASE_URL: https://dev.nightwatchjs.org
REMOTE_SERVER: ${{ secrets.REMOTE_SERVER }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
API_DOCS_FOLDER: ${{ github.workspace }}/nightwatch/lib/api

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Checkout Nightwatch source code
uses: actions/checkout@v2
with:
repository: nightwatchjs/nightwatch
path: nightwatch

- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: '18'

- name: Install dependencies
run: npm install

- name: Build the website
run: npm run build

- name: Creating symlinks to old version
run: |
ln -s ../nightwatchjs.org out/v17
ln -s ../v09.nightwatchjs.org out/v09
ln -s ../nightwatch-v26 out/v26

- name: Deploy to server
run: |
mkdir -p ~/.ssh
echo "${{ secrets.PROD_DEPLOY_SECRET }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan ${{ env.REMOTE_SERVER }} >> ~/.ssh/known_hosts
rsync -azP --delete ./out/ ${{ env.REMOTE_USER }}@${{ env.REMOTE_SERVER }}:${{ secrets.REMOTE_PREVIEW_DIRECTORY }}
20 changes: 19 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,23 @@
node_modules
.idea
*.plist
.idea/
.vscode/

api/**/*.ejs
# Dependency directories
node_modules/
logs

# Postdoc output directory
out/
output/

# dotenv environment variables file
.env
.env.local

# Nightwatch output directory
tests_output
/public/__examples/
package-lock.json
.pd*
67 changes: 64 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Nightwatch Documentation
# Nightwatch.js Documentation

Documentation sources for [nightwatchjs.org](http://nightwatchjs.org) website.

Expand All @@ -10,12 +10,73 @@ Documentation sources for [nightwatchjs.org](http://nightwatchjs.org) website.
[![Twitter Follow](https://img.shields.io/twitter/follow/nightwatchjs.svg?style=social)](https://twitter.com/nightwatchjs)

<p align="center">
<img alt="Nightwatch.js Schematic Logo" src="https://raw.githubusercontent.com/nightwatchjs/nightwatch/f214d79b3f7d0cf7602a6b57823420baaa3b5282/.github/assets/nightwatch-logo.svg" width=300 />
<img alt="Nightwatch.js Logo" src="https://raw.githubusercontent.com/nightwatchjs/nightwatch/main/.github/assets/nightwatch-logo.png" width=300 />
</p>

#### [Homepage](https://nightwatchjs.org) &bullet; [Getting Started](https://nightwatchjs.org/gettingstarted) &bullet; [Developer Guide](https://nightwatchjs.org/guide) &bullet; [API Reference](https://nightwatchjs.org/api) &bullet; [About](https://nightwatchjs.org/about)
#### [Homepage](https://nightwatchjs.org) &bullet; [Developer Guide](https://nightwatchjs.org/guide) &bullet; [API Reference](https://nightwatchjs.org/api) &bullet; [About](https://nightwatchjs.org/about) &bullet; [Blog](https://nightwatchjs.org/blog)

***

## Development

The docs content is written in Markdown and it is located in the `docs` folder. The individual API command pages are generated from the Nightwatch source code. based on the JSDoc comments.

### Run the website locally

The website is built with **PostDoc** (a static site generator built with Vite and EJS). It supports Markdown, EJS, and front matter.
It comes with a dev server with Hot module replacement (HMR).

### Configuration

The website configuration is located in the `postdoc.config.js` file. In order to run the website locally, you need to have the Nightwatch source code repo clones and then specify the path to it in the `postdoc.config.js` file.

You can also set the `API_DOCS_FOLDER` environment variable to specify the path. You can also disable the API docs generation by setting the `apidocs` property to `false` in the `postdoc.config.js` file, e.g.:

```js
export default {
apidocs: false
}
```

### Installation

```bash
npm install
npm start
```

### PostDoc CLI

To view the available options, run:

```bash
npx postdoc --help
```

#### Automatically open the website in the browser

```bash
npm start -- --open [chrome|firefox|edge|safari]
```

## Build

To build the website, run:

```bash
npm run build
```

The generated files will be in the `out` folder.

Quickly serve the generated files with:

```bash
npx postdoc preview
```

## License
MIT

[discord-badge]: https://img.shields.io/discord/618399631038218240.svg?color=7389D8&labelColor=6A7EC2&logo=discord&logoColor=ffffff&style=flat-square
[discord]: https://discord.gg/SN8Da2X
54 changes: 54 additions & 0 deletions build/optimize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import {generate} from 'critical';
import {minify} from 'html-minifier';
import {readFileSync, writeFileSync} from 'fs';
import path from 'path';

// Inline critical CSS
generate({
inline: true,
base: 'out/',
src: 'index.html',
target: {
html: 'index.html',
uncritical: 'css/landing/style.css'
},
dimensions: [
{
height: 200,
width: 500
},
{
height: 900,
width: 1024
},
{
height: 900,
width: 1400
}
],
// ignore CSS rules
ignoreInlinedStyles: true
}).then(({css, html, uncritical}) => {
console.log('Critical CSS generated', css.length);
console.log('Uncritical CSS generated', uncritical.length);
}).catch(err => {
console.error('Critical CSS generation failed', err);
}).then(() => {
// Minify HTML
const htmlPath = path.resolve('out/index.html');
const htmlContent = readFileSync(htmlPath, 'utf8');
const minifiedHTMLContent = minify(htmlContent, {
collapseWhitespace: true,
collapseInlineTagWhitespace: true,
conservativeCollapse: true,
minifyCSS: true,
minifyJS: true,
removeComments: true,
useShortDoctype: true,
html5: true
});

writeFileSync(htmlPath, minifiedHTMLContent, 'utf8');
console.log('Wrote minified HTML to', htmlPath, minifiedHTMLContent.length);
});

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ Nightwatch will call the command on the context of the page or section. Client c
From Nightwatch 2 it is also possible to export the page commands as an ES6 class.

### Recommended content
- [Define page elements](https://nightwatchjs.org/guide/using-page-objects/defining-elements.html)
- [Define sections](https://nightwatchjs.org/guide/using-page-objects/defining-sections.html)
- [Add page-specific commands](https://nightwatchjs.org/guide/using-page-objects/writing-page-specific-commands.html)
- [Define page elements](/guide/using-page-objects/defining-elements.html)
- [Define sections](/guide/using-page-objects/defining-sections.html)
- [Add page-specific commands](/guide/using-page-objects/writing-page-specific-commands.html)

<div class="doc-pagination pt-40">
<div class="previous">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ It is very useful to be able to run your tests against multiple browsers in para
From **v1.7** you are able to do just that.

### Recommended content
- [Define and use test environments](https://nightwatchjs.org/guide/configuration/define-test-environments.html)
- [How-to guide > Run tests in parallel](https://nightwatchjs.org/guide/running-tests/parallel-running.html)
- [Define and use test environments](/guide/configuration/define-test-environments.html)
- [How-to guide > Run tests in parallel](/guide/running-tests/parallel-running.html)

<div class="doc-pagination pt-40">
<div class="previous">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ myGlobalVar is: "integrated global"
```

### Recommended content
- [Use external globals in tests](https://nightwatchjs.org/guide/writing-tests/using-test-globals.html)
- [Use global test hooks in tests](https://nightwatchjs.org/guide/writing-tests/global-test-hooks.html)
- [Use external globals in tests](/guide/writing-tests/using-test-globals.html)
- [Use global test hooks in tests](/guide/writing-tests/global-test-hooks.html)

<div class="doc-pagination pt-40">
<div class="previous">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ The below settings can be used to define ways of filtering test files.
</table>

### Recommended content
- [Reference > All configuration settings](https://nightwatchjs.org/guide/reference/settings.html)
- [Reference > Configuration defaults](https://nightwatchjs.org/guide/reference/defaults.html)
- [Reference > All configuration settings](/guide/reference/settings.html)
- [Reference > Configuration defaults](/guide/reference/defaults.html)

<div class="doc-pagination pt-40">
<div class="previous">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ module.exports = (async function() {
// if this is not specified, the test source must be passed as the second argument to the test runner.
src_folders: [],
<br>
// See https://nightwatchjs.org/guide/working-with-page-objects/using-page-objects.html
// See /guide/working-with-page-objects/using-page-objects.html
page_objects_path: ['node_modules/nightwatch/examples/pages/'],
<br>
// See https://nightwatchjs.org/guide/extending-nightwatch/custom-commands.html
// See /guide/extending-nightwatch/custom-commands.html
custom_commands_path: ['node_modules/nightwatch/examples/custom-commands/'],
<br>
// See https://nightwatchjs.org/guide/extending-nightwatch/custom-assertions.html
// See /guide/extending-nightwatch/custom-assertions.html
custom_assertions_path: '',
<br>
// See https://nightwatchjs.org/guide/extending-nightwatch/plugin-api.html
// See /guide/extending-nightwatch/plugin-api.html
plugins: [],
<br>
// See https://nightwatchjs.org/guide/#external-globals
// See /guide/#external-globals
globals_path : '',
<br>
webdriver: {},
Expand Down Expand Up @@ -102,8 +102,8 @@ module.exports = (async function() {
[1]: https://aws.amazon.com/device-farm/

### Recommended content
- [Reference > All configuration settings](https://nightwatchjs.org/guide/reference/settings.html)
- [Reference > Configuration defaults](https://nightwatchjs.org/guide/reference/defaults.html)
- [Reference > All configuration settings](/guide/reference/settings.html)
- [Reference > Configuration defaults](/guide/reference/defaults.html)

<div class="doc-pagination pt-40">
<div class="previous">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ You can specify proxy settings in Nightwatch by adding the `proxy` key in your `

### Recommended content

- [Reference > All configuration settings](https://nightwatchjs.org/guide/reference/settings.html)
- [Reference > Configuration defaults](https://nightwatchjs.org/guide/reference/defaults.html)
- [Reference > All configuration settings](/guide/reference/settings.html)
- [Reference > Configuration defaults](/guide/reference/defaults.html)

<div class="doc-pagination pt-40">
<div class="previous">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ The below settings can be used to control the output and logging when running te
</table>

### Recommended content
- [Reference > All configuration settings](https://nightwatchjs.org/guide/reference/settings.html)
- [Reference > Configuration defaults](https://nightwatchjs.org/guide/reference/defaults.html)
- [Reference > All configuration settings](/guide/reference/settings.html)
- [Reference > Configuration defaults](/guide/reference/defaults.html)

<div class="doc-pagination pt-40">
<div class="previous">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ OK. 1 assertions passed. (5.604s)
```

### Recommended content
- [Concepts > Test environments](https://nightwatchjs.org/guide/concepts/test-environments.html)
- [Concepts > Test environments](/guide/concepts/test-environments.html)
- [Reference > Browser Drivers > ChormeDriver](/guide/configuration/define-test-environments.html)
- [Reference > All configuration settings](https://nightwatchjs.org/guide/reference/settings.html)
- [Reference > Configuration defaults](https://nightwatchjs.org/guide/reference/defaults.html)
- [Reference > All configuration settings](/guide/reference/settings.html)
- [Reference > Configuration defaults](/guide/reference/defaults.html)

<div class="doc-pagination pt-40">
<div class="previous">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The Nightwatch test runner binary expects a configuration file located in the cu
- `nightwatch.conf.ts` (when using TypeScript)
- `nightwatch.json`

You can always specify a config file location via the `--config` CLI argument. Read more about CLI options on the [Reference > Nightwatch CLI](https://nightwatchjs.org/guide/nightwatch-cli/command-line-options.html) page.
You can always specify a config file location via the `--config` CLI argument. Read more about CLI options on the [Reference > Nightwatch CLI](/guide/nightwatch-cli/command-line-options.html) page.

<div class="alert alert-info">
From Nightwatch 2, you can also specify the config file to return a Promise and the result will be <code>await</code>-ed.
Expand Down Expand Up @@ -67,8 +67,8 @@ The following packages can be used from NPM and, if installed, Nightwatch will a


### Recommended content
- [Reference > All configuration settings](https://nightwatchjs.org/guide/reference/settings.html)
- [Reference > Configuration defaults](https://nightwatchjs.org/guide/reference/defaults.html)
- [Reference > All configuration settings](/guide/reference/settings.html)
- [Reference > Configuration defaults](/guide/reference/defaults.html)

<div class="doc-pagination pt-40">
<div class="previous">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Considering this setup, to run tests, for instance, against Safari, we would run

<pre><code class="language-bash">nightwatch --env safari</code></pre>

Refer to the [Defining Test Environments](https://nightwatchjs.org/guide/using-nightwatch/concepts.html#defining-test-environments) page to learn more about how to use test environments.
Refer to the [Defining Test Environments](/guide/using-nightwatch/concepts.html#defining-test-environments) page to learn more about how to use test environments.

### Working with Test Globals
Another useful concept that Nightwatch provides is test globals. In its most simple form, it is a dictionary of name-value pairs which is defined in your configuration file.
Expand Down Expand Up @@ -141,7 +141,7 @@ Like the `launch_url` property, the `globals` object is made available directly
};</code></pre>
</div>

Refer to the [Using Test Globals](https://nightwatchjs.org/guide/using-nightwatch/concepts.html#using-test-globals) page to learn more about how to use test globals.
Refer to the [Using Test Globals](/guide/using-nightwatch/concepts.html#using-test-globals) page to learn more about how to use test globals.

### Using Env variables
Any config value in either `nightwatch.conf.js` or `nightwatch.json` can be specified as the name of an environment variables. Nightwatch will automatically populate the value, if found, from `process.env`.
Expand Down Expand Up @@ -215,5 +215,5 @@ Assuming you have downloaded or installed the ChromeDriver service, the simplest
[4]: https://www.npmjs.com/package/selenium-server

### Recommended content
- [Reference > All configuration settings](https://nightwatchjs.org/guide/reference/settings.html)
- [Reference > Configuration defaults](https://nightwatchjs.org/guide/reference/defaults.html)
- [Reference > All configuration settings](/guide/reference/settings.html)
- [Reference > Configuration defaults](/guide/reference/defaults.html)
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ The following **NPM** packages are assumed to be installed in the current projec

### Recommended content

- [Reference > All configuration settings](https://nightwatchjs.org/guide/reference/settings.html)
- [Reference > Configuration defaults](https://nightwatchjs.org/guide/reference/defaults.html)
- [Reference > All configuration settings](/guide/reference/settings.html)
- [Reference > Configuration defaults](/guide/reference/defaults.html)

<div class="doc-pagination pt-40">
<div class="previous">
Expand Down
Loading
Loading