Skip to content

Commit d658603

Browse files
authored
Merge branch 'main' into patch-2
2 parents d87c599 + 2470f9c commit d658603

File tree

25 files changed

+902
-141
lines changed

25 files changed

+902
-141
lines changed

.github/scripts/medusa-config.js

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
const dotenv = require("dotenv");
2+
3+
let ENV_FILE_NAME = "";
4+
switch (process.env.NODE_ENV) {
5+
case "production":
6+
ENV_FILE_NAME = ".env.production";
7+
break;
8+
case "staging":
9+
ENV_FILE_NAME = ".env.staging";
10+
break;
11+
case "test":
12+
ENV_FILE_NAME = ".env.test";
13+
break;
14+
case "development":
15+
default:
16+
ENV_FILE_NAME = ".env";
17+
break;
18+
}
19+
20+
try {
21+
dotenv.config({ path: process.cwd() + "/" + ENV_FILE_NAME });
22+
} catch (e) {}
23+
24+
// CORS when consuming Medusa from admin
25+
const ADMIN_CORS =
26+
process.env.ADMIN_CORS || "http://localhost:7000,http://localhost:7001";
27+
28+
// CORS to avoid issues when consuming Medusa from a client
29+
const STORE_CORS = process.env.STORE_CORS || "http://localhost:8000";
30+
31+
const DATABASE_URL =
32+
process.env.DATABASE_URL || "postgres://medusa:password@localhost/medusa";
33+
34+
const REDIS_URL = process.env.REDIS_URL || "redis://localhost:6379";
35+
36+
const plugins = [
37+
`medusa-fulfillment-manual`,
38+
`medusa-payment-manual`,
39+
{
40+
resolve: `@medusajs/file-local`,
41+
options: {
42+
upload_dir: "uploads",
43+
},
44+
},
45+
{
46+
resolve: "@medusajs/admin",
47+
/** @type {import('@medusajs/admin').PluginOptions} */
48+
options: {
49+
autoRebuild: true,
50+
develop: {
51+
open: process.env.OPEN_BROWSER !== "false",
52+
},
53+
},
54+
},
55+
{
56+
resolve: `medusa-plugin-meilisearch`,
57+
options: {
58+
config: {
59+
host: process.env.MEILISEARCH_HOST,
60+
apiKey: process.env.MEILISEARCH_API_KEY,
61+
},
62+
settings: {
63+
products: {
64+
indexSettings: {
65+
searchableAttributes: [
66+
"title",
67+
"description",
68+
"variant_sku",
69+
],
70+
displayedAttributes: [
71+
"id",
72+
"title",
73+
"description",
74+
"variant_sku",
75+
"thumbnail",
76+
"handle",
77+
],
78+
},
79+
primaryKey: "id",
80+
},
81+
},
82+
},
83+
},
84+
];
85+
86+
const modules = {
87+
/*eventBus: {
88+
resolve: "@medusajs/event-bus-redis",
89+
options: {
90+
redisUrl: REDIS_URL
91+
}
92+
},
93+
cacheService: {
94+
resolve: "@medusajs/cache-redis",
95+
options: {
96+
redisUrl: REDIS_URL
97+
}
98+
},*/
99+
};
100+
101+
/** @type {import('@medusajs/medusa').ConfigModule["projectConfig"]} */
102+
const projectConfig = {
103+
jwtSecret: process.env.JWT_SECRET,
104+
cookieSecret: process.env.COOKIE_SECRET,
105+
store_cors: STORE_CORS,
106+
database_url: DATABASE_URL,
107+
admin_cors: ADMIN_CORS,
108+
// Uncomment the following lines to enable REDIS
109+
redis_url: REDIS_URL
110+
};
111+
112+
/** @type {import('@medusajs/medusa').ConfigModule} */
113+
module.exports = {
114+
projectConfig,
115+
plugins,
116+
modules,
117+
};

.github/workflows/test-e2e.yaml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,16 @@ env:
2929
DATABASE_TYPE: "postgres"
3030
REDIS_URL: redis://localhost:6379
3131
DATABASE_URL: postgres://test_medusa_user:password@localhost/test_medusa_db
32+
MEILISEARCH_HOST: http://localhost:7700
33+
MEILISEARCH_API_KEY: meili_api_key
34+
3235
NEXT_PUBLIC_BASE_URL: http://localhost:8000
36+
NEXT_PUBLIC_DEFAULT_REGION: us
37+
NEXT_PUBLIC_MEDUSA_BACKEND_URL: http://localhost:9000
38+
NEXT_PUBLIC_INDEX_NAME: products
39+
NEXT_PUBLIC_SEARCH_ENDPOINT: http://127.0.0.1:7700
40+
NEXT_PUBLIC_SEARCH_API_KEY: meili_api_key
41+
REVALIDATE_SECRET: supersecret
3342

3443
jobs:
3544
e2e-test-runner:
@@ -53,6 +62,9 @@ jobs:
5362
5463
meilisearch:
5564
image: getmeili/meilisearch:v1.7
65+
env:
66+
MEILI_MASTER_KEY: meili_api_key
67+
MEILI_ENV: development
5668
ports:
5769
- 7700:7700
5870
options: >-
@@ -100,11 +112,18 @@ jobs:
100112
--db-database ${{ env.TEST_POSTGRES_DATABASE }} \
101113
--db-host ${{ env.TEST_POSTGRES_HOST }} \
102114
--db-port ${{ env.TEST_POSTGREST_PORT }}
103-
115+
104116
- name: Build the backend
105117
working-directory: ../backend
106118
run: yarn build:admin
107119

120+
- name: Setup search in the backend
121+
working-directory: ../backend
122+
run: yarn add medusa-plugin-meilisearch
123+
124+
- name: Move custom medusa config to the backend
125+
run: cp .github/scripts/medusa-config.js ../backend/medusa-config.js
126+
108127
- name: Seed data from default seed file
109128
working-directory: ../backend
110129
run: medusa seed --seed-file=data/seed.json
@@ -119,9 +138,6 @@ jobs:
119138
- name: Install playwright
120139
run: yarn playwright install --with-deps
121140

122-
- name: Copy environment
123-
run: cp .env.template .env
124-
125141
- name: Setup frontend
126142
run: yarn build
127143

e2e/fixtures/account/order-page.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class OrderPage extends AccountPage {
2626

2727
constructor(page: Page) {
2828
super(page)
29-
this.container = page.getByTestId("order-complete-container")
29+
this.container = page.getByTestId("order-details-container")
3030
this.backToOverviewButton = page.getByTestId("back-to-overview-button")
3131
this.orderEmail = this.container.getByTestId("order-email")
3232
this.orderDate = this.container.getByTestId("order-date")
@@ -63,17 +63,16 @@ export class OrderPage extends AccountPage {
6363
async getProduct(title: string, variant: string) {
6464
const productRow = this.productRow
6565
.filter({
66-
has: this.productTitle.filter({ hasText: title }),
66+
hasText: title,
6767
})
6868
.filter({
69-
has: this.productVariant.filter({ hasText: variant }),
69+
hasText: `Variant: ${variant}`,
7070
})
7171
return {
7272
productRow,
73-
title: productRow.getByTestId("product-title"),
73+
name: productRow.getByTestId("product-name"),
7474
variant: productRow.getByTestId("product-variant"),
75-
deleteButton: productRow.getByTestId("delete-button"),
76-
quantitySelect: productRow.getByTestId("quantity-select"),
75+
quantity: productRow.getByTestId("product-quantity"),
7776
price: productRow.getByTestId("product-unit-price"),
7877
total: productRow.getByTestId("product-price"),
7978
}

e2e/fixtures/account/orders-page.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,14 @@ export class OrdersPage extends AccountPage {
2020
this.orderDisplayId = page.getByTestId("order-display-id")
2121
}
2222

23-
async getOrder(text: string) {
24-
const card = this.orderCard.filter({ hasText: "text" }).first()
23+
async getOrderById(orderId: string) {
24+
const orderIdLocator = this.page
25+
.getByTestId("order-display-id")
26+
.filter({
27+
hasText: orderId,
28+
})
29+
.first()
30+
const card = this.orderCard.filter({ has: orderIdLocator }).first()
2531
const items = (await card.getByTestId("order-item").all()).map(
2632
(orderItem) => {
2733
return {
@@ -35,8 +41,10 @@ export class OrdersPage extends AccountPage {
3541
card,
3642
displayId: card.getByTestId("order-display-id"),
3743
createdAt: card.getByTestId("order-created-at"),
44+
orderId: card.getByTestId("order-display-id"),
3845
amount: card.getByTestId("order-amount"),
3946
detailsLink: card.getByTestId("order-details-link"),
47+
itemsLocator: card.getByTestId("order-item"),
4048
items,
4149
}
4250
}

e2e/fixtures/base/base-page.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { CartDropdown } from "./cart-dropdown"
22
import { NavMenu } from "./nav-menu"
33
import { Page, Locator } from "@playwright/test"
4+
import { SearchModal } from "./search-modal"
45

56
export class BasePage {
67
page: Page
78
navMenu: NavMenu
89
cartDropdown: CartDropdown
10+
searchModal: SearchModal
911
accountLink: Locator
1012
searchLink: Locator
1113
storeLink: Locator
@@ -15,6 +17,7 @@ export class BasePage {
1517
this.page = page
1618
this.navMenu = new NavMenu(page)
1719
this.cartDropdown = new CartDropdown(page)
20+
this.searchModal = new SearchModal(page)
1821
this.accountLink = page.getByTestId("nav-account-link")
1922
this.storeLink = page.getByTestId("nav-store-link")
2023
this.searchLink = page.getByTestId("nav-search-link")

e2e/fixtures/base/search-modal.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { Page, Locator } from "@playwright/test"
2+
import { BaseModal } from "./base-modal"
3+
import { NavMenu } from "./nav-menu"
4+
5+
export class SearchModal extends BaseModal {
6+
searchInput: Locator
7+
searchResults: Locator
8+
noSearchResultsContainer: Locator
9+
searchResult: Locator
10+
searchResultTitle: Locator
11+
12+
constructor(page: Page) {
13+
super(page, page.getByTestId("search-modal-container"))
14+
this.searchInput = this.container.getByTestId("search-input")
15+
this.searchResults = this.container.getByTestId("search-results")
16+
this.noSearchResultsContainer = this.container.getByTestId(
17+
"no-search-results-container"
18+
)
19+
this.searchResult = this.container.getByTestId("search-result")
20+
this.searchResultTitle = this.container.getByTestId("search-result-title")
21+
}
22+
23+
async open() {
24+
const menu = new NavMenu(this.page)
25+
await menu.open()
26+
await menu.searchLink.click()
27+
await this.container.waitFor({ state: "visible" })
28+
}
29+
30+
async close() {
31+
const viewport = this.page.viewportSize()
32+
const y = viewport ? viewport.height / 2 : 100
33+
await this.page.mouse.click(1, y, { clickCount: 2, delay: 100 })
34+
await this.container.waitFor({ state: "hidden" })
35+
}
36+
}

e2e/fixtures/checkout-page.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export class CheckoutPage extends BasePage {
4242
submitAddressButton: Locator
4343
addressErrorMessage: Locator
4444

45+
deliveryOptionsContainer: Locator
4546
deliveryOptionRadio: Locator
4647
deliveryOptionErrorMessage: Locator
4748
submitDeliveryOptionButton: Locator
@@ -166,6 +167,9 @@ export class CheckoutPage extends BasePage {
166167
"address-error-message"
167168
)
168169

170+
this.deliveryOptionsContainer = this.container.getByTestId(
171+
"delivery-options-container"
172+
)
169173
this.deliveryOptionRadio = this.container.getByTestId(
170174
"delivery-option-radio"
171175
)

0 commit comments

Comments
 (0)