Skip to content

Commit

Permalink
fix: update e2e test runner
Browse files Browse the repository at this point in the history
  • Loading branch information
VariableVic committed Jul 5, 2024
1 parent 169e7f8 commit 6547d6b
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 93 deletions.
149 changes: 57 additions & 92 deletions .github/scripts/medusa-config.js
Original file line number Diff line number Diff line change
@@ -1,111 +1,76 @@
const dotenv = require("dotenv")
const { defineConfig, loadEnv } = require("@medusajs/utils")

let ENV_FILE_NAME = ""
switch (process.env.NODE_ENV) {
case "production":
ENV_FILE_NAME = ".env.production"
break
case "staging":
ENV_FILE_NAME = ".env.staging"
break
case "test":
ENV_FILE_NAME = ".env.test"
break
case "development":
default:
ENV_FILE_NAME = ".env"
break
}

try {
dotenv.config({ path: process.cwd() + "/" + ENV_FILE_NAME })
} catch (e) {}
loadEnv(process.env.NODE_ENV || "development", process.cwd())

// CORS when consuming Medusa from admin
const ADMIN_CORS =
process.env.ADMIN_CORS || "http://localhost:7000,http://localhost:7001"
// Medusa's docs are added for a better learning experience. Feel free to remove.
const ADMIN_CORS = `${
process.env.ADMIN_CORS?.length
? `${process.env.ADMIN_CORS},`
: "http://localhost:7000,http://localhost:7001,"
}https://docs.medusajs.com,https://medusa-docs-v2-git-docs-v2-medusajs.vercel.app,https://medusa-resources-git-docs-v2-medusajs.vercel.app`

// CORS to avoid issues when consuming Medusa from a client
const STORE_CORS = process.env.STORE_CORS || "http://localhost:8000"
// Medusa's docs are added for a better learning experience. Feel free to remove.
const STORE_CORS = `${
process.env.STORE_CORS?.length
? `${process.env.STORE_CORS},`
: "http://localhost:8000,"
}https://docs.medusajs.com,https://medusa-docs-v2-git-docs-v2-medusajs.vercel.app,https://medusa-resources-git-docs-v2-medusajs.vercel.app`

const DATABASE_URL =
process.env.DATABASE_URL || "postgres://medusa:password@localhost/medusa"

const REDIS_URL = process.env.REDIS_URL || "redis://localhost:6379"

const plugins = [
`medusa-fulfillment-manual`,
`medusa-payment-manual`,
{
resolve: `@medusajs/file-local`,
options: {
upload_dir: "uploads",
},
},
{
resolve: "@medusajs/admin",
/** @type {import('@medusajs/admin').PluginOptions} */
options: {
autoRebuild: true,
develop: {
open: process.env.OPEN_BROWSER !== "false",
export default defineConfig({
plugins: [
`medusa-fulfillment-manual`,
`medusa-payment-manual`,
{
resolve: `@medusajs/file-local`,
options: {
upload_dir: "uploads",
},
},
},
{
resolve: `medusa-plugin-meilisearch`,
options: {
config: {
host: process.env.MEILISEARCH_HOST,
apiKey: process.env.MEILISEARCH_API_KEY,
},
settings: {
products: {
indexSettings: {
searchableAttributes: ["title", "description", "variant_sku"],
displayedAttributes: [
"id",
"title",
"description",
"variant_sku",
"thumbnail",
"handle",
],
{
resolve: `medusa-plugin-meilisearch`,
options: {
config: {
host: process.env.MEILISEARCH_HOST,
apiKey: process.env.MEILISEARCH_API_KEY,
},
settings: {
products: {
indexSettings: {
searchableAttributes: ["title", "description", "variant_sku"],
displayedAttributes: [
"id",
"title",
"description",
"variant_sku",
"thumbnail",
"handle",
],
},
primaryKey: "id",
},
primaryKey: "id",
},
},
},
],
admin: {
backendUrl: "http://localhost:9000",
},
]

const modules = {
/*eventBus: {
resolve: "@medusajs/event-bus-redis",
options: {
redisUrl: REDIS_URL
}
projectConfig: {
databaseUrl: DATABASE_URL,
http: {
storeCors: STORE_CORS,
adminCors: ADMIN_CORS,
authCors: process.env.AUTH_CORS || ADMIN_CORS,
jwtSecret: process.env.JWT_SECRET || "supersecret",
cookieSecret: process.env.COOKIE_SECRET || "supersecret",
},
redisUrl: REDIS_URL,
},
cacheService: {
resolve: "@medusajs/cache-redis",
options: {
redisUrl: REDIS_URL
}
},*/
}

const projectConfig = {
jwtSecret: process.env.JWT_SECRET,
cookieSecret: process.env.COOKIE_SECRET,
store_cors: STORE_CORS,
database_url: DATABASE_URL,
admin_cors: ADMIN_CORS,
// Uncomment the following lines to enable REDIS
redis_url: REDIS_URL,
}

module.exports = {
projectConfig,
plugins,
modules,
}
})
4 changes: 3 additions & 1 deletion .github/workflows/test-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ jobs:
working-directory: ../
# https://docs.medusajs.com/cli/reference#options
run: |
medusa new backend \
medusa new cli-test \
-y \
--v2 \
--branch feat/v2 \
--skip-db \
--skip-migrations \
--skip-env \
Expand Down

0 comments on commit 6547d6b

Please sign in to comment.