|
| 1 | +const puppeteer = require('puppeteer'); |
| 2 | + |
| 3 | +const baseUrl = 'http://localhost:8000'; |
| 4 | +describe('Tests the navbar and its components on various pages', () => { |
| 5 | + let browser; |
| 6 | + let page; |
| 7 | + jest.setTimeout(60000); |
| 8 | + |
| 9 | + const testNavbar = async (navbarPage) => { |
| 10 | + const navbar = await navbarPage.$('#tasksNav'); |
| 11 | + expect(navbar).toBeTruthy(); |
| 12 | + |
| 13 | + const rdsLogo = await navbarPage.$('.logo'); |
| 14 | + expect(rdsLogo).toBeTruthy(); |
| 15 | + |
| 16 | + const navLinks = await navbarPage.$('.nav-links'); |
| 17 | + expect(navLinks).toBeTruthy(); |
| 18 | + }; |
| 19 | + |
| 20 | + beforeAll(async () => { |
| 21 | + browser = await puppeteer.launch({ |
| 22 | + headless: 'new', |
| 23 | + ignoreHTTPSErrors: true, |
| 24 | + args: ['--incognito', '--disable-web-security'], |
| 25 | + devtools: false, |
| 26 | + }); |
| 27 | + }); |
| 28 | + |
| 29 | + beforeEach(async () => { |
| 30 | + page = await browser.newPage(); |
| 31 | + }); |
| 32 | + |
| 33 | + afterEach(async () => { |
| 34 | + await page.close(); |
| 35 | + }); |
| 36 | + |
| 37 | + afterAll(async () => { |
| 38 | + await browser.close(); |
| 39 | + }); |
| 40 | + |
| 41 | + it('Renders the navbar correctly on the home page', async () => { |
| 42 | + await page.goto(`${baseUrl}`); |
| 43 | + await testNavbar(page); |
| 44 | + }); |
| 45 | + |
| 46 | + it('Renders the navbar correctly on the tasks page', async () => { |
| 47 | + await page.goto(`${baseUrl}/task`); |
| 48 | + await testNavbar(page); |
| 49 | + }); |
| 50 | + |
| 51 | + it('Renders the navbar correctly on the profile page', async () => { |
| 52 | + await page.goto(`${baseUrl}/profile`); |
| 53 | + await testNavbar(page); |
| 54 | + }); |
| 55 | + |
| 56 | + it('Renders the navbar correctly on the Discord users page', async () => { |
| 57 | + await page.goto(`${baseUrl}/users/discord`); |
| 58 | + await testNavbar(page); |
| 59 | + }); |
| 60 | + |
| 61 | + it('Renders the navbar correctly on the User Management page', async () => { |
| 62 | + await page.goto(`${baseUrl}/users`); |
| 63 | + await testNavbar(page); |
| 64 | + }); |
| 65 | + |
| 66 | + it('Renders the navbar correctly on the Extension Requests page', async () => { |
| 67 | + await page.goto(`${baseUrl}/extension-requests`); |
| 68 | + await testNavbar(page); |
| 69 | + }); |
| 70 | + |
| 71 | + it('Renders the navbar correctly on the Task Requests page', async () => { |
| 72 | + await page.goto(`${baseUrl}/task-requests`); |
| 73 | + await testNavbar(page); |
| 74 | + }); |
| 75 | + |
| 76 | + it('Renders the navbar correctly on the Online Members page', async () => { |
| 77 | + await page.goto(`${baseUrl}/online-members/online-members.html`); |
| 78 | + await testNavbar(page); |
| 79 | + }); |
| 80 | + |
| 81 | + it('Renders the navbar correctly on the Standup Updates page', async () => { |
| 82 | + await page.goto(`${baseUrl}/standup/index.html`); |
| 83 | + await testNavbar(page); |
| 84 | + }); |
| 85 | + |
| 86 | + it('Renders the navbar correctly on the Identity Service Logs page', async () => { |
| 87 | + await page.goto(`${baseUrl}/identity-service-logs/index.html`); |
| 88 | + await testNavbar(page); |
| 89 | + }); |
| 90 | + |
| 91 | + it('Renders the navbar correctly on the Requests page', async () => { |
| 92 | + await page.goto(`${baseUrl}/requests/index.html`); |
| 93 | + await testNavbar(page); |
| 94 | + }); |
| 95 | + |
| 96 | + it('Renders the navbar correctly on the Activity Feed page', async () => { |
| 97 | + await page.goto(`${baseUrl}/feed/index.html`); |
| 98 | + await testNavbar(page); |
| 99 | + }); |
| 100 | +}); |
0 commit comments