Clear created data after test
MODIFY
test/api/SiteAreaOrgTest.ts
test/api/SiteAreaOrgTest.ts
@@ -32,6 +32,7 @@ class TestData {
public siteAreaWithSiteAdmin: SiteArea;
public siteAreaWithoutSiteAdmin: SiteArea;
public createdSiteAreas: any[] = [];
+ public createdSites: any[] = [];
public createdUsers: any[] = [];
}
@@ -63,6 +64,7 @@ async function createSiteWithoutSiteAdmin() {
testData.userService.siteApi,
siteData
);
+ testData.createdSites.push(testData.siteWithoutSiteAdmin);
}
/**
@@ -75,6 +77,7 @@ async function createSiteWithSiteAdmin() {
Factory.site.build({ companyID: testData.tenantContext.getContext().companies[0].id })
);
await assignSiteAdmin(ContextDefinition.USER_CONTEXTS.BASIC_USER, testData.siteWithSiteAdmin);
+ testData.createdSites.push(testData.siteWithSiteAdmin);
}
/**
@@ -125,6 +128,15 @@ describe('Site Area tests', function() {
);
});
testData.createdSiteAreas = [];
+ // Delete any created site
+ testData.createdSites.forEach(async (site) => {
+ await testData.centralUserService.deleteEntity(
+ testData.centralUserService.siteApi,
+ site,
+ false
+ );
+ });
+ testData.createdSiteAreas = [];
// Delete any created user
testData.createdUsers.forEach(async (user) => {
await testData.centralUserService.deleteEntity(
@@ -290,16 +302,19 @@ describe('Site Area tests', function() {
testData.userService.siteAreaApi,
Factory.siteArea.build({ siteID: testData.siteWithSiteAdmin.id })
);
+ testData.createdSiteAreas.push(testData.siteAreaWithSiteAdmin);
await createSiteWithoutSiteAdmin();
testData.siteAreaWithoutSiteAdmin = await testData.userService.createEntity(
testData.userService.siteAreaApi,
Factory.siteArea.build({ siteID: testData.siteWithoutSiteAdmin.id })
);
+ testData.createdSiteAreas.push(testData.siteAreaWithoutSiteAdmin);
// Create the entity
testData.newSiteArea = await testData.userService.createEntity(
testData.userService.siteAreaApi,
Factory.siteArea.build({ siteID: testData.siteContext.getSite().id })
);
+ testData.createdSiteAreas.push(testData.newSiteArea);
testData.testAsset = await testData.userService.createEntity(
testData.userService.assetApi,
Factory.asset.build({

Clear created data after test