Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
65 changes: 65 additions & 0 deletions e2e/tests/export-citation/url-persistence.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { test, expect } from '@playwright/test';

const NECTAR_URL = process.env.NECTAR_URL || process.env.BASE_URL || 'http://127.0.0.1:8000';

test.describe('Export Citation URL Persistence', () => {
test('custom format URL should not redirect to bibtex', async ({ page }) => {
// This is the URL that should work - format=custom with customFormat parameter
const customFormatUrl = `${NECTAR_URL}/search/exportcitation/custom?q=star&customFormat=testing`;

// Navigate to the custom format URL
await page.goto(customFormatUrl);

// Wait for page to be fully loaded
await page.waitForLoadState('networkidle');

// The URL should still contain format=custom, not bibtex
const currentUrl = page.url();

expect(currentUrl).toContain('/exportcitation/custom');
expect(currentUrl).not.toContain('/exportcitation/bibtex');
});

test('custom format URL with all params should preserve them', async ({ page }) => {
// Full URL with all export parameters
const fullUrl = `${NECTAR_URL}/search/exportcitation/custom?q=star&customFormat=testing+testing&authorcutoff=10&maxauthor=10&keyformat=%25R&journalformat=1`;

await page.goto(fullUrl);
await page.waitForLoadState('networkidle');

const currentUrl = page.url();

// Format should remain custom
expect(currentUrl).toContain('/exportcitation/custom');

// customFormat should be preserved
expect(currentUrl).toContain('customFormat=');
});

test('bibtex format URL should remain bibtex', async ({ page }) => {
const bibtexUrl = `${NECTAR_URL}/search/exportcitation/bibtex?q=star`;

await page.goto(bibtexUrl);
await page.waitForLoadState('networkidle');

const currentUrl = page.url();

expect(currentUrl).toContain('/exportcitation/bibtex');
});

test('custom format URL should not change after page interaction', async ({ page }) => {
// Navigate to custom format URL
const customFormatUrl = `${NECTAR_URL}/search/exportcitation/custom?q=star&customFormat=MY_CUSTOM_FORMAT`;

await page.goto(customFormatUrl);
await page.waitForLoadState('networkidle');

// Wait a moment for any potential redirect
await page.waitForTimeout(2000);

// URL should still be custom
const currentUrl = page.url();
expect(currentUrl).toContain('/exportcitation/custom');
expect(currentUrl).toContain('customFormat=');
});
});
5 changes: 4 additions & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ import withBundleAnalyzer from '@next/bundle-analyzer';
import { withSentryConfig } from '@sentry/nextjs';
import nextBuildId from 'next-build-id';

// Allow http://localhost in development mode for MSW mocking
const devConnectSrc = process.env.NEXT_PUBLIC_API_MOCKING === 'enabled' ? 'http://localhost http://localhost:*' : '';

const CSP = `
default-src 'self';
script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdn.jsdelivr.net https://cdnjs.cloudflare.com https://www.google-analytics.com https://www.googletagmanager.com https://www.google.com https://recaptcha.google.com https://www.recaptcha.net https://recaptcha.net https://www.googleadservices.com https://www.googlesyndication.com https://www.gstatic.com https://www.gstatic.cn;
style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://fonts.googleapis.com;
base-uri 'self';
object-src 'none';
connect-src 'self' https://*.google-analytics.com https://*.adsabs.harvard.edu https://o1060269.ingest.sentry.io https://scixplorer.org https://*.scixplorer.org https://www.googletagmanager.com https://www.google.com https://recaptcha.google.com https://www.recaptcha.net https://recaptcha.net https://www.gstatic.com https://www.gstatic.cn https://*.googleapis.com https://*.clients6.google.com https://cdn.jsdelivr.net;
connect-src 'self' ${devConnectSrc} https://*.google-analytics.com https://*.adsabs.harvard.edu https://o1060269.ingest.sentry.io https://scixplorer.org https://*.scixplorer.org https://www.googletagmanager.com https://www.google.com https://recaptcha.google.com https://www.recaptcha.net https://recaptcha.net https://www.gstatic.com https://www.gstatic.cn https://*.googleapis.com https://*.clients6.google.com https://cdn.jsdelivr.net;
font-src 'self' data: https://cdnjs.cloudflare.com https://fonts.gstatic.com https://cdn.jsdelivr.net;
frame-src https://www.youtube-nocookie.com https://www.google.com https://www.google.com/recaptcha/ https://recaptcha.google.com https://www.recaptcha.net https://recaptcha.net;
form-action 'self';
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"next": "16.1.1",
"next-build-id": "^3.0.0",
"nprogress": "^0.2.0",
"nuqs": "^2.8.6",
"pino": "^8.16.2",
"pino-pretty": "^10.2.3",
"prop-types": "^15.8.1",
Expand Down
107 changes: 61 additions & 46 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading