-
-
Notifications
You must be signed in to change notification settings - Fork 992
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: fix flash of unstructured content, add tests for it #11013
Conversation
…from the backend Provide an alternative, readonly, disabled, unindexed input object with the text "Loading...", to be replaced with the _real_ input element after the content is loaded. This provides the correct appearance and spacing so the content doesn't jiggle about between the start of loading and the SearchSelect element being finalized. It was visually distracting and unappealing.
…correct component under test.
- Add a unit test to ensure the "Loading..." element is displayed correctly before data arrives - Demo how to mock a `fetchObjects()` call in testing. Very cool. - Make distinguishing rule sets for code, tests, and scripts in nightmare mode - In SearchSelect, Move the `styles()` declaration to the top of the class for consistency. - To test for the FLOUC issue in SearchSelect. This is both an exercise in mocking @BeryJu's `fetchObjects()` protocol, and shows how we can unit test generic components that render API objects.
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for authentik-storybook ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #11013 +/- ##
==========================================
+ Coverage 92.70% 92.77% +0.07%
==========================================
Files 736 736
Lines 36360 36360
==========================================
+ Hits 33706 33732 +26
+ Misses 2654 2628 -26
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
authentik PR Installation instructions Instructions for docker-composeAdd the following block to your AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-014f43b0cd484827e9182227c9f5133af998da8f
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s For arm64, use these values: AUTHENTIK_IMAGE=ghcr.io/goauthentik/dev-server
AUTHENTIK_TAG=gh-014f43b0cd484827e9182227c9f5133af998da8f-arm64
AUTHENTIK_OUTPOSTS__CONTAINER_IMAGE_BASE=ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s Afterwards, run the upgrade commands from the latest release notes. Instructions for KubernetesAdd the following block to your authentik:
outposts:
container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
global:
image:
repository: ghcr.io/goauthentik/dev-server
tag: gh-014f43b0cd484827e9182227c9f5133af998da8f For arm64, use these values: authentik:
outposts:
container_image_base: ghcr.io/goauthentik/dev-%(type)s:gh-%(build_hash)s
global:
image:
repository: ghcr.io/goauthentik/dev-server
tag: gh-014f43b0cd484827e9182227c9f5133af998da8f-arm64 Afterwards, run the upgrade commands from the latest release notes. |
const MAX_PARAMS = 5; | ||
const MAX_COGNITIVE_COMPLEXITY = 9; | ||
|
||
const rules = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved the rules up into their own block for re-use and, hah!, got bit by my own standards. Changing this file caused lint:nightmare
to complain that I had magic numbers in the eslint.nightmate
configuration files. Fair.
}, | ||
globals: { | ||
...globals.nodeBuiltin, | ||
...globals.jest, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing the test files requires I include the global definition for the test functions.
@@ -228,8 +230,15 @@ export class SearchSelectBase<T> | |||
return html`<em>${msg("Failed to fetch objects: ")} ${this.error.detail}</em>`; | |||
} | |||
|
|||
// `this.objects` is both a container and a sigil; if it is in the `undefined` state, it's a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After implementing the loader display, I worried that my implementation is naive. It is, but not in a way that breaks my expectations. This comment explains the state management between "First loading," "displaying," and "displaying and loading."
@@ -48,7 +46,7 @@ export interface ISearchSelectEz<T> extends ISearchSelectBase<T> { | |||
@customElement("ak-search-select-ez") | |||
export class SearchSelectEz<T> extends SearchSelectBase<T> implements ISearchSelectEz<T> { | |||
static get styles() { | |||
return [PFBase]; | |||
return [...SearchSelectBase.styles]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Child classes should use as much of the parent as possible.
@@ -69,6 +69,10 @@ export interface ISearchSelectView { | |||
*/ | |||
@customElement("ak-search-select-view") | |||
export class SearchSelectView extends AKElement implements ISearchSelectView { | |||
static get styles() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just moved for consistency. I need to document our component pattern more seriously.
@@ -1,100 +1,108 @@ | |||
/* eslint-env jest */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an awful diff. This test file was originally just about the view,
so I renamed it to ak-search-select-view.test.ts
. This is actually a new test file to test the API interaction. I recommend View File
using the three-dot entry to the right. ➠
* main: website/docs: cve release notes (#11026) security: fix CVE-2024-42490 (#11022) web: bump API Client version (#11021) providers/scim: optimize sending all members within a group (#9968) providers/scim: add API endpoint to sync single user (#8486) web: bump chromedriver from 127.0.3 to 128.0.0 in /tests/wdio (#11017) web: dual-select uses, part 2: dual-select harder (#9377) web: fix flash of unstructured content, add tests for it (#11013) core: bump drf-orjson-renderer from 1.7.2 to 1.7.3 (#11015) core: bump github.com/gorilla/sessions from 1.3.0 to 1.4.0 (#11002) website/docs: Correct the forward authentication configuration template for Caddy (#11012)
* main: (165 commits) web/flows: update flow background (#11044) web: bump API Client version (#11043) website/integrations: Correct Discord avatar code and add warning. (#11031) core, web: update translations (#11032) website: bump docusaurus-theme-openapi-docs from 4.0.0 to 4.0.1 in /website (#11034) core: bump ruff from 0.6.1 to 0.6.2 (#11035) core: bump goauthentik.io/api/v3 from 3.2024063.12 to 3.2024063.13 (#11036) web: bump the babel group across 1 directory with 3 updates (#11038) web: bump wireit from 0.14.7 to 0.14.8 in /web (#11039) web: bump @goauthentik/api from 2024.6.3-1723921843 to 2024.6.3-1724337552 in /web/sfe (#11040) enterprise: add up-to-date license status (#11042) website/docs: cve release notes (#11026) security: fix CVE-2024-42490 (#11022) web: bump API Client version (#11021) providers/scim: optimize sending all members within a group (#9968) providers/scim: add API endpoint to sync single user (#8486) web: bump chromedriver from 127.0.3 to 128.0.0 in /tests/wdio (#11017) web: dual-select uses, part 2: dual-select harder (#9377) web: fix flash of unstructured content, add tests for it (#11013) core: bump drf-orjson-renderer from 1.7.2 to 1.7.3 (#11015) ...
* web/element/ak-select-table: Provide unit test accessibility to Firefox and Safari; wrap calls to manipulate test DOMs directly in a browser.exec call so they run in the proper context and be await()ed properly web: finalize testing for tables web: added basic unit testing to API-free tables website/docs: cve release notes (#11026) security: fix CVE-2024-42490 (#11022) web: bump API Client version (#11021) providers/scim: optimize sending all members within a group (#9968) providers/scim: add API endpoint to sync single user (#8486) web: bump chromedriver from 127.0.3 to 128.0.0 in /tests/wdio (#11017) web: dual-select uses, part 2: dual-select harder (#9377) web: fix flash of unstructured content, add tests for it (#11013) core: bump drf-orjson-renderer from 1.7.2 to 1.7.3 (#11015) core: bump github.com/gorilla/sessions from 1.3.0 to 1.4.0 (#11002) web: interim commit of the basic sortable & selectable table. website/docs: Correct the forward authentication configuration template for Caddy (#11012) web: test for flash of unstructured content web: comment on state management in API layer, move file to point to correct component under test. web: fix Flash of Unstructured Content while SearchSelect is loading from the backend
web: test for flash of unstructured content
What
fetchObjects()
call in testing. Very cool.styles()
declaration to the top of the class for consistency.Why
This is both an exercise in mocking @BeryJu’s
fetchObjects()
protocol, and shows how we can unit test generic components that render API objects.make web
)