Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Isaiah/playwright tests #537

Merged
merged 98 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
b557bc4
setup PlayWright tests
IsaiahA21 Aug 24, 2024
c2a1d84
Included more test cases
IsaiahA21 Aug 24, 2024
b64dc11
refactor: Updated documentation to include how to run Playwright tests
IsaiahA21 Aug 24, 2024
1d655a9
additonal updates to documentation
IsaiahA21 Aug 24, 2024
e548a21
Added test coverage for navigation bar and project page
IsaiahA21 Sep 7, 2024
baa9d47
updated PlayWright config for a larger viewport size. And updated con…
IsaiahA21 Sep 13, 2024
59cb696
Tests that had to find image elements were based on style-components …
IsaiahA21 Sep 14, 2024
09b4dbe
memorized the testdataId for the profile image.
IsaiahA21 Sep 14, 2024
314e70d
Inside useMemo, forgot to include return
IsaiahA21 Sep 14, 2024
3acc0cf
Add data-testid to ApplyButton component for unique identification
IsaiahA21 Sep 18, 2024
977ec01
Added an env variable for testing, and a globalSetup configuration fi…
IsaiahA21 Sep 24, 2024
b108a08
modify playwright.config.ts to take the value passed from the GitHub…
IsaiahA21 Oct 5, 2024
ef36b3f
Add Playwright test workflow for Vercel deployment
IsaiahA21 Oct 5, 2024
7cc49c1
Fix Playwright installation command in Vercel workflow
IsaiahA21 Oct 5, 2024
4c3081e
Add workers to playwright test commands and uploaded the test-reports
IsaiahA21 Oct 5, 2024
4185db2
Update Playwright test report upload action to use version 4 because …
IsaiahA21 Oct 5, 2024
80f97c0
Refactor Apply Now button in ProjectsPage.tsx and test.ts files
IsaiahA21 Oct 5, 2024
f87b285
Refactor Playwright test workflow for Vercel deployment
IsaiahA21 Oct 5, 2024
a9686d8
revert homepage test back
IsaiahA21 Oct 5, 2024
2365d91
Update content-updates.md
IsaiahA21 Nov 8, 2024
86b62de
Merge branch 'main' into isaiah/PlaywrightTests
IsaiahA21 Nov 14, 2024
74c13c4
run playwright test after merging main
IsaiahA21 Nov 14, 2024
2964383
Merge branch 'isaiah/PlaywrightTests' of https://github.com/techstart…
IsaiahA21 Nov 14, 2024
a66e69e
ran playwright test after merging main
IsaiahA21 Nov 14, 2024
c79e6c3
chore: Update team member LinkedIn profile link (#519)
IsaiahA21 Jul 5, 2024
53d4f71
setup PlayWright tests
IsaiahA21 Aug 24, 2024
daaf27c
Included more test cases
IsaiahA21 Aug 24, 2024
0792eef
refactor: Updated documentation to include how to run Playwright tests
IsaiahA21 Aug 24, 2024
8b47be1
additonal updates to documentation
IsaiahA21 Aug 24, 2024
ac93dc5
Added test coverage for navigation bar and project page
IsaiahA21 Sep 7, 2024
4637ef8
updated PlayWright config for a larger viewport size. And updated con…
IsaiahA21 Sep 13, 2024
91f6d13
Tests that had to find image elements were based on style-components …
IsaiahA21 Sep 14, 2024
94023dc
memorized the testdataId for the profile image.
IsaiahA21 Sep 14, 2024
ffb9eaa
Inside useMemo, forgot to include return
IsaiahA21 Sep 14, 2024
42e9de6
Add data-testid to ApplyButton component for unique identification
IsaiahA21 Sep 18, 2024
c6a11e7
Added an env variable for testing, and a globalSetup configuration fi…
IsaiahA21 Sep 24, 2024
f036c74
modify playwright.config.ts to take the value passed from the GitHub…
IsaiahA21 Oct 5, 2024
d7f9923
Add Playwright test workflow for Vercel deployment
IsaiahA21 Oct 5, 2024
bc02b5c
Fix Playwright installation command in Vercel workflow
IsaiahA21 Oct 5, 2024
5b2fc63
Add workers to playwright test commands and uploaded the test-reports
IsaiahA21 Oct 5, 2024
c1677cc
Update Playwright test report upload action to use version 4 because …
IsaiahA21 Oct 5, 2024
e83680a
Refactor Apply Now button in ProjectsPage.tsx and test.ts files
IsaiahA21 Oct 5, 2024
cd718bb
Refactor Playwright test workflow for Vercel deployment
IsaiahA21 Oct 5, 2024
ceea101
revert homepage test back
IsaiahA21 Oct 5, 2024
bcd249d
Updated sponsor package link (#538)
Sahitiakella Sep 16, 2024
b65319d
Open Project Member applicaions for 24-25 year (#539)
brian-ngyn Sep 17, 2024
e025121
handling empty PM list (#533)
mortezafa Sep 19, 2024
33882a6
Labib Co-VP Finance (#542)
brian-ngyn Sep 20, 2024
22c8dd4
updating link to executive application (#544)
Sukritib13 Sep 25, 2024
644268b
524 - initail changes, added Alumni tab, reusable components (#536)
Sukritib13 Oct 6, 2024
849be47
2024-2025 PMs (#546)
Sahitiakella Oct 22, 2024
6d0e3e8
updating team execs 2024-2025 (#547)
Sukritib13 Oct 29, 2024
ce687dc
run playwright test after merging main
IsaiahA21 Nov 14, 2024
3fe80ef
Update content-updates.md
IsaiahA21 Nov 8, 2024
f9ee135
ran playwright test after merging main
IsaiahA21 Nov 14, 2024
ac1ac0f
Merge branch 'isaiah/PlaywrightTests' of https://github.com/techstart…
IsaiahA21 Nov 14, 2024
4fca6f0
memorized the testdataId for the profile image.
IsaiahA21 Sep 14, 2024
c24f612
Inside useMemo, forgot to include return
IsaiahA21 Sep 14, 2024
81d3e1b
Add data-testid to ApplyButton component for unique identification
IsaiahA21 Sep 18, 2024
2e337e9
Added an env variable for testing, and a globalSetup configuration fi…
IsaiahA21 Sep 24, 2024
f39cb68
modify playwright.config.ts to take the value passed from the GitHub…
IsaiahA21 Oct 5, 2024
2ac3f48
Add Playwright test workflow for Vercel deployment
IsaiahA21 Oct 5, 2024
3bd3f9c
Fix Playwright installation command in Vercel workflow
IsaiahA21 Oct 5, 2024
24b6cce
Add workers to playwright test commands and uploaded the test-reports
IsaiahA21 Oct 5, 2024
c854e41
Update Playwright test report upload action to use version 4 because …
IsaiahA21 Oct 5, 2024
00a51cb
Refactor Apply Now button in ProjectsPage.tsx and test.ts files
IsaiahA21 Oct 5, 2024
dacb14a
Refactor Playwright test workflow for Vercel deployment
IsaiahA21 Oct 5, 2024
861c7ef
revert homepage test back
IsaiahA21 Oct 5, 2024
ff1dc75
Updated sponsor package link (#538)
Sahitiakella Sep 16, 2024
c2cb85e
Open Project Member applicaions for 24-25 year (#539)
brian-ngyn Sep 17, 2024
5488cc5
handling empty PM list (#533)
mortezafa Sep 19, 2024
ae3d322
Labib Co-VP Finance (#542)
brian-ngyn Sep 20, 2024
599e6cb
updating link to executive application (#544)
Sukritib13 Sep 25, 2024
36bac42
524 - initail changes, added Alumni tab, reusable components (#536)
Sukritib13 Oct 6, 2024
e5b7088
2024-2025 PMs (#546)
Sahitiakella Oct 22, 2024
3f8d729
updating team execs 2024-2025 (#547)
Sukritib13 Oct 29, 2024
677037f
run playwright test after merging main
IsaiahA21 Nov 14, 2024
77c0a78
Update content-updates.md
IsaiahA21 Nov 8, 2024
85a4ea3
ran playwright test after merging main
IsaiahA21 Nov 14, 2024
3391c6f
setup PlayWright tests
IsaiahA21 Aug 24, 2024
795e95e
refactor: Updated documentation to include how to run Playwright tests
IsaiahA21 Aug 24, 2024
90268e5
additonal updates to documentation
IsaiahA21 Aug 24, 2024
4e69742
Added test coverage for navigation bar and project page
IsaiahA21 Sep 7, 2024
98bfcde
updated PlayWright config for a larger viewport size. And updated con…
IsaiahA21 Sep 13, 2024
0cac7c0
Tests that had to find image elements were based on style-components …
IsaiahA21 Sep 14, 2024
4c7a030
Refactor Apply Now button in ProjectsPage.tsx and test.ts files
IsaiahA21 Oct 5, 2024
4dfabd8
Refactor Playwright test workflow for Vercel deployment
IsaiahA21 Oct 5, 2024
e176143
revert homepage test back
IsaiahA21 Oct 5, 2024
359e030
Open Project Member applicaions for 24-25 year (#539)
brian-ngyn Sep 17, 2024
22f56a0
handling empty PM list (#533)
mortezafa Sep 19, 2024
d394738
Labib Co-VP Finance (#542)
brian-ngyn Sep 20, 2024
453e507
updating link to executive application (#544)
Sukritib13 Sep 25, 2024
9c2637d
524 - initail changes, added Alumni tab, reusable components (#536)
Sukritib13 Oct 6, 2024
3e041f8
run playwright test after merging main
IsaiahA21 Nov 14, 2024
78f573a
ran playwright test after merging main
IsaiahA21 Nov 14, 2024
ae15d80
Merge branch 'isaiah/PlaywrightTests' of https://github.com/techstart…
IsaiahA21 Nov 14, 2024
af7e987
Nov7PlaywrightChanges
IsaiahA21 Nov 14, 2024
3c91ab2
Everything working as expected
IsaiahA21 Nov 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/playwright_tests_on_vercel.yml
IsaiahA21 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on:
deployment_status:
name: Playwright

jobs:
run-end2endTests:
# Only run if the deployment was successful
if: github.event_name == 'deployment_status' && github.event.deployment_status.state == 'success'
runs-on: ubuntu-latest
steps:
# Checkout the code from the repository
- uses: actions/checkout@v2

# Install project dependencies and Playwright (including browsers)
- name: Install dependencies
run: npm ci && npx playwright install --with-deps

# Run Playwright tests
- name: Run tests
run: npx playwright test --workers=4 --project=chromium
IsaiahA21 marked this conversation as resolved.
Show resolved Hide resolved
env:
BASE_URL: ${{github.event.deployment_status.environment_url}}

# Upload test result
- name: Upload Playwright test report
uses: actions/upload-artifact@v4
with:
name: playwright-reports
path: playwright-reports/
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ yarn-debug.log*
yarn-error.log*

# VSCode workspaces
*.code-workspace
*.code-workspace
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
112 changes: 94 additions & 18 deletions content-updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ This guide documents how and when to update different content on the Tech Start
- [Applications](#applications)
- [Resources Page](#resources-page)
- [Guides](#guides)
- [Playwright Tests](#playwright-tests)
- [Installing Playwright](#installing-playwright)
- [How to run tests](#how-to-run-the-tests)
- [To view test results](#to-view-the-test-results)

## Homepage

Expand All @@ -31,15 +35,11 @@ This guide documents how and when to update different content on the Tech Start
Statistics about our projects and members are set using the `NumberStat` component on the homepage:

```typescript
<div className="homePage__numberContainer">
<NumberStat number={10} stat="projects so far" />
<NumberStat number={92} stat="members so far" />
<NumberStat
number={93}
suffix={"%"}
stat="enjoyed their involvement"
/>
</div>
<div className="homePage__numberContainer">
<NumberStat number={10} stat="projects so far" />
<NumberStat number={92} stat="members so far" />
<NumberStat number={93} suffix={"%"} stat="enjoyed their involvement" />
</div>
```

The `number` values must be updated at the end of each school year.
Expand Down Expand Up @@ -72,18 +72,21 @@ You can update our social media outlets via the `SocialMedia` component used in
For example:

```typescript
<SocialMedia
color={SocialMediaColor.Gradient}
icon={faInstagram}
link="https://www.instagram.com/techstartucalgary/"
/>
<SocialMedia
color={SocialMediaColor.Gradient}
icon={faInstagram}
link="https://www.instagram.com/techstartucalgary/"
/>
```

### Gallery

Everything related to gallery can be found under [src/components/PhotoGallery](https://github.com/Tech-Start-UCalgary/tsu-website/tree/main/src/components/PhotoGallery)

To Add a new picture visit [TechStart Google Photos Album](https://photos.app.goo.gl/SkVei5N56poqTh8g8)
- Ask the administrator(s) for credential
- click add new

- Ask the administrator(s) for credential
- click add new

To make changes to the server, visit [tsuServer](https://github.com/techstartucalgary/tsuServer)

Expand Down Expand Up @@ -172,12 +175,11 @@ The team picture should be updated after each showcase, stored in [src/images](h

Application status is managed through the `ApplySection` component used in `ApplyPage.tsx`.

- When an application becomes open, set `statusIsOpen` to `true` and `applicationLink` to the new application URL.
- When an application becomes open, set `statusIsOpen` to `true` and `applicationLink` to the new application URL.
- When an application becomes closed, set `statusIsOpen` to `false`.

Example:


```typescript
<ApplySection
role="Project Member"
Expand Down Expand Up @@ -220,3 +222,77 @@ Example:
description="Learn Django, a python-based web framework for building backends, APIs, multi-page applications, and more!"
/>
```

## Playwright Tests

### Installing Playwright

Here are 2 helpful links to get you started with Playwright
[Playwright Getting Started ](https://playwright.dev/docs/intro) Or [Getting Started with Playwright and VS Code](https://www.youtube.com/watch?v=Xz6lhEzgI5I).
The second link is a video tutorial that will guide you through the process of setting up Playwright with VS Code, writing tests, and running them using the IDE.

### How to run the tests using the terminal

Ensure the tsu website is running locally on `localhost:3000`

This will run all the tests in the tests folder

```bash
npx playwright test
IsaiahA21 marked this conversation as resolved.
Show resolved Hide resolved
```

This will run the test cases in the HomePage.test.ts file on the chromium browser

```bash
npx playwright test tests/homePage/HomePage.test.ts --project=chromium
```

### To view the test results

Either navigate to the `playwright-report` folder and open the generated `report.html` file in the browser\
or run the following command to open the report.html file in the browser

```bash
npx playwright show-report
```

### Create tests using Playwright Recorder

You can either click "Record new" or use the terminal command `npx playwright codegen <url>` to generate test code for a specific URL and a specific viewport size.\
For example, to generate test code for the Tech Start UCalgary website with a viewport size of 1600x900, run the following command:

```bash
npx playwright codegen --viewport-size=1600,900 https://techstartucalgary.com
```

=======

### Installing Plawright

Here are 2 helpful links to get you started with Plawright
[Plawright Getting Started ](https://playwright.dev/docs/intro) Or [Getting Started with Playwright and VS Code](https://www.youtube.com/watch?v=Xz6lhEzgI5I)

### How to run the tests

This will run all the tests in the tests folder

```bash
npx playwright test
```

This will run the test cases in the HomePage.test.ts file on the chromium browser

```bash
npx playwright test tests/homePage/HomePage.test.ts --project=chromium
```

### To view the test results

Either navigate to the `playwright-report` folder and open the generated `report.html` file in the browser\
or run the following command to open the report.html file in the browser

```bash
npx playwright show-report
```

> > > > > > > b64dc11 (refactor: Updated documentation to include how to run Playwright tests)
13 changes: 13 additions & 0 deletions global-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { defineConfig } from '@playwright/test';
import dotenv from 'dotenv';
import path from 'path';

/**
* globalSetup configuration file to set something up once before running all tests
*/

async function globalSetupFunc() {
dotenv.config({ path: path.resolve(__dirname, '.env.local') });
console.log("Running tests on environment:", process.env.STAGING === '1' ? "Local" : "Production");
}
export default globalSetupFunc;
60 changes: 60 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
]
},
"devDependencies": {
"@playwright/test": "^1.46.1",
"@types/aos": "^3.0.4",
"@types/express": "^4.17.17",
"@types/jest": "^26.0.24",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions playwright-reports/index.html

Large diffs are not rendered by default.

81 changes: 81 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { defineConfig, devices } from '@playwright/test';
import dotenv from 'dotenv';
import path from 'path';


/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
globalSetup: require.resolve('./global-setup'),
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', { outputFolder: 'playwright-reports', open: 'never' }],
['list']],
/* 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: process.env.BASE_URL || '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'],
viewport: { width: 1600, height: 900 }, // Simulating 90% zoom by using larger resolution
},
},

{
name: 'firefox',
use: {
...devices['Desktop Firefox'],
viewport: { width: 1600, height: 900 }, // Simulating 90% zoom by using larger resolution
},
},

{
name: 'webkit',
use: {
...devices['Desktop Safari'],
viewport: { width: 1600, height: 900 }, // Simulating 90% zoom by using larger resolution
},
},

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },
IsaiahA21 marked this conversation as resolved.
Show resolved Hide resolved

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],


});
2 changes: 1 addition & 1 deletion src/components/ApplyButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const ApplyButton = () => {
<span>&#62;</span>
<span>&#62;</span>{" "}
</S.ApplyButtonArrow>
<S.ApplyButtonText> theTeam.join()</S.ApplyButtonText>
<S.ApplyButtonText data-testid="homePage_apply_btn"> theTeam.join()</S.ApplyButtonText>
</S.ApplyButton>
</S.ApplyButtonLink>
</motion.div>
Expand Down
Loading
Loading