Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ beforeAll(async () => {
});

afterAll(async () => {
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.collections.Groups.deleteMany({});
await testApp.stop();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ beforeAll(async () => {
});

afterAll(async () => {
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.Catalog.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.stop();
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/api/mutations/addTag/addTag.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ beforeAll(async () => {
});

afterAll(async () => {
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.stop();
});

beforeEach(async () => {
tagInput = {
displayTitle: "Tag: Display Title",
Expand Down Expand Up @@ -67,6 +70,7 @@ describe("unauthorized user", () => {
}
});
});

describe("authorized user", () => {
beforeAll(async () => {
await testApp.setLoggedInUser(mockTagsAccount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ beforeAll(async () => {
});

afterAll(async () => {
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.Discounts.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ afterAll(async () => {
await testApp.collections.Products.deleteOne({ _id: internalVariantIds[0] });
await testApp.collections.Products.deleteOne({ _id: internalVariantIds[1] });
await testApp.collections.Products.deleteOne({ _id: internalVariantIds[2] });
await testApp.collections.Tags.deleteMany({});
await testApp.clearLoggedInUser();
await testApp.stop();
});
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/api/mutations/removeTag/removeTag.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ beforeAll(async () => {
});

afterAll(async () => {
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.stop();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ beforeAll(async () => {
});

afterAll(async () => {
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.Catalog.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ beforeAll(async () => {
});

afterAll(async () => {
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.Catalog.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.stop();
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/api/mutations/updateTag/updateTag.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ beforeAll(async () => {
});

afterAll(async () => {
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.collections.Tags.deleteMany({});
await testApp.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ beforeAll(async () => {

afterAll(async () => {
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.stop();
});
Expand Down
6 changes: 5 additions & 1 deletion tests/integration/api/queries/account/account.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ beforeAll(async () => {
accountQuery = testApp.query(AccountFullQuery);
});

afterAll(() => testApp.stop());
afterAll(async () => {
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.stop();
});

test("unauthenticated", async () => {
try {
Expand Down
1 change: 1 addition & 0 deletions tests/integration/api/queries/account/accounts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ beforeAll(async () => {

afterAll(async () => {
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.Groups.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ beforeAll(async () => {
administratorsQuery = testApp.query(AdministratorsFullQuery);
});

afterAll(() => testApp.stop());
afterAll(async () => {
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.stop();
});

test("unauthenticated", async () => {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ beforeAll(async () => {
});

afterAll(async () => {
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.Discounts.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ beforeAll(async () => {
});

afterAll(async () => {
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.Templates.deleteMany({});
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.Shops.deleteMany({});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const mockFulfillmentRestriction = {
}
};

const mockOwenrAccount = Factory.Account.makeOne({
const mockOwnerAccount = Factory.Account.makeOne({
roles: {
[internalShopId]: ["owner"]
},
Expand All @@ -43,20 +43,21 @@ beforeAll(async () => {

await testApp.insertPrimaryShop({ _id: internalShopId, name: shopName });
await testApp.collections.FlatRateFulfillmentRestrictions.insertOne(mockFulfillmentRestriction);
await testApp.createUserAndAccount(mockOwenrAccount);
await testApp.createUserAndAccount(mockOwnerAccount);
getFlatRateFulfillmentRestriction = testApp.query(FlatRateFulfillmentRestrictionQuery);
});

afterAll(async () => {
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.FlatRateFulfillmentRestrictions.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.stop();
});

test("a shop owner can query for a flat rate fulfillment restriction", async () => {
let result;
await testApp.setLoggedInUser(mockOwenrAccount);
await testApp.setLoggedInUser(mockOwnerAccount);

try {
result = await getFlatRateFulfillmentRestriction({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ beforeAll(async () => {

afterAll(async () => {
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.FlatRateFulfillmentRestrictions.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.stop();
Expand Down
9 changes: 8 additions & 1 deletion tests/integration/api/queries/group/group.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,14 @@ beforeAll(async () => {
groupQuery = testApp.query(GroupFullQuery);
});

afterAll(() => testApp.stop());
afterAll(async () => {
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.Groups.deleteMany({});
await testApp.collections.Shops.deleteMany({});

await testApp.stop();
});

test("unauthenticated", async () => {
try {
Expand Down
8 changes: 7 additions & 1 deletion tests/integration/api/queries/groups/groups.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ beforeAll(async () => {
groupsQuery = testApp.query(GroupsFullQuery);
});

afterAll(() => testApp.stop());
afterAll(async () => {
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.Groups.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.stop();
});

test("unauthenticated", async () => {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ beforeAll(async () => {

afterAll(async () => {
await testApp.collections.NavigationItems.deleteMany({});
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.stop();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ beforeAll(async () => {
afterAll(async () => {
await testApp.collections.NavigationItems.deleteMany({});
await testApp.collections.NavigationTrees.deleteMany({});
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.stop();
});
Expand Down
7 changes: 6 additions & 1 deletion tests/integration/api/queries/orderById/orderById.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ beforeEach(async () => {
await testApp.collections.Orders.deleteMany({});
});

afterAll(() => testApp.stop());
afterAll(async () => {
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.stop();
});

test("get account order success", async () => {
await testApp.collections.Orders.insertOne(order);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ beforeEach(async () => {
afterAll(async () => {
await testApp.collections.Orders.deleteMany({});
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.stop();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ beforeAll(async () => {

afterAll(async () => {
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.collections.Packages.deleteMany({});
await testApp.stop();
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/api/queries/ping/ping.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ beforeAll(async () => {
}`);
});

afterAll(() => testApp.stop());
afterAll(async () => {
await testApp.stop();
});

test("simple test ping", async () => {
const result = await pingQuery();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ beforeAll(async () => {
}`);
});

afterAll(() => testApp.stop());
afterAll(async () => {
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.stop();
});

test("get primaryShop, no auth necessary", async () => {
const result = await primaryShopQuery();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ beforeAll(async () => {
}`);
});

afterAll(() => testApp.stop());
afterAll(async () => {
await testApp.collections.Shops.deleteMany({});
await testApp.stop();
});

test("get primaryShopId, no auth necessary", async () => {
const result = await primaryShopIdQuery();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ beforeAll(async () => {
});

afterAll(async () => {
await testApp.collections.Shops.deleteOne({ _id: internalShopId });
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.collections.Tags.deleteOne({ _id: mockTagWithFeatured._id });
await Promise.all(mockProductsWithTagAndFeaturedProducts.map((mockProduct) => testApp.collections.Products.deleteOne({ _id: mockProduct._id })));
await testApp.clearLoggedInUser();
Expand Down
1 change: 1 addition & 0 deletions tests/integration/api/queries/roles/roles.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ beforeAll(async () => {

afterAll(async () => {
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.stop();
});
Expand Down
5 changes: 4 additions & 1 deletion tests/integration/api/queries/shop/shop.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ beforeAll(async () => {
}`);
});

afterAll(() => testApp.stop());
afterAll(async () => {
await testApp.collections.Shops.deleteMany({});
await testApp.stop();
});

test("get shop, no auth necessary", async () => {
const opaqueShopId = encodeOpaqueId("reaction/shop", shopId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ beforeAll(async () => {

afterAll(async () => {
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.AppSettings.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.collections.AppSettings.deleteMany({});
await testApp.stop();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ beforeAll(async () => {

afterAll(async () => {
await testApp.collections.Products.deleteMany({});
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.stop();
});
Expand Down
1 change: 1 addition & 0 deletions tests/integration/api/queries/tags/tag.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ beforeAll(async () => {

afterAll(async () => {
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.collections.Tags.deleteMany({});
await testApp.clearLoggedInUser();
Expand Down
6 changes: 5 additions & 1 deletion tests/integration/api/queries/tags/tags.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ beforeAll(async () => {
await Promise.all(mockTags.map((tag) => testApp.collections.Tags.insertOne(tag)));
});

afterAll(() => testApp.stop());
afterAll(async () => {
await testApp.collections.Tags.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.stop();
});

test("get the first 20 tags when neither first or last is in query", async () => {
let result;
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/api/queries/taxRates/taxRates.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ beforeAll(async () => {

afterAll(async () => {
await testApp.collections.Taxes.deleteMany({});
await testApp.collections.Accounts.deleteMany({});
await testApp.collections.users.deleteMany({});
await testApp.collections.Shops.deleteMany({});
await testApp.stop();
});
Expand Down
Loading