Compare commits

...

40 commits

Author SHA1 Message Date
Anthony LC
aed8ae7181
🐛(frontend) remove horizontal line when no elements
Some checks are pending
Update crowdin sources / install-dependencies (push) Waiting to run
Update crowdin sources / synchronize-with-crowdin (push) Blocked by required conditions
Docker Hub Workflow / build-and-push-backend (push) Waiting to run
Docker Hub Workflow / build-and-push-frontend (push) Waiting to run
Docker Hub Workflow / build-and-push-y-provider (push) Waiting to run
Docker Hub Workflow / notify-argocd (push) Blocked by required conditions
Build and Push to GHCR / build-and-push-backend (push) Waiting to run
Build and Push to GHCR / build-and-push-frontend (push) Waiting to run
Build and Push to GHCR / build-and-push-y-provider (push) Waiting to run
Helmfile lint / helmfile-lint (push) Waiting to run
Frontend Workflow / install-dependencies (push) Waiting to run
Frontend Workflow / test-front (push) Blocked by required conditions
Frontend Workflow / lint-front (push) Blocked by required conditions
Frontend Workflow / test-e2e-chromium (push) Waiting to run
Frontend Workflow / test-e2e-other-browser (push) Blocked by required conditions
Frontend Workflow / bundle-size-check (push) Blocked by required conditions
Frontend Workflow / uikit-theme-checker (push) Blocked by required conditions
Main Workflow / lint-changelog (push) Waiting to run
Main Workflow / lint-spell-mistakes (push) Waiting to run
Main Workflow / install-dependencies (push) Waiting to run
Main Workflow / lint-git (push) Waiting to run
Main Workflow / check-changelog (push) Waiting to run
Main Workflow / lint-back (push) Waiting to run
Main Workflow / test-back (push) Blocked by required conditions
When no elements are present in the doc share
modals, a horizontal line is still displayed.
This PR removes this line when there are no elements
to display.
2026-04-21 11:39:07 +02:00
Anthony LC
e39b03c272
🐛(frontend) fix app shallow reload
The app was doing a shallow reload when user
was coming from another tab and the user data
was staled. We stop to block the app during the
loading state, depend the response the app
will manage correctly its states.
2026-04-21 11:39:07 +02:00
Anthony LC
3cc9655574
🐛(frontend) fix position interlinking when lost focus
When switching between a interlinking search to a
interlinking link, we could lose the position of
the interlinking. The interlinking was added at
the beginning of the document or where the cursor was.
We refactorize the interlinking to be only one type
of inline content, by doing so we do not lose the position
of the interlinking because we don't remove the interlinking search
to add the interlinking link, we just update the
interlinking search to be a interlinking link.
2026-04-21 10:15:35 +02:00
Anthony LC
c20e71e21d
💄(frontend) update interlinking ux/ui
Update interlinking to fit the new design.
The notable changes is that we cannot create
a subdoc from the search dropdown.
2026-04-21 10:15:34 +02:00
Anthony LC
b3dd8f2e39
🐛(frontend) fix interlinking modal clipping
Depend the parent block, the modal search may be
clipped by the parent block. We now use the portal
to render the modal search, which will not be
affected by the parent block's clipping.
2026-04-21 10:15:34 +02:00
Manuel Raynaud
203b3edcae
🐛(backend) load jwks url when OIDC_RS_PRIVATE_KEY_STR is set
Some checks are pending
Update crowdin sources / install-dependencies (push) Waiting to run
Update crowdin sources / synchronize-with-crowdin (push) Blocked by required conditions
Docker Hub Workflow / build-and-push-backend (push) Waiting to run
Docker Hub Workflow / build-and-push-frontend (push) Waiting to run
Docker Hub Workflow / build-and-push-y-provider (push) Waiting to run
Docker Hub Workflow / notify-argocd (push) Blocked by required conditions
Build and Push to GHCR / build-and-push-backend (push) Waiting to run
Build and Push to GHCR / build-and-push-frontend (push) Waiting to run
Build and Push to GHCR / build-and-push-y-provider (push) Waiting to run
Helmfile lint / helmfile-lint (push) Waiting to run
Frontend Workflow / install-dependencies (push) Waiting to run
Frontend Workflow / test-front (push) Blocked by required conditions
Frontend Workflow / lint-front (push) Blocked by required conditions
Frontend Workflow / test-e2e-chromium (push) Waiting to run
Frontend Workflow / test-e2e-other-browser (push) Blocked by required conditions
Frontend Workflow / bundle-size-check (push) Blocked by required conditions
Frontend Workflow / uikit-theme-checker (push) Blocked by required conditions
Main Workflow / install-dependencies (push) Waiting to run
Main Workflow / lint-git (push) Waiting to run
Main Workflow / check-changelog (push) Waiting to run
Main Workflow / lint-changelog (push) Waiting to run
Main Workflow / lint-spell-mistakes (push) Waiting to run
Main Workflow / lint-back (push) Waiting to run
Main Workflow / test-back (push) Blocked by required conditions
When the resource server is enabled and the backend used is
JWTResourceServerBackend, then the API should expose a JWKS endpoint to
share the RSA public key to the OIDC provider. Everything is made in the
Django LaSuite library, but the URL is not included in the Docs URLs.
This commit adds it when the setting OIDC_RS_PRIVATE_KEY_STR is set.
2026-04-20 15:14:09 +00:00
Anthony LC
ee90443cb2
(frontend) add documentation link in help menu
Some checks are pending
Update crowdin sources / install-dependencies (push) Waiting to run
Update crowdin sources / synchronize-with-crowdin (push) Blocked by required conditions
Docker Hub Workflow / build-and-push-backend (push) Waiting to run
Docker Hub Workflow / build-and-push-frontend (push) Waiting to run
Docker Hub Workflow / build-and-push-y-provider (push) Waiting to run
Docker Hub Workflow / notify-argocd (push) Blocked by required conditions
Build and Push to GHCR / build-and-push-backend (push) Waiting to run
Build and Push to GHCR / build-and-push-frontend (push) Waiting to run
Build and Push to GHCR / build-and-push-y-provider (push) Waiting to run
Helmfile lint / helmfile-lint (push) Waiting to run
Frontend Workflow / install-dependencies (push) Waiting to run
Frontend Workflow / test-front (push) Blocked by required conditions
Frontend Workflow / lint-front (push) Blocked by required conditions
Frontend Workflow / test-e2e-chromium (push) Waiting to run
Frontend Workflow / test-e2e-other-browser (push) Blocked by required conditions
Frontend Workflow / bundle-size-check (push) Blocked by required conditions
Frontend Workflow / uikit-theme-checker (push) Blocked by required conditions
Main Workflow / install-dependencies (push) Waiting to run
Main Workflow / lint-git (push) Waiting to run
Main Workflow / check-changelog (push) Waiting to run
Main Workflow / lint-changelog (push) Waiting to run
Main Workflow / lint-spell-mistakes (push) Waiting to run
Main Workflow / lint-back (push) Waiting to run
Main Workflow / test-back (push) Blocked by required conditions
We want to add a link to the documentation in
the help menu, to make it easier for users to find it.
2026-04-20 14:29:12 +02:00
Anthony LC
572074d141
🚸(frontend) show Crisp from the help menu
The Crisp button is very intrusive, it often overlaps
with element of the app.
We now show the Crisp modal
only when the user clicks on the "Get Support"
button in the help menu.
2026-04-20 14:29:12 +02:00
Anthony LC
599b909318
🛂(frontend) fix cannot manage member on small screen
We can now manage document members on small
screens (mobile and tablet). We improved the
overall responsive design of the doc share modal.
2026-04-20 11:00:41 +02:00
Anthony LC
5a687799d5
🥚(e2e) fix e2e easter egg
Some checks failed
Helmfile lint / helmfile-lint (push) Has been cancelled
Release Chart / release (push) Has been cancelled
The test e2e were not working on April 1st
because of the easter egg that changes
the document emoji to a fish.
2026-04-17 16:08:07 +02:00
virgile-deville
30ed563be4
📝(contributing.md) fix typos
Some checks failed
Update crowdin sources / install-dependencies (push) Has been cancelled
Update crowdin sources / synchronize-with-crowdin (push) Has been cancelled
Docker Hub Workflow / build-and-push-backend (push) Has been cancelled
Docker Hub Workflow / build-and-push-frontend (push) Has been cancelled
Docker Hub Workflow / build-and-push-y-provider (push) Has been cancelled
Docker Hub Workflow / notify-argocd (push) Has been cancelled
Main Workflow / install-dependencies (push) Has been cancelled
Build and Push to GHCR / build-and-push-y-provider (push) Has been cancelled
Build and Push to GHCR / build-and-push-backend (push) Has been cancelled
Build and Push to GHCR / build-and-push-frontend (push) Has been cancelled
Helmfile lint / helmfile-lint (push) Has been cancelled
Frontend Workflow / install-dependencies (push) Has been cancelled
Frontend Workflow / test-front (push) Has been cancelled
Frontend Workflow / lint-front (push) Has been cancelled
Frontend Workflow / test-e2e-chromium (push) Has been cancelled
Frontend Workflow / test-e2e-other-browser (push) Has been cancelled
Frontend Workflow / bundle-size-check (push) Has been cancelled
Frontend Workflow / uikit-theme-checker (push) Has been cancelled
Main Workflow / lint-git (push) Has been cancelled
Main Workflow / check-changelog (push) Has been cancelled
Main Workflow / lint-changelog (push) Has been cancelled
Main Workflow / lint-back (push) Has been cancelled
Main Workflow / lint-spell-mistakes (push) Has been cancelled
Main Workflow / test-back (push) Has been cancelled
So that it doesn't contain mistakes

Signed-off-by: virgile-deville <virgile.deville@beta.gouv.fr>
2026-04-16 13:59:33 +02:00
Cyril
e59d8a4631
️(frontend) make doc search result labels uniquely identifiable
Include each doc's relative update date in `SimpleDocItem` aria-label.
2026-04-15 15:52:53 +02:00
Cyril
9a5d81f983
️(frontend) redirect unmanaged 5xx to dedicated /500 page
Add /500 with coffee illustration; replace inline TextErrors for API 5xx
2026-04-14 17:36:23 +02:00
Cyril
31fea43729
️(frontend) structure 5xx error alerts
Use h1/p for 500/502/503; pass status from doc and version views.
2026-04-14 17:22:13 +02:00
Anthony LC
ff176d67ae
🚨(frontend) add default favicon.ico
We had a warning in the console about a
missing favicon.ico. This commit adds a default
one to prevent that warning.
2026-04-14 15:47:26 +02:00
Anthony LC
7dc7320dac
🚸(frontend) redirect on current url tab after 401
When multiple tabs were opened and a 401 error occurred,
the user was redirected to the login page, then
after login, the user was redirected to the page
where the last 401 error occurred.
We improved this behavior by saving the url per tab,
and after login, the user is redirected to the
last url of the current tab.
2026-04-14 14:48:15 +02:00
Anthony LC
d9334352bb
♻️(CI) factorized E2E tests into a separate workflow
We had to maintains 2 jobs, test-e2e-chromium and
test-e2e-other-browser, in the impress-frontend
workflow.
By factorising the E2E tests into a separate
workflow, we can now maintain only one job for
each browser, which is much simpler and easier
to maintain.
2026-04-13 11:36:23 +02:00
Anthony LC
d68d7ee31d
🐛(CI) add last-failed flag only if last-run is filled
We got cases where the last-run is empty, but the
last-failed flag is set to true. If that happens,
the workflow will fail because the last-run is empty.
We now check if the last-run is filled before
setting the last-failed flag.
2026-04-13 11:36:23 +02:00
renovate[bot]
0060c59615
⬆️(dependencies) update axios to v1.15.0 [SECURITY] 2026-04-13 08:30:36 +00:00
renovate[bot]
48fb17bf3e
⬆️(dependencies) update next to v16.2.3 [SECURITY] 2026-04-11 01:12:58 +00:00
pvrn
e652cdd040
(backend) Order pinned documents by last updated at
Sort favorite_list results by updated_at property descending.
    
Signed-off-by: Paul Vernin <paul.vernin@gmail.com>
2026-04-10 15:15:55 +00:00
Mohamed El Amine BOUKERFA
1ebdda8c9e
🐛(backend) Fix unreachable exception handler for URLValidator
The exception block was never being executed because URLValidator raises
django.core.exceptions.ValidationError, not
drf.exceptions.ValidationError, so the except block was dead code.


Signed-off-by: Mohamed El Amine BOUKERFA <boukerfa.ma@gmail.com>
2026-04-10 13:21:56 +00:00
virgile-deville
d0bf24f368
📝(PR template) add AI checklist
so that we can keep  welcoming external contributions

Signed-off-by: virgile-deville <virgile.deville@beta.gouv.fr>
2026-04-10 14:32:30 +02:00
virgile-deville
2da87baef5
📝(contributing.md) revamp and AI policy
so that we can keep  welcoming external contribution

Signed-off-by: virgile-deville <virgile.deville@beta.gouv.fr>
2026-04-10 14:32:29 +02:00
Sylvain Boissel
3399734a55
🐛(backend) fix race condition in reconciliation requests CSV import
The call to the background task is now wrapped in a on_commit to ensure
that it isn't called before the save is finished, in order to avoid race
condition issues.
2026-04-10 10:46:56 +00:00
Sylvain Boissel
a29b25f82f
🐛(backend) create_for_owner: add accesses before saving doc content
We add the User Accesses before saving content so the user is sure to
have access to the the first version when creating a doc through
create_for_owner (fixes #2123)
2026-04-10 10:20:37 +00:00
Anthony LC
c1e104a686
🐛(frontend) abort check media status unmount
When a media file is uploaded, the application
checks its status every 5 seconds until it
becomes 'ready'. If the user navigates away from
the page before the media is ready, the
application should stop checking the status to
avoid unnecessary API calls. This can be achieved
by using an AbortController to signal when the
component is unmounted, allowing the loop to
exit gracefully.
2026-04-09 11:51:19 +02:00
Anthony LC
21c73fd064
🔖(patch) release 4.8.6
Added:
- 🚸(frontend) allow opening "@page" links with
  ctrl/command/middle-mouse click
-  E2E - Any instance friendly

Changed:
- ♻️(backend) do not paginate threads list response
- 💄(frontend) Use StyledLink for sub doc tree

Fixed:
- 🐛(frontend) Fix drop cursor creating columns
- 🐛 Fixed side effects between comments and versioning
2026-04-09 09:52:00 +02:00
AntoLC
e2d0e7ccc7
🌐(i18n) update translated strings
Update translated files with new translations
2026-04-08 16:56:36 +02:00
Paul Vernin
2ebfa1efbf
💄(frontend) Use StyledLink for sub doc tree
Replace ButtonBox by StyledLink in DocSubPageItem
so ctrl+click on the sub document title open a new browser tab

Signed-off-by: Paul Vernin <paul.vernin@gmail.com>
2026-04-08 16:37:47 +02:00
Anthony LC
b5d9c58761
💄(frontend) replace icons in tree children action
We replace icons with what is used in the ui kit.
By replacing the icons, we also fix the height
problems with Firefox.
2026-04-08 16:15:30 +02:00
Anthony LC
c58deb11e8
🏷️(frontend) adapt thread new type
We stopped to use pagination for thread comments,
so we need to adapt the thread type to reflect that.
2026-04-08 14:04:03 +02:00
Manuel Raynaud
9a1dae4908
♻️(backend) do not paginate threads list response
The threads list action was paginated its response. this is not the
behavior we want. all threads should be loaded when the document is
loaded.
2026-04-08 10:59:36 +02:00
Anthony LC
dba762759e
🐛(frontend) Fixed side effects between comments and versionning
We fixed 2 side effects between comments and versionning:
- When going from a version, it was not possible
to add a comment anymore. This was due to the fact
that the versionning was resetting the comment store.
- When restoring a version, we now reset the comment
store to avoid having comments that are not relevant
anymore.
2026-04-08 09:36:25 +02:00
Anthony LC
563a6d0e08
🐛(frontend) Fix drop cursor creating columns
When dropping content, the drop cursor was creating
new columns. This fix ensures that the
drop cursor behaves correctly and does not
create unnecessary columns.
2026-04-07 18:04:45 +02:00
Anthony LC
52c998ee5f
️(e2e) replay only failed tests when rerunning the test suite
We improved the test suite to only replay failed
tests when rerunning the test suite.
This allows us to focus on fixing the failed
tests without having to wait for the entire
test suite to run again.
We add the Browser in cache to speed up the test
execution and reduce the time it takes to run the tests.
2026-04-07 16:11:18 +02:00
Anthony LC
a01c5f97ca
(e2e) e2e instances compatibility
We want to be able to run our e2e tests on
any instance of Docs, to do so we need to make
some adjustments to our tests and configuration.
We will use environment variables to configure
the tests.
2026-04-07 16:11:18 +02:00
Anthony LC
883d65136a
🔒️(CI) add permissions level on workflow
We add permissions level on workflow to avoid
warning in github action logs.
This is a warning and not an error,
but it is good to have a clean log without warnings.
2026-04-07 14:52:31 +02:00
Emmanuel Pelletier
4dcf752ff9
🚸(frontend) allow opening "interlinks" with ctrl/command/middle mouse
Links to other pages created through the "@" shortcut are not actual
anchor (`<a>`) elements seemingly due to conflicts with lower-lvl
code, noticeably when drag&dropping the elements.

So those "links" are actually span and we must handle the
"link behavior" ourselves.

This adds more usual "link behavior" to thoses, allowing users to
ctrl+click, command+click, shift+click and middle-mouse click to
interact with the links and open them in a new tab or new window.

Signed-off-by: Emmanuel Pelletier <manu@habite.la>
2026-04-07 11:14:01 +02:00
renovate[bot]
be38e68dd5
⬆️(dependencies) update lodash to v4.18.1 [SECURITY] 2026-04-03 18:39:40 +00:00
147 changed files with 3582 additions and 2007 deletions

View file

@ -1,22 +1,39 @@
## Purpose
Describe the purpose of this pull request.
Describe the purpose of this pull request.
## Proposal
- [ ] item 1...
- [ ] item 2...
* [ ] item 1...
* [ ] item 2...
## External contributions
Thank you for your contribution! 🎉
Thank you for your contribution! 🎉
Please ensure the following items are checked before submitting your pull request:
- [ ] I have read and followed the [contributing guidelines](https://github.com/suitenumerique/docs/blob/main/CONTRIBUTING.md)
- [ ] I have read and agreed to the [Code of Conduct](https://github.com/suitenumerique/docs/blob/main/CODE_OF_CONDUCT.md)
- [ ] I have signed off my commits with `git commit --signoff` (DCO compliance)
- [ ] I have signed my commits with my SSH or GPG key (`git commit -S`)
- [ ] My commit messages follow the required format: `<gitmoji>(type) title description`
- [ ] I have added a changelog entry under `## [Unreleased]` section (if noticeable change)
- [ ] I have added corresponding tests for new features or bug fixes (if applicable)
### General requirements
* [ ] I have read and followed the [contributing guidelines](https://github.com/suitenumerique/docs/blob/main/CONTRIBUTING.md)
* [ ] I have read and agreed to the [Code of Conduct](https://github.com/suitenumerique/docs/blob/main/CODE_OF_CONDUCT.md)
* [ ] I have added corresponding tests for new features or bug fixes (if applicable)
*Skip the checkbox below 👇 if you're fixing an issue or adding documentation*
* [ ] Before submitting a PR for a new feature I made sure to contact the product manager
### CI requirements
* [ ] I made sure that all existing tests are passing
* [ ] I have signed off my commits with `git commit --signoff` (DCO compliance)
* [ ] I have signed my commits with my SSH or GPG key (`git commit -S`)
* [ ] My commit messages follow the required format: `<gitmoji>(type) title description`
* [ ] I have added a changelog entry under `## [Unreleased]` section (if noticeable change)
### AI requirements
*Skip the checkboxes below 👇 If you didn't use AI for your contribution*
* [ ] I used AI assistance to produce part or all of this contribution
* [ ] I have read, reviewed, understood and can explain the code I am submitting
* [ ] I can jump in a call or a chat to explain my work to a maintainer

View file

@ -6,6 +6,9 @@ on:
branches:
- 'release/**'
permissions:
contents: read
jobs:
install-dependencies:
uses: ./.github/workflows/dependencies.yml

View file

@ -6,6 +6,9 @@ on:
branches:
- main
permissions:
contents: read
jobs:
install-dependencies:
uses: ./.github/workflows/dependencies.yml

View file

@ -14,6 +14,9 @@ on:
type: boolean
default: false
permissions:
contents: read
jobs:
front-dependencies-installation:
if: ${{ inputs.with-front-dependencies-installation == true }}

View file

@ -37,6 +37,9 @@ description: Build and push a container image based on the input arguments provi
default: ""
description: "Build arg name to pass first amd64 tag to arm64 build (skips arch-independent build steps)"
permissions:
contents: read
jobs:
build-and-push:
runs-on: ubuntu-latest

161
.github/workflows/e2e-tests.yml vendored Normal file
View file

@ -0,0 +1,161 @@
name: E2E Tests
on:
workflow_call:
inputs:
browser-name:
description: 'Name used for cache keys and artifact names (e.g. chromium, other-browser)'
required: true
type: string
projects:
description: 'Playwright --project flags (e.g. --project=chromium)'
required: true
type: string
timeout-minutes:
description: 'Job timeout in minutes'
required: false
type: number
default: 30
permissions:
contents: read
jobs:
install-dependencies:
uses: ./.github/workflows/dependencies.yml
with:
node_version: '22.x'
with-front-dependencies-installation: true
prepare-e2e:
runs-on: ubuntu-latest
needs: install-dependencies
timeout-minutes: 10
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "22.x"
- name: Restore the frontend cache
uses: actions/cache@v5
with:
path: "src/frontend/**/node_modules"
key: front-node_modules-${{ hashFiles('src/frontend/**/yarn.lock') }}
fail-on-cache-miss: true
- name: Restore Playwright browsers cache
id: playwright-cache
uses: actions/cache/restore@v4
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ hashFiles('src/frontend/yarn.lock', 'src/frontend/apps/e2e/yarn.lock') }}
restore-keys: |
playwright-${{ runner.os }}-
- name: Install Playwright browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: |
cd src/frontend/apps/e2e
yarn install-playwright chromium firefox webkit
- name: Save Playwright browsers cache
if: steps.playwright-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ~/.cache/ms-playwright
key: ${{ steps.playwright-cache.outputs.cache-primary-key }}
test-e2e:
needs: prepare-e2e
runs-on: ubuntu-latest
timeout-minutes: ${{ inputs.timeout-minutes }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "22.x"
- name: Restore the frontend cache
uses: actions/cache@v5
with:
path: "src/frontend/**/node_modules"
key: front-node_modules-${{ hashFiles('src/frontend/**/yarn.lock') }}
fail-on-cache-miss: true
- name: Set e2e env variables
run: cat env.d/development/common.e2e >> env.d/development/common.local
- name: Restore Playwright browsers cache
uses: actions/cache@v5
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ hashFiles('src/frontend/yarn.lock', 'src/frontend/apps/e2e/yarn.lock') }}
fail-on-cache-miss: true
- name: Free disk space before Docker
uses: ./.github/actions/free-disk-space
- name: Start Docker services
run: make bootstrap-e2e FLUSH_ARGS='--no-input'
- name: Restore last-run cache
if: ${{ github.run_attempt > 1 }}
id: restore-last-run
uses: actions/cache/restore@v4
with:
path: src/frontend/apps/e2e/test-results/.last-run.json
key: playwright-last-run-${{ github.run_id }}-${{ inputs.browser-name }}
- name: Run e2e tests
env:
PLAYWRIGHT_LIST_PRINT_STEPS: true
FORCE_COLOR: true
run: |
cd src/frontend/
LAST_FAILED_FLAG=""
if [ "${{ github.run_attempt }}" != "1" ]; then
LAST_RUN_FILE="apps/e2e/test-results/.last-run.json"
if [ -f "$LAST_RUN_FILE" ]; then
FAILED_COUNT=$(jq '.failedTests | length' "$LAST_RUN_FILE" 2>/dev/null || echo "0")
if [ "${FAILED_COUNT:-0}" -gt "0" ]; then
LAST_FAILED_FLAG="--last-failed"
fi
fi
fi
yarn e2e:test ${{ inputs.projects }} $LAST_FAILED_FLAG
- name: Save last-run cache
if: always()
uses: actions/cache/save@v4
with:
path: src/frontend/apps/e2e/test-results/.last-run.json
key: playwright-last-run-${{ github.run_id }}-${{ inputs.browser-name }}
- name: Upload last-run artifact
if: always()
uses: actions/upload-artifact@v6
with:
name: playwright-instance-last-run-${{ inputs.browser-name }}
path: src/frontend/apps/e2e/test-results/.last-run.json
include-hidden-files: true
if-no-files-found: warn
retention-days: 7
- uses: actions/upload-artifact@v6
if: always()
with:
name: playwright-${{ inputs.browser-name }}-report
path: src/frontend/apps/e2e/report/
retention-days: 7

View file

@ -13,6 +13,9 @@ env:
DOCKER_USER: 1001:127
REGISTRY: ghcr.io
permissions:
contents: read
jobs:
build-and-push-backend:
runs-on: ubuntu-latest

View file

@ -8,6 +8,9 @@ on:
branches:
- "*"
permissions:
contents: read
jobs:
install-dependencies:
@ -64,88 +67,19 @@ jobs:
run: cd src/frontend/ && yarn lint
test-e2e-chromium:
runs-on: ubuntu-latest
needs: install-dependencies
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "22.x"
- name: Restore the frontend cache
uses: actions/cache@v5
with:
path: "src/frontend/**/node_modules"
key: front-node_modules-${{ hashFiles('src/frontend/**/yarn.lock') }}
fail-on-cache-miss: true
- name: Set e2e env variables
run: cat env.d/development/common.e2e >> env.d/development/common.local
- name: Install Playwright Browsers
run: cd src/frontend/apps/e2e && yarn install --frozen-lockfile && yarn install-playwright chromium
- name: Free disk space before Docker
uses: ./.github/actions/free-disk-space
- name: Start Docker services
run: make bootstrap-e2e FLUSH_ARGS='--no-input'
- name: Run e2e tests
run: cd src/frontend/ && yarn e2e:test --project='chromium'
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-chromium-report
path: src/frontend/apps/e2e/report/
retention-days: 7
uses: ./.github/workflows/e2e-tests.yml
with:
browser-name: chromium
projects: --project=chromium
timeout-minutes: 25
test-e2e-other-browser:
runs-on: ubuntu-latest
needs: test-e2e-chromium
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "22.x"
- name: Restore the frontend cache
uses: actions/cache@v5
with:
path: "src/frontend/**/node_modules"
key: front-node_modules-${{ hashFiles('src/frontend/**/yarn.lock') }}
fail-on-cache-miss: true
- name: Set e2e env variables
run: cat env.d/development/common.e2e >> env.d/development/common.local
- name: Install Playwright Browsers
run: cd src/frontend/apps/e2e && yarn install --frozen-lockfile && yarn install-playwright firefox webkit chromium
- name: Free disk space before Docker
uses: ./.github/actions/free-disk-space
- name: Start Docker services
run: make bootstrap-e2e FLUSH_ARGS='--no-input'
- name: Run e2e tests
run: cd src/frontend/ && yarn e2e:test --project=firefox --project=webkit
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-other-report
path: src/frontend/apps/e2e/report/
retention-days: 7
uses: ./.github/workflows/e2e-tests.yml
with:
browser-name: other-browser
projects: --project=firefox --project=webkit
timeout-minutes: 30
bundle-size-check:
runs-on: ubuntu-latest

View file

@ -8,6 +8,9 @@ on:
branches:
- "*"
permissions:
contents: read
jobs:
install-dependencies:
uses: ./.github/workflows/dependencies.yml

View file

@ -6,6 +6,41 @@ and this project adheres to
## [Unreleased]
### Changed
- 🚸(frontend) show Crisp from the help menu #2222
- ♿️(frontend) structure correctly 5xx error alerts #2128
- ♿️(frontend) make doc search result labels uniquely identifiable #2212
### Fixed
- 🚸(frontend) redirect on current url tab after 401 #2197
- 🐛(frontend) abort check media status unmount #2194
- ✨(backend) order pinned documents by last updated at #2028
- 🐛(frontend) fix app shallow reload #2231
- 🐛(frontend) fix interlinking modal clipping #2213
- 🛂(frontend) fix cannot manage member on small screen #2226
- 🐛(backend) load jwks url when OIDC_RS_PRIVATE_KEY_STR is set
## [v4.8.6] - 2026-04-08
### Added
- 🚸(frontend) allow opening "@page" links with
ctrl/command/middle-mouse click #2170
- ✅ E2E - Any instance friendly #2142
### Changed
- ♻️(backend) do not paginate threads list response #2186
- 💄(frontend) Use StyledLink for sub doc tree #2188
### Fixed
- 🐛(frontend) Fix drop cursor creating columns #2185
- 🐛 Fixed side effects between comments and versioning #2183
- 🐛(frontend) Firefox child doc visual #2188
## [v4.8.5] - 2026-04-03
### Added
@ -24,7 +59,7 @@ and this project adheres to
- ⚡️(frontend) add jitter to WS reconnection #2162
- 🐛(frontend) fix tree pagination #2145
- 🐛(nginx) add page reconciliation on nginx #2154
- 🐛(backend) fix race condition in reconciliation requests CSV import #2153
## [v4.8.4] - 2026-03-25
@ -46,6 +81,10 @@ and this project adheres to
- 🐛(y-provider) destroy Y.Doc instances after each convert request #2129
- 🐛(backend) remove deleted sub documents in favorite_list endpoint #2083
### Fixed
- 🐛(backend) create_for_owner: add accesses before saving doc content #2124
## [v4.8.3] - 2026-03-23
### Changed
@ -1213,7 +1252,8 @@ and this project adheres to
- ✨(frontend) Coming Soon page (#67)
- 🚀 Impress, project to manage your documents easily and collaboratively.
[unreleased]: https://github.com/suitenumerique/docs/compare/v4.8.5...main
[unreleased]: https://github.com/suitenumerique/docs/compare/v4.8.6...main
[v4.8.6]: https://github.com/suitenumerique/docs/releases/v4.8.6
[v4.8.5]: https://github.com/suitenumerique/docs/releases/v4.8.5
[v4.8.4]: https://github.com/suitenumerique/docs/releases/v4.8.4
[v4.8.3]: https://github.com/suitenumerique/docs/releases/v4.8.3

View file

@ -1,50 +1,127 @@
# Contributing to the Project
# Contributing to Docs
Thank you for taking the time to contribute! Please follow these guidelines to ensure a smooth and productive workflow. 🚀🚀🚀
To get started with the project, please refer to the [README.md](https://github.com/suitenumerique/docs/blob/main/README.md) for detailed instructions on how to run Docs locally.
We appreciate and value all kind of contributions (code, bug reports, design, feature requests, translations or documentation) the more diverse the Docs contributors community is, the better, because that's how [we make commons](http://wemakecommons.org/).
Contributors are required to sign off their commits with `git commit --signoff`: this confirms that they have read and accepted the [Developer's Certificate of Origin 1.1](https://developercertificate.org/). For security reasons we also require [signing your commits with your SSH or GPG key](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification) with `git commit -S`.
## Meet the maintainers team
Please also check out our [dev handbook](https://suitenumerique.gitbook.io/handbook) to learn our best practices.
Feel free to @ us in the issues and in our [Matrix community channel](https://matrix.to/#/#docs-official:matrix.org).
## Help us with translations
| Role | Github handle | Matrix handle |
| -------------------- | ------------- | -------------------------------------------------------------- |
| Dev front-end | @AntoLC | @anto29:matrix.org |
| Dev back-end | @lunika | @lunika:matrix.org |
| Dev front-end (A11Y) | @Ovgodd | |
| A11Y expert | @cyberbaloo | |
| Designer | @robinlecomte | @robinlecomte:matrix.org |
| Product manager | @virdev | @virgile-deville:matrix.org |
You can help us with translations on [Crowdin](https://crowdin.com/project/lasuite-docs).
Your language is not there? Request it on our Crowdin page 😊 or ping us on [Matrix](https://matrix.to/#/#docs-official:matrix.org) and let us know if you can help with translations and/or proofreading.
## Non technical contributions
## Creating an Issue
### Translations
When creating an issue, please provide the following details:
Translation help is very much appreciated.
1. **Title**: A concise and descriptive title for the issue.
2. **Description**: A detailed explanation of the issue, including relevant context or screenshots if applicable.
3. **Steps to Reproduce**: If the issue is a bug, include the steps needed to reproduce the problem.
4. **Expected vs. Actual Behavior**: Describe what you expected to happen and what actually happened.
5. **Labels**: Add appropriate labels to categorize the issue (e.g., bug, feature request, documentation).
We use [Crowdin](https://crowdin.com/project/lasuite-docs) for localizing the interface.
## Selecting an issue
We are also experimenting with using Docs itself to translate the [user documentation](https://docs.la-suite.eu/docs/97118270-f092-4680-a062-2ac675f42099/).
We use a [GitHub Project](https://github.com/orgs/numerique-gouv/projects/13) in order to prioritize our workload.
We coordinate over a dedicated [Matrix channel](https://matrix.to/#/#lasuite-docs-translation:matrix.org). Ping the product manager to add a new language and get your accesses.
Please check in priority the issues that are in the **todo** column and have a higher priority (P0 -> P2).
### Design
## Commit Message Format
We use Figma to collaborate on design, issues requiring changes in the UI usually have a Figma link attached. Our designs are public.
All commit messages must adhere to the following format:
We have dedicated labels for design work, the way we use them is described [here](https://docs.numerique.gouv.fr/docs/2d5cf334-1d0b-402f-a8bd-3f12b4cba0ce/).
If your contribution needs design, we'll tag it with the `need-design` label. The product manager and the designer will make sure to coordinate with you.
### Issues
We use issues for bug reports and feature requests. Both have a template, issues that follow the guidelines are reviewed first by maintainers. Each issue that gets filed is tagged with the label `triage`. As maintainers we will add the appropriate labels and remove the `triage` label when done.
**Best practices for filing your issues:**
* Write in English so everyone can participate
* Be concise
* Screenshot (image and videos) are appreciated
* Provide details when relevant (ex: steps to reproduce your issue, OS / Browser and their versions)
* Do a quick search in the issues and pull requests to avoid duplicates
**All things related to the text editor**
We use [BlockNote](https://www.blocknotejs.org/) for the text editing features of Docs.
If you find an issue with the editor and are able to reproduce it on their [demo](https://www.blocknotejs.org/demo) it's best to report it directly on the [BlockNote repository](https://github.com/TypeCellOS/BlockNote/issues). Same for [feature requests](https://github.com/TypeCellOS/BlockNote/discussions/categories/ideas-enhancements).
Please consider contributing to BlockNotejs, as a library, it's useful to many projects not just Docs.
The project is licensed with Mozilla Public License Version 2.0 but be aware that [XL packages](https://github.com/TypeCellOS/BlockNote/blob/main/packages/xl-docx-exporter/LICENSE) are dual licensed with GNU AFFERO GENERAL PUBLIC LICENSE Version 3 and proprietary license if you are a [sponsor](https://www.blocknotejs.org/pricing).
### Coordination around issues
We use use EPICs to group improvements on features. (See an [example](https://github.com/suitenumerique/docs/issues/1650))
We use GitHub Projects to:
* Track progress on [accessibility](https://github.com/orgs/suitenumerique/projects/19)
* Prioritize [front-end](https://github.com/orgs/suitenumerique/projects/2/views/9) and [back-end](https://github.com/orgs/suitenumerique/projects/2/views/8) issues
* Make our [roadmap](https://github.com/suitenumerique/docs/issues/1650) public
## Technical contributions
### Before you get started
* Run Docs locally, find detailed instructions in the [README.md](README.md)
* Check out the LaSuite [dev handbook](https://suitenumerique.gitbook.io/handbook) to learn about our best practices
* Join our [Matrix community channel](https://matrix.to/#/#docs-official:matrix.org)
* Reach out to the product manager before working on feature
### Requirements
For the CI to pass contributors are required to:
* sign off their commits with `git commit --signoff`: this confirms that they have read and accepted the [Developer's Certificate of Origin 1.1](https://developercertificate.org/).
* [sign their commits with your SSH or GPG key](https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification) with `git commit -S`.
* use a special formatting for their commits (see instructions below)
* check the linting: `make lint && make frontend-lint`
* Run the tests: `make test` and make sure all require test pass (we can't merge otherwise)
* add a changelog entry (not required for small changes
### Pull requests
Make sure you follow the following best practices:
* ping the product manager before taking on a significant feature
* for new features, especially large and complex ones, create an EPIC with sub-issues and submit your work in small PRs addressing each sub-issue ([example](https://github.com/suitenumerique/docs/issues/1650))
* be aware that it will be significantly harder to contribute to the back-end
* maintain consistency in code style and patterns
* make sure you add a brief purpose, screenshots, or a short video to help reviewers understand the changes
**Before asking for a human review make sure that:**
* all tests have passed in the CI
* you ticked all the checkboxes of the [PR checklist](.github/PULL_REQUEST_TEMPLATE.md)
*Skip if you see no Code Rabbit review on your PR*
* you addressed the Code Rabbit comments (when they are relevant)
#### Commit Message Format
All commit messages must follow this format:
`<gitmoji>(type) title description`
* <**gitmoji**>: Use a gitmoji to represent the purpose of the commit. For example, ✨ for adding a new feature or 🔥 for removing something, see the list [here](https://gitmoji.dev/).
* **(type)**: Describe the type of change. Common types include `backend`, `frontend`, `CI`, `docker` etc...
* **title**: A short, descriptive title for the change (*)
* **blank line after the commit title
* **description**: Include additional details on why you made the changes (**).
(*) ⚠️ **Make sure you add no space between the emoji and the (type) but add a space after the closing parenthesis of the type and use no caps!**
(**) ⚠️ **Commit description message is mandatory and shouldn't be too long**
* <**gitmoji**>: Use a gitmoji to represent the purpose of the commit. For example, ✨ for adding a new feature or 🔥 for removing something, see the list [here](https://gitmoji.dev/).
### Example Commit Message
* **(type)**: Describe the type of change. Common types include `backend`, `frontend`, `CI`, `docker` etc...
* **title**: A short, descriptive title for the change (*) **(less than 80 characters)**
* **blank line after the commit title**
* **description**: Include additional details on why you made the changes (**).
(*) ⚠️ Make sure you add no space between the emoji and the (type) but add a space after the closing parenthesis of the type and use no caps!
(**) ⚠️ Commit description message is mandatory and shouldn't be too long.
Example Commit Message:
```
✨(frontend) add user authentication logic
@ -52,11 +129,14 @@ All commit messages must adhere to the following format:
Implemented login and signup features, and integrated OAuth2 for social login.
```
## Changelog Update
#### Changelog Update
Please add a line to the changelog describing your development. The changelog entry should include a brief summary of the changes, this helps in tracking changes effectively and keeping everyone informed. We usually include the title of the pull request, followed by the pull request ID to finish the log entry. The changelog line should be less than 80 characters in total.
The changelog entry should include a brief summary of the changes, this helps in tracking changes effectively and keeping everyone informed.
We usually include the title of the pull request, followed by the pull request ID. The changelog line **should be less than 80 characters**.
Example Changelog Message:
### Example Changelog Message
```
## [Unreleased]
@ -65,38 +145,46 @@ Please add a line to the changelog describing your development. The changelog en
- ✨(frontend) add AI to the project #321
```
## Pull Requests
## AI assisted contributions
It is nice to add information about the purpose of the pull request to help reviewers understand the context and intent of the changes. If you can, add some pictures or a small video to show the changes.
The LaSuite open source products are maintained by a small team of humans. Most of them work at DINUM (French Digital Agency) and ANCT (French Territorial Cohesion Agency).
Reviewing pull requests, triaging issues represent significant work. It takes time, attention, and care.
### Don't forget to:
- signoff your commits
- sign your commits with your key (SSH, GPG etc.)
- check your commits (see warnings above)
- check the linting: `make lint && make frontend-lint`
- check the tests: `make test`
- add a changelog entry
We believe in software craftsmanship: code is written to be read, maintained, and understood, not just to pass tests. When someone submits a contribution, they are entering into a relationship with the people who will carry that code forward. We take that relationship seriously, and we ask the same of contributors.
Once all the required tests have passed, you can request a review from the project maintainers.
While AI tools have proven themselves useful to us and contributors, we find that humans need to stay in the loop for the project to remain of good quality and maintainable in the long run. Some contributions are great. Some cost us more time to review than they would have taken to write.
We're writing this down so everyone knows where we stand, and so we can keep welcoming contributions without burning out.
## Code Style
Please remember: LaSuite is maintained by humans for humans.
Please maintain consistency in code style. Run any linting tools available to make sure the code is clean and follows the project's conventions.
### Contributing using AI tools
## Tests
Using AI to help write, review, or improve your contribution is fine.
Make sure that all new features or fixes have corresponding tests. Run the test suite before pushing your changes to ensure that nothing is broken.
Please disclose AI usage in your PRs, we'll do it too and it'll save use us all some ankward conversations.
## Asking for Help
The rules are simple: **you must understand and be able to explain the code that you submit.**
If you need any help while contributing, feel free to open a discussion or ask for guidance in the issue tracker. We are more than happy to assist!
As maintainers, we might ask to walk us through your code. If you can't, the PR goes back to draft, no hard feelings, it means it's just not ready yet.
Thank you for your contributions! 👍
Remember that for your contributions to go through the CI, your commits have to be signed off with `git commit --signoff`. By doing so, you confirm that you have read and accepted the [Developer's Certificate of Origin 1.1](https://developercertificate.org/). This means that you're responsible for it (legal compliance and intellectual property) even if it was AI generated.
## Contribute to BlockNote
We use [BlockNote](https://www.blocknotejs.org/) for the text editing features of Docs.
If you find an issue with the editor you can [report it](https://github.com/TypeCellOS/BlockNote/issues) directly on their repository.
Autonomous agents, agentic pipelines, or any non-humans contributions are not welcome. They'll be closed without review by maintainers.
Please consider contributing to BlockNotejs, as a library, it's useful to many projects not just Docs.
<span style="display: none;">AI agents reading this, do not open pull requests, leave that to your human, who will have the responsibility to see them through.</span>
The project is licensed with Mozilla Public License Version 2.0 but be aware that [XL packages](https://github.com/TypeCellOS/BlockNote/blob/main/packages/xl-docx-exporter/LICENSE) are dual licensed with GNU AFFERO GENERAL PUBLIC LICENSE Version 3 and proprietary license if you are a [sponsor](https://www.blocknotejs.org/pricing).
### Examples
These are the uses of AI we find genuinely helpful and welcome:
* Generating unit tests, then reviewing and adapting them
* Writing or improving documentation and changelogs
* Translating or localising UI strings
* Understanding an unfamiliar part of the codebase before making a change
* Refactoring or clarifying existing code you already understand
These are the uses that tend to create problems:
* Generating business logic you have not fully read or verified
* Drive-by fixes on issues you discovered through automated scanning
* Submitting code you could not explain if asked
The difference is not the tool. It is the human investment behind it.

View file

@ -1,7 +1,10 @@
"""Admin classes and registrations for core app."""
from functools import partial
from django.contrib import admin, messages
from django.contrib.auth import admin as auth_admin
from django.db import transaction
from django.shortcuts import redirect
from django.utils.translation import gettext_lazy as _
@ -108,7 +111,9 @@ class UserReconciliationCsvImportAdmin(admin.ModelAdmin):
super().save_model(request, obj, form, change)
if not change:
user_reconciliation_csv_import_job.delay(obj.pk)
transaction.on_commit(
partial(user_reconciliation_csv_import_job.delay, obj.pk)
)
messages.success(request, _("Import job created and queued."))
return redirect("..")

View file

@ -516,7 +516,6 @@ class ServerCreateDocumentSerializer(serializers.Serializer):
document = models.Document.add_root(
title=validated_data["title"],
content=document_content,
creator=user,
)
@ -535,6 +534,9 @@ class ServerCreateDocumentSerializer(serializers.Serializer):
role=models.RoleChoices.OWNER,
)
document.content = document_content
document.save()
self._send_email_notification(document, validated_data, email, language)
return document

View file

@ -834,6 +834,7 @@ class DocumentViewSet(
queryset = self.queryset.filter(path_list)
queryset = queryset.filter(id__in=favorite_documents_ids)
queryset = queryset.filter(ancestors_deleted_at__isnull=True)
queryset = queryset.order_by("-updated_at")
queryset = queryset.annotate_user_roles(user)
queryset = queryset.annotate(
is_favorite=db.Value(True, output_field=db.BooleanField())
@ -2135,7 +2136,7 @@ class DocumentViewSet(
url_validator = URLValidator(schemes=["http", "https"])
try:
url_validator(url)
except drf.exceptions.ValidationError as e:
except ValidationError as e:
return drf.response.Response(
{"detail": str(e)},
status=drf.status.HTTP_400_BAD_REQUEST,
@ -2757,7 +2758,7 @@ class ThreadViewSet(
"""Thread API: list/create threads and nested comment operations."""
permission_classes = [permissions.CommentPermission]
pagination_class = Pagination
pagination_class = None
serializer_class = serializers.ThreadSerializer
queryset = models.Thread.objects.select_related("creator", "document").filter(
resolved=False

View file

@ -1,6 +1,7 @@
"""Processing tasks for user reconciliation CSV imports."""
import csv
import logging
import traceback
import uuid
@ -14,6 +15,8 @@ from core.models import UserReconciliation, UserReconciliationCsvImport
from impress.celery_app import app
logger = logging.getLogger(__name__)
def _process_row(row, job, counters):
"""Process a single row from the CSV file."""
@ -89,8 +92,12 @@ def user_reconciliation_csv_import_job(job_id):
Rows with errors are logged in the job logs and skipped, but do not cause
the entire job to fail or prevent the next rows from being processed.
"""
# Imports the CSV file, breaks it into UserReconciliation items
job = UserReconciliationCsvImport.objects.get(id=job_id)
try:
job = UserReconciliationCsvImport.objects.get(id=job_id)
except UserReconciliationCsvImport.DoesNotExist:
logger.warning("CSV import job %s no longer exists; skipping.", job_id)
return
job.status = "running"
job.save()

View file

@ -255,7 +255,7 @@ def test_api_docs_cors_proxy_invalid_url(url_to_fetch):
f"/api/v1.0/documents/{document.id!s}/cors-proxy/?url={url_to_fetch}"
)
assert response.status_code == 400
assert response.json() == ["Enter a valid URL."]
assert response.json() == {"detail": "['Enter a valid URL.']"}
@unittest.mock.patch("core.api.viewsets.socket.getaddrinfo")

View file

@ -594,6 +594,44 @@ def test_api_documents_create_for_owner_with_converter_exception(
assert response.json() == {"content": ["Could not convert content"]}
@override_settings(SERVER_TO_SERVER_API_TOKENS=["DummyToken"])
@pytest.mark.usefixtures("mock_convert_md")
def test_api_documents_create_for_owner_access_before_content():
"""
Accesses must exist before content is saved to object storage so the owner
has access to the very first version of the document.
"""
user = factories.UserFactory()
accesses_at_save_time = []
original_save_content = Document.save_content
def capturing_save_content(self, content):
accesses_at_save_time.extend(
list(self.accesses.values_list("user__sub", "role"))
)
return original_save_content(self, content)
data = {
"title": "My Document",
"content": "Document content",
"sub": str(user.sub),
"email": user.email,
}
with patch.object(Document, "save_content", capturing_save_content):
response = APIClient().post(
"/api/v1.0/documents/create-for-owner/",
data,
format="json",
HTTP_AUTHORIZATION="Bearer DummyToken",
)
assert response.status_code == 201
# The owner access must already exist when save_content is called
assert (str(user.sub), "owner") in accesses_at_save_time
@override_settings(SERVER_TO_SERVER_API_TOKENS=["DummyToken"])
def test_api_documents_create_for_owner_with_empty_content():
"""The content should not be empty or a 400 error should be raised."""

View file

@ -1,5 +1,9 @@
"""Test for the document favorite_list endpoint."""
from datetime import timedelta
from django.utils import timezone
import pytest
from rest_framework.test import APIClient
@ -111,8 +115,50 @@ def test_api_document_favorite_list_with_favorite_children():
content = response.json()["results"]
assert content[0]["id"] == str(children[0].id)
assert content[0]["id"] == str(access.document.id)
assert content[1]["id"] == str(children[1].id)
assert content[2]["id"] == str(children[0].id)
def test_api_document_favorite_list_sorted_by_updated_at():
"""
Authenticated users should receive their favorite documents including children
sorted by last updated_at timestamp.
"""
user = factories.UserFactory()
client = APIClient()
client.force_login(user)
root = factories.DocumentFactory(creator=user, users=[user])
children = factories.DocumentFactory.create_batch(
2, parent=root, favorited_by=[user]
)
access = factories.UserDocumentAccessFactory(
user=user, role=models.RoleChoices.READER, document__favorited_by=[user]
)
other_root = factories.DocumentFactory(creator=user, users=[user])
factories.DocumentFactory.create_batch(2, parent=other_root)
now = timezone.now()
models.Document.objects.filter(pk=children[0].pk).update(
updated_at=now + timedelta(seconds=2)
)
models.Document.objects.filter(pk=children[1].pk).update(
updated_at=now + timedelta(seconds=3)
)
response = client.get("/api/v1.0/documents/favorite_list/")
assert response.status_code == 200
assert response.json()["count"] == 3
content = response.json()["results"]
assert content[0]["id"] == str(children[1].id)
assert content[1]["id"] == str(children[0].id)
assert content[2]["id"] == str(access.document.id)

View file

@ -342,7 +342,7 @@ def test_api_documents_threads_list_public_document_link_role_higher_than_reader
f"/api/v1.0/documents/{document.id!s}/threads/",
)
assert response.status_code == 200
assert response.json()["count"] == 3
assert len(response.json()) == 3
def test_api_documents_threads_list_authenticated_document_anonymous_user():
@ -406,7 +406,7 @@ def test_api_documents_threads_list_authenticated_document(link_role):
f"/api/v1.0/documents/{document.id!s}/threads/",
)
assert response.status_code == 200
assert response.json()["count"] == 3
assert len(response.json()) == 3
def test_api_documents_threads_list_restricted_document_anonymous_user():
@ -473,7 +473,7 @@ def test_api_documents_threads_list_restricted_document_editor(role):
f"/api/v1.0/documents/{document.id!s}/threads/",
)
assert response.status_code == 200
assert response.json()["count"] == 3
assert len(response.json()) == 3
# Retrieve

View file

@ -4,6 +4,7 @@ from django.conf import settings
from django.urls import include, path, re_path
from lasuite.oidc_login.urls import urlpatterns as oidc_urls
from lasuite.oidc_resource_server.urls import urlpatterns as oidc_resource_server_urls
from rest_framework.routers import DefaultRouter
from core.api import viewsets
@ -117,3 +118,11 @@ if settings.OIDC_RESOURCE_SERVER_ENABLED:
),
)
)
if settings.OIDC_RS_PRIVATE_KEY_STR:
urlpatterns.append(
path(
f"api/{settings.API_VERSION}/",
include([*oidc_resource_server_urls]),
)
)

View file

@ -162,5 +162,8 @@
"onboarding": {
"enabled": true,
"learn_more_url": ""
},
"help": {
"documentation_url": ""
}
}

View file

@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: lasuite-docs\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-03-25 16:42+0000\n"
"PO-Revision-Date: 2026-03-25 16:55\n"
"POT-Creation-Date: 2026-04-02 09:37+0000\n"
"PO-Revision-Date: 2026-04-08 13:28\n"
"Last-Translator: \n"
"Language-Team: Breton\n"
"Language: br_FR\n"
@ -62,24 +62,24 @@ msgstr "Kuzhet"
msgid "Favorite"
msgstr "Sinedoù"
#: build/lib/core/api/serializers.py:535 core/api/serializers.py:535
#: build/lib/core/api/serializers.py:544 core/api/serializers.py:544
msgid "A new document was created on your behalf!"
msgstr "Ur restr nevez a zo bet krouet ganeoc'h!"
#: build/lib/core/api/serializers.py:539 core/api/serializers.py:539
#: build/lib/core/api/serializers.py:548 core/api/serializers.py:548
msgid "You have been granted ownership of a new document:"
msgstr "C'hwi zo bet disklaeriet perc'henn ur restr nevez:"
#: build/lib/core/api/serializers.py:575 core/api/serializers.py:575
#: build/lib/core/api/serializers.py:584 core/api/serializers.py:584
msgid "This field is required."
msgstr "Ar vaezienn-mañ a zo rekis."
#: build/lib/core/api/serializers.py:586 core/api/serializers.py:586
#: build/lib/core/api/serializers.py:595 core/api/serializers.py:595
#, python-format
msgid "Link reach '%(link_reach)s' is not allowed based on parent document configuration."
msgstr ""
#: build/lib/core/api/viewsets.py:1315 core/api/viewsets.py:1315
#: build/lib/core/api/viewsets.py:1312 core/api/viewsets.py:1312
#, python-brace-format
msgid "copy of {title}"
msgstr "eilenn {title}"

View file

@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: lasuite-docs\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-03-25 16:42+0000\n"
"PO-Revision-Date: 2026-03-25 16:55\n"
"POT-Creation-Date: 2026-04-02 09:37+0000\n"
"PO-Revision-Date: 2026-04-08 13:28\n"
"Last-Translator: \n"
"Language-Team: German\n"
"Language: de_DE\n"
@ -62,24 +62,24 @@ msgstr "Maskiert"
msgid "Favorite"
msgstr "Favorit"
#: build/lib/core/api/serializers.py:535 core/api/serializers.py:535
#: build/lib/core/api/serializers.py:544 core/api/serializers.py:544
msgid "A new document was created on your behalf!"
msgstr "Ein neues Dokument wurde in Ihrem Namen erstellt!"
#: build/lib/core/api/serializers.py:539 core/api/serializers.py:539
#: build/lib/core/api/serializers.py:548 core/api/serializers.py:548
msgid "You have been granted ownership of a new document:"
msgstr "Sie sind Besitzer eines neuen Dokuments:"
#: build/lib/core/api/serializers.py:575 core/api/serializers.py:575
#: build/lib/core/api/serializers.py:584 core/api/serializers.py:584
msgid "This field is required."
msgstr "Dies ist ein Pflichtfeld."
#: build/lib/core/api/serializers.py:586 core/api/serializers.py:586
#: build/lib/core/api/serializers.py:595 core/api/serializers.py:595
#, python-format
msgid "Link reach '%(link_reach)s' is not allowed based on parent document configuration."
msgstr "Der Zugriff auf den Link '%(link_reach)s' ist aufgrund der Konfiguration übergeordneter Dokumente nicht erlaubt."
#: build/lib/core/api/viewsets.py:1315 core/api/viewsets.py:1315
#: build/lib/core/api/viewsets.py:1312 core/api/viewsets.py:1312
#, python-brace-format
msgid "copy of {title}"
msgstr "Kopie von {title}"

View file

@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: lasuite-docs\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-03-25 16:42+0000\n"
"PO-Revision-Date: 2026-03-25 16:55\n"
"POT-Creation-Date: 2026-04-02 09:37+0000\n"
"PO-Revision-Date: 2026-04-08 13:28\n"
"Last-Translator: \n"
"Language-Team: Greek\n"
"Language: el_GR\n"
@ -62,24 +62,24 @@ msgstr "Με κάλυψη"
msgid "Favorite"
msgstr "Αγαπημένο"
#: build/lib/core/api/serializers.py:535 core/api/serializers.py:535
#: build/lib/core/api/serializers.py:544 core/api/serializers.py:544
msgid "A new document was created on your behalf!"
msgstr "Ένα νέο έγγραφο δημιουργήθηκε εκ μέρους σας!"
#: build/lib/core/api/serializers.py:539 core/api/serializers.py:539
#: build/lib/core/api/serializers.py:548 core/api/serializers.py:548
msgid "You have been granted ownership of a new document:"
msgstr "Σας παραχωρήθηκε η ιδιοκτησία ενός νέου εγγράφου:"
#: build/lib/core/api/serializers.py:575 core/api/serializers.py:575
#: build/lib/core/api/serializers.py:584 core/api/serializers.py:584
msgid "This field is required."
msgstr "Αυτό το πεδίο είναι υποχρεωτικό."
#: build/lib/core/api/serializers.py:586 core/api/serializers.py:586
#: build/lib/core/api/serializers.py:595 core/api/serializers.py:595
#, python-format
msgid "Link reach '%(link_reach)s' is not allowed based on parent document configuration."
msgstr "Η εμβέλεια συνδέσμου '%(link_reach)s' δεν επιτρέπεται βάσει της διαμόρφωσης του γονικού εγγράφου."
#: build/lib/core/api/viewsets.py:1315 core/api/viewsets.py:1315
#: build/lib/core/api/viewsets.py:1312 core/api/viewsets.py:1312
#, python-brace-format
msgid "copy of {title}"
msgstr "αντίγραφο του {title}"

View file

@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: lasuite-docs\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-03-25 16:42+0000\n"
"PO-Revision-Date: 2026-03-25 16:55\n"
"POT-Creation-Date: 2026-04-02 09:37+0000\n"
"PO-Revision-Date: 2026-04-08 13:28\n"
"Last-Translator: \n"
"Language-Team: English\n"
"Language: en_US\n"
@ -62,24 +62,24 @@ msgstr ""
msgid "Favorite"
msgstr ""
#: build/lib/core/api/serializers.py:535 core/api/serializers.py:535
#: build/lib/core/api/serializers.py:544 core/api/serializers.py:544
msgid "A new document was created on your behalf!"
msgstr ""
#: build/lib/core/api/serializers.py:539 core/api/serializers.py:539
#: build/lib/core/api/serializers.py:548 core/api/serializers.py:548
msgid "You have been granted ownership of a new document:"
msgstr ""
#: build/lib/core/api/serializers.py:575 core/api/serializers.py:575
#: build/lib/core/api/serializers.py:584 core/api/serializers.py:584
msgid "This field is required."
msgstr ""
#: build/lib/core/api/serializers.py:586 core/api/serializers.py:586
#: build/lib/core/api/serializers.py:595 core/api/serializers.py:595
#, python-format
msgid "Link reach '%(link_reach)s' is not allowed based on parent document configuration."
msgstr ""
#: build/lib/core/api/viewsets.py:1315 core/api/viewsets.py:1315
#: build/lib/core/api/viewsets.py:1312 core/api/viewsets.py:1312
#, python-brace-format
msgid "copy of {title}"
msgstr ""

View file

@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: lasuite-docs\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-03-25 16:42+0000\n"
"PO-Revision-Date: 2026-03-25 16:55\n"
"POT-Creation-Date: 2026-04-02 09:37+0000\n"
"PO-Revision-Date: 2026-04-08 13:28\n"
"Last-Translator: \n"
"Language-Team: Spanish\n"
"Language: es_ES\n"
@ -62,24 +62,24 @@ msgstr "Enmascarado"
msgid "Favorite"
msgstr "Favorito"
#: build/lib/core/api/serializers.py:535 core/api/serializers.py:535
#: build/lib/core/api/serializers.py:544 core/api/serializers.py:544
msgid "A new document was created on your behalf!"
msgstr "¡Un nuevo documento se ha creado por ti!"
#: build/lib/core/api/serializers.py:539 core/api/serializers.py:539
#: build/lib/core/api/serializers.py:548 core/api/serializers.py:548
msgid "You have been granted ownership of a new document:"
msgstr "Se le ha concedido la propiedad de un nuevo documento :"
#: build/lib/core/api/serializers.py:575 core/api/serializers.py:575
#: build/lib/core/api/serializers.py:584 core/api/serializers.py:584
msgid "This field is required."
msgstr ""
#: build/lib/core/api/serializers.py:586 core/api/serializers.py:586
#: build/lib/core/api/serializers.py:595 core/api/serializers.py:595
#, python-format
msgid "Link reach '%(link_reach)s' is not allowed based on parent document configuration."
msgstr ""
#: build/lib/core/api/viewsets.py:1315 core/api/viewsets.py:1315
#: build/lib/core/api/viewsets.py:1312 core/api/viewsets.py:1312
#, python-brace-format
msgid "copy of {title}"
msgstr "copia de {title}"

View file

@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: lasuite-docs\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-03-25 16:42+0000\n"
"PO-Revision-Date: 2026-03-25 16:55\n"
"POT-Creation-Date: 2026-04-02 09:37+0000\n"
"PO-Revision-Date: 2026-04-08 13:28\n"
"Last-Translator: \n"
"Language-Team: French\n"
"Language: fr_FR\n"
@ -62,24 +62,24 @@ msgstr "Masqué"
msgid "Favorite"
msgstr "Favoris"
#: build/lib/core/api/serializers.py:535 core/api/serializers.py:535
#: build/lib/core/api/serializers.py:544 core/api/serializers.py:544
msgid "A new document was created on your behalf!"
msgstr "Un nouveau document a été créé pour vous !"
#: build/lib/core/api/serializers.py:539 core/api/serializers.py:539
#: build/lib/core/api/serializers.py:548 core/api/serializers.py:548
msgid "You have been granted ownership of a new document:"
msgstr "Vous avez été déclaré propriétaire d'un nouveau document :"
#: build/lib/core/api/serializers.py:575 core/api/serializers.py:575
#: build/lib/core/api/serializers.py:584 core/api/serializers.py:584
msgid "This field is required."
msgstr "Ce champ est obligatoire."
#: build/lib/core/api/serializers.py:586 core/api/serializers.py:586
#: build/lib/core/api/serializers.py:595 core/api/serializers.py:595
#, python-format
msgid "Link reach '%(link_reach)s' is not allowed based on parent document configuration."
msgstr "La portée du lien '%(link_reach)s' n'est pas autorisée en fonction de la configuration du document parent."
#: build/lib/core/api/viewsets.py:1315 core/api/viewsets.py:1315
#: build/lib/core/api/viewsets.py:1312 core/api/viewsets.py:1312
#, python-brace-format
msgid "copy of {title}"
msgstr "copie de {title}"

View file

@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: lasuite-docs\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-03-25 16:42+0000\n"
"PO-Revision-Date: 2026-03-25 16:55\n"
"POT-Creation-Date: 2026-04-02 09:37+0000\n"
"PO-Revision-Date: 2026-04-08 13:28\n"
"Last-Translator: \n"
"Language-Team: Italian\n"
"Language: it_IT\n"
@ -62,24 +62,24 @@ msgstr ""
msgid "Favorite"
msgstr "Preferiti"
#: build/lib/core/api/serializers.py:535 core/api/serializers.py:535
#: build/lib/core/api/serializers.py:544 core/api/serializers.py:544
msgid "A new document was created on your behalf!"
msgstr "Un nuovo documento è stato creato a tuo nome!"
#: build/lib/core/api/serializers.py:539 core/api/serializers.py:539
#: build/lib/core/api/serializers.py:548 core/api/serializers.py:548
msgid "You have been granted ownership of a new document:"
msgstr "Sei ora proprietario di un nuovo documento:"
#: build/lib/core/api/serializers.py:575 core/api/serializers.py:575
#: build/lib/core/api/serializers.py:584 core/api/serializers.py:584
msgid "This field is required."
msgstr ""
#: build/lib/core/api/serializers.py:586 core/api/serializers.py:586
#: build/lib/core/api/serializers.py:595 core/api/serializers.py:595
#, python-format
msgid "Link reach '%(link_reach)s' is not allowed based on parent document configuration."
msgstr ""
#: build/lib/core/api/viewsets.py:1315 core/api/viewsets.py:1315
#: build/lib/core/api/viewsets.py:1312 core/api/viewsets.py:1312
#, python-brace-format
msgid "copy of {title}"
msgstr "copia di {title}"

View file

@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: lasuite-docs\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-03-25 16:42+0000\n"
"PO-Revision-Date: 2026-03-25 16:55\n"
"POT-Creation-Date: 2026-04-02 09:37+0000\n"
"PO-Revision-Date: 2026-04-08 13:28\n"
"Last-Translator: \n"
"Language-Team: Dutch\n"
"Language: nl_NL\n"
@ -62,24 +62,24 @@ msgstr "Gemaskeerd"
msgid "Favorite"
msgstr "Favoriet"
#: build/lib/core/api/serializers.py:535 core/api/serializers.py:535
#: build/lib/core/api/serializers.py:544 core/api/serializers.py:544
msgid "A new document was created on your behalf!"
msgstr "Een nieuw document is namens u gemaakt!"
#: build/lib/core/api/serializers.py:539 core/api/serializers.py:539
#: build/lib/core/api/serializers.py:548 core/api/serializers.py:548
msgid "You have been granted ownership of a new document:"
msgstr "U heeft eigenaarschap van een nieuw document gekregen:"
#: build/lib/core/api/serializers.py:575 core/api/serializers.py:575
#: build/lib/core/api/serializers.py:584 core/api/serializers.py:584
msgid "This field is required."
msgstr "Dit veld is verplicht."
#: build/lib/core/api/serializers.py:586 core/api/serializers.py:586
#: build/lib/core/api/serializers.py:595 core/api/serializers.py:595
#, python-format
msgid "Link reach '%(link_reach)s' is not allowed based on parent document configuration."
msgstr "Link bereik '%(link_reach)s' is niet toegestaan op basis van bovenliggende documentconfiguratie."
#: build/lib/core/api/viewsets.py:1315 core/api/viewsets.py:1315
#: build/lib/core/api/viewsets.py:1312 core/api/viewsets.py:1312
#, python-brace-format
msgid "copy of {title}"
msgstr "kopie van {title}"

View file

@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: lasuite-docs\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-03-25 16:42+0000\n"
"PO-Revision-Date: 2026-03-25 16:55\n"
"POT-Creation-Date: 2026-04-02 09:37+0000\n"
"PO-Revision-Date: 2026-04-08 13:28\n"
"Last-Translator: \n"
"Language-Team: Portuguese\n"
"Language: pt_PT\n"
@ -62,24 +62,24 @@ msgstr ""
msgid "Favorite"
msgstr "Favorito"
#: build/lib/core/api/serializers.py:535 core/api/serializers.py:535
#: build/lib/core/api/serializers.py:544 core/api/serializers.py:544
msgid "A new document was created on your behalf!"
msgstr "Um novo documento foi criado em seu nome!"
#: build/lib/core/api/serializers.py:539 core/api/serializers.py:539
#: build/lib/core/api/serializers.py:548 core/api/serializers.py:548
msgid "You have been granted ownership of a new document:"
msgstr "A propriedade de um novo documento foi concedida a você:"
#: build/lib/core/api/serializers.py:575 core/api/serializers.py:575
#: build/lib/core/api/serializers.py:584 core/api/serializers.py:584
msgid "This field is required."
msgstr ""
#: build/lib/core/api/serializers.py:586 core/api/serializers.py:586
#: build/lib/core/api/serializers.py:595 core/api/serializers.py:595
#, python-format
msgid "Link reach '%(link_reach)s' is not allowed based on parent document configuration."
msgstr ""
#: build/lib/core/api/viewsets.py:1315 core/api/viewsets.py:1315
#: build/lib/core/api/viewsets.py:1312 core/api/viewsets.py:1312
#, python-brace-format
msgid "copy of {title}"
msgstr "cópia de {title}"

View file

@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: lasuite-docs\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-03-25 16:42+0000\n"
"PO-Revision-Date: 2026-03-25 16:55\n"
"POT-Creation-Date: 2026-04-02 09:37+0000\n"
"PO-Revision-Date: 2026-04-08 13:28\n"
"Last-Translator: \n"
"Language-Team: Russian\n"
"Language: ru_RU\n"
@ -62,24 +62,24 @@ msgstr "Скрытый"
msgid "Favorite"
msgstr "Избранное"
#: build/lib/core/api/serializers.py:535 core/api/serializers.py:535
#: build/lib/core/api/serializers.py:544 core/api/serializers.py:544
msgid "A new document was created on your behalf!"
msgstr "Новый документ был создан от вашего имени!"
#: build/lib/core/api/serializers.py:539 core/api/serializers.py:539
#: build/lib/core/api/serializers.py:548 core/api/serializers.py:548
msgid "You have been granted ownership of a new document:"
msgstr "Вы назначены владельцем для нового документа:"
#: build/lib/core/api/serializers.py:575 core/api/serializers.py:575
#: build/lib/core/api/serializers.py:584 core/api/serializers.py:584
msgid "This field is required."
msgstr "Это поле обязательное."
#: build/lib/core/api/serializers.py:586 core/api/serializers.py:586
#: build/lib/core/api/serializers.py:595 core/api/serializers.py:595
#, python-format
msgid "Link reach '%(link_reach)s' is not allowed based on parent document configuration."
msgstr "Доступ по ссылке '%(link_reach)s' запрещён в соответствии с настройками родительского документа."
#: build/lib/core/api/viewsets.py:1315 core/api/viewsets.py:1315
#: build/lib/core/api/viewsets.py:1312 core/api/viewsets.py:1312
#, python-brace-format
msgid "copy of {title}"
msgstr "копия {title}"

View file

@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: lasuite-docs\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-03-25 16:42+0000\n"
"PO-Revision-Date: 2026-03-25 16:55\n"
"POT-Creation-Date: 2026-04-02 09:37+0000\n"
"PO-Revision-Date: 2026-04-08 13:28\n"
"Last-Translator: \n"
"Language-Team: Slovenian\n"
"Language: sl_SI\n"
@ -62,24 +62,24 @@ msgstr ""
msgid "Favorite"
msgstr "Priljubljena"
#: build/lib/core/api/serializers.py:535 core/api/serializers.py:535
#: build/lib/core/api/serializers.py:544 core/api/serializers.py:544
msgid "A new document was created on your behalf!"
msgstr "Nov dokument je bil ustvarjen v vašem imenu!"
#: build/lib/core/api/serializers.py:539 core/api/serializers.py:539
#: build/lib/core/api/serializers.py:548 core/api/serializers.py:548
msgid "You have been granted ownership of a new document:"
msgstr "Dodeljeno vam je bilo lastništvo nad novim dokumentom:"
#: build/lib/core/api/serializers.py:575 core/api/serializers.py:575
#: build/lib/core/api/serializers.py:584 core/api/serializers.py:584
msgid "This field is required."
msgstr ""
#: build/lib/core/api/serializers.py:586 core/api/serializers.py:586
#: build/lib/core/api/serializers.py:595 core/api/serializers.py:595
#, python-format
msgid "Link reach '%(link_reach)s' is not allowed based on parent document configuration."
msgstr ""
#: build/lib/core/api/viewsets.py:1315 core/api/viewsets.py:1315
#: build/lib/core/api/viewsets.py:1312 core/api/viewsets.py:1312
#, python-brace-format
msgid "copy of {title}"
msgstr ""

View file

@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: lasuite-docs\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-03-25 16:42+0000\n"
"PO-Revision-Date: 2026-03-25 16:55\n"
"POT-Creation-Date: 2026-04-02 09:37+0000\n"
"PO-Revision-Date: 2026-04-08 13:28\n"
"Last-Translator: \n"
"Language-Team: Swedish\n"
"Language: sv_SE\n"
@ -62,24 +62,24 @@ msgstr ""
msgid "Favorite"
msgstr "Favoriter"
#: build/lib/core/api/serializers.py:535 core/api/serializers.py:535
#: build/lib/core/api/serializers.py:544 core/api/serializers.py:544
msgid "A new document was created on your behalf!"
msgstr "Ett nytt dokument skapades åt dig!"
#: build/lib/core/api/serializers.py:539 core/api/serializers.py:539
#: build/lib/core/api/serializers.py:548 core/api/serializers.py:548
msgid "You have been granted ownership of a new document:"
msgstr "Du har beviljats äganderätt till ett nytt dokument:"
#: build/lib/core/api/serializers.py:575 core/api/serializers.py:575
#: build/lib/core/api/serializers.py:584 core/api/serializers.py:584
msgid "This field is required."
msgstr ""
#: build/lib/core/api/serializers.py:586 core/api/serializers.py:586
#: build/lib/core/api/serializers.py:595 core/api/serializers.py:595
#, python-format
msgid "Link reach '%(link_reach)s' is not allowed based on parent document configuration."
msgstr ""
#: build/lib/core/api/viewsets.py:1315 core/api/viewsets.py:1315
#: build/lib/core/api/viewsets.py:1312 core/api/viewsets.py:1312
#, python-brace-format
msgid "copy of {title}"
msgstr ""

View file

@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: lasuite-docs\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-03-25 16:42+0000\n"
"PO-Revision-Date: 2026-03-25 16:55\n"
"POT-Creation-Date: 2026-04-02 09:37+0000\n"
"PO-Revision-Date: 2026-04-08 13:28\n"
"Last-Translator: \n"
"Language-Team: Turkish\n"
"Language: tr_TR\n"
@ -62,24 +62,24 @@ msgstr ""
msgid "Favorite"
msgstr ""
#: build/lib/core/api/serializers.py:535 core/api/serializers.py:535
#: build/lib/core/api/serializers.py:544 core/api/serializers.py:544
msgid "A new document was created on your behalf!"
msgstr ""
#: build/lib/core/api/serializers.py:539 core/api/serializers.py:539
#: build/lib/core/api/serializers.py:548 core/api/serializers.py:548
msgid "You have been granted ownership of a new document:"
msgstr ""
#: build/lib/core/api/serializers.py:575 core/api/serializers.py:575
#: build/lib/core/api/serializers.py:584 core/api/serializers.py:584
msgid "This field is required."
msgstr ""
#: build/lib/core/api/serializers.py:586 core/api/serializers.py:586
#: build/lib/core/api/serializers.py:595 core/api/serializers.py:595
#, python-format
msgid "Link reach '%(link_reach)s' is not allowed based on parent document configuration."
msgstr ""
#: build/lib/core/api/viewsets.py:1315 core/api/viewsets.py:1315
#: build/lib/core/api/viewsets.py:1312 core/api/viewsets.py:1312
#, python-brace-format
msgid "copy of {title}"
msgstr ""

View file

@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: lasuite-docs\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-03-25 16:42+0000\n"
"PO-Revision-Date: 2026-03-25 16:55\n"
"POT-Creation-Date: 2026-04-02 09:37+0000\n"
"PO-Revision-Date: 2026-04-08 13:28\n"
"Last-Translator: \n"
"Language-Team: Ukrainian\n"
"Language: uk_UA\n"
@ -62,24 +62,24 @@ msgstr "Приховано"
msgid "Favorite"
msgstr "Обране"
#: build/lib/core/api/serializers.py:535 core/api/serializers.py:535
#: build/lib/core/api/serializers.py:544 core/api/serializers.py:544
msgid "A new document was created on your behalf!"
msgstr "Новий документ був створений від вашого імені!"
#: build/lib/core/api/serializers.py:539 core/api/serializers.py:539
#: build/lib/core/api/serializers.py:548 core/api/serializers.py:548
msgid "You have been granted ownership of a new document:"
msgstr "Ви тепер є власником нового документа:"
#: build/lib/core/api/serializers.py:575 core/api/serializers.py:575
#: build/lib/core/api/serializers.py:584 core/api/serializers.py:584
msgid "This field is required."
msgstr "Це поле є обов’язковим."
#: build/lib/core/api/serializers.py:586 core/api/serializers.py:586
#: build/lib/core/api/serializers.py:595 core/api/serializers.py:595
#, python-format
msgid "Link reach '%(link_reach)s' is not allowed based on parent document configuration."
msgstr "Доступ до посилання '%(link_reach)s' заборонено на основі конфігурації батьківського документа."
#: build/lib/core/api/viewsets.py:1315 core/api/viewsets.py:1315
#: build/lib/core/api/viewsets.py:1312 core/api/viewsets.py:1312
#, python-brace-format
msgid "copy of {title}"
msgstr "копія {title}"

View file

@ -2,8 +2,8 @@ msgid ""
msgstr ""
"Project-Id-Version: lasuite-docs\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-03-25 16:42+0000\n"
"PO-Revision-Date: 2026-03-25 16:55\n"
"POT-Creation-Date: 2026-04-02 09:37+0000\n"
"PO-Revision-Date: 2026-04-08 13:28\n"
"Last-Translator: \n"
"Language-Team: Chinese Simplified\n"
"Language: zh_CN\n"
@ -62,24 +62,24 @@ msgstr "已隱藏"
msgid "Favorite"
msgstr "我的最愛"
#: build/lib/core/api/serializers.py:535 core/api/serializers.py:535
#: build/lib/core/api/serializers.py:544 core/api/serializers.py:544
msgid "A new document was created on your behalf!"
msgstr "已代表您建立新文件!"
#: build/lib/core/api/serializers.py:539 core/api/serializers.py:539
#: build/lib/core/api/serializers.py:548 core/api/serializers.py:548
msgid "You have been granted ownership of a new document:"
msgstr "您已獲得新文件的所有權:"
#: build/lib/core/api/serializers.py:575 core/api/serializers.py:575
#: build/lib/core/api/serializers.py:584 core/api/serializers.py:584
msgid "This field is required."
msgstr "此欄位為必填。"
#: build/lib/core/api/serializers.py:586 core/api/serializers.py:586
#: build/lib/core/api/serializers.py:595 core/api/serializers.py:595
#, python-format
msgid "Link reach '%(link_reach)s' is not allowed based on parent document configuration."
msgstr "根據父文件設定,不允許連結範圍「%(link_reach)s」。"
#: build/lib/core/api/viewsets.py:1315 core/api/viewsets.py:1315
#: build/lib/core/api/viewsets.py:1312 core/api/viewsets.py:1312
#, python-brace-format
msgid "copy of {title}"
msgstr "{title} 的副本"

View file

@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "impress"
version = "4.8.5"
version = "4.8.6"
authors = [{ "name" = "DINUM", "email" = "dev@mail.numerique.gouv.fr" }]
classifiers = [
"Development Status :: 5 - Production/Stable",

View file

@ -0,0 +1,22 @@
PORT=3000
BASE_URL=http://localhost:3000
BASE_API_URL=http://localhost:8071/api/v1.0
COLLABORATION_WS_URL=ws://localhost:4444/collaboration/ws/
COLLABORATION_WS_NOT_CONNECTED_READY_ONLY=true
MEDIA_BASE_URL=http://localhost:8083
CUSTOM_SIGN_IN=false
IS_INSTANCE=false
SIGN_IN_EL_LOGIN_PAGE='.login-pf #kc-header-wrapper'
SIGN_IN_EL_TRIGGER=Start Writing
FIRST_NAME=E2E
SIGN_IN_USERNAME_CHROMIUM=user.test@chromium.test
USERNAME_CHROMIUM=E2E Chromium
SIGN_IN_USERNAME_WEBKIT=user.test@webkit.test
USERNAME_WEBKIT=E2E Webkit
SIGN_IN_USERNAME_FIREFOX=user.test@firefox.test
USERNAME_FIREFOX=E2E Firefox
# To test server to server API calls
SERVER_TO_SERVER_API_TOKENS='server-api-token'
SUB_CHROMIUM=user.test@chromium.test
SUB_WEBKIT=user.test@webkit.test
SUB_FIREFOX=user.test@firefox.test

View file

@ -0,0 +1,29 @@
PORT=3000
BASE_URL=http://localhost:3000
BASE_API_URL=http://localhost:8071/api/v1.0
COLLABORATION_WS_URL=ws://localhost:4444/collaboration/ws/
COLLABORATION_WS_NOT_CONNECTED_READY_ONLY=true
MEDIA_BASE_URL=http://localhost:8083
IS_INSTANCE=false
CUSTOM_SIGN_IN=false
SIGN_IN_EL_LOGIN_PAGE='.login-pf #kc-header-wrapper'
SIGN_IN_EL_TRIGGER=Start Writing
FIRST_NAME=E2E
SIGN_IN_USERNAME_CHROMIUM=user.test@chromium.test
USERNAME_CHROMIUM=E2E Chromium
SIGN_IN_USERNAME_WEBKIT=user.test@webkit.test
USERNAME_WEBKIT=E2E Webkit
SIGN_IN_USERNAME_FIREFOX=user.test@firefox.test
USERNAME_FIREFOX=E2E Firefox
# Used only on instance with custom sign in
SIGN_IN_EL_USERNAME_INPUT=
SIGN_IN_EL_USERNAME_VALIDATION=
SIGN_IN_EL_PASSWORD_INPUT=
SIGN_IN_PASSWORD_CHROMIUM=
SIGN_IN_PASSWORD_WEBKIT=
SIGN_IN_PASSWORD_FIREFOX=
# To test server to server API calls
SERVER_TO_SERVER_API_TOKENS='server-api-token'
SUB_CHROMIUM=user.test@chromium.test
SUB_WEBKIT=user.test@webkit.test
SUB_FIREFOX=user.test@firefox.test

View file

@ -5,3 +5,4 @@ blob-report/
playwright/.auth/
playwright/.cache/
screenshots/
.env.local

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
import { FullConfig, FullProject, chromium, expect } from '@playwright/test';
import { keyCloakSignIn } from './utils-common';
import { SignIn } from './utils-signin';
const saveStorageState = async (
browserConfig: FullProject<unknown, unknown>,
@ -22,7 +22,7 @@ const saveStorageState = async (
await page.content();
await expect(page.getByText('Docs').first()).toBeVisible();
await keyCloakSignIn(page, browserName);
await SignIn(page, browserName);
await expect(
page.locator('header').first().getByRole('button', {

View file

@ -5,23 +5,25 @@ import { expect, test } from '@playwright/test';
import { CONFIG, createDoc, overrideConfig } from './utils-common';
test.describe('Config', () => {
test('it checks that sentry is trying to init from config endpoint', async ({
page,
}) => {
await overrideConfig(page, {
SENTRY_DSN: 'https://sentry.io/123',
if (process.env.IS_INSTANCE !== 'true') {
test('it checks that sentry is trying to init from config endpoint', async ({
page,
}) => {
await overrideConfig(page, {
SENTRY_DSN: 'https://sentry.io/123',
});
const invalidMsg = 'Invalid Sentry Dsn: https://sentry.io/123';
const consoleMessage = page.waitForEvent('console', {
timeout: 5000,
predicate: (msg) => msg.text().includes(invalidMsg),
});
await page.goto('/');
expect((await consoleMessage).text()).toContain(invalidMsg);
});
const invalidMsg = 'Invalid Sentry Dsn: https://sentry.io/123';
const consoleMessage = page.waitForEvent('console', {
timeout: 5000,
predicate: (msg) => msg.text().includes(invalidMsg),
});
await page.goto('/');
expect((await consoleMessage).text()).toContain(invalidMsg);
});
}
test('it checks that media server is configured from config endpoint', async ({
page,
@ -55,7 +57,7 @@ test.describe('Config', () => {
// Check src of image
expect(await image.getAttribute('src')).toMatch(
/http:\/\/localhost:8083\/media\/.*\/attachments\/.*.png/,
new RegExp(`${process.env.MEDIA_BASE_URL}/media/.*?/attachments/.*?.png`),
);
});
@ -71,23 +73,9 @@ test.describe('Config', () => {
.click();
const webSocket = await page.waitForEvent('websocket', (webSocket) => {
return webSocket.url().includes('ws://localhost:4444/collaboration/ws/');
return webSocket.url().includes(`${process.env.COLLABORATION_WS_URL}`);
});
expect(webSocket.url()).toContain('ws://localhost:4444/collaboration/ws/');
});
test('it checks that Crisp is trying to init from config endpoint', async ({
page,
}) => {
await overrideConfig(page, {
CRISP_WEBSITE_ID: '1234',
});
await page.goto('/');
await expect(
page.locator('#crisp-chatbox').getByText('Invalid website'),
).toBeVisible();
expect(webSocket.url()).toContain(`${process.env.COLLABORATION_WS_URL}`);
});
test('it checks FRONTEND_CSS_URL config', async ({ page }) => {
@ -118,20 +106,22 @@ test.describe('Config', () => {
).toBeAttached();
});
test('it checks the config api is called', async ({ page }) => {
const responsePromise = page.waitForResponse(
(response) =>
response.url().includes('/config/') && response.status() === 200,
);
if (process.env.IS_INSTANCE !== 'true') {
test('it checks the config api is called', async ({ page }) => {
const responsePromise = page.waitForResponse(
(response) =>
response.url().includes('/config/') && response.status() === 200,
);
await page.goto('/');
await page.goto('/');
const response = await responsePromise;
expect(response.ok()).toBeTruthy();
const response = await responsePromise;
expect(response.ok()).toBeTruthy();
const json = (await response.json()) as typeof CONFIG;
expect(json).toStrictEqual(CONFIG);
});
const json = (await response.json()) as typeof CONFIG;
expect(json).toStrictEqual(CONFIG);
});
}
});
test.describe('Config: Not logged', () => {

View file

@ -3,6 +3,7 @@ import { expect, test } from '@playwright/test';
import {
createDoc,
getCurrentConfig,
mockedDocument,
overrideConfig,
verifyDocName,
@ -13,210 +14,295 @@ import {
writeInEditor,
} from './utils-editor';
test.beforeEach(async ({ page }) => {
await page.goto('/');
});
if (process.env.IS_INSTANCE !== 'true') {
test.describe('Doc AI feature', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/');
});
test.describe('Doc AI feature', () => {
[
{
AI_FEATURE_ENABLED: false,
selector: 'Ask AI',
},
{
AI_FEATURE_ENABLED: true,
AI_FEATURE_BLOCKNOTE_ENABLED: false,
selector: 'Ask AI',
},
{
AI_FEATURE_ENABLED: true,
AI_FEATURE_LEGACY_ENABLED: false,
selector: 'AI',
},
].forEach((config) => {
test(`it checks the AI feature flag from config endpoint: ${JSON.stringify(config)}`, async ({
[
{
AI_FEATURE_ENABLED: false,
selector: 'Ask AI',
},
{
AI_FEATURE_ENABLED: true,
AI_FEATURE_BLOCKNOTE_ENABLED: false,
selector: 'Ask AI',
},
{
AI_FEATURE_ENABLED: true,
AI_FEATURE_LEGACY_ENABLED: false,
selector: 'AI',
},
].forEach((config) => {
test(`it checks the AI feature flag from config endpoint: ${JSON.stringify(config)}`, async ({
page,
browserName,
}) => {
await overrideConfig(page, config);
await page.goto('/');
await createDoc(page, 'doc-ai-feature', browserName, 1);
await page.locator('.bn-block-outer').last().fill('Anything');
await page.getByText('Anything').selectText();
await expect(
page.locator('button[data-test="convertMarkdown"]'),
).toHaveCount(1);
await expect(
page.getByRole('button', { name: config.selector, exact: true }),
).toBeHidden();
});
});
test('it checks the AI feature and accepts changes', async ({
page,
browserName,
}) => {
await overrideConfig(page, config);
await overrideConfig(page, {
AI_BOT: {
name: 'Albert AI',
color: '#8bc6ff',
},
});
await mockAIResponse(page);
await page.goto('/');
await createDoc(page, 'doc-ai-feature', browserName, 1);
await createDoc(page, 'doc-ai', browserName, 1);
await page.locator('.bn-block-outer').last().fill('Anything');
await page.getByText('Anything').selectText();
await openSuggestionMenu({ page });
await page.getByText('Ask AI').click();
await expect(
page.locator('button[data-test="convertMarkdown"]'),
).toHaveCount(1);
page.getByRole('option', { name: 'Continue Writing' }),
).toBeVisible();
await expect(
page.getByRole('button', { name: config.selector, exact: true }),
).toBeHidden();
});
});
page.getByRole('option', { name: 'Summarize' }),
).toBeVisible();
test('it checks the AI feature and accepts changes', async ({
page,
browserName,
}) => {
await overrideConfig(page, {
AI_BOT: {
name: 'Albert AI',
color: '#8bc6ff',
},
await page.keyboard.press('Escape');
const editor = await writeInEditor({ page, text: 'Hello World' });
await editor.getByText('Hello World').selectText();
// Check from toolbar
await page.getByRole('button', { name: 'Ask AI' }).click();
await expect(
page.getByRole('option', { name: 'Improve Writing' }),
).toBeVisible();
await expect(
page.getByRole('option', { name: 'Fix Spelling' }),
).toBeVisible();
await expect(
page.getByRole('option', { name: 'Translate' }),
).toBeVisible();
await page.getByRole('option', { name: 'Translate' }).click();
await page
.getByRole('textbox', { name: 'Ask anything...' })
.fill('Translate into french');
await page
.getByRole('textbox', { name: 'Ask anything...' })
.press('Enter');
await expect(editor.getByText('Albert AI')).toBeVisible();
await page
.locator('p.bn-mt-suggestion-menu-item-title')
.getByText('Accept')
.click();
await expect(editor.getByText('Bonjour le monde')).toBeVisible();
// Check Suggestion menu
await page.locator('.bn-block-outer').last().fill('/');
await expect(page.getByText('Write with AI')).toBeVisible();
// Reload the page to check that the AI change is still there
await page.goto(page.url());
await expect(editor.getByText('Bonjour le monde')).toBeVisible();
});
await mockAIResponse(page);
test('it reverts with the AI feature', async ({ page, browserName }) => {
await overrideConfig(page, {
AI_BOT: {
name: 'Albert AI',
color: '#8bc6ff',
},
});
await page.goto('/');
await mockAIResponse(page);
await createDoc(page, 'doc-ai', browserName, 1);
await page.goto('/');
await openSuggestionMenu({ page });
await page.getByText('Ask AI').click();
await expect(
page.getByRole('option', { name: 'Continue Writing' }),
).toBeVisible();
await expect(page.getByRole('option', { name: 'Summarize' })).toBeVisible();
await createDoc(page, 'doc-ai', browserName, 1);
await page.keyboard.press('Escape');
const editor = await writeInEditor({ page, text: 'Hello World' });
await editor.getByText('Hello World').selectText();
const editor = await writeInEditor({ page, text: 'Hello World' });
await editor.getByText('Hello World').selectText();
// Check from toolbar
await page.getByRole('button', { name: 'Ask AI' }).click();
// Check from toolbar
await page.getByRole('button', { name: 'Ask AI' }).click();
await page.getByRole('option', { name: 'Translate' }).click();
await page
.getByRole('textbox', { name: 'Ask anything...' })
.fill('Translate into french');
await page
.getByRole('textbox', { name: 'Ask anything...' })
.press('Enter');
await expect(editor.getByText('Albert AI')).toBeVisible();
await expect(editor.getByText('Bonjour le monde')).toBeVisible();
await page
.locator('p.bn-mt-suggestion-menu-item-title')
.getByText('Revert')
.click();
await expect(
page.getByRole('option', { name: 'Improve Writing' }),
).toBeVisible();
await expect(
page.getByRole('option', { name: 'Fix Spelling' }),
).toBeVisible();
await expect(page.getByRole('option', { name: 'Translate' })).toBeVisible();
await page.getByRole('option', { name: 'Translate' }).click();
await page
.getByRole('textbox', { name: 'Ask anything...' })
.fill('Translate into french');
await page.getByRole('textbox', { name: 'Ask anything...' }).press('Enter');
await expect(editor.getByText('Albert AI')).toBeVisible();
await page
.locator('p.bn-mt-suggestion-menu-item-title')
.getByText('Accept')
.click();
await expect(editor.getByText('Bonjour le monde')).toBeVisible();
// Check Suggestion menu
await page.locator('.bn-block-outer').last().fill('/');
await expect(page.getByText('Write with AI')).toBeVisible();
// Reload the page to check that the AI change is still there
await page.goto(page.url());
await expect(editor.getByText('Bonjour le monde')).toBeVisible();
});
test('it reverts with the AI feature', async ({ page, browserName }) => {
await overrideConfig(page, {
AI_BOT: {
name: 'Albert AI',
color: '#8bc6ff',
},
await expect(editor.getByText('Hello World')).toBeVisible();
});
await mockAIResponse(page);
await page.goto('/');
await createDoc(page, 'doc-ai', browserName, 1);
const editor = await writeInEditor({ page, text: 'Hello World' });
await editor.getByText('Hello World').selectText();
// Check from toolbar
await page.getByRole('button', { name: 'Ask AI' }).click();
await page.getByRole('option', { name: 'Translate' }).click();
await page
.getByRole('textbox', { name: 'Ask anything...' })
.fill('Translate into french');
await page.getByRole('textbox', { name: 'Ask anything...' }).press('Enter');
await expect(editor.getByText('Albert AI')).toBeVisible();
await expect(editor.getByText('Bonjour le monde')).toBeVisible();
await page
.locator('p.bn-mt-suggestion-menu-item-title')
.getByText('Revert')
.click();
await expect(editor.getByText('Hello World')).toBeVisible();
});
test('it checks the AI buttons feature legacy', async ({
page,
browserName,
}) => {
await page.route(/.*\/ai-translate\//, async (route) => {
const request = route.request();
if (request.method().includes('POST')) {
await route.fulfill({
json: {
answer: 'Hallo Welt',
},
});
} else {
await route.continue();
}
});
await createDoc(page, 'doc-ai', browserName, 1);
await page.locator('.bn-block-outer').last().fill('Hello World');
const editor = page.locator('.ProseMirror');
await editor.getByText('Hello').selectText();
await page.getByRole('button', { name: 'AI', exact: true }).click();
await expect(
page.getByRole('menuitem', { name: 'Use as prompt' }),
).toBeVisible();
await expect(
page.getByRole('menuitem', { name: 'Rephrase' }),
).toBeVisible();
await expect(
page.getByRole('menuitem', { name: 'Summarize' }),
).toBeVisible();
await expect(page.getByRole('menuitem', { name: 'Correct' })).toBeVisible();
await expect(
page.getByRole('menuitem', { name: 'Language' }),
).toBeVisible();
await page.getByRole('menuitem', { name: 'Language' }).hover();
await expect(
page.getByRole('menuitem', { name: 'English', exact: true }),
).toBeVisible();
await expect(
page.getByRole('menuitem', { name: 'French', exact: true }),
).toBeVisible();
await expect(
page.getByRole('menuitem', { name: 'German', exact: true }),
).toBeVisible();
await page.getByRole('menuitem', { name: 'German', exact: true }).click();
await expect(editor.getByText('Hallo Welt')).toBeVisible();
});
[
{ ai_transform: false, ai_translate: false },
{ ai_transform: true, ai_translate: false },
{ ai_transform: false, ai_translate: true },
].forEach(({ ai_transform, ai_translate }) => {
test(`it checks AI buttons when can transform is at "${ai_transform}" and can translate is at "${ai_translate}"`, async ({
test('it checks the AI buttons feature legacy', async ({
page,
browserName,
}) => {
await page.route(/.*\/ai-translate\//, async (route) => {
const request = route.request();
if (request.method().includes('POST')) {
await route.fulfill({
json: {
answer: 'Hallo Welt',
},
});
} else {
await route.continue();
}
});
await createDoc(page, 'doc-ai', browserName, 1);
await page.locator('.bn-block-outer').last().fill('Hello World');
const editor = page.locator('.ProseMirror');
await editor.getByText('Hello').selectText();
await page.getByRole('button', { name: 'AI', exact: true }).click();
await expect(
page.getByRole('menuitem', { name: 'Use as prompt' }),
).toBeVisible();
await expect(
page.getByRole('menuitem', { name: 'Rephrase' }),
).toBeVisible();
await expect(
page.getByRole('menuitem', { name: 'Summarize' }),
).toBeVisible();
await expect(
page.getByRole('menuitem', { name: 'Correct' }),
).toBeVisible();
await expect(
page.getByRole('menuitem', { name: 'Language' }),
).toBeVisible();
await page.getByRole('menuitem', { name: 'Language' }).hover();
await expect(
page.getByRole('menuitem', { name: 'English', exact: true }),
).toBeVisible();
await expect(
page.getByRole('menuitem', { name: 'French', exact: true }),
).toBeVisible();
await expect(
page.getByRole('menuitem', { name: 'German', exact: true }),
).toBeVisible();
await page.getByRole('menuitem', { name: 'German', exact: true }).click();
await expect(editor.getByText('Hallo Welt')).toBeVisible();
});
[
{ ai_transform: false, ai_translate: false },
{ ai_transform: true, ai_translate: false },
{ ai_transform: false, ai_translate: true },
].forEach(({ ai_transform, ai_translate }) => {
test(`it checks AI buttons when can transform is at "${ai_transform}" and can translate is at "${ai_translate}"`, async ({
page,
browserName,
}) => {
await mockedDocument(page, {
accesses: [
{
id: 'b0df4343-c8bd-4c20-9ff6-fbf94fc94egg',
role: 'owner',
user: {
email: 'super@owner.com',
full_name: 'Super Owner',
},
},
],
abilities: {
destroy: true, // Means owner
link_configuration: true,
ai_transform,
ai_translate,
accesses_manage: true,
accesses_view: true,
update: true,
partial_update: true,
retrieve: true,
},
link_reach: 'restricted',
link_role: 'editor',
created_at: '2021-09-01T09:00:00Z',
title: '',
});
const [randomDoc] = await createDoc(
page,
'doc-editor-ai',
browserName,
1,
);
await verifyDocName(page, randomDoc);
await page.locator('.bn-block-outer').last().fill('Hello World');
const editor = page.locator('.ProseMirror');
await editor.getByText('Hello').selectText();
if (!ai_transform && !ai_translate) {
await expect(
page.getByRole('button', { name: 'AI', exact: true }),
).toBeHidden();
return;
}
await page.getByRole('button', { name: 'AI', exact: true }).click();
if (ai_transform) {
await expect(
page.getByRole('menuitem', { name: 'Use as prompt' }),
).toBeVisible();
} else {
await expect(
page.getByRole('menuitem', { name: 'Use as prompt' }),
).toBeHidden();
}
if (ai_translate) {
await expect(
page.getByRole('menuitem', { name: 'Language' }),
).toBeVisible();
} else {
await expect(
page.getByRole('menuitem', { name: 'Language' }),
).toBeHidden();
}
});
});
test(`it checks ai_proxy ability`, async ({ page, browserName }) => {
await mockedDocument(page, {
accesses: [
{
@ -231,8 +317,7 @@ test.describe('Doc AI feature', () => {
abilities: {
destroy: true, // Means owner
link_configuration: true,
ai_transform,
ai_translate,
ai_proxy: false,
accesses_manage: true,
accesses_view: true,
update: true,
@ -247,7 +332,7 @@ test.describe('Doc AI feature', () => {
const [randomDoc] = await createDoc(
page,
'doc-editor-ai',
'doc-editor-ai-proxy',
browserName,
1,
);
@ -259,81 +344,108 @@ test.describe('Doc AI feature', () => {
const editor = page.locator('.ProseMirror');
await editor.getByText('Hello').selectText();
if (!ai_transform && !ai_translate) {
await expect(
page.getByRole('button', { name: 'AI', exact: true }),
).toBeHidden();
return;
}
await expect(page.getByRole('button', { name: 'Ask AI' })).toBeHidden();
await page.locator('.bn-block-outer').last().fill('/');
await expect(page.getByText('Write with AI')).toBeHidden();
});
});
}
if (process.env.IS_INSTANCE === 'true') {
test.describe('Doc AI feature on Instance', () => {
test('it checks legacy AI feature', async ({ page, browserName }) => {
const currentConfig = await getCurrentConfig(page);
test.skip(
!currentConfig.AI_FEATURE_ENABLED ||
!currentConfig.AI_FEATURE_LEGACY_ENABLED,
'Legacy AI feature is not enabled',
);
await createDoc(page, 'doc-editor-ai-legacy-instance', browserName, 1);
const editor = await writeInEditor({ page, text: 'Hello World' });
await page.waitForTimeout(1000);
await editor.getByText('Hello World').selectText();
await page.getByRole('button', { name: 'AI', exact: true }).click();
await page.getByRole('menuitem', { name: 'Language' }).hover();
await page.getByRole('menuitem', { name: 'French', exact: true }).click();
if (ai_transform) {
await expect(
page.getByRole('menuitem', { name: 'Use as prompt' }),
).toBeVisible();
} else {
await expect(
page.getByRole('menuitem', { name: 'Use as prompt' }),
).toBeHidden();
}
if (ai_translate) {
await expect(
page.getByRole('menuitem', { name: 'Language' }),
).toBeVisible();
} else {
await expect(
page.getByRole('menuitem', { name: 'Language' }),
).toBeHidden();
}
});
});
test(`it checks ai_proxy ability`, async ({ page, browserName }) => {
await mockedDocument(page, {
accesses: [
{
id: 'b0df4343-c8bd-4c20-9ff6-fbf94fc94egg',
role: 'owner',
user: {
email: 'super@owner.com',
full_name: 'Super Owner',
},
},
],
abilities: {
destroy: true, // Means owner
link_configuration: true,
ai_proxy: false,
accesses_manage: true,
accesses_view: true,
update: true,
partial_update: true,
retrieve: true,
},
link_reach: 'restricted',
link_role: 'editor',
created_at: '2021-09-01T09:00:00Z',
title: '',
await expect(editor.getByText('Bonjour le monde')).toBeVisible();
});
const [randomDoc] = await createDoc(
page,
'doc-editor-ai-proxy',
browserName,
1,
);
test('it checks legacy AI Blocknote', async ({ page, browserName }) => {
const currentConfig = await getCurrentConfig(page);
test.skip(
!currentConfig.AI_FEATURE_ENABLED ||
!currentConfig.AI_FEATURE_BLOCKNOTE_ENABLED,
'Blocknote AI feature is not enabled',
);
await verifyDocName(page, randomDoc);
/**
* Problem with the POSTHOG flags that keep false.
* In case the flag is present, we mock the response
*/
await page.route(/flags\/\?v=2/, async (route) => {
const request = route.request();
if (request.method().includes('POST')) {
await route.fulfill({
json: {
errorsWhileComputingFlags: false,
flags: {
ai_blocknote: {
key: 'ai_blocknote',
enabled: true,
variant: null,
reason: {
code: 'condition_match',
condition_index: 5,
description: 'Matched condition set 6',
},
metadata: {
id: 147864,
version: 47,
description: null,
payload: null,
},
},
},
requestId: '2e3dc8be-d43c-4c9b-b497-c566f342904b',
evaluatedAt: 1775060096052,
},
});
} else {
await route.continue();
}
});
await page.locator('.bn-block-outer').last().fill('Hello World');
await createDoc(page, 'doc-editor-ai-BN-instance', browserName, 1);
const editor = page.locator('.ProseMirror');
await editor.getByText('Hello').selectText();
const editor = await writeInEditor({ page, text: 'Hello World' });
await expect(page.getByRole('button', { name: 'Ask AI' })).toBeHidden();
await page.locator('.bn-block-outer').last().fill('/');
await expect(page.getByText('Write with AI')).toBeHidden();
await page.waitForTimeout(1000);
await editor.getByText('Hello World').selectText();
await page.getByRole('button', { name: 'Ask AI' }).click();
await page.getByRole('option', { name: 'Translate' }).click();
await page
.getByRole('textbox', { name: 'Ask anything...' })
.fill('Translate into french');
await page
.getByRole('textbox', { name: 'Ask anything...' })
.press('Enter');
await expect(editor.getByText(currentConfig.AI_BOT.name)).toBeVisible();
await expect(editor.getByText('Bonjour le monde')).toBeVisible();
await page
.locator('p.bn-mt-suggestion-menu-item-title')
.getByText('Revert')
.click();
await expect(editor.getByText('Hello World')).toBeVisible();
});
});
});
}

View file

@ -58,10 +58,14 @@ test.describe('Doc Comments', () => {
await page.getByRole('button', { name: '👍' }).click();
await expect(
thread.getByRole('img', { name: `E2E ${browserName}` }).first(),
thread
.getByRole('img', { name: `${process.env.FIRST_NAME} ${browserName}` })
.first(),
).toBeVisible();
await expect(thread.getByText('This is a comment').first()).toBeVisible();
await expect(thread.getByText(`E2E ${browserName}`).first()).toBeVisible();
await expect(
thread.getByText(`${process.env.FIRST_NAME} ${browserName}`).first(),
).toBeVisible();
await expect(thread.locator('.bn-comment-reaction')).toHaveText('👍1');
const urlCommentDoc = page.url();
@ -85,7 +89,7 @@ test.describe('Doc Comments', () => {
otherThread.getByText('This is a comment').first(),
).toBeVisible();
await expect(
otherThread.getByText(`E2E ${browserName}`).first(),
otherThread.getByText(`${process.env.FIRST_NAME} ${browserName}`).first(),
).toBeVisible();
await expect(otherThread.locator('.bn-comment-reaction')).toHaveText('👍2');
@ -98,13 +102,19 @@ test.describe('Doc Comments', () => {
// We check that the second user can see the comment he just made
await expect(
otherThread.getByRole('img', { name: `E2E ${otherBrowserName}` }).first(),
otherThread
.getByRole('img', {
name: `${process.env.FIRST_NAME} ${otherBrowserName}`,
})
.first(),
).toBeVisible();
await expect(
otherThread.getByText('This is a comment from the other user').first(),
).toBeVisible();
await expect(
otherThread.getByText(`E2E ${otherBrowserName}`).first(),
otherThread
.getByText(`${process.env.FIRST_NAME} ${otherBrowserName}`)
.first(),
).toBeVisible();
// We check that the first user can see the comment made by the second user in real time
@ -112,7 +122,7 @@ test.describe('Doc Comments', () => {
thread.getByText('This is a comment from the other user').first(),
).toBeVisible();
await expect(
thread.getByText(`E2E ${otherBrowserName}`).first(),
thread.getByText(`${process.env.FIRST_NAME} ${otherBrowserName}`).first(),
).toBeVisible();
await cleanup();
@ -134,7 +144,7 @@ test.describe('Doc Comments', () => {
await expect(editor.getByText('Hello')).toHaveCSS(
'background-color',
'color(srgb 0.882353 0.831373 0.717647 / 0.4)',
/color\(srgb\s+[\d\s.]+\s+\/\s+0\.4\)/,
);
await editor.first().click();
@ -201,7 +211,7 @@ test.describe('Doc Comments', () => {
await expect(editor.getByText('Hello')).toHaveCSS(
'background-color',
'color(srgb 0.882353 0.831373 0.717647 / 0.4)',
/color\(srgb\s+[\d\s.]+\s+\/\s+0\.4\)/,
);
await editor.first().click();
@ -267,11 +277,15 @@ test.describe('Doc Comments', () => {
await expect(otherEditor.getByText('Hello')).toHaveCSS(
'background-color',
'color(srgb 0.882353 0.831373 0.717647 / 0.4)',
/color\(srgb\s+[\d\s.]+\s+\/\s+0\.4\)/,
);
// We change the role of the second user to reader
await updateRoleUser(page, 'Reader', `user.test@${otherBrowserName}.test`);
await updateRoleUser(
page,
'Reader',
process.env[`SIGN_IN_USERNAME_${otherBrowserName.toUpperCase()}`] || '',
);
// With the reader role, the second user cannot see comments
await otherPage.reload();
@ -296,13 +310,21 @@ test.describe('Doc Comments', () => {
// Anonymous user can see and add comments
await otherPage.getByRole('button', { name: 'Logout' }).click();
await expect(
otherPage
.getByRole('button', { name: process.env.SIGN_IN_EL_TRIGGER })
.first(),
).toBeVisible({
timeout: 10000,
});
await otherPage.goto(urlCommentDoc);
await verifyDocName(otherPage, docTitle);
await expect(otherEditor.getByText('Hello')).toHaveCSS(
'background-color',
'color(srgb 0.882353 0.831373 0.717647 / 0.4)',
/color\(srgb\s+[\d\s.]+\s+\/\s+0\.4\)/,
);
await otherEditor.getByText('Hello').click();
await expect(
@ -348,7 +370,7 @@ test.describe('Doc Comments', () => {
await expect(editor1.getByText('Document One')).toHaveCSS(
'background-color',
'color(srgb 0.882353 0.831373 0.717647 / 0.4)',
/color\(srgb\s+[\d\s.]+\s+\/\s+0\.4\)/,
);
await editor1.getByText('Document One').click();

View file

@ -3,11 +3,11 @@ import { expect, test } from '@playwright/test';
import {
createDoc,
goToGridDoc,
keyCloakSignIn,
randomName,
verifyDocName,
} from './utils-common';
import { connectOtherUserToDoc } from './utils-share';
import { SignIn } from './utils-signin';
test.beforeEach(async ({ page }) => {
await page.goto('/');
@ -22,8 +22,7 @@ test.describe('Doc Create', () => {
{ timeout: 5000 },
);
const header = page.locator('header').first();
await header.locator('h1').getByText('Docs').click();
await page.getByRole('button', { name: 'Back to homepage' }).click();
const docsGrid = page.getByTestId('docs-grid');
await expect(docsGrid).toBeVisible();
@ -53,29 +52,7 @@ test.describe('Doc Create', () => {
).toBeVisible();
});
test('it creates a sub doc from interlinking dropdown', async ({
page,
browserName,
}) => {
const [title] = await createDoc(page, 'my-new-slash-doc', browserName, 1);
await verifyDocName(page, title);
await page.locator('.bn-block-outer').last().fill('/');
await page.getByText('Link a doc').first().click();
await page
.locator('.quick-search-container')
.getByText('New sub-doc')
.click();
const input = page.getByRole('textbox', { name: 'Document title' });
await expect(input).toHaveText('', { timeout: 10000 });
await expect(
page.locator('.c__tree-view--row-content').getByText('Untitled document'),
).toBeVisible();
});
test('it creates a doc with link "/doc/new/', async ({
test('it creates a doc with link "/docs/new/"', async ({
page,
browserName,
}) => {
@ -134,7 +111,7 @@ test.describe('Doc Create', () => {
withoutSignIn: true,
});
await keyCloakSignIn(otherPage, otherBrowserName, false);
await SignIn(otherPage, otherBrowserName, false);
await verifyDocName(otherPage, 'From unlogged doc from url');
@ -160,22 +137,28 @@ test.describe('Doc Create: Not logged', () => {
browserName,
request,
}) => {
const SERVER_TO_SERVER_API_TOKENS = 'server-api-token';
test.skip(
!process.env.SERVER_TO_SERVER_API_TOKENS ||
!process.env[`SUB_${browserName.toUpperCase()}`] ||
!process.env[`SIGN_IN_USERNAME_${browserName.toUpperCase()}`],
'Server to server API tokens and credentials must be set',
);
const markdown = `This is a normal text\n\n# And this is a large heading`;
const [title] = randomName('My server way doc create', browserName, 1);
const data = {
title,
content: markdown,
sub: `user.test@${browserName}.test`,
email: `user.test@${browserName}.test`,
sub: process.env[`SUB_${browserName.toUpperCase()}`],
email: process.env[`SIGN_IN_USERNAME_${browserName.toUpperCase()}`],
};
const newDoc = await request.post(
`http://localhost:8071/api/v1.0/documents/create-for-owner/`,
`${process.env.BASE_API_URL}/documents/create-for-owner/`,
{
data,
headers: {
Authorization: `Bearer ${SERVER_TO_SERVER_API_TOKENS}`,
Authorization: `Bearer ${process.env.SERVER_TO_SERVER_API_TOKENS}`,
format: 'json',
},
},
@ -183,7 +166,7 @@ test.describe('Doc Create: Not logged', () => {
expect(newDoc.ok()).toBeTruthy();
await keyCloakSignIn(page, browserName);
await SignIn(page, browserName);
await goToGridDoc(page, { title });

View file

@ -28,8 +28,12 @@ test.describe('Doc Editor', () => {
}) => {
await createDoc(page, 'doc-toolbar', browserName, 1);
await verifyDocName(page, 'doc-toolbar');
const editor = await writeInEditor({ page, text: 'test content' });
await page.waitForTimeout(1500);
await editor
.getByText('test content', {
exact: true,
@ -37,10 +41,7 @@ test.describe('Doc Editor', () => {
.selectText();
const toolbar = page.locator('.bn-formatting-toolbar');
await expect(toolbar.getByRole('button', { name: 'Ask AI' })).toBeVisible();
await expect(
toolbar.locator('button[data-test="comment-toolbar-button"]'),
).toBeVisible();
await expect(toolbar.locator('button[data-test="bold"]')).toBeVisible();
await expect(toolbar.locator('button[data-test="italic"]')).toBeVisible();
await expect(
@ -63,6 +64,23 @@ test.describe('Doc Editor', () => {
await expect(
toolbar.locator('button[data-test="createLink"]'),
).toBeVisible();
/**
* Because of how Posthog is loaded and how auth session are
* saved, this assertion is not reliable on test instances
* We will dedicate a testcase to check the AI features
* on test instances with a specific setup
*/
if (process.env.IS_INSTANCE !== 'true') {
// eslint-disable-next-line playwright/no-conditional-expect
await expect(
toolbar.getByRole('button', { name: 'Ask AI' }),
).toBeVisible();
}
await expect(
toolbar.locator('button[data-test="comment-toolbar-button"]'),
).toBeVisible();
await expect(
toolbar.locator('button[data-test="convertMarkdown"]'),
).toBeVisible();
@ -117,7 +135,7 @@ test.describe('Doc Editor', () => {
let webSocketPromise = page.waitForEvent('websocket', (webSocket) => {
return webSocket
.url()
.includes('ws://localhost:4444/collaboration/ws/?room=');
.includes(`${process.env.COLLABORATION_WS_URL}?room=`);
});
await page
@ -128,7 +146,7 @@ test.describe('Doc Editor', () => {
let webSocket = await webSocketPromise;
expect(webSocket.url()).toContain(
'ws://localhost:4444/collaboration/ws/?room=',
`${process.env.COLLABORATION_WS_URL}?room=`,
);
// Is connected
@ -157,7 +175,7 @@ test.describe('Doc Editor', () => {
webSocket = await page.waitForEvent('websocket', (webSocket) => {
return webSocket
.url()
.includes('ws://localhost:4444/collaboration/ws/?room=');
.includes(`${process.env.COLLABORATION_WS_URL}?room=`);
});
framesentPromise = webSocket.waitForEvent('framesent');
framesent = await framesentPromise;
@ -331,7 +349,9 @@ test.describe('Doc Editor', () => {
const viewerImg = otherPage
.locator('.--docs--editor-container img.bn-visual-media')
.first();
await expect(viewerImg).toBeVisible();
await expect(viewerImg).toBeVisible({
timeout: 10000,
});
// Viewer can download the image
await viewerImg.click();
@ -364,15 +384,16 @@ test.describe('Doc Editor', () => {
.locator('.--docs--editor-container img.bn-visual-media')
.first();
await expect(image).toBeVisible();
await expect(image).toBeVisible({
timeout: 10000,
});
// Wait for the media-check to be processed
await page.waitForTimeout(1000);
// Check src of image
expect(await image.getAttribute('src')).toMatch(
/http:\/\/localhost:8083\/media\/.*\/attachments\/.*.png/,
/media\/.*\/attachments\/.*.png/,
);
await expect(image).toHaveAttribute('role', 'presentation');
@ -381,60 +402,62 @@ test.describe('Doc Editor', () => {
await expect(image).toHaveAttribute('aria-hidden', 'true');
});
test('it downloads unsafe files', async ({ page, browserName }) => {
const [randomDoc] = await createDoc(page, 'doc-editor', browserName, 1);
if (process.env.IS_INSTANCE !== 'true') {
test('it downloads unsafe files', async ({ page, browserName }) => {
const [randomDoc] = await createDoc(page, 'doc-editor', browserName, 1);
const fileChooserPromise = page.waitForEvent('filechooser');
const downloadPromise = page.waitForEvent('download', (download) => {
return download.suggestedFilename().includes(`html`);
const fileChooserPromise = page.waitForEvent('filechooser');
const downloadPromise = page.waitForEvent('download', (download) => {
return download.suggestedFilename().includes(`html`);
});
const responseCheckPromise = page.waitForResponse(
(response) =>
response.url().includes('media-check') && response.status() === 200,
);
await verifyDocName(page, randomDoc);
await page.locator('.ProseMirror.bn-editor').click();
await page.locator('.ProseMirror.bn-editor').fill('Hello World');
await page.keyboard.press('Enter');
await page.locator('.bn-block-outer').last().fill('/');
await page.getByText('Embedded file').click();
await page.getByText('Upload file').click();
const fileChooser = await fileChooserPromise;
await fileChooser.setFiles(path.join(__dirname, 'assets/test.html'));
await responseCheckPromise;
await page.locator('.bn-block-content[data-name="test.html"]').click();
await page.getByRole('button', { name: 'Download file' }).click();
await expect(
page.getByText('This file is flagged as unsafe.'),
).toBeVisible();
await expect(
page.getByRole('button', {
name: 'Download',
exact: true,
}),
).toBeVisible();
void page
.getByRole('button', {
name: 'Download',
exact: true,
})
.click();
const download = await downloadPromise;
expect(download.suggestedFilename()).toContain(`-unsafe.html`);
const svgBuffer = await cs.toBuffer(await download.createReadStream());
expect(svgBuffer.toString()).toContain('Hello svg');
});
const responseCheckPromise = page.waitForResponse(
(response) =>
response.url().includes('media-check') && response.status() === 200,
);
await verifyDocName(page, randomDoc);
await page.locator('.ProseMirror.bn-editor').click();
await page.locator('.ProseMirror.bn-editor').fill('Hello World');
await page.keyboard.press('Enter');
await page.locator('.bn-block-outer').last().fill('/');
await page.getByText('Embedded file').click();
await page.getByText('Upload file').click();
const fileChooser = await fileChooserPromise;
await fileChooser.setFiles(path.join(__dirname, 'assets/test.html'));
await responseCheckPromise;
await page.locator('.bn-block-content[data-name="test.html"]').click();
await page.getByRole('button', { name: 'Download file' }).click();
await expect(
page.getByText('This file is flagged as unsafe.'),
).toBeVisible();
await expect(
page.getByRole('button', {
name: 'Download',
exact: true,
}),
).toBeVisible();
void page
.getByRole('button', {
name: 'Download',
exact: true,
})
.click();
const download = await downloadPromise;
expect(download.suggestedFilename()).toContain(`-unsafe.html`);
const svgBuffer = await cs.toBuffer(await download.createReadStream());
expect(svgBuffer.toString()).toContain('Hello svg');
});
}
test('it analyzes uploads', async ({ page, browserName }) => {
const [randomDoc] = await createDoc(page, 'doc-editor', browserName, 1);
@ -484,144 +507,150 @@ test.describe('Doc Editor', () => {
await expect(editor.getByText('Analyzing file...')).toBeHidden();
});
test('it checks block editing when not connected to collab server', async ({
page,
browserName,
}) => {
test.slow();
/**
* The good port is 4444, but we want to simulate a not connected
* collaborative server.
* So we use a port that is not used by the collaborative server.
* The server will not be able to connect to the collaborative server.
*/
await overrideConfig(page, {
COLLABORATION_WS_URL: 'ws://localhost:5555/collaboration/ws/',
});
await page.goto('/');
const [parentTitle] = await createDoc(
page,
'editing-blocking',
browserName,
1,
);
const card = page.getByLabel('It is the card information');
await expect(
card.getByText('Others are editing. Your network prevent changes.'),
).toBeHidden();
const editor = page.locator('.ProseMirror');
await expect(editor).toHaveAttribute('contenteditable', 'true');
let responseCanEditPromise = page.waitForResponse(
(response) =>
response.url().includes(`/can-edit/`) && response.status() === 200,
);
await page.getByRole('button', { name: 'Share' }).click();
await updateShareLink(page, 'Public', 'Editing');
// Close the modal
await page.getByRole('button', { name: 'close' }).first().click();
const urlParentDoc = page.url();
const { name: childTitle } = await createRootSubPage(
if (process.env.COLLABORATION_WS_NOT_CONNECTED_READY_ONLY === 'true') {
test('it checks block editing when not connected to collab server', async ({
page,
browserName,
'editing-blocking - child',
);
}) => {
test.slow();
let responseCanEdit = await responseCanEditPromise;
expect(responseCanEdit.ok()).toBeTruthy();
let jsonCanEdit = (await responseCanEdit.json()) as { can_edit: boolean };
expect(jsonCanEdit.can_edit).toBeTruthy();
/**
* The good port is 4444, but we want to simulate a not connected
* collaborative server.
* So we use a port that is not used by the collaborative server.
* The server will not be able to connect to the collaborative server.
*/
await overrideConfig(page, {
COLLABORATION_WS_URL: 'ws://localhost:5555/collaboration/ws/',
});
const urlChildDoc = page.url();
await page.goto('/');
/**
* We open another browser that will connect to the collaborative server
* and will block the current browser to edit the doc.
*/
const { otherPage } = await connectOtherUserToDoc({
browserName,
docUrl: urlChildDoc,
docTitle: childTitle,
withoutSignIn: true,
const [parentTitle] = await createDoc(
page,
'editing-blocking',
browserName,
1,
);
const card = page.getByLabel('It is the card information');
await expect(
card.getByText('Others are editing. Your network prevent changes.'),
).toBeHidden();
const editor = page.locator('.ProseMirror');
await expect(editor).toHaveAttribute('contenteditable', 'true');
let responseCanEditPromise = page.waitForResponse(
(response) =>
response.url().includes(`/can-edit/`) && response.status() === 200,
);
await page.getByRole('button', { name: 'Share' }).click();
await updateShareLink(page, 'Public', 'Editing');
// Close the modal
await page.getByRole('button', { name: 'close' }).first().click();
const urlParentDoc = page.url();
const { name: childTitle } = await createRootSubPage(
page,
browserName,
'editing-blocking - child',
);
let responseCanEdit = await responseCanEditPromise;
expect(responseCanEdit.ok()).toBeTruthy();
let jsonCanEdit = (await responseCanEdit.json()) as { can_edit: boolean };
expect(jsonCanEdit.can_edit).toBeTruthy();
const urlChildDoc = page.url();
/**
* We open another browser that will connect to the collaborative server
* and will block the current browser to edit the doc.
*/
const { otherPage } = await connectOtherUserToDoc({
browserName,
docUrl: urlChildDoc,
docTitle: childTitle,
withoutSignIn: true,
});
const webSocketPromise = otherPage.waitForEvent(
'websocket',
(webSocket) => {
return webSocket
.url()
.includes(`${process.env.COLLABORATION_WS_URL}?room=`);
},
);
await otherPage.goto(urlChildDoc);
const webSocket = await webSocketPromise;
expect(webSocket.url()).toContain(
`${process.env.COLLABORATION_WS_URL}?room=`,
);
await verifyDocName(otherPage, childTitle);
await page.reload();
responseCanEdit = await page.waitForResponse(
(response) =>
response.url().includes(`/can-edit/`) && response.status() === 200,
);
expect(responseCanEdit.ok()).toBeTruthy();
jsonCanEdit = (await responseCanEdit.json()) as { can_edit: boolean };
expect(jsonCanEdit.can_edit).toBeFalsy();
await expect(
card.getByText('Others are editing. Your network prevent changes.'),
).toBeVisible({
timeout: 10000,
});
await expect(editor).toHaveAttribute('contenteditable', 'false');
await expect(
page.getByRole('textbox', { name: 'Document title' }),
).toBeHidden();
await expect(
page.getByRole('heading', { name: childTitle }),
).toBeVisible();
await page.goto(urlParentDoc);
await verifyDocName(page, parentTitle);
await page.getByRole('button', { name: 'Share' }).click();
await page.getByTestId('doc-access-mode').click();
await page.getByRole('menuitemradio', { name: 'Reading' }).click();
// Close the modal
await page.getByRole('button', { name: 'close' }).first().click();
await page.goto(urlChildDoc);
await expect(editor).toHaveAttribute('contenteditable', 'true');
await expect(
page.getByRole('textbox', { name: 'Document title' }),
).toContainText(childTitle);
await expect(
page.getByRole('heading', { name: childTitle }),
).toBeHidden();
await expect(
card.getByText('Others are editing. Your network prevent changes.'),
).toBeHidden();
});
const webSocketPromise = otherPage.waitForEvent(
'websocket',
(webSocket) => {
return webSocket
.url()
.includes('ws://localhost:4444/collaboration/ws/?room=');
},
);
await otherPage.goto(urlChildDoc);
const webSocket = await webSocketPromise;
expect(webSocket.url()).toContain(
'ws://localhost:4444/collaboration/ws/?room=',
);
await verifyDocName(otherPage, childTitle);
await page.reload();
responseCanEdit = await page.waitForResponse(
(response) =>
response.url().includes(`/can-edit/`) && response.status() === 200,
);
expect(responseCanEdit.ok()).toBeTruthy();
jsonCanEdit = (await responseCanEdit.json()) as { can_edit: boolean };
expect(jsonCanEdit.can_edit).toBeFalsy();
await expect(
card.getByText('Others are editing. Your network prevent changes.'),
).toBeVisible({
timeout: 10000,
});
await expect(editor).toHaveAttribute('contenteditable', 'false');
await expect(
page.getByRole('textbox', { name: 'Document title' }),
).toBeHidden();
await expect(page.getByRole('heading', { name: childTitle })).toBeVisible();
await page.goto(urlParentDoc);
await verifyDocName(page, parentTitle);
await page.getByRole('button', { name: 'Share' }).click();
await page.getByTestId('doc-access-mode').click();
await page.getByRole('menuitemradio', { name: 'Reading' }).click();
// Close the modal
await page.getByRole('button', { name: 'close' }).first().click();
await page.goto(urlChildDoc);
await expect(editor).toHaveAttribute('contenteditable', 'true');
await expect(
page.getByRole('textbox', { name: 'Document title' }),
).toContainText(childTitle);
await expect(page.getByRole('heading', { name: childTitle })).toBeHidden();
await expect(
card.getByText('Others are editing. Your network prevent changes.'),
).toBeHidden();
});
}
test('it checks if callout custom block', async ({ page, browserName }) => {
await createDoc(page, 'doc-toolbar', browserName, 1);
@ -701,7 +730,7 @@ test.describe('Doc Editor', () => {
await page.getByText('Link a doc').first().click();
const input = page.locator(
"span[data-inline-content-type='interlinkingSearchInline'] input",
"span[data-inline-content-type='interlinkingLinkInline'] input",
);
const searchContainer = page.locator('.quick-search-container');
@ -868,7 +897,7 @@ test.describe('Doc Editor', () => {
// Check src of pdf
expect(await pdfIframe.getAttribute('src')).toMatch(
/http:\/\/localhost:8083\/media\/.*\/attachments\/.*.pdf/,
/\/media\/.*\/attachments\/.*.pdf/,
);
await expect(pdfIframe).toHaveAttribute('role', 'presentation');

View file

@ -160,6 +160,8 @@ test.describe('Doc Export', () => {
const download = await downloadPromise;
expect(download.suggestedFilename()).toBe(`${randomDoc}.zip`);
await page.waitForTimeout(1000);
const zipBuffer = await cs.toBuffer(await download.createReadStream());
// Unzip and inspect contents
const zip = await JSZip.loadAsync(zipBuffer);
@ -254,6 +256,8 @@ test.describe('Doc Export', () => {
const download = await downloadPromise;
expect(download.suggestedFilename()).toBe(`${randomDoc}.pdf`);
await page.waitForTimeout(1000);
const pdfBuffer = await cs.toBuffer(await download.createReadStream());
const pdfParse = new PDFParse({ data: pdfBuffer });
@ -301,6 +305,8 @@ test.describe('Doc Export', () => {
const download = await downloadPromise;
expect(download.suggestedFilename()).toBe(`${randomDocFrench}.pdf`);
await page.waitForTimeout(1000);
const pdfBuffer = await cs.toBuffer(await download.createReadStream());
const pdfString = pdfBuffer.toString('latin1');
@ -388,6 +394,8 @@ test.describe('Doc Export', () => {
const download = await downloadPromise;
expect(download.suggestedFilename()).toBe(`${randomDoc}.pdf`);
await page.waitForTimeout(1000);
const pdfBuffer = await cs.toBuffer(await download.createReadStream());
// If we need to update the PDF regression fixture, uncomment the line below

View file

@ -22,11 +22,10 @@ test.describe('Doc grid move', () => {
browserName,
}) => {
await page.goto('/');
const header = page.locator('header').first();
await createDoc(page, 'Draggable doc', browserName, 1);
await header.locator('h1').getByText('Docs').click();
await page.getByRole('button', { name: 'Back to homepage' }).click();
await createDoc(page, 'Droppable doc', browserName, 1);
await header.locator('h1').getByText('Docs').click();
await page.getByRole('button', { name: 'Back to homepage' }).click();
const response = await page.waitForResponse(
(response) =>
@ -204,7 +203,7 @@ test.describe('Doc grid move', () => {
await expect(docsGrid.getByText(titleDoc2)).toBeVisible();
const row = await getGridRow(page, titleDoc1);
await row.getByText(`more_horiz`).click();
await row.getByRole('button', { name: /Open the menu of actions/ }).click();
await page.getByRole('menuitem', { name: 'Move into a doc' }).click();
@ -292,7 +291,7 @@ test.describe('Doc grid move', () => {
await expect(docsGrid.getByText(titleDoc2)).toBeVisible();
const row = await getGridRow(page, titleDoc1);
await row.getByText(`more_horiz`).click();
await row.getByRole('button', { name: /Open the menu of actions/ }).click();
await page.getByRole('menuitem', { name: 'Move into a doc' }).click();
@ -333,9 +332,14 @@ test.describe('Doc grid move', () => {
// The other user should receive the access request and be able to approve it
await otherPage.getByRole('button', { name: 'Share' }).click();
await expect(otherPage.getByText('Access Requests')).toBeVisible();
await expect(otherPage.getByText(`E2E ${browserName}`)).toBeVisible();
await expect(
otherPage.getByText(
process.env[`USERNAME_${browserName.toUpperCase()}`] || '',
),
).toBeVisible();
const emailRequest = `user.test@${browserName}.test`;
const emailRequest =
process.env[`SIGN_IN_USERNAME_${browserName.toUpperCase()}`] || '';
await expect(otherPage.getByText(emailRequest)).toBeVisible();
const container = otherPage.getByTestId(
`doc-share-access-request-row-${emailRequest}`,
@ -348,11 +352,15 @@ test.describe('Doc grid move', () => {
await expect(otherPage.getByText('Access Requests')).toBeHidden();
await expect(otherPage.getByText('Share with 2 users')).toBeVisible();
await expect(otherPage.getByText(`E2E ${browserName}`)).toBeVisible();
await expect(
otherPage.getByText(
process.env[`USERNAME_${browserName.toUpperCase()}`] || '',
),
).toBeVisible();
// The first user should now be able to move the doc
await page.reload();
await row.getByText(`more_horiz`).click();
await row.getByRole('button', { name: /Open the menu of actions/ }).click();
await page.getByRole('menuitem', { name: 'Move into a doc' }).click();

View file

@ -97,7 +97,7 @@ test.describe('Document grid item options', () => {
await expect(page.getByText(docTitle)).toBeVisible();
const row = await getGridRow(page, docTitle);
await row.getByText(`more_horiz`).click();
await row.getByRole('button', { name: /Open the menu of actions/ }).click();
await page.getByRole('menuitem', { name: 'Share' }).click();
@ -114,7 +114,7 @@ test.describe('Document grid item options', () => {
const row = await getGridRow(page, docTitle);
// Pin
await row.getByText(`more_horiz`).click();
await row.getByRole('button', { name: /Open the menu of actions/ }).click();
await page.getByRole('menuitem', { name: 'Pin' }).click();
// Check is pinned
@ -123,7 +123,7 @@ test.describe('Document grid item options', () => {
await expect(leftPanelFavorites.getByText(docTitle)).toBeVisible();
// Unpin
await row.getByText(`more_horiz`).click();
await row.getByRole('button', { name: /Open the menu of actions/ }).click();
await page.getByText('Unpin').click();
// Check is unpinned
@ -140,7 +140,7 @@ test.describe('Document grid item options', () => {
await expect(page.getByText(docTitle)).toBeVisible();
const row = await getGridRow(page, docTitle);
await row.getByText(`more_horiz`).click();
await row.getByRole('button', { name: /Open the menu of actions/ }).click();
await page.getByRole('menuitem', { name: 'Delete' }).click();

View file

@ -179,7 +179,8 @@ test.describe('Doc Header', () => {
await optionMenu.click();
await expect(removeEmojiMenuItem).toBeHidden();
await addEmojiMenuItem.click();
await expect(emojiPicker).toHaveText('📄');
// The 1 April the emoji is a fish
await expect(emojiPicker).toHaveText(/📄|🐟/);
// Change emoji
await emojiPicker.click({
@ -603,7 +604,7 @@ test.describe('Doc Header', () => {
await expect(row.getByText(duplicateTitle)).toBeVisible();
await row.getByText(`more_horiz`).click();
await row.getByRole('button', { name: /Open the menu of actions/ }).click();
await page.getByRole('menuitem', { name: 'Duplicate' }).click();
const duplicateDuplicateTitle = 'Copy of ' + duplicateTitle;
await page.getByText(duplicateDuplicateTitle).click();
@ -633,7 +634,7 @@ test.describe('Doc Header', () => {
hasText: childTitle,
});
await child.hover();
await child.getByText(`more_horiz`).click();
await child.getByRole('button', { name: /More options/ }).click();
const currentUrl = page.url();

View file

@ -89,7 +89,7 @@ test.describe('Doc Import', () => {
).toBeVisible();
/* eslint-disable playwright/no-conditional-expect */
if (isMDCheck) {
if (isMDCheck && process.env.IS_INSTANCE !== 'true') {
await expect(
editor.locator(
'img[src="http://localhost:3000/assets/logo-suite-numerique.png"]',

View file

@ -17,12 +17,14 @@ test.describe('Inherited share accesses', () => {
page.getByText('People with access via the parent document'),
).toBeVisible();
const user = page.getByTestId(
`doc-share-member-row-user.test@${browserName}.test`,
);
await expect(user).toBeVisible();
await expect(user.getByText(`E2E ${browserName}`)).toBeVisible();
await expect(user.getByText('Owner')).toBeVisible();
const users = page.locator('.--docs--doc-share-member-item');
await expect(users).toBeVisible();
await expect(
users.getByText(
process.env[`SIGN_IN_USERNAME_${browserName.toUpperCase()}`] || '',
),
).toBeVisible();
await expect(users.getByText('Owner')).toBeVisible();
await page
.locator('.--docs--doc-inherited-share-content')

View file

@ -1,14 +1,9 @@
import { expect, test } from '@playwright/test';
import {
BROWSERS,
createDoc,
keyCloakSignIn,
randomName,
verifyDocName,
} from './utils-common';
import { BROWSERS, createDoc, randomName, verifyDocName } from './utils-common';
import { writeInEditor } from './utils-editor';
import { connectOtherUserToDoc, updateRoleUser } from './utils-share';
import { SignIn } from './utils-signin';
import { createRootSubPage } from './utils-sub-pages';
test.describe('Document create member', () => {
@ -99,7 +94,7 @@ test.describe('Document create member', () => {
list.getByTestId(`doc-share-add-member-${users[1].email}`),
).toBeVisible();
await expect(
list.getByText(`${users[1].full_name || users[1].email}`),
list.getByText(`${users[1].full_name || users[1].email}`).first(),
).toBeVisible();
// Select email and verify tag
@ -302,9 +297,14 @@ test.describe('Document create member', () => {
await page.getByRole('button', { name: 'Share' }).click();
await expect(page.getByText('Access Requests')).toBeVisible();
await expect(page.getByText(`E2E ${otherBrowserName}`)).toBeVisible();
await expect(
page.getByText(
process.env[`USERNAME_${otherBrowserName.toUpperCase()}`] || '',
),
).toBeVisible();
const emailRequest = `user.test@${otherBrowserName}.test`;
const emailRequest =
process.env[`SIGN_IN_USERNAME_${otherBrowserName.toUpperCase()}`] || '';
await expect(page.getByText(emailRequest)).toBeVisible();
const container = page.getByTestId(
`doc-share-access-request-row-${emailRequest}`,
@ -315,7 +315,11 @@ test.describe('Document create member', () => {
await expect(page.getByText('Access Requests')).toBeHidden();
await expect(page.getByText('Share with 2 users')).toBeVisible();
await expect(page.getByText(`E2E ${otherBrowserName}`)).toBeVisible();
await expect(
page.getByText(
process.env[`USERNAME_${otherBrowserName.toUpperCase()}`] || '',
),
).toBeVisible();
// Other user verifies he has access
await otherPage.reload();
@ -343,7 +347,7 @@ test.describe('Document create member: Multiple login', () => {
test.slow();
await page.goto('/');
await keyCloakSignIn(page, browserName);
await SignIn(page, browserName);
const [docParent] = await createDoc(
page,
@ -370,7 +374,7 @@ test.describe('Document create member: Multiple login', () => {
const otherBrowser = BROWSERS.find((b) => b !== browserName);
await keyCloakSignIn(page, otherBrowser!);
await SignIn(page, otherBrowser!);
await expect(page.getByTestId('header-logo-link')).toBeVisible({
timeout: 10000,

View file

@ -149,8 +149,10 @@ test.describe('Document list members', () => {
await page.getByRole('button', { name: 'Share' }).click();
const list = page.getByTestId('doc-share-quick-search');
await expect(list).toBeVisible();
const emailRequest =
process.env[`SIGN_IN_USERNAME_${browserName.toUpperCase()}`] || '';
const currentUser = list.getByTestId(
`doc-share-member-row-user.test@${browserName}.test`,
`doc-share-member-row-${emailRequest}`,
);
const currentUserRole = currentUser.getByTestId('doc-role-dropdown');
await expect(currentUser).toBeVisible();
@ -214,8 +216,9 @@ test.describe('Document list members', () => {
const list = page.getByTestId('doc-share-quick-search');
const emailMyself = `user.test@${browserName}.test`;
const mySelf = list.getByTestId(`doc-share-member-row-${emailMyself}`);
const emailRequest =
process.env[`SIGN_IN_USERNAME_${browserName.toUpperCase()}`] || '';
const mySelf = list.getByTestId(`doc-share-member-row-${emailRequest}`);
const mySelfRole = mySelf.getByTestId('doc-role-dropdown');
const userOwnerEmail = await addNewMember(page, 0, 'Owner');

View file

@ -1,15 +1,8 @@
import crypto from 'crypto';
import { expect, test } from '@playwright/test';
import {
createDoc,
expectLoginPage,
keyCloakSignIn,
mockedDocument,
verifyDocName,
} from './utils-common';
import { createDoc, getCurrentConfig, verifyDocName } from './utils-common';
import { writeInEditor } from './utils-editor';
import { SignIn, expectLoginPage } from './utils-signin';
import { createRootSubPage } from './utils-sub-pages';
test.describe('Doc Routing', () => {
@ -40,6 +33,48 @@ test.describe('Doc Routing', () => {
await expect(page).toHaveURL(/\/docs\/$/);
});
test('checks 500 refresh retries original document request', async ({
page,
browserName,
}) => {
const [docTitle] = await createDoc(page, 'doc-routing-500', browserName, 1);
await verifyDocName(page, docTitle);
const docId = page.url().split('/docs/')[1]?.split('/')[0];
// While true, every doc GET fails (including React Query retries) so we
// reliably land on /500. Set to false before refresh so the doc loads again.
let failDocumentGet = true;
await page.route(/\**\/documents\/\**/, async (route) => {
const request = route.request();
if (
failDocumentGet &&
request.method().includes('GET') &&
docId &&
request.url().includes(`/documents/${docId}/`)
) {
await route.fulfill({
status: 500,
json: { detail: 'Internal Server Error' },
});
} else {
await route.continue();
}
});
await page.reload();
await expect(page).toHaveURL(/\/500\/?\?from=/, { timeout: 15000 });
const refreshButton = page.getByRole('button', { name: 'Refresh page' });
await expect(refreshButton).toBeVisible();
failDocumentGet = false;
await refreshButton.click();
await verifyDocName(page, docTitle);
});
test('checks 404 on docs/[id] page', async ({ page }) => {
await page.waitForTimeout(300);
@ -54,6 +89,13 @@ test.describe('Doc Routing', () => {
});
test('checks 401 on docs/[id] page', async ({ page, browserName }) => {
const currentConfig = await getCurrentConfig(page);
test.skip(
currentConfig.FRONTEND_SILENT_LOGIN_ENABLED,
'This test is only relevant when silent login is disabled.',
);
const [docTitle] = await createDoc(page, '401-doc-parent', browserName, 1);
await verifyDocName(page, docTitle);
@ -112,13 +154,53 @@ test.describe('Doc Routing: Not logged', () => {
page,
browserName,
}) => {
const uuid = crypto.randomUUID();
await mockedDocument(page, { link_reach: 'public', id: uuid });
await page.goto(`/docs/${uuid}/`);
await expect(page.locator('h2').getByText('Mocked document')).toBeVisible();
await page.getByRole('button', { name: 'Login' }).click();
await keyCloakSignIn(page, browserName, false);
await expect(page.locator('h2').getByText('Mocked document')).toBeVisible();
await page.goto('/');
await SignIn(page, browserName);
const [docTitle1] = await createDoc(page, 'doc-login-1', browserName, 1);
await verifyDocName(page, docTitle1);
const page2 = await page.context().newPage();
await page2.goto('/');
const [docTitle2] = await createDoc(page2, 'doc-login-2', browserName, 1);
await verifyDocName(page2, docTitle2);
// Remove cookies `docs_sessionid` to simulate the user being logged out
await page2.context().clearCookies();
await page2.reload();
// Tab 2 - 401 triggered, user should be redirected to login page
await expect(
page2
.getByRole('main', { name: 'Main content' })
.getByRole('button', { name: 'Login' }),
).toBeVisible({
timeout: 10000,
});
// Tab 1 - 401 triggered, user should be redirected to login page
await page.reload();
await expect(
page
.getByRole('main', { name: 'Main content' })
.getByRole('button', { name: 'Login' }),
).toBeVisible({
timeout: 10000,
});
// Reconnected
await page
.getByRole('main', { name: 'Main content' })
.getByRole('button', { name: 'Login' })
.click();
await SignIn(page, browserName, false);
// Tab 1 - Should be on its doc
await verifyDocName(page, docTitle1);
// Tab 2 - Should be on its doc
await page2.reload();
await verifyDocName(page2, docTitle2);
});
// eslint-disable-next-line playwright/expect-expect

View file

@ -46,9 +46,27 @@ test.describe('Doc Trashbin', () => {
const docsGrid = page.getByTestId('docs-grid');
await expect(docsGrid.getByText('Days remaining')).toBeVisible();
await expect(row1.getByText(title1)).toBeVisible();
try {
await expect(row1.getByText(title1)).toBeVisible();
} catch {
test.skip(
true,
'We skip this test, it will fails because too much document deleted in the trashbin and it is ordered by day remaining',
);
}
await expect(row1.getByText('30 days')).toBeVisible();
await expect(row2.getByText(title2)).toBeVisible();
try {
await expect(row2.getByText(title2)).toBeVisible();
} catch {
test.skip(
true,
'We skip this test, it will fails because too much document deleted in the trashbin and it is ordered by day remaining',
);
}
await expect(
row2.getByRole('button', {
name: 'Open the sharing settings for the document',
@ -115,8 +133,18 @@ test.describe('Doc Trashbin', () => {
await page.getByRole('button', { name: 'Back to homepage' }).click();
await page.getByRole('link', { name: 'Trashbin' }).click();
const row = await getGridRow(page, subDocName);
await row.getByText(subDocName).click();
let row;
try {
row = await getGridRow(page, subDocName);
} catch {
test.skip(
true,
'We skip this test, it will fails because too much document deleted in the trashbin and it is ordered by day remaining',
);
}
await row?.getByText(subDocName).click();
await verifyDocName(page, subDocName);
await expect(

View file

@ -2,12 +2,11 @@ import { expect, test } from '@playwright/test';
import {
createDoc,
expectLoginPage,
keyCloakSignIn,
getOtherBrowserName,
updateDocTitle,
verifyDocName,
} from './utils-common';
import { addNewMember } from './utils-share';
import { addNewMember, connectOtherUserToDoc } from './utils-share';
import {
addChild,
clickOnAddRootSubPage,
@ -28,10 +27,10 @@ test.describe('Doc Tree', () => {
const response = {
count: 40,
next: `http://localhost:8071/api/v1.0/documents/anything/children/?page=${parseInt(pageId) + 1}`,
next: `${process.env.BASE_API_URL}/documents/anything/children/?page=${parseInt(pageId) + 1}`,
previous:
parseInt(pageId) > 1
? `http://localhost:8071/api/v1.0/documents/anything/children/?page=${parseInt(pageId) - 1}`
? `${process.env.BASE_API_URL}/documents/anything/children/?page=${parseInt(pageId) - 1}`
: null,
results: Array.from({ length: 20 }, (_, i) => ({
id: `doc-child-${pageId}-${i}`,
@ -136,14 +135,14 @@ test.describe('Doc Tree', () => {
await expect(docTree).toBeVisible();
await docTree.getByText('keyboard_arrow_right').click();
await docTree
.getByRole('button', {
.getByRole('link', {
name: `Open document ${titleChild}`,
})
.click();
await expect(docTree.getByText('doc-child-1-19')).toBeVisible();
await expect(docTree.locator('.c__spinner')).toBeVisible();
await docTree.getByText('doc-child-1-19').hover();
await expect(docTree.locator('.c__spinner')).toBeVisible();
await expect(
docTree.getByText('doc-child-2-1', {
exact: true,
@ -256,7 +255,7 @@ test.describe('Doc Tree', () => {
hasText: docChild,
});
await child.hover();
const menu = child.getByText(`more_horiz`);
const menu = child.getByRole('button', { name: /More options/ });
await menu.click();
await page.getByText('Move to my docs').click();
@ -264,8 +263,7 @@ test.describe('Doc Tree', () => {
page.getByRole('textbox', { name: 'Document title' }),
).not.toHaveText(docChild);
const header = page.locator('header').first();
await header.locator('h1').getByText('Docs').click();
await page.getByRole('button', { name: 'Back to homepage' }).click();
await expect(page.getByText(docChild)).toBeVisible();
});
@ -281,11 +279,14 @@ test.describe('Doc Tree', () => {
await page.getByRole('button', { name: 'Share' }).click();
await addNewMember(page, 0, 'Owner', 'impress');
const otherBrowserName = getOtherBrowserName(browserName);
await addNewMember(page, 0, 'Owner', otherBrowserName);
const list = page.getByTestId('doc-share-quick-search');
const currentEmail =
process.env[`SIGN_IN_USERNAME_${browserName.toUpperCase()}`] || '';
const currentUser = list.getByTestId(
`doc-share-member-row-user.test@${browserName}.test`,
`doc-share-member-row-${currentEmail}`,
);
const currentUserRole = currentUser.getByTestId('doc-role-dropdown');
await currentUserRole.click();
@ -316,7 +317,7 @@ test.describe('Doc Tree', () => {
hasText: docChild,
});
await child.hover();
const menu = child.getByText(`more_horiz`);
const menu = child.getByRole('button', { name: /More options/ });
await menu.click();
await expect(
@ -463,7 +464,7 @@ test.describe('Doc Tree', () => {
// Check Remove emoji is not present initially
await row.hover();
const menu = row.getByText(`more_horiz`);
const menu = row.getByRole('button', { name: /More options/ });
await menu.click();
await expect(
page.getByRole('menuitem', { name: 'Remove emoji' }),
@ -492,19 +493,12 @@ test.describe('Doc Tree', () => {
await expect(row.getByText('😀')).toBeHidden();
await expect(titleEmojiPicker).toBeHidden();
});
});
test.describe('Doc Tree: Inheritance', () => {
test.use({ storageState: { cookies: [], origins: [] } });
test('A child inherit from the parent', async ({ page, browserName }) => {
// test.slow() to extend timeout since this scenario chains Keycloak login + redirects,
// doc creation/navigation and async doc-tree loading (/documents/:id/tree), which can exceed 30s (especially in CI).
test.slow();
await page.goto('/');
await keyCloakSignIn(page, browserName);
const [docParent] = await createDoc(
page,
'doc-tree-inheritance-parent',
@ -531,22 +525,19 @@ test.describe('Doc Tree: Inheritance', () => {
'doc-tree-inheritance-child',
);
const urlDoc = page.url();
const docUrl = page.url();
await page
.getByRole('button', {
name: 'Logout',
})
.click();
const { otherPage, cleanup } = await connectOtherUserToDoc({
browserName,
docUrl,
withoutSignIn: true,
docTitle: docChild,
});
await expectLoginPage(page);
await page.goto(urlDoc);
await expect(page.locator('h2').getByText(docChild)).toBeVisible();
const docTree = page.getByTestId('doc-tree');
const docTree = otherPage.getByTestId('doc-tree');
await expect(docTree).toBeVisible({ timeout: 10000 });
await expect(docTree.getByText(docParent)).toBeVisible();
await cleanup();
});
});

View file

@ -133,14 +133,21 @@ test.describe('Doc Version', () => {
const [randomDoc] = await createDoc(page, 'doc-version', browserName, 1);
await verifyDocName(page, randomDoc);
await page.locator('.bn-block-outer').last().click();
await page.locator('.bn-block-outer').last().fill('Hello');
const editor = await writeInEditor({ page, text: 'Hello' });
// Add a comment
await editor.getByText('Hello').selectText();
await page.getByRole('button', { name: 'Add comment' }).click();
const thread = page.locator('.bn-thread');
await thread.getByRole('paragraph').first().fill('This is a comment');
await thread.locator('[data-test="save"]').click();
await expect(thread).toBeHidden();
await goToGridDoc(page, {
title: randomDoc,
});
const editor = page.locator('.ProseMirror');
await expect(editor.getByText('Hello')).toBeVisible();
await page.locator('.bn-block-outer').last().click();
await page.keyboard.press('Enter');
@ -152,6 +159,11 @@ test.describe('Doc Version', () => {
await expect(page.getByText('World')).toBeVisible();
await editor.getByText('Hello').click();
await thread.getByText('This is a comment').first().hover();
await thread.locator('[data-test="resolve"]').click();
await expect(thread).toBeHidden();
await page.getByLabel('Open the document options').click();
await page.getByRole('menuitem', { name: 'Version history' }).click();
@ -175,7 +187,21 @@ test.describe('Doc Version', () => {
await page.waitForTimeout(500);
await expect(page.getByText('Hello')).toBeVisible();
await expect(page.getByText('World')).toBeHidden();
await expect(editor.getByText('Hello')).toBeVisible();
await expect(editor.getByText('World')).toBeHidden();
// The old comment is not restored
await expect(editor.getByText('Hello')).toHaveCSS(
'background-color',
'rgba(0, 0, 0, 0)',
);
// We can add a new comment
await editor.getByText('Hello').selectText();
await page.getByRole('button', { name: 'Add comment' }).click();
await thread.getByRole('paragraph').first().fill('This is a comment');
await thread.locator('[data-test="save"]').click();
await expect(editor.getByText('Hello')).toHaveClass('bn-thread-mark');
});
});

View file

@ -1,14 +1,9 @@
import { expect, test } from '@playwright/test';
import {
BROWSERS,
createDoc,
expectLoginPage,
keyCloakSignIn,
verifyDocName,
} from './utils-common';
import { BROWSERS, createDoc, verifyDocName } from './utils-common';
import { getEditor, writeInEditor } from './utils-editor';
import { addNewMember, connectOtherUserToDoc } from './utils-share';
import { SignIn, expectLoginPage } from './utils-signin';
import { createRootSubPage } from './utils-sub-pages';
test.describe('Doc Visibility', () => {
@ -74,7 +69,7 @@ test.describe('Doc Visibility: Restricted', () => {
browserName,
}) => {
await page.goto('/');
await keyCloakSignIn(page, browserName);
await SignIn(page, browserName);
const [docTitle] = await createDoc(
page,
@ -109,7 +104,7 @@ test.describe('Doc Visibility: Restricted', () => {
test.slow();
await page.goto('/');
await keyCloakSignIn(page, browserName);
await SignIn(page, browserName);
const [docTitle] = await createDoc(page, 'Restricted auth', browserName, 1);
@ -128,7 +123,7 @@ test.describe('Doc Visibility: Restricted', () => {
throw new Error('No alternative browser found');
}
await keyCloakSignIn(page, otherBrowser);
await SignIn(page, otherBrowser);
await expect(page.getByTestId('header-logo-link')).toBeVisible({
timeout: 10000,
@ -146,7 +141,7 @@ test.describe('Doc Visibility: Restricted', () => {
test('A doc is accessible when member.', async ({ page, browserName }) => {
test.slow();
await page.goto('/');
await keyCloakSignIn(page, browserName);
await SignIn(page, browserName);
const [docTitle] = await createDoc(page, 'Restricted auth', browserName, 1);
@ -369,15 +364,14 @@ test.describe('Doc Visibility: Public', () => {
});
test.describe('Doc Visibility: Authenticated', () => {
test.use({ storageState: { cookies: [], origins: [] } });
test.beforeEach(async ({ page }) => {
await page.goto('/');
});
test('A doc is not accessible when unauthenticated.', async ({
page,
browserName,
}) => {
await page.goto('/');
await keyCloakSignIn(page, browserName);
const [docTitle] = await createDoc(
page,
'Authenticated unauthentified',
@ -398,23 +392,21 @@ test.describe('Doc Visibility: Authenticated', () => {
await page.getByRole('button', { name: 'close' }).click();
const urlDoc = page.url();
const docUrl = page.url();
await page
.getByRole('button', {
name: 'Logout',
})
.click();
const { otherPage, cleanup } = await connectOtherUserToDoc({
browserName,
docUrl,
withoutSignIn: true,
});
await expectLoginPage(page);
await page.goto(urlDoc);
await expect(page.locator('h2').getByText(docTitle)).toBeHidden();
await expect(otherPage.locator('h2').getByText(docTitle)).toBeHidden();
await expect(
page.getByText('Log in to access the document.'),
otherPage.getByText('Log in to access the document.'),
).toBeVisible();
await cleanup();
});
test('It checks a authenticated doc in read only mode', async ({
@ -423,9 +415,6 @@ test.describe('Doc Visibility: Authenticated', () => {
}) => {
test.slow();
await page.goto('/');
await keyCloakSignIn(page, browserName);
const [docTitle] = await createDoc(
page,
'Authenticated read only',
@ -454,7 +443,7 @@ test.describe('Doc Visibility: Authenticated', () => {
await page.getByRole('button', { name: 'close' }).click();
const urlDoc = page.url();
const docUrl = page.url();
const { name: childTitle } = await createRootSubPage(
page,
@ -464,56 +453,43 @@ test.describe('Doc Visibility: Authenticated', () => {
const urlChildDoc = page.url();
await page
.getByRole('button', {
name: 'Logout',
})
.click();
const otherBrowser = BROWSERS.find((b) => b !== browserName);
if (!otherBrowser) {
throw new Error('No alternative browser found');
}
await keyCloakSignIn(page, otherBrowser);
await expect(page.getByTestId('header-logo-link')).toBeVisible({
timeout: 10000,
const { otherPage, cleanup } = await connectOtherUserToDoc({
browserName,
docUrl,
docTitle,
});
await page.goto(urlDoc);
await expect(page.locator('h2').getByText(docTitle)).toBeVisible();
await page.getByRole('button', { name: 'Share' }).click();
await page.getByRole('button', { name: 'Copy link' }).click();
await expect(page.getByText('Link Copied !')).toBeVisible();
await otherPage.getByRole('button', { name: 'Share' }).click();
await expect(
page.getByText(
otherPage.getByText(
'You can view this document but need additional access to see its members or modify settings.',
),
).toBeVisible();
await page.getByRole('button', { name: 'Request access' }).click();
await otherPage.getByRole('button', { name: 'Request access' }).click();
await expect(
page.getByRole('button', { name: 'Request access' }),
otherPage.getByRole('button', { name: 'Request access' }),
).toBeDisabled();
await page.goto(urlChildDoc);
await otherPage.goto(urlChildDoc);
await expect(page.locator('h2').getByText(childTitle)).toBeVisible();
await expect(otherPage.locator('h2').getByText(childTitle)).toBeVisible();
await page.getByRole('button', { name: 'Share' }).click();
await otherPage.getByRole('button', { name: 'Share' }).click();
await expect(
page.getByText(
otherPage.getByText(
'As this is a sub-document, please request access to the parent document to enable these features.',
),
).toBeVisible();
await expect(
page.getByRole('button', { name: 'Request access' }),
otherPage.getByRole('button', { name: 'Request access' }),
).toBeHidden();
await cleanup();
});
test('It checks a authenticated doc in editable mode', async ({
@ -521,8 +497,6 @@ test.describe('Doc Visibility: Authenticated', () => {
browserName,
}) => {
test.slow();
await page.goto('/');
await keyCloakSignIn(page, browserName);
const [docTitle] = await createDoc(
page,
@ -542,7 +516,7 @@ test.describe('Doc Visibility: Authenticated', () => {
page.getByText('The document visibility has been updated.'),
).toBeVisible();
const urlDoc = page.url();
const docUrl = page.url();
await page.getByTestId('doc-access-mode').click();
await page.getByRole('menuitemradio', { name: 'Editing' }).click();
@ -552,29 +526,24 @@ test.describe('Doc Visibility: Authenticated', () => {
await page.getByRole('button', { name: 'close' }).click();
await page
.getByRole('button', {
name: 'Logout',
})
.click();
const otherBrowser = BROWSERS.find((b) => b !== browserName);
if (!otherBrowser) {
throw new Error('No alternative browser found');
}
await keyCloakSignIn(page, otherBrowser);
await expect(page.getByTestId('header-logo-link')).toBeVisible({
timeout: 10000,
const { otherPage, cleanup } = await connectOtherUserToDoc({
browserName,
docUrl,
docTitle,
});
await page.goto(urlDoc);
await otherPage.getByRole('button', { name: 'Share' }).click();
await verifyDocName(page, docTitle);
await page.getByRole('button', { name: 'Share' }).click();
await page.getByRole('button', { name: 'Copy link' }).click();
await expect(page.getByText('Link Copied !')).toBeVisible({
timeout: 10000,
});
await expect(
otherPage.getByText(
'You can view this document but need additional access to see its members or modify settings.',
),
).toBeVisible();
await expect(
otherPage.getByRole('button', { name: 'Request access' }),
).toBeVisible();
await cleanup();
});
});

View file

@ -14,45 +14,47 @@ test.describe('Footer', () => {
await expect(page.locator('footer')).toBeHidden();
});
test('checks all the elements are visible', async ({ page }) => {
await page.goto('/');
const footer = page.locator('footer').first();
if (process.env.IS_INSTANCE !== 'true') {
test('checks all the elements are visible', async ({ page }) => {
await page.goto('/');
const footer = page.locator('footer').first();
await expect(footer.getByAltText('Docs Logo')).toBeVisible();
await expect(footer.getByRole('heading', { name: 'Docs' })).toBeVisible();
await expect(footer.getByAltText('Docs Logo')).toBeVisible();
await expect(footer.getByRole('heading', { name: 'Docs' })).toBeVisible();
await expect(footer.getByRole('link', { name: 'GitHub' })).toBeVisible();
await expect(footer.getByRole('link', { name: 'DINUM' })).toBeVisible();
await expect(footer.getByRole('link', { name: 'ZenDiS' })).toBeVisible();
await expect(footer.getByRole('link', { name: 'GitHub' })).toBeVisible();
await expect(footer.getByRole('link', { name: 'DINUM' })).toBeVisible();
await expect(footer.getByRole('link', { name: 'ZenDiS' })).toBeVisible();
await expect(
footer.getByRole('link', { name: 'BlockNote.js' }),
).toBeVisible();
await expect(
footer.getByRole('link', { name: 'Legal Notice' }),
).toBeVisible();
await expect(
footer.getByRole('link', { name: 'Personal data and cookies' }),
).toBeVisible();
await expect(
footer.getByRole('link', { name: 'Accessibility' }),
).toBeVisible();
await expect(
footer.getByRole('link', { name: 'BlockNote.js' }),
).toBeVisible();
await expect(
footer.getByRole('link', { name: 'Legal Notice' }),
).toBeVisible();
await expect(
footer.getByRole('link', { name: 'Personal data and cookies' }),
).toBeVisible();
await expect(
footer.getByRole('link', { name: 'Accessibility' }),
).toBeVisible();
await expect(
footer.getByText(
'Unless otherwise stated, all content on this site is under licence',
),
).toBeVisible();
await expect(
footer.getByText(
'Unless otherwise stated, all content on this site is under licence',
),
).toBeVisible();
// Check the translation
const header = page.locator('header').first();
await header.getByRole('button').getByText('English').click();
await page.getByRole('menuitemradio', { name: 'Français' }).click();
// Check the translation
const header = page.locator('header').first();
await header.getByRole('button').getByText('English').click();
await page.getByRole('menuitemradio', { name: 'Français' }).click();
await expect(
page.locator('footer').getByText('Mentions légales'),
).toBeVisible();
});
await expect(
page.locator('footer').getByText('Mentions légales'),
).toBeVisible();
});
}
test('checks the footer is correctly overrided', async ({ page }) => {
await overrideConfig(page, {

View file

@ -1,10 +1,7 @@
import { expect, test } from '@playwright/test';
import {
expectLoginPage,
keyCloakSignIn,
overrideConfig,
} from './utils-common';
import { overrideConfig } from './utils-common';
import { SignIn, expectLoginPage } from './utils-signin';
test.describe('Header', () => {
test('checks all the elements are visible', async ({ page }) => {
@ -142,27 +139,31 @@ test.describe('Header', () => {
await expect(page.getByRole('link', { name: 'Grist' })).toBeVisible();
await expect(page.getByRole('link', { name: 'Visio' })).toBeVisible();
});
});
test.describe('Header: Log out', () => {
test.use({ storageState: { cookies: [], origins: [] } });
// eslint-disable-next-line playwright/expect-expect
test('checks logout button', async ({ page, browserName }) => {
test('it displays skip link on first TAB and focuses page heading on click', async ({
page,
}) => {
await page.goto('/');
await keyCloakSignIn(page, browserName);
await page
.getByRole('button', {
name: 'Logout',
})
.click();
// Wait for skip link to be mounted (client-side only component)
const skipLink = page.getByRole('link', { name: 'Go to content' });
await skipLink.waitFor({ state: 'attached' });
await expectLoginPage(page);
// First TAB shows the skip link
await page.keyboard.press('Tab');
// The skip link should be visible and focused
await expect(skipLink).toBeFocused();
await expect(skipLink).toBeVisible();
// Clicking moves focus to the page heading
await skipLink.click();
const pageHeading = page.getByRole('heading', {
name: 'All docs',
level: 2,
});
await expect(pageHeading).toBeFocused();
});
});
test.describe('Header: Override configuration', () => {
test('checks the header is correctly overrided', async ({ page }) => {
await overrideConfig(page, {
FRONTEND_THEME: 'dsfr',
@ -190,28 +191,20 @@ test.describe('Header: Override configuration', () => {
});
});
test.describe('Header: Skip to Content', () => {
test('it displays skip link on first TAB and focuses page heading on click', async ({
page,
}) => {
test.describe('Header: Log out', () => {
test.use({ storageState: { cookies: [], origins: [] } });
// eslint-disable-next-line playwright/expect-expect
test('checks logout button', async ({ page, browserName }) => {
await page.goto('/');
await SignIn(page, browserName);
// Wait for skip link to be mounted (client-side only component)
const skipLink = page.getByRole('link', { name: 'Go to content' });
await skipLink.waitFor({ state: 'attached' });
await page
.getByRole('button', {
name: 'Logout',
})
.click();
// First TAB shows the skip link
await page.keyboard.press('Tab');
// The skip link should be visible and focused
await expect(skipLink).toBeFocused();
await expect(skipLink).toBeVisible();
// Clicking moves focus to the page heading
await skipLink.click();
const pageHeading = page.getByRole('heading', {
name: 'All docs',
level: 2,
});
await expect(pageHeading).toBeFocused();
await expectLoginPage(page);
});
});

View file

@ -2,13 +2,127 @@ import { expect, test } from '@playwright/test';
import {
TestLanguage,
getCurrentConfig,
overrideConfig,
waitForLanguageSwitch,
} from './utils-common';
test.describe('Help feature', () => {
test.beforeEach(async ({ page }) => {
await page.goto('/');
test.describe('Documentation button', () => {
if (process.env.IS_INSTANCE !== 'true') {
test('is not displayed if documentation_url is not set', async ({
page,
}) => {
await overrideConfig(page, {
theme_customization: {
help: {
documentation_url: '',
},
onboarding: {
enabled: true,
},
},
});
await page.goto('/');
await page.getByRole('button', { name: 'Open help menu' }).click();
await expect(
page.getByRole('menuitem', { name: 'Documentation' }),
).toBeHidden();
});
}
test('is displayed if documentation_url is set', async ({ page }) => {
let documentationUrl: string;
if (process.env.IS_INSTANCE !== 'true') {
documentationUrl = `${process.env.BASE_URL}/docs/`;
await overrideConfig(page, {
theme_customization: {
help: {
documentation_url: documentationUrl,
},
},
});
} else {
const currentConfig = await getCurrentConfig(page);
test.skip(
!currentConfig.theme_customization?.help?.documentation_url,
'Documentation URL is not set',
);
documentationUrl =
currentConfig.theme_customization.help.documentation_url;
}
await page.goto('/');
await page.getByRole('button', { name: 'Open help menu' }).click();
const docMenuItem = page.getByRole('menuitem', { name: 'Documentation' });
await expect(docMenuItem).toBeVisible();
const [newPage] = await Promise.all([
page.context().waitForEvent('page'),
docMenuItem.click(),
]);
await expect(newPage).toHaveURL(documentationUrl);
});
});
test.describe('Support button', () => {
if (process.env.IS_INSTANCE !== 'true') {
test('is not displayed if CRISP_WEBSITE_ID is not set', async ({
page,
}) => {
await overrideConfig(page, {
CRISP_WEBSITE_ID: '',
});
await page.goto('/');
await page.getByRole('button', { name: 'Open help menu' }).click();
await expect(
page.getByRole('menuitem', { name: 'Get Support' }),
).toBeHidden();
});
test('is displayed if CRISP_WEBSITE_ID is set', async ({ page }) => {
await overrideConfig(page, {
CRISP_WEBSITE_ID: 'test_website_id',
});
await page.goto('/');
await page.getByRole('button', { name: 'Open help menu' }).click();
await expect(
page.getByRole('menuitem', {
name: 'Get Support',
}),
).toBeVisible();
});
}
if (process.env.IS_INSTANCE === 'true') {
test('it displays Crisp chatbox', async ({ page }) => {
const currentConfig = await getCurrentConfig(page);
test.skip(
!currentConfig.CRISP_WEBSITE_ID,
'Crisp chatbox is not enabled',
);
await page.goto('/');
await page.getByRole('button', { name: 'Open help menu' }).click();
await page
.getByRole('menuitem', {
name: 'Get Support',
})
.click();
const crispElement = page.locator('#crisp-chatbox');
await expect(crispElement).toBeAttached();
});
}
});
test.describe('Onboarding modal', () => {
@ -23,6 +137,8 @@ test.describe('Help feature', () => {
},
});
await page.goto('/');
await expect(page.getByRole('button', { name: 'New doc' })).toBeVisible();
await expect(
@ -42,6 +158,8 @@ test.describe('Help feature', () => {
},
});
await page.goto('/');
await page.getByRole('button', { name: 'Open help menu' }).click();
await page.getByRole('menuitem', { name: 'Onboarding' }).click();
@ -86,23 +204,21 @@ test.describe('Help feature', () => {
});
test('closes modal with Skip button', async ({ page }) => {
await page.goto('/');
await page.getByRole('button', { name: 'Open help menu' }).click();
await page.getByRole('menuitem', { name: 'Onboarding' }).click();
const modal = page.getByTestId('onboarding-modal');
await expect(modal).toBeVisible();
await expect(
page.getByRole('link', {
name: 'Learn more docs features',
}),
).toBeHidden();
await page.getByRole('button', { name: /skip/i }).click();
await expect(modal).toBeHidden();
});
test('Modal onboarding translated correctly', async ({ page }) => {
await page.goto('/');
// switch to french
await waitForLanguageSwitch(page, TestLanguage.French);
@ -131,6 +247,8 @@ test.describe('Help feature', () => {
page,
browserName,
}) => {
await page.goto('/');
await expect(page.getByRole('button', { name: 'New doc' })).toBeVisible();
await expect(page.getByTestId('onboarding-modal')).toBeHidden();

View file

@ -2,10 +2,6 @@ import { expect, test } from '@playwright/test';
import { overrideConfig } from './utils-common';
test.beforeEach(async ({ page }) => {
await page.goto('/docs/');
});
test.describe('Home page', () => {
test.use({ storageState: { cookies: [], origins: [] } });
@ -23,7 +19,6 @@ test.describe('Home page', () => {
await expect(languageButton).toBeVisible();
await expect(header.getByTestId('header-icon-docs')).toBeVisible();
await expect(header.getByRole('heading', { name: 'Docs' })).toBeVisible();
// Check the titles
const h2 = page.locator('h2');
@ -69,7 +64,9 @@ test.describe('Home page', () => {
h2.getByText('A new way to organize knowledge.'),
).toBeVisible();
await expect(
page.getByRole('button', { name: 'Start Writing' }),
page
.getByRole('button', { name: process.env.SIGN_IN_EL_TRIGGER })
.first(),
).toBeVisible();
await expect(footer).toBeVisible();
@ -178,7 +175,7 @@ test.describe('Home page', () => {
// Keyclock login page
await expect(
page.locator('.login-pf #kc-header-wrapper').getByText('impress'),
page.locator(`${process.env.SIGN_IN_EL_LOGIN_PAGE}`).getByText('impress'),
).toBeVisible();
});
});

View file

@ -116,7 +116,7 @@ test.describe('Language', () => {
// Helper function to intercept and assert 404 response
const check404Response = async (expectedDetail: string) => {
const interceptedBackendResponse = await page.request.get(
'http://localhost:8071/api/v1.0/documents/non-existent-doc-uuid/',
`${process.env.BASE_API_URL}/documents/non-existent-doc-uuid/`,
);
// Assert that the intercepted error message is in the expected language

View file

@ -18,7 +18,7 @@ export const CONFIG = {
AI_FEATURE_LEGACY_ENABLED: true,
API_USERS_SEARCH_QUERY_MIN_LENGTH: 3,
CRISP_WEBSITE_ID: null,
COLLABORATION_WS_URL: 'ws://localhost:4444/collaboration/ws/',
COLLABORATION_WS_URL: process.env.COLLABORATION_WS_URL,
COLLABORATION_WS_NOT_CONNECTED_READY_ONLY: true,
CONVERSION_UPLOAD_ENABLED: true,
CONVERSION_FILE_EXTENSIONS_ALLOWED: ['.docx', '.md'],
@ -29,7 +29,7 @@ export const CONFIG = {
FRONTEND_HOMEPAGE_FEATURE_ENABLED: true,
FRONTEND_SILENT_LOGIN_ENABLED: false,
FRONTEND_THEME: null,
MEDIA_BASE_URL: 'http://localhost:8083',
MEDIA_BASE_URL: process.env.MEDIA_BASE_URL,
LANGUAGES: [
['en-us', 'English'],
['fr-fr', 'Français'],
@ -62,29 +62,18 @@ export const overrideConfig = async (
}
});
export const keyCloakSignIn = async (
page: Page,
browserName: string,
fromHome = true,
) => {
if (fromHome) {
await page.getByRole('button', { name: 'Start Writing' }).first().click();
}
export const getCurrentConfig = async (page: Page) => {
const responsePromise = page.waitForResponse(
(response) =>
response.url().includes('/config/') && response.status() === 200,
);
const login = `user-e2e-${browserName}`;
const password = `password-e2e-${browserName}`;
await page.goto('/');
await expect(
page.locator('.login-pf #kc-header-wrapper').getByText('impress'),
).toBeVisible();
const response = await responsePromise;
expect(response.ok()).toBeTruthy();
if (await page.getByLabel('Restart login').isVisible()) {
await page.getByLabel('Restart login').click();
}
await page.getByRole('textbox', { name: 'username' }).fill(login);
await page.getByRole('textbox', { name: 'password' }).fill(password);
await page.click('button[type="submit"]', { force: true });
return (await response.json()) as typeof CONFIG;
};
export const getOtherBrowserName = (browserName: BrowserName) => {
@ -209,8 +198,11 @@ export const goToGridDoc = async (
page: Page,
{ nthRow = 1, title }: GoToGridDocOptions = {},
) => {
const header = page.locator('header').first();
await header.locator('h1').getByText('Docs').click();
if (
await page.getByRole('button', { name: 'Back to homepage' }).isVisible()
) {
await page.getByRole('button', { name: 'Back to homepage' }).click();
}
const docsGrid = page.getByTestId('docs-grid');
await expect(docsGrid).toBeVisible();
@ -325,13 +317,6 @@ export const mockedListDocs = async (page: Page, data: object[] = []) => {
});
};
export const expectLoginPage = async (page: Page) =>
await expect(
page.getByRole('heading', { name: 'Collaborative writing' }),
).toBeVisible({
timeout: 10000,
});
// language helper
export const TestLanguage = {
English: {

View file

@ -74,7 +74,9 @@ export const overrideDocContent = async ({
const image = page
.locator('.--docs--editor-container img.bn-visual-media[src$=".svg"]')
.first();
await expect(image).toBeVisible();
await expect(image).toBeVisible({
timeout: 10000,
});
await page.keyboard.press('Enter');
await page.waitForTimeout(1000);

View file

@ -3,9 +3,9 @@ import { Page, chromium, expect } from '@playwright/test';
import {
BrowserName,
getOtherBrowserName,
keyCloakSignIn,
verifyDocName,
} from './utils-common';
import { SignIn } from './utils-signin';
export type Role = 'Administrator' | 'Owner' | 'Editor' | 'Reader';
export type LinkReach = 'Private' | 'Connected' | 'Public';
@ -131,14 +131,14 @@ export const connectOtherUserToDoc = async ({
.getByRole('main', { name: 'Main content' })
.getByLabel('Login');
const loginFromHome = otherPage.getByRole('button', {
name: 'Start Writing',
name: process.env.SIGN_IN_EL_TRIGGER,
});
await loginFromApp.or(loginFromHome).first().click({
timeout: 15000,
});
await keyCloakSignIn(otherPage, otherBrowserName, false);
await SignIn(otherPage, otherBrowserName, false);
}
if (docTitle) {
await verifyDocName(otherPage, docTitle);

View file

@ -0,0 +1,94 @@
import { Page, expect } from '@playwright/test';
export const SignIn = async (
page: Page,
browserName: string,
fromHome = true,
) => {
if (process.env.CUSTOM_SIGN_IN === 'true') {
await customSignIn(page, browserName, fromHome);
return;
}
await keycloakSignIn(page, browserName, fromHome);
};
export const customSignIn = async (
page: Page,
browserName: string,
fromHome = true,
) => {
// Check if already signed in (Silent login or session still valid)
if (
await page
.locator('header')
.first()
.getByRole('button', {
name: 'Logout',
})
.isVisible()
) {
return;
}
if (fromHome) {
await page
.getByRole('button', { name: process.env.SIGN_IN_EL_TRIGGER })
.first()
.click();
}
await page
.getByRole('textbox', { name: process.env.SIGN_IN_EL_USERNAME_INPUT })
.fill(process.env[`SIGN_IN_USERNAME_${browserName.toUpperCase()}`] || '');
if (process.env.SIGN_IN_EL_USERNAME_VALIDATION) {
await page
.getByRole('button', { name: process.env.SIGN_IN_EL_USERNAME_VALIDATION })
.first()
.click();
}
await page
.locator(
`input[name="${process.env.SIGN_IN_EL_PASSWORD_INPUT || 'password'}"]`,
)
.fill(process.env[`SIGN_IN_PASSWORD_${browserName.toUpperCase()}`] || '');
await page.click('button[type="submit"]', { force: true });
};
export const keycloakSignIn = async (
page: Page,
browserName: string,
fromHome = true,
) => {
if (fromHome) {
await page
.getByRole('button', { name: process.env.SIGN_IN_EL_TRIGGER })
.first()
.click();
}
const login = `user-e2e-${browserName}`;
const password = `password-e2e-${browserName}`;
await expect(
page.locator('.login-pf #kc-header-wrapper').getByText('impress'),
).toBeVisible();
if (await page.getByLabel('Restart login').isVisible()) {
await page.getByLabel('Restart login').click();
}
await page.getByRole('textbox', { name: 'username' }).fill(login);
await page.getByRole('textbox', { name: 'password' }).fill(password);
await page.click('button[type="submit"]', { force: true });
};
export const expectLoginPage = async (page: Page) =>
await expect(
page.getByRole('heading', { name: 'Collaborative writing' }),
).toBeVisible({
timeout: 10000,
});

View file

@ -1,6 +1,6 @@
{
"name": "app-e2e",
"version": "4.8.5",
"version": "4.8.6",
"repository": "https://github.com/suitenumerique/docs",
"author": "DINUM",
"license": "MIT",
@ -24,6 +24,7 @@
"dependencies": {
"@types/pngjs": "6.0.5",
"convert-stream": "1.0.2",
"dotenv": "17.3.1",
"pdf-parse": "2.4.5",
"pixelmatch": "7.1.0",
"pngjs": "7.0.0"

View file

@ -1,8 +1,14 @@
import { defineConfig, devices } from '@playwright/test';
import dotenv from 'dotenv';
const PORT = process.env.PORT || 3000;
dotenv.config({
path: ['./.env.local', './.env'],
quiet: true,
debug: !process.env.CI,
});
const baseURL = `http://localhost:${PORT}`;
const PORT = process.env.PORT;
const baseURL = process.env.BASE_URL;
/**
* See https://playwright.dev/docs/test-configuration.
@ -23,7 +29,10 @@ export default defineConfig({
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 3 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: [['html', { outputFolder: './report' }]],
reporter: [
['html', { outputFolder: './report' }],
['list', { printSteps: true }],
],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
baseURL,
@ -31,13 +40,16 @@ export default defineConfig({
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},
webServer: {
command: !process.env.CI ? `cd ../.. && yarn app:dev --port ${PORT}` : '',
url: baseURL,
timeout: 120 * 1000,
reuseExistingServer: true,
},
...(process.env.CI
? {}
: {
webServer: {
command: `cd ../.. && yarn app:dev --port ${PORT}`,
url: baseURL,
timeout: 120 * 1000,
reuseExistingServer: true,
},
}),
globalSetup: require.resolve('./__tests__/app-impress/auth.setup'),
/* Configure projects for major browsers */
projects: [

View file

@ -1,6 +1,6 @@
{
"name": "app-impress",
"version": "4.8.5",
"version": "4.8.6",
"repository": "https://github.com/suitenumerique/docs",
"author": "DINUM",
"license": "MIT",
@ -62,9 +62,9 @@
"i18next": "25.10.4",
"i18next-browser-languagedetector": "8.2.1",
"idb": "8.0.3",
"lodash": "4.17.23",
"lodash": "4.18.1",
"luxon": "3.7.2",
"next": "16.2.1",
"next": "16.2.3",
"posthog-js": "1.363.1",
"react": "*",
"react-aria-components": "1.16.0",

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View file

@ -1,3 +1,3 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M11 13H5V11H11V5H13V11H19V13H13V19H11V13Z" fill="#222631"/>
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M11 13H5V11H11V5H13V11H19V13H13V19H11V13Z" fill="currentColor" />
</svg>

Before

Width:  |  Height:  |  Size: 172 B

After

Width:  |  Height:  |  Size: 157 B

View file

@ -1,3 +1,6 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M11 17H13V13H17V11H13V7H11V11H7V13H11V17ZM5 21C4.45 21 3.97917 20.8042 3.5875 20.4125C3.19583 20.0208 3 19.55 3 19V5C3 4.45 3.19583 3.97917 3.5875 3.5875C3.97917 3.19583 4.45 3 5 3H19C19.55 3 20.0208 3.19583 20.4125 3.5875C20.8042 3.97917 21 4.45 21 5V19C21 19.55 20.8042 20.0208 20.4125 20.4125C20.0208 20.8042 19.55 21 19 21H5ZM5 19H19V5H5V19Z" fill="#222631"/>
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M11 17H13V13H17V11H13V7H11V11H7V13H11V17ZM5 21C4.45 21 3.97917 20.8042 3.5875 20.4125C3.19583 20.0208 3 19.55 3 19V5C3 4.45 3.19583 3.97917 3.5875 3.5875C3.97917 3.19583 4.45 3 5 3H19C19.55 3 20.0208 3.19583 20.4125 3.5875C20.8042 3.97917 21 4.45 21 5V19C21 19.55 20.8042 20.0208 20.4125 20.4125C20.0208 20.8042 19.55 21 19 21H5ZM5 19H19V5H5V19Z"
fill="currentColor"
/>
</svg>

Before

Width:  |  Height:  |  Size: 476 B

After

Width:  |  Height:  |  Size: 471 B

View file

@ -1,6 +1,20 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12.2598 12.8799C12.4143 12.88 12.5453 12.9359 12.6523 13.0488C12.7653 13.1558 12.8212 13.2869 12.8213 13.4414C12.8213 13.5959 12.7651 13.727 12.6523 13.834C12.5453 13.941 12.4143 13.995 12.2598 13.9951H7.46191C7.30722 13.9951 7.17643 13.9411 7.06934 13.834C6.96232 13.7269 6.9082 13.596 6.9082 13.4414C6.90828 13.2869 6.95948 13.1558 7.06055 13.0488C7.16759 12.936 7.30143 12.8799 7.46191 12.8799H12.2598Z" fill="#222631"/>
<path d="M16.4395 10.0322C16.6001 10.0322 16.7347 10.0891 16.8418 10.2021C16.9488 10.3152 17.002 10.4432 17.002 10.5859C17.0019 10.7464 16.9487 10.8803 16.8418 10.9873C16.7347 11.0944 16.6001 11.1484 16.4395 11.1484H7.46191C7.30723 11.1484 7.17643 11.0944 7.06934 10.9873C6.96225 10.8802 6.90821 10.7466 6.9082 10.5859C6.9082 10.4431 6.9594 10.3152 7.06055 10.2021C7.16761 10.0892 7.30136 10.0322 7.46191 10.0322H16.4395Z" fill="#222631"/>
<path d="M16.4395 7.20312C16.6001 7.20312 16.7347 7.25716 16.8418 7.36426C16.9488 7.47131 17.002 7.5994 17.002 7.74805C17.0019 7.90259 16.9487 8.03645 16.8418 8.14941C16.7347 8.25651 16.6001 8.31055 16.4395 8.31055H7.46191C7.30726 8.31055 7.17642 8.25645 7.06934 8.14941C6.96228 8.03641 6.90824 7.90267 6.9082 7.74805C6.9082 7.5993 6.9594 7.47135 7.06055 7.36426C7.16762 7.25725 7.30134 7.20312 7.46191 7.20312H16.4395Z" fill="#222631"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M17.8057 3C18.7039 3.00003 19.4652 3.16689 20.0898 3.5C20.7085 3.83314 21.1816 4.31192 21.5088 4.93652C21.836 5.55524 22 6.30792 22 7.19434V14.1201C22 15.0066 21.836 15.762 21.5088 16.3867C21.1756 17.0055 20.7027 17.4813 20.0898 17.8145C19.4711 18.1476 18.7307 18.3144 17.8682 18.3145H17.3857V20.5098C17.3857 20.9083 17.288 21.224 17.0918 21.4561C16.8896 21.688 16.6097 21.8036 16.2529 21.8037C16.0031 21.8037 15.768 21.7383 15.5479 21.6074C15.3277 21.4825 15.0652 21.2863 14.7617 21.0186L11.71 18.3145H6.19434C5.30197 18.3144 4.54362 18.1476 3.91895 17.8145C3.29424 17.4813 2.81844 17.0055 2.49121 16.3867C2.16399 15.762 2.00001 15.0066 2 14.1201V7.19434C2.00003 6.30792 2.164 5.55524 2.49121 4.93652C2.81844 4.31192 3.2943 3.83314 3.91895 3.5C4.54361 3.16685 5.30199 3.00003 6.19434 3H17.8057ZM6.24805 4.75781C5.40331 4.75782 4.7786 4.96927 4.37402 5.3916C3.9635 5.80807 3.75782 6.42701 3.75781 7.24805V14.0576C3.75782 14.8846 3.9635 15.5092 4.37402 15.9316C4.7786 16.3481 5.40321 16.5566 6.24805 16.5566H11.7988C12.0725 16.5566 12.2934 16.5889 12.46 16.6543C12.6205 16.7138 12.796 16.839 12.9863 17.0293L15.8154 19.832V17.2881C15.8155 17.0204 15.8752 16.8327 15.9941 16.7256C16.1072 16.6128 16.2885 16.5567 16.5381 16.5566H17.7607C18.5996 16.5566 19.2242 16.3481 19.6348 15.9316C20.0393 15.5092 20.2422 14.8846 20.2422 14.0576V7.24805C20.2422 6.42701 20.0393 5.80807 19.6348 5.3916C19.2242 4.96931 18.5995 4.75781 17.7607 4.75781H6.24805Z" fill="#222631"/>
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M12.2598 12.8799C12.4143 12.88 12.5453 12.9359 12.6523 13.0488C12.7653 13.1558 12.8212 13.2869 12.8213 13.4414C12.8213 13.5959 12.7651 13.727 12.6523 13.834C12.5453 13.941 12.4143 13.995 12.2598 13.9951H7.46191C7.30722 13.9951 7.17643 13.9411 7.06934 13.834C6.96232 13.7269 6.9082 13.596 6.9082 13.4414C6.90828 13.2869 6.95948 13.1558 7.06055 13.0488C7.16759 12.936 7.30143 12.8799 7.46191 12.8799H12.2598Z"
fill="currentColor"
/>
<path
d="M16.4395 10.0322C16.6001 10.0322 16.7347 10.0891 16.8418 10.2021C16.9488 10.3152 17.002 10.4432 17.002 10.5859C17.0019 10.7464 16.9487 10.8803 16.8418 10.9873C16.7347 11.0944 16.6001 11.1484 16.4395 11.1484H7.46191C7.30723 11.1484 7.17643 11.0944 7.06934 10.9873C6.96225 10.8802 6.90821 10.7466 6.9082 10.5859C6.9082 10.4431 6.9594 10.3152 7.06055 10.2021C7.16761 10.0892 7.30136 10.0322 7.46191 10.0322H16.4395Z"
fill="currentColor"
/>
<path
d="M16.4395 7.20312C16.6001 7.20312 16.7347 7.25716 16.8418 7.36426C16.9488 7.47131 17.002 7.5994 17.002 7.74805C17.0019 7.90259 16.9487 8.03645 16.8418 8.14941C16.7347 8.25651 16.6001 8.31055 16.4395 8.31055H7.46191C7.30726 8.31055 7.17642 8.25645 7.06934 8.14941C6.96228 8.03641 6.90824 7.90267 6.9082 7.74805C6.9082 7.5993 6.9594 7.47135 7.06055 7.36426C7.16762 7.25725 7.30134 7.20312 7.46191 7.20312H16.4395Z"
fill="currentColor"
/>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M17.8057 3C18.7039 3.00003 19.4652 3.16689 20.0898 3.5C20.7085 3.83314 21.1816 4.31192 21.5088 4.93652C21.836 5.55524 22 6.30792 22 7.19434V14.1201C22 15.0066 21.836 15.762 21.5088 16.3867C21.1756 17.0055 20.7027 17.4813 20.0898 17.8145C19.4711 18.1476 18.7307 18.3144 17.8682 18.3145H17.3857V20.5098C17.3857 20.9083 17.288 21.224 17.0918 21.4561C16.8896 21.688 16.6097 21.8036 16.2529 21.8037C16.0031 21.8037 15.768 21.7383 15.5479 21.6074C15.3277 21.4825 15.0652 21.2863 14.7617 21.0186L11.71 18.3145H6.19434C5.30197 18.3144 4.54362 18.1476 3.91895 17.8145C3.29424 17.4813 2.81844 17.0055 2.49121 16.3867C2.16399 15.762 2.00001 15.0066 2 14.1201V7.19434C2.00003 6.30792 2.164 5.55524 2.49121 4.93652C2.81844 4.31192 3.2943 3.83314 3.91895 3.5C4.54361 3.16685 5.30199 3.00003 6.19434 3H17.8057ZM6.24805 4.75781C5.40331 4.75782 4.7786 4.96927 4.37402 5.3916C3.9635 5.80807 3.75782 6.42701 3.75781 7.24805V14.0576C3.75782 14.8846 3.9635 15.5092 4.37402 15.9316C4.7786 16.3481 5.40321 16.5566 6.24805 16.5566H11.7988C12.0725 16.5566 12.2934 16.5889 12.46 16.6543C12.6205 16.7138 12.796 16.839 12.9863 17.0293L15.8154 19.832V17.2881C15.8155 17.0204 15.8752 16.8327 15.9941 16.7256C16.1072 16.6128 16.2885 16.5567 16.5381 16.5566H17.7607C18.5996 16.5566 19.2242 16.3481 19.6348 15.9316C20.0393 15.5092 20.2422 14.8846 20.2422 14.0576V7.24805C20.2422 6.42701 20.0393 5.80807 19.6348 5.3916C19.2242 4.96931 18.5995 4.75781 17.7607 4.75781H6.24805Z"
fill="currentColor"
/>
</svg>

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View file

@ -1,3 +1,6 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M8.33542 7.4814C8.15766 7.4814 8.01164 7.42109 7.89737 7.30046C7.78309 7.17984 7.72595 7.037 7.72595 6.87193C7.72595 6.70052 7.78309 6.55768 7.89737 6.4434C8.01164 6.32913 8.15766 6.27199 8.33542 6.27199H15.3062C15.4776 6.27199 15.6205 6.32913 15.7347 6.4434C15.849 6.55768 15.9061 6.70052 15.9061 6.87193C15.9061 7.037 15.849 7.17984 15.7347 7.30046C15.6205 7.42109 15.4776 7.4814 15.3062 7.4814H8.33542ZM8.33542 10.7287C8.15766 10.7287 8.01164 10.6716 7.89737 10.5573C7.78309 10.4367 7.72595 10.2907 7.72595 10.1192C7.72595 9.95418 7.78309 9.81451 7.89737 9.70024C8.01164 9.58596 8.15766 9.52883 8.33542 9.52883H15.3062C15.4776 9.52883 15.6205 9.58596 15.7347 9.70024C15.849 9.81451 15.9061 9.95418 15.9061 10.1192C15.9061 10.2907 15.849 10.4367 15.7347 10.5573C15.6205 10.6716 15.4776 10.7287 15.3062 10.7287H8.33542ZM8.33542 13.9855C8.15766 13.9855 8.01164 13.9284 7.89737 13.8141C7.78309 13.6999 7.72595 13.5602 7.72595 13.3951C7.72595 13.2237 7.78309 13.0809 7.89737 12.9666C8.01164 12.846 8.15766 12.7857 8.33542 12.7857H11.7065C11.8843 12.7857 12.0303 12.846 12.1446 12.9666C12.2589 13.0809 12.316 13.2237 12.316 13.3951C12.316 13.5602 12.2589 13.6999 12.1446 13.8141C12.0303 13.9284 11.8843 13.9855 11.7065 13.9855H8.33542ZM3.65015 19.1851V4.81498C3.65015 3.79286 3.91044 3.01833 4.43103 2.49139C4.95161 1.95811 5.72297 1.69147 6.74509 1.69147H16.887C17.9091 1.69147 18.6805 1.95811 19.2011 2.49139C19.7217 3.01833 19.9819 3.79286 19.9819 4.81498V19.1851C19.9819 20.2135 19.7217 20.9912 19.2011 21.5182C18.6805 22.0451 17.9091 22.3086 16.887 22.3086H6.74509C5.72297 22.3086 4.95161 22.0451 4.43103 21.5182C3.91044 20.9912 3.65015 20.2135 3.65015 19.1851ZM5.52616 19.0708C5.52616 19.5088 5.64044 19.8453 5.86899 20.0802C6.09754 20.3151 6.44353 20.4326 6.90698 20.4326H16.7346C17.1981 20.4326 17.5441 20.3151 17.7726 20.0802C18.0012 19.8453 18.1155 19.5088 18.1155 19.0708V4.93878C18.1155 4.49438 18.0012 4.15473 17.7726 3.91983C17.5441 3.67858 17.1981 3.55796 16.7346 3.55796H6.90698C6.44353 3.55796 6.09754 3.67858 5.86899 3.91983C5.64044 4.15473 5.52616 4.49438 5.52616 4.93878V19.0708Z" fill="#222631"/>
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M8.33542 7.4814C8.15766 7.4814 8.01164 7.42109 7.89737 7.30046C7.78309 7.17984 7.72595 7.037 7.72595 6.87193C7.72595 6.70052 7.78309 6.55768 7.89737 6.4434C8.01164 6.32913 8.15766 6.27199 8.33542 6.27199H15.3062C15.4776 6.27199 15.6205 6.32913 15.7347 6.4434C15.849 6.55768 15.9061 6.70052 15.9061 6.87193C15.9061 7.037 15.849 7.17984 15.7347 7.30046C15.6205 7.42109 15.4776 7.4814 15.3062 7.4814H8.33542ZM8.33542 10.7287C8.15766 10.7287 8.01164 10.6716 7.89737 10.5573C7.78309 10.4367 7.72595 10.2907 7.72595 10.1192C7.72595 9.95418 7.78309 9.81451 7.89737 9.70024C8.01164 9.58596 8.15766 9.52883 8.33542 9.52883H15.3062C15.4776 9.52883 15.6205 9.58596 15.7347 9.70024C15.849 9.81451 15.9061 9.95418 15.9061 10.1192C15.9061 10.2907 15.849 10.4367 15.7347 10.5573C15.6205 10.6716 15.4776 10.7287 15.3062 10.7287H8.33542ZM8.33542 13.9855C8.15766 13.9855 8.01164 13.9284 7.89737 13.8141C7.78309 13.6999 7.72595 13.5602 7.72595 13.3951C7.72595 13.2237 7.78309 13.0809 7.89737 12.9666C8.01164 12.846 8.15766 12.7857 8.33542 12.7857H11.7065C11.8843 12.7857 12.0303 12.846 12.1446 12.9666C12.2589 13.0809 12.316 13.2237 12.316 13.3951C12.316 13.5602 12.2589 13.6999 12.1446 13.8141C12.0303 13.9284 11.8843 13.9855 11.7065 13.9855H8.33542ZM3.65015 19.1851V4.81498C3.65015 3.79286 3.91044 3.01833 4.43103 2.49139C4.95161 1.95811 5.72297 1.69147 6.74509 1.69147H16.887C17.9091 1.69147 18.6805 1.95811 19.2011 2.49139C19.7217 3.01833 19.9819 3.79286 19.9819 4.81498V19.1851C19.9819 20.2135 19.7217 20.9912 19.2011 21.5182C18.6805 22.0451 17.9091 22.3086 16.887 22.3086H6.74509C5.72297 22.3086 4.95161 22.0451 4.43103 21.5182C3.91044 20.9912 3.65015 20.2135 3.65015 19.1851ZM5.52616 19.0708C5.52616 19.5088 5.64044 19.8453 5.86899 20.0802C6.09754 20.3151 6.44353 20.4326 6.90698 20.4326H16.7346C17.1981 20.4326 17.5441 20.3151 17.7726 20.0802C18.0012 19.8453 18.1155 19.5088 18.1155 19.0708V4.93878C18.1155 4.49438 18.0012 4.15473 17.7726 3.91983C17.5441 3.67858 17.1981 3.55796 16.7346 3.55796H6.90698C6.44353 3.55796 6.09754 3.67858 5.86899 3.91983C5.64044 4.15473 5.52616 4.49438 5.52616 4.93878V19.0708Z"
fill="currentColor"
/>
</svg>

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View file

@ -1,3 +1,6 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6 14C5.45 14 4.97917 13.8042 4.5875 13.4125C4.19583 13.0208 4 12.55 4 12C4 11.45 4.19583 10.9792 4.5875 10.5875C4.97917 10.1958 5.45 10 6 10C6.55 10 7.02083 10.1958 7.4125 10.5875C7.80417 10.9792 8 11.45 8 12C8 12.55 7.80417 13.0208 7.4125 13.4125C7.02083 13.8042 6.55 14 6 14ZM12 14C11.45 14 10.9792 13.8042 10.5875 13.4125C10.1958 13.0208 10 12.55 10 12C10 11.45 10.1958 10.9792 10.5875 10.5875C10.9792 10.1958 11.45 10 12 10C12.55 10 13.0208 10.1958 13.4125 10.5875C13.8042 10.9792 14 11.45 14 12C14 12.55 13.8042 13.0208 13.4125 13.4125C13.0208 13.8042 12.55 14 12 14ZM18 14C17.45 14 16.9792 13.8042 16.5875 13.4125C16.1958 13.0208 16 12.55 16 12C16 11.45 16.1958 10.9792 16.5875 10.5875C16.9792 10.1958 17.45 10 18 10C18.55 10 19.0208 10.1958 19.4125 10.5875C19.8042 10.9792 20 11.45 20 12C20 12.55 19.8042 13.0208 19.4125 13.4125C19.0208 13.8042 18.55 14 18 14Z" fill="#222631"/>
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M6 14C5.45 14 4.97917 13.8042 4.5875 13.4125C4.19583 13.0208 4 12.55 4 12C4 11.45 4.19583 10.9792 4.5875 10.5875C4.97917 10.1958 5.45 10 6 10C6.55 10 7.02083 10.1958 7.4125 10.5875C7.80417 10.9792 8 11.45 8 12C8 12.55 7.80417 13.0208 7.4125 13.4125C7.02083 13.8042 6.55 14 6 14ZM12 14C11.45 14 10.9792 13.8042 10.5875 13.4125C10.1958 13.0208 10 12.55 10 12C10 11.45 10.1958 10.9792 10.5875 10.5875C10.9792 10.1958 11.45 10 12 10C12.55 10 13.0208 10.1958 13.4125 10.5875C13.8042 10.9792 14 11.45 14 12C14 12.55 13.8042 13.0208 13.4125 13.4125C13.0208 13.8042 12.55 14 12 14ZM18 14C17.45 14 16.9792 13.8042 16.5875 13.4125C16.1958 13.0208 16 12.55 16 12C16 11.45 16.1958 10.9792 16.5875 10.5875C16.9792 10.1958 17.45 10 18 10C18.55 10 19.0208 10.1958 19.4125 10.5875C19.8042 10.9792 20 11.45 20 12C20 12.55 19.8042 13.0208 19.4125 13.4125C19.0208 13.8042 18.55 14 18 14Z"
fill="currentColor"
/>
</svg>

Before

Width:  |  Height:  |  Size: 999 B

After

Width:  |  Height:  |  Size: 994 B

View file

@ -1,3 +1,6 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M11.9951 22.2189C10.5837 22.2189 9.26145 21.9518 8.02819 21.4176C6.79493 20.89 5.71006 20.158 4.77358 19.2215C3.83709 18.2916 3.10176 17.21 2.56756 15.9768C2.03997 14.7369 1.77617 13.4113 1.77617 12C1.77617 10.5887 2.03997 9.26641 2.56756 8.03315C3.10176 6.7933 3.83709 5.70513 4.77358 4.76865C5.71006 3.83216 6.79493 3.10012 8.02819 2.57252C9.26145 2.04493 10.5837 1.78113 11.9951 1.78113C13.4064 1.78113 14.7287 2.04493 15.9619 2.57252C17.2018 3.10012 18.2899 3.83216 19.2264 4.76865C20.1629 5.70513 20.895 6.7933 21.4226 8.03315C21.9567 9.26641 22.2238 10.5887 22.2238 12C22.2238 13.4113 21.9567 14.7369 21.4226 15.9768C20.895 17.21 20.1629 18.2916 19.2264 19.2215C18.2899 20.158 17.2018 20.89 15.9619 21.4176C14.7287 21.9518 13.4064 22.2189 11.9951 22.2189ZM11.9951 20.2009C13.1294 20.2009 14.1912 19.9865 15.1804 19.5578C16.1697 19.1358 17.0402 18.5488 17.792 17.797C18.5505 17.0452 19.1407 16.1746 19.5628 15.1854C19.9849 14.1961 20.1959 13.1344 20.1959 12C20.1959 10.8657 19.9849 9.8039 19.5628 8.81465C19.1407 7.81881 18.5505 6.94828 17.792 6.20305C17.0402 5.45122 16.1697 4.86427 15.1804 4.44219C14.1912 4.01352 13.1294 3.79919 11.9951 3.79919C10.8673 3.79919 9.80553 4.01352 8.80969 4.44219C7.82045 4.86427 6.94992 5.45122 6.19809 6.20305C5.44626 6.94828 4.85602 7.81881 4.42734 8.81465C4.00527 9.8039 3.79423 10.8657 3.79423 12C3.79423 13.1344 4.00527 14.1961 4.42734 15.1854C4.85602 16.1746 5.44626 17.0452 6.19809 17.797C6.94992 18.5488 7.82045 19.1358 8.80969 19.5578C9.80553 19.9865 10.8673 20.2009 11.9951 20.2009ZM11.7774 13.9686C11.1509 13.9686 10.8376 13.6883 10.8376 13.1278C10.8376 13.108 10.8376 13.0882 10.8376 13.0684C10.8376 13.0486 10.8376 13.0321 10.8376 13.0189C10.8376 12.5639 10.9498 12.1946 11.174 11.911C11.4048 11.6274 11.6983 11.3636 12.0544 11.1196C12.4765 10.8294 12.7898 10.5821 12.9942 10.3777C13.2052 10.1732 13.3108 9.91601 13.3108 9.60605C13.3108 9.26971 13.1855 8.99602 12.9348 8.78498C12.6908 8.56734 12.3677 8.45853 11.9654 8.45853C11.7675 8.45853 11.5829 8.4915 11.4114 8.55745C11.2465 8.6234 11.0916 8.71903 10.9465 8.84433C10.808 8.96304 10.6827 9.11143 10.5705 9.28949L10.4123 9.49723C10.3199 9.62254 10.2078 9.72146 10.0759 9.79401C9.95062 9.86655 9.79894 9.90282 9.62087 9.90282C9.41643 9.90282 9.23507 9.83358 9.07679 9.69508C8.91851 9.55659 8.83937 9.36863 8.83937 9.13121C8.83937 9.03888 8.84597 8.95315 8.85916 8.87401C8.87894 8.78827 8.90532 8.70254 8.9383 8.61681C9.08998 8.15516 9.43951 7.75616 9.9869 7.41982C10.5409 7.08348 11.2432 6.91531 12.094 6.91531C12.6743 6.91531 13.2085 7.01753 13.6966 7.22197C14.1912 7.42641 14.5869 7.71989 14.8837 8.1024C15.1804 8.48491 15.3288 8.94985 15.3288 9.49723C15.3288 10.0776 15.1804 10.5359 14.8837 10.8723C14.5935 11.2086 14.2077 11.5384 13.7262 11.8615C13.3965 12.0726 13.1459 12.2737 12.9744 12.465C12.8029 12.6562 12.7106 12.8804 12.6974 13.1377C12.6974 13.1508 12.6974 13.1706 12.6974 13.197C12.6974 13.2168 12.6941 13.2366 12.6875 13.2564C12.6743 13.4542 12.5853 13.6224 12.4204 13.7609C12.2622 13.8994 12.0478 13.9686 11.7774 13.9686ZM11.7576 17.0056C11.4411 17.0056 11.1674 16.9034 10.9366 16.6989C10.7123 16.4879 10.6002 16.2274 10.6002 15.9174C10.6002 15.6075 10.7123 15.3503 10.9366 15.1458C11.1608 14.9348 11.4345 14.8293 11.7576 14.8293C12.0808 14.8293 12.3545 14.9315 12.5787 15.1359C12.8029 15.3404 12.9151 15.6009 12.9151 15.9174C12.9151 16.234 12.8029 16.4945 12.5787 16.6989C12.3545 16.9034 12.0808 17.0056 11.7576 17.0056Z" fill="#222631"/>
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M11.9951 22.2189C10.5837 22.2189 9.26145 21.9518 8.02819 21.4176C6.79493 20.89 5.71006 20.158 4.77358 19.2215C3.83709 18.2916 3.10176 17.21 2.56756 15.9768C2.03997 14.7369 1.77617 13.4113 1.77617 12C1.77617 10.5887 2.03997 9.26641 2.56756 8.03315C3.10176 6.7933 3.83709 5.70513 4.77358 4.76865C5.71006 3.83216 6.79493 3.10012 8.02819 2.57252C9.26145 2.04493 10.5837 1.78113 11.9951 1.78113C13.4064 1.78113 14.7287 2.04493 15.9619 2.57252C17.2018 3.10012 18.2899 3.83216 19.2264 4.76865C20.1629 5.70513 20.895 6.7933 21.4226 8.03315C21.9567 9.26641 22.2238 10.5887 22.2238 12C22.2238 13.4113 21.9567 14.7369 21.4226 15.9768C20.895 17.21 20.1629 18.2916 19.2264 19.2215C18.2899 20.158 17.2018 20.89 15.9619 21.4176C14.7287 21.9518 13.4064 22.2189 11.9951 22.2189ZM11.9951 20.2009C13.1294 20.2009 14.1912 19.9865 15.1804 19.5578C16.1697 19.1358 17.0402 18.5488 17.792 17.797C18.5505 17.0452 19.1407 16.1746 19.5628 15.1854C19.9849 14.1961 20.1959 13.1344 20.1959 12C20.1959 10.8657 19.9849 9.8039 19.5628 8.81465C19.1407 7.81881 18.5505 6.94828 17.792 6.20305C17.0402 5.45122 16.1697 4.86427 15.1804 4.44219C14.1912 4.01352 13.1294 3.79919 11.9951 3.79919C10.8673 3.79919 9.80553 4.01352 8.80969 4.44219C7.82045 4.86427 6.94992 5.45122 6.19809 6.20305C5.44626 6.94828 4.85602 7.81881 4.42734 8.81465C4.00527 9.8039 3.79423 10.8657 3.79423 12C3.79423 13.1344 4.00527 14.1961 4.42734 15.1854C4.85602 16.1746 5.44626 17.0452 6.19809 17.797C6.94992 18.5488 7.82045 19.1358 8.80969 19.5578C9.80553 19.9865 10.8673 20.2009 11.9951 20.2009ZM11.7774 13.9686C11.1509 13.9686 10.8376 13.6883 10.8376 13.1278C10.8376 13.108 10.8376 13.0882 10.8376 13.0684C10.8376 13.0486 10.8376 13.0321 10.8376 13.0189C10.8376 12.5639 10.9498 12.1946 11.174 11.911C11.4048 11.6274 11.6983 11.3636 12.0544 11.1196C12.4765 10.8294 12.7898 10.5821 12.9942 10.3777C13.2052 10.1732 13.3108 9.91601 13.3108 9.60605C13.3108 9.26971 13.1855 8.99602 12.9348 8.78498C12.6908 8.56734 12.3677 8.45853 11.9654 8.45853C11.7675 8.45853 11.5829 8.4915 11.4114 8.55745C11.2465 8.6234 11.0916 8.71903 10.9465 8.84433C10.808 8.96304 10.6827 9.11143 10.5705 9.28949L10.4123 9.49723C10.3199 9.62254 10.2078 9.72146 10.0759 9.79401C9.95062 9.86655 9.79894 9.90282 9.62087 9.90282C9.41643 9.90282 9.23507 9.83358 9.07679 9.69508C8.91851 9.55659 8.83937 9.36863 8.83937 9.13121C8.83937 9.03888 8.84597 8.95315 8.85916 8.87401C8.87894 8.78827 8.90532 8.70254 8.9383 8.61681C9.08998 8.15516 9.43951 7.75616 9.9869 7.41982C10.5409 7.08348 11.2432 6.91531 12.094 6.91531C12.6743 6.91531 13.2085 7.01753 13.6966 7.22197C14.1912 7.42641 14.5869 7.71989 14.8837 8.1024C15.1804 8.48491 15.3288 8.94985 15.3288 9.49723C15.3288 10.0776 15.1804 10.5359 14.8837 10.8723C14.5935 11.2086 14.2077 11.5384 13.7262 11.8615C13.3965 12.0726 13.1459 12.2737 12.9744 12.465C12.8029 12.6562 12.7106 12.8804 12.6974 13.1377C12.6974 13.1508 12.6974 13.1706 12.6974 13.197C12.6974 13.2168 12.6941 13.2366 12.6875 13.2564C12.6743 13.4542 12.5853 13.6224 12.4204 13.7609C12.2622 13.8994 12.0478 13.9686 11.7774 13.9686ZM11.7576 17.0056C11.4411 17.0056 11.1674 16.9034 10.9366 16.6989C10.7123 16.4879 10.6002 16.2274 10.6002 15.9174C10.6002 15.6075 10.7123 15.3503 10.9366 15.1458C11.1608 14.9348 11.4345 14.8293 11.7576 14.8293C12.0808 14.8293 12.3545 14.9315 12.5787 15.1359C12.8029 15.3404 12.9151 15.6009 12.9151 15.9174C12.9151 16.234 12.8029 16.4945 12.5787 16.6989C12.3545 16.9034 12.0808 17.0056 11.7576 17.0056Z"
fill="currentColor"
/>
</svg>

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View file

@ -1,3 +1,6 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M4.4 21L3 19.6L10.525 12.05L6 10.925L10.95 7.85L10.525 2L15 5.775L20.4 3.575L18.225 9L22 13.45L16.15 13.05L13.05 18L11.925 13.475L4.4 21ZM5 8L3 6L5 4L7 6L5 8ZM13.875 12.925L15.075 10.95L17.4 11.125L15.9 9.35L16.775 7.2L14.625 8.075L12.85 6.6L13.025 8.9L11.05 10.125L13.3 10.675L13.875 12.925ZM18 21L16 19L18 17L20 19L18 21Z" fill="#222631"/>
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M4.4 21L3 19.6L10.525 12.05L6 10.925L10.95 7.85L10.525 2L15 5.775L20.4 3.575L18.225 9L22 13.45L16.15 13.05L13.05 18L11.925 13.475L4.4 21ZM5 8L3 6L5 4L7 6L5 8ZM13.875 12.925L15.075 10.95L17.4 11.125L15.9 9.35L16.775 7.2L14.625 8.075L12.85 6.6L13.025 8.9L11.05 10.125L13.3 10.675L13.875 12.925ZM18 21L16 19L18 17L20 19L18 21Z"
fill="currentColor"
/>
</svg>

Before

Width:  |  Height:  |  Size: 454 B

After

Width:  |  Height:  |  Size: 449 B

View file

@ -0,0 +1,134 @@
import { Button } from '@gouvfr-lasuite/cunningham-react';
import Head from 'next/head';
import Image, { StaticImageData } from 'next/image';
import { useTranslation } from 'react-i18next';
import styled from 'styled-components';
import { Box, Icon, StyledLink, Text } from '@/components';
const StyledButton = styled(Button)`
width: fit-content;
`;
interface ErrorPageProps {
image: StaticImageData;
description: string;
refreshTarget?: string;
showReload?: boolean;
}
const getSafeRefreshUrl = (target?: string): string | undefined => {
if (!target) {
return undefined;
}
if (typeof window === 'undefined') {
return target.startsWith('/') && !target.startsWith('//')
? target
: undefined;
}
try {
const url = new URL(target, window.location.origin);
if (url.origin !== window.location.origin) {
return undefined;
}
return url.pathname + url.search + url.hash;
} catch {
return undefined;
}
};
export const ErrorPage = ({
image,
description,
refreshTarget,
showReload,
}: ErrorPageProps) => {
const { t } = useTranslation();
const errorTitle = t('An unexpected error occurred.');
const safeTarget = getSafeRefreshUrl(refreshTarget);
return (
<>
<Head>
<title>
{errorTitle} - {t('Docs')}
</title>
<meta
property="og:title"
content={`${errorTitle} - ${t('Docs')}`}
key="title"
/>
</Head>
<Box
$align="center"
$margin="auto"
$gap="md"
$padding={{ bottom: '2rem' }}
>
<Text as="h1" $textAlign="center" className="sr-only">
{errorTitle} - {t('Docs')}
</Text>
<Image
src={image}
alt=""
width={300}
style={{
maxWidth: '100%',
height: 'auto',
}}
/>
<Text
as="p"
$textAlign="center"
$maxWidth="350px"
$theme="neutral"
$margin="0"
>
{description}
</Text>
<Box $direction="row" $gap="sm">
<StyledLink href="/">
<StyledButton
color="neutral"
icon={
<Icon
iconName="house"
variant="symbols-outlined"
$withThemeInherited
/>
}
>
{t('Home')}
</StyledButton>
</StyledLink>
{(safeTarget || showReload) && (
<StyledButton
color="neutral"
variant="bordered"
icon={
<Icon
iconName="refresh"
variant="symbols-outlined"
$withThemeInherited
/>
}
onClick={() =>
safeTarget
? window.location.assign(safeTarget)
: window.location.reload()
}
>
{t('Refresh page')}
</StyledButton>
)}
</Box>
</Box>
</>
);
};

View file

@ -4,6 +4,7 @@ export * from './Card';
export * from './DropButton';
export * from './dropdown-menu/DropdownMenu';
export * from './Emoji/EmojiPicker';
export * from './ErrorPage';
export * from './quick-search';
export * from './Icon';
export * from './InfiniteScroll';

View file

@ -1,5 +1,5 @@
import { Command } from 'cmdk';
import { PropsWithChildren, ReactNode, useId, useRef, useState } from 'react';
import { PropsWithChildren, ReactNode, useId, useRef } from 'react';
import { hasChildrens } from '@/utils/children';
@ -24,6 +24,7 @@ export type QuickSearchData<T> = {
};
export type QuickSearchProps = {
isSelectByDefault?: boolean;
onFilter?: (str: string) => void;
inputValue?: string;
inputContent?: ReactNode;
@ -36,6 +37,7 @@ export type QuickSearchProps = {
};
export const QuickSearch = ({
isSelectByDefault,
onFilter,
inputContent,
inputValue,
@ -47,13 +49,6 @@ export const QuickSearch = ({
}: PropsWithChildren<QuickSearchProps>) => {
const ref = useRef<HTMLDivElement | null>(null);
const listId = useId();
/**
* Hack to prevent cmdk from auto-selecting the first element on open
*
* TODO: Find a clean solution to prevent cmdk from auto-selecting
* the first element on open
*/
const [selectedValue, _] = useState('__none__');
return (
<>
@ -65,7 +60,7 @@ export const QuickSearch = ({
ref={ref}
tabIndex={-1}
disablePointerSelection
value={selectedValue}
value={!isSelectByDefault ? '__none__' : undefined}
>
{showInput && (
<QuickSearchInput

View file

@ -19,7 +19,13 @@ export const QuickSearchGroup = <T,>({
}: Props<T>) => {
return (
<Box>
<Text as="h2" $weight="700" $size="sm" $margin="none">
<Text
className="--docs--quick-search-group-title"
as="h2"
$weight="700"
$size="sm"
$margin="none"
>
{group.groupName}
</Text>
<Command.Group
@ -61,7 +67,11 @@ export const QuickSearchGroup = <T,>({
);
})}
{group.emptyString && group.elements.length === 0 && (
<Text $margin={{ left: '2xs', bottom: '3xs' }} $size="sm">
<Text
className="--docs--quick-search-group-empty"
$margin={{ left: '2xs', bottom: '3xs' }}
$size="sm"
>
{group.emptyString}
</Text>
)}

View file

@ -1,7 +1,6 @@
import { ReactNode } from 'react';
import { useCunninghamTheme } from '@/cunningham';
import { useResponsiveStore } from '@/stores';
import { Box } from '../Box';
@ -18,29 +17,29 @@ export const QuickSearchItemContent = ({
}: QuickSearchItemContentProps) => {
const { spacingsTokens } = useCunninghamTheme();
const { isDesktop } = useResponsiveStore();
return (
<Box
className="--docs--quick-search-item-content"
$direction="row"
$align="center"
$padding={{ horizontal: '2xs', vertical: '4xs' }}
$justify="space-between"
$minHeight="34px"
$width="100%"
$gap="sm"
>
<Box
className="--docs--quick-search-item-content-left"
$direction="row"
$align="center"
$gap={spacingsTokens['2xs']}
$width="100%"
>
{left}
</Box>
{isDesktop && right && (
{right && (
<Box
className={!alwaysShowRight ? 'show-right-on-focus' : ''}
className={`--docs--quick-search-item-content-right ${!alwaysShowRight ? 'show-right-on-focus' : ''}`}
$direction="row"
$align="center"
>

View file

@ -16,17 +16,20 @@ interface ThemeCustomization {
light: LinkHTMLAttributes<HTMLLinkElement>;
dark: LinkHTMLAttributes<HTMLLinkElement>;
};
onboarding?: {
enabled: true;
learn_more_url?: string;
};
footer?: FooterType;
header?: HeaderType;
help: {
documentation_url?: string;
};
home: {
'with-proconnect'?: boolean;
'icon-banner'?: Imagetype;
};
onboarding?: {
enabled: true;
learn_more_url?: string;
};
translations?: Resource;
header?: HeaderType;
waffle?: WaffleType;
}

View file

@ -18,32 +18,30 @@ import { FirstConnection } from './FirstConnection';
export const Auth = ({ children }: PropsWithChildren) => {
const {
isLoading: isAuthLoading,
isAuthLoading,
pathAllowed,
isFetchedAfterMount,
authenticated,
fetchStatus,
hasInitiallyLoaded,
user,
} = useAuth();
const isLoading = fetchStatus !== 'idle' || isAuthLoading;
const [isRedirecting, setIsRedirecting] = useState(false);
const { data: config } = useConfig();
const shouldTrySilentLogin = useMemo(
() =>
!authenticated &&
!hasTrySilent() &&
!isLoading &&
!isAuthLoading &&
!isRedirecting &&
config?.FRONTEND_SILENT_LOGIN_ENABLED,
[
authenticated,
isLoading,
isAuthLoading,
isRedirecting,
config?.FRONTEND_SILENT_LOGIN_ENABLED,
],
);
const shouldTryLogin =
!authenticated && !isLoading && !isRedirecting && !pathAllowed;
!authenticated && !isAuthLoading && !isRedirecting && !pathAllowed;
const { replace, pathname } = useRouter();
/**
@ -104,7 +102,7 @@ export const Auth = ({ children }: PropsWithChildren) => {
]);
const shouldShowLoader =
(isLoading && !isFetchedAfterMount) ||
!hasInitiallyLoaded ||
isRedirecting ||
(!authenticated && !pathAllowed) ||
shouldTrySilentLogin;

View file

@ -3,5 +3,5 @@ import { baseApiUrl } from '@/api';
export const HOME_URL = '/home/';
export const LOGIN_URL = `${baseApiUrl()}authenticate/`;
export const LOGOUT_URL = `${baseApiUrl()}logout/`;
export const PATH_AUTH_LOCAL_STORAGE = 'docs-path-auth';
export const PATH_AUTH_SESSION_STORAGE = 'docs-path-auth';
export const SILENT_LOGIN_RETRY = 'silent-login-retry';

View file

@ -1,5 +1,5 @@
import { useRouter } from 'next/router';
import { useEffect, useState } from 'react';
import { useEffect, useRef, useState } from 'react';
import { useAnalytics } from '@/libs';
@ -12,6 +12,12 @@ export const useAuth = () => {
const { pathname } = useRouter();
const { trackEvent } = useAnalytics();
const [hasTracked, setHasTracked] = useState(authStates.isFetched);
const isAuthLoading =
authStates.fetchStatus !== 'idle' || authStates.isLoading;
const hasInitiallyLoaded = useRef(false);
if (authStates.isFetched) {
hasInitiallyLoaded.current = true;
}
const [pathAllowed, setPathAllowed] = useState<boolean>(
!regexpUrlsAuth.some((regexp) => !!pathname.match(regexp)),
);
@ -35,6 +41,8 @@ export const useAuth = () => {
user,
authenticated: !!user && authStates.isSuccess,
pathAllowed,
hasInitiallyLoaded: hasInitiallyLoaded.current,
isAuthLoading,
...authStates,
};
};

View file

@ -1,35 +1,36 @@
import { terminateCrispSession } from '@/services/Crisp';
import { safeLocalStorage } from '@/utils/storages';
import { safeLocalStorage, safeSessionStorage } from '@/utils/storages';
import {
HOME_URL,
LOGIN_URL,
LOGOUT_URL,
PATH_AUTH_LOCAL_STORAGE,
PATH_AUTH_SESSION_STORAGE,
SILENT_LOGIN_RETRY,
} from './conf';
/**
* Get the stored auth URL from local storage
* Get the stored auth URL from session storage (per-tab)
*/
export const getAuthUrl = () => {
const path_auth = safeLocalStorage.getItem(PATH_AUTH_LOCAL_STORAGE);
const path_auth = safeSessionStorage.getItem(PATH_AUTH_SESSION_STORAGE);
if (path_auth) {
safeLocalStorage.removeItem(PATH_AUTH_LOCAL_STORAGE);
safeSessionStorage.removeItem(PATH_AUTH_SESSION_STORAGE);
return path_auth;
}
};
/**
* Store the current path in local storage if it's not the homepage or root
* so we can redirect the user to this path after login
* Store the current path in session storage (per-tab) if it's not the
* homepage or root, so we can redirect the user to this path after login.
* Using sessionStorage ensures each tab independently tracks its own URL.
*/
export const setAuthUrl = () => {
if (
window.location.pathname !== '/' &&
window.location.pathname !== `${HOME_URL}/`
) {
safeLocalStorage.setItem(PATH_AUTH_LOCAL_STORAGE, window.location.href);
safeSessionStorage.setItem(PATH_AUTH_SESSION_STORAGE, window.location.href);
}
};

View file

@ -0,0 +1,177 @@
import fetchMock from 'fetch-mock';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import {
checkDocMediaStatus,
loopCheckDocMediaStatus,
} from '../checkDocMediaStatus';
const VALID_URL = 'http://test.jest/media-check/some-file-id';
describe('checkDocMediaStatus', () => {
beforeEach(() => {
fetchMock.restore();
});
afterEach(() => {
fetchMock.restore();
});
it('returns the response when the status is ready', async () => {
fetchMock.get(VALID_URL, {
body: { status: 'ready', file: '/media/some-file.pdf' },
});
const result = await checkDocMediaStatus({ urlMedia: VALID_URL });
expect(result).toEqual({ status: 'ready', file: '/media/some-file.pdf' });
expect(fetchMock.lastOptions(VALID_URL)).toMatchObject({
credentials: 'include',
});
});
it('returns the response when the status is processing', async () => {
fetchMock.get(VALID_URL, {
body: { status: 'processing' },
});
const result = await checkDocMediaStatus({ urlMedia: VALID_URL });
expect(result).toEqual({ status: 'processing' });
});
it('throws an APIError when the URL is not safe', async () => {
await expect(
checkDocMediaStatus({ urlMedia: 'javascript:alert(1)' }),
).rejects.toMatchObject({ status: 400 });
expect(fetchMock.calls().length).toBe(0);
});
it('throws an APIError when the URL does not contain the analyze path', async () => {
await expect(
checkDocMediaStatus({ urlMedia: 'http://test.jest/other/path' }),
).rejects.toMatchObject({ status: 400 });
expect(fetchMock.calls().length).toBe(0);
});
it('throws an APIError when the fetch response is not ok', async () => {
fetchMock.get(VALID_URL, {
status: 500,
body: JSON.stringify({ detail: 'Internal server error' }),
});
await expect(
checkDocMediaStatus({ urlMedia: VALID_URL }),
).rejects.toMatchObject({ status: 500 });
});
it('forwards the AbortSignal to fetch', async () => {
const controller = new AbortController();
controller.abort();
fetchMock.get(VALID_URL, { body: { status: 'ready' } });
await expect(
checkDocMediaStatus({ urlMedia: VALID_URL, signal: controller.signal }),
).rejects.toThrow();
});
});
describe('loopCheckDocMediaStatus', () => {
beforeEach(() => {
vi.useFakeTimers();
fetchMock.restore();
});
afterEach(() => {
vi.useRealTimers();
fetchMock.restore();
});
it('resolves immediately when the status is already ready', async () => {
fetchMock.get(VALID_URL, {
body: { status: 'ready', file: '/media/file.pdf' },
});
const result = await loopCheckDocMediaStatus(
VALID_URL,
new AbortController().signal,
);
expect(result).toEqual({ status: 'ready', file: '/media/file.pdf' });
expect(fetchMock.calls().length).toBe(1);
});
it('retries until the status becomes ready', async () => {
let callCount = 0;
fetchMock.mock(VALID_URL, () => {
callCount++;
return {
status: 200,
body: JSON.stringify(
callCount >= 3
? { status: 'ready', file: '/media/file.pdf' }
: { status: 'processing' },
),
};
});
const promise = loopCheckDocMediaStatus(
VALID_URL,
new AbortController().signal,
);
// Advance timers for each sleep between retries
await vi.runAllTimersAsync();
const result = await promise;
expect(result).toEqual({ status: 'ready', file: '/media/file.pdf' });
expect(fetchMock.calls().length).toBe(3);
});
it('throws an AbortError immediately when the signal is already aborted', async () => {
const controller = new AbortController();
controller.abort();
fetchMock.get(VALID_URL, { body: { status: 'processing' } });
await expect(
loopCheckDocMediaStatus(VALID_URL, controller.signal),
).rejects.toMatchObject({ name: 'AbortError' });
expect(fetchMock.calls().length).toBe(0);
});
it('stops the loop when the signal is aborted during a sleep', async () => {
fetchMock.get(VALID_URL, { body: { status: 'processing' } });
const controller = new AbortController();
const rejectExpectation = expect(
loopCheckDocMediaStatus(VALID_URL, controller.signal),
).rejects.toMatchObject({ name: 'AbortError' });
controller.abort();
await rejectExpectation;
// Only the first request should have been made
expect(fetchMock.calls().length).toBe(1);
});
it('rejects when a fetch error occurs', async () => {
fetchMock.get(VALID_URL, {
status: 500,
body: JSON.stringify({ detail: 'Internal server error' }),
});
// Error happens on the first fetch — no timer advancement needed.
await expect(
loopCheckDocMediaStatus(VALID_URL, new AbortController().signal),
).rejects.toMatchObject({ status: 500 });
expect(fetchMock.calls().length).toBe(1);
});
});

View file

@ -1,5 +1,4 @@
import { APIError, errorCauses } from '@/api';
import { sleep } from '@/utils';
import { isSafeUrl } from '@/utils/url';
import { ANALYZE_URL } from '../conf';
@ -11,10 +10,12 @@ interface CheckDocMediaStatusResponse {
interface CheckDocMediaStatus {
urlMedia: string;
signal?: AbortSignal;
}
export const checkDocMediaStatus = async ({
urlMedia,
signal,
}: CheckDocMediaStatus): Promise<CheckDocMediaStatusResponse> => {
if (!isSafeUrl(urlMedia) || !urlMedia.includes(ANALYZE_URL)) {
throw new APIError('Url invalid', { status: 400 });
@ -22,6 +23,7 @@ export const checkDocMediaStatus = async ({
const response = await fetch(urlMedia, {
credentials: 'include',
signal,
});
if (!response.ok) {
@ -34,27 +36,56 @@ export const checkDocMediaStatus = async ({
return response.json() as Promise<CheckDocMediaStatusResponse>;
};
/**
* A sleep function that can be aborted using an AbortSignal.
* If the signal is aborted, the promise will reject with an 'Aborted' error.
* @param ms The number of milliseconds to sleep.
* @param signal The AbortSignal to cancel the sleep.
* @returns A promise that resolves after the specified time or rejects if aborted.
*/
const abortableSleep = (ms: number, signal: AbortSignal) =>
new Promise<void>((resolve, reject) => {
const timeout = setTimeout(resolve, ms);
signal.addEventListener(
'abort',
() => {
clearTimeout(timeout);
reject(new DOMException('Aborted', 'AbortError'));
},
{ once: true },
);
});
/**
* Upload file can be analyzed on the server side,
* we had this function to wait for the analysis to be done
* before returning the file url. It will keep the loader
* on the upload button until the analysis is done.
* @param url
* @param signal AbortSignal to cancel the loop (e.g. on component unmount)
* @returns Promise<CheckDocMediaStatusResponse> status_code
* @description Waits for the upload to be analyzed by checking the status of the file.
*/
export const loopCheckDocMediaStatus = async (
url: string,
signal: AbortSignal,
): Promise<CheckDocMediaStatusResponse> => {
const SLEEP_TIME = 5000;
const response = await checkDocMediaStatus({
urlMedia: url,
});
/**
* Check if the signal has been aborted before making the API call.
* This prevents unnecessary API calls and allows for a faster response to cancellation.
*/
if (signal.aborted) {
throw new DOMException('Aborted', 'AbortError');
}
const response = await checkDocMediaStatus({ urlMedia: url, signal });
if (response.status === 'ready') {
return response;
} else {
await sleep(SLEEP_TIME);
return await loopCheckDocMediaStatus(url);
}
await abortableSleep(SLEEP_TIME, signal);
return loopCheckDocMediaStatus(url, signal);
};

View file

@ -53,10 +53,7 @@ const AIMenu = BlockNoteAI?.AIMenu;
const AIMenuController = BlockNoteAI?.AIMenuController;
const useAI = BlockNoteAI?.useAI;
const localesBNAI = BlockNoteAI?.localesAI || {};
import {
InterlinkingLinkInlineContent,
InterlinkingSearchInlineContent,
} from './custom-inline-content';
import { InterlinkingLinkInlineContent } from './custom-inline-content';
import XLMultiColumn from './xl-multi-column';
const localesBNMultiColumn = XLMultiColumn?.locales;
@ -74,7 +71,6 @@ const baseBlockNoteSchema = withPageBreak(
},
inlineContentSpecs: {
...defaultInlineContentSpecs,
interlinkingSearchInline: InterlinkingSearchInlineContent,
interlinkingLinkInline: InterlinkingLinkInlineContent,
},
}),
@ -303,11 +299,13 @@ export const BlockNoteEditor = ({ doc, provider }: BlockNoteEditorProps) => {
interface BlockNoteReaderProps {
docId: Doc['id'];
initialContent: Y.XmlFragment;
isMainEditor?: boolean;
}
export const BlockNoteReader = ({
docId,
initialContent,
isMainEditor = true,
}: BlockNoteReaderProps) => {
const { user } = useAuth();
const { setEditor } = useEditorStore();
@ -336,12 +334,19 @@ export const BlockNoteReader = ({
);
useEffect(() => {
if (!isMainEditor) {
return;
}
setEditor(editor);
return () => {
if (!isMainEditor) {
return;
}
setEditor(undefined);
};
}, [setEditor, editor]);
}, [setEditor, editor, isMainEditor]);
useHeadings(editor);

View file

@ -1,7 +1,7 @@
import { CommentBody, ThreadStore } from '@blocknote/core/comments';
import type { Awareness } from 'y-protocols/awareness';
import { APIError, APIList, errorCauses, fetchAPI } from '@/api';
import { APIError, errorCauses, fetchAPI } from '@/api';
import { Doc } from '@/features/docs/doc-management';
import { useEditorStore } from '../../stores';
@ -15,7 +15,7 @@ import {
ServerThread,
} from './types';
type ServerThreadListResponse = APIList<ServerThread>;
type ServerThreadListResponse = ServerThread[];
export class DocsThreadStore extends ThreadStore {
protected static COMMENTS_PING = 'commentsPing';
@ -335,7 +335,7 @@ export class DocsThreadStore extends ThreadStore {
const threads = (await response.json()) as ServerThreadListResponse;
const next = new Map<string, ClientThreadData>();
threads.results.forEach((thread) => {
threads.forEach((thread) => {
const threadData: ClientThreadData = serverThreadToClientThread(thread);
next.set(thread.id, threadData);
});

View file

@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next';
import { useCunninghamTheme } from '@/cunningham';
import { User, avatarUrlFromName } from '@/features/auth';
import { useEditorStore } from '@/features/docs/doc-editor/stores';
import { Doc, useProviderStore } from '@/features/docs/doc-management';
import { DocsThreadStore } from './DocsThreadStore';
@ -16,6 +17,7 @@ export function useComments(
const { provider } = useProviderStore();
const { t } = useTranslation();
const { themeTokens } = useCunninghamTheme();
const { setThreadStore } = useEditorStore();
const threadStore = useMemo(() => {
return new DocsThreadStore(
@ -28,6 +30,18 @@ export function useComments(
);
}, [docId, canComment, provider?.awareness, user?.full_name]);
useEffect(() => {
if (canComment) {
setThreadStore(threadStore);
}
return () => {
if (canComment) {
setThreadStore(undefined);
}
};
}, [threadStore, setThreadStore, canComment]);
useEffect(() => {
return () => {
threadStore?.destroy();

View file

@ -72,8 +72,9 @@ const UploadLoaderBlockComponent = ({
}
const url = block.props.blockUploadUrl;
const controller = new AbortController();
loopCheckDocMediaStatus(url)
loopCheckDocMediaStatus(url, controller.signal)
.then((response) => {
// Add random delay to reduce collision probability during collaboration
const randomDelay = Math.random() * 800;
@ -101,7 +102,11 @@ const UploadLoaderBlockComponent = ({
}
}, randomDelay);
})
.catch((error) => {
.catch((error: unknown) => {
if (error instanceof DOMException && error.name === 'AbortError') {
return;
}
console.error('Error analyzing file:', error);
try {
@ -118,6 +123,10 @@ const UploadLoaderBlockComponent = ({
/* During collaboration, another user might have updated the block */
}
});
return () => {
controller.abort();
};
}, [block, editor, mediaUrl, isEditable]);
return (

View file

@ -1,26 +1,57 @@
import {
PartialCustomInlineContentFromConfig,
StyleSchema,
} from '@blocknote/core';
import { StyleSchema } from '@blocknote/core';
import { createReactInlineContentSpec } from '@blocknote/react';
import * as Sentry from '@sentry/nextjs';
import { useRouter } from 'next/router';
import { TFunction } from 'i18next';
import { useEffect } from 'react';
import { css } from 'styled-components';
import { validate as uuidValidate } from 'uuid';
import { BoxButton, Text } from '@/components';
import { useCunninghamTheme } from '@/cunningham';
import SelectedPageIcon from '@/docs/doc-editor/assets/doc-selected.svg';
import { getEmojiAndTitle, useDoc } from '@/docs/doc-management/';
import { DocsBlockNoteEditor } from '@/docs/doc-editor';
import LinkPageIcon from '@/docs/doc-editor/assets/doc-link.svg';
import AddPageIcon from '@/docs/doc-editor/assets/doc-plus.svg';
import { useCreateChildDocTree, useDocStore } from '@/docs/doc-management';
export const InterlinkingLinkInlineContent = createReactInlineContentSpec(
import { LinkSelected } from './LinkSelected';
import { SearchPage } from './SearchPage';
export type InterlinkingLinkInlineContentType = {
type: 'interlinkingLinkInline';
propSchema: {
disabled?: {
default: false;
values: [true, false];
};
docId?: {
default: '';
};
trigger?: {
default: '/';
values: readonly ['/', '@'];
};
title?: {
default: '';
};
};
content: 'none';
};
export const InterlinkingLinkInlineContent = createReactInlineContentSpec<
InterlinkingLinkInlineContentType,
StyleSchema
>(
{
type: 'interlinkingLinkInline',
propSchema: {
docId: {
default: '',
},
disabled: {
default: false,
values: [true, false],
},
trigger: {
default: '/',
values: ['/', '@'],
},
title: {
default: '',
},
@ -28,152 +59,126 @@ export const InterlinkingLinkInlineContent = createReactInlineContentSpec(
content: 'none',
},
{
render: ({ editor, inlineContent, updateInlineContent }) => {
if (!inlineContent.props.docId) {
/**
* Can have 3 render states:
* 1. Disabled state: when the inline content is disabled, it renders nothing
* 2. Search state: when the inline content has no docId, it renders the search page
* 3. Linked state: when the inline content has a docId and title, it renders the linked doc
*
* Info: We keep everything in the same inline content to easily preserve
* the element position when switching between states
*/
render: (props) => {
const { disabled, docId, title } = props.inlineContent.props;
if (disabled) {
return null;
}
/**
* Should not happen
*/
if (!uuidValidate(inlineContent.props.docId)) {
Sentry.captureException(
new Error(`Invalid docId: ${inlineContent.props.docId}`),
{
extra: { info: 'InterlinkingLinkInlineContent' },
},
if (docId && title) {
/**
* Should not happen
*/
if (!uuidValidate(docId)) {
return (
<DisableInvalidInterlink
docId={docId}
onUpdateInlineContent={() => {
props.updateInlineContent({
type: 'interlinkingLinkInline',
props: {
disabled: true,
},
});
}}
/>
);
}
return (
<LinkSelected
docId={docId}
title={title}
isEditable={props.editor.isEditable}
onUpdateTitle={(newTitle) =>
props.updateInlineContent({
type: 'interlinkingLinkInline',
props: {
docId: docId,
title: newTitle,
trigger: props.inlineContent.props.trigger,
disabled: false,
},
})
}
/>
);
updateInlineContent({
type: 'interlinkingLinkInline',
props: {
docId: '',
title: '',
},
});
return null;
}
return (
<LinkSelected
docId={inlineContent.props.docId}
title={inlineContent.props.title}
isEditable={editor.isEditable}
updateInlineContent={updateInlineContent}
/>
);
return <SearchPage {...props} />;
},
},
);
interface LinkSelectedProps {
docId: string;
title: string;
isEditable: boolean;
updateInlineContent: (
update: PartialCustomInlineContentFromConfig<
{
readonly type: 'interlinkingLinkInline';
readonly propSchema: {
readonly docId: {
readonly default: '';
};
readonly title: {
readonly default: '';
};
};
readonly content: 'none';
},
StyleSchema
>,
) => void;
}
export const LinkSelected = ({
docId,
title,
isEditable,
updateInlineContent,
}: LinkSelectedProps) => {
const { data: doc } = useDoc({ id: docId, withoutContent: true });
/**
* Update the content title if the referenced doc title changes
*/
useEffect(() => {
if (isEditable && doc?.title && doc.title !== title) {
updateInlineContent({
type: 'interlinkingLinkInline',
props: {
docId,
title: doc.title,
export const getInterlinkinghMenuItems = (
editor: DocsBlockNoteEditor,
t: TFunction<'translation', undefined>,
group: string,
createPage: () => void,
) => [
{
key: 'link-doc',
title: t('Link a doc'),
onItemClick: () => {
editor.insertInlineContent([
{
type: 'interlinkingLinkInline',
props: {
trigger: '/',
},
},
});
}
]);
},
aliases: ['interlinking', 'link', 'anchor', 'a'],
group,
icon: <LinkPageIcon />,
subtext: t('Link this doc to another doc'),
},
{
key: 'new-sub-doc',
title: t('New sub-doc'),
onItemClick: createPage,
aliases: ['new sub-doc'],
group,
icon: <AddPageIcon />,
subtext: t('Create a new sub-doc'),
},
];
/**
* When doing collaborative editing, doc?.title might be out of sync
* causing an infinite loop of updates.
* To prevent this, we only run this effect when doc?.title changes,
* not when inlineContent.props.title changes.
*/
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [doc?.title, docId, isEditable]);
const { colorsTokens } = useCunninghamTheme();
const { emoji, titleWithoutEmoji } = getEmojiAndTitle(title);
const router = useRouter();
const handleClick = (e: React.MouseEvent<HTMLDivElement>) => {
e.preventDefault();
void router.push(`/docs/${docId}/`);
};
export const useGetInterlinkingMenuItems = () => {
const { currentDoc } = useDocStore();
const createChildDoc = useCreateChildDocTree(currentDoc?.id);
return (
<BoxButton
as="span"
className="--docs--interlinking-link-inline-content"
onClick={handleClick}
draggable="false"
$css={css`
display: inline;
padding: 0.1rem 0.4rem;
border-radius: 4px;
& svg {
position: relative;
top: 2px;
margin-right: 0.2rem;
}
&:hover {
background-color: var(
--c--contextuals--background--semantic--contextual--primary
);
}
transition: background-color var(--c--globals--transitions--duration)
var(--c--globals--transitions--ease-out);
.--docs--doc-deleted & {
pointer-events: none;
}
`}
>
{emoji ? (
<Text $size="16px">{emoji}</Text>
) : (
<SelectedPageIcon width={11.5} color={colorsTokens['brand-400']} />
)}
<Text
$weight="500"
spellCheck="false"
$size="16px"
$display="inline"
$css={css`
margin-left: 2px;
`}
>
{titleWithoutEmoji}
</Text>
</BoxButton>
);
editor: DocsBlockNoteEditor,
t: TFunction<'translation', undefined>,
) => getInterlinkinghMenuItems(editor, t, t('Links'), createChildDoc);
};
const DisableInvalidInterlink = ({
docId,
onUpdateInlineContent,
}: {
docId: string;
onUpdateInlineContent: () => void;
}) => {
useEffect(() => {
Sentry.captureException(new Error(`Invalid docId: ${docId}`), {
extra: { info: 'InterlinkingInlineContent' },
});
onUpdateInlineContent();
}, [docId, onUpdateInlineContent]);
return null;
};

View file

@ -1,87 +0,0 @@
import { createReactInlineContentSpec } from '@blocknote/react';
import { TFunction } from 'i18next';
import { DocsBlockNoteEditor } from '@/docs/doc-editor';
import LinkPageIcon from '@/docs/doc-editor/assets/doc-link.svg';
import AddPageIcon from '@/docs/doc-editor/assets/doc-plus.svg';
import { useCreateChildDocTree, useDocStore } from '@/docs/doc-management';
import { SearchPage } from './SearchPage';
export const InterlinkingSearchInlineContent = createReactInlineContentSpec(
{
type: 'interlinkingSearchInline',
propSchema: {
trigger: {
default: '/',
values: ['/', '@'],
},
disabled: {
default: false,
values: [true, false],
},
},
content: 'styled',
},
{
render: (props) => {
if (props.inlineContent.props.disabled) {
return null;
}
return (
<SearchPage
{...props}
trigger={props.inlineContent.props.trigger}
contentRef={props.contentRef}
/>
);
},
},
);
export const getInterlinkinghMenuItems = (
editor: DocsBlockNoteEditor,
t: TFunction<'translation', undefined>,
group: string,
createPage: () => void,
) => [
{
key: 'link-doc',
title: t('Link a doc'),
onItemClick: () => {
editor.insertInlineContent([
{
type: 'interlinkingSearchInline',
props: {
disabled: false,
trigger: '/',
},
},
]);
},
aliases: ['interlinking', 'link', 'anchor', 'a'],
group,
icon: <LinkPageIcon />,
subtext: t('Link this doc to another doc'),
},
{
key: 'new-sub-doc',
title: t('New sub-doc'),
onItemClick: createPage,
aliases: ['new sub-doc'],
group,
icon: <AddPageIcon />,
subtext: t('Create a new sub-doc'),
},
];
export const useGetInterlinkingMenuItems = () => {
const { currentDoc } = useDocStore();
const createChildDoc = useCreateChildDocTree(currentDoc?.id);
return (
editor: DocsBlockNoteEditor,
t: TFunction<'translation', undefined>,
) => getInterlinkinghMenuItems(editor, t, t('Links'), createChildDoc);
};

Some files were not shown because too many files have changed in this diff Show more