Skip to content

Commit

Permalink
add navbar tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CassandraGoose committed Apr 30, 2024
1 parent e8af4b1 commit 8d5c6ce
Showing 1 changed file with 39 additions and 12 deletions.
51 changes: 39 additions & 12 deletions tests/navbar.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,42 @@
// import { test, expect } from '@playwright/test';
import { test, expect } from '@playwright/test';

// test.beforeEach(async ({ page }) => {
// // Go to the starting url before each test.
// await page.goto('http://localhost:3000/');
// });
test.beforeEach(async ({ page }) => {
page.context().clearCookies();
await page.goto('http://localhost:3000/login');
await page.getByTestId('username').click();
await page.getByTestId('username').fill('IAmCass');
await page.getByTestId('password').click();
await page.getByTestId('password').fill(process.env.TEST_USER_PW || '');
await page.getByTestId('login').click();
});

// test('exists', async ({ page }) => {
// await page.goto('http://localhost:3000/');
// await expect(page.getByTestId('navbar')).toBeVisible();
// await expect(page.getByTestId('navbar-dashboard-link')).toBeVisible();
// await expect(page.getByTestId('navbar-user-button')).toBeVisible();
// await expect(page.getByTestId('home-link')).toBeVisible();
// });
test('navigates to splash page', async ({ page}) => {
await page.getByTestId('home-link').click();
await expect(page.getByTestId('splash-title')).toContainText('TRACK');
await expect(page.getByTestId('splash-tag')).toContainText('Learn it. Prove it.');
await expect(page.locator('section')).toContainText('This application is currently under development and is not accepting new sign ups at this time. Try out Track as a sample user below:');
});

test('navigates to dashboard', async ({ page }) => {
await page.getByTestId('navbar-dashboard-link').click();
await expect(page.getByRole('heading')).toContainText('My Pathways');
});

test('navigates to available pathways', async ({ page }) => {
await page.getByTestId('navbar-pathways-link').click();
await expect(page.getByRole('heading')).toContainText('Available Pathways');
});

test('navigates to profile', async ({ page }) => {
await page.getByTestId('navbar-user-button').click();
await page.getByRole('link', { name: 'Profile' }).click();
await expect(page.getByTestId('username')).toContainText('IAmCass');
});

test('logs out', async ({ page }) => {
await page.getByTestId('navbar-user-button').click();
await page.getByRole('button', { name: 'Log out' }).click();
await expect(page.getByTestId('splash-title')).toContainText('TRACK');
await expect(page.getByTestId('navbar-dashboard-link')).toBeHidden();
await expect(page.getByTestId('navbar-user-button')).toBeHidden();
});

0 comments on commit 8d5c6ce

Please sign in to comment.