Skip to content

Commit

Permalink
Merge pull request #2191 from Sefaria/chore/sc-29905/write-more-playw…
Browse files Browse the repository at this point in the history
…right-tests-for-topic-pages-manual-integration

New Topic Page Playwright Tests
  • Loading branch information
nsantacruz authored Dec 19, 2024
2 parents 0a18102 + 956f772 commit 14cd1b7
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 12 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/integration-testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ concurrency: integration_environment

jobs:
variables:
if: ${{ github.event_name == 'merge_group' }}
if: ${{ github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
outputs:
date: ${{ steps.data.outputs.date }}
Expand All @@ -29,7 +29,7 @@ jobs:
echo "current_branch=merge-queue"
>> $GITHUB_OUTPUT
build-generic:
if: ${{ github.event_name == 'merge_group' }}
if: ${{ github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' }}
name: "Integration Image Build"
needs:
- variables
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-derived:
if: ${{ github.event_name == 'merge_group' }}
if: ${{ github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
name: "Integration Image Build Stage 2"
permissions:
Expand Down Expand Up @@ -140,7 +140,7 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
run-tests:
if: ${{ github.event_name == 'merge_group' }}
if: ${{ github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' }}
name: "Playwright" # This name is referenced when slacking status
needs:
- build-derived
Expand Down 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 All @@ -204,7 +209,7 @@ jobs:
- name: Uninstall
run: helm delete integration-${{ needs.variables.outputs.commit }} -n ${{ secrets.DEV_SANDBOX_NAMESPACE }} --debug --timeout 10m0s
ending-notification:
if: ${{ github.event_name == 'merge_group' }}
if: ${{ github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
needs:
- run-tests
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: '[email protected]',
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,
};
47 changes: 45 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,47 @@ 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 = 'search?q=Monkey&tab=sheet&tvar=1&tsort=relevance&stopics_enFilters=Monkey&svar=1&ssort=relevance';
await page.waitForURL((url) => url.href.includes(expectedUrl));
});

test('Check no redirection when user is admin', async ({ context }) => {
const page = await goToPageWithUser(context, '/topics/Monkey', testAdminUser);
await page.waitForSelector('span:has-text("Admin")')

});

test('Filter topics', async ({ context }) => {
const page = await goToPageWithLang(context, '/topics/all/a');
Expand Down
1 change: 1 addition & 0 deletions sefaria/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@
}

}

DATA_UPLOAD_MAX_MEMORY_SIZE = 24000000

BASE_DIR = os.path.dirname(os.path.dirname(__file__))
2 changes: 1 addition & 1 deletion static/js/TopicPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,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

0 comments on commit 14cd1b7

Please sign in to comment.