Skip to content

Commit

Permalink
feat:add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Aug 12, 2022
1 parent 3243300 commit 827f4bf
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ context('Delete Plugin List with the Drawer', () => {
checkedSwitcher: '.ant-switch-checked',
refresh: '.anticon-reload',
empty: '.ant-empty-normal',
tab: '.ant-tabs-tab',
tabBtn: '.ant-tabs-tab-btn',
};

const data = {
Expand Down Expand Up @@ -109,4 +111,56 @@ context('Delete Plugin List with the Drawer', () => {
});
cy.get(selector.empty).should('be.visible');
});

it('should switch tabs to distinguish with enable or not enbale', function () {
cy.visit('/plugin/list');
cy.get(selector.refresh).click();
cy.contains('button', 'Enable').click();
cy.contains(data.basicAuthPlugin)
.parents(selector.pluginCardBordered)
.within(() => {
cy.get('button').click({
force: true,
});
});
cy.get(selector.drawer)
.should('be.visible')
.within(() => {
cy.get(selector.disabledSwitcher).click();
cy.get(selector.checkedSwitcher).should('exist');
});
cy.contains('button', 'Submit').click();
cy.contains(data.basicAuthPlugin).should('not.exist');

cy.get(selector.tab).within(() => {
cy.contains(selector.tabBtn, 'Edit').click({
force: true,
});
});

cy.contains(data.basicAuthPlugin)
.parents(selector.pluginCardBordered)
.within(() => {
cy.get('button').click({
force: true,
});
});

cy.contains('button', 'Delete').click({
force: true,
});
cy.contains('button', 'Confirm').click({
force: true,
});

cy.contains(data.basicAuthPlugin).should('not.exist');
cy.get(selector.tab).within(() => {
cy.contains(selector.tabBtn, 'Enable').click({
force: true,
});
});
cy.contains(data.basicAuthPlugin).should('exist');
cy.visit('/plugin/list');
cy.get(selector.empty).should('be.visible');
});
});
21 changes: 10 additions & 11 deletions web/src/components/Plugin/PluginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,6 @@ const PanelSectionStyle = {
width: 'calc(100% - 20px)',
};

const tabsList = [
{
title: 'Not Enable',
key: 'add',
},
{
title: 'Enable',
key: 'edit',
},
];

const { Sider, Content } = Layout;

// NOTE: use this flag as plugin's name to hide drawer
Expand Down Expand Up @@ -112,6 +101,16 @@ const PluginPage: React.FC<Props> = ({
});

const [selectedTab, setSelectedTab] = useState<string>('add');
const tabsList = [
{
title: formatMessage({ id: 'component.plugin.enable' }),
key: 'add',
},
{
title: formatMessage({ id: 'component.plugin.disable' }),
key: 'edit',
},
];
const SwitchTab = () => (
<Tabs
defaultActiveKey={selectedTab}
Expand Down
5 changes: 1 addition & 4 deletions web/src/pages/Plugin/PluginMarket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ const PluginMarket: React.FC = () => {
schemaType="route"
onChange={(pluginsData) => {
createOrUpdate({
plugins: {
...initialData,
...pluginsData,
},
plugins: pluginsData,
}).then(() => {
initPageData();
});
Expand Down

0 comments on commit 827f4bf

Please sign in to comment.