Skip to content

Commit

Permalink
remove playwright changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Malar-Natarajan committed Jul 25, 2024
1 parent 9a8d66a commit c99fe56
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 114 deletions.
18 changes: 2 additions & 16 deletions playwright/src/fixtures/content.page.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Content page locators and functions
import { Locator, Page } from 'playwright'
import { MobileNavigation, sleep } from '../utilities/utilities'
import { MobileNavigation } from '../utilities/utilities'

class ContentPage {
colorlocator: any
Expand Down Expand Up @@ -33,8 +33,6 @@ class ContentPage {
osanoManageButton: Locator
osanoAccept: Locator
osanoDialog: Locator
mathLocator: Locator
closeOverlay: Locator

constructor(page: Page) {
this.page = page
Expand All @@ -61,18 +59,12 @@ class ContentPage {
this.textarea = this.page.locator('textarea[class*="TextArea"]')
this.osanoCloseButton = this.page.locator('button[class*="osano-cm-dialog__close"]')
this.osanoAccept = this.page.locator('button[class*="type_accept"]')
this.mathLocator = this.page.locator(".math")
this.closeOverlay = this.page.locator('[aria-label="close overlay"]')
}

async open(path: string) {
// Open a Rex page with base url
await this.page.goto(path)

if(await this.page.$$(".math")) {
await Promise.all([await this.page.$$("[id*=MathJax][id*=Frame] .math")])
}

// Close the osano cookie management widget
if (await this.osanoAccept.isVisible()) {
try {
Expand All @@ -96,17 +88,11 @@ class ContentPage {
await this.page
.context()
.addCookies([{ name: 'nudge_study_guides_date', value: current_date, url: this.page.url() }])

if(await this.closeOverlay.isVisible()) {
await this.closeOverlay.click()
}
}

async canonical() {
// Return canonical link of the current page
const canonicalPageSelector = await this.page.$('[rel="canonical"]')

sleep(1)
let canonicalPageSelector = await this.page.$('[rel="canonical"]')
const canonicalPage = await canonicalPageSelector.evaluate((e) => e.getAttribute('href'))
return canonicalPage
}
Expand Down
98 changes: 0 additions & 98 deletions playwright/tests/rex-test/rex.behaviorspec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -673,102 +673,4 @@ test('C543225 canonicals for old editions point to the latest edition', async ({
await Toc.pageClick(241)
// THEN: Canonical page points to latest edition of the original content
expect(await bookPage.canonical()).toBe('https://openstax.org/books/principles-economics-3e/pages/d-the-expenditure-output-model')
})


test('C543225 canonicals for multi-volumed books point to a single volume', async ({ page, isMobile, browserName }) => {
test.skip(isMobile as boolean, 'test only desktop resolution')
test.skip(browserName == 'webkit', 'test only chrome')
test.skip(browserName == 'firefox', 'test only chrome')

// GIVEN: Open Volume 1 of calculus book
const bookPage = new ContentPage(page)
const path1 = '/books/calculus-volume-1/pages/1-introduction'

await bookPage.open(path1)
// THEN: Canonical of Volume 1 points to itself
expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/1-introduction')

// WHEN: Open EOC page
const Toc = new TOC(page)
await Toc.pageClick(17)

// THEN: Canonical of volume 1 EOC page points to itself
expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/2-key-terms')

// WHEN: Open EOB nested page
await Toc.pageClick(81)

// THEN: Canonical of volume 1 EOB nested page points to itself
expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/chapter-3')

// WHEN: Open EOB page
await Toc.pageClick(76)

// THEN: Canonical of volume 1 EOB page points to itself
expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/a-table-of-integrals')

// WHEN: Open Volume 2 of calculus book
const path2 = '/books/calculus-volume-2/pages/1-3-the-fundamental-theorem-of-calculus'
await bookPage.open(path2)
sleep(3)

// THEN: Canonical of Volume 2 points to volume 1 for shared content
expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/5-3-the-fundamental-theorem-of-calculus')

// WHEN: Open volume 2 page that is not shared with previous volume
await Toc.pageClick(71)

// THEN: Canonical of Volume 2 points to self for non-shared content
expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-2/pages/7-2-calculus-of-parametric-curves')

// WHEN: Open EOC page
await Toc.pageClick(11)

// THEN: Canonical of volume 2 EOC page points to itself
expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-2/pages/1-key-concepts')

// WHEN: Open EOB nested page
await Toc.pageClick(84)

// THEN: Canonical of volume 2 EOB nested page points to itself
expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-2/pages/chapter-3')

// WHEN: Open EOB page
await Toc.pageClick(81)

// THEN: Canonical of volume 2 EOB page points to volume 1
expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/c-review-of-pre-calculus')

// WHEN: Open volume 3 page that is shared with previous volumes
const path3 = '/books/calculus-volume-3/pages/1-1-parametric-equations'
await bookPage.open(path3)
sleep(3)

// THEN: Canonical of Volume 3 points to shared content
expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-2/pages/7-1-parametric-equations')

// WHEN: Open volume 3 page that is not shared with previous volume
await Toc.pageClick(13)

// THEN: Canonical of Volume 3 points to self for non-shared content
expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-3/pages/2-2-vectors-in-three-dimensions')

// WHEN: Open EOC page
await Toc.pageClick(10)

// THEN: Canonical of volume 3 EOC page points to itself
expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-3/pages/1-review-exercises')

// WHEN: Open EOB nested page
await Toc.pageClick(84)

// THEN: Canonical of volume 3 EOB nested page points to itself
expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-3/pages/chapter-3')

// WHEN: Open EOB page
await Toc.pageClick(81)

// THEN: Canonical of volume 2 EOB page points to volume 1
expect(await bookPage.canonical()).toBe('https://openstax.org/books/calculus-volume-1/pages/c-review-of-pre-calculus')
})

0 comments on commit c99fe56

Please sign in to comment.