Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

close #868, adjust limit query and add test for event links #869

Merged
merged 1 commit into from
Jan 22, 2025
Merged
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
8 changes: 4 additions & 4 deletions playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ export default defineConfig({
use: {...devices['Desktop Chrome']},
},

// {
// name: 'firefox',
// use: {...devices['Desktop Firefox']},
// },
{
name: 'firefox',
use: {...devices['Desktop Firefox']},
},

// {
// name: 'webkit',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const projectOverviewQuery = `
query ProjectOverview($language: String = "de-DE", $status: [String] = ["published"]) {
Projects(filter: { status: { _in: $status } } ) {
Projects(limit: -1, filter: { status: { _in: $status } } ) {
status
project_id
project_status
Expand Down
2 changes: 1 addition & 1 deletion src/routes/[[locale=locale]]/blog/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ query BlogQuery(
$language: String = "de-DE"
$status: [String] = ["published"]
) {
Blog_Posts(sort: "-publication_datetime", filter: { status: { _in: $status } }) {
Blog_Posts(limit: -1, sort: "-publication_datetime", filter: { status: { _in: $status } }) {
publication_datetime
title_image {
id
Expand Down
8 changes: 4 additions & 4 deletions svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function canBePrerendered(url) {
const queries = {
blogs: `
query BlogSlugs($status: [String] = ["published"]) {
Blog_Posts(sort: ["-publication_datetime"], filter: {status: { _in: $status }}) {
Blog_Posts(limit: -1, sort: ["-publication_datetime"], filter: {status: { _in: $status }}) {
translations(filter:{slug:{_neq:null}}) {
languages_code {
code
Expand All @@ -74,22 +74,22 @@ const queries = {
`,
events: `
query EventSlugs($status: [String] = ["published"]) {
Events (filter : {status: {_in: $status}}){
Events (limit: -1, filter : {status: {_in: $status}}){
slug
}
}
`,
projects: `
query ProjectSlugs($status: [String] = ["published"]) {
Projects (filter : {status: {_in: $status}}) {
Projects (limit: -1, filter : {status: {_in: $status}}) {
slug: project_id
}
}

`,
jobs: `
query Jobs($status: [String] = ["published"]) {
Jobs(filter: { status: { _in: $status } }) {
Jobs(limit: -1, filter: { status: { _in: $status } }) {
slug
}
}
Expand Down
81 changes: 81 additions & 0 deletions tests/event-links.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import {test, expect} from '@playwright/test';

test.describe('event subpages accessibility test', () => {
const eventPages = [
{path: '/veranstaltungen/?viewType=list', lang: 'de'},
{path: '/en/events/?viewType=list', lang: 'en'},
];

for (const {path, lang} of eventPages) {
test(`check if all ${lang} event detail pages are accessible`, async ({
page,
}) => {
// Go to events page with list view
await page.goto(path, {waitUntil: 'networkidle'});
await page.waitForLoadState('domcontentloaded');
await page.waitForTimeout(2000); // Wait for dynamic content

// Get all event links
const eventLinks = await page.evaluate((lang) => {
const baseSelector =
lang === 'en'
? 'a[href*="/en/events/"]'
: 'a[href*="/veranstaltungen/"]';

return Array.from(document.querySelectorAll(baseSelector))
.filter((link) => {
const href = link.href;
const isMainPage =
lang === 'en'
? href === 'http://localhost:3000/en/events' ||
href === 'http://localhost:3000/en/events/'
: href === 'http://localhost:3000/veranstaltungen' ||
href === 'http://localhost:3000/veranstaltungen/';
const isEventDetail =
href.includes('?viewType=list') && !isMainPage;
return isEventDetail;
})
.map((link) => ({
url: link.href.replace('?viewType=list', ''),
title: link.textContent?.trim() || null,
}));
}, lang);

// Log found links for debugging
console.log(`Found ${eventLinks.length} event links:`);
eventLinks.forEach((link) => {
console.log(`- ${link.title}: ${link.url}`);
});

// Verify we found links
expect(
eventLinks.length,
`No event links found for ${lang} page`,
).toBeGreaterThan(0);

// Limit to first 5 events
const limitedEventLinks = eventLinks.slice(0, 5);

// Visit and check each event page
for (const {url, title} of limitedEventLinks) {
console.log(`Checking event: ${title} at ${url}`);

const response = await page.goto(url, {waitUntil: 'networkidle'});
expect(response?.status(), `Failed to load ${url}`).toBe(200);

// Basic accessibility checks
await expect(page).toHaveTitle(/.+/);
await expect(page.locator('header')).toBeVisible();

// Event specific checks
const eventTitle = page.getByRole('heading', {level: 1});
await expect(eventTitle).toBeVisible();

// Language verification
const expectedPath =
lang === 'en' ? '/en/events/' : '/veranstaltungen/';
expect(page.url()).toContain(expectedPath);
}
});
}
});
Loading