Skip to content

Commit

Permalink
Testing relative links
Browse files Browse the repository at this point in the history
  • Loading branch information
mendhak committed May 25, 2024
1 parent 5f4885a commit fe4fbc5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/draft-post.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test.beforeEach(async ({page, baseURL}) => {
test.describe('Draft Post Tests', () => {

test('Verify Draft Post is only visible locally', async ({ page }) => {
await page.click('text=This draft post should only appear locally');
await page.getByRole('link', {name: 'This draft post should only appear locally', exact: true} ).click();
expect(page).toHaveURL(siteURL + 'a-draft-post/');

// Ensure the draft post is not visible on the live site
Expand Down
39 changes: 39 additions & 0 deletions tests/post-with-relative-links.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { test, expect, Page } from '@playwright/test';

let siteURL;

test.beforeEach(async ({page, baseURL}) => {
await page.goto('/');
siteURL = baseURL;
});


test.describe('Posts with relative links', () => {

test('Test a link using a markdown path', async ({ page }) => {
await page.goto('posting-links/');
let link = await page.getByRole('link', { name: 'Link using Markdown path', exact: true });
await link.click();
expect(page.url()).toBe(siteURL + 'customary-lorem-ipsum/');

await page.goBack();

link = await page.getByRole('link', { name: 'Link using Markdown path and heading anchor', exact: true });
await link.click();
expect(page.url()).toBe(siteURL + 'customary-lorem-ipsum/#tincidunt-arcu-non-sodales');

await page.goBack();

link = await page.getByRole('link', { name: 'Link using root-relative URL', exact: true });
await link.click();
expect(page.url()).toBe(siteURL + 'customary-lorem-ipsum/');

await page.goBack();

link = await page.getByRole('button', { name: 'Button with a link', exact: true });
await link.click();
expect(page.url()).toBe(siteURL );


});
});

0 comments on commit fe4fbc5

Please sign in to comment.