Skip to content

Commit

Permalink
Merge pull request #28 from rocky-linux/develop
Browse files Browse the repository at this point in the history
Release of Fixes and Security Fixes
  • Loading branch information
NebraskaCoder authored May 3, 2024
2 parents c260ff0 + fc93811 commit 650136d
Show file tree
Hide file tree
Showing 11 changed files with 241 additions and 5 deletions.
1 change: 1 addition & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"austenc.tailwind-docs",
"eamodio.gitlens",
"unifiedjs.vscode-mdx",
"ms-playwright.playwright",
"github.copilot"
]
}
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Playwright Tests
on:
push:
pull_request:
jobs:
e2e-tests:
timeout-minutes: 60
runs-on: ubuntu-latest
env:
CI: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Build
run: npm run build
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,10 @@ yarn-error.log*
next-env.d.ts

# JetBrains IDEs
.idea
.idea

# Playwright
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
44 changes: 44 additions & 0 deletions e2e/Homepage.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { test, expect } from "@playwright/test";
import { expectDownloadPage } from "./utils/PageUtils";

test.describe("Core Rocky Brand", () => {
test("has title", async ({ page }) => {
await page.goto("/");

// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/Rocky Linux/);
});
});

test.describe("Home Page Downloads Flow", () => {
test("has download buttons", async ({ page, isMobile }) => {
await page.goto("/");

// Check that we have a download button in the navigation on desktop.
if (!isMobile) {
const navDownloadButton = page
.getByRole("navigation")
.getByRole("button", { name: "Download" });

await expect(navDownloadButton).toBeVisible();

await navDownloadButton.click();

await expectDownloadPage(page);

await page.goBack();
}

// Check that we have a download button in the hero section.

const heroDownloadButton = page.getByRole("main").getByRole("button", {
name: "Download",
});

await expect(heroDownloadButton).toBeVisible();

await heroDownloadButton.click();

await expectDownloadPage(page);
});
});
10 changes: 10 additions & 0 deletions e2e/Redirects.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { test } from "@playwright/test";
import { expectDownloadPage } from "./utils/PageUtils";

test.describe("Website Redirects", () => {
test("redirects old /cloud-images to /download", async ({ page }) => {
await page.goto("/cloud-images");

await expectDownloadPage(page);
});
});
6 changes: 6 additions & 0 deletions e2e/utils/PageUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { expect, type Page } from "@playwright/test";

export const expectDownloadPage = async (page: Page) => {
await expect(page).toHaveURL(/\/download/);
await expect(page).toHaveTitle(/Download - Rocky Linux/);
};
4 changes: 4 additions & 0 deletions jest.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const config = {
"^@/(.*)$": "<rootDir>/$1",
"^test-utils": "<rootDir>/@types/test-utils/test-utils.tsx",
},
testPathIgnorePatterns: ["<rootDir>/e2e/"],
modulePathIgnorePatterns: ["<rootDir>/e2e/"],
passWithNoTests: true,
collectCoverageFrom: [
"**/*.{ts,tsx}",
"!**/*.d.ts",
Expand All @@ -28,6 +31,7 @@ const config = {
"!<rootDir>/tailwind.config.ts",
"!**/postcss.config.js",
"!**/layout.{ts,tsx,js,jsx}",
"!<rootDir>/e2e/**",
"!<rootDir>/i18n.ts",
"!<rootDir>/middleware.ts",
],
Expand Down
9 changes: 9 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ const nextConfig = {
images: {
domains: ["www.rockylinux.org", "rockylinux.org"],
},
async redirects() {
return [
{
source: "/cloud-images",
destination: "/download",
permanent: true,
},
];
},
};

module.exports = withNextIntl(nextConfig);
52 changes: 49 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
"format": "prettier --write '**/*.{js,jsx,ts,tsx,json,css,md}'",
"lint": "next lint",
"lint:ci": "eslint . > eslint-output.txt || true",
"prepare": "husky install",
"prepare": "husky && playwright install",
"start": "next start",
"e2e": "playwright test",
"e2e:dev": "playwright test --ui",
"e2e:install": "playwright install",
"test": "jest --watch",
"test:ci": "jest --json --outputFile=jest-output.json 2>&1 | tee jest-output.txt",
"test:coverage": "jest --coverage",
Expand Down Expand Up @@ -69,6 +72,7 @@
"zod": "^3.22.4"
},
"devDependencies": {
"@playwright/test": "^1.43.1",
"@storybook/addon-a11y": "^7.6.13",
"@storybook/addon-actions": "^7.6.13",
"@storybook/addon-docs": "^7.6.13",
Expand Down
77 changes: 77 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { defineConfig, devices } from "@playwright/test";

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: "./e2e",
/* 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: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: "http://127.0.0.1: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: { ...devices["Desktop Edge"], channel: "msedge" },
},
{
name: "Google Chrome",
use: { ...devices["Desktop Chrome"], channel: "chrome" },
},
],

/* Run your local dev server before starting the tests */
webServer: {
command: "npm run start",
url: "http://127.0.0.1:3000",
reuseExistingServer: !process.env.CI,
},
});

0 comments on commit 650136d

Please sign in to comment.