From eb30ce29c6e8a92f6c62da21d7d4b7c21da2e33e Mon Sep 17 00:00:00 2001 From: Ririio Date: Thu, 16 Mar 2023 21:28:13 -0400 Subject: [PATCH 1/4] Initial Commit for issue-testing --- .../certificate/certificate-display.tsx | 4 +- app/components/header.tsx | 1 + playwright.config.ts | 13 +++-- test/e2e/auth.setup.ts | 2 +- test/e2e/certificate.spec.ts | 37 +++++++++++++ test/e2e/header/header.desktop.spec.ts | 18 +++++++ test/e2e/header/header.mobile.spec.ts | 20 +++++++ test/e2e/header/header.spec.ts | 16 ++++++ test/e2e/landing-page.spec.ts | 50 +++++++++++++++++ test/e2e/login.spec.ts | 54 ++++++++++--------- test/e2e/new-dns-record.spec.ts | 9 ++-- 11 files changed, 189 insertions(+), 35 deletions(-) create mode 100644 test/e2e/certificate.spec.ts create mode 100644 test/e2e/header/header.desktop.spec.ts create mode 100644 test/e2e/header/header.mobile.spec.ts create mode 100644 test/e2e/header/header.spec.ts create mode 100644 test/e2e/landing-page.spec.ts diff --git a/app/components/certificate/certificate-display.tsx b/app/components/certificate/certificate-display.tsx index d885aaae..9b1ff4af 100644 --- a/app/components/certificate/certificate-display.tsx +++ b/app/components/certificate/certificate-display.tsx @@ -53,7 +53,7 @@ export default function CertificateDisplay({ title, description, value }: Certif background: 'whitesmoke', color: 'teal.500', }} - aria-label="Copy to Clipboard" + aria-label={`Copy ${title}`} icon={} onClick={() => onCopy()} /> @@ -67,7 +67,7 @@ export default function CertificateDisplay({ title, description, value }: Certif background: 'brand.500', color: 'white', }} - aria-label="Download" + aria-label={`Download ${title}`} icon={ } size="auto" diff --git a/playwright.config.ts b/playwright.config.ts index 3aa411ed..99d98a42 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -34,12 +34,12 @@ const config: PlaywrightTestConfig = { /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */ actionTimeout: 0, /* Base URL to use in actions like `await page.goto('/')`. */ - baseURL: `http://localhost:${process.env.PORT}`, + baseURL: `http://localhost:${process.env.PORT || 8080}`, /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ - trace: 'on-first-retry', + trace: 'retain-on-failure', /* Record video on first retry */ - video: 'on-first-retry', + video: 'retain-on-failure', }, /* Configure projects for major browsers */ @@ -58,6 +58,7 @@ const config: PlaywrightTestConfig = { ...devices['Desktop Chrome'], }, dependencies: ['setup'], + testIgnore: /.*\.mobile\.spec\.ts/, }, { @@ -66,6 +67,7 @@ const config: PlaywrightTestConfig = { ...devices['Desktop Firefox'], }, dependencies: ['setup'], + testIgnore: /.*\.mobile\.spec\.ts/, }, { @@ -74,6 +76,7 @@ const config: PlaywrightTestConfig = { ...devices['Desktop Safari'], }, dependencies: ['setup'], + testIgnore: /.*\.mobile\.spec\.ts/, }, /* Test against mobile viewports. */ @@ -83,6 +86,7 @@ const config: PlaywrightTestConfig = { ...devices['Pixel 5'], }, dependencies: ['setup'], + testIgnore: /.*\.desktop\.spec\.ts/, }, /** * We override the isMobile for Mobile Safari to false to make it work in CI @@ -100,6 +104,7 @@ const config: PlaywrightTestConfig = { defaultBrowserType: devices['iPhone 12'].defaultBrowserType, }, dependencies: ['setup'], + testIgnore: /.*\.desktop\.spec\.ts/, }, /* Test against branded browsers. */ @@ -109,6 +114,7 @@ const config: PlaywrightTestConfig = { channel: 'msedge', }, dependencies: ['setup'], + testIgnore: /.*\.mobile\.spec\.ts/, }, { name: 'Google Chrome', @@ -116,6 +122,7 @@ const config: PlaywrightTestConfig = { channel: 'chrome', }, dependencies: ['setup'], + testIgnore: /.*\.mobile\.spec\.ts/, }, ], diff --git a/test/e2e/auth.setup.ts b/test/e2e/auth.setup.ts index 3e42f1cd..52e690a1 100644 --- a/test/e2e/auth.setup.ts +++ b/test/e2e/auth.setup.ts @@ -8,7 +8,7 @@ setup('authenticate as user', async ({ page }) => { await page.getByLabel('Username').fill('user1'); await page.getByLabel('Password').fill('user1pass'); await page.getByRole('button', { name: 'Login' }).click(); - await page.waitForURL('http://localhost:8080'); + await page.waitForURL('/'); await page.context().storageState({ path: userFile }); }); diff --git a/test/e2e/certificate.spec.ts b/test/e2e/certificate.spec.ts new file mode 100644 index 00000000..f52b68b0 --- /dev/null +++ b/test/e2e/certificate.spec.ts @@ -0,0 +1,37 @@ +import { test, expect } from '@playwright/test'; +import { loggedInAsUser } from './utils'; + +test.describe('Certificate Page', () => { + loggedInAsUser(); + + test.beforeEach(async ({ page }) => { + await page.goto('/certificate'); + }); + + test('Request a Certificate', async ({ page }) => { + const titleHeader = page.getByRole('heading', { name: 'Certificate' }); + const domainName = page.getByText('user1.starchart.com'); + + await expect(domainName).toContainText('user1.starchart.com'); + await expect(titleHeader).toContainText('Certificate'); + await page.getByRole('button', { name: 'Request a Certificate' }).click(); + page + .locator('div') + .filter({ + hasText: 'We have received your request, and will notify you when your certificate is read', + }) + .nth(1); + + await page.getByRole('button', { name: 'Copy Public Key' }).click(); + await page.getByRole('button', { name: 'Copy Private Key' }).click(); + + await page.getByRole('button', { name: 'Download Public Key' }).click(); + await page.getByRole('button', { name: 'Download Private Key' }).click(); + + const publicKey = page.getByRole('heading', { name: 'Public Key' }); + const privateKey = page.getByRole('heading', { name: 'Private Key' }); + + await expect(publicKey).toContainText('Public Key'); + await expect(privateKey).toContainText('Private Key'); + }); +}); diff --git a/test/e2e/header/header.desktop.spec.ts b/test/e2e/header/header.desktop.spec.ts new file mode 100644 index 00000000..675f47da --- /dev/null +++ b/test/e2e/header/header.desktop.spec.ts @@ -0,0 +1,18 @@ +import { test, expect } from '@playwright/test'; +import { loggedInAsUser } from '../utils'; + +test.describe('navigate to links', () => { + loggedInAsUser(); + + test.beforeEach(async ({ page }) => { + await page.goto('/'); + }); + + test('navigate to certificate and domain (desktop)', async ({ page }) => { + await page.getByRole('link', { name: 'Certificate', exact: true }).click(); + await expect(page).toHaveURL('/certificate'); + + await page.getByRole('link', { name: 'Domains', exact: true }).click(); + await expect(page).toHaveURL('/domains'); + }); +}); diff --git a/test/e2e/header/header.mobile.spec.ts b/test/e2e/header/header.mobile.spec.ts new file mode 100644 index 00000000..e6e22003 --- /dev/null +++ b/test/e2e/header/header.mobile.spec.ts @@ -0,0 +1,20 @@ +import { test, expect } from '@playwright/test'; +import { loggedInAsUser } from '../utils'; + +test.describe('navigate to links through mobile', () => { + loggedInAsUser(); + + test.beforeEach(async ({ page }) => { + await page.goto('/'); + }); + + test('navigate to certificate and domain (mobile)', async ({ page }) => { + await page.click('.header-hamburger'); + await page.getByRole('link', { name: 'Certificate', exact: true }).click(); + await expect(page).toHaveURL('/certificate'); + + await page.click('.header-hamburger'); + await page.getByRole('link', { name: 'Domains', exact: true }).click(); + await expect(page).toHaveURL('/domains'); + }); +}); diff --git a/test/e2e/header/header.spec.ts b/test/e2e/header/header.spec.ts new file mode 100644 index 00000000..90986f57 --- /dev/null +++ b/test/e2e/header/header.spec.ts @@ -0,0 +1,16 @@ +import { test, expect } from '@playwright/test'; +import { loggedInAsUser } from '../utils'; + +test.describe('sign out of the account', () => { + loggedInAsUser(); + + test.beforeEach(async ({ page }) => { + await page.goto('/'); + }); + + test('sign out', async ({ page }) => { + await page.getByRole('banner').getByRole('button').click(); + await page.getByRole('menuitem', { name: 'Sign Out' }).click(); + await expect(page).toHaveURL('/login?redirectTo=%2F'); + }); +}); diff --git a/test/e2e/landing-page.spec.ts b/test/e2e/landing-page.spec.ts new file mode 100644 index 00000000..bb52b54c --- /dev/null +++ b/test/e2e/landing-page.spec.ts @@ -0,0 +1,50 @@ +import { test, expect } from '@playwright/test'; +import { loggedInAsUser } from './utils'; + +test.describe('landing page link', () => { + loggedInAsUser(); + + test.beforeEach(async ({ page }) => { + await page.goto('/'); + + const dnsCard = page.getByRole('heading', { name: 'DNS Records' }); + const certCard = page.getByRole('heading', { name: 'Certificate' }); + + await expect(dnsCard).toContainText('DNS Records'); + await expect(certCard).toContainText('Certificate'); + }); + + test('Manage DNS Records Link Button', async ({ page }) => { + await page.getByRole('link', { name: 'Manage DNS Records' }).click(); + await expect(page).toHaveURL('/domains'); + }); + + test('Manage DNS Records Instruction Link', async ({ page }) => { + await page + .getByRole('paragraph') + .filter({ + hasText: 'DNS Record: Lorem Ipsum is simply dummy text of the printing and typesetting ind', + }) + .getByRole('link', { name: 'to learn more, see these instructions...' }) + .click(); + + await expect(page).toHaveURL('/domains/instructions'); + }); + + test('Manage Certificate Link Button', async ({ page }) => { + await page.getByRole('link', { name: 'Manage Certificate' }).click(); + await expect(page).toHaveURL('/certificate'); + }); + + test('Manage Certificate Instruction Link', async ({ page }) => { + await page + .getByRole('paragraph') + .filter({ + hasText: + 'Certificate: Lorem Ipsum is simply dummy text of the printing and typesetting ind', + }) + .getByRole('link', { name: 'to learn more, see these instructions...' }) + .click(); + await expect(page).toHaveURL('/certificate/instructions'); + }); +}); diff --git a/test/e2e/login.spec.ts b/test/e2e/login.spec.ts index f6881c88..1c032f11 100644 --- a/test/e2e/login.spec.ts +++ b/test/e2e/login.spec.ts @@ -1,29 +1,33 @@ import { test, expect } from '@playwright/test'; -test('Login with User 1', async ({ page }) => { - await page.goto('/login?redirectTo=%2F'); - await page.getByRole('button', { name: 'Sign In' }).click(); - await page.getByLabel('Username').fill('user1'); - await page.getByLabel('Password').fill('user1pass'); - await page.getByRole('button', { name: 'Login' }).click(); - await page.waitForURL('http://localhost:8080'); - const locator = page.locator('#header-user'); - const starchartHeading = page.getByRole('heading', { name: 'My.Custom.Domain' }); - await expect(locator).toContainText('user1'); - await expect(starchartHeading).toContainText('My.Custom.Domain'); -}); +test.describe('Login with user', () => { + test('Login with User 1', async ({ page }) => { + await page.goto('/login?redirectTo=%2F'); + await page.getByRole('button', { name: 'Sign In' }).click(); + await page.getByLabel('Username').fill('user1'); + await page.getByLabel('Password').fill('user1pass'); + await page.getByRole('button', { name: 'Login' }).click(); + await page.waitForURL('http://localhost:8080'); + + const locator = page.locator('#header-user'); + const starchartHeading = page.getByRole('heading', { name: 'My.Custom.Domain' }); + + await expect(locator).toContainText('user1'); + await expect(starchartHeading).toContainText('My.Custom.Domain'); + }); -test('Login with User 1 dev redirect', async ({ page }) => { - await page.goto('/login?redirectTo=%2Fdomains'); - await page.getByRole('button', { name: 'Sign In' }).click(); - await page.getByLabel('Username').fill('user1'); - await page.getByLabel('Password').fill('user1pass'); - await page.getByRole('button', { name: 'Login' }).click(); - await page.waitForURL('http://localhost:8080/domains'); - const locator1 = page.locator('#header-user'); - const userInNav = page.getByRole('heading', { name: 'My.Custom.Domain' }); - const domainHeading = page.getByRole('heading', { name: 'Domains' }); - await expect(locator1).toContainText('user1'); - await expect(userInNav).toContainText('My.Custom.Domain'); - await expect(domainHeading).toContainText('Domains'); + test('Login with User 1 dev redirect', async ({ page }) => { + await page.goto('/login?redirectTo=%2Fdomains'); + await page.getByRole('button', { name: 'Sign In' }).click(); + await page.getByLabel('Username').fill('user1'); + await page.getByLabel('Password').fill('user1pass'); + await page.getByRole('button', { name: 'Login' }).click(); + await page.waitForURL('/domains'); + const locator1 = page.locator('#header-user'); + const userInNav = page.getByRole('heading', { name: 'My.Custom.Domain' }); + const domainHeading = page.getByRole('heading', { name: 'Domains' }); + await expect(locator1).toContainText('user1'); + await expect(userInNav).toContainText('My.Custom.Domain'); + await expect(domainHeading).toContainText('Domains'); + }); }); diff --git a/test/e2e/new-dns-record.spec.ts b/test/e2e/new-dns-record.spec.ts index 06e22858..b3b277f4 100644 --- a/test/e2e/new-dns-record.spec.ts +++ b/test/e2e/new-dns-record.spec.ts @@ -12,8 +12,11 @@ test.describe('not authenticated', () => { test.describe('authenticated as user', () => { loggedInAsUser(); - test('redirects to edit dns record page when required fields are filled', async ({ page }) => { + test.beforeEach(async ({ page }) => { await page.goto('/domains/new'); + }); + + test('redirects to edit dns record page when required fields are filled', async ({ page }) => { await page.getByLabel('Record Name*').fill('test'); await page.getByRole('combobox', { name: 'Type' }).selectOption('A'); await page.getByLabel('Value*').fill('test'); @@ -22,7 +25,6 @@ test.describe('authenticated as user', () => { }); test('redirects to edit dns record page when all fields are filled', async ({ page }) => { - await page.goto('/domains/new'); await page.getByLabel('Record Name*').fill('test'); await page.getByRole('combobox', { name: 'Type' }).selectOption('A'); await page.getByLabel('Value*').fill('test'); @@ -34,8 +36,7 @@ test.describe('authenticated as user', () => { }); test('does not create dns record if required fields are empty', async ({ page }) => { - await page.goto('/domains/new'); await page.getByRole('button', { name: 'Create' }).click(); - await expect(page).toHaveURL(/.*domains\/new/); + await expect(page).toHaveURL('/domains/new'); }); }); From 085c9282ef30491b21e0bb9fc6b5b6c81a455161 Mon Sep 17 00:00:00 2001 From: Ririio Date: Fri, 17 Mar 2023 10:35:52 -0400 Subject: [PATCH 2/4] resolving issues with changes --- playwright.config.ts | 6 ++--- test/e2e/certificate.spec.ts | 1 + test/e2e/login.spec.ts | 52 +++++++++++++++++------------------- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/playwright.config.ts b/playwright.config.ts index 99d98a42..ae9b25ce 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -34,12 +34,12 @@ const config: PlaywrightTestConfig = { /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */ actionTimeout: 0, /* Base URL to use in actions like `await page.goto('/')`. */ - baseURL: `http://localhost:${process.env.PORT || 8080}`, + baseURL: 'http://localhost:8080', /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ - trace: 'retain-on-failure', + trace: 'on-first-retry', /* Record video on first retry */ - video: 'retain-on-failure', + video: 'on-first-retry', }, /* Configure projects for major browsers */ diff --git a/test/e2e/certificate.spec.ts b/test/e2e/certificate.spec.ts index f52b68b0..08b7e39b 100644 --- a/test/e2e/certificate.spec.ts +++ b/test/e2e/certificate.spec.ts @@ -15,6 +15,7 @@ test.describe('Certificate Page', () => { await expect(domainName).toContainText('user1.starchart.com'); await expect(titleHeader).toContainText('Certificate'); await page.getByRole('button', { name: 'Request a Certificate' }).click(); + page .locator('div') .filter({ diff --git a/test/e2e/login.spec.ts b/test/e2e/login.spec.ts index 1c032f11..918ce03b 100644 --- a/test/e2e/login.spec.ts +++ b/test/e2e/login.spec.ts @@ -1,33 +1,31 @@ import { test, expect } from '@playwright/test'; -test.describe('Login with user', () => { - test('Login with User 1', async ({ page }) => { - await page.goto('/login?redirectTo=%2F'); - await page.getByRole('button', { name: 'Sign In' }).click(); - await page.getByLabel('Username').fill('user1'); - await page.getByLabel('Password').fill('user1pass'); - await page.getByRole('button', { name: 'Login' }).click(); - await page.waitForURL('http://localhost:8080'); +test('Login with User 1', async ({ page }) => { + await page.goto('/login?redirectTo=%2F'); + await page.getByRole('button', { name: 'Sign In' }).click(); + await page.getByLabel('Username').fill('user1'); + await page.getByLabel('Password').fill('user1pass'); + await page.getByRole('button', { name: 'Login' }).click(); + await page.waitForURL('/'); - const locator = page.locator('#header-user'); - const starchartHeading = page.getByRole('heading', { name: 'My.Custom.Domain' }); + const locator = page.locator('#header-user'); + const starchartHeading = page.getByRole('heading', { name: 'My.Custom.Domain' }); - await expect(locator).toContainText('user1'); - await expect(starchartHeading).toContainText('My.Custom.Domain'); - }); + await expect(locator).toContainText('user1'); + await expect(starchartHeading).toContainText('My.Custom.Domain'); +}); - test('Login with User 1 dev redirect', async ({ page }) => { - await page.goto('/login?redirectTo=%2Fdomains'); - await page.getByRole('button', { name: 'Sign In' }).click(); - await page.getByLabel('Username').fill('user1'); - await page.getByLabel('Password').fill('user1pass'); - await page.getByRole('button', { name: 'Login' }).click(); - await page.waitForURL('/domains'); - const locator1 = page.locator('#header-user'); - const userInNav = page.getByRole('heading', { name: 'My.Custom.Domain' }); - const domainHeading = page.getByRole('heading', { name: 'Domains' }); - await expect(locator1).toContainText('user1'); - await expect(userInNav).toContainText('My.Custom.Domain'); - await expect(domainHeading).toContainText('Domains'); - }); +test('Login with User 1 dev redirect', async ({ page }) => { + await page.goto('/login?redirectTo=%2Fdomains'); + await page.getByRole('button', { name: 'Sign In' }).click(); + await page.getByLabel('Username').fill('user1'); + await page.getByLabel('Password').fill('user1pass'); + await page.getByRole('button', { name: 'Login' }).click(); + await page.waitForURL('/domains'); + const locator1 = page.locator('#header-user'); + const userInNav = page.getByRole('heading', { name: 'My.Custom.Domain' }); + const domainHeading = page.getByRole('heading', { name: 'Domains' }); + await expect(locator1).toContainText('user1'); + await expect(userInNav).toContainText('My.Custom.Domain'); + await expect(domainHeading).toContainText('Domains'); }); From 9844626779dfdfdb84ae970b5393d2e9c58bba04 Mon Sep 17 00:00:00 2001 From: Ririio Date: Fri, 17 Mar 2023 15:37:26 -0400 Subject: [PATCH 3/4] minor adjustments with naming --- .../certificate/certificate-display.tsx | 2 +- test/e2e/certificate.spec.ts | 22 ++++++++++++++++++- test/e2e/landing-page.spec.ts | 13 ++++++----- test/e2e/login.spec.ts | 2 ++ 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/app/components/certificate/certificate-display.tsx b/app/components/certificate/certificate-display.tsx index 9b1ff4af..0cb23001 100644 --- a/app/components/certificate/certificate-display.tsx +++ b/app/components/certificate/certificate-display.tsx @@ -58,7 +58,7 @@ export default function CertificateDisplay({ title, description, value }: Certif onClick={() => onCopy()} /> - + { await expect(domainName).toContainText('user1.starchart.com'); await expect(titleHeader).toContainText('Certificate'); + await page.getByRole('button', { name: 'Request a Certificate' }).click(); - page + const loadingPageText = page .locator('div') .filter({ hasText: 'We have received your request, and will notify you when your certificate is read', }) .nth(1); + await expect(loadingPageText).toContainText( + 'We have received your request, and will notify you when your certificate is read' + ); + + //Copy Key Toast Text await page.getByRole('button', { name: 'Copy Public Key' }).click(); await page.getByRole('button', { name: 'Copy Private Key' }).click(); + const publicCopyToastText = page.getByText('Public Key was copied to the clipboard'); + const privateCopyToastText = page.getByText('Private Key was copied to the clipboard'); + + await expect(publicCopyToastText).toContainText('Public Key was copied to the clipboard'); + await expect(privateCopyToastText).toContainText('Private Key was copied to the clipboard'); + + //Download Key Toast Text await page.getByRole('button', { name: 'Download Public Key' }).click(); await page.getByRole('button', { name: 'Download Private Key' }).click(); + const publicDownloadToastText = page.getByText('Public Key is Downloaded'); + const privateDownloadToastText = page.getByText('Private Key is Downloaded'); + + await expect(publicDownloadToastText).toContainText('Public Key is Downloaded'); + await expect(privateDownloadToastText).toContainText('Private Key is Downloaded'); + + //Text Titles const publicKey = page.getByRole('heading', { name: 'Public Key' }); const privateKey = page.getByRole('heading', { name: 'Private Key' }); diff --git a/test/e2e/landing-page.spec.ts b/test/e2e/landing-page.spec.ts index bb52b54c..8cbf3b34 100644 --- a/test/e2e/landing-page.spec.ts +++ b/test/e2e/landing-page.spec.ts @@ -1,7 +1,7 @@ import { test, expect } from '@playwright/test'; import { loggedInAsUser } from './utils'; -test.describe('landing page link', () => { +test.describe('Landing Page', () => { loggedInAsUser(); test.beforeEach(async ({ page }) => { @@ -14,12 +14,13 @@ test.describe('landing page link', () => { await expect(certCard).toContainText('Certificate'); }); - test('Manage DNS Records Link Button', async ({ page }) => { + test('Manage DNS Records Button', async ({ page }) => { await page.getByRole('link', { name: 'Manage DNS Records' }).click(); + await expect(page).toHaveURL('/domains'); }); - test('Manage DNS Records Instruction Link', async ({ page }) => { + test('DNS Records Instructions Link', async ({ page }) => { await page .getByRole('paragraph') .filter({ @@ -31,12 +32,13 @@ test.describe('landing page link', () => { await expect(page).toHaveURL('/domains/instructions'); }); - test('Manage Certificate Link Button', async ({ page }) => { + test('Manage Certificate Button', async ({ page }) => { await page.getByRole('link', { name: 'Manage Certificate' }).click(); + await expect(page).toHaveURL('/certificate'); }); - test('Manage Certificate Instruction Link', async ({ page }) => { + test('Certificate Instructions Link', async ({ page }) => { await page .getByRole('paragraph') .filter({ @@ -45,6 +47,7 @@ test.describe('landing page link', () => { }) .getByRole('link', { name: 'to learn more, see these instructions...' }) .click(); + await expect(page).toHaveURL('/certificate/instructions'); }); }); diff --git a/test/e2e/login.spec.ts b/test/e2e/login.spec.ts index 918ce03b..6a29c654 100644 --- a/test/e2e/login.spec.ts +++ b/test/e2e/login.spec.ts @@ -22,9 +22,11 @@ test('Login with User 1 dev redirect', async ({ page }) => { await page.getByLabel('Password').fill('user1pass'); await page.getByRole('button', { name: 'Login' }).click(); await page.waitForURL('/domains'); + const locator1 = page.locator('#header-user'); const userInNav = page.getByRole('heading', { name: 'My.Custom.Domain' }); const domainHeading = page.getByRole('heading', { name: 'Domains' }); + await expect(locator1).toContainText('user1'); await expect(userInNav).toContainText('My.Custom.Domain'); await expect(domainHeading).toContainText('Domains'); From 64e77389f9f2a31812bad3039a7408363c44fed8 Mon Sep 17 00:00:00 2001 From: Ririio Date: Fri, 17 Mar 2023 21:05:24 -0400 Subject: [PATCH 4/4] Replacing redundant test with waitFor() --- test/e2e/certificate.spec.ts | 12 +++++------- test/e2e/landing-page.spec.ts | 2 ++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/e2e/certificate.spec.ts b/test/e2e/certificate.spec.ts index 64574c1d..7d65c1d8 100644 --- a/test/e2e/certificate.spec.ts +++ b/test/e2e/certificate.spec.ts @@ -24,9 +24,7 @@ test.describe('Certificate Page', () => { }) .nth(1); - await expect(loadingPageText).toContainText( - 'We have received your request, and will notify you when your certificate is read' - ); + await loadingPageText.waitFor(); //Copy Key Toast Text await page.getByRole('button', { name: 'Copy Public Key' }).click(); @@ -35,8 +33,8 @@ test.describe('Certificate Page', () => { const publicCopyToastText = page.getByText('Public Key was copied to the clipboard'); const privateCopyToastText = page.getByText('Private Key was copied to the clipboard'); - await expect(publicCopyToastText).toContainText('Public Key was copied to the clipboard'); - await expect(privateCopyToastText).toContainText('Private Key was copied to the clipboard'); + await publicCopyToastText.waitFor(); + await privateCopyToastText.waitFor(); //Download Key Toast Text await page.getByRole('button', { name: 'Download Public Key' }).click(); @@ -45,8 +43,8 @@ test.describe('Certificate Page', () => { const publicDownloadToastText = page.getByText('Public Key is Downloaded'); const privateDownloadToastText = page.getByText('Private Key is Downloaded'); - await expect(publicDownloadToastText).toContainText('Public Key is Downloaded'); - await expect(privateDownloadToastText).toContainText('Private Key is Downloaded'); + await publicDownloadToastText.waitFor(); + await privateDownloadToastText.waitFor(); //Text Titles const publicKey = page.getByRole('heading', { name: 'Public Key' }); diff --git a/test/e2e/landing-page.spec.ts b/test/e2e/landing-page.spec.ts index 8cbf3b34..adb413b0 100644 --- a/test/e2e/landing-page.spec.ts +++ b/test/e2e/landing-page.spec.ts @@ -6,7 +6,9 @@ test.describe('Landing Page', () => { test.beforeEach(async ({ page }) => { await page.goto('/'); + }); + test('Contains DNS Record and Certificate cards', async ({ page }) => { const dnsCard = page.getByRole('heading', { name: 'DNS Records' }); const certCard = page.getByRole('heading', { name: 'Certificate' });