Skip to content

Commit

Permalink
Merge branch 'next' into 16174-fix-docs-args-hmr
Browse files Browse the repository at this point in the history
  • Loading branch information
shilman committed Oct 27, 2021
2 parents 2504e5a + eff5efe commit db17405
Show file tree
Hide file tree
Showing 9 changed files with 241 additions and 319 deletions.
16 changes: 8 additions & 8 deletions .circleci/config.yml
Expand Up @@ -27,7 +27,7 @@ executors:
environment:
NODE_OPTIONS: --max_old_space_size=3076
resource_class: <<parameters.class>>
sb_cypress_6_node_12:
sb_cypress_8_node_14:
parameters:
class:
description: The Resource class
Expand All @@ -37,8 +37,8 @@ executors:
working_directory: /tmp/storybook
docker:
# ⚠️ The Cypress docker image is based on Node.js one so be careful when updating it because it can also
# cause an upgrade of the Node.
- image: cypress/included:6.8.0
# cause an upgrade of Node.js version too. Cypress 8.5 image is based on Node.js 14
- image: cypress/included:8.7.0
environment:
NODE_OPTIONS: --max_old_space_size=3076
resource_class: <<parameters.class>>
Expand Down Expand Up @@ -169,7 +169,7 @@ jobs:
e2e-tests-extended:
executor:
class: medium
name: sb_cypress_6_node_12
name: sb_cypress_8_node_14
parallelism: 4
steps:
- when:
Expand Down Expand Up @@ -203,7 +203,7 @@ jobs:
e2e-tests-core:
executor:
class: large
name: sb_cypress_6_node_12
name: sb_cypress_8_node_14
parallelism: 2
steps:
- git-shallow-clone/checkout_advanced:
Expand All @@ -229,7 +229,7 @@ jobs:
cra-bench:
executor:
class: medium
name: sb_cypress_6_node_12
name: sb_cypress_8_node_14
working_directory: /tmp/storybook
steps:
- git-shallow-clone/checkout_advanced:
Expand All @@ -253,7 +253,7 @@ jobs:
e2e-tests-pnp:
executor:
class: medium
name: sb_cypress_6_node_12
name: sb_cypress_8_node_14
working_directory: /tmp/storybook
steps:
- git-shallow-clone/checkout_advanced:
Expand All @@ -276,7 +276,7 @@ jobs:
e2e-tests-examples:
executor:
class: small
name: sb_cypress_6_node_12
name: sb_cypress_8_node_14
steps:
- git-shallow-clone/checkout_advanced:
clone_options: '--depth 1 --verbose'
Expand Down
2 changes: 1 addition & 1 deletion app/vue/preset.js
@@ -1 +1 @@
module.exports = require('./dist/cjs/server/framework-preset-babel-vue');
module.exports = require('./dist/cjs/server/framework-preset-vue');
4 changes: 3 additions & 1 deletion cypress.json
@@ -1,5 +1,7 @@
{
"defaultCommandTimeout": 20000,
"requestTimeout": 20000,
"responseTimeout": 60000
"responseTimeout": 60000,
"viewportHeight": 800,
"viewportWidth": 1280
}
23 changes: 10 additions & 13 deletions cypress/helper.ts
Expand Up @@ -11,22 +11,19 @@ const getUrl = (route: string) => {
};

export const visit = (route = '') => {
return cy
.clearLocalStorage()
.visit(getUrl(route))
.get(`#storybook-preview-iframe`)
.then({ timeout: 15000 }, (iframe) => {
return cy.wrap(iframe, { timeout: 10000 }).should(() => {
const content: Document | null = (iframe[0] as HTMLIFrameElement).contentDocument;
const element: HTMLElement | null = content !== null ? content.documentElement : null;
cy.clearLocalStorage().visit(getUrl(route));
return cy.get(`#storybook-preview-iframe`).then({ timeout: 15000 }, (iframe) => {
return cy.wrap(iframe, { timeout: 10000 }).should(() => {
const content: Document | null = (iframe[0] as HTMLIFrameElement).contentDocument;
const element: HTMLElement | null = content !== null ? content.documentElement : null;

expect(element).not.null;
expect(element).not.null;

if (element !== null) {
expect(element.querySelector('#root > *')).not.null;
}
});
if (element !== null) {
expect(element.querySelector('#root > *')).not.null;
}
});
});
};

export const clickAddon = (addonName: Addons) => {
Expand Down
10 changes: 7 additions & 3 deletions cypress/integration/navigation.spec.ts
Expand Up @@ -6,15 +6,19 @@ describe('Navigation', () => {
});

it('should search navigation item', () => {
cy.get('#storybook-explorer-searchfield').click().clear().type('syntax');
cy.get('#storybook-explorer-searchfield').click({ force: true });
cy.get('#storybook-explorer-searchfield').clear();
cy.get('#storybook-explorer-searchfield').type('syntax');

cy.get('#storybook-explorer-menu button')
.should('contain', 'SyntaxHighlighter')
.and('not.contain', 'a11y');
});

it('should display no results after searching a non-existing navigation item', () => {
cy.get('#storybook-explorer-searchfield').click().clear().type('zzzzzzzzzz');
cy.get('#storybook-explorer-searchfield').click({ force: true });
cy.get('#storybook-explorer-searchfield').clear();
cy.get('#storybook-explorer-searchfield').type('zzzzzzzzzz');

cy.get('#storybook-explorer-menu button').should('be.hidden');
});
Expand All @@ -24,7 +28,7 @@ describe('Routing', () => {
it('should navigate to story addons-a11y-basebutton--default', () => {
visit('official-storybook');

cy.get('#addons-a11y-basebutton--label').click();
cy.get('#addons-a11y-basebutton--label').click({ force: true });
cy.url().should('include', 'path=/story/addons-a11y-basebutton--label');
});

Expand Down
7 changes: 6 additions & 1 deletion cypress/support/commands.js
Expand Up @@ -103,7 +103,12 @@ Cypress.Commands.add('navigateToStory', (kind, name) => {
if ($item.attr('aria-expanded') === 'false') $item.click();
});
}
cy.get(storyLinkId).click();
cy.get(storyLinkId).click({ force: true });

// FIXME: Find a way to not wait like this but check for an element in the UI
// A pause is good when switching stories
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(300);

// assert url changes
cy.url().should('include', `path=/story/${kindId}--${storyId}`);
Expand Down
8 changes: 8 additions & 0 deletions cypress/support/index.js
Expand Up @@ -16,5 +16,13 @@
// Import commands.js using ES2015 syntax:
import './commands';

// Turn off all uncaught exception handling
// https://docs.cypress.io/guides/references/migration-guide#Uncaught-exception-and-unhandled-rejections
Cypress.on('uncaught:exception', (err, runnable) => {
// returning false here prevents Cypress from
// failing the test
return false;
});

// Alternatively you can use CommonJS syntax:
// require('./commands')
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -318,8 +318,8 @@
},
"optionalDependencies": {
"@cypress/skip-test": "^2.6.1",
"@cypress/webpack-preprocessor": "^5.7.0",
"cypress": "6.8.0",
"@cypress/webpack-preprocessor": "^5.9.1",
"cypress": "8.7.0",
"puppeteer": "^2.1.1",
"ts-loader": "^8.0.14",
"verdaccio": "^4.10.0",
Expand Down

0 comments on commit db17405

Please sign in to comment.