Skip to content

Commit

Permalink
Stabilize test cases (#4637)
Browse files Browse the repository at this point in the history
  • Loading branch information
sviatlana-stsiapanava authored Jan 15, 2025
1 parent 2a62c75 commit 51795c7
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 20 deletions.
52 changes: 44 additions & 8 deletions cypress/e2e/settings/tenant/location-setup.cy.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import uuid from 'uuid';
import { Permissions } from '../../../support/dictionary';
import { Locations, ServicePoints } from '../../../support/fragments/settings/tenant';
import TenantPane, { TENANTS } from '../../../support/fragments/settings/tenant/tenantPane';
import TopMenuNavigation from '../../../support/fragments/topMenuNavigation';
import Users from '../../../support/fragments/users/users';
import Campuses from '../../../support/fragments/settings/tenant/location-setup/campuses';
import Institutions from '../../../support/fragments/settings/tenant/location-setup/institutions';
import Libraries from '../../../support/fragments/settings/tenant/location-setup/libraries';
import getRandomPostfix from '../../../support/utils/stringTools';

describe('Settings: Tenant', () => {
const testData = {
Expand All @@ -15,12 +20,43 @@ describe('Settings: Tenant', () => {
cy.createTempUser([Permissions.settingsTenantViewLocation.gui]).then((userProperties) => {
testData.user = userProperties;
cy.getAdminToken().then(() => {
ServicePoints.createViaApi(testData.servicePoint);
const { institution, location } = Locations.getDefaultLocation({
servicePointId: testData.servicePoint.id,
testData.institution = Institutions.getDefaultInstitution({
id: uuid(),
name: `1_autotest_institution_${getRandomPostfix()}`,
});
testData.campus = Campuses.getDefaultCampuse({
id: uuid(),
name: `1_autotest_campuse_${getRandomPostfix()}`,
institutionId: testData.institution.id,
});
testData.institution = institution;
testData.location = location;
testData.library = Libraries.getDefaultLibrary({
id: uuid(),
name: `1_autotest_library_${getRandomPostfix()}`,
campusId: testData.campus.id,
});
testData.location = {
id: uuid(),
isActive: true,
institutionId: testData.institution.id,
institutionName: testData.institution.name,
campusId: testData.campus.id,
campusName: testData.campus.name,
libraryId: testData.library.id,
libraryName: testData.library.name,
servicePointIds: [testData.servicePoint.id],
name: `1_autotest_location_name_${getRandomPostfix()}`,
code: `1_autotest_location_code_${getRandomPostfix()}`,
discoveryDisplayName: `1_autotest_name_${getRandomPostfix()}`,
primaryServicePoint: testData.servicePoint.id,
};

Institutions.createViaApi(testData.institution).then(() => {
Campuses.createViaApi(testData.campus).then(() => {
Libraries.createViaApi(testData.library);
});
});

ServicePoints.createViaApi(testData.servicePoint);
Locations.createViaApi(testData.location);
});

Expand All @@ -44,12 +80,12 @@ describe('Settings: Tenant', () => {
() => {
cy.intercept('/location-units/institutions*', { locinsts: [testData.institution] });
// Select "Institutions" option on the "Location setup" subsection
const Institutions = TenantPane.selectTenant(TENANTS.INSTITUTIONS);
TenantPane.selectTenant(TENANTS.INSTITUTIONS);
Institutions.checkNoActionButtons();

// Select "Campuses" option on the "Location setup" subsection
// Select any existing institution from the "Select institution" dropdown
const Campuses = TenantPane.selectTenant(TENANTS.CAMPUSES);
TenantPane.selectTenant(TENANTS.CAMPUSES);
Campuses.selectOption('Institution', {
name: testData.location.institutionName,
id: testData.location.institutionId,
Expand All @@ -58,7 +94,7 @@ describe('Settings: Tenant', () => {

// Select "Libraries" option on the "Location setup" subsection
// Select any existing institution from the "Select institution" dropdown
const Libraries = TenantPane.selectTenant(TENANTS.LIBRARIES);
TenantPane.selectTenant(TENANTS.LIBRARIES);
Libraries.selectOption('Institution', {
name: testData.location.institutionName,
id: testData.location.institutionId,
Expand Down
45 changes: 42 additions & 3 deletions cypress/e2e/settings/tenant/service-points-view.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import NewLocation from '../../../support/fragments/settings/tenant/locations/ne
import ServicePoints from '../../../support/fragments/settings/tenant/servicePoints/servicePoints';
import SettingsMenu from '../../../support/fragments/settingsMenu';
import Users from '../../../support/fragments/users/users';
import TopMenu from '../../../support/fragments/topMenu';
import TopMenuNavigation from '../../../support/fragments/topMenuNavigation';
import getRandomPostfix from '../../../support/utils/stringTools';
import { APPLICATION_NAMES } from '../../../support/constants';

describe('Settings: Tenant', () => {
const testData = {
Expand All @@ -27,7 +29,44 @@ describe('Settings: Tenant', () => {
ServicePoints.createViaApi(servicePoint);
});

const location = NewLocation.getDefaultLocation(testData.servicePoints[0].id);
const location = {
id: uuid(),
isActive: true,
institutionId: uuid(),
institutionName: `1_autotest_institution_${getRandomPostfix()}`,
campusId: uuid(),
campusName: `1_autotest_campuse_${getRandomPostfix()}`,
libraryId: uuid(),
libraryName: `1_autotest_library_${getRandomPostfix()}`,
servicePointIds: [testData.servicePoints[0].id],
name: `1_autotest_location_name_${getRandomPostfix()}`,
code: `1_autotest_location_code_${getRandomPostfix()}`,
discoveryDisplayName: `1_autotest_name_${getRandomPostfix()}`,
primaryServicePoint: testData.servicePoints[0].id,
};

Institutions.createViaApi(
Institutions.getDefaultInstitution({
id: location.institutionId,
name: location.institutionName,
}),
).then(() => {
Campuses.createViaApi(
Campuses.getDefaultCampuse({
id: location.campusId,
name: location.campusName,
institutionId: location.institutionId,
}),
).then(() => {
Libraries.createViaApi(
Libraries.getDefaultLibrary({
id: location.libraryId,
name: location.libraryName,
campusId: location.campusId,
}),
);
});
});

[...Array(3).keys()].forEach((index) => {
testData.locations.push({
Expand All @@ -45,7 +84,7 @@ describe('Settings: Tenant', () => {

cy.login(testData.user.username, testData.user.password);
cy.wait(2000);
cy.visit(TopMenu.settingsPath);
TopMenuNavigation.navigateToApp(APPLICATION_NAMES.SETTINGS);
Locations.goToLocationsTab();
});
});
Expand Down
52 changes: 43 additions & 9 deletions cypress/e2e/settings/tenant/tenant-view.cy.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import uuid from 'uuid';
import { Permissions } from '../../../support/dictionary';
import { Locations, ServicePoints } from '../../../support/fragments/settings/tenant';
import TenantPane, { TENANTS } from '../../../support/fragments/settings/tenant/tenantPane';
import TopMenuNavigation from '../../../support/fragments/topMenuNavigation';
import Users from '../../../support/fragments/users/users';
import Campuses from '../../../support/fragments/settings/tenant/location-setup/campuses';
import Institutions from '../../../support/fragments/settings/tenant/location-setup/institutions';
import Libraries from '../../../support/fragments/settings/tenant/location-setup/libraries';
import getRandomPostfix from '../../../support/utils/stringTools';

describe('Settings: Tenant', () => {
const testData = {
Expand All @@ -11,11 +16,42 @@ describe('Settings: Tenant', () => {
before('Create test data', () => {
cy.getAdminToken();
ServicePoints.createViaApi(testData.servicePoint);
const { institution, location } = Locations.getDefaultLocation({
servicePointId: testData.servicePoint.id,

testData.institution = Institutions.getDefaultInstitution({
id: uuid(),
name: `1_autotest_institution_${getRandomPostfix()}`,
});
testData.campus = Campuses.getDefaultCampuse({
id: uuid(),
name: `1_autotest_campuse_${getRandomPostfix()}`,
institutionId: testData.institution.id,
});
testData.library = Libraries.getDefaultLibrary({
id: uuid(),
name: `1_autotest_library_${getRandomPostfix()}`,
campusId: testData.campus.id,
});
testData.location = {
id: uuid(),
isActive: true,
institutionId: testData.institution.id,
institutionName: testData.institution.name,
campusId: testData.campus.id,
campusName: testData.campus.name,
libraryId: testData.library.id,
libraryName: testData.library.name,
servicePointIds: [testData.servicePoint.id],
name: `1_autotest_location_name_${getRandomPostfix()}`,
code: `1_autotest_location_code_${getRandomPostfix()}`,
discoveryDisplayName: `1_autotest_name_${getRandomPostfix()}`,
primaryServicePoint: testData.servicePoint.id,
};

Institutions.createViaApi(testData.institution).then(() => {
Campuses.createViaApi(testData.campus).then(() => {
Libraries.createViaApi(testData.library);
});
});
testData.institution = institution;
testData.location = location;
Locations.createViaApi(testData.location);
cy.createTempUser([Permissions.settingsTenantView.gui]).then((userProperties) => {
testData.user = userProperties;
Expand All @@ -39,15 +75,13 @@ describe('Settings: Tenant', () => {
{ tags: ['extendedPath', 'firebird', 'C409487'] },
() => {
cy.intercept('/location-units/institutions*', { locinsts: [testData.institution] });
// reload is needed because sometimes Location setup section is not displayed
cy.reload();
// Select "Institutions" option on the "Location setup" subsection
const Institutions = TenantPane.selectTenant(TENANTS.INSTITUTIONS);
TenantPane.selectTenant(TENANTS.INSTITUTIONS);
Institutions.checkNoActionButtons();

// Select "Campuses" option on the "Location setup" subsection
// Select any existing institution from the "Select institution" dropdown
const Campuses = TenantPane.selectTenant(TENANTS.CAMPUSES);
TenantPane.selectTenant(TENANTS.CAMPUSES);
Campuses.selectOption('Institution', {
name: testData.location.institutionName,
id: testData.location.institutionId,
Expand All @@ -56,7 +90,7 @@ describe('Settings: Tenant', () => {

// Select "Libraries" option on the "Location setup" subsection
// Select any existing institution from the "Select institution" dropdown
const Libraries = TenantPane.selectTenant(TENANTS.LIBRARIES);
TenantPane.selectTenant(TENANTS.LIBRARIES);
Libraries.selectOption('Institution', {
name: testData.location.institutionName,
id: testData.location.institutionId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const saveButton = editFormRoot.find(Button('Save & close'));
export default {
waitLoading() {
cy.expect(editFormRoot.exists());
cy.wait(1000);
},
fillLocationForm({ servicePoint }) {
this.waitLoading();
Expand Down

0 comments on commit 51795c7

Please sign in to comment.