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

web: provide a test framework #9681

Merged
merged 57 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
3146e5a
web: fix esbuild issue with style sheets
kensternberg-authentik Mar 8, 2024
fe52f44
Merge branch 'main' into dev
kensternberg-authentik Mar 11, 2024
e505f27
Merge branch 'main' into dev
kensternberg-authentik Mar 11, 2024
5090621
Merge branch 'main' into dev
kensternberg-authentik Mar 11, 2024
035bda4
Merge branch 'main' into dev
kensternberg-authentik Mar 12, 2024
2d0117d
Merge branch 'main' into dev
kensternberg-authentik Mar 13, 2024
22cb5b7
Merge branch 'main' into dev
kensternberg-authentik Mar 14, 2024
8b4e036
Merge branch 'main' into dev
kensternberg-authentik Mar 14, 2024
db96e1a
Merge branch 'main' into dev
kensternberg-authentik Mar 18, 2024
8946b81
Merge branch 'main' into dev
kensternberg-authentik Mar 19, 2024
30beca9
Merge branch 'main' into dev
kensternberg-authentik Mar 19, 2024
5d84082
Merge branch 'main' into dev
kensternberg-authentik Mar 20, 2024
a7e3dca
Merge branch 'main' into dev
kensternberg-authentik Mar 21, 2024
2d254d6
Merge branch 'main' into dev
kensternberg-authentik Mar 25, 2024
3f95020
Merge branch 'main' into dev
kensternberg-authentik Mar 26, 2024
a056703
Merge branch 'main' into dev
kensternberg-authentik Mar 27, 2024
fc00bde
Merge branch 'main' into dev
kensternberg-authentik Mar 29, 2024
7123b2c
Merge branch 'main' into dev
kensternberg-authentik Mar 29, 2024
5d4c380
Merge branch 'main' into dev
kensternberg-authentik Apr 1, 2024
66cefcc
Merge branch 'main' into dev
kensternberg-authentik Apr 2, 2024
875fc5c
Merge branch 'main' into dev
kensternberg-authentik Apr 4, 2024
c84be1d
Merge branch 'main' into dev
kensternberg-authentik Apr 8, 2024
b08dcc2
Merge branch 'main' into dev
kensternberg-authentik Apr 9, 2024
272fdc5
Merge branch 'main' into dev
kensternberg-authentik Apr 10, 2024
23665d1
Merge branch 'main' into dev
kensternberg-authentik Apr 10, 2024
cacdf64
Merge branch 'main' into dev
kensternberg-authentik Apr 11, 2024
085debf
Merge branch 'main' into dev
kensternberg-authentik Apr 12, 2024
f19ed14
Merge branch 'main' into dev
kensternberg-authentik Apr 16, 2024
ac4ba5d
Merge branch 'main' into dev
kensternberg-authentik Apr 17, 2024
98503f6
Merge branch 'main' into dev
kensternberg-authentik Apr 18, 2024
2d94b16
Merge branch 'main' into dev
kensternberg-authentik Apr 22, 2024
34de6bf
Merge branch 'main' into dev
kensternberg-authentik Apr 24, 2024
ca42506
Merge branch 'main' into dev
kensternberg-authentik Apr 25, 2024
2a96900
Merge branch 'main' into dev
kensternberg-authentik May 2, 2024
9acebec
Merge branch 'main' into dev
kensternberg-authentik May 3, 2024
8248163
Merge branch 'main' into dev
kensternberg-authentik May 3, 2024
ee37e92
Merge branch 'main' into dev
kensternberg-authentik May 7, 2024
e1d565d
Merge branch 'main' into dev
kensternberg-authentik May 8, 2024
3d532d4
Merge branch 'main' into dev
kensternberg-authentik May 9, 2024
fffc8c7
Merge branch 'main' into dev
kensternberg-authentik May 10, 2024
61717b1
web: provide a test framework
kensternberg-authentik May 10, 2024
ac8ecf1
Rolling back a reversion.
kensternberg-authentik May 10, 2024
3fae9e5
Merge branch 'main' into dev
kensternberg-authentik May 13, 2024
9133ab6
Merge branch 'dev' into web/automated-testing
kensternberg-authentik May 13, 2024
41c362e
Adjusting paths to work with tests.
kensternberg-authentik May 15, 2024
fbec633
add ci to test
BeryJu May 18, 2024
396d55c
Merge branch 'main' into web/automated-testing
BeryJu May 24, 2024
86994e6
Merge branch 'main' into web/automated-testing
kensternberg-authentik Jun 13, 2024
0f46f75
web: patch spotlight on the fly to fix syntax issue that blocked stor…
kensternberg-authentik Jun 13, 2024
1ec97e7
Merge branch 'main' into web/automated-testing
kensternberg-authentik Jun 17, 2024
6ceb187
Somehow missed these in the merge.
kensternberg-authentik Jun 17, 2024
3b7067e
Merge branch 'main' into web/automated-testing
kensternberg-authentik Jun 18, 2024
ea71d41
Merge missed something.
kensternberg-authentik Jun 18, 2024
cc2cf47
Merge branch 'main' into web/automated-testing
kensternberg-authentik Jun 26, 2024
9126943
Fixed an issue where npm install and npm ci had different shell scrip…
kensternberg-authentik Jun 26, 2024
179fc13
Merge branch 'main' into web/automated-testing
kensternberg-authentik Jun 26, 2024
abc0d46
Removed debugging messages.
kensternberg-authentik Jun 27, 2024
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
18 changes: 18 additions & 0 deletions .github/workflows/ci-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,21 @@ jobs:
- name: build
working-directory: web/
run: npm run build
test:
needs:
- ci-web-mark
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: web/package.json
cache: "npm"
cache-dependency-path: web/package-lock.json
- working-directory: web/
run: npm ci
- name: Generate API
run: make gen-client-ts
- name: test
working-directory: web/
run: npm run test
24,619 changes: 14,784 additions & 9,835 deletions web/package-lock.json

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"lint:precommit": "bun scripts/eslint-precommit.mjs",
"lint:spelling": "node scripts/check-spelling.mjs",
"lit-analyse": "lit-analyzer src",
"postinstall": "bash scripts/patch-spotlight.sh",
"precommit": "npm-run-all --parallel tsc lit-analyse lint:spelling --sequential lint:precommit prettier",
"prequick": "run-s tsc:execute lit-analyse lint:precommit lint:spelling",
"prettier-check": "prettier --check .",
Expand All @@ -27,7 +28,10 @@
"tsc": "run-s build-locales tsc:execute",
"storybook": "storybook dev -p 6006",
"storybook:build": "cross-env NODE_OPTIONS='--max_old_space_size=8192' storybook build",
"storybook:build-import-map": "node scripts/build-storybook-import-maps.mjs"
"storybook:build-import-map": "node scripts/build-storybook-import-maps.mjs",
"test": "npx wdio run ./wdio.conf.ts --logLevel=warn --autoCompileOpts.tsNodeOpts.project=tsconfig.test.json",
"test-view": "npx wdio run ./wdio.conf.ts --autoCompileOpts.tsNodeOpts.project=tsconfig.test.json",
"test-watch": "npx wdio run ./wdio.conf.ts --autoCompileOpts.tsNodeOpts.project=tsconfig.test.json --watch"
},
"dependencies": {
"@codemirror/lang-html": "^6.4.9",
Expand Down Expand Up @@ -96,6 +100,10 @@
"@types/showdown": "^2.0.6",
"@typescript-eslint/eslint-plugin": "^7.14.0",
"@typescript-eslint/parser": "^7.14.0",
"@wdio/browser-runner": "^8.36.1",
"@wdio/cli": "^8.36.1",
"@wdio/mocha-framework": "^8.36.1",
"@wdio/spec-reporter": "^8.36.1",
"babel-plugin-macros": "^3.1.0",
"babel-plugin-tsconfig-paths": "^1.0.3",
"chokidar": "^3.6.0",
Expand All @@ -120,10 +128,12 @@
"storybook": "^8.1.10",
"storybook-addon-mock": "^5.0.0",
"ts-lit-plugin": "^2.0.2",
"ts-node": "^10.9.2",
"tslib": "^2.6.3",
"turnstile-types": "^1.2.1",
"typescript": "^5.5.2",
"vite-tsconfig-paths": "^4.3.2"
"vite-tsconfig-paths": "^4.3.2",
"wdio-wait-for": "^3.0.11"
},
"optionalDependencies": {
"@esbuild/darwin-arm64": "^0.21.4",
Expand Down
26 changes: 26 additions & 0 deletions web/scripts/patch-spotlight.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

TARGET=$(find "./node_modules/@spotlightjs/overlay/dist/" -name "index-[0-9a-f]*.js");

if ! grep -GL 'QX2 = ' "$TARGET" > /dev/null ; then
patch --forward --no-backup-if-mismatch -p0 "$TARGET" <<EOF
--- a/index-5682ce90.js 2024-06-13 16:19:28
+++ b/index-5682ce90.js 2024-06-13 16:20:23
@@ -4958,11 +4958,10 @@
}
);
}
-const q2 = w.lazy(() => import("./main-3257b7fc.js").then((n) => n.m));
+const q2 = w.lazy(() => import("./main-3257b7fc.js").then((n) => n.m)), QX2 = () => {};
function Gp({
data: n,
- onUpdateData: a = () => {
- },
+ onUpdateData: a = QX2,
editingEnabled: s = !1,
clipboardEnabled: o = !1,
displayDataTypes: c = !1,
EOF
else
echo "spotlight overlay.js patch already applied"
fi
63 changes: 63 additions & 0 deletions web/src/elements/EmptyState.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { ensureCSSStyleSheet } from "@goauthentik/elements/utils/ensureCSSStyleSheet.js";
import { $, expect } from "@wdio/globals";

import { msg } from "@lit/localize";
import { TemplateResult, html, render as litRender } from "lit";

import AKGlobal from "@goauthentik/common/styles/authentik.css";
import PFBase from "@patternfly/patternfly/patternfly-base.css";

import "./EmptyState.js";

const render = (body: TemplateResult) => {
document.adoptedStyleSheets = [
...document.adoptedStyleSheets,
ensureCSSStyleSheet(PFBase),
ensureCSSStyleSheet(AKGlobal),
];
return litRender(body, document.body);
};

describe("ak-empty-state", () => {
it("should render the default loader", async () => {
render(html`<ak-empty-state ?loading=${true} header=${msg("Loading")}> </ak-empty-state>`);

const empty = await $("ak-empty-state").$(">>>.pf-c-empty-state__icon");
await expect(empty).toExist();

const header = await $("ak-empty-state").$(">>>.pf-c-title");
await expect(header).toHaveText("Loading");
});

it("should handle standard boolean", async () => {
render(html`<ak-empty-state loading header=${msg("Loading")}> </ak-empty-state>`);

const empty = await $("ak-empty-state").$(">>>.pf-c-empty-state__icon");
await expect(empty).toExist();

const header = await $("ak-empty-state").$(">>>.pf-c-title");
await expect(header).toHaveText("Loading");
});

it("should render a static empty state", async () => {
render(html`<ak-empty-state header=${msg("No messages found")}> </ak-empty-state>`);

const empty = await $("ak-empty-state").$(">>>.pf-c-empty-state__icon");
await expect(empty).toExist();
await expect(empty).toHaveClass("fa-question-circle");

const header = await $("ak-empty-state").$(">>>.pf-c-title");
await expect(header).toHaveText("No messages found");
});

it("should render a slotted message", async () => {
render(
html`<ak-empty-state header=${msg("No messages found")}>
<p slot="body">Try again with a different filter</p>
</ak-empty-state>`,
);

const message = await $("ak-empty-state").$(">>>.pf-c-empty-state__body").$(">>>p");
await expect(message).toHaveText("Try again with a different filter");
});
});
20 changes: 10 additions & 10 deletions web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
"extends": "./tsconfig.base.json",
"compilerOptions": {
"paths": {
"@goauthentik/admin/*": ["src/admin/*"],
"@goauthentik/common/*": ["src/common/*"],
"@goauthentik/components/*": ["src/components/*"],
"@goauthentik/admin/*": ["./src/admin/*"],
"@goauthentik/common/*": ["./src/common/*"],
"@goauthentik/components/*": ["./src/components/*"],
"@goauthentik/docs/*": ["../website/docs/*"],
"@goauthentik/elements/*": ["src/elements/*"],
"@goauthentik/flow/*": ["src/flow/*"],
"@goauthentik/locales/*": ["src/locales/*"],
"@goauthentik/polyfill/*": ["src/polyfill/*"],
"@goauthentik/standalone/*": ["src/standalone/*"],
"@goauthentik/user/*": ["src/user/*"]
},
"@goauthentik/elements/*": ["./src/elements/*"],
"@goauthentik/flow/*": ["./src/flow/*"],
"@goauthentik/locales/*": ["./src/locales/*"],
"@goauthentik/polyfill/*": ["./src/polyfill/*"],
"@goauthentik/standalone/*": ["./src/standalone/*"],
"@goauthentik/user/*": ["./src/user/*"]
}
}
}
34 changes: 34 additions & 0 deletions web/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"compilerOptions": {
"baseUrl": ".",
"types": ["node", "webdriverio/async", "@wdio/cucumber-framework", "expect-webdriverio"],
"target": "esnext",
"forceConsistentCasingInFileNames": true,
"experimentalDecorators": true,
"lib": [
"ES5",
"ES2015",
"ES2016",
"ES2017",
"ES2018",
"ES2019",
"ES2020",
"ESNext",
"DOM",
"DOM.Iterable",
"WebWorker"
],
"paths": {
"@goauthentik/admin/*": ["./src/admin/*"],
"@goauthentik/common/*": ["./src/common/*"],
"@goauthentik/components/*": ["./src/components/*"],
"@goauthentik/docs/*": ["../website/docs/*"],
"@goauthentik/elements/*": ["./src/elements/*"],
"@goauthentik/flow/*": ["./src/flow/*"],
"@goauthentik/locales/*": ["./src/locales/*"],
"@goauthentik/polyfill/*": ["./src/polyfill/*"],
"@goauthentik/standalone/*": ["./src/standalone/*"],
"@goauthentik/user/*": ["./src/user/*"]
}
}
}
Loading
Loading