Skip to content

Commit

Permalink
fix: fe ci
Browse files Browse the repository at this point in the history
  • Loading branch information
LiteSun committed Apr 8, 2021
1 parent 132dcf4 commit 59dba3e
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 30 deletions.
4 changes: 3 additions & 1 deletion web/cypress/fixtures/selector.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,7 @@
"twentyPerPage": "[title=\"20 / page\"]",
"pageList": ".ant-table-pagination-right",
"pageTwo": ".ant-pagination-item-2",
"pageTwoActived": ".ant-pagination-item-2.ant-pagination-item-active"
"pageTwoActived": ".ant-pagination-item-2.ant-pagination-item-active",
"selectDropdown": ".ant-select-dropdown",
"codeMirrorMode":"[data-cy='code-mirror-mode']"
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ context('Delete Plugin List with the Drawer', () => {
cy.get('button').click({ force: true });
});

cy.get("[data-cy='code-mirror-mode']").invoke('text').then(text => {
cy.get(this.domSelector.codeMirrorMode).invoke('text').then(text => {
if (text === 'UIForm') {
cy.get("[data-cy='code-mirror-mode']").click();
cy.get(".ant-select-dropdown").should('be.visible');
cy.get(".ant-select-dropdown [label=JSON]").click();
cy.get(this.domSelector.codeMirrorMode).click();
cy.get(this.domSelector.selectDropdown).should('be.visible');
cy.get( this.domSelector.selectDropdown + " [label=JSON]" ).click();
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ context('Create Configure and Delete PluginTemplate', () => {
});
cy.focused(this.domSelector.drawer).should('exist');

cy.get("[data-cy='code-mirror-mode']").click();
cy.get('.ant-select-dropdown').should('be.visible');
cy.get(".ant-select-dropdown [label=JSON]").click();
cy.get(this.domSelector.codeMirrorMode).click();
cy.get(this.domSelector.selectDropdown).should('be.visible');
cy.get( this.domSelector.selectDropdown + " [label=JSON]" ).click();
cy.get(this.domSelector.disabledSwitcher).click({
force: true,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ context('Create and Delete Route', () => {
cy.get(this.domSelector.checkedSwitcher).should('exist');
});

cy.get("[data-cy='code-mirror-mode']").click();
cy.get('.ant-select-dropdown').should('be.visible');
cy.get(".ant-select-dropdown [label=JSON]").click();
cy.get(this.domSelector.codeMirrorMode).click();
cy.get(this.domSelector.selectDropdown).should('be.visible');
cy.get( this.domSelector.selectDropdown + " [label=JSON]" ).click();

cy.contains('button', 'Submit').click();
cy.get(this.domSelector.drawer, { timeout }).should('not.exist');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ context('Create and Delete Service ', () => {
cy.get(this.domSelector.checkedSwitcher).should('exist');
});

cy.get("[data-cy='code-mirror-mode']").click();
cy.get('.ant-select-dropdown').should('be.visible');
cy.get(".ant-select-dropdown [label=JSON]").click();
cy.get(this.domSelector.codeMirrorMode).click();
cy.get(this.domSelector.selectDropdown).should('be.visible');
cy.get( this.domSelector.selectDropdown + " [label=JSON]" ).click();
cy.contains('button', 'Submit').click();
cy.get(this.domSelector.drawer, { timeout }).should('not.exist');

Expand Down
34 changes: 18 additions & 16 deletions web/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,18 @@ Cypress.Commands.add('login', () => {

Cypress.Commands.add('configurePlugins', (cases) => {
const timeout = 300;
const domSelectors = {
const domSelector = {
name: '[data-cy-plugin-name]',
parents: '.ant-card-bordered',
drawer_wrap: '.ant-drawer-content-wrapper',
drawer: '.ant-drawer-content',
switch: '#disable',
close: '.anticon-close',
selectDropdown: '.ant-select-dropdown',
codeMirrorMode:'[data-cy="code-mirror-mode"]'
};

cy.get(domSelectors.name, { timeout }).then(function (cards) {
cy.get(domSelector.name, { timeout }).then(function (cards) {
[...cards].forEach((card) => {
const name = card.innerText;
const pluginCases = cases[name] || [];
Expand All @@ -54,17 +56,17 @@ Cypress.Commands.add('configurePlugins', (cases) => {
}

cy.contains(name)
.parents(domSelectors.parents)
.parents(domSelector.parents)
.within(() => {
cy.contains('Enable').click({
force: true,
});
});

// NOTE: wait for the Drawer to appear on the DOM
cy.focused(domSelectors.drawer).should('exist');
cy.get(domSelectors.drawer, { timeout }).within(() => {
cy.get(domSelectors.switch).click({
cy.focused(domSelector.drawer).should('exist');
cy.get(domSelector.drawer, { timeout }).within(() => {
cy.get(domSelector.switch).click({
force: true,
});
});
Expand All @@ -73,35 +75,35 @@ Cypress.Commands.add('configurePlugins', (cases) => {
if (codemirror) {
codemirror.setValue(JSON.stringify(data));
}
cy.get(domSelectors.drawer).should('exist');
cy.get(domSelector.drawer).should('exist');

cy.get("[data-cy='code-mirror-mode']").invoke('text').then(text => {
cy.get(domSelector.codeMirrorMode).invoke('text').then(text => {
if (text === 'UIForm') {
cy.get("[data-cy='code-mirror-mode']").click();
cy.get(".ant-select-dropdown").should('be.visible');
cy.get(".ant-select-dropdown [label=JSON]").click();
cy.get(domSelector.codeMirrorMode).click();
cy.get(domSelector.selectDropdown).should('be.visible');
cy.get(domSelector.selectDropdown + " [label=JSON]" ).click();
}
});

cy.get(domSelectors.drawer, { timeout }).within(() => {
cy.get(domSelector.drawer, { timeout }).within(() => {
cy.contains('Submit').click({
force: true,
});
cy.get(domSelectors.drawer).should('not.exist');
cy.get(domSelector.drawer).should('not.exist');
});
});

if (shouldValid === true) {
cy.get(domSelectors.drawer).should('not.exist');
cy.get(domSelector.drawer).should('not.exist');
} else if (shouldValid === false) {
cy.get(this.domSelector.notification).should('contain', 'Invalid plugin data');

cy.get(domSelectors.close).should('be.visible').click({
cy.get(domSelector.close).should('be.visible').click({
force: true,
multiple: true,
});

cy.get(domSelectors.drawer, { timeout })
cy.get(domSelector.drawer, { timeout })
.invoke('show')
.within(() => {
cy.contains('Cancel').click({
Expand Down

0 comments on commit 59dba3e

Please sign in to comment.