diff --git a/base-theme/layouts/partials/external_resource_link.html b/base-theme/layouts/partials/external_resource_link.html index 17e7b523a..7497f89be 100644 --- a/base-theme/layouts/partials/external_resource_link.html +++ b/base-theme/layouts/partials/external_resource_link.html @@ -13,21 +13,11 @@ {{- if and $isBroken $backupUrl -}} {{- $href = $backupUrl -}} {{- end -}} -{{- if not (in $href "ocw.mit.edu") -}} - {{- partial "link" (dict +{{- partial "link" (dict "href" $href "text" $text "class" $className "onClick" $onClick "target" "_blank" - ) - -}} -{{- else -}} - {{- partial "link" (dict - "href" $href - "text" $text - "class" "external-link" - "onClick" "" - ) - -}} -{{- end -}} + ) +-}} diff --git a/tests-e2e/ocw-ci-test-course/external-resources.spec.ts b/tests-e2e/ocw-ci-test-course/external-resources.spec.ts index ea882ebf0..edfdd6f9a 100644 --- a/tests-e2e/ocw-ci-test-course/external-resources.spec.ts +++ b/tests-e2e/ocw-ci-test-course/external-resources.spec.ts @@ -35,11 +35,7 @@ test("Nav external resource without warning directly opens a new tab", async ({ const link = page.getByRole("link", { name: "OCW (no warning)" }) await expect(link).toBeVisible() - const targetAttribute = await link.getAttribute("target") - expect(targetAttribute).toBeNull() - - const classAttribute = await link.getAttribute("class") - expect(classAttribute).toContain("external-link") + await expectTriggerToOpenANewTab(page, "https://ocw.mit.edu/", link) }) test("External resource in page opens a new tab", async ({ page }) => { @@ -65,13 +61,14 @@ test("Broken external resource opens backup_url", async ({ page }) => { const link = page.getByRole("link", { name: "broken external resource" }) - const targetAttribute = await link.getAttribute("target") - expect(targetAttribute).toBeNull() - - const classAttribute = await link.getAttribute("class") - expect(classAttribute).toContain("external-link") - await link.click() + const continueButton = page.getByRole("button", { name: "Continue" }) + + await expectTriggerToOpenANewTab( + page, + "https://old.ocw.mit.edu/", + continueButton + ) }) test("External resource opens confirmation modal", async ({ page }) => {