Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: file upload (minio, s3, frontend...) #443

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3b3bcb4
wip: Upload file
ivan-dalmet Oct 25, 2023
36f89f2
WIP Working
yoannfleurydev Jul 24, 2024
7b44b85
fix: after squash and master rebase
yoannfleurydev Feb 17, 2025
1daf3c9
fix: avatar data
ivan-dalmet Feb 17, 2025
592dacb
fix: check bucket url and remove files router
ivan-dalmet Feb 17, 2025
ac22b8b
fix: ligther code
ivan-dalmet Feb 17, 2025
b8ebc5d
fix: serializable metadata and file type
yoannfleurydev Feb 17, 2025
1244dc1
feat: some improvement to function names
yoannfleurydev Feb 17, 2025
95dffdb
ci: upload artifact version and pnpm
yoannfleurydev Feb 17, 2025
7080193
feat: type in implementation not in helper
yoannfleurydev Feb 17, 2025
a5f6e73
feat: file size and type
yoannfleurydev Feb 17, 2025
bff986f
feat: extract configuration and validation
yoannfleurydev Feb 17, 2025
0673b4f
fix: use POST for presigned url
ivan-dalmet Feb 18, 2025
ffe42ef
fix: size and time
ivan-dalmet Feb 18, 2025
ed6728b
wip: fetch metadata on server and store only key instead of full url
ivan-dalmet Feb 19, 2025
0d0b373
fix: move /files into /lib/s3
ivan-dalmet Feb 19, 2025
08e8337
wip: refacto files config
ivan-dalmet Feb 19, 2025
833eab9
fix: use same validation in server and client
ivan-dalmet Feb 19, 2025
983cde7
fix: file upload field elipsis
ivan-dalmet Feb 21, 2025
4e99980
fix: remove unused imports
ivan-dalmet Feb 21, 2025
599c689
fix: fetch metadata error response
ivan-dalmet Feb 24, 2025
74a947b
fix: use placeholder instead of inputText
ivan-dalmet Feb 24, 2025
8f69e89
feat: add accept on file upload field
ivan-dalmet Feb 24, 2025
dbac239
fix: wrong file size for avatar
ivan-dalmet Feb 24, 2025
36922cb
fix: simple usage
ivan-dalmet Feb 24, 2025
9885347
fix: docker compose port issue
ivan-dalmet Mar 5, 2025
602d924
fix: metadata schema
ivan-dalmet Mar 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ yarn-debug.log*
yarn-error.log*

# local env files
.env
.env.local
.env.development.local
.env.test.local
Expand Down
12 changes: 12 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# DOCKER
DOCKER_MINIO_FORWARD_PORT="9000"
DOCKER_MINIO_FORWARD_CONSOLE_PORT="9090"
DOCKER_MINIO_USERNAME="startui"
DOCKER_MINIO_PASSWORD="password"
DOCKER_DATABASE_PORT="5432"
DOCKER_DATABASE_NAME="startui"
DOCKER_DATABASE_USERNAME="startui"
DOCKER_DATABASE_PASSWORD="startui"


# PUBLIC CONFIG
NEXT_PUBLIC_BASE_URL="http://localhost:3000"
# Use the following environment variables to show the environment name.
Expand Down Expand Up @@ -38,3 +43,10 @@ EMAIL_FROM="Start UI <noreply@example.com>"
# LOGGER
LOGGER_LEVEL="info"
LOGGER_PRETTY="true"

# S3
S3_ENDPOINT="http://127.0.0.1:${DOCKER_MINIO_FORWARD_PORT}"
S3_BUCKET_NAME="start-ui-bucket"
S3_BUCKET_PUBLIC_URL="http://127.0.0.1:${DOCKER_MINIO_FORWARD_PORT}/${S3_BUCKET_NAME}"
S3_ACCESS_KEY_ID="miniodevuser"
S3_SECRET_ACCESS_KEY="miniodevuserpassword"
1 change: 0 additions & 1 deletion .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jobs:
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 8
run_install: false

- name: Get pnpm store directory
Expand Down
27 changes: 25 additions & 2 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ jobs:
AUTH_SECRET: Replace me with `openssl rand -base64 32` generated secret
EMAIL_SERVER: smtp://username:password@localhost:1025
EMAIL_FROM: Start UI <noreply@example.com>
S3_ENDPOINT: http://127.0.0.1:9000
S3_BUCKET_NAME: start-ui-bucket
S3_BUCKET_PUBLIC_URL: http://127.0.0.1:9000/start-ui-bucket
S3_ACCESS_KEY_ID: miniotestuser
S3_SECRET_ACCESS_KEY: miniotestuserpassword

services:
postgres:
image: postgres
Expand All @@ -50,16 +56,33 @@ jobs:
with:
node-version: 20

# - name: Setup minio
# env:
# MINIO_ACCESS_KEY: minioadmin
# MINIO_SECRET_KEY: minioadmin
# run: |
# docker run -d -p 9000:9000 --name minio
# -e MINIO_ACCESS_KEY=startui \
# -e MINIO_SECRET_KEY=password \
# -v /tmp/data:/data \
# -v /tmp/config:/root/.minio \
# minio/minio server /data

# export S3_ACCESS_KEY_ID=miniotestuser
# export S3_SECRET_ACCESS_KEY=miniotestuserpassword
# export AWS_EC2_METADATA_DISABLED=true

# aws --endpoint-url http://127.0.0.1:9000/start-ui-bucket s3 mb s3://testbucket

- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 9
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
echo STORE_PATH=$(pnpm store path --silent) >> $GITHUB_ENV

- name: Cache node modules
uses: actions/cache@v4
Expand Down
21 changes: 11 additions & 10 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { useEffect } from 'react';
import { Box, useColorMode } from '@chakra-ui/react';
import { Preview } from '@storybook/react';
import { themes } from '@storybook/theming';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { useTranslation } from 'react-i18next';
import { useDarkMode } from 'storybook-dark-mode';

Expand All @@ -12,10 +13,8 @@ import {
AVAILABLE_LANGUAGES,
DEFAULT_LANGUAGE_KEY,
} from '../src/lib/i18n/constants';
// @ts-ignore don't want to implement a d.ts declaration for storybook only
import logoReversed from './logo-reversed.svg';
// @ts-ignore don't want to implement a d.ts declaration for storybook only
import logo from './logo.svg';

const queryClient = new QueryClient();

const DocumentationWrapper = ({ children, context, isDarkMode }) => {
const { i18n } = useTranslation();
Expand Down Expand Up @@ -86,12 +85,14 @@ const preview: Preview = {
const isDarkMode = useDarkMode();
return (
<Providers>
<DocumentationWrapper isDarkMode={isDarkMode} context={context}>
{/* Calling as a function to avoid errors. Learn more at:
* https://github.com/storybookjs/storybook/issues/15223#issuecomment-1092837912
*/}
{story(context)}
</DocumentationWrapper>
<QueryClientProvider client={queryClient}>
<DocumentationWrapper isDarkMode={isDarkMode} context={context}>
{/* Calling as a function to avoid errors. Learn more at:
* https://github.com/storybookjs/storybook/issues/15223#issuecomment-1092837912
*/}
{story(context)}
</DocumentationWrapper>
</QueryClientProvider>
</Providers>
);
},
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ A live read-only demonstration of what you will have when starting a project wit

- [NodeJS](https://nodejs.org/) >=20
- [Pnpm](https://pnpm.io/)
- [Docker](https://www.docker.com/) (or a [PostgreSQL](https://www.postgresql.org/) database)
- [Docker](https://www.docker.com/) (or a [PostgreSQL](https://www.postgresql.org/) database and an [S3 compatible](https://aws.amazon.com/s3/) service)

## Getting Started

Expand Down Expand Up @@ -53,14 +53,17 @@ cp .env.example .env
pnpm install
```

3. Setup and start the db with docker
3. Setup and start the services (database and S3) with docker
```bash
pnpm dk:init
```

> [!NOTE]
> **Don't want to use docker?**
>
> Setup a PostgreSQL database (locally or online) and replace the **DATABASE_URL** environment variable. Then you can run `pnpm db:push` to update your database schema and then run `pnpm db:seed` to seed your database.
> For S3, Start UI [web] comes with a Minio service. You can use any online S3 compatible services and update the
> environment variables accordingly.

## Development

Expand Down
59 changes: 59 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,68 @@
services:
postgres:
image: postgres:16.1
env_file:
- .env
ports:
- '${DOCKER_DATABASE_PORT:-5432}:5432'
environment:
POSTGRES_DB: $DOCKER_DATABASE_NAME
POSTGRES_USER: $DOCKER_DATABASE_USERNAME
POSTGRES_PASSWORD: $DOCKER_DATABASE_PASSWORD
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U $DOCKER_DATABASE_NAME']
interval: 10s
timeout: 5s
retries: 5
Comment on lines +12 to +16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

❓ Verification inconclusive

Postgres Healthcheck Variable Mismatch
The healthcheck command currently uses $DOCKER_DATABASE_NAME for the -U flag, which expects a username. It should likely be $DOCKER_DATABASE_USERNAME to correctly check connectivity.

-      test: ['CMD-SHELL', 'pg_isready -U $DOCKER_DATABASE_NAME']
+      test: ['CMD-SHELL', 'pg_isready -U $DOCKER_DATABASE_USERNAME']

Critical Issue: Postgres Healthcheck Environment Variable

The healthcheck command in docker-compose.yml is incorrectly using $DOCKER_DATABASE_NAME for the -U flag, which requires a username. This should be replaced with $DOCKER_DATABASE_USERNAME to ensure that the healthcheck correctly verifies connectivity.

  • Location: docker-compose.yml, Lines 12-16
  • Suggested Change:
    -      test: ['CMD-SHELL', 'pg_isready -U $DOCKER_DATABASE_NAME']
    +      test: ['CMD-SHELL', 'pg_isready -U $DOCKER_DATABASE_USERNAME']
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U $DOCKER_DATABASE_NAME']
interval: 10s
timeout: 5s
retries: 5
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U $DOCKER_DATABASE_USERNAME']
interval: 10s
timeout: 5s
retries: 5


initializedatabase:
build:
context: .
dockerfile: docker/initialize-database.dockerfile
depends_on:
postgres:
condition: service_healthy
environment:
DATABASE_URL: 'postgres://${DOCKER_DATABASE_USERNAME}:${DOCKER_DATABASE_PASSWORD}@postgres:${DOCKER_DATABASE_PORT}/${DOCKER_DATABASE_NAME}'

minio:
image: 'minio/minio:RELEASE.2024-07-16T23-46-41Z-cpuv1'
ports:
- '${DOCKER_FORWARD_MINIO_PORT:-9000}:9000'
- '${DOCKER_FORWARD_MINIO_CONSOLE_PORT:-9090}:9090'
environment:
MINIO_ROOT_USER: $DOCKER_MINIO_USERNAME
MINIO_ROOT_PASSWORD: $DOCKER_MINIO_PASSWORD
volumes:
- 'minio:/data/minio'
command: minio server /data/minio --console-address ":${FORWARD_MINIO_CONSOLE_PORT:-9090}"
healthcheck:
test: ['CMD', 'mc', 'ready', 'local']
interval: 5s
timeout: 5s
retries: 5

Comment on lines +28 to +44
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

⚠️ Potential issue

MinIO Service Configuration & Environment Variable Consistency
The MinIO service has been configured with appropriate port mappings, environment variables, and healthchecks. One point to note: the port mapping references the environment variable DOCKER_FORWARD_MINIO_CONSOLE_PORT (line 31) while the command uses ${FORWARD_MINIO_CONSOLE_PORT:-9090} (line 38). This inconsistency might lead to unexpected behavior. Please update the command to use the consistent variable name. For example:

-    command: minio server /data/minio --console-address ":${FORWARD_MINIO_CONSOLE_PORT:-9090}"
+    command: minio server /data/minio --console-address ":${DOCKER_FORWARD_MINIO_CONSOLE_PORT:-9090}"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
minio:
image: 'minio/minio:RELEASE.2024-07-16T23-46-41Z-cpuv1'
ports:
- '${DOCKER_FORWARD_MINIO_PORT:-9000}:9000'
- '${DOCKER_FORWARD_MINIO_CONSOLE_PORT:-9090}:9090'
environment:
MINIO_ROOT_USER: $DOCKER_MINIO_USERNAME
MINIO_ROOT_PASSWORD: $DOCKER_MINIO_PASSWORD
volumes:
- 'minio:/data/minio'
command: minio server /data/minio --console-address ":${FORWARD_MINIO_CONSOLE_PORT:-9090}"
healthcheck:
test: ['CMD', 'mc', 'ready', 'local']
interval: 5s
timeout: 5s
retries: 5
minio:
image: 'minio/minio:RELEASE.2024-07-16T23-46-41Z-cpuv1'
ports:
- '${DOCKER_FORWARD_MINIO_PORT:-9000}:9000'
- '${DOCKER_FORWARD_MINIO_CONSOLE_PORT:-9090}:9090'
environment:
MINIO_ROOT_USER: $DOCKER_MINIO_USERNAME
MINIO_ROOT_PASSWORD: $DOCKER_MINIO_PASSWORD
volumes:
- 'minio:/data/minio'
- command: minio server /data/minio --console-address ":${FORWARD_MINIO_CONSOLE_PORT:-9090}"
+ command: minio server /data/minio --console-address ":${DOCKER_FORWARD_MINIO_CONSOLE_PORT:-9090}"
healthcheck:
test: ['CMD', 'mc', 'ready', 'local']
interval: 5s
timeout: 5s
retries: 5

createbuckets:
image: minio/mc
depends_on:
minio:
condition: service_healthy
# Set an alias, meaning myminio is an alias for the host, the username and the password, avoiding to type it again in the next commands
# As an admin, add a new user to scope minio access to this new user, avoiding to use the admin credentials in the application
# Set the policy readwrite to the user we previously created on the previously created alias
# Create the bucket on the previously created alias
# Set the public access policy to download, meaning readonly.
entrypoint: >
/bin/sh -c "
/usr/bin/mc alias set myminio http://minio:${DOCKER_FORWARD_MINIO_PORT:-9000} $DOCKER_MINIO_USERNAME $DOCKER_MINIO_PASSWORD;
/usr/bin/mc admin user add myminio $S3_ACCESS_KEY_ID $S3_SECRET_ACCESS_KEY;
/usr/bin/mc admin policy attach myminio readwrite --user $S3_ACCESS_KEY_ID;
/usr/bin/mc mb myminio/$S3_BUCKET_NAME;
/usr/bin/mc anonymous set download myminio/$S3_BUCKET_NAME;
exit 0;
"
Comment on lines +56 to +63
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add validation and error handling to createbuckets service.

The current shell script doesn't check for errors or validate that operations have succeeded, which could lead to silent failures.

Add error checking to ensure each command completes successfully:

     entrypoint: >
       /bin/sh -c "
-      /usr/bin/mc alias set myminio http://minio:${DOCKER_FORWARD_MINIO_PORT:-9000} $DOCKER_MINIO_USERNAME $DOCKER_MINIO_PASSWORD;
-      /usr/bin/mc admin user add myminio $S3_ACCESS_KEY_ID $S3_SECRET_ACCESS_KEY;
-      /usr/bin/mc admin policy attach myminio readwrite --user $S3_ACCESS_KEY_ID;
-      /usr/bin/mc mb myminio/$S3_BUCKET_NAME;
-      /usr/bin/mc anonymous set download myminio/$S3_BUCKET_NAME;
-      exit 0;
+      /usr/bin/mc alias set myminio http://minio:${DOCKER_FORWARD_MINIO_PORT:-9000} $DOCKER_MINIO_USERNAME $DOCKER_MINIO_PASSWORD || exit 1;
+      /usr/bin/mc admin user add myminio $S3_ACCESS_KEY_ID $S3_SECRET_ACCESS_KEY 2>/dev/null || echo 'User already exists';
+      /usr/bin/mc admin policy attach myminio readwrite --user $S3_ACCESS_KEY_ID || exit 1;
+      /usr/bin/mc mb myminio/$S3_BUCKET_NAME 2>/dev/null || echo 'Bucket already exists';
+      /usr/bin/mc anonymous set download myminio/$S3_BUCKET_NAME || exit 1;
+      echo 'S3 configuration completed successfully';
       "
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/bin/sh -c "
/usr/bin/mc alias set myminio http://minio:${DOCKER_FORWARD_MINIO_PORT:-9000} $DOCKER_MINIO_USERNAME $DOCKER_MINIO_PASSWORD;
/usr/bin/mc admin user add myminio $S3_ACCESS_KEY_ID $S3_SECRET_ACCESS_KEY;
/usr/bin/mc admin policy attach myminio readwrite --user $S3_ACCESS_KEY_ID;
/usr/bin/mc mb myminio/$S3_BUCKET_NAME;
/usr/bin/mc anonymous set download myminio/$S3_BUCKET_NAME;
exit 0;
"
entrypoint: >
/bin/sh -c "
/usr/bin/mc alias set myminio http://minio:${DOCKER_FORWARD_MINIO_PORT:-9000} $DOCKER_MINIO_USERNAME $DOCKER_MINIO_PASSWORD || exit 1;
/usr/bin/mc admin user add myminio $S3_ACCESS_KEY_ID $S3_SECRET_ACCESS_KEY 2>/dev/null || echo 'User already exists';
/usr/bin/mc admin policy attach myminio readwrite --user $S3_ACCESS_KEY_ID || exit 1;
/usr/bin/mc mb myminio/$S3_BUCKET_NAME 2>/dev/null || echo 'Bucket already exists';
/usr/bin/mc anonymous set download myminio/$S3_BUCKET_NAME || exit 1;
echo 'S3 configuration completed successfully';
"


# use docker compose down --volumes to remove volumes declared in this file
volumes:
minio:
driver: local
13 changes: 13 additions & 0 deletions docker/initialize-database.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:20-alpine

WORKDIR /usr/src/app

COPY . .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Optimize Docker context.

Copying the entire project directory is inefficient. Consider using a .dockerignore file to exclude unnecessary files and directories.


🏁 Script executed:

#!/bin/bash
# Check if .dockerignore exists and its contents
if [ -f .dockerignore ]; then
    echo "Found .dockerignore:"
    cat .dockerignore
else
    echo ".dockerignore not found"
fi

Length of output: 626


Optimize Docker build context and enhance container reliability.
The repository's root-level .dockerignore file is present and effectively excludes many unnecessary files. However, using COPY . . in docker/initialize-database.dockerfile still transfers the entire project context—which may include files not essential for database initialization. To further optimize your Docker build and container behavior, please consider the following improvements:

  • Selective Copying: Instead of copying the whole project, explicitly copy only the files and directories required for database initialization.
  • Health Check: Add a health check in the Dockerfile to confirm that the database container is fully initialized and ready.
  • Dependency Versioning: Pin the pnpm version to avoid potential issues from version updates.

Please update the Dockerfile accordingly.


RUN apk upgrade --update-cache --available && \
apk add openssl && \
rm -rf /var/cache/apk/*
RUN npm install -g pnpm@latest-9
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Consider using a specific pnpm version.

Using pnpm@latest-9 could lead to unexpected behavior if a new version introduces breaking changes.

-RUN npm install -g pnpm@latest-9
+RUN npm install -g pnpm@9.x.x

🌐 Web query:

What is the latest stable version of pnpm 9?

💡 Result:

The latest stable version of pnpm 9 is v9.15.5, based on recent patch updates listed in the release notes[3]. This version includes security improvements and bug fixes such as:

  • POSIX-compatible script argument quoting for newline support[3]
  • Proxy setting enforcement for Git-hosted dependencies[3]
  • Dependency build script verification enhancements[3]

While pnpm has since released major versions (currently v10.x), the final stable release in the v9 series remains v9.15.5 as of February 2025[3][6]. This version maintains compatibility with Node.js v18+ and includes all security patches backported from later major releases[4].

Citations:


Pin pnpm to a specific stable version (v9.15.5) in the Dockerfile

To avoid potential issues from future breaking changes introduced in newer pnpm releases, please update the command in docker/initialize-database.dockerfile to install the stable version v9.15.5 for the pnpm v9 series. Based on the latest information, the stable release is v9.15.5.

-RUN npm install -g pnpm@latest-9
+RUN npm install -g pnpm@9.15.5
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
RUN npm install -g pnpm@latest-9
RUN npm install -g pnpm@9.15.5

RUN pnpm install

CMD [ "pnpm", "db:init" ]
46 changes: 46 additions & 0 deletions e2e/avatar-upload.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { expect, test } from '@playwright/test';
import { pageUtils } from 'e2e/utils/pageUtils';
import { USER_EMAIL } from 'e2e/utils/users';

import { env } from '@/env.mjs';
import { ROUTES_ACCOUNT } from '@/features/account/routes';
import { ROUTES_APP } from '@/features/app/routes';
import locales from '@/locales';

test.beforeEach('Login to the app', async ({ page }) => {
const utils = pageUtils(page);

await utils.loginApp({ email: USER_EMAIL });
await page.waitForURL(
`${env.NEXT_PUBLIC_BASE_URL}${ROUTES_APP.root() || '/'}**`
);
await expect(page.getByTestId('app-layout')).toBeVisible();
});
test.describe('Avatar upload flow', () => {
test('Upload an avatar', async ({ page }) => {
await expect(page.getByTestId('avatar-account')).toBeVisible();

await page.getByTestId('avatar-account').click();

await page.waitForURL(`**${ROUTES_ACCOUNT.app.root()}`);
await expect(
page.getByText(locales.en.account.data.avatar.placeholder)
).toBeVisible();

const fileChooserPromise = page.waitForEvent('filechooser');

await page.getByText(locales.en.account.data.avatar.placeholder).click();

const fileChooser = await fileChooserPromise;
await fileChooser.setFiles('./public/android-chrome-192x192.png');

await page
.getByRole('button', { name: locales.en.account.profile.actions.update })
.first()
.click();

await expect(
page.locator('a[data-testid="avatar-account"] > img')
).toHaveAttribute('src');
});
});
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"private": true,
"version": "2.0.0",
"description": "Opinionated UI starter with ⚛️ React, ⚡️ Chakra UI, ⚛️ React Query & 📋 React Hook Form — From the 🐻 BearStudio Team",
"packageManager": "pnpm@9.15.0",
"engines": {
"node": ">=20"
},
Expand All @@ -29,7 +30,7 @@
"test:ui": "vitest --ui",
"e2e": "dotenv -- cross-var playwright test",
"e2e:ui": "dotenv -- cross-var playwright test --ui",
"dk:init": "docker compose up -d && sleep 10 && pnpm db:init",
"dk:init": "docker compose up -d",
"dk:start": "docker compose start",
"dk:stop": "docker compose stop",
"dk:clear": "docker compose down --volumes",
Expand All @@ -42,6 +43,8 @@
"*.{ts,tsx,js,jsx,json}": "prettier --write"
},
"dependencies": {
"@aws-sdk/client-s3": "3.435.0",
"@aws-sdk/s3-request-presigner": "3.435.0",
"@chakra-ui/anatomy": "2.2.2",
"@chakra-ui/next-js": "2.2.0",
"@chakra-ui/react": "2.8.2",
Expand Down
Loading
Loading