Compare commits

...

4 Commits

Author SHA1 Message Date
Andrey Antukh
0b68edf84e 🚧 WIP 2026-02-10 19:18:03 +01:00
Andrey Antukh
afe7d41adf 🐛 Fix rpc methods on plugins e2e tests 2026-02-10 19:09:54 +01:00
Andrey Antukh
96f9e796be Allow self-signed certs on plugins e2e browser setup 2026-02-10 19:09:00 +01:00
Andrey Antukh
28eac35660 Enable cors by default on devenv 2026-02-10 19:08:21 +01:00
8 changed files with 36 additions and 17 deletions

View File

@@ -29,6 +29,8 @@ export PENPOT_FLAGS="\
enable-user-feedback \
disable-secure-session-cookies \
enable-smtp \
enable-cors \
disable-secure-session-cookies \
enable-prepl-server \
enable-urepl-server \
enable-rpc-climit \

View File

@@ -213,14 +213,14 @@
(assoc "access-control-allow-origin" origin)
(assoc "access-control-allow-methods" "GET,POST,DELETE,OPTIONS,PUT,HEAD,PATCH")
(assoc "access-control-allow-credentials" "true")
(assoc "access-control-expose-headers" "x-requested-with, content-type, cookie")
(assoc "access-control-allow-headers" "x-frontend-version, content-type, accept, x-requested-width")))
(assoc "access-control-expose-headers" "content-type, set-cookie")
(assoc "access-control-allow-headers" "x-frontend-version, x-client, x-requested-width, content-type, accept, cookie")))
(defn wrap-cors
[handler]
(fn [request]
(let [response (if (= (yreq/method request) :options)
{::yres/status 200}
{::yres/status 204}
(handler request))
origin (yreq/get-header request "origin")]
(update response ::yres/headers with-cors-headers origin))))

View File

@@ -11,7 +11,7 @@ import comments from './plugins/create-comments';
import { Agent } from './utils/agent';
describe('Plugins', () => {
it('create board - text - rectable', async () => {
it.only('create board - text - rectable', async () => {
const agent = await Agent();
const result = await agent.runCode(testingPlugin.toString(), {
screenshot: 'create-board-text-rect',

View File

@@ -56,10 +56,13 @@ export async function Agent() {
console.log('File URL:', fileUrl);
console.log('Launching browser...');
const browser = await puppeteer.launch({});
const browser = await puppeteer.launch({args: ['--ignore-certificate-errors']});
const page = await browser.newPage();
await page.setViewport({ width: 1920, height: 1080 });
await page.setExtraHTTPHeaders({
'X-Client': 'plugins/e2e:puppeter',
});
console.log('Setting authentication cookie...');
page.setCookie({

View File

@@ -1,27 +1,38 @@
import { FileRpc } from '../models/file-rpc.model';
const apiUrl = 'http://localhost:3449';
const apiUrl = 'https://localhost:3449';
export async function PenpotApi() {
if (!process.env['E2E_LOGIN_EMAIL']) {
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(
`${apiUrl}/api/rpc/command/login-with-password`,
`${apiUrl}/api/main/methods/login-with-password`,
{
credentials: 'include',
method: 'POST',
headers: {
'Content-Type': 'application/transit+json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
'~:email': process.env['E2E_LOGIN_EMAIL'],
'~:password': process.env['E2E_LOGIN_PASSWORD'],
}),
body: body
},
);
console.log("AAAAAAAAAAAA", 1, apiUrl)
// console.log("AAAAAAAAAAAA", 2, resultLoginRequest);
console.dir(resultLoginRequest.headers, {depth:20});
console.log('Document Cookies:', window.document.cookie);
const loginData = await resultLoginRequest.json();
const authToken = resultLoginRequest.headers
.get('set-cookie')
?.split(';')
@@ -35,7 +46,7 @@ export async function PenpotApi() {
getAuth: () => authToken,
createFile: async () => {
const createFileRequest = await fetch(
`${apiUrl}/api/rpc/command/create-file`,
`${apiUrl}/api/main/methods/create-file`,
{
method: 'POST',
headers: {
@@ -65,7 +76,7 @@ export async function PenpotApi() {
},
deleteFile: async (fileId: string) => {
const deleteFileRequest = await fetch(
`${apiUrl}/api/rpc/command/delete-file`,
`${apiUrl}/api/main/methods/delete-file`,
{
method: 'POST',
headers: {

View File

@@ -14,6 +14,6 @@ export default defineConfig({
reportsDirectory: '../coverage/e2e',
provider: 'v8',
},
setupFiles: ['dotenv/config'],
setupFiles: ['dotenv/config', 'vitest.setup.ts']
},
});

View File

@@ -0,0 +1,3 @@
// import { vi } from 'vitest';
window.location.href = 'https://localhost:3449';

View File

@@ -4,7 +4,7 @@
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
E2E_LOGIN_EMAIL="test@penpot.app"
@@ -24,7 +24,7 @@
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
import testingPlugin from './plugins/create-board-text-rect';