@fixedwidthtable/fixedwidthtable 0.0.1-security → 0.0.3
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.
Potentially problematic release.
This version of @fixedwidthtable/fixedwidthtable might be problematic. Click here for more details.
- package/.eslintignore +2 -0
- package/.eslintrc.js +8 -0
- package/.github/dependabot.yml +24 -0
- package/.github/workflows/audit.yml +14 -0
- package/.github/workflows/ci.yml +53 -0
- package/.github/workflows/release.yml +31 -0
- package/.github/workflows/reusable-audit.yml +41 -0
- package/.github/workflows/reusable-lint.yml +33 -0
- package/CODEOWNERS +1 -0
- package/LICENSE.md +18 -0
- package/README.md +12 -3
- package/e2e/browser/test/e2e.playwright.ts +67 -0
- package/e2e/browser/test/globalSetup.ts +30 -0
- package/e2e/browser/test-app/.eslintrc.js +6 -0
- package/e2e/browser/test-app/README.md +46 -0
- package/e2e/browser/test-app/components/appContainer/index.tsx +109 -0
- package/e2e/browser/test-app/components/solidClient/index.tsx +149 -0
- package/e2e/browser/test-app/next-env.d.ts +5 -0
- package/e2e/browser/test-app/next.config.js +6 -0
- package/e2e/browser/test-app/package-lock.json +1982 -0
- package/e2e/browser/test-app/package.json +25 -0
- package/e2e/browser/test-app/pages/_app.tsx +28 -0
- package/e2e/browser/test-app/pages/index.tsx +36 -0
- package/e2e/browser/test-app/tsconfig.json +20 -0
- package/eslint-configs/README.md +75 -0
- package/eslint-configs/eslint-config-base/README.md +29 -0
- package/eslint-configs/eslint-config-base/index.js +159 -0
- package/eslint-configs/eslint-config-base/license-header.js +20 -0
- package/eslint-configs/eslint-config-base/package.json +41 -0
- package/eslint-configs/eslint-config-lib/README.md +51 -0
- package/eslint-configs/eslint-config-lib/index.js +83 -0
- package/eslint-configs/eslint-config-lib/package.json +29 -0
- package/eslint-configs/eslint-config-react/README.md +97 -0
- package/eslint-configs/eslint-config-react/index.js +75 -0
- package/eslint-configs/eslint-config-react/package.json +32 -0
- package/lerna.json +4 -0
- package/package.json +45 -3
- package/packages/base-rollup-config/README.md +22 -0
- package/packages/base-rollup-config/index.mjs +59 -0
- package/packages/base-rollup-config/package.json +25 -0
- package/packages/internal-playwright-helpers/README.md +30 -0
- package/packages/internal-playwright-helpers/package.json +29 -0
- package/packages/internal-playwright-helpers/rollup.config.mjs +57 -0
- package/packages/internal-playwright-helpers/src/fixtures.ts +51 -0
- package/packages/internal-playwright-helpers/src/flows/auth.ts +93 -0
- package/packages/internal-playwright-helpers/src/index.ts +26 -0
- package/packages/internal-playwright-helpers/src/pages/cognito.ts +48 -0
- package/packages/internal-playwright-helpers/src/pages/open-id.ts +56 -0
- package/packages/internal-playwright-helpers/src/pages/testPage.ts +74 -0
- package/packages/internal-playwright-helpers/tsconfig.json +8 -0
- package/packages/internal-playwright-testids/package.json +22 -0
- package/packages/internal-playwright-testids/rollup.config.mjs +56 -0
- package/packages/internal-playwright-testids/src/index.ts +35 -0
- package/packages/internal-playwright-testids/tsconfig.json +8 -0
- package/packages/internal-test-env/README.md +44 -0
- package/packages/internal-test-env/env/.env.example +36 -0
- package/packages/internal-test-env/index.ts +474 -0
- package/packages/internal-test-env/package.json +30 -0
- package/packages/internal-test-env/rollup.config.mjs +80 -0
- package/packages/internal-test-env/tsconfig.json +20 -0
- package/packages/internal-test-env/utils.ts +31 -0
- package/packages/jest-jsdom-polyfills/README.md +21 -0
- package/packages/jest-jsdom-polyfills/index.js +80 -0
- package/packages/jest-jsdom-polyfills/package.json +36 -0
- package/playwright.config.ts +76 -0
- package/scripts/index.js +1 -0
- package/scripts/prepare-release.sh +32 -0
- package/scripts/release.sh +36 -0
- package/tsconfig.base.json +17 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# eslint-config-inrupt-react
|
|
2
|
+
|
|
3
|
+
Eslint and prettier configs
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
1. `npm install --save-dev @inrupt/eslint-config-react @rushstack/eslint-patch`
|
|
8
|
+
|
|
9
|
+
## Setup (Quick start)
|
|
10
|
+
|
|
11
|
+
Create a `.eslintrc.js` in the the root of your project with the following contents:
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
require("@rushstack/eslint-patch/modern-module-resolution");
|
|
15
|
+
|
|
16
|
+
module.exports = {
|
|
17
|
+
extends: ["@inrupt/eslint-config-react"],
|
|
18
|
+
parserOptions: {
|
|
19
|
+
project: "./tsconfig.eslint.json",
|
|
20
|
+
},
|
|
21
|
+
rules: {},
|
|
22
|
+
};
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The file `tsconfig.eslint.json` is your typescript configuration with the e2e tests, unit tests and examples included, e.g.,
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"extends": "./tsconfig.json",
|
|
30
|
+
"include": ["src/**/*.ts", "e2e/**/*.ts", "*.md"],
|
|
31
|
+
"exclude": ["**/node_modules", "**/dist/**"]
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### For typescript projects:
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
require("@rushstack/eslint-patch/modern-module-resolution");
|
|
39
|
+
|
|
40
|
+
module.exports = {
|
|
41
|
+
root: true,
|
|
42
|
+
|
|
43
|
+
extends: [
|
|
44
|
+
"@inrupt/eslint-config-react",
|
|
45
|
+
"@inrupt/eslint-config-lib",
|
|
46
|
+
"plugin:import/typescript",
|
|
47
|
+
],
|
|
48
|
+
|
|
49
|
+
parserOptions: {
|
|
50
|
+
project: "./tsconfig.eslint.json",
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
// These settings and the `plugin:import/typescript` are required until we add
|
|
54
|
+
// this configuration to our @inrupt/eslint-config-lib base
|
|
55
|
+
settings: {
|
|
56
|
+
"import/parsers": {
|
|
57
|
+
"@typescript-eslint/parser": [".ts", ".tsx"],
|
|
58
|
+
},
|
|
59
|
+
"import/resolver": {
|
|
60
|
+
typescript: {
|
|
61
|
+
alwaysTryTypes: true,
|
|
62
|
+
project: "./tsconfig.eslint.json",
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
rules: {
|
|
68
|
+
"react/jsx-filename-extension": [
|
|
69
|
+
"error",
|
|
70
|
+
{
|
|
71
|
+
extensions: [".tsx"],
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Migrating to this configuration:
|
|
79
|
+
|
|
80
|
+
1. Add `extends: ['@inrupt/eslint-config-react']` to your `.eslintrc.js` file.
|
|
81
|
+
1. Add the following line to the top of the `.eslintrc.js` file:
|
|
82
|
+
|
|
83
|
+
```js
|
|
84
|
+
require("@rushstack/eslint-patch/modern-module-resolution");
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Rules
|
|
88
|
+
|
|
89
|
+
Exhaustive documentation forthcoming. For now, the general principles are:
|
|
90
|
+
|
|
91
|
+
- Load a stylistic base set - in this case,
|
|
92
|
+
[airbnb](https://www.npmjs.com/package/eslint-config-airbnb) and
|
|
93
|
+
[airbnb/hooks](https://www.npmjs.com/package/eslint-config-airbnb-hooks)
|
|
94
|
+
- Load inrupt-base, which loads recommended configs for common libraries: eslint, jest, typescript,
|
|
95
|
+
and prettier
|
|
96
|
+
- Do very little else- as few custom rules or overrides as possible.
|
|
97
|
+
- Some rules are updated to work with nextjs.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright Inrupt Inc.
|
|
3
|
+
//
|
|
4
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
// of this software and associated documentation files (the "Software"), to deal in
|
|
6
|
+
// the Software without restriction, including without limitation the rights to use,
|
|
7
|
+
// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
8
|
+
// Software, and to permit persons to whom the Software is furnished to do so,
|
|
9
|
+
// subject to the following conditions:
|
|
10
|
+
//
|
|
11
|
+
// The above copyright notice and this permission notice shall be included in
|
|
12
|
+
// all copies or substantial portions of the Software.
|
|
13
|
+
//
|
|
14
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
15
|
+
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
16
|
+
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
17
|
+
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
18
|
+
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
19
|
+
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
|
+
//
|
|
21
|
+
|
|
22
|
+
module.exports = {
|
|
23
|
+
extends: ["airbnb", "airbnb/hooks", "@inrupt/eslint-config-base"],
|
|
24
|
+
|
|
25
|
+
plugins: ["react"],
|
|
26
|
+
|
|
27
|
+
parser: "@babel/eslint-parser",
|
|
28
|
+
|
|
29
|
+
parserOptions: {
|
|
30
|
+
ecmaFeatures: { jsx: true },
|
|
31
|
+
ecmaVersion: 2018,
|
|
32
|
+
sourceType: "module",
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
settings: {
|
|
36
|
+
"import/resolver": {
|
|
37
|
+
node: {
|
|
38
|
+
extensions: [".js", ".jsx"],
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
rules: {
|
|
44
|
+
// Disable the jsx-one-expression-per-line rule, which makes it a pain to handle spaces and
|
|
45
|
+
// inline elements like em
|
|
46
|
+
"react/jsx-one-expression-per-line": ["off"],
|
|
47
|
+
|
|
48
|
+
"react/jsx-filename-extension": ["warn", { extensions: [".jsx"] }],
|
|
49
|
+
|
|
50
|
+
// Order the properties of react components nicely
|
|
51
|
+
"react/static-property-placement": ["error", "static public field"],
|
|
52
|
+
|
|
53
|
+
// Allow Nextjs <Link> tags to contain a href attribute
|
|
54
|
+
"jsx-a11y/anchor-is-valid": [
|
|
55
|
+
"error",
|
|
56
|
+
{
|
|
57
|
+
components: ["Link"],
|
|
58
|
+
specialLink: ["hrefLeft", "hrefRight"],
|
|
59
|
+
aspects: ["invalidHref", "preferButton"],
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
|
|
63
|
+
"import/extensions": [
|
|
64
|
+
"error",
|
|
65
|
+
{
|
|
66
|
+
js: "never",
|
|
67
|
+
jsx: "never",
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
|
|
71
|
+
"no-use-before-define": ["warn"],
|
|
72
|
+
|
|
73
|
+
"react/react-in-jsx-scope": ["off"],
|
|
74
|
+
},
|
|
75
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@inrupt/eslint-config-react",
|
|
3
|
+
"description": "Shared eslint config for React projects at @inrupt",
|
|
4
|
+
"version": "2.4.0",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"main": "index.js",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/inrupt/typescript-sdk-tools.git"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"eslint",
|
|
15
|
+
"react",
|
|
16
|
+
"inrupt"
|
|
17
|
+
],
|
|
18
|
+
"author": "Inrupt <engineering@inrupt.com>",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/inrupt/typescript-sdk-tools/issues"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/inrupt/typescript-sdk-tools/tree/main/eslint-configs/eslint-config-react#readme",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@babel/eslint-parser": "^7.22.15",
|
|
26
|
+
"@inrupt/eslint-config-base": "file:../eslint-config-base",
|
|
27
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
28
|
+
"eslint-plugin-jsx-a11y": "^6.2.3",
|
|
29
|
+
"eslint-plugin-react": "^7.33.2",
|
|
30
|
+
"eslint-plugin-react-hooks": "^4.6.0"
|
|
31
|
+
}
|
|
32
|
+
}
|
package/lerna.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fixedwidthtable/fixedwidthtable",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"description": "Meta-package for tools used whilst developing the fixedwidthtable SDK",
|
|
4
|
+
"version": "0.0.3",
|
|
5
|
+
"private": false,
|
|
6
|
+
"type": "commonjs",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "lerna run build",
|
|
9
|
+
"clean": "lerna run clean",
|
|
10
|
+
"release": "scripts/release.sh",
|
|
11
|
+
"test": "playwright test",
|
|
12
|
+
"e2e:test:setup": "cd ./e2e/browser/test-app && npm ci",
|
|
13
|
+
"prepare-release": "scripts/prepare-release.sh",
|
|
14
|
+
"lint": "npm run lint:check",
|
|
15
|
+
"lint:check": "npm run lint:eslint && npm run lint:prettier -- --check",
|
|
16
|
+
"lint:eslint": "eslint --config .eslintrc.js \"packages/\" \"e2e/\" \"eslint-configs/\"",
|
|
17
|
+
"lint:prettier": "prettier \"{src,e2e,examples}/**/*.{ts,tsx,js,jsx,css}\" \"**/*.{md,mdx,yml}\"",
|
|
18
|
+
"lint:fix": "npm run lint:eslint -- --fix && npm run lint:prettier -- --write",
|
|
19
|
+
"preinstall": "node scripts/index.js"
|
|
20
|
+
},
|
|
21
|
+
"workspaces": [
|
|
22
|
+
"eslint-configs/*",
|
|
23
|
+
"packages/*"
|
|
24
|
+
],
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/inrupt/typescript-sdk-tools.git"
|
|
28
|
+
},
|
|
29
|
+
"author": "Inrupt <engineering@inrupt.com>",
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"bugs": {
|
|
32
|
+
"url": "https://github.com/inrupt/typescript-sdk-tools/issues"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/inrupt/typescript-sdk-tools#readme",
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@inrupt/eslint-config-lib": "^2.1.1",
|
|
37
|
+
"lerna": "^7.2.0",
|
|
38
|
+
"rimraf": "^5.0.1",
|
|
39
|
+
"rollup": "^3.29.1",
|
|
40
|
+
"rollup-plugin-typescript2": "^0.35.0",
|
|
41
|
+
"typescript": "^5.2.2"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@rushstack/eslint-patch": "^1.3.3",
|
|
45
|
+
"@types/react": "^18.2.21",
|
|
46
|
+
"next": "^13.4.19"
|
|
47
|
+
}
|
|
6
48
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# @inrupt/base-rollup-config
|
|
2
|
+
|
|
3
|
+
This package contains the base configuration for rollup across our packages
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
1. `npm install --save-dev @inrupt/base-rollup-config`
|
|
8
|
+
|
|
9
|
+
## Usage:
|
|
10
|
+
|
|
11
|
+
Can be used in rollup.config.mjs as follows:
|
|
12
|
+
|
|
13
|
+
```mjs
|
|
14
|
+
import { createRequire } from "node:module";
|
|
15
|
+
import createConfig from "@inrupt/base-rollup-config";
|
|
16
|
+
const require = createRequire(import.meta.url);
|
|
17
|
+
|
|
18
|
+
export default createConfig(require("./package.json"));
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Make sure to specify `main` (cjs), `module` (esm) and `types` entrypoints in the package.json as rollup uses
|
|
22
|
+
these entries to determine where to write the output.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright Inrupt Inc.
|
|
3
|
+
//
|
|
4
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
// of this software and associated documentation files (the "Software"), to deal in
|
|
6
|
+
// the Software without restriction, including without limitation the rights to use,
|
|
7
|
+
// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
8
|
+
// Software, and to permit persons to whom the Software is furnished to do so,
|
|
9
|
+
// subject to the following conditions:
|
|
10
|
+
//
|
|
11
|
+
// The above copyright notice and this permission notice shall be included in
|
|
12
|
+
// all copies or substantial portions of the Software.
|
|
13
|
+
//
|
|
14
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
15
|
+
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
16
|
+
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
17
|
+
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
18
|
+
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
19
|
+
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
|
+
//
|
|
21
|
+
import typescript from "rollup-plugin-typescript2";
|
|
22
|
+
import { createRequire } from "node:module";
|
|
23
|
+
const require = createRequire(import.meta.url);
|
|
24
|
+
|
|
25
|
+
export const createSharedConfig = pkg => ({
|
|
26
|
+
plugins: [
|
|
27
|
+
typescript({
|
|
28
|
+
// Use our own version of TypeScript, rather than the one bundled with the plugin:
|
|
29
|
+
typescript: require("typescript"),
|
|
30
|
+
tsconfigOverride: {
|
|
31
|
+
compilerOptions: {
|
|
32
|
+
module: "esnext",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
}),
|
|
36
|
+
],
|
|
37
|
+
external: Object.keys(pkg.dependencies),
|
|
38
|
+
// The following option is useful because symlinks are used in monorepos
|
|
39
|
+
preserveSymlinks: true,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export default pkg => [
|
|
43
|
+
{
|
|
44
|
+
input: "./src/index.ts",
|
|
45
|
+
output: [
|
|
46
|
+
{
|
|
47
|
+
file: pkg.module,
|
|
48
|
+
format: "esm",
|
|
49
|
+
sourcemap: true,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
file: pkg.main,
|
|
53
|
+
format: "cjs",
|
|
54
|
+
sourcemap: true,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
...createSharedConfig(pkg),
|
|
58
|
+
},
|
|
59
|
+
];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@inrupt/base-rollup-config",
|
|
3
|
+
"version": "2.4.0",
|
|
4
|
+
"description": "This package provides a shared rollup config for our packages",
|
|
5
|
+
"main": "index.mjs",
|
|
6
|
+
"module": "true",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/inrupt/typescript-sdk-tools.git"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"inrupt",
|
|
16
|
+
"rollup",
|
|
17
|
+
"bundler"
|
|
18
|
+
],
|
|
19
|
+
"author": "Inrupt <engineering@inrupt.com>",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/inrupt/typescript-sdk-tools/issues"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/inrupt/typescript-sdk-tools#readme"
|
|
25
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# @inrupt/internal-playwright-helpers
|
|
2
|
+
|
|
3
|
+
This package contains utilities to help setup automated testing environments.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
1. `npm install --save-dev @inrupt/internal-playwright-helpers`
|
|
8
|
+
|
|
9
|
+
## Usage:
|
|
10
|
+
|
|
11
|
+
Add the function import as needed.
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
import { loginAndAllow } from "@inrupt/internal-playwright-helpers"
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Then add in calls to the functions such as `loginAndAllow` to your test files.
|
|
18
|
+
|
|
19
|
+
For these helpers to work, your app should use predefined testids defined in
|
|
20
|
+
`@@inrupt/internal-playwright-testids`. The following testids are expected in the
|
|
21
|
+
exposed helpers:
|
|
22
|
+
|
|
23
|
+
- The OpenID provider should be specified in a text input identified with
|
|
24
|
+
`TESTID_OPENID_PROVIDER_INPUT`.
|
|
25
|
+
- The login should be initiated by clicking a button identified with
|
|
26
|
+
`TESTID_LOGIN_BUTTON`.
|
|
27
|
+
- When the login process is complete, an element identified with
|
|
28
|
+
`TESTID_SESSION_STATUS` should appear in the DOM.
|
|
29
|
+
- When an error occurs, an element identified with `TESTID_ERROR_MESSAGE` should
|
|
30
|
+
appear in the DOM.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@inrupt/internal-playwright-helpers",
|
|
3
|
+
"version": "2.4.0",
|
|
4
|
+
"description": "This package provides page models for known common elements of the sdk testable UIs",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.es.js",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "rollup -c rollup.config.mjs",
|
|
12
|
+
"clean": "rimraf dist"
|
|
13
|
+
},
|
|
14
|
+
"author": "Inrupt <devtools-team@inrupt.com>",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"require": "./dist/index.js",
|
|
19
|
+
"import": "./dist/index.mjs"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@inrupt/internal-playwright-testids": "2.4.0",
|
|
24
|
+
"@inrupt/internal-test-env": "2.4.0"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@playwright/test": "^1.37.0"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// The following is only possible from Node 18 onwards
|
|
2
|
+
// import pkg from "./package.json" assert { type: "json" };
|
|
3
|
+
|
|
4
|
+
// Until we only support Node 18+, this should be used instead
|
|
5
|
+
// (see https://rollupjs.org/guide/en/#importing-packagejson)
|
|
6
|
+
import { createRequire } from "node:module";
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
const pkg = require("./package.json");
|
|
9
|
+
|
|
10
|
+
import typescript from "rollup-plugin-typescript2";
|
|
11
|
+
|
|
12
|
+
const external = [
|
|
13
|
+
...Object.keys(pkg.dependencies || {}),
|
|
14
|
+
...Object.keys(pkg.peerDependencies || {}),
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
const plugins = [
|
|
18
|
+
typescript({
|
|
19
|
+
// Use our own version of TypeScript, rather than the one bundled with the plugin:
|
|
20
|
+
typescript: require("typescript"),
|
|
21
|
+
tsconfigOverride: {
|
|
22
|
+
compilerOptions: {
|
|
23
|
+
module: "esnext",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
const rollupDefaultConfig = { external, plugins };
|
|
30
|
+
|
|
31
|
+
export default [
|
|
32
|
+
{
|
|
33
|
+
...rollupDefaultConfig,
|
|
34
|
+
input: "src/index.ts",
|
|
35
|
+
output: [
|
|
36
|
+
{
|
|
37
|
+
file: pkg.main,
|
|
38
|
+
format: "cjs",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
file: pkg.module,
|
|
42
|
+
entryFileNames: "[name].es.js",
|
|
43
|
+
format: "esm",
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
...rollupDefaultConfig,
|
|
49
|
+
input: ["src/index.ts"],
|
|
50
|
+
output: {
|
|
51
|
+
dir: "dist",
|
|
52
|
+
entryFileNames: "[name].mjs",
|
|
53
|
+
format: "esm",
|
|
54
|
+
preserveModules: true,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
];
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright Inrupt Inc.
|
|
3
|
+
//
|
|
4
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
// of this software and associated documentation files (the "Software"), to deal in
|
|
6
|
+
// the Software without restriction, including without limitation the rights to use,
|
|
7
|
+
// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
8
|
+
// Software, and to permit persons to whom the Software is furnished to do so,
|
|
9
|
+
// subject to the following conditions:
|
|
10
|
+
//
|
|
11
|
+
// The above copyright notice and this permission notice shall be included in
|
|
12
|
+
// all copies or substantial portions of the Software.
|
|
13
|
+
//
|
|
14
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
15
|
+
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
16
|
+
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
17
|
+
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
18
|
+
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
19
|
+
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
|
+
//
|
|
21
|
+
import { test as base } from "@playwright/test";
|
|
22
|
+
import { getBrowserTestingEnvironment } from "@inrupt/internal-test-env";
|
|
23
|
+
import { AuthFlow } from "./flows/auth";
|
|
24
|
+
|
|
25
|
+
export type AuthFixture = {
|
|
26
|
+
auth: AuthFlow;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const test = base.extend<AuthFixture>({
|
|
30
|
+
// Override the page fixture to start the app automatically
|
|
31
|
+
page: async ({ page }, use) => {
|
|
32
|
+
await page.goto("/");
|
|
33
|
+
await use(page);
|
|
34
|
+
},
|
|
35
|
+
auth: async ({ page }, use) => {
|
|
36
|
+
const { idp, clientCredentials } = getBrowserTestingEnvironment({
|
|
37
|
+
clientCredentials: {
|
|
38
|
+
owner: { login: true, password: true },
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
const auth = new AuthFlow(
|
|
42
|
+
page,
|
|
43
|
+
idp,
|
|
44
|
+
clientCredentials.owner.login,
|
|
45
|
+
clientCredentials.owner.password,
|
|
46
|
+
);
|
|
47
|
+
await use(auth);
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export { expect } from "@playwright/test";
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright Inrupt Inc.
|
|
3
|
+
//
|
|
4
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
// of this software and associated documentation files (the "Software"), to deal in
|
|
6
|
+
// the Software without restriction, including without limitation the rights to use,
|
|
7
|
+
// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
8
|
+
// Software, and to permit persons to whom the Software is furnished to do so,
|
|
9
|
+
// subject to the following conditions:
|
|
10
|
+
//
|
|
11
|
+
// The above copyright notice and this permission notice shall be included in
|
|
12
|
+
// all copies or substantial portions of the Software.
|
|
13
|
+
//
|
|
14
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
15
|
+
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
16
|
+
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
17
|
+
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
18
|
+
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
19
|
+
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
|
+
//
|
|
21
|
+
|
|
22
|
+
import type { Page } from "@playwright/test";
|
|
23
|
+
import { CognitoPage } from "../pages/cognito";
|
|
24
|
+
import { OpenIdPage } from "../pages/open-id";
|
|
25
|
+
import { TestPage } from "../pages/testPage";
|
|
26
|
+
|
|
27
|
+
export class AuthFlow {
|
|
28
|
+
page: Page;
|
|
29
|
+
|
|
30
|
+
openidProvider: string;
|
|
31
|
+
|
|
32
|
+
userLogin: string;
|
|
33
|
+
|
|
34
|
+
password: string;
|
|
35
|
+
|
|
36
|
+
constructor(
|
|
37
|
+
page: Page,
|
|
38
|
+
openidProvider: string,
|
|
39
|
+
userLogin: string,
|
|
40
|
+
password: string,
|
|
41
|
+
) {
|
|
42
|
+
this.page = page;
|
|
43
|
+
this.openidProvider = openidProvider;
|
|
44
|
+
this.userLogin = userLogin;
|
|
45
|
+
this.password = password;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Start the app, and if applicable initiate login from the client, get redirected
|
|
50
|
+
* to the OpenID provider, log in, allow the client when redirected to the broker,
|
|
51
|
+
* and completes login after being redirected to client.
|
|
52
|
+
*/
|
|
53
|
+
async login(
|
|
54
|
+
options: { allow: boolean; timeout?: number } = { allow: true },
|
|
55
|
+
): Promise<void> {
|
|
56
|
+
const timeoutOptions = { timeout: options.timeout ?? 15_000 };
|
|
57
|
+
const testPage = new TestPage(this.page, this.openidProvider);
|
|
58
|
+
const cognitoPage = new CognitoPage(this.page);
|
|
59
|
+
const openIdPage = new OpenIdPage(this.page);
|
|
60
|
+
// First, initiate login in the test client, and wait for the redirect to the OP
|
|
61
|
+
await Promise.all([
|
|
62
|
+
this.page.waitForURL(
|
|
63
|
+
(url) =>
|
|
64
|
+
// If the user is already authenticated to the OpenID Provider, they may be redirected directly to the broker
|
|
65
|
+
CognitoPage.isOnPage(url) || OpenIdPage.isOnPage(url),
|
|
66
|
+
timeoutOptions,
|
|
67
|
+
),
|
|
68
|
+
testPage.startLogin(timeoutOptions),
|
|
69
|
+
]);
|
|
70
|
+
if (CognitoPage.isOnPage(new URL(this.page.url()))) {
|
|
71
|
+
await Promise.all([
|
|
72
|
+
this.page.waitForURL(
|
|
73
|
+
(url: URL) =>
|
|
74
|
+
// After login, the user is redirected either to the broker or to the client.
|
|
75
|
+
OpenIdPage.isOnPage(url) || TestPage.isOnPage(url),
|
|
76
|
+
timeoutOptions,
|
|
77
|
+
),
|
|
78
|
+
cognitoPage.login(this.userLogin, this.password, timeoutOptions),
|
|
79
|
+
]);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Clicking on the consent screen from the broker will redirect to the
|
|
83
|
+
// test page, and trigger the token request. To prevent this being a
|
|
84
|
+
// race condition, waiting on this request should be done prior to
|
|
85
|
+
// giving consent.
|
|
86
|
+
const completeLoginConditions = [testPage.handleRedirect()];
|
|
87
|
+
// TODO: handle allow === false
|
|
88
|
+
if (options.allow && OpenIdPage.isOnPage(new URL(this.page.url()))) {
|
|
89
|
+
completeLoginConditions.push(openIdPage.allow(timeoutOptions));
|
|
90
|
+
}
|
|
91
|
+
await Promise.all(completeLoginConditions);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright Inrupt Inc.
|
|
3
|
+
//
|
|
4
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
// of this software and associated documentation files (the "Software"), to deal in
|
|
6
|
+
// the Software without restriction, including without limitation the rights to use,
|
|
7
|
+
// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
|
8
|
+
// Software, and to permit persons to whom the Software is furnished to do so,
|
|
9
|
+
// subject to the following conditions:
|
|
10
|
+
//
|
|
11
|
+
// The above copyright notice and this permission notice shall be included in
|
|
12
|
+
// all copies or substantial portions of the Software.
|
|
13
|
+
//
|
|
14
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
15
|
+
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
16
|
+
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
17
|
+
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
18
|
+
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
19
|
+
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
20
|
+
//
|
|
21
|
+
|
|
22
|
+
export { CognitoPage } from "./pages/cognito";
|
|
23
|
+
export { OpenIdPage } from "./pages/open-id";
|
|
24
|
+
export { TestPage } from "./pages/testPage";
|
|
25
|
+
export { AuthFlow } from "./flows/auth";
|
|
26
|
+
export { test, expect } from "./fixtures";
|