chore(tests): Try to use the api integration tests for v2 (#6588)
Few things to keep in mind: 1. You need to set MEDUSA_FF_MEDUSA_V2 to true before running the tests to run with the v2 API 2. You can use the `breaking` function to differentiate between v1 and v2 differences. This can help us identify what was breaking pretty quickly afterwards 3. You will need to run specific tests for now instead of all if you want to target v2. I think that's fine though, as we don't really need these to run on every PR until we have feature parity (and by then, all tests would be both v1 and v2 compatible) **note: Adrien** - add a new way to load modules only to run their loaders comparable to the way to run the migrations only - improve tests runner to cleanup the data properly as well as re running all loaders and core defaults Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
This commit is contained in:
1 parent
000eb61e33
commit
12b035cb18
76 files changed
+773
-371
No files matched your search
@@ -1,8 +1,12 @@
|
||||
import * as entities from "./src/models"
|
||||
import { TSMigrationGenerator } from "@medusajs/utils"
|
||||
|
||||
module.exports = {
|
||||
entities: Object.values(entities),
|
||||
schema: "public",
|
||||
clientUrl: "postgres://postgres@localhost/medusa-region",
|
||||
type: "postgresql",
|
||||
migrations: {
|
||||
generator: TSMigrationGenerator,
|
||||
},
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import { Country, Region } from "@models"
|
||||
|
||||
export const LinkableKeys = {
|
||||
region_id: Region.name,
|
||||
country_id: Region.name,
|
||||
country_iso: Country.name,
|
||||
}
|
||||
|
||||
const entityLinkableKeysMap: MapToConfig = {}
|
||||
|
||||
@@ -26,14 +26,13 @@ ${generatePostgresAlterColummnIfExistStatement(
|
||||
CREATE INDEX IF NOT EXISTS "IDX_region_deleted_at" ON "region" ("deleted_at") WHERE "deleted_at" IS NOT NULL;
|
||||
-- Create or update "region_country" table
|
||||
CREATE TABLE IF NOT EXISTS "region_country" (
|
||||
"id" text NOT NULL,
|
||||
"iso_2" text NOT NULL,
|
||||
"iso_3" text NOT NULL,
|
||||
"num_code" int NOT NULL,
|
||||
"name" text NOT NULL,
|
||||
"display_name" text NOT NULL,
|
||||
"region_id" text NULL,
|
||||
CONSTRAINT "region_country_pkey" PRIMARY KEY ("id")
|
||||
CONSTRAINT "region_country_pkey" PRIMARY KEY ("iso_2")
|
||||
);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS "IDX_region_country_region_id_iso_2_unique" ON "region_country" (region_id, iso_2);
|
||||
-- Adjust foreign keys for "region_country"
|
||||
|
||||
@@ -1,18 +1,6 @@
|
||||
import {
|
||||
BeforeCreate,
|
||||
Entity,
|
||||
Unique,
|
||||
ManyToOne,
|
||||
OnInit,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
Index,
|
||||
} from "@mikro-orm/core"
|
||||
import { Entity, ManyToOne, PrimaryKey, Property } from "@mikro-orm/core"
|
||||
|
||||
import {
|
||||
createPsqlIndexStatementHelper,
|
||||
generateEntityId,
|
||||
} from "@medusajs/utils"
|
||||
import { createPsqlIndexStatementHelper } from "@medusajs/utils"
|
||||
import Region from "./region"
|
||||
|
||||
// We don't need a partial index on deleted_at here since we don't support soft deletes on countries
|
||||
@@ -28,8 +16,6 @@ RegionIdIsoIndexStatement.MikroORMIndex()
|
||||
@Entity({ tableName: "region_country" })
|
||||
export default class Country {
|
||||
@PrimaryKey({ columnType: "text" })
|
||||
id: string
|
||||
|
||||
@Property({ columnType: "text" })
|
||||
iso_2: string
|
||||
|
||||
@@ -55,14 +41,4 @@ export default class Country {
|
||||
onDelete: "set null",
|
||||
})
|
||||
region?: Region | null
|
||||
|
||||
@BeforeCreate()
|
||||
onCreate() {
|
||||
this.id = generateEntityId(this.id, "reg_ctry")
|
||||
}
|
||||
|
||||
@OnInit()
|
||||
onInit() {
|
||||
this.id = generateEntityId(this.id, "reg_ctry")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user