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

Tests verifying basic topic page functionality #2093

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 6 additions & 1 deletion .github/workflows/integration-testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,12 @@ jobs:

- name: Run Playwright tests
run: npx playwright test

env:
PLAYWRIGHT_SUPERUSER_EMAIL: "${{ secrets.PLAYWRIGHT_SUPERUSER_EMAIL }}"
PLAYWRIGHT_SUPERUSER_PASSWORD: "${{ secrets.PLAYWRIGHT_SUPERUSER_PASSWORD }}"
PLAYWRIGHT_USER_EMAIL: "${{ secrets.PLAYWRIGHT_USER_EMAIL }}"
PLAYWRIGHT_USER_PASSWORD: "${{ secrets.PLAYWRIGHT_USER_PASSWORD }}"

- name: Upload Playwright report
uses: actions/upload-artifact@v3
if: always()
Expand Down
11 changes: 8 additions & 3 deletions e2e-tests/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ export const cookieObject = {
}

export const testUser = {
email: 'test@example.com',
password: 'test',
}
email: process.env.PLAYWRIGHT_USER_EMAIL,
password: process.env.PLAYWRIGHT_USER_PASSWORD,
}

export const testAdminUser = {
email: process.env.PLAYWRIGHT_SUPERUSER_EMAIL,
password: process.env.PLAYWRIGHT_SUPERUSER_PASSWORD,
};
48 changes: 46 additions & 2 deletions e2e-tests/tests/topics.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { test } from '@playwright/test';
import {goToPageWithLang} from '../utils';
import {expect, test} from '@playwright/test';
import {goToPageWithLang, goToPageWithUser} from '../utils';
import {LANGUAGES, testAdminUser} from "../globals";
import * as assert from "node:assert";


test('Go to topic page', async ({ context }) => {
Expand All @@ -8,6 +10,48 @@ test('Go to topic page', async ({ context }) => {
await page.getByRole('link', { name: 'Rosh Hashanah' }).first().isVisible();
});

test('Check source', async ({ context }) => {
const page = await goToPageWithLang(context, '/topics');
await page.getByRole('link', { name: 'Jewish Calendar' }).click();
await page.getByRole('link', { name: 'Shabbat' }).first().click();
await page.getByRole('link', { name: 'Notable Sources' }).first().isVisible();
await page.getByRole('link', { name: 'All Sources' }).first().isVisible();
});

test('Check admin tab', async ({ context }) => {
const page = await goToPageWithUser(context, '/topics', testAdminUser);
await page.getByRole('link', { name: 'Jewish Calendar' }).click();
await page.getByRole('link', { name: 'Shabbat' }).first().click();
await page.getByRole('link', { name: 'Notable Sources' }).first().isVisible();
await page.getByRole('link', { name: 'All Sources' }).first().isVisible();
await page.getByRole('link', { name: 'Admin' }).first().isVisible();
});

test('Check sources he interface', async ({ context }) => {
const page = await goToPageWithLang(context, '/topics', LANGUAGES.HE);
await page.getByRole('link', { name: 'מועדי השנה' }).click();
await page.getByRole('link', { name: 'שבת' }).first().click();
await page.getByRole('link', { name: 'מקורות מרכזיים' }).first().isVisible();
await page.getByRole('link', { name: 'כל המקורות' }).first().isVisible();
});

test('Check author page', async ({ context }) => {
const page = await goToPageWithLang(context, '/topics/jonathan-sacks');
await page.getByRole('link', { name: 'Works on Sefaria' }).first().isVisible();
});

test('Check redirection for sourceless topic', async ({ context }) => {
const page = await goToPageWithLang(context, '/topics/Monkey');
const expectedUrl = 'https://www.sefaria.org/search?q=Monkey&tab=sheet&tvar=1&tsort=relevance&stopics_enFilters=Monkey&svar=1&ssort=relevance'
await page.waitForTimeout(10000)
expect(page.url()).toEqual(expectedUrl)
});

test('Check no redirection when user is admin', async ({ context }) => {
const page = await goToPageWithUser(context, '/topics/Monkey', testAdminUser);
await page.waitForTimeout(10000)
await page.getByRole('link', { name: 'Admin' }).first().isVisible();
});

test('Filter topics', async ({ context }) => {
const page = await goToPageWithLang(context, '/topics/all/a');
Expand Down
2 changes: 1 addition & 1 deletion static/js/TopicPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ const TopicPage = ({

useEffect( ()=> {
// hack to redirect to temporary sheet content on topics page for those topics that only have sheet content.
if (!Sefaria.is_moderator && !topicData.isLoading && Object.keys(topicData.tabs).length == 0 && topicData.subclass != "author"){
if (!Sefaria.is_moderator && !topicData.isLoading && Object.keys(topicData.tabs).length == 0 && topicData.subclass != "author"){
const interfaceIsHe = Sefaria.interfaceLang === "hebrew";
const interfaceLang = interfaceIsHe ? 'he' : 'en';
const coInterfaceLang = interfaceIsHe ? 'en' : 'he';
Expand Down
Loading