1.9.5 • Published 4 days ago

@maxio-com/self-service v1.9.5

Weekly downloads
-
License
-
Repository
-
Last release
4 days ago

Headless Billing Portal

written in typescript styled with prettier tested with jest Commitizen friendly yarn lerna

🔧 Installation and usage

1. Install dependencies

pnpm install @maxio-com/self-service
npm install @maxio-com/self-service
yarn add @maxio-com/self-service

2. Import components

Import components from @maxio-com/self-service package as ES6 modules or include them in your HTML file.

import { Components } from '@maxio-com/self-service';

3. Use components

const componentsFactory = new Components({
  theme: componentsTheme,
  i18nSettings: {
    loadPath: 'loadPath-url',
    language: locale,
  },
  accessTokenUrl: 'accessTokenUrl-url',
});

4. Examples

Vue.js example is available in vue-self-service-example directory.

React.js example is available in react-self-service-example directory.

Installation

Please follow the steps described below to correctly setup mono-repository.

Required system dependencies

  • NodeJS - JavaScript runtime environment.
  • pnpm - package manager used to maintain project dependencies

a. NodeJS

Install NodeJS JavaScript runtime based on your environemnt of choice:

For Homebrew on OS X and macOS

brew install node

You can also download and install NodeJS directly from the official website.

Ensure that NodeJS environment is at least v14

b. PNPM

Install pnpm package manager:

c. Checkout repository

Checkout repository from main branch.

d. Install dependencies

Execute pnpm install command in terminal to install all required dependencies.

e. Configure GIT hooks

Execute npx husky install command in terminal to setup GIT pre-commit and commit-msg hooks integration.

mock server

For development purposes this project could use api-adapter-mock server. To run server make sure that required system dependencies are installed:

Run command defined below in the command-line interface:

CommandDescription
docker-compose upruns mock server instance on port 8080.

✨ npm scripts

List of useful commands that could be used by developers. Execution in the command-line interface should be prefixed with yarn package manager.

CommandDescription
storybookrun storybook for development on port 6006
build-storybookbuild storybook production distribution.
lintrun linter against current application codebase.
testrun unit tests.
test:coveragerun unit tests with coverage reporter.
prettierrun code formatter process against current codebase.
dpdmdetects circular dependencies in codebase.

commit

This project uses Conventional Commits to enforce common commit standards.

CommandDescription
npx git-czrun commit command line interface.

build

This repository builds multiple artifacts to address different integration use cases:

ArtifactDescription
UMDbundle with all dependencies dedicated for browser environment.
EcmaScript Moduletranspiled code to EcmaScript module exports / imports with tree-shaking support.
CommonJS Moduletranspiled code to NodeJS exports / imports syntax.
Types Definitionstypes declarations for applications implemented in TypeScript environment.

translations

Some translations are allowed to have basic HTML tags inside like <strong> or <i>. However, this only works for elements without additional attributes (like className), having none or a single text children and provided that we use them in places that allow by design for text formatting.

E2E Tests

This repository uses Playwright framework for testing and automation.

pipeline

End-to-end tests could be executed by using dedicated GitHub Actions workflow. By default the Playwright Tests is triggered for each pull request created in the repository.

The pipeline could be also triggered manually by using Run workflow feature in GitHub Actions.

The docker image used in pipeline is coupled with Playwright version installed as NPM dependency.

AIO tests

The Playwright and tests are fully integrated with AIO test management tool. The end-to-end tests codebase could contain tags which refers to specific AIO test cases.

During manual pipeline execution - the test_cycle_id argument could be used to execute only tests cases included in AIO Test Cycle and automatically update execution results.

How to perform End to End Testing using Playwright locally

1. Build RUC package using command:

pnpm build:browser

As a result maxio-components.umd.js will be created inside dist folder

2. Copy assets into e2e_pages folder using command:

pnpm copy:e2e-assets

Note: You can use pnpm clean:e2e-assets to clean old assets first if needed

3. Serve pages and assets so playwright can load it properly on specified port:

pnpm serve:e2e-assets

4. Provide required env variables (you can refer to .env.example)

5. Run playwright tests:

npx playwright test

Additional information:

  • playwright.config.ts: Is playwright configuration file. Anything related to browser, hosts, timeouts, and parallelism can be configured there.

  • --headed flag added to npx playwright test allows to open browser during tests

  • page.pause() allows to pause the test execution and do some debugging