Skip to content

Commit

Permalink
test: Remove unnecessary window chrome mock
Browse files Browse the repository at this point in the history
  • Loading branch information
gkarat committed Nov 15, 2023
1 parent 1ce3907 commit 7a3136c
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 39 deletions.
6 changes: 1 addition & 5 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,8 @@ Cypress.Commands.add('mountWithContext', (Component, options = {}, props) => {

// one of the fec dependencies talks to window.insights.chrome
Cypress.Commands.add(
'mockWindowChrome',
'mockWindowInsights',
({ userPermissions } = { userPermissions: ['*:*:*'] }) => {
window.chrome = {
...window.chrome,
getApp: () => 'inventory',
};
window.insights = {
...window.insights,
chrome: {
Expand Down
6 changes: 3 additions & 3 deletions src/components/GroupSystems/GroupSystems.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('test data', () => {
});

before(() => {
cy.mockWindowChrome();
cy.mockWindowInsights();
});

describe('renders correctly', () => {
Expand Down Expand Up @@ -457,7 +457,7 @@ describe('integration with rbac', () => {

describe('has only read permissions', () => {
before(() => {
cy.mockWindowChrome({
cy.mockWindowInsights({
userPermissions: READ_PERMISSIONS_WITH_RD,
});
});
Expand All @@ -481,7 +481,7 @@ describe('integration with rbac', () => {

describe('has groups write permissions', () => {
before(() => {
cy.mockWindowChrome({
cy.mockWindowInsights({
userPermissions: [
...READ_PERMISSIONS_WITH_RD,
...WRITE_PERMISSIONS_WITH_RD,
Expand Down
6 changes: 3 additions & 3 deletions src/components/GroupsTable/GroupsTable.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const mountTable = (initialEntry = '/') =>
});

before(() => {
cy.mockWindowChrome();
cy.mockWindowInsights();
});

const waitTable = () =>
Expand Down Expand Up @@ -427,7 +427,7 @@ describe('edge cases', () => {
describe('integration with rbac', () => {
describe('with only groups read', () => {
before(() => {
cy.mockWindowChrome({ userPermissions: ['inventory:groups:read'] });
cy.mockWindowInsights({ userPermissions: ['inventory:groups:read'] });
});

beforeEach(() => {
Expand Down Expand Up @@ -455,7 +455,7 @@ describe('integration with rbac', () => {

describe('with the write permissions for some groups', () => {
before(() => {
cy.mockWindowChrome({
cy.mockWindowInsights({
userPermissions: [
'inventory:groups:read',
{
Expand Down
2 changes: 1 addition & 1 deletion src/components/ImmutableDevices/ImmutableDevices.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const mountWithProps = (props) => {
};

before(() => {
cy.mockWindowChrome();
cy.mockWindowInsights();
});

describe('ImmutableDevices', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/InventoryGroupDetail/GroupDetailInfo.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const mountPage = (params) =>

describe('group detail information page', () => {
before(() => {
cy.mockWindowChrome({ userPermissions: ['rbac:*:*'] });
cy.mockWindowInsights({ userPermissions: ['rbac:*:*'] });
});

beforeEach(() => {
Expand Down Expand Up @@ -42,7 +42,7 @@ describe('group detail information page', () => {

describe('with no user access administrator role', () => {
beforeEach(() => {
cy.mockWindowChrome({ userPermissions: [] });
cy.mockWindowInsights({ userPermissions: [] });
mountPage({ chrome: { isBeta: () => true } });
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const mountPage = () =>
});

before(() => {
cy.mockWindowChrome(); // with all permissions
cy.mockWindowInsights(); // with all permissions
});

const waitPageLoad = () =>
Expand Down Expand Up @@ -95,7 +95,7 @@ describe('group detail page', () => {
describe('integration with rbac', () => {
describe('no permissions', () => {
before(() => {
cy.mockWindowChrome({ userPermissions: [] });
cy.mockWindowInsights({ userPermissions: [] });
});

beforeEach(() => {
Expand Down Expand Up @@ -133,7 +133,7 @@ describe('integration with rbac', () => {

describe('only groups read permissions', () => {
before(() => {
cy.mockWindowChrome({
cy.mockWindowInsights({
userPermissions: [
{
permission: 'inventory:groups:read',
Expand Down Expand Up @@ -182,7 +182,7 @@ describe('integration with rbac', () => {

describe('only group read and hosts read permission', () => {
before(() => {
cy.mockWindowChrome({
cy.mockWindowInsights({
userPermissions: [
'inventory:hosts:read',
{
Expand Down
4 changes: 2 additions & 2 deletions src/components/InventoryGroups/InventoryGroups.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import InventoryGroups from './InventoryGroups';
const mountPage = () => cy.mountWithContext(InventoryGroups);

before(() => {
cy.mockWindowChrome();
cy.mockWindowInsights();
});

describe('groups table page', () => {
Expand Down Expand Up @@ -44,7 +44,7 @@ describe('groups table page', () => {
describe('integration with rbac', () => {
it('disables empty state button when not enough permissions', () => {
interceptors['successful empty']();
cy.mockWindowChrome({ userPermissions: [] });
cy.mockWindowInsights({ userPermissions: [] });
mountPage();

cy.ouiaId('CreateGroupButton').shouldHaveAriaDisabled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const mountModal = (
describe('AddSelectedHostsToGroupModal', () => {
describe('without any permissions', () => {
before(() => {
cy.mockWindowChrome({
cy.mockWindowInsights({
userPermissions: [],
});
});
Expand All @@ -42,7 +42,7 @@ describe('AddSelectedHostsToGroupModal', () => {

describe('with limited groups write permissions', () => {
it('should still hide the create group button', () => {
cy.mockWindowChrome({
cy.mockWindowInsights({
userPermissions: [
{
resourceDefinitions: [
Expand All @@ -66,7 +66,7 @@ describe('AddSelectedHostsToGroupModal', () => {

describe('with groups write permission', () => {
before(() => {
cy.mockWindowChrome({
cy.mockWindowInsights({
userPermissions: ['inventory:groups:write'],
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const AVAILABLE_FILTER_NAMES = [
const ALERT = '[data-ouia-component-type="PF4/Alert"]';

before(() => {
cy.mockWindowChrome();
cy.mockWindowInsights();
});

const mountModal = () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const mockResponse = [

describe('Create Group Modal', () => {
before(() => {
cy.mockWindowChrome();
cy.mockWindowInsights();
});

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fixtures.results = [

describe('Delete Group Modal', () => {
before(() => {
cy.mockWindowChrome();
cy.mockWindowInsights();
});

describe('multiple hosts', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('test data', () => {

describe('render the modal', () => {
before(() => {
cy.mockWindowChrome();
cy.mockWindowInsights();
});

beforeEach(setInterceptors);
Expand Down
4 changes: 2 additions & 2 deletions src/components/InventoryTable/InventoryTable.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const setTableInterceptors = () => {

describe('with default parameters', () => {
before(() => {
cy.mockWindowChrome();
cy.mockWindowInsights();
});

beforeEach(() => {
Expand Down Expand Up @@ -246,7 +246,7 @@ describe('with default parameters', () => {
});

describe('hiding filters', () => {
before(cy.mockWindowChrome);
before(cy.mockWindowInsights);

beforeEach(() => setTableInterceptors());

Expand Down
2 changes: 1 addition & 1 deletion src/components/InventoryTabs/HybridInventoryTabs.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const mountWithProps = (props) => {
};

before(() => {
cy.mockWindowChrome();
cy.mockWindowInsights();
});

describe('When edge parity feature is enabled', () => {
Expand Down
8 changes: 4 additions & 4 deletions src/routes/InventoryDetail.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ hostInGroup.results[0].groups = [
hostInGroup.results[0].system_profile.operating_system.name = 'RHEL';

describe('renders correctly', () => {
before(() => cy.mockWindowChrome());
before(() => cy.mockWindowInsights());
beforeEach(() => prepareTest());

it('renders main components for edge host', () => {
Expand All @@ -67,7 +67,7 @@ describe('renders correctly', () => {

describe('rbac integration', () => {
describe('with no permissions', () => {
before(() => cy.mockWindowChrome({ userPermissions: [] }));
before(() => cy.mockWindowInsights({ userPermissions: [] }));
beforeEach(() => prepareTest(hostInGroup));

it('should disable delete and edit buttons', () => {
Expand All @@ -90,7 +90,7 @@ describe('rbac integration', () => {

describe('with write permissions limited by group', () => {
before(() =>
cy.mockWindowChrome({
cy.mockWindowInsights({
userPermissions: [
{
permission: 'inventory:hosts:write',
Expand Down Expand Up @@ -124,7 +124,7 @@ describe('rbac integration', () => {

describe('with excluding group permissions', () => {
before(() =>
cy.mockWindowChrome({
cy.mockWindowInsights({
userPermissions: [
{
permission: 'inventory:hosts:write',
Expand Down
10 changes: 5 additions & 5 deletions src/routes/InventoryTable.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const waitForTable = (waitNetwork = false) => {
};

before(() => {
cy.mockWindowChrome();
cy.mockWindowInsights();
});

describe('test data', () => {
Expand Down Expand Up @@ -235,7 +235,7 @@ describe('inventory table', () => {
describe('integration with rbac', () => {
describe('with only read permissions', () => {
before(() => {
cy.mockWindowChrome({
cy.mockWindowInsights({
userPermissions: ['inventory:*:read'],
});
});
Expand Down Expand Up @@ -273,7 +273,7 @@ describe('inventory table', () => {

describe('with group-level hosts write permissions', () => {
before(() => {
cy.mockWindowChrome({
cy.mockWindowInsights({
userPermissions: [
'inventory:*:read',
{
Expand Down Expand Up @@ -352,7 +352,7 @@ describe('inventory table', () => {

describe('with excluding group-level hosts write permissions', () => {
before(() => {
cy.mockWindowChrome({
cy.mockWindowInsights({
userPermissions: [
'inventory:*:read',
{
Expand Down Expand Up @@ -402,7 +402,7 @@ describe('inventory table', () => {

describe('with limited groups write permissions', () => {
before(() => {
cy.mockWindowChrome({
cy.mockWindowInsights({
userPermissions: [
'inventory:*:read',
{
Expand Down

0 comments on commit 7a3136c

Please sign in to comment.