Skip to content

Commit

Permalink
OC-700 Spike: re-enable server-side rendering (#508)
Browse files Browse the repository at this point in the history
* removed conditional CSR from _app.tsx

* Reverted meta tags and updated e2e tests

* fixed prettier issues

* added fallback meta tags back

---------

Co-authored-by: Florin H <florin.holhos@wingravity.com>
  • Loading branch information
florin-holhos and Florin H authored Oct 10, 2023
1 parent e59cd05 commit 623810e
Show file tree
Hide file tree
Showing 35 changed files with 699 additions and 869 deletions.
57 changes: 31 additions & 26 deletions e2e/tests/LoggedIn/publish.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ const addCoAuthor = async (page: Page, user: Helpers.TestUser) => {

const removeCoAuthor = async (page: Page, user: Helpers.TestUser) => {
const responsePromise = page.waitForResponse((res) => res.url().includes('/coauthors') && res.ok());
await page.locator('aside button:has-text("Co-authors")').click();
await page.locator('aside button:has-text("Co-authors")').first().click();
await responsePromise;
const row = page.locator('tr', { hasText: user.email });
await row.locator('button[title="Delete"]').click();
Expand Down Expand Up @@ -836,7 +836,7 @@ test.describe('Publication flow + co-authors', () => {
await expect(page.locator(PageModel.publish.publishButton)).toBeEnabled();

// add co-authors
await page.locator('aside button:has-text("Co-authors")').click();
await page.locator('aside button:has-text("Co-authors")').first().click();
await addCoAuthor(page, Helpers.user2);
await addCoAuthor(page, Helpers.user3);

Expand Down Expand Up @@ -919,7 +919,7 @@ test.describe('Publication flow + co-authors', () => {
await publicationFlowConflictOfInterest(page, true, 'Some conflict of interest text');

// add one co-author
await page.locator('aside button:has-text("Co-authors")').click();
await page.locator('aside button:has-text("Co-authors")').first().click();
await addCoAuthor(page, Helpers.user2);

// Request approval from co author
Expand Down Expand Up @@ -969,7 +969,7 @@ test.describe('Publication flow + co-authors', () => {
await publicationFlowConflictOfInterest(page, true, 'Some conflict of interest text');

// add co-author
await page.locator('aside button:has-text("Co-authors")').click();
await page.locator('aside button:has-text("Co-authors")').first().click();
await addCoAuthor(page, Helpers.user3);

// verify co-author has been added
Expand Down Expand Up @@ -1037,7 +1037,7 @@ test.describe('Publication flow + co-authors', () => {
await publicationFlowConflictOfInterest(page, true, 'Some conflict of interest text');

// add co-authors
await page.locator('aside button:has-text("Co-authors")').click();
await page.locator('aside button:has-text("Co-authors")').first().click();
await addCoAuthor(page, Helpers.user2);

// verify authors order into the table
Expand Down Expand Up @@ -1121,7 +1121,7 @@ test.describe('Publication flow + co-authors', () => {
await publicationFlowConflictOfInterest(page, true, 'Some conflict of interest text');

// add co-author
await page.locator('aside button:has-text("Co-authors")').click();
await page.locator('aside button:has-text("Co-authors")').first().click();
await addCoAuthor(page, Helpers.user2);

// verify co-author has been added
Expand Down Expand Up @@ -1195,7 +1195,7 @@ test.describe('Publication flow + co-authors', () => {
await publicationFlowConflictOfInterest(page, true, 'Some conflict of interest text');

// add co-author
await page.locator('aside button:has-text("Co-authors")').click();
await page.locator('aside button:has-text("Co-authors")').first().click();
await addCoAuthor(page, Helpers.user2);

// verify co-author has been added
Expand Down Expand Up @@ -1263,7 +1263,7 @@ test.describe('Publication flow + co-authors', () => {
await publicationFlowConflictOfInterest(page, true, 'Some conflict of interest text');

// add co-author
await page.locator('aside button:has-text("Co-authors")').click();
await page.locator('aside button:has-text("Co-authors")').first().click();
await addCoAuthor(page, Helpers.user2);

// verify co-author has been added
Expand Down Expand Up @@ -1338,7 +1338,7 @@ test.describe('Publication flow + co-authors', () => {
await publicationFlowConflictOfInterest(page, false);

// add co-author
await page.locator('aside button:has-text("Co-authors")').click();
await page.locator('aside button:has-text("Co-authors")').first().click();
await addCoAuthor(page, Helpers.user2);

// verify co-author has been added
Expand Down Expand Up @@ -1400,7 +1400,7 @@ test.describe('Publication flow + co-authors', () => {
await publicationFlowConflictOfInterest(page, false);

// add co-author
await page.locator('aside button:has-text("Co-authors")').click();
await page.locator('aside button:has-text("Co-authors")').first().click();
await addCoAuthor(page, Helpers.user2);

// verify co-author has been added
Expand Down Expand Up @@ -1474,14 +1474,14 @@ test.describe('Publication flow + co-authors', () => {
await publicationFlowConflictOfInterest(page, false);

// add co-author
await page.locator('aside button:has-text("Co-authors")').click();
await page.locator('aside button:has-text("Co-authors")').first().click();
await addCoAuthor(page, Helpers.user2);

// verify co-author has been added
await expect(page.locator(`td:has-text("${Helpers.user2.email}")`)).toBeVisible();

// add co-author
await page.locator('aside button:has-text("Co-authors")').click();
await page.locator('aside button:has-text("Co-authors")').first().click();
await addCoAuthor(page, Helpers.user3);

// verify co-author has been added
Expand Down Expand Up @@ -1543,14 +1543,14 @@ test.describe('Publication flow + co-authors', () => {
await publicationFlowConflictOfInterest(page, false);

// add co-author
await page.locator('aside button:has-text("Co-authors")').click();
await page.locator('aside button:has-text("Co-authors")').first().click();
await addCoAuthor(page, Helpers.user2);

// verify co-author has been added
await expect(page.locator(`td:has-text("${Helpers.user2.email}")`)).toBeVisible();

// add co-author
await page.locator('aside button:has-text("Co-authors")').click();
await page.locator('aside button:has-text("Co-authors")').first().click();
await addCoAuthor(page, Helpers.user3);

// verify co-author has been added
Expand Down Expand Up @@ -1629,7 +1629,7 @@ test.describe('Publication flow + co-authors', () => {
await publicationFlowConflictOfInterest(page, false);

// add co-author
await page.locator('aside button:has-text("Co-authors")').click();
await page.locator('aside button:has-text("Co-authors")').first().click();
await addCoAuthor(page, Helpers.user2);

// verify co-author has been added
Expand Down Expand Up @@ -1700,7 +1700,7 @@ test.describe('Publication flow + co-authors', () => {
await publicationFlowConflictOfInterest(page, false);

// add co-author
await page.locator('aside button:has-text("Co-authors")').click();
await page.locator('aside button:has-text("Co-authors")').first().click();
await addCoAuthor(page, Helpers.user2);

// verify co-author has been added
Expand Down Expand Up @@ -1781,7 +1781,7 @@ test.describe('Publication flow + co-authors', () => {
await publicationFlowConflictOfInterest(page, false);

// add co-author
await page.locator('aside button:has-text("Co-authors")').click();
await page.locator('aside button:has-text("Co-authors")').first().click();
await addCoAuthor(page, Helpers.user2);

// verify co-author has been added
Expand Down Expand Up @@ -1845,7 +1845,7 @@ test.describe('Publication flow + co-authors', () => {
await publicationFlowConflictOfInterest(page, false);

// add co-author
await page.locator('aside button:has-text("Co-authors")').click();
await page.locator('aside button:has-text("Co-authors")').first().click();
await addCoAuthor(page, Helpers.user2);

// verify co-author has been added
Expand Down Expand Up @@ -1907,14 +1907,14 @@ test.describe('Publication flow + co-authors', () => {
await publicationFlowConflictOfInterest(page, false);

// add co-author
await page.locator('aside button:has-text("Co-authors")').click();
await page.locator('aside button:has-text("Co-authors")').first().click();
await addCoAuthor(page, Helpers.user2);

// verify co-author has been added
await expect(page.locator(`td:has-text("${Helpers.user2.email}")`)).toBeVisible();

// add co-author
await page.locator('aside button:has-text("Co-authors")').click();
await page.locator('aside button:has-text("Co-authors")').first().click();
await addCoAuthor(page, Helpers.user3);

// verify co-author has been added
Expand Down Expand Up @@ -1991,12 +1991,17 @@ test.describe('Publication flow + co-authors', () => {

const publicationId = page.url().split('/').pop();

await page.waitForResponse(
(response) =>
response.request().method() === 'GET' &&
response.url().includes(`/publications/${publicationId}`) &&
response.ok()
);
await Promise.all([
page.waitForResponse(
(response) =>
response.request().method() === 'PUT' &&
response.url().includes(`/publications/${publicationId}/my-affiliations`)
),
page.waitForResponse(
(response) =>
response.request().method() === 'GET' && response.url().includes(`/publications/${publicationId}`)
)
]);

// check approval's tracker table first row includes the selected affiliation title
await expect(page.locator('table[data-testid="approval-tracker-table"] > tbody > tr')
Expand Down
110 changes: 49 additions & 61 deletions e2e/tests/LoggedIn/search.e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,78 +1,66 @@
import { expect, test } from "@playwright/test";
import * as Helpers from "../helpers";
import { PageModel } from "../PageModel";
import { expect, test } from '@playwright/test';
import * as Helpers from '../helpers';
import { PageModel } from '../PageModel';

test.describe("Search", () => {
test("Full publication title search", async ({ browser }) => {
// Start up test
const page = await browser.newPage();
test.describe('Search', () => {
test('Full publication title search', async ({ browser }) => {
// Start up test
const page = await browser.newPage();

// Login
await page.goto(Helpers.UI_BASE);
await Helpers.login(page, browser);
await expect(page.locator(PageModel.header.usernameButton)).toHaveText(
`${Helpers.user1.fullName}`
);
// Login
await page.goto(Helpers.UI_BASE);
await Helpers.login(page, browser);
await expect(page.locator(PageModel.header.usernameButton)).toHaveText(`${Helpers.user1.fullName}`);

// search and check result
await Helpers.search(
page,
"How has life on earth evolved?",
PageModel.search.publicationSearchResult
);
// search and check result
await Helpers.search(page, 'How has life on earth evolved?', PageModel.search.publicationSearchResult);

// Click on search result
await page.locator(PageModel.search.publicationSearchResult).click();
await expect(page.locator("h1")).toHaveText(
"How has life on earth evolved?"
);
});
// Click on search result
await page.locator(PageModel.search.publicationSearchResult).click();
await expect(page.locator('h1')).toContainText('How has life on earth evolved?');
});
});

test.describe("Search term is persisted in URL query string", () => {
test("Partial search term search", async ({ browser }) => {
// Start up test
const page = await browser.newPage();
await page.goto(Helpers.UI_BASE);
test.describe('Search term is persisted in URL query string', () => {
test('Partial search term search', async ({ browser }) => {
// Start up test
const page = await browser.newPage();
await page.goto(Helpers.UI_BASE);

// search and expect URL query string to contain search text
await Helpers.search(page, PageModel.search.searchTerm);
await expect(page).toHaveURL(
new RegExp(`query=${PageModel.search.searchTerm}`)
);
// search and expect URL query string to contain search text
await Helpers.search(page, PageModel.search.searchTerm);
await expect(page).toHaveURL(new RegExp(`query=${PageModel.search.searchTerm}`));

// navigate to first publication (expect URL to contain path) click browser 'back'
await Helpers.clickFirstPublication(page);
await page.goBack();
// navigate to first publication (expect URL to contain path) click browser 'back'
await Helpers.clickFirstPublication(page);
await page.goBack();

await expect(page).toHaveURL(
new RegExp(`query=${PageModel.search.searchTerm}`)
);
});
await expect(page).toHaveURL(new RegExp(`query=${PageModel.search.searchTerm}`));
});
});

test.describe("dateTo and dateFrom fields are persisted in URL query string", () => {
test("dateTo and dateFrom in query string", async ({ browser }) => {
// Start up test
const page = await browser.newPage();
await page.goto(Helpers.UI_BASE);
await page.locator(PageModel.header.searchButton).click();
test.describe('dateTo and dateFrom fields are persisted in URL query string', () => {
test('dateTo and dateFrom in query string', async ({ browser }) => {
// Start up test
const page = await browser.newPage();
await page.goto(Helpers.UI_BASE);
await page.locator(PageModel.header.searchButton).click();

//select dateFrom & dateTo
const dateFromInput = page.locator(PageModel.search.dateFromInput);
const dateToInput = page.locator(PageModel.search.dateToInput);
//select dateFrom & dateTo
const dateFromInput = page.locator(PageModel.search.dateFromInput);
const dateToInput = page.locator(PageModel.search.dateToInput);

await dateFromInput.fill(PageModel.search.dateFrom);
await dateToInput.fill(PageModel.search.dateTo);
await dateFromInput.fill(PageModel.search.dateFrom);
await dateToInput.fill(PageModel.search.dateTo);

// expect dateFrom/dateTo input and URL to match selections
await Helpers.testDateInput(page, dateFromInput, dateToInput);
// expect dateFrom/dateTo input and URL to match selections
await Helpers.testDateInput(page, dateFromInput, dateToInput);

// navigate to first publication (expect URL to contain path) click browser 'back'
await Helpers.clickFirstPublication(page);
await page.goBack();
// navigate to first publication (expect URL to contain path) click browser 'back'
await Helpers.clickFirstPublication(page);
await page.goBack();

// expect dateFrom/dateTo input and URL to match selections
await Helpers.testDateInput(page, dateFromInput, dateToInput);
});
// expect dateFrom/dateTo input and URL to match selections
await Helpers.testDateInput(page, dateFromInput, dateToInput);
});
});
5 changes: 4 additions & 1 deletion ui/src/components/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import * as Components from '@components';
import * as Config from '@config';
import * as Assets from '@assets';
import * as SolidIcons from '@heroicons/react/24/solid';
import dynamic from 'next/dynamic';

const ScrollTopNoSSR = dynamic(() => import('../ScrollToTop'), { ssr: false });

type Props = {
waves: boolean;
Expand Down Expand Up @@ -149,7 +152,7 @@ const Footer: React.FC<Props> = (props: Props): React.ReactElement => (
</div>
</div>
</div>
<Components.ScrollToTop />
<ScrollTopNoSSR />
</footer>
</>
);
Expand Down
Loading

0 comments on commit 623810e

Please sign in to comment.