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

Add documentation #7

Merged
merged 2 commits into from
Oct 8, 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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/jekyll-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Sample workflow for building and deploying a Jekyll site to GitHub Pages
name: Deploy Jekyll with GitHub Pages dependencies preinstalled

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
paths:
- "docs/**"

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: ./docs
destination: ./_site
- name: Upload artifact
uses: actions/upload-pages-artifact@v3

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
2 changes: 2 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_site
.jekyll-cache
7 changes: 7 additions & 0 deletions docs/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
source 'https://rubygems.org'

gem "jekyll", "~> 4.3.4" # installed by `gem jekyll`
# gem "webrick" # required when using Ruby >= 3 and Jekyll <= 4.2.2

gem "just-the-docs", "0.10.0" # pinned to the current release
# gem "just-the-docs" # always download the latest release
94 changes: 94 additions & 0 deletions docs/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
bigdecimal (3.1.8)
colorator (1.1.0)
concurrent-ruby (1.3.4)
em-websocket (0.5.3)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0)
eventmachine (1.2.7)
ffi (1.17.0-arm64-darwin)
ffi (1.17.0-x86_64-linux-gnu)
ffi (1.17.0-x86_64-linux-musl)
forwardable-extended (2.6.0)
google-protobuf (4.28.1-arm64-darwin)
bigdecimal
rake (>= 13)
google-protobuf (4.28.1-x86_64-linux)
bigdecimal
rake (>= 13)
http_parser.rb (0.8.0)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
jekyll (4.3.4)
addressable (~> 2.4)
colorator (~> 1.0)
em-websocket (~> 0.5)
i18n (~> 1.0)
jekyll-sass-converter (>= 2.0, < 4.0)
jekyll-watch (~> 2.0)
kramdown (~> 2.3, >= 2.3.1)
kramdown-parser-gfm (~> 1.0)
liquid (~> 4.0)
mercenary (>= 0.3.6, < 0.5)
pathutil (~> 0.9)
rouge (>= 3.0, < 5.0)
safe_yaml (~> 1.0)
terminal-table (>= 1.8, < 4.0)
webrick (~> 1.7)
jekyll-include-cache (0.2.1)
jekyll (>= 3.7, < 5.0)
jekyll-sass-converter (3.0.0)
sass-embedded (~> 1.54)
jekyll-seo-tag (2.8.0)
jekyll (>= 3.8, < 5.0)
jekyll-watch (2.2.1)
listen (~> 3.0)
just-the-docs (0.10.0)
jekyll (>= 3.8.5)
jekyll-include-cache
jekyll-seo-tag (>= 2.0)
rake (>= 12.3.1)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
liquid (4.0.4)
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
mercenary (0.4.0)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (6.0.1)
rake (13.2.1)
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
rexml (3.3.7)
rouge (4.3.0)
safe_yaml (1.0.5)
sass-embedded (1.78.0)
google-protobuf (~> 4.27)
rake (>= 13)
sass-embedded (1.78.0-arm64-darwin)
google-protobuf (~> 4.27)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
unicode-display_width (2.6.0)
webrick (1.8.1)

PLATFORMS
arm64-darwin
x86_64-linux-gnu
x86_64-linux-musl

DEPENDENCIES
jekyll (~> 4.3.4)
just-the-docs (= 0.10.0)

BUNDLED WITH
2.5.9
11 changes: 11 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
title: CustomerGauge
description: CustomerGauge public node packages documentation
theme: just-the-docs

url: https://cgauge.github.io/packages

mermaid:
version: "11.3.0"

aux_links:
Github: https://github.com/cgauge/packages
57 changes: 57 additions & 0 deletions docs/docs/dtc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
title: DTC
layout: default
nav_order: 2
---

# Declarative Test Cases

## Introduction

Declarative Test Case was created to avoid writing code to test the code (in the end, who tests the test?). The main idea is to have a similar way of thinking while writing tests. Using the same data and structure format, something that can be shared between people with different knowledge level and abilities.

The executing and plugins flow follow the Arrange-Act-Assert pattern:

```mermaid
graph TD;
accTitle: Arrange-Act-Assert
accDescr: Test steps
Arrange[Arrange inputs and targets]
Act[Act on the target behavior]
Assert[Assert expected outcomes]
Arrange-->Act;
Act-->Assert;
```

# Architecture

The library architecture is divided in four main parts: Loader, Runner, Test Types and Plugins

```mermaid
flowchart LR
accTitle: Architecture
accDescr: Executing flow
Loader-->Files@{ shape: processes, label: "Files" }
subgraph Runner
subgraph Test Type Plugins
Arrange-->Act
Act-->Assert
end
end
Files-->Runner
```

## Loader

By default DTC loads Javascript files expecting the content to be default exported, but you can basically load any file type by configuring a custom loader.

## Runner

By default DTC use Node Native Test Runner Javascript, but it is also flexible to be configured to use Jest, Playwright or any other Test Runner.

## Default test types

- Unit: it runs small set of code
- Narrow: for integration tests mocking network, like HTTP calls
- Broad: for integration tests using network

37 changes: 37 additions & 0 deletions docs/docs/dtc/configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: Configuration
layout: default
parent: DTC
nav_order: 2
---

# Configuration

It is possible to configure custom loaders, runners, test types and plugins.

## Custom configuration

```js
// dtc.config.js
export default {
loader: async (filePath) => customLoader(filePath),
runner: new CustomTestRunner(),
plugins: {
unit: [new CustomPlugin()],
customTestType: [new CustomPlugin(), new AnotherPlugin()],
},
testRegex: /.*\.dtc\.[jt]s?$/
}
```

## Using a configuration

```sh
npx dtc -c dtc.config.js
```

## Executing a custom test type

```sh
npx dtc -c dtc.config.js -t customTestType
```
56 changes: 56 additions & 0 deletions docs/docs/dtc/quick-start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
title: Quick Start
layout: default
parent: DTC
nav_order: 1
---

# Quick Start

## Installation

```sh
npm install -D @cgauge/dtc
```

### Target file

```js
// hello.js
export const greeting = (name) => `Hello ${name}`
```

### Test case
```js
// hello.dtc.js
export default {
name: 'My first test case',
unit: {
act: {
import: 'greeting',
from: './hello.js',
arguments: ['World']
},
assert: 'Hello World'
}
}
```

### Executing

```sh
npx dtc
```

### Result

```sh
✔ My first test case
ℹ tests 1
ℹ suites 0
ℹ pass 1
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
```
22 changes: 22 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: Home
layout: home
nav_order: 1
---

# CustomerGauge Public Packages

- DTC - Declarative Test Cases
- DTC AWS Plugin - Interact with AWS services
- DTC MySQL Plugin - Interact and Mock MySQL calls
- DTC Playwright Plugin - Test Runner and Interaction
- Nock AWS - Helper to mock AWS API calls
- YAML - YAML parse with extra tags

## Contributing

Contributions are always welcome, please have a look at our issues to see if there's something you could help with.

## License

All packages are licensed under LGPLv3 license.