Reviewed-on: #5 Co-authored-by: pedro-bento <mail@pbento.pt> Co-committed-by: pedro-bento <mail@pbento.pt>
37 lines
1.6 KiB
JavaScript
37 lines
1.6 KiB
JavaScript
import { test, expect } from '@playwright/test';
|
|
import { openApp, completedSession, JOB_ID } from '../fixtures/app.js';
|
|
|
|
test.describe('postiz publish', () => {
|
|
test('publishes a clip to the connected channels through /api/postiz/post', async ({ page }) => {
|
|
await openApp(page, {
|
|
seed: {
|
|
session: completedSession(),
|
|
postizUrl: 'http://postiz.e2e.local',
|
|
postizKey: 'postiz-e2e-key',
|
|
},
|
|
});
|
|
await expect(page.getByRole('heading', { name: 'First viral clip' })).toBeVisible();
|
|
|
|
await page.getByRole('button', { name: 'post', exact: true }).first().click();
|
|
const dialog = page.getByRole('dialog');
|
|
await expect(dialog.getByText('PUBLISH', { exact: true })).toBeVisible();
|
|
|
|
// Connected channels load from the mocked integrations endpoint.
|
|
await expect(dialog.getByText('My YouTube')).toBeVisible();
|
|
|
|
const requestPromise = page.waitForRequest(
|
|
(r) => r.method() === 'POST' && r.url().includes('/api/postiz/post'),
|
|
);
|
|
await dialog.getByRole('button', { name: /publish now/i }).click();
|
|
const request = await requestPromise;
|
|
|
|
const body = request.postDataJSON();
|
|
expect(body.job_id).toBe(JOB_ID);
|
|
expect(body.clip_index).toBe(0);
|
|
expect(body.integration_ids).toContain('int-yt');
|
|
expect(body.title).toBe('First viral clip');
|
|
expect(request.headers()['x-postiz-url']).toBe('http://postiz.e2e.local');
|
|
|
|
await expect(page.getByText(/Posted to My YouTube/)).toBeVisible();
|
|
});
|
|
});
|