Add tests for roadmap pages and homepage

pull/3305/head
Kamran Ahmed 2 years ago
parent af9e266190
commit cbd79ef299
  1. 4
      .gitignore
  2. 4
      package.json
  3. 108
      playwright.config.ts
  4. 18
      pnpm-lock.yaml
  5. 7
      tests/index.spec.ts
  6. BIN
      tests/index.spec.ts-snapshots/homepage-test-1-chromium-darwin.png
  7. BIN
      tests/index.spec.ts-snapshots/homepage-test-1-firefox-darwin.png
  8. BIN
      tests/index.spec.ts-snapshots/homepage-test-1-webkit-darwin.png
  9. 13
      tests/roadmap.spec.ts
  10. BIN
      tests/roadmap.spec.ts-snapshots/roadmap-android-1-chromium-darwin.png
  11. BIN
      tests/roadmap.spec.ts-snapshots/roadmap-angular-1-chromium-darwin.png
  12. BIN
      tests/roadmap.spec.ts-snapshots/roadmap-aspnet-core-1-chromium-darwin.png
  13. BIN
      tests/roadmap.spec.ts-snapshots/roadmap-backend-1-chromium-darwin.png
  14. BIN
      tests/roadmap.spec.ts-snapshots/roadmap-blockchain-1-chromium-darwin.png
  15. BIN
      tests/roadmap.spec.ts-snapshots/roadmap-computer-science-1-chromium-darwin.png
  16. BIN
      tests/roadmap.spec.ts-snapshots/roadmap-cyber-security-1-chromium-darwin.png
  17. BIN
      tests/roadmap.spec.ts-snapshots/roadmap-design-system-1-chromium-darwin.png
  18. BIN
      tests/roadmap.spec.ts-snapshots/roadmap-devops-1-chromium-darwin.png
  19. BIN
      tests/roadmap.spec.ts-snapshots/roadmap-flutter-1-chromium-darwin.png
  20. BIN
      tests/roadmap.spec.ts-snapshots/roadmap-frontend-1-chromium-darwin.png
  21. BIN
      tests/roadmap.spec.ts-snapshots/roadmap-golang-1-chromium-darwin.png
  22. BIN
      tests/roadmap.spec.ts-snapshots/roadmap-graphql-1-chromium-darwin.png
  23. BIN
      tests/roadmap.spec.ts-snapshots/roadmap-java-1-chromium-darwin.png
  24. BIN
      tests/roadmap.spec.ts-snapshots/roadmap-javascript-1-chromium-darwin.png
  25. BIN
      tests/roadmap.spec.ts-snapshots/roadmap-nodejs-1-chromium-darwin.png
  26. BIN
      tests/roadmap.spec.ts-snapshots/roadmap-postgresql-dba-1-chromium-darwin.png
  27. BIN
      tests/roadmap.spec.ts-snapshots/roadmap-python-1-chromium-darwin.png
  28. BIN
      tests/roadmap.spec.ts-snapshots/roadmap-qa-1-chromium-darwin.png
  29. BIN
      tests/roadmap.spec.ts-snapshots/roadmap-react-1-chromium-darwin.png
  30. BIN
      tests/roadmap.spec.ts-snapshots/roadmap-react-native-1-chromium-darwin.png
  31. BIN
      tests/roadmap.spec.ts-snapshots/roadmap-software-architect-1-chromium-darwin.png
  32. BIN
      tests/roadmap.spec.ts-snapshots/roadmap-software-design-architecture-1-chromium-darwin.png
  33. BIN
      tests/roadmap.spec.ts-snapshots/roadmap-spring-boot-1-chromium-darwin.png
  34. BIN
      tests/roadmap.spec.ts-snapshots/roadmap-vue-1-chromium-darwin.png

4
.gitignore vendored

@ -20,3 +20,7 @@ pnpm-debug.log*
# macOS-specific files
.DS_Store
/test-results/
/playwright-report/
/playwright/.cache/
tests-examples

@ -13,7 +13,8 @@
"compress:jsons": "node bin/compress-jsons.cjs",
"upgrade": "ncu -u",
"roadmap-links": "node bin/roadmap-links.cjs",
"roadmap-content": "node bin/roadmap-content.cjs"
"roadmap-content": "node bin/roadmap-content.cjs",
"test:e2e": "playwright test"
},
"dependencies": {
"@astrojs/sitemap": "^1.0.0",
@ -27,6 +28,7 @@
"tailwindcss": "^3.2.4"
},
"devDependencies": {
"@playwright/test": "^1.29.2",
"@tailwindcss/typography": "^0.5.9",
"gh-pages": "^4.0.0",
"json-to-pretty-yaml": "^1.2.2",

@ -0,0 +1,108 @@
import type { PlaywrightTestConfig } from '@playwright/test';
import { devices } from '@playwright/test';
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();
/**
* See https://playwright.dev/docs/test-configuration.
*/
const config: PlaywrightTestConfig = {
testDir: './tests',
/* Maximum time one test can run for. */
timeout: 30 * 1000,
expect: {
/**
* Maximum time expect() should wait for the condition to be met.
* For example in `await expect(locator).toHaveText();`
*/
timeout: 5000,
},
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
actionTimeout: 0,
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: 'http://localhost:3000',
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},
/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
},
},
// {
// name: 'firefox',
// use: {
// ...devices['Desktop Firefox'],
// },
// },
// {
// name: 'webkit',
// use: {
// ...devices['Desktop Safari'],
// },
// },
/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: {
// ...devices['Pixel 5'],
// },
// },
// {
// name: 'Mobile Safari',
// use: {
// ...devices['iPhone 12'],
// },
// },
/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: {
// channel: 'msedge',
// },
// },
// {
// name: 'Google Chrome',
// use: {
// channel: 'chrome',
// },
// },
],
/* Folder for test artifacts such as screenshots, videos, traces, etc. */
// outputDir: 'test-results/',
/* Run your local dev server before starting the tests */
webServer: {
command: 'npm run dev',
url: "http://localhost:3000",
reuseExistingServer: !process.env.CI,
},
};
export default config;

@ -3,6 +3,7 @@ lockfileVersion: 5.4
specifiers:
'@astrojs/sitemap': ^1.0.0
'@astrojs/tailwind': ^2.1.3
'@playwright/test': ^1.29.2
'@tailwindcss/typography': ^0.5.9
astro: ^1.9.2
astro-compress: ^1.1.27
@ -28,6 +29,7 @@ dependencies:
tailwindcss: 3.2.4
devDependencies:
'@playwright/test': 1.29.2
'@tailwindcss/typography': 0.5.9_tailwindcss@3.2.4
gh-pages: 4.0.0
json-to-pretty-yaml: 1.2.2
@ -580,6 +582,15 @@ packages:
tiny-glob: 0.2.9
tslib: 2.4.1
/@playwright/test/1.29.2:
resolution: {integrity: sha512-+3/GPwOgcoF0xLz/opTnahel1/y42PdcgZ4hs+BZGIUjtmEFSXGg+nFoaH3NSmuc7a6GSFwXDJ5L7VXpqzigNg==}
engines: {node: '>=14'}
hasBin: true
dependencies:
'@types/node': 17.0.45
playwright-core: 1.29.2
dev: true
/@pnpm/network.ca-file/1.0.2:
resolution: {integrity: sha512-YcPQ8a0jwYU9bTdJDpXjMi7Brhkr1mXsXrUJvjqM2mQDgkRiz8jFaQGOdaLxgjtUfQgZhKy/O3cG/YwmgKaxLA==}
engines: {node: '>=12.22.0'}
@ -756,7 +767,6 @@ packages:
/@types/node/17.0.45:
resolution: {integrity: sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==}
dev: false
/@types/parse5/6.0.3:
resolution: {integrity: sha512-SuT16Q1K51EAVPz1K29DJ/sXjhSQ0zjvsypYJ6tlwVsRV9jwW5Adq2ch8Dq8kDBCkYnELS7N7VNCSB5nC56t/g==}
@ -4228,6 +4238,12 @@ packages:
dependencies:
find-up: 4.1.0
/playwright-core/1.29.2:
resolution: {integrity: sha512-94QXm4PMgFoHAhlCuoWyaBYKb92yOcGVHdQLoxQ7Wjlc7Flg4aC/jbFW7xMR52OfXMVkWicue4WXE7QEegbIRA==}
engines: {node: '>=14'}
hasBin: true
dev: true
/postcss-import/14.1.0_postcss@8.4.20:
resolution: {integrity: sha512-flwI+Vgm4SElObFVPpTIT7SU7R3qk2L7PyduMcokiaVKuWv9d/U+Gm/QAd8NDLuykTWTkcrjOeD2Pp1rMeBTGw==}
engines: {node: '>=10.0.0'}

@ -0,0 +1,7 @@
import { test, expect } from '@playwright/test';
test('homepage test', async ({ page }) => {
await page.goto('/');
await expect(page).toHaveScreenshot({ fullPage: true });
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 563 KiB

@ -0,0 +1,13 @@
import path from 'node:path';
import fs from 'node:fs';
import { test, expect } from '@playwright/test';
const roadmapIds = fs.readdirSync(path.join(process.cwd(), 'src/roadmaps'));
for (const roadmapId of roadmapIds) {
test(`roadmap ${roadmapId}`, async ({ page }) => {
await page.goto(`/${roadmapId}`);
await expect(page).toHaveScreenshot({ fullPage: true });
});
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 455 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 690 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 860 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 685 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 555 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 745 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 800 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 379 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 384 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 648 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 492 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 330 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 396 KiB

Loading…
Cancel
Save