-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Plawright POC * removed unused variable * removed example file * Remove TS issues * CI url fix * Add artefacts config * basic setup finished * all create product type tests refactored and single from create product * trigger tsc type checks on test folder before commits * cr fixes * removed PW workflow for now, add notification to cypress tests about delete when migration is done, cr fix interface naming * wraped combobox on taxes and category components with box with data test id * git ignore fix --------- Co-authored-by: wojteknowacki <[email protected]>
- Loading branch information
1 parent
327008a
commit f97d75c
Showing
27 changed files
with
846 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npx lint-staged | ||
npm run check-types-playwright |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,39 @@ | ||
import dotenv from "dotenv"; | ||
|
||
import { defineConfig, devices } from "@playwright/test"; | ||
|
||
dotenv.config(); | ||
|
||
export default defineConfig({ | ||
testDir: "playwright/tests", | ||
fullyParallel: true, | ||
forbidOnly: !!process.env.CI, | ||
retries: process.env.CI ? 2 : 0, | ||
workers: process.env.CI ? 1 : undefined, | ||
reporter: "html", | ||
// webServer: { | ||
// command: "npm run dev", | ||
// url: "http://localhost:9000/", | ||
// reuseExistingServer: !process.env.CI, | ||
// }, | ||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
use: { | ||
baseURL: process.env.CYPRESS_baseUrl, | ||
trace: "on-first-retry", | ||
screenshot: "only-on-failure", | ||
testIdAttribute: "data-test-id", | ||
video: process.env.CI ? "retain-on-failure" : "off", | ||
}, | ||
|
||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ name: "setup", testMatch: /.*\.setup\.ts/ }, | ||
|
||
{ | ||
// if new project added make sure to add dependency as below | ||
dependencies: ["setup"], | ||
name: "chromium", | ||
use: { ...devices["Desktop Chrome"] }, | ||
}, | ||
], | ||
}); |
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,40 @@ | ||
import { APIResponse, request } from "@playwright/test"; | ||
|
||
const URL = process.env.API_URI || ""; | ||
interface Data { | ||
query: string; | ||
} | ||
|
||
interface User { | ||
email: string; | ||
password: string; | ||
} | ||
export class GraphQLService { | ||
async example( | ||
user: User, | ||
authorization: string = "auth", | ||
): Promise<APIResponse> { | ||
const headers = { Authorization: `Bearer ${authorization}` }; | ||
|
||
const api = await request.newContext(); | ||
const query = `mutation TokenAuth{ | ||
tokenCreate(email: "${user.email}", password: "${user.password}") { | ||
token | ||
refreshToken | ||
errors: errors { | ||
code | ||
field | ||
message | ||
} | ||
user { | ||
id | ||
} | ||
} | ||
}`; | ||
const data: Data = { | ||
query: query, | ||
}; | ||
const loginResponse = await api.post(URL, { data, headers }); | ||
return loginResponse; | ||
} | ||
} |
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,4 @@ | ||
export const LOCATORS = { | ||
successBanner: '[data-test-type="success"]', | ||
dataGridTable: "[data-testid='data-grid-canvas']", | ||
}; |
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,36 @@ | ||
export const URL_LIST = { | ||
addProduct: "products/add", | ||
addPageType: "pages/add?page-type-id=", | ||
apps: "custom-apps/", | ||
attributes: "attributes/", | ||
categories: "categories/", | ||
channels: "channels/", | ||
collections: "collections/", | ||
configuration: "configuration/", | ||
customers: "customers/", | ||
dashboard: "dashboard/", | ||
draftOrders: "orders/drafts/", | ||
giftCards: "gift-cards/", | ||
homePage: "/", | ||
newPassword: "new-password/", | ||
navigation: "navigation/", | ||
orders: "orders/", | ||
pages: "pages/", | ||
pageTypes: "page-types/", | ||
permissionsGroups: "permission-groups/", | ||
plugins: "plugins/", | ||
products: "products/", | ||
productTypes: "product-types/", | ||
productTypesAdd: "product-types/add", | ||
sales: "discounts/sales/", | ||
shippingMethods: "shipping/", | ||
siteSettings: "site-settings/", | ||
staffMembers: "staff/", | ||
stripeApiPaymentMethods: "https://api.stripe.com/v1/payment_methods", | ||
translations: "translations/", | ||
variants: "variant/", | ||
vouchers: "discounts/vouchers/", | ||
variant: "variant/", | ||
warehouses: "warehouses/", | ||
webhooksAndEvents: "custom-apps/", | ||
}; |
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,28 @@ | ||
import type { | ||
Locator, | ||
Page, | ||
} from "@playwright/test"; | ||
|
||
export class ProductCreateDialog { | ||
readonly page: Page; | ||
readonly dialogProductTypeInput: Locator; | ||
readonly promptedOptions: Locator; | ||
readonly confirmButton: Locator; | ||
constructor(page: Page) { | ||
this.page = page; | ||
this.dialogProductTypeInput = page.locator( | ||
"[data-test-id='dialog-product-type'] input", | ||
); | ||
this.promptedOptions = page.getByTestId( | ||
"single-autocomplete-select-option", | ||
); | ||
this.confirmButton = page.getByTestId("submit"); | ||
} | ||
async selectProductTypeWithVariants() { | ||
await this.dialogProductTypeInput.fill("beer"); | ||
await this.promptedOptions.filter({ hasText: "Beer" }).click(); | ||
} | ||
async clickConfirmButton() { | ||
await this.confirmButton.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { | ||
Locator, | ||
Page, | ||
} from "@playwright/test"; | ||
|
||
export class HomePage { | ||
readonly page: Page; | ||
readonly welcomeMessage: Locator; | ||
constructor(page: Page) { | ||
this.page = page; | ||
this.welcomeMessage = page.getByTestId("home-header"); | ||
} | ||
async goto() { | ||
await this.page.goto("/"); | ||
} | ||
} |
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,34 @@ | ||
import type { | ||
Locator, | ||
Page, | ||
} from "@playwright/test"; | ||
|
||
export class LoginPage { | ||
readonly page: Page; | ||
readonly emailInput: Locator; | ||
readonly passwordInput: Locator; | ||
readonly signInButton: Locator; | ||
constructor(page: Page) { | ||
this.page = page; | ||
this.emailInput = page.getByTestId("email"); | ||
this.passwordInput = page.getByTestId("password"); | ||
this.signInButton = page.getByTestId("submit"); | ||
} | ||
async typeEmail(email: string) { | ||
await this.emailInput.type(email); | ||
} | ||
async typePassword(password: string) { | ||
await this.passwordInput.type(password); | ||
} | ||
async clickSignInButton() { | ||
await this.signInButton.click(); | ||
} | ||
async goto() { | ||
const CYPRESS_baseUrl = process.env.CYPRESS_baseUrl; | ||
const loginPageUrl = | ||
CYPRESS_baseUrl === "http://localhost:9000/" | ||
? "http://localhost:9000/" | ||
: "/dashboard"; | ||
await this.page.goto(loginPageUrl); | ||
} | ||
} |
Oops, something went wrong.