Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
test: link click counter (#9556)
Browse files Browse the repository at this point in the history
* Update home.spec.js

* Update home.spec.js

* Update home.spec.js

* Update home.spec.js

* Update tests/home.spec.js

* Update tests/home.spec.js

* Update profile.spec.js

* Update profile.spec.js

* Update profile.spec.js

---------

Co-authored-by: Eddie Jaoude <eddie@jaoudestudios.com>
  • Loading branch information
kbventures and eddiejaoude authored Oct 25, 2023
1 parent 2587d59 commit 2ab9592
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions tests/profile.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { test, expect } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";

import connectMongo from "@config/mongo";
import { Profile } from "@models/index";
import { Profile, Link } from "@models/index";

test("Profile has title", async ({ page }) => {
const username = "_test-profile-user-1";
Expand Down Expand Up @@ -69,8 +69,24 @@ test("Profile views increase", async ({ page }) => {
expect(startingViews.views).toEqual(endingViews.views - 3);
});

test.fixme("Link clicks increase", async () => {
// will need DB integration
test("Link clicks increase", async ({page}) => {

await connectMongo();
await page.goto("/eddiejaoude");

const startingLinks = await Link.find({ username: "eddiejaoude" })
const startingLink = startingLinks[0]

const previousClickCount = startingLink.clicks;

const profileLink = page.locator('a').filter({ hasText: startingLink.name })

await profileLink.click();
await page.waitForTimeout(1000);
const currentLink = await Link.findOne({ name: startingLink.name, username: "eddiejaoude" })
const updateCurrentLinkClicks = currentLink.clicks

expect(updateCurrentLinkClicks).toEqual((previousClickCount + 1));
});

test("Profile not found redirects to search page with error message", async ({
Expand Down

0 comments on commit 2ab9592

Please sign in to comment.