Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ESSNTL-4196): group detail info + tests #1792

Merged
merged 4 commits into from
Mar 15, 2023
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
40 changes: 40 additions & 0 deletions src/components/InventoryGroupDetail/GroupDetailInfo.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { mount } from '@cypress/react';
import React from 'react';
import GroupDetailInfo from './GroupDetailInfo';

const mountPage = () =>
mount(
<GroupDetailInfo />
);

before(() => {
cy.window().then(
(window) =>
(window.insights = {
chrome: {
isProd: false,
auth: {
getUser: () => {
return Promise.resolve({});
}
}
}
})
);
});

describe('group detail information page', () => {
it('Title is rendered', () => {
mountPage();
cy.get('div[class="pf-c-card__title pf-c-title pf-m-lg card-title"]').should('have.text', 'User access configuration');
});
it('button is present', () => {
mountPage();
cy.get('button[class="pf-c-button pf-m-secondary"]').should('have.text', 'Manage access');
});
it('card text is present', () => {
mountPage();
cy.get('div[class="pf-c-card__body"]').should
('have.text', 'Manage your inventory group user access configuration under Identity & Access Management > User Access.');
});
});
37 changes: 26 additions & 11 deletions src/components/InventoryGroupDetail/GroupDetailInfo.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
import { EmptyState, EmptyStateBody, Spinner } from '@patternfly/react-core';
import { InvalidObject } from '@redhat-cloud-services/frontend-components';
import {
Button,
Card,
CardTitle,
CardBody,
CardHeader,
CardActions } from '@patternfly/react-core';
import React from 'react';
import { useSelector } from 'react-redux';

const GroupDetailInfo = () => {
const { uninitialized, loading } = useSelector((state) => state.groupDetail);

// TODO: implement according to mocks
const address = window.location.href.includes('beta') ? '/beta/iam/user-access' : '/iam/user-access';

return (
<EmptyState>
<EmptyStateBody>
{uninitialized || loading ? <Spinner /> : <InvalidObject />}
</EmptyStateBody>
</EmptyState>
<Card>
<CardHeader>
<CardActions>
<Button variant="secondary" >
<a
href={`${window.location.origin}/iam/user-access`}
>Manage access</a>
</Button>
</CardActions>
<CardTitle className="pf-c-title pf-m-lg card-title">User access configuration</CardTitle>
</CardHeader>
<CardBody>
Manage your inventory group user access configuration under
<a
href={`${window.location.origin}${address}`}
> Identity & Access Management {'>'} User Access.</a>
</CardBody>
</Card>
);
};

Expand Down