-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: rename modalPage as it is not a modalPage * test: add updatePreferences test * chore: count subscribed dapps * test: add message test * chore: fix bugs in tests * chore: expose env in workflow * chore: pass duplex option for webkit * Update tests/shared/helpers/notifyServer.ts Co-authored-by: Ben Kremer <[email protected]> * Apply suggestions from code review Co-authored-by: Chris Smith <[email protected]> Co-authored-by: Ben Kremer <[email protected]> * chore: update env vars * chore: remove need for clipboard, and stream in fetch * chore: remove unused prop * chore: wait for dapps to be subscribed * chore: disable webkit * chore: remove extra subscribe * chore: remove unhelpful logs * Update tests/shared/pages/InboxPage.ts Co-authored-by: Enes <[email protected]> * Update tests/shared/pages/InboxPage.ts Co-authored-by: Enes <[email protected]> * chore: remove empty space * chore: refactor waitForSubscriptions --------- Co-authored-by: Ben Kremer <[email protected]> Co-authored-by: Chris Smith <[email protected]> Co-authored-by: Enes <[email protected]>
- Loading branch information
1 parent
32d70f8
commit 441b7a8
Showing
9 changed files
with
311 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,38 @@ | ||
import { test as base } from '@playwright/test' | ||
|
||
import { ModalPage } from '../pages/InboxPage' | ||
import { ModalValidator } from '../validators/ModalValidator' | ||
import { InboxPage } from '../pages/InboxPage' | ||
import { InboxValidator } from '../validators/ModalValidator' | ||
import { SettingsPage } from '../pages/SettingsPage' | ||
import { NotifyServer } from '../helpers/notifyServer' | ||
|
||
// Declare the types of fixtures to use | ||
export interface ModalFixture { | ||
modalPage: ModalPage | ||
modalValidator: ModalValidator | ||
inboxPage: InboxPage | ||
inboxValidator: InboxValidator | ||
settingsPage: SettingsPage | ||
notifyServer: NotifyServer | ||
library: string | ||
} | ||
|
||
export const test = base.extend<ModalFixture>({ | ||
modalPage: async ({ page }, use) => { | ||
const modalPage = new ModalPage(page) | ||
await modalPage.load() | ||
await use(modalPage) | ||
inboxPage: async ({ page }, use) => { | ||
const inboxPage = new InboxPage(page) | ||
await inboxPage.load() | ||
await use(inboxPage) | ||
}, | ||
modalValidator: async ({ modalPage }, use) => { | ||
const modalValidator = new ModalValidator(modalPage.page) | ||
inboxValidator: async ({ inboxPage }, use) => { | ||
const modalValidator = new InboxValidator(inboxPage.page) | ||
await use(modalValidator) | ||
} | ||
}, | ||
// Have to pass same page object to maintain state between pages | ||
settingsPage: async({ inboxPage }, use) => { | ||
const settingsPage = new SettingsPage(inboxPage.page) | ||
settingsPage.load() | ||
use(settingsPage) | ||
}, | ||
notifyServer: async({}, use) => { | ||
const notifyServer = new NotifyServer(); | ||
use(notifyServer) | ||
}, | ||
}) | ||
export { expect } from '@playwright/test' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { expect } from "@playwright/test" | ||
|
||
export class NotifyServer { | ||
private notifyBaseUrl = "https://notify.walletconnect.com" | ||
|
||
public async sendMessage({ | ||
projectId, | ||
projectSecret, | ||
accounts, | ||
url, | ||
title, | ||
body, | ||
icon, | ||
type | ||
}: { | ||
projectId: string, | ||
projectSecret: string, | ||
accounts: string[] | ||
title: string, | ||
body: string, | ||
icon: string, | ||
url: string | ||
type: string | ||
}) { | ||
const request = JSON.stringify({ | ||
accounts, | ||
notification: { | ||
title, | ||
body, | ||
icon, | ||
url, | ||
type | ||
} | ||
}) | ||
|
||
const fetchUrl = `${this.notifyBaseUrl}/${projectId}/notify` | ||
|
||
const headers = new Headers({ | ||
Authorization: `Bearer ${projectSecret}`, | ||
"Content-Type": "application/json" | ||
}) | ||
|
||
const fetchResults = await fetch(fetchUrl, { | ||
method: "POST", | ||
headers, | ||
body: request | ||
}) | ||
|
||
console.log({fetchResultsStatus: fetchResults.status, fetchResults: await fetchResults.text()}) | ||
|
||
expect(fetchResults.status).toEqual(200) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { type Locator, type Page, expect } from '@playwright/test' | ||
|
||
import { BASE_URL } from '../../shared/constants' | ||
|
||
export class SettingsPage { | ||
private readonly baseURL = BASE_URL | ||
|
||
constructor(public readonly page: Page) {} | ||
|
||
async load() {} | ||
|
||
async goToNotificationSettings() { | ||
await this.page.locator('.Sidebar__Navigation__Link[href="/settings"]').click() | ||
} | ||
|
||
async displayCustomDapp(dappUrl: string) { | ||
await this.page.getByPlaceholder('app.example.com').fill(dappUrl) | ||
await this.page.getByRole('button', { name: "Save", exact: true}).click() | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.