Skip to content

Commit

Permalink
add: storageState
Browse files Browse the repository at this point in the history
  • Loading branch information
vinaybadgujar102 committed Oct 7, 2023
1 parent 218de20 commit d6a51e5
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 0 deletions.
46 changes: 46 additions & 0 deletions auth.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"cookies": [],
"origins": [
{
"origin": "http://localhost:3000",
"localStorage": [
{
"name": "checkedIn",
"value": "yes"
},
{
"name": "language",
"value": "\"en\""
},
{
"name": "lastRefresh",
"value": "02/10/2023"
},
{
"name": "theme",
"value": "{\"light\":1,\"dark\":1}"
},
{
"name": "darkMode",
"value": "off"
},
{
"name": "installId",
"value": "8e79de41-5c85-4fba-b175-e95f5635123d"
},
{
"name": "dexieVersion",
"value": "12"
},
{
"name": "i18nextLng",
"value": "en"
},
{
"name": "confirmationState",
"value": "{\"open\":false,\"goal\":{\"archive\":true,\"delete\":true,\"shareAnonymously\":true,\"shareWithOne\":true},\"collaboration\":{\"colabRequest\":true,\"delete\":true,\"archive\":true}}"
}
]
}
]
}
75 changes: 75 additions & 0 deletions tests/example.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { test, expect } from "@playwright/test";

test("test", async ({ browser }) => {
test.setTimeout(40000);
const userOneContext = await browser.newContext({
storageState: "./auth.json",
serviceWorkers: "allow",
});
const userTwoContext = await browser.newContext({
storageState: "./auth.json",
serviceWorkers: "allow",
});
const userTwoPage = await userTwoContext.newPage();
const userOnePage = await userOneContext.newPage();
await userOnePage.goto("http://localhost:3000/");
await userOnePage.getByRole("button", { name: "Goals" }).click();
await userOnePage.locator(".goal-tile").first().click();
await userOnePage
.locator("div")
.filter({ hasText: /^ActionsEdit$/ })
.locator("div")
.nth(2)
.click();
await userOnePage
.locator("div")
.filter({ hasText: /^Share$/ })
.first()
.click();
await userOnePage.getByRole("button", { name: "Share privately" }).click();
await userOnePage.getByRole("button", { name: "Choose contact" }).click();
await userOnePage.getByPlaceholder("Name").click();
await userOnePage.getByPlaceholder("Name").fill("User 2");
await userOnePage.getByRole("button", { name: "add contact Share invitation" }).click();
await userOnePage.waitForTimeout(5000);
await userOnePage.goBack();
await userOnePage.getByRole("button", { name: "U", exact: true }).click();
await userOnePage.waitForSelector(".ant-notification-notice");
const link = await userOnePage.evaluate("navigator.clipboard.readText()");
await userOnePage.goto("http://localhost:3000/");
await userOnePage.getByRole("button", { name: "Goals" }).click();
await userOnePage.locator(".goal-tile").first().click();
await userOnePage
.locator("div")
.filter({ hasText: /^ActionsEdit$/ })
.locator("div")
.nth(2)
.click();
await userOnePage
.locator("div")
.filter({ hasText: /^Share$/ })
.first()
.click();
await userOnePage.getByRole("button", { name: "Share privately" }).click();
await userOnePage.getByRole("button", { name: "Choose contact" }).click();

await userTwoPage.waitForTimeout(1000);
await userTwoPage.goto(`${link}`);
await userTwoPage.getByPlaceholder("Contact name").click();
await userTwoPage.getByPlaceholder("Contact name").fill("User 1");
await userTwoPage.getByRole("button", { name: "Add to my contacts" }).click();
await userTwoPage.waitForTimeout(2000);
await userOnePage.getByRole("button", { name: "U", exact: true }).click();
await userOnePage.waitForSelector(".ant-notification-notice");

await userTwoPage.reload(); // Refresh the window
await userTwoPage.getByRole("button", { name: "Goals" }).click();
await userTwoPage.getByRole("button", { name: "Schedule" }).click();
await userTwoPage.getByRole("button", { name: "Goals" }).click(); // Switch back to My Goals
await userTwoPage.reload(); // Refresh the window
await userTwoPage.waitForSelector(".header-icon[alt='zinzen inbox']");
await userTwoPage.waitForSelector(".header-icon[alt='zinzen inbox']"); // Check if inbox icon is visible
await userTwoPage.getByRole("button", { name: "zinzen inbox" }).click(); // Click on inbox
await userTwoPage.waitForSelector(".goal-tile");
});

0 comments on commit d6a51e5

Please sign in to comment.