mirror of
https://github.com/penpot/penpot.git
synced 2026-02-11 23:25:58 -05:00
Compare commits
4 Commits
develop
...
niwinz-dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b68edf84e | ||
|
|
afe7d41adf | ||
|
|
96f9e796be | ||
|
|
28eac35660 |
@@ -29,6 +29,8 @@ export PENPOT_FLAGS="\
|
|||||||
enable-user-feedback \
|
enable-user-feedback \
|
||||||
disable-secure-session-cookies \
|
disable-secure-session-cookies \
|
||||||
enable-smtp \
|
enable-smtp \
|
||||||
|
enable-cors \
|
||||||
|
disable-secure-session-cookies \
|
||||||
enable-prepl-server \
|
enable-prepl-server \
|
||||||
enable-urepl-server \
|
enable-urepl-server \
|
||||||
enable-rpc-climit \
|
enable-rpc-climit \
|
||||||
|
|||||||
@@ -213,14 +213,14 @@
|
|||||||
(assoc "access-control-allow-origin" origin)
|
(assoc "access-control-allow-origin" origin)
|
||||||
(assoc "access-control-allow-methods" "GET,POST,DELETE,OPTIONS,PUT,HEAD,PATCH")
|
(assoc "access-control-allow-methods" "GET,POST,DELETE,OPTIONS,PUT,HEAD,PATCH")
|
||||||
(assoc "access-control-allow-credentials" "true")
|
(assoc "access-control-allow-credentials" "true")
|
||||||
(assoc "access-control-expose-headers" "x-requested-with, content-type, cookie")
|
(assoc "access-control-expose-headers" "content-type, set-cookie")
|
||||||
(assoc "access-control-allow-headers" "x-frontend-version, content-type, accept, x-requested-width")))
|
(assoc "access-control-allow-headers" "x-frontend-version, x-client, x-requested-width, content-type, accept, cookie")))
|
||||||
|
|
||||||
(defn wrap-cors
|
(defn wrap-cors
|
||||||
[handler]
|
[handler]
|
||||||
(fn [request]
|
(fn [request]
|
||||||
(let [response (if (= (yreq/method request) :options)
|
(let [response (if (= (yreq/method request) :options)
|
||||||
{::yres/status 200}
|
{::yres/status 204}
|
||||||
(handler request))
|
(handler request))
|
||||||
origin (yreq/get-header request "origin")]
|
origin (yreq/get-header request "origin")]
|
||||||
(update response ::yres/headers with-cors-headers origin))))
|
(update response ::yres/headers with-cors-headers origin))))
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import comments from './plugins/create-comments';
|
|||||||
import { Agent } from './utils/agent';
|
import { Agent } from './utils/agent';
|
||||||
|
|
||||||
describe('Plugins', () => {
|
describe('Plugins', () => {
|
||||||
it('create board - text - rectable', async () => {
|
it.only('create board - text - rectable', async () => {
|
||||||
const agent = await Agent();
|
const agent = await Agent();
|
||||||
const result = await agent.runCode(testingPlugin.toString(), {
|
const result = await agent.runCode(testingPlugin.toString(), {
|
||||||
screenshot: 'create-board-text-rect',
|
screenshot: 'create-board-text-rect',
|
||||||
|
|||||||
@@ -56,10 +56,13 @@ export async function Agent() {
|
|||||||
console.log('File URL:', fileUrl);
|
console.log('File URL:', fileUrl);
|
||||||
|
|
||||||
console.log('Launching browser...');
|
console.log('Launching browser...');
|
||||||
const browser = await puppeteer.launch({});
|
const browser = await puppeteer.launch({args: ['--ignore-certificate-errors']});
|
||||||
const page = await browser.newPage();
|
const page = await browser.newPage();
|
||||||
|
|
||||||
await page.setViewport({ width: 1920, height: 1080 });
|
await page.setViewport({ width: 1920, height: 1080 });
|
||||||
|
await page.setExtraHTTPHeaders({
|
||||||
|
'X-Client': 'plugins/e2e:puppeter',
|
||||||
|
});
|
||||||
|
|
||||||
console.log('Setting authentication cookie...');
|
console.log('Setting authentication cookie...');
|
||||||
page.setCookie({
|
page.setCookie({
|
||||||
|
|||||||
@@ -1,27 +1,38 @@
|
|||||||
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',
|
||||||
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'],
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
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 loginData = await resultLoginRequest.json();
|
||||||
|
|
||||||
|
|
||||||
const authToken = resultLoginRequest.headers
|
const authToken = resultLoginRequest.headers
|
||||||
.get('set-cookie')
|
.get('set-cookie')
|
||||||
?.split(';')
|
?.split(';')
|
||||||
@@ -35,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: {
|
||||||
@@ -65,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: {
|
||||||
|
|||||||
@@ -14,6 +14,6 @@ export default defineConfig({
|
|||||||
reportsDirectory: '../coverage/e2e',
|
reportsDirectory: '../coverage/e2e',
|
||||||
provider: 'v8',
|
provider: 'v8',
|
||||||
},
|
},
|
||||||
setupFiles: ['dotenv/config'],
|
setupFiles: ['dotenv/config', 'vitest.setup.ts']
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
3
plugins/apps/e2e/vitest.setup.ts
Normal file
3
plugins/apps/e2e/vitest.setup.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
// import { vi } from 'vitest';
|
||||||
|
|
||||||
|
window.location.href = 'https://localhost:3449';
|
||||||
@@ -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';
|
||||||
|
|||||||
Reference in New Issue
Block a user