From 8c1b3aa300188be5aba49b1e6565adc3691530d7 Mon Sep 17 00:00:00 2001 From: Abhay Fernandes Date: Mon, 2 Sep 2024 10:04:52 -0400 Subject: [PATCH 1/6] Update the favicon --- package.json | 4 ++-- public/favicon.svg | 10 +--------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 9f7e153..03a690e 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "blue-bar", + "name": "msu-secs-website", "type": "module", "version": "0.0.1", "scripts": { @@ -14,4 +14,4 @@ "@astrojs/check": "^0.9.3", "typescript": "^5.5.4" } -} \ No newline at end of file +} diff --git a/public/favicon.svg b/public/favicon.svg index f157bd1..16f5fdf 100644 --- a/public/favicon.svg +++ b/public/favicon.svg @@ -1,9 +1 @@ - - - - + From ea646be47822d82fa8a4ad00ddb6fbe2f2830053 Mon Sep 17 00:00:00 2001 From: Abhay Fernandes Date: Mon, 2 Sep 2024 10:04:52 -0400 Subject: [PATCH 2/6] Update the favicon --- .gitignore | 3 +++ public/favicon.svg | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index 8e6d783..e6b94d7 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,6 @@ examples/**/env.d.ts # want to share with others (see # https://github.com/withastro/astro/pull/11759#discussion_r1721444711) *.code-workspace + +# ignore .astro run files +.astro/ diff --git a/public/favicon.svg b/public/favicon.svg index 16f5fdf..99c384f 100644 --- a/public/favicon.svg +++ b/public/favicon.svg @@ -1 +1,5 @@ +<<<<<<< HEAD +======= + +>>>>>>> 7a66ed1 (Update the favicon) From 3ea1859d3dbeb0caef3d9ebee95ef35bfee2d5c9 Mon Sep 17 00:00:00 2001 From: Abhay Fernandes Date: Mon, 2 Sep 2024 10:04:52 -0400 Subject: [PATCH 3/6] Update the favicon --- public/favicon.svg | 4 ---- 1 file changed, 4 deletions(-) diff --git a/public/favicon.svg b/public/favicon.svg index 99c384f..783d5f5 100644 --- a/public/favicon.svg +++ b/public/favicon.svg @@ -1,5 +1 @@ -<<<<<<< HEAD - -======= ->>>>>>> 7a66ed1 (Update the favicon) From f6dc912d753d3e1ff2c3bc4ac921c059bfb28227 Mon Sep 17 00:00:00 2001 From: Abhay Fernandes Date: Mon, 2 Sep 2024 10:04:52 -0400 Subject: [PATCH 4/6] Update the favicon --- public/favicon.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/favicon.svg b/public/favicon.svg index 783d5f5..6bc9380 100644 --- a/public/favicon.svg +++ b/public/favicon.svg @@ -1 +1 @@ - + From fa10eded4a576885476cef539b86ada09d7a0502 Mon Sep 17 00:00:00 2001 From: Abhay Fernandes Date: Mon, 2 Sep 2024 10:45:41 -0400 Subject: [PATCH 5/6] update and add infra for playwright tests --- .github/workflows/node.js.yml | 31 --------- .github/workflows/playwright.yml | 32 +++++++++ .gitignore | 8 +++ package-lock.json | 82 +++++++++++++++++++++- package.json | 7 +- playwright.config.ts | 78 +++++++++++++++++++++ src/pages/index.astro | 114 +------------------------------ tests/example.spec.ts | 18 +++++ 8 files changed, 223 insertions(+), 147 deletions(-) delete mode 100644 .github/workflows/node.js.yml create mode 100644 .github/workflows/playwright.yml create mode 100644 playwright.config.ts create mode 100644 tests/example.spec.ts diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml deleted file mode 100644 index 2284b93..0000000 --- a/.github/workflows/node.js.yml +++ /dev/null @@ -1,31 +0,0 @@ -# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs - -name: Node.js CI - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -jobs: - build: - - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [18.x, 20.x, 22.x] - # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ - - steps: - - uses: actions/checkout@v4 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node-version }} - cache: 'npm' - - run: npm ci - - run: npm run build --if-present - - run: npm test diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml new file mode 100644 index 0000000..db3e37d --- /dev/null +++ b/.github/workflows/playwright.yml @@ -0,0 +1,32 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs + +name: Playwright Tests + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + test: + timeout-minutes: 60 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18 + - name: Install dependencies + run: npm ci + - name: Install Playwright Browsers + run: npx playwright install --with-deps + - name: Run Playwright tests + run: npx playwright test + - uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 diff --git a/.gitignore b/.gitignore index e6b94d7..785542b 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,11 @@ examples/**/env.d.ts # ignore .astro run files .astro/ +/test-results/ +/playwright-report/ +/blob-report/ +/playwright/.cache/ +/test-results/ +/playwright-report/ +/blob-report/ +/playwright/.cache/ diff --git a/package-lock.json b/package-lock.json index 23db32e..1c0f3f4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,20 @@ { - "name": "blue-bar", + "name": "msu-secs-website", "version": "0.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "blue-bar", + "name": "msu-secs-website", "version": "0.0.1", "dependencies": { "@astrojs/check": "^0.9.3", "astro": "^4.15.2", "typescript": "^5.5.4" + }, + "devDependencies": { + "@playwright/test": "^1.46.1", + "@types/node": "^22.5.2" } }, "node_modules/@ampproject/remapping": { @@ -1272,6 +1276,21 @@ "resolved": "https://registry.npmjs.org/@oslojs/encoding/-/encoding-0.4.1.tgz", "integrity": "sha512-hkjo6MuIK/kQR5CrGNdAPZhS01ZCXuWDRJ187zh6qqF2+yMHZpD9fAYpX8q2bOO6Ryhl3XpCT6kUX76N8hhm4Q==" }, + "node_modules/@playwright/test": { + "version": "1.46.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.46.1.tgz", + "integrity": "sha512-Fq6SwLujA/DOIvNC2EL/SojJnkKf/rAwJ//APpJJHRyMi1PdKrY3Az+4XNQ51N4RTbItbIByQ0jgd1tayq1aeA==", + "dev": true, + "dependencies": { + "playwright": "1.46.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, "node_modules/@rollup/pluginutils": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.0.tgz", @@ -1588,6 +1607,15 @@ "@types/unist": "*" } }, + "node_modules/@types/node": { + "version": "22.5.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.2.tgz", + "integrity": "sha512-acJsPTEqYqulZS/Yp/S3GgeE6GZ0qYODUR8aVr/DkhHQ8l9nd4j5x1/ZJy9/gHrRlFMqkO6i0I3E27Alu4jjPg==", + "devOptional": true, + "dependencies": { + "undici-types": "~6.19.2" + } + }, "node_modules/@types/unist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", @@ -4386,6 +4414,50 @@ "node": ">=8" } }, + "node_modules/playwright": { + "version": "1.46.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.46.1.tgz", + "integrity": "sha512-oPcr1yqoXLCkgKtD5eNUPLiN40rYEM39odNpIb6VE6S7/15gJmA1NzVv6zJYusV0e7tzvkU/utBFNa/Kpxmwng==", + "dev": true, + "dependencies": { + "playwright-core": "1.46.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, + "node_modules/playwright-core": { + "version": "1.46.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.46.1.tgz", + "integrity": "sha512-h9LqIQaAv+CYvWzsZ+h3RsrqCStkBHlgo6/TJlFst3cOTlLghBQlJwPOZKQJTKNaD3QIB7aAVQ+gfWbN3NXB7A==", + "dev": true, + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/playwright/node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/postcss": { "version": "8.4.44", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.44.tgz", @@ -5103,6 +5175,12 @@ "semver": "^7.3.8" } }, + "node_modules/undici-types": { + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", + "devOptional": true + }, "node_modules/unified": { "version": "11.0.5", "resolved": "https://registry.npmjs.org/unified/-/unified-11.0.5.tgz", diff --git a/package.json b/package.json index 03a690e..0e94693 100644 --- a/package.json +++ b/package.json @@ -7,11 +7,16 @@ "start": "astro dev", "build": "astro check && astro build", "preview": "astro preview", + "test": "npx playwright test", "astro": "astro" }, "dependencies": { - "astro": "^4.15.2", "@astrojs/check": "^0.9.3", + "astro": "^4.15.2", "typescript": "^5.5.4" + }, + "devDependencies": { + "@playwright/test": "^1.46.1", + "@types/node": "^22.5.2" } } diff --git a/playwright.config.ts b/playwright.config.ts new file mode 100644 index 0000000..4a501ea --- /dev/null +++ b/playwright.config.ts @@ -0,0 +1,78 @@ +import { defineConfig, devices } from '@playwright/test'; + +/** + * Read environment variables from file. + * https://github.com/motdotla/dotenv + */ +// import dotenv from 'dotenv'; +// dotenv.config({ path: path.resolve(__dirname, '.env') }); + +/** + * See https://playwright.dev/docs/test-configuration. + */ +export default defineConfig({ + testDir: './tests', + /* 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, + // }, +}); diff --git a/src/pages/index.astro b/src/pages/index.astro index fb62628..2f512b9 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,123 +1,11 @@ --- import Layout from '../layouts/Layout.astro'; -import Card from '../components/Card.astro'; --- - +
- -

Welcome to Astro

-

- To get started, open the directory src/pages in your project.
- Code Challenge: Tweak the "Welcome to Astro" message above. -

-
diff --git a/tests/example.spec.ts b/tests/example.spec.ts new file mode 100644 index 0000000..54a906a --- /dev/null +++ b/tests/example.spec.ts @@ -0,0 +1,18 @@ +import { test, expect } from '@playwright/test'; + +test('has title', async ({ page }) => { + await page.goto('https://playwright.dev/'); + + // Expect a title "to contain" a substring. + await expect(page).toHaveTitle(/Playwright/); +}); + +test('get started link', async ({ page }) => { + await page.goto('https://playwright.dev/'); + + // Click the get started link. + await page.getByRole('link', { name: 'Get started' }).click(); + + // Expects page to have a heading with the name of Installation. + await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); +}); From 99a6a89c20a271061168420df29e238d51ea9997 Mon Sep 17 00:00:00 2001 From: Abhay Fernandes Date: Mon, 2 Sep 2024 10:57:02 -0400 Subject: [PATCH 6/6] Add playwright for testing, update github actions --- playwright.config.ts | 43 +++++++++++++++++++++---------------------- tests/example.spec.ts | 13 ++----------- 2 files changed, 23 insertions(+), 33 deletions(-) diff --git a/playwright.config.ts b/playwright.config.ts index 4a501ea..faa3117 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -25,7 +25,7 @@ export default defineConfig({ /* 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', + baseURL: 'http://127.0.0.1:4321', /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ trace: 'on-first-retry', @@ -49,30 +49,29 @@ export default defineConfig({ }, /* Test against mobile viewports. */ - // { - // name: 'Mobile Chrome', - // use: { ...devices['Pixel 5'] }, - // }, - // { - // name: 'Mobile Safari', - // use: { ...devices['iPhone 12'] }, - // }, + { + 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' }, - // }, + { + 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, - // }, + webServer: { + command: 'npm run start', + reuseExistingServer: !process.env.CI, + }, }); diff --git a/tests/example.spec.ts b/tests/example.spec.ts index 54a906a..012e80d 100644 --- a/tests/example.spec.ts +++ b/tests/example.spec.ts @@ -1,18 +1,9 @@ import { test, expect } from '@playwright/test'; test('has title', async ({ page }) => { - await page.goto('https://playwright.dev/'); + await page.goto('/'); // Expect a title "to contain" a substring. - await expect(page).toHaveTitle(/Playwright/); + await expect(page).toHaveTitle(/Home/); }); -test('get started link', async ({ page }) => { - await page.goto('https://playwright.dev/'); - - // Click the get started link. - await page.getByRole('link', { name: 'Get started' }).click(); - - // Expects page to have a heading with the name of Installation. - await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible(); -});