🐛 Fix rpc methods on plugins e2e tests

This commit is contained in:
Andrey Antukh 2026-02-10 19:09:54 +01:00
parent 1e7bef081a
commit bd7f4dca3a
2 changed files with 13 additions and 11 deletions

View File

@ -1,24 +1,26 @@
import { FileRpc } from '../models/file-rpc.model'; import { FileRpc } from '../models/file-rpc.model';
const apiUrl = 'http://localhost:3449'; const apiUrl = 'https://localhost:3449';
export async function PenpotApi() { export async function PenpotApi() {
if (!process.env['E2E_LOGIN_EMAIL']) { if (!process.env['E2E_LOGIN_EMAIL']) {
throw new Error('E2E_LOGIN_EMAIL not set'); throw new Error('E2E_LOGIN_EMAIL not set');
} }
const body = JSON.stringify({
'email': process.env['E2E_LOGIN_EMAIL'],
'password': process.env['E2E_LOGIN_PASSWORD'],
});
const resultLoginRequest = await fetch( const resultLoginRequest = await fetch(
`${apiUrl}/api/rpc/command/login-with-password`, `${apiUrl}/api/main/methods/login-with-password`,
{ {
credentials: 'include', credentials: 'include',
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/transit+json', 'Content-Type': 'application/json'
}, },
body: JSON.stringify({ body: body
'~:email': process.env['E2E_LOGIN_EMAIL'],
'~:password': process.env['E2E_LOGIN_PASSWORD'],
}),
}, },
); );
@ -44,7 +46,7 @@ export async function PenpotApi() {
getAuth: () => authToken, getAuth: () => authToken,
createFile: async () => { createFile: async () => {
const createFileRequest = await fetch( const createFileRequest = await fetch(
`${apiUrl}/api/rpc/command/create-file`, `${apiUrl}/api/main/methods/create-file`,
{ {
method: 'POST', method: 'POST',
headers: { headers: {
@ -74,7 +76,7 @@ export async function PenpotApi() {
}, },
deleteFile: async (fileId: string) => { deleteFile: async (fileId: string) => {
const deleteFileRequest = await fetch( const deleteFileRequest = await fetch(
`${apiUrl}/api/rpc/command/delete-file`, `${apiUrl}/api/main/methods/delete-file`,
{ {
method: 'POST', method: 'POST',
headers: { headers: {

View File

@ -4,7 +4,7 @@
1. **Configure Environment Variables** 1. **Configure Environment Variables**
Create and populate the `.env` file with a valid user mail & password: Create and populate the `apps/e2e/.env` file with a valid user mail & password:
```env ```env
E2E_LOGIN_EMAIL="test@penpot.app" E2E_LOGIN_EMAIL="test@penpot.app"
@ -24,7 +24,7 @@
1. **Adding Tests** 1. **Adding Tests**
Place your test files in the `/apps/e2e/src/**/*.spec.ts` directory. Below is an example of a test file: Place your test files in the `apps/e2e/src/**/*.spec.ts` directory. Below is an example of a test file:
```ts ```ts
import testingPlugin from './plugins/create-board-text-rect'; import testingPlugin from './plugins/create-board-text-rect';