Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky tests #478

Merged
merged 6 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
cache: "yarn"
- name: Install dependencies
run: |
yarn add bos-workspace
yarn add bos-workspace@1.0.0-alpha.32
npx playwright install-deps
npx playwright install
- name: Run tests
Expand Down
4 changes: 2 additions & 2 deletions apps/new/widget/components/project/StarProject.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ const starClick = (event) => {
};

const title = hasStar
? props.titleUnstar ?? "Unstar"
: props.titleStar ?? "Star";
? (props.titleUnstar ?? "Unstar")
: (props.titleStar ?? "Star");

const inner = (
<div className="d-inline-flex align-items-center">
Expand Down
2 changes: 1 addition & 1 deletion apps/new/widget/page/proposals/Index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ useEffect(() => {
currentPage === 0
? lastProposalId > resPerPage
? lastProposalId - resPerPage
: lastProposalId ?? resPerPage
: (lastProposalId ?? resPerPage)
: filteredProposals[0].id - currentPage * resPerPage;

sdk
Expand Down
8 changes: 6 additions & 2 deletions apps/old/widget/components/Avatar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ function Avatar(props) {
const ImageWrapper = styled.div`
img {
width: ${(props) =>
props.variant === "mobile" ? "40px" : props.size ?? "52px"} !important;
props.variant === "mobile"
? "40px"
: (props.size ?? "52px")} !important;
height: ${(props) =>
props.variant === "mobile" ? "40px" : props.size ?? "52px"} !important;
props.variant === "mobile"
? "40px"
: (props.size ?? "52px")} !important;
flex-shrink: 0 !important;
border-radius: 100px !important;
}
Expand Down
4 changes: 2 additions & 2 deletions apps/old/widget/components/post/BookmarkButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ const bookmarkClick = () => {
};

const title = hasBookmark
? props.titleUnbookmark ?? "Unbookmark"
: props.titleBookmark ?? "Bookmark";
? (props.titleUnbookmark ?? "Unbookmark")
: (props.titleBookmark ?? "Bookmark");

const inner = (
<div className="d-inline-flex align-items-center">
Expand Down
2 changes: 1 addition & 1 deletion apps/old/widget/events/MonthView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ const EventModal = styled.div`
`;

const embedCss =
props.embedCss ?? theme === "light" ? customCSSLight : customCSSDark;
(props.embedCss ?? theme === "light") ? customCSSLight : customCSSDark;

const code = `
<script src='https://cdn.jsdelivr.net/npm/fullcalendar/index.global.js'></script>
Expand Down
11 changes: 7 additions & 4 deletions playwright-tests/tests/activity.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,13 +560,16 @@ test.describe("User is logged in", () => {
});
});
test("Convert post into proposal", async ({ page }) => {
await page.waitForTimeout(1000);
await page.waitForLoadState("networkidle");

const dropdown = page.locator(".bi.bi-three-dots-vertical").nth(1);
await expect(dropdown).toBeVisible();
await dropdown.click();
await page.waitForTimeout(1000);
const convertPost = page.getByText("Propose");

const convertPost = page.getByRole("button", { name: "Propose" });
await expect(convertPost).toBeVisible();
await convertPost.click();
await page.waitForTimeout(1000);

const DAOContractID = await page.getByText("build.sputnik-dao.near");
await expect(DAOContractID).toBeVisible();
});
Expand Down
18 changes: 0 additions & 18 deletions playwright-tests/tests/landing-page.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,12 @@ test.describe("Navbar tabs redirection", () => {
const homeTab = page.locator("span", { hasText: "Home" });
await homeTab.click();
expect(page.url()).toContain("?page=home");
await page.waitForTimeout(1000);
expect(
page.getByText(
"Designed to support builders in a multi-chain ecosystem.",
{ exact: true },
),
).toBeVisible();
});

test("Activity", async ({ page }) => {
const activityTab = page.locator("span", { hasText: "Activity" });
await activityTab.click();
expect(page.url()).toContain("?page=activity");
await page.waitForTimeout(1000);
expect(page.getByText("All").nth(0)).toBeVisible();
});
test("Projects", async ({ page }) => {
const projectsTab = page.getByRole("link", {
Expand All @@ -32,20 +23,11 @@ test.describe("Navbar tabs redirection", () => {
});
await projectsTab.click();
expect(page.url()).toContain("?page=projects");
await page.waitForTimeout(2000);
expect(
page.getByText(
"Easily create, share, and track all projects within our vibrant builder community",
{ exact: true },
),
).toBeVisible();
});
test("Resources", async ({ page }) => {
const resourcesTab = page.locator("span", { hasText: "Resources" });
await resourcesTab.click();
expect(page.url()).toContain("?page=resources");
await page.waitForTimeout(2000);
expect(page.getByText("Current Build DAO", { exact: true })).toBeVisible();
});
});

Expand Down
75 changes: 40 additions & 35 deletions playwright-tests/tests/project.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { expect, test } from "@playwright/test";
import { ROOT_SRC } from "../util/constants";

const projectId = "meghagoel.testnet/project/testing-project-on-builddao";

test.describe("?page=project&id=", () => {
const projectId = "meghagoel.testnet/project/testing-project-on-builddao";
test.beforeEach(async ({ page }) => {
await page.goto(`/${ROOT_SRC}?page=project&id=${projectId}`);
});
Expand Down Expand Up @@ -213,44 +214,48 @@ test.describe("?page=project&id=", () => {
});
});
});
});

test.describe("Activity Page", () => {
test.beforeEach(async ({ page }) => {
await page.goto(`/${ROOT_SRC}?page=project&id=${projectId}&tab=activity`);
});
test("should display feed and post option", async ({ page }) => {
await expect(
page.getByText("Testing Project On Build DAO"),
).toBeVisible();
await expect(page.getByText("Post")).toBeVisible();
});
test.describe("Feed Pages", () => {
test.use({
storageState: "playwright-tests/storage-states/wallet-connected.json",
});

test.describe("Updates Page", () => {
test.beforeEach(async ({ page }) => {
await page.goto(
`/${ROOT_SRC}?page=project&id=${projectId}&tab=updatesFeed`,
);
});
test("should display feed and post option", async ({ page }) => {
await expect(
page.getByText("Testing Project On Build DAO Updates"),
).toBeVisible();
await expect(page.getByText("Post")).toBeVisible();
});
});
const pages = [
{
name: "Activity",
tab: "activity",
expectedText: "Testing Project On Build DAO",
},
{
name: "Updates",
tab: "updatesFeed",
expectedText: "Testing Project On Build DAO Updates",
},
{
name: "Feedback",
tab: "feedbackFeed",
expectedText: "Testing Project On Build DAO Feedback",
},
];

test.describe("Feedback Page", () => {
test.beforeEach(async ({ page }) => {
await page.goto(
`/${ROOT_SRC}?page=project&id=${projectId}&tab=feedbackFeed`,
);
});
test("should display feed and post option", async ({ page }) => {
await expect(
page.getByText("Testing Project On Build DAO Feedback"),
).toBeVisible();
await expect(page.getByText("Post")).toBeVisible();
pages.forEach(({ name, tab, expectedText }) => {
test.describe(`${name} Feed`, () => {
test.beforeEach(async ({ page }) => {
await page.goto(`/${ROOT_SRC}?page=project&id=${projectId}&tab=${tab}`);
});

test(`should display feed and post option`, async ({ page }) => {
await expect(async () => {
const element = await page.getByText(expectedText);
await expect(element).toBeVisible();
}).toPass();

await expect(async () => {
const postButton = await page.getByRole("button", { name: "Post" });
await expect(postButton).toBeVisible();
}).toPass();
});
});
});
});
Loading