Skip to content

Commit

Permalink
Merge pull request #28 from cis3296s24/testing
Browse files Browse the repository at this point in the history
added testing
  • Loading branch information
tun82434 authored Apr 16, 2024
2 parents 1840967 + 0188cd4 commit b2f794c
Show file tree
Hide file tree
Showing 6 changed files with 290 additions and 1 deletion.
27 changes: 27 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Playwright Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
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: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
/receiptifyv1/config.js
/receiptifyv1/config.js
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
91 changes: 91 additions & 0 deletions package-lock.json

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

14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "receiptify-split-the-bill",
"version": "1.0.0",
"description": "Receiptify: Split the Bill is inspired by the original Receiptify, a web application that generates receipts that lists out a user's top tracks in the past, month, 6 months, and all time. Our version of receiptify generates receipts based on a group of users in a session. Our application generates a combined music receipt that displays a compiled list of all users' top tracks in the past, month, 6 months, and all time.",
"main": "index.js",
"scripts": {},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@playwright/test": "^1.43.1",
"@types/node": "^20.12.7"
}
}
79 changes: 79 additions & 0 deletions playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// @ts-check
const { defineConfig, devices } = require('@playwright/test');

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

/**
* @see https://playwright.dev/docs/test-configuration
*/
module.exports = 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,
// },
});

73 changes: 73 additions & 0 deletions tests/app.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// @ts-check
const { test, expect } = require("@playwright/test");
//const { test, expect } = require("playwright-test-coverage");


test('homepage has title', async ({ page }) => {
await page.goto('http://localhost:3000/');

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

test('join has title', async ({ page }) => {
await page.goto('http://localhost:3000/join');

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

test('verify login link', async ({ page }) => {
await page.goto('http://localhost:3000/');

// Wait for the link element to appear on the page
const link = await page.waitForSelector('a[href="/login"]');

// Check if the link exists
expect(link).not.toBeNull();
});

test('verify join link', async ({ page }) => {
await page.goto('http://localhost:3000/');

// Wait for the link element to appear on the page
const link = await page.waitForSelector('a[href="/join"]');

// Check if the link exists
expect(link).not.toBeNull();
});

test('verify receipt shown with sessionID', async ({ page }) => {
await page.goto('http://localhost:3000/#client=spotify&access_token=BQAzDrIGbK7zymnqRlL4lvoUAikbeTo5XmSYs8ZWO3PlQaqHOEvVMwfHB8-Y0tAljDFjkkV-ZOdRJmUl7bFnP542pQsQVUPvFF8sSjhAc8T8ULSOyTc2q7NcUyzXL4Jo1Aoa3_J4dn_QNHRkrPM2sqV0xKIL55iTGV5EHl90Owic5f1aZWN8VmD6JBDDoZbgLhpel4bkJCpWlEQWORQTj_tfaizdyOk6LGcKB0V0Fa8om8e39bUzCeGS&refresh_token=AQCj4b-7yq4VNNQpZq5eGCjsyEIEnPxWufw-8cJ6rsf2bKn4oiUDbV_f2Hvy86B7nJWYSVN0IDJ0MWBp4SuxKKsqka89FS2cugj4c2yTz1QfYiQs0BTpCFFLhNaoeV6qy-4&sessionID=660497');

// Wait for an element containing the word to appear on the page
await page.waitForSelector('body'); // Wait for the body element to ensure the page is loaded
const textContent = await page.textContent('body');

// Check if the word is present in the page content
//const word = 'SESSIONID';
const word = 'SESSIONID';
// @ts-ignore
const isWordPresent = textContent.toLowerCase().includes(word.toLowerCase());

// Assert that the word is present
expect(isWordPresent).toBe(true);

});

test('verify receipt shown with display name', async ({ page }) => {
await page.goto('http://localhost:3000/#client=spotify&access_token=BQAzDrIGbK7zymnqRlL4lvoUAikbeTo5XmSYs8ZWO3PlQaqHOEvVMwfHB8-Y0tAljDFjkkV-ZOdRJmUl7bFnP542pQsQVUPvFF8sSjhAc8T8ULSOyTc2q7NcUyzXL4Jo1Aoa3_J4dn_QNHRkrPM2sqV0xKIL55iTGV5EHl90Owic5f1aZWN8VmD6JBDDoZbgLhpel4bkJCpWlEQWORQTj_tfaizdyOk6LGcKB0V0Fa8om8e39bUzCeGS&refresh_token=AQCj4b-7yq4VNNQpZq5eGCjsyEIEnPxWufw-8cJ6rsf2bKn4oiUDbV_f2Hvy86B7nJWYSVN0IDJ0MWBp4SuxKKsqka89FS2cugj4c2yTz1QfYiQs0BTpCFFLhNaoeV6qy-4&sessionID=660497');

// Wait for an element containing the word to appear on the page
await page.waitForSelector('body'); // Wait for the body element to ensure the page is loaded
const textContent = await page.textContent('body');

// Check if the word is present in the page content
const word = 'Nina Perone';
// @ts-ignore
const isWordPresent = textContent.toLowerCase().includes(word.toLowerCase());

// Assert that the word is present
expect(isWordPresent).toBe(true);

});

0 comments on commit b2f794c

Please sign in to comment.