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

Tijl/ /fix playwright #2049

Merged
merged 27 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2ec039a
update playwright
tijlleenders Sep 22, 2024
2c1cdd8
fix local server port
tijlleenders Sep 22, 2024
dff4f57
github action to run latest playwright
tijlleenders Sep 22, 2024
44d63ef
set port to 3000
tijlleenders Sep 22, 2024
d4538b9
update: config goal ui playwright test
vinaybadgujar102 Oct 4, 2024
a6a8dc4
fix: collaboration playwright test
vinaybadgujar102 Oct 4, 2024
254c002
fix: other playwright tests
vinaybadgujar102 Oct 4, 2024
7e462af
add: retires to collaboration playwright test for response confirmation
vinaybadgujar102 Oct 4, 2024
deabe69
edit: increase collaboration timeout limit
vinaybadgujar102 Oct 4, 2024
8e368ad
add: run playwright in headful mode in ci/cd
vinaybadgujar102 Oct 4, 2024
7f11bc6
edit: increase retries for collaboration playwright test
vinaybadgujar102 Oct 4, 2024
e18f286
fix: add appropriate reloads
vinaybadgujar102 Oct 5, 2024
c358394
edit: create new goal and share that goal in test
vinaybadgujar102 Oct 5, 2024
6c791f9
add network idles
vinaybadgujar102 Oct 5, 2024
cf8addd
check for notification symbol
vinaybadgujar102 Oct 5, 2024
4316443
add console logs
vinaybadgujar102 Oct 5, 2024
4f2a7bb
add more console log
vinaybadgujar102 Oct 5, 2024
abd24fd
await for modal to display
vinaybadgujar102 Oct 5, 2024
b38620d
fix: replace isvisible with inviewport
vinaybadgujar102 Oct 5, 2024
adb862a
small fix
vinaybadgujar102 Oct 5, 2024
b571cee
small fix
vinaybadgujar102 Oct 5, 2024
4560c5e
remove: dead function
vinaybadgujar102 Oct 5, 2024
31cefde
edit: check for the updated goal in my goals container
vinaybadgujar102 Oct 6, 2024
396936f
add page reload
vinaybadgujar102 Oct 6, 2024
8de42fd
fix: minor error related to navigation
vinaybadgujar102 Oct 6, 2024
c84045b
edit: click on partner goal switch mode button instead of navigating …
vinaybadgujar102 Oct 6, 2024
979b836
move back to headless mode
vinaybadgujar102 Oct 6, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: lts/*
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v4
if: always()
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
Expand Down
29 changes: 17 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"@dnd-kit/sortable": "^8.0.0",
"@dnd-kit/utilities": "^3.2.2",
"@jest/globals": "^28.1.0",
"@playwright/test": "^1.38.1",
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^11.2.7",
"@types/node": "^17.0.31",
Expand Down Expand Up @@ -84,6 +83,7 @@
"@babel/preset-env": "^7.18.2",
"@babel/preset-react": "^7.17.12",
"@babel/preset-typescript": "^7.17.12",
"@playwright/test": "^1.47.2",
"@types/crypto-js": "^4.1.1",
"@typescript-eslint/eslint-plugin": "^5.22.0",
"@typescript-eslint/parser": "^5.22.0",
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default defineConfig({
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
retries: process.env.CI ? 5 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
Expand Down
4 changes: 2 additions & 2 deletions playwright/tests/bottom-nav/navigation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { test, expect } from "@playwright/test";
import { STORAGE_STATE } from "playwright/config/constants";

test.describe("BottomNavbar", () => {
test.use({ storageState: STORAGE_STATE });

test.beforeEach(async ({ page }) => {
await page.goto("http://127.0.0.1:3000/");
await page.getByText("English").click();
await page.getByRole("button", { name: "Continue zinzen faq" }).click();
});

test("should navigate to MyTime when Schedule button is clicked", async ({ page }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test, expect, Page } from "@playwright/test";
import { API_SERVER_URL, API_SERVER_URL_GOAL, STORAGE_STATE } from "playwright/config/constants";
import { API_SERVER_URL, API_SERVER_URL_GOAL } from "playwright/config/constants";
import {
acceptContactInvitation,
addContact,
Expand All @@ -12,22 +12,42 @@ import {
waitForResponseConfirmation,
} from "../../utils/collaboration-feature-utils";

test.describe.configure({ mode: "serial" });
test.describe.configure({ mode: "serial", timeout: 100000 });

test.describe("Goal Sharing Feature", () => {
let userAContext;
let userBContext;
let userCContext;
let userAPage: Page;
let userBPage: Page;
let userCPage: Page;
let invitationLink: string;
let currentGoalTitle: string;
let currentGoalTitle = "Test Goal";

test.beforeAll(async ({ browser }) => {
({ context: userAContext, page: userAPage } = await createUserContextAndPage(browser, STORAGE_STATE));
({ context: userBContext, page: userBPage } = await createUserContextAndPage(browser, STORAGE_STATE));
({ context: userCContext, page: userCPage } = await createUserContextAndPage(browser, STORAGE_STATE));
console.log("Setting up users A, B, and C pages...");
({ page: userAPage } = await createUserContextAndPage(browser));
({ page: userBPage } = await createUserContextAndPage(browser));
({ page: userCPage } = await createUserContextAndPage(browser));

console.log("Navigating User A to the main page...");
await userAPage.goto("http://127.0.0.1:3000/");
await userAPage.getByText("English").click();
await userAPage.getByRole("button", { name: "Continue zinzen faq" }).click();

console.log("Navigating User B to the main page...");
await userBPage.goto("http://127.0.0.1:3000/");
await userBPage.getByText("English").click();
await userBPage.getByRole("button", { name: "Continue zinzen faq" }).click();

console.log("Navigating User C to the main page...");
await userCPage.goto("http://127.0.0.1:3000/");
await userCPage.getByText("English").click();
await userCPage.getByRole("button", { name: "Continue zinzen faq" }).click();
});

test.afterAll(async () => {
console.log("Closing all user pages...");
await userAPage.close();
await userBPage.close();
await userCPage.close();
});

const userCollaborationScenarios = [
Expand Down Expand Up @@ -64,56 +84,96 @@ test.describe("Goal Sharing Feature", () => {

userCollaborationScenarios.forEach(({ sharer, receiver, sharerPage, receiverPage }) => {
test(`from User ${sharer} share invitation to User ${receiver}`, async () => {
console.log(`User ${sharer} is navigating to their goals page...`);
await goToMyGoalsPageFlow(sharerPage());
currentGoalTitle = await sharerPage().locator(".goal-title").first().locator("span").innerText();
invitationLink = await addContact(sharerPage(), receiver, "relId", "relationshipId");

if (sharer === "A") {
console.log(`User ${sharer} is creating a new goal titled "${currentGoalTitle}"...`);
await sharerPage().getByRole("button", { name: "add goal | add feeling | add group", exact: true }).click();
const titleInputContainer = sharerPage().getByPlaceholder("Goal title");
await titleInputContainer.fill(currentGoalTitle);
await titleInputContainer.press("Enter");
}

console.log(`User ${sharer} is adding User ${receiver} as a contact...`);
invitationLink = await addContact(sharerPage(), receiver, currentGoalTitle);

console.log(`User ${sharer} is navigating to their goals page again...`);
await goToMyGoalsPageFlow(sharerPage());
await goToShareGoalModalFlow(sharerPage());

console.log(`User ${sharer} is opening the share goal modal for "${currentGoalTitle}"...`);
await goToShareGoalModalFlow(sharerPage(), currentGoalTitle);
});

test(`from User ${receiver} accept invitation of User ${sharer}`, async () => {
console.log(`User ${receiver} is accepting the invitation from User ${sharer}...`);
await acceptContactInvitation(receiverPage(), invitationLink, receiver);
await waitForResponseConfirmation(receiverPage(), API_SERVER_URL, "accepted");
await waitForResponseConfirmation(receiverPage(), API_SERVER_URL);
});

test(`share goal from User ${receiver} to User ${sharer}`, async () => {
await sharerPage().getByRole("button", { name: receiver, exact: true }).click();
await sharerPage().waitForSelector(".ant-notification-notice");
console.log(`User ${sharer} is sharing the goal with User ${receiver}...`);
await goToMyGoalsPageFlow(sharerPage());

console.log(`User ${sharer} is opening the share goal modal for "${currentGoalTitle}"...`);
await goToShareGoalModalFlow(sharerPage(), currentGoalTitle);
await expect(async () => {
await sharerPage().getByRole("button", { name: receiver, exact: true }).click();
await sharerPage().waitForLoadState("networkidle");
}).toPass({
timeout: 10_000,
});
});

test(`check whether shared goal is visible in User ${receiver}'s patner goal`, async () => {
test(`check whether shared goal is visible in User ${receiver}'s partner goal`, async () => {
console.log(`User ${receiver} is reloading the page to check for shared goal visibility...`);
await receiverPage().reload();
await waitForResponseConfirmation(receiverPage(), API_SERVER_URL_GOAL, "shareMessage");
await waitForResponseConfirmation(receiverPage(), API_SERVER_URL_GOAL);
await receiverPage().getByRole("img", { name: "ZinZen" }).click();
await receiverPage().reload();
await expect(receiverPage().locator(".user-goal-main")).toBeVisible();
});

test(`initiate collaboration between User ${sharer} and User ${receiver}`, async () => {
await collaborateFlow(receiverPage());
console.log(`Initiating collaboration between User ${sharer} and User ${receiver}...`);
await collaborateFlow(receiverPage(), currentGoalTitle);
});

test(`check if collaborated goal is visible in User ${receiver}'s MyGoal`, async () => {
await receiverPage().getByRole("button", { name: "Goals" }).click();
await expect(receiverPage().locator(".goal-title").first().locator("span")).toContainText(currentGoalTitle);
console.log(`Checking if collaborated goal is visible in User ${receiver}'s MyGoal...`);
await receiverPage().locator(".header-logo-wrapper").click();
await expect(receiverPage().locator(".my-goals-content").first()).toContainText(currentGoalTitle);
});
});

editAndConfirmScenarios.forEach(
({ sharer, receiverFirst, receiverSecond, sharerPage, receiverPageFirst, receiverPageSecond }) => {
test(`goal update by ${sharer}: edit goal in User ${sharer}`, async () => {
await goToMyGoalsPageFlow(sharerPage());
await goalActionFlow(sharerPage(), "Edit");
await sharerPage().locator(".header-title").locator("input").fill(`${currentGoalTitle} edited by ${sharer}`);
await sharerPage().locator(".action-btn-container").locator(".action-btn").click();
currentGoalTitle = await sharerPage().locator(".goal-title").first().locator("span").innerText();
console.log(`User ${sharer} is updating the goal "${currentGoalTitle}"...`);
await expect(async () => {
await goToMyGoalsPageFlow(sharerPage());
await goalActionFlow(sharerPage(), "Edit", currentGoalTitle);
await sharerPage().locator(".header-title").locator("input").fill(`${currentGoalTitle} edited by ${sharer}`);
await sharerPage().locator(".action-btn-container").locator(".action-btn").click();
}).toPass();

console.log(`Getting the updated goal title from User ${sharer}'s page...`);
currentGoalTitle = await sharerPage()
.locator(".user-goal-dark")
.filter({
has: sharerPage().locator(".contact-button"),
})
.locator(".goal-title span")
.innerText();
});

test(`goal update by ${sharer}: check if User ${receiverFirst} received updated goal from User ${sharer}`, async () => {
console.log(`Checking if User ${receiverFirst} received the updated goal from User ${sharer}...`);
await verifyUpdatedGoal(receiverPageFirst(), currentGoalTitle, API_SERVER_URL_GOAL);
});

test(`goal update by ${sharer}: check if User ${receiverSecond} received updated goal from User ${sharer}`, async () => {
console.log(`Checking if User ${receiverSecond} received the updated goal from User ${sharer}...`);
await verifyUpdatedGoal(receiverPageSecond(), currentGoalTitle, API_SERVER_URL_GOAL);
});
},
Expand Down

This file was deleted.

7 changes: 4 additions & 3 deletions playwright/tests/config-goal-ui.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ test.describe("Config Goal UI", () => {

test("should add a new goal after pressing Enter key", async ({ page }) => {
await page.getByRole("button", { name: "Goals" }).click();
await page.getByRole("button", { name: "add goal | add feeling | add group", exact: true }).click();
await page.getByRole("button", { name: "Goal add goal", exact: true }).click();
await page.getByRole("button", { name: "add goal | add feeling | add group", exact: true }).click({});

const titleInputContainer = page.getByPlaceholder("Goal title");
const testGoalTitle = "Test Goal";
Expand All @@ -24,7 +23,9 @@ test.describe("Config Goal UI", () => {

test("should add a new budget after pressing Enter key", async ({ page }) => {
await page.getByRole("button", { name: "Goals" }).click();
await page.getByRole("button", { name: "add goal | add feeling | add group", exact: true }).click();
await page.getByRole("button", { name: "add goal | add feeling | add group", exact: true }).click({
delay: 1000,
});
await page.getByRole("button", { name: "Budget add goal", exact: true }).click();

const titleInputContainer = page.getByPlaceholder("Budget title");
Expand Down
5 changes: 2 additions & 3 deletions playwright/tests/header-ui.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { test, expect } from "@playwright/test";
import { STORAGE_STATE } from "playwright/config/constants";

test.describe("Header component", () => {
test.use({ storageState: STORAGE_STATE });

test.beforeEach(async ({ page }) => {
await page.goto("http://127.0.0.1:3000/");
await page.getByText("English").click();
await page.getByRole("button", { name: "Continue zinzen faq" }).click();
});

test("should display the title correctly", async ({ page }) => {
Expand Down
Loading
Loading