|
| 1 | +import { test, expect } from "@playwright/test"; |
| 2 | +import { prepareVisualisation } from "../../vis/js/utils/e2eVisualisationLoader"; |
| 3 | +import { waitForVisualisationCreation } from "../../vis/js/utils/e2eWaitForVisualisationCreation"; |
| 4 | + |
| 5 | +test.describe("Basic tests for PubMed integration (Knowledge Map visualisation type)", () => { |
| 6 | + test.describe("Using direct dynamic URL / PSVS link", () => { |
| 7 | + test("Loads default Knowledge Map visualisation", async ({ page }) => { |
| 8 | + const VISUALISATION_DYNAMIC_URL = |
| 9 | + "/search?type=get&vis_type=overview&q=infection&service=pubmed&sorting=most-relevant"; |
| 10 | + |
| 11 | + await prepareVisualisation(page, VISUALISATION_DYNAMIC_URL); |
| 12 | + |
| 13 | + await expect(page.locator("#search-term-unique")).toContainText( |
| 14 | + "infection", |
| 15 | + ); |
| 16 | + await expect(page.locator("#source")).toContainText( |
| 17 | + "Data source: PubMed", |
| 18 | + ); |
| 19 | + await page.getByTestId("context").getByText("More information").click(); |
| 20 | + await expect(page.locator("#info-body")).toContainText( |
| 21 | + "This knowledge map presents you with a topical overview of research on infection based on the 100 most relevant resources matching your search query.", |
| 22 | + ); |
| 23 | + }); |
| 24 | + }); |
| 25 | + |
| 26 | + test.describe("Using search embedded search box", () => { |
| 27 | + test("Loads default Knowledge Map visualisation", async ({ page }) => { |
| 28 | + const VISUALISATION_DYNAMIC_URL = "/embedded_searchbox?service=pubmed"; |
| 29 | + |
| 30 | + await page.goto(VISUALISATION_DYNAMIC_URL); |
| 31 | + await page |
| 32 | + .getByRole("textbox", { name: "Enter search query (e.g." }) |
| 33 | + .click(); |
| 34 | + await page |
| 35 | + .getByRole("textbox", { name: "Enter search query (e.g." }) |
| 36 | + .fill("infection"); |
| 37 | + await page.getByRole("button", { name: "Create Overview" }).click(); |
| 38 | + await waitForVisualisationCreation(page); |
| 39 | + |
| 40 | + await expect(page.locator("#search-term-unique")).toContainText( |
| 41 | + "infection", |
| 42 | + ); |
| 43 | + await expect(page.locator("#source")).toContainText( |
| 44 | + "Data source: PubMed", |
| 45 | + ); |
| 46 | + await page.getByTestId("context").getByText("More information").click(); |
| 47 | + await expect(page.locator("#info-body")).toContainText( |
| 48 | + "This knowledge map presents you with a topical overview of research on infection based on the 100 most relevant resources matching your search query.", |
| 49 | + ); |
| 50 | + }); |
| 51 | + }); |
| 52 | + |
| 53 | + test.describe("Using old search box", () => { |
| 54 | + const MAIN_PAGE = ""; |
| 55 | + |
| 56 | + test("Loads default Knowledge Map visualisation using the 'covid-19' try out link", async ({ |
| 57 | + page, |
| 58 | + }) => { |
| 59 | + await page.goto(MAIN_PAGE); |
| 60 | + |
| 61 | + await page.getByRole("radio", { name: "PubMed (life sciences)" }).check(); |
| 62 | + |
| 63 | + const visualisationPagePromise = page.waitForEvent("popup"); |
| 64 | + await page.getByRole("link", { name: "covid-" }).click(); |
| 65 | + const visualisationPage = await visualisationPagePromise; |
| 66 | + |
| 67 | + await waitForVisualisationCreation(visualisationPage); |
| 68 | + |
| 69 | + await expect( |
| 70 | + visualisationPage.locator("#search-term-unique"), |
| 71 | + ).toContainText("covid-19"); |
| 72 | + await expect(visualisationPage.locator("#source")).toContainText( |
| 73 | + "Data source: PubMed", |
| 74 | + ); |
| 75 | + await visualisationPage |
| 76 | + .getByTestId("context") |
| 77 | + .getByText("More information") |
| 78 | + .click(); |
| 79 | + await expect(visualisationPage.locator("#info-body")).toContainText( |
| 80 | + "This knowledge map presents you with a topical overview of research on covid-19 based on the 100 most relevant resources matching your search query.We use text similarity to create a knowledge map. The algorithm groups those resources together that have many words in common. Area titles are created from subject keywords of resources that have been assigned to the same area. We select those keywords and phrases that appear frequently in one area, and seldom in other areas.Knowledge maps provide an instant overview of a topic by showing the main areas at a glance, and resources related to them. This makes it possible to easily identify useful, pertinent information.Please read our FAQs to find out more about knowledge maps.Data sourceThe data is taken from PubMed. PubMed comprises more than 38 million citations for biomedical literature from MEDLINE, life science journals, and online books. For more information please visit the PubMed website.Citations are available for resources with a DOI and based on citation data provided by Crossref. Results may be impacted by accuracy and completeness of this data.Open source softwareThe visualization is created with the award winning open source software Head Start provided by Open Knowledge Maps. Open Knowledge Maps is a non-profit organisation run by a group of dedicated team members and volunteers. In order to improve our free and open service, we need your support. Please send us your feedback to info@openknowledgemaps.org.If you want to support us financially, you can:Make a donationBecome an organisational memberBecome a funder of our roadmapSign-up for our newsletter to receive occasional updates.", |
| 81 | + ); |
| 82 | + }); |
| 83 | + |
| 84 | + test('Loads default Knowledge Map visualisation using the "climate change" try out link', async ({ |
| 85 | + page, |
| 86 | + }) => { |
| 87 | + await page.goto(MAIN_PAGE); |
| 88 | + |
| 89 | + await page.getByRole("radio", { name: "PubMed (life sciences)" }).check(); |
| 90 | + |
| 91 | + const visualisationPagePromise = page.waitForEvent("popup"); |
| 92 | + await page.getByRole("link", { name: '"climate change"' }).click(); |
| 93 | + const visualisationPage = await visualisationPagePromise; |
| 94 | + |
| 95 | + await waitForVisualisationCreation(visualisationPage); |
| 96 | + |
| 97 | + await expect( |
| 98 | + visualisationPage.locator("#search-term-unique"), |
| 99 | + ).toContainText('"climate change"'); |
| 100 | + await expect(visualisationPage.locator("#source")).toContainText( |
| 101 | + "Data source: PubMed", |
| 102 | + ); |
| 103 | + await visualisationPage |
| 104 | + .getByTestId("context") |
| 105 | + .getByText("More information") |
| 106 | + .click(); |
| 107 | + await expect(visualisationPage.locator("#info-body")).toContainText( |
| 108 | + 'This knowledge map presents you with a topical overview of research on "climate change" based on the 100 most relevant resources matching your search query.', |
| 109 | + ); |
| 110 | + }); |
| 111 | + }); |
| 112 | +}); |
0 commit comments