Compare commits

...

8 Commits

Author SHA1 Message Date
1c9e4652f9 Updating version required by SFE. 2024-09-30 09:35:59 -07:00
079ed7bf4c Merge branch 'main' into web/bug/fix-wdio-and-lint
* main:
  core: bump goauthentik.io/api/v3 from 3.2024082.1 to 3.2024083.1 (#11555)
  website: bump @types/react from 18.3.9 to 18.3.10 in /website (#11556)
  core: bump watchdog from 5.0.2 to 5.0.3 (#11557)
  core: bump uvicorn from 0.30.6 to 0.31.0 (#11558)
  core: bump psycopg from 3.2.2 to 3.2.3 (#11559)
  web: bump the storybook group across 1 directory with 7 updates (#11560)
  web: bump the rollup group across 2 directories with 4 updates (#11561)
  web: bump the wdio group across 2 directories with 5 updates (#11562)
  web: bump chromedriver from 129.0.0 to 129.0.1 in /tests/wdio (#11563)
  web: bump @types/node from 22.7.3 to 22.7.4 in /web (#11564)
  web: bump rapidoc from 9.3.6 to 9.3.7 in /web (#11565)
  web: bump knip from 5.30.5 to 5.30.6 in /web (#11566)
  website/docs: update wording for events that occur when too many users exist (#11547)
2024-09-30 08:52:42 -07:00
430278712f Merge branch 'main' into web/bug/fix-wdio-and-lint
* main:
  providers/oauth2: improve indexes on tokens (#11543)
  web: bump API Client version (#11544)
  release: 2024.8.3 (#11542)
2024-09-27 08:48:54 -07:00
2aad79b5db Forgot to run prettier. 2024-09-27 08:45:11 -07:00
0fcf1ebf94 web: small fixes for wdio and lint
**PLEASE** Stop trying to upgrade WebdriverIO following Dependabot's instructions. The changes
between wdio8 and wdio9 are extensive enough to require a lot more manual intervention. The unit
tests fail in wdio 9, with the testbed driver Wdio uses to compile content to push to the browser
([vite](https://vitejs.dev) complaining:

```
2024-09-27T15:30:03.672Z WARN @wdio/browser-runner:vite: warning: Unrecognized default export in file /Users/ken/projects/dev/web/node_modules/@patternfly/patternfly/components/Dropdown/dropdown.css
  Plugin: postcss-lit
  File: /Users/ken/projects/dev/web/node_modules/@patternfly/patternfly/components/Dropdown/dropdown.css
[0-6] 2024-09-27T15:30:04.083Z INFO webdriver: BIDI COMMAND script.callFunction {"functionDeclaration":"<Function[976 bytes]>","awaitPromise":true,"arguments":[],"target":{"context":"8E608E6D13E355DFFC28112C236B73AF"}}
[0-6]  Error:  Test failed due to following error(s):
  - ak-search-select.test.ts: The requested module '/src/common/styles/authentik.css' does not provide an export named 'default': SyntaxError: The requested module '/src/common/styles/authentik.css' does not provide an export named 'default'

```

So until we can figure out why the Vite installation isn't liking our CSS import scheme, we'll
have to soldier on with what we have.  At least with Wdio 8, we get:

```
Spec Files:      7 passed, 7 total (100% completed) in 00:00:19
```
2024-09-27 08:42:22 -07:00
ed7c1b9b3e package-lock.json update 2024-09-27 07:52:45 -07:00
e71e875056 Merge branch 'main' into web/bug/fix-wdio-and-lint
* main:
  website: update release notes for 2024.8.3 and 2024.6.5 (#11541)
  website/docs: added a Docs banner to announce new docs structure (#11525)
  security: fix CVE-2024-47070 (#11536)
  security: fix CVE-2024-47077 (#11535)
  sources/ldap: fix ms_ad userAccountControl not checking for lockout (#11532)
  web: Fix missing integrity fields in package-lock.json (#11509)
  core, web: update translations (#11527)
  core: bump ruff from 0.6.7 to 0.6.8 (#11528)
  web: bump the wdio group across 2 directories with 3 updates (#11529)
  web: bump @patternfly/elements from 4.0.1 to 4.0.2 in /web (#11530)
  web: bump @types/node from 22.7.2 to 22.7.3 in /web (#11531)
2024-09-27 07:50:30 -07:00
705f096e3f web: small fixes for wdio and lint
- Roll back another dependabot breaking change, this time to WebdriverIO
- Remove the redundant scripts wrapping ESLint for Precommit mode. Access to those modes is
  available through the flags to the `./web/scripts/eslint.mjs` script.
- Remove SonarJS checks until SonarJS is ESLint 9 compatible.
- Minor nitpicking.
2024-09-26 14:23:03 -07:00
12 changed files with 2513 additions and 8113 deletions

10391
web/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -75,10 +75,10 @@
"@types/showdown": "^2.0.6",
"@typescript-eslint/eslint-plugin": "^8.7.0",
"@typescript-eslint/parser": "^8.7.0",
"@wdio/browser-runner": "^9.1.2",
"@wdio/cli": "^9.1.2",
"@wdio/mocha-framework": "^9.1.2",
"@wdio/spec-reporter": "^9.1.2",
"@wdio/browser-runner": "^8.40.5",
"@wdio/cli": "^8.40.5",
"@wdio/mocha-framework": "^9.1.0",
"@wdio/spec-reporter": "^9.1.0",
"babel-plugin-macros": "^3.1.0",
"babel-plugin-tsconfig-paths": "^1.0.3",
"chokidar": "^4.0.1",
@ -86,7 +86,6 @@
"esbuild": "^0.24.0",
"eslint": "^9.11.1",
"eslint-plugin-lit": "^1.14.0",
"eslint-plugin-sonarjs": "^2.0.2",
"eslint-plugin-wc": "^2.1.0",
"github-slugger": "^2.0.0",
"glob": "^11.0.0",
@ -330,14 +329,14 @@
"command": "node scripts/build-storybook-import-maps.mjs"
},
"test": {
"command": "wdio run ./wdio.conf.ts --logLevel=warn",
"command": "wdio ./wdio.conf.ts --logLevel=info",
"env": {
"CI": "true",
"TS_NODE_PROJECT": "tsconfig.test.json"
}
},
"test-watch": {
"command": "wdio run ./wdio.conf.ts",
"command": "wdio ./wdio.conf.ts",
"env": {
"TS_NODE_PROJECT": "tsconfig.test.json"
}

View File

@ -1,67 +0,0 @@
import { execFileSync } from "child_process";
import { ESLint } from "eslint";
import path from "path";
import process from "process";
// Code assumes this script is in the './web/scripts' folder.
const projectRoot = execFileSync("git", ["rev-parse", "--show-toplevel"], {
encoding: "utf8",
}).replace("\n", "");
process.chdir(path.join(projectRoot, "./web"));
const eslintConfig = {
fix: true,
overrideConfig: {
env: {
browser: true,
es2021: true,
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:lit/recommended",
"plugin:custom-elements/recommended",
"plugin:storybook/recommended",
"plugin:sonarjs/recommended",
],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 12,
sourceType: "module",
project: true,
},
plugins: ["@typescript-eslint", "lit", "custom-elements", "sonarjs"],
ignorePatterns: ["authentik-live-tests/**", "./.storybook/**/*.ts"],
rules: {
"indent": "off",
"linebreak-style": ["error", "unix"],
"quotes": ["error", "double", { avoidEscape: true }],
"semi": ["error", "always"],
"@typescript-eslint/ban-ts-comment": "off",
"no-unused-vars": "off",
"sonarjs/cognitive-complexity": ["warn", 9],
"sonarjs/no-duplicate-string": "off",
"sonarjs/no-nested-template-literals": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
"no-console": ["error", { allow: ["debug", "warn", "error"] }],
},
},
};
const updated = ["./src/", "./build.mjs", "./scripts/*.mjs"];
const eslint = new ESLint(eslintConfig);
const results = await eslint.lintFiles(updated);
const formatter = await eslint.loadFormatter("stylish");
const resultText = formatter.format(results);
const errors = results.reduce((acc, result) => acc + result.errorCount, 0);
console.log(resultText);
process.exit(errors > 1 ? 1 : 0);

View File

@ -1,94 +0,0 @@
import { execFileSync } from "child_process";
import { ESLint } from "eslint";
import path from "path";
import process from "process";
// Code assumes this script is in the './web/scripts' folder.
const projectRoot = execFileSync("git", ["rev-parse", "--show-toplevel"], {
encoding: "utf8",
}).replace("\n", "");
process.chdir(path.join(projectRoot, "./web"));
const eslintConfig = {
fix: true,
overrideConfig: {
env: {
browser: true,
es2021: true,
},
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:lit/recommended",
"plugin:custom-elements/recommended",
"plugin:storybook/recommended",
"plugin:sonarjs/recommended",
],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 12,
sourceType: "module",
project: true,
},
plugins: ["@typescript-eslint", "lit", "custom-elements", "sonarjs"],
ignorePatterns: ["authentik-live-tests/**", "./.storybook/**/*.ts"],
rules: {
"indent": "off",
"linebreak-style": ["error", "unix"],
"quotes": ["error", "double", { avoidEscape: true }],
"semi": ["error", "always"],
"@typescript-eslint/ban-ts-comment": "off",
"no-unused-vars": "off",
"sonarjs/cognitive-complexity": ["warn", 9],
"sonarjs/no-duplicate-string": "off",
"sonarjs/no-nested-template-literals": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],
"no-console": ["error", { allow: ["debug", "warn", "error"] }],
},
},
};
const porcelainV1 = /^(..)\s+(.*$)/;
const gitStatus = execFileSync("git", ["status", "--porcelain", "."], { encoding: "utf8" });
const statuses = gitStatus.split("\n").reduce((acc, line) => {
const match = porcelainV1.exec(line.replace("\n"));
if (!match) {
return acc;
}
const [status, path] = Array.from(match).slice(1, 3);
return [...acc, [status, path.split("\x00")[0]]];
}, []);
const isModified = /^(M|\?|\s)(M|\?|\s)/;
const modified = (s) => isModified.test(s);
const isCheckable = /\.(ts|js|mjs)$/;
const checkable = (s) => isCheckable.test(s);
const ignored = /\/\.storybook\//;
const notIgnored = (s) => !ignored.test(s);
const updated = statuses.reduce(
(acc, [status, filename]) =>
modified(status) && checkable(filename) && notIgnored(filename)
? [...acc, path.join(projectRoot, filename)]
: acc,
[],
);
const eslint = new ESLint(eslintConfig);
const results = await eslint.lintFiles(updated);
const formatter = await eslint.loadFormatter("stylish");
const resultText = formatter.format(results);
const errors = results.reduce((acc, result) => acc + result.errorCount, 0);
console.log(resultText);
process.exit(errors > 1 ? 1 : 0);

View File

@ -1,7 +1,6 @@
import eslint from "@eslint/js";
import tsparser from "@typescript-eslint/parser";
import litconf from "eslint-plugin-lit";
import sonar from "eslint-plugin-sonarjs";
import wcconf from "eslint-plugin-wc";
import globals from "globals";
import tseslint from "typescript-eslint";
@ -9,7 +8,9 @@ import tseslint from "typescript-eslint";
const MAX_DEPTH = 4;
const MAX_NESTED_CALLBACKS = 4;
const MAX_PARAMS = 5;
const MAX_COGNITIVE_COMPLEXITY = 9;
// Waiting for SonarJS to be compatible
// const MAX_COGNITIVE_COMPLEXITY = 9;
const rules = {
"accessor-pairs": "error",
@ -128,9 +129,11 @@ const rules = {
"no-unused-vars": "off",
"no-console": ["error", { allow: ["debug", "warn", "error"] }],
"sonarjs/cognitive-complexity": ["off", MAX_COGNITIVE_COMPLEXITY],
"sonarjs/no-duplicate-string": "off",
"sonarjs/no-nested-template-literals": "off",
// SonarJS is not yet compatible with ESLint 9. Commenting these out
// until it is.
// "sonarjs/cognitive-complexity": ["off", MAX_COGNITIVE_COMPLEXITY],
// "sonarjs/no-duplicate-string": "off",
// "sonarjs/no-nested-template-literals": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-unused-vars": [
"error",
@ -167,7 +170,7 @@ export default [
wcconf.configs["flat/recommended"],
litconf.configs["flat/recommended"],
...tseslint.configs.recommended,
sonar.configs.recommended,
// sonar.configs.recommended,
{
languageOptions: {
parser: tsparser,

View File

@ -1,7 +1,6 @@
import eslint from "@eslint/js";
import tsparser from "@typescript-eslint/parser";
import litconf from "eslint-plugin-lit";
import sonar from "eslint-plugin-sonarjs";
import wcconf from "eslint-plugin-wc";
import globals from "globals";
import tseslint from "typescript-eslint";
@ -30,7 +29,7 @@ export default [
wcconf.configs["flat/recommended"],
litconf.configs["flat/recommended"],
...tseslint.configs.recommended,
sonar.configs.recommended,
// sonar.configs.recommended,
{
languageOptions: {
parser: tsparser,
@ -43,9 +42,11 @@ export default [
rules: {
"no-unused-vars": "off",
"no-console": ["error", { allow: ["debug", "warn", "error"] }],
"sonarjs/cognitive-complexity": ["off", 9],
"sonarjs/no-duplicate-string": "off",
"sonarjs/no-nested-template-literals": "off",
// SonarJS is not yet compatible with ESLint 9. Commenting these out
// until it is.
// "sonarjs/cognitive-complexity": ["off", 9],
// "sonarjs/no-duplicate-string": "off",
// "sonarjs/no-nested-template-literals": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-unused-vars": [
"error",

View File

@ -4,7 +4,7 @@
"private": true,
"license": "MIT",
"dependencies": {
"@goauthentik/api": "^2024.6.3-1724414734",
"@goauthentik/api": "^2024.8.3-1727449099",
"base64-js": "^1.5.1",
"bootstrap": "^4.6.1",
"formdata-polyfill": "^4.0.10",

View File

@ -35,7 +35,7 @@ describe("ak-quick-actions-card", () => {
></ak-quick-actions-card>`,
);
const component = await $("ak-quick-actions-card");
const items = await component.$$(">>>.pf-c-list li").getElements();
const items = await component.$$(">>>.pf-c-list li");
await expect(Array.from(items).length).toEqual(5);
await expect(await component.$(">>>.pf-c-list li:nth-of-type(4)")).toHaveText(
"Manage users",

View File

@ -39,7 +39,7 @@ export class AkSearchSelectViewDriver {
);
}
const id = await element.getAttribute("data-ouia-component-id");
const menu = await $(`[data-ouia-component-id="menu-${id}"]`).getElement();
const menu = await $(`[data-ouia-component-id="menu-${id}"]`);
return new AkSearchSelectViewDriver(element, menu);
}
@ -52,7 +52,7 @@ export class AkSearchSelectViewDriver {
}
async listElements() {
return await this.menu.$$(">>>li").getElements();
return await this.menu.$$(">>>li");
}
async focusOnInput() {

View File

@ -21,9 +21,7 @@ describe("Search select: Test Input Field", () => {
html`<ak-search-select-view .options=${longGoodForYouPairs}> </ak-search-select-view>`,
document.body,
);
select = await AkSearchSelectViewDriver.build(
await $("ak-search-select-view").getElement(),
);
select = await AkSearchSelectViewDriver.build(await $("ak-search-select-view"));
});
it("should open the menu when the input is clicked", async () => {
@ -58,9 +56,7 @@ describe("Search select: Test Input Field", () => {
expect(await select.open).toBe(false);
expect(await select.menuIsVisible()).toBe(false);
await browser.keys("A");
select = await AkSearchSelectViewDriver.build(
await $("ak-search-select-view").getElement(),
);
select = await AkSearchSelectViewDriver.build(await $("ak-search-select-view"));
expect(await select.open).toBe(true);
expect(await select.menuIsVisible()).toBe(true);
});

View File

@ -97,9 +97,7 @@ describe("Search select: event driven startup", () => {
mock?.dispatchEvent(new Event("resolve"));
});
expect(await $(">>>ak-search-select-loading-indicator")).not.toBeDisplayed();
select = await AkSearchSelectViewDriver.build(
await $(">>>ak-search-select-view").getElement(),
);
select = await AkSearchSelectViewDriver.build(await $(">>>ak-search-select-view"));
expect(await select).toBeExisting();
});

View File

@ -1,4 +1,5 @@
import replace from "@rollup/plugin-replace";
import type { Options } from "@wdio/types";
import { cwd } from "process";
import postcssLit from "rollup-plugin-postcss-lit";
import type { UserConfig } from "vite";
@ -14,7 +15,7 @@ const maxInstances =
? 10
: 1;
export const config: WebdriverIO.Config = {
export const config: Options.Testrunner = {
//
// ====================
// Runner Configuration
@ -42,7 +43,13 @@ export const config: WebdriverIO.Config = {
},
],
tsConfigPath: "./tsconfig.json",
autoCompileOpts: {
autoCompile: true,
tsNodeOpts: {
project: "./tsconfig.json",
transpileOnly: true,
},
},
//
// ==================
@ -133,11 +140,11 @@ export const config: WebdriverIO.Config = {
// baseUrl: 'http://localhost:8080',
//
// Default timeout for all waitFor* commands.
waitforTimeout: 10000,
waitforTimeout: 12000,
//
// Default timeout in milliseconds for request
// if browser driver or grid doesn't send response
connectionRetryTimeout: 120000,
connectionRetryTimeout: 12000,
//
// Default request retries count
connectionRetryCount: 3,