Skip to content

Commit

Permalink
test(docs-e2e): disable flaky tests that are increasing run times eno…
Browse files Browse the repository at this point in the history
…rmously
  • Loading branch information
MFarabi619 committed Dec 21, 2024
1 parent 8959c7c commit 95a40fb
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 85 deletions.
4 changes: 0 additions & 4 deletions apps/docs-e2e/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,4 @@ export default defineConfig({
testIgnore: ['./src/lighthouse.spec.ts'],
},
],
// Ignore Chromium projects in CI to speed up runs
// ignore: process.env.CI
// ? ['chromium (desktop)', 'chromium (mobile)']
// : [],
})
163 changes: 85 additions & 78 deletions apps/docs-e2e/src/docs.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
/* eslint-disable unused-imports/no-unused-vars */
import { test as base, expect } from '@playwright/test'
import { clickAndGoToPage } from './helpers/click-and-go-to-page'
import { DocsLayout } from './pom'

const test = base.extend<{ docsLayoutPage: DocsLayout }>({
docsLayoutPage: async ({ page }, use) => {
const test = base.extend<{ docsLayoutPage: DocsLayout, context }>({
// Define the custom browser context fixture
context: async ({ browser }, use) => {
const context = await browser.newContext() // Create a new context
// eslint-disable-next-line react-hooks/rules-of-hooks
await use(context)
await context.close()
},

docsLayoutPage: async ({ context }, use) => {
const page = await context.newPage()
const docsLayoutPage = new DocsLayout(page)
await docsLayoutPage.goto()
// eslint-disable-next-line react-hooks/rules-of-hooks
await use(docsLayoutPage)
},
})

test.beforeEach(async ({ docsLayoutPage }) => {
await docsLayoutPage.goto()
})

test.afterEach(async ({ docsLayoutPage }) => {
await docsLayoutPage.page.evaluate(() => {
localStorage.clear()
sessionStorage.clear()
})
await docsLayoutPage.page.close()
})

const GITHUB_BASE_URL = 'https://github.com/cuhacking'
const GITHUB_ORG_BASE_URL = 'https://github.com/orgs/cuhacking'
const DOCS_BASE_URL = 'http://localhost:3000'
Expand Down Expand Up @@ -47,19 +68,21 @@ test.describe(`Common MOBILE, TABLET and DESKTOP Layout Elements`, {
await expect(docsLayoutPage.cuHackingLogoIcon).toBeVisible()
})

test(`should take user to docs home page when cuHacking logo icon is clicked in header`, async ({ docsLayoutPage }) => {
await docsLayoutPage.cuHackingLogoIcon.click()
await expect(docsLayoutPage.page).toHaveURL(DOCS_BASE_URL)
})
// Disabled due to flaky result
// test(`should take user to docs home page when cuHacking logo icon is clicked in header`, async ({ docsLayoutPage }) => {
// await docsLayoutPage.cuHackingLogoIcon.click()
// await expect(docsLayoutPage.page).toHaveURL(DOCS_BASE_URL)
// })

test(`should contain cuHacking logo Text in header`, async ({ docsLayoutPage }) => {
await expect(docsLayoutPage.cuHackingLogoText).toBeVisible()
})

test(`should take user to docs home page when cuHacking logo text is clicked in header`, async ({ docsLayoutPage }) => {
await docsLayoutPage.cuHackingLogoText.click()
await expect(docsLayoutPage.page).toHaveURL(DOCS_BASE_URL)
})
// Disabled due to flaky result
// test(`should take user to docs home page when cuHacking logo text is clicked in header`, async ({ docsLayoutPage }) => {
// await docsLayoutPage.cuHackingLogoText.click()
// await expect(docsLayoutPage.page).toHaveURL(DOCS_BASE_URL)
// })

test(`should check for 'Next page' Button`, async ({ docsLayoutPage }) => {
await expect(docsLayoutPage.nextButton).toBeVisible()
Expand All @@ -69,9 +92,10 @@ test.describe(`Common MOBILE, TABLET and DESKTOP Layout Elements`, {
await expect(docsLayoutPage.editOnGithubButton).toBeVisible()
})

test(`should load index page when 'Edit on Github' is clicked`, async ({ docsLayoutPage }) => {
await clickAndGoToPage(docsLayoutPage, docsLayoutPage.editOnGithubButton, CUHACKING_2025_GITHUB_INDEX_PAGE_URL)
})
// Disabled due to flaky result
// test(`should load index page when 'Edit on Github' is clicked`, async ({ docsLayoutPage }) => {
// await clickAndGoToPage(docsLayoutPage, docsLayoutPage.editOnGithubButton, CUHACKING_2025_GITHUB_INDEX_PAGE_URL)
// })
})

/* ---------------- TABLET + DESKTOP + MOBILE LINKS---------------- */
Expand All @@ -84,107 +108,87 @@ test.describe('Common MOBILE, TABLET and DESKTOP Links', {
await docsLayoutPage.hamburgerIcon.click()
}
})
test('should contain website link', async ({ docsLayoutPage }) => {
await expect(docsLayoutPage.websiteLink).toBeVisible()
})

test('should take user to website when website link clicked', async ({ docsLayoutPage }) => {
await clickAndGoToPage(docsLayoutPage, docsLayoutPage.websiteLink, CUHACKING_2025_LANDING_PAGE_URL)
})

test('should contain Portal link', async ({ docsLayoutPage }) => {
test('should contain all links', async ({ docsLayoutPage }) => {
await expect(docsLayoutPage.websiteLink).toBeVisible()
await expect(docsLayoutPage.portalLink).toBeVisible()
await expect(docsLayoutPage.designLink).toBeVisible()
await expect(docsLayoutPage.eslintLink).toBeVisible()
await expect(docsLayoutPage.discordLink).toBeVisible()
await expect(docsLayoutPage.instagramLink).toBeVisible()
await expect(docsLayoutPage.linkedinLink).toBeVisible()
await expect(docsLayoutPage.linktreeLink).toBeVisible()
await expect(docsLayoutPage.figmaLink).toBeVisible()
await expect(docsLayoutPage.projectBoardLink).toBeVisible()
await expect(docsLayoutPage.githubLink).toBeVisible()
})

test('should take user to Portal when Portal link is clicked', async ({ docsLayoutPage }) => {
await clickAndGoToPage(docsLayoutPage, docsLayoutPage.portalLink, CUHACKING_2025_PORTAL_URL)
})
// Disabled due to flaky result
// test('should take user to website when website link clicked', async ({ docsLayoutPage }) => {
// await clickAndGoToPage(docsLayoutPage, docsLayoutPage.websiteLink, CUHACKING_2025_LANDING_PAGE_URL)
// })

test('should contain design link', async ({ docsLayoutPage }) => {
await expect(docsLayoutPage.designLink).toBeVisible()
})
// Disabled due to flaky result
// test('should take user to Portal when Portal link is clicked', async ({ docsLayoutPage }) => {
// await clickAndGoToPage(docsLayoutPage, docsLayoutPage.portalLink, CUHACKING_2025_PORTAL_URL)
// })

// TODO: Uncomment when the link is available

// test('should take user to design site when design link clicked', async ({ docsLayoutPage }) => {
// await clickAndGoToPage(docsLayoutPage, docsLayoutPage.designLink, CUHACKING_2025_DESIGN_URL)
// })

test('should contain Eslint link', async ({ docsLayoutPage }) => {
await expect(docsLayoutPage.eslintLink).toBeVisible()
})
// TODO: Uncomment when the link is available

// test('should take user to eslint site when eslint link clicked', async ({ docsLayoutPage }) => {
// await clickAndGoToPage(docsLayoutPage, docsLayoutPage.eslintLink, CUHACKING_2025_ESLINT_URL)
// })

test('should contain discord link', async ({ docsLayoutPage }) => {
await expect(docsLayoutPage.discordLink).toBeVisible()
})

test('should take user to Discord link site when Discord link clicked', async ({ docsLayoutPage }) => {
await clickAndGoToPage(docsLayoutPage, docsLayoutPage.discordLink, CUHACKING_2025_DISCORD_URL)
})

test('should contain Instagram link', async ({ docsLayoutPage }) => {
await expect(docsLayoutPage.instagramLink).toBeVisible()
})
// Disabled due to flaky result
// test('should take user to Discord link site when Discord link clicked', async ({ docsLayoutPage }) => {
// await clickAndGoToPage(docsLayoutPage, docsLayoutPage.discordLink, CUHACKING_2025_DISCORD_URL)
// })

// TODO: Instagram link requires auth to view

// test('should take user to Instagram when Instagram link clicked', async ({ docsLayoutPage }) => {
// await clickAndGoToPage(docsLayoutPage, docsLayoutPage.instagramLink, CUHACKING_2025_INSTAGRAM_URL)
// })

test('should contain LinkedIn link', async ({ docsLayoutPage }) => {
await expect(docsLayoutPage.linkedinLink).toBeVisible()
})

// TODO: LinkedIn link requires auth to view

// test('should take user to LinkedIn when LinkedIn link clicked', async ({ docsLayoutPage }) => {
// await clickAndGoToPage(docsLayoutPage, docsLayoutPage.linkedinLink, CUHACKING_2025_LINKED_IN_URL)
// })

test('should contain Linktree link', async ({ docsLayoutPage }) => {
await expect(docsLayoutPage.linktreeLink).toBeVisible()
})

test('should take user to Linktree when Linktree link is clicked', async ({ docsLayoutPage }) => {
await clickAndGoToPage(docsLayoutPage, docsLayoutPage.linktreeLink, CUHACKING_2025_LINKTREE_URL)
})

test('should contain Figma link', async ({ docsLayoutPage }) => {
await expect(docsLayoutPage.figmaLink).toBeVisible()
})

test('should take user to Figma when Figma link is clicked', async ({ docsLayoutPage }) => {
await clickAndGoToPage(docsLayoutPage, docsLayoutPage.figmaLink, CUHACKING_2025_FIGMA_URL)
})

test('should contain Project board link', async ({ docsLayoutPage }) => {
await expect(docsLayoutPage.projectBoardLink).toBeVisible()
})
// Disabled due to flaky result
// test('should take user to Linktree when Linktree link is clicked', async ({ docsLayoutPage }) => {
// await clickAndGoToPage(docsLayoutPage, docsLayoutPage.linktreeLink, CUHACKING_2025_LINKTREE_URL)
// })

test('should take user to Project board when Project board link is clicked', async ({ docsLayoutPage }) => {
await clickAndGoToPage(docsLayoutPage, docsLayoutPage.projectBoardLink, CUHACKING_2025_GITHUB_PROJECT_BOARD_URL)
})
// Disabled due to flaky result
// test('should take user to Figma when Figma link is clicked', async ({ docsLayoutPage }) => {
// await clickAndGoToPage(docsLayoutPage, docsLayoutPage.figmaLink, CUHACKING_2025_FIGMA_URL)
// })

test('should contain Github link', async ({ docsLayoutPage }) => {
await expect(docsLayoutPage.githubLink).toBeVisible()
})
// Disabled due to flaky result
// test('should take user to Project board when Project board link is clicked', async ({ docsLayoutPage }) => {
// await clickAndGoToPage(docsLayoutPage, docsLayoutPage.projectBoardLink, CUHACKING_2025_GITHUB_PROJECT_BOARD_URL)
// })

test('should take user to Github repo when Github link is clicked', async ({ docsLayoutPage }) => {
await clickAndGoToPage(docsLayoutPage, docsLayoutPage.githubLink, CUHACKING_2025_GITHUB_REPOSITORY_URL)
})
// Disabled due to flaky result
// test('should take user to Github repo when Github link is clicked', async ({ docsLayoutPage }) => {
// await clickAndGoToPage(docsLayoutPage, docsLayoutPage.githubLink, CUHACKING_2025_GITHUB_REPOSITORY_URL)
// })
})

/* ---------------- MOBILE + TABLET ---------------- */
test.describe(`Common MOBILE and TABLET Layout Elements`, {
tag: '@smoke',
}, () => {
test.beforeEach(async () => {
test.beforeEach(async ({ docsLayoutPage }) => {
await docsLayoutPage.goto()
const device = test.info().project.name
if (device.includes('desktop')) {
test.skip()
Expand All @@ -209,7 +213,8 @@ test.describe(`Common MOBILE and TABLET Layout Elements`, {
test.describe('Common TABLET and DESKTOP Layout Elements', {
tag: '@smoke',
}, () => {
test.beforeEach(async () => {
test.beforeEach(async ({ docsLayoutPage }) => {
await docsLayoutPage.goto()
const device = test.info().project.name
if (device.includes('mobile')) {
test.skip()
Expand Down Expand Up @@ -243,7 +248,8 @@ test.describe('Common TABLET and DESKTOP Layout Elements', {
test.describe('Unique MOBILE Header Elements', {
tag: '@smoke',
}, () => {
test.beforeEach(async () => {
test.beforeEach(async ({ docsLayoutPage }) => {
await docsLayoutPage.goto()
const device = test.info().project.name
if (device.includes('desktop') || device.includes('tablet')) {
test.skip()
Expand All @@ -267,7 +273,8 @@ test.describe('Unique MOBILE Header Elements', {
test.describe('Unique DESKTOP Floating Table Elements', {
tag: '@smoke',
}, () => {
test.beforeEach(async () => {
test.beforeEach(async ({ docsLayoutPage }) => {
await docsLayoutPage.goto()
const device = test.info().project.name
if (device.includes('mobile') || device.includes('tablet')) {
test.skip()
Expand Down
5 changes: 3 additions & 2 deletions apps/docs-e2e/src/lighthouse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ const thresholdsConfig = {
// 'pwa': 50,
}

lighthouseTest('should pass lighthouse audits', async ({ page, port }, testInfo) => {
lighthouseTest('should pass lighthouse audits', async ({ page, port }) => {
// Skip Lighthouse tests for specific projects
const testInfo = test.info().project.name
if (
['firefox (desktop)', 'webkit (desktop)', 'webkit (tablet)', 'webkit (mobile)'].includes(
testInfo.project.name,
testInfo,
)
) {
test.skip('Lighthouse is not supported for this project')
Expand Down
2 changes: 1 addition & 1 deletion apps/docs-e2e/src/pom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class DocsLayout {
// Mobile + Tablet + Desktop
this.cuHackingLogoIcon = page.getByRole('img', { name: 'cuHacking logo' }).first()
this.cuHackingLogoText = page.getByRole('link', { name: 'cuHacking logo cuHacking' }).first()
this.nextButton = page.getByRole('link', { name: 'Next Tech Stack' })
this.nextButton = page.getByRole('link', { name: /Next/i })
this.editOnGithubButton = page.getByRole('link', { name: 'Edit on GitHub' })

// Mobile + Tablet + Desktop Links
Expand Down

0 comments on commit 95a40fb

Please sign in to comment.