Skip to content

Commit

Permalink
trying waitForFonts
Browse files Browse the repository at this point in the history
  • Loading branch information
jendiamond committed Oct 17, 2024
1 parent fed5ce2 commit d98a19f
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 17 deletions.
4 changes: 1 addition & 3 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

import { setup } from "@storybook/vue3"
import type { Preview } from "@storybook/vue3"
import "ucla-library-design-tokens/scss/app-global.scss"
Expand Down Expand Up @@ -60,9 +61,6 @@ export const parameters = {
},
},
}

export const decorators = [ (Story) => { document.fonts.ready.then(() => Story()); return <Story />; }, ];

setup((app) => {
app.use(router)
app.use(createPinia())
Expand Down
15 changes: 7 additions & 8 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
Cypress.Commands.add('waitForFontsToLoad', () => {
return cy.window().then((win) => {
return new Promise((resolve) => {
if (win.document.fonts.status === 'loaded') {
resolve(); // Fonts are already loaded
} else {
win.document.fonts.ready.then(resolve); // Wait until fonts are ready
}
});
});
});
if (win.document.fonts.status === 'loaded')
resolve() // Fonts are already loaded
else
win.document.fonts.ready.then(resolve) // Wait until fonts are ready
})
})
})

// ***********************************************
// This example commands.ts shows you how to
Expand Down
2 changes: 1 addition & 1 deletion src/stories/BannerFeatured.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('BannerFeatured', () => {
)
cy.get('.banner-featured').should('exist')

// Wait for fonts to load before proceeding
// Wait for fonts to load before proceeding
cy.waitForFontsToLoad().then(() => {
// Now take Percy snapshot
cy.percySnapshot('Banner Featured: Defaul')
Expand Down
2 changes: 1 addition & 1 deletion src/stories/BlockEventDetail.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('BlockEventDetail', () => {
)
cy.get('.block-event-detail').should('exist')

// Wait for fonts to load before proceeding
// Wait for fonts to load before proceeding
cy.waitForFontsToLoad().then(() => {
// Now take Percy snapshot
cy.percySnapshot('BLOCK / Event Detail: Default')
Expand Down
3 changes: 1 addition & 2 deletions src/stories/ButtonShow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ describe('BUTTON / Show', () => {
cy.visit('/iframe.html?id=button-show--default&args=&viewMode=story')
cy.get('.button-show').should('exist')


// Wait for fonts to load before proceeding
// Wait for fonts to load before proceeding
cy.waitForFontsToLoad().then(() => {
// Now take Percy snapshot
cy.percySnapshot('BUTTON / Show: Default')
Expand Down
2 changes: 1 addition & 1 deletion src/stories/Flexible_MediaWithText.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('FLEXIBLE / Media With Text', () => {
)
cy.get('.section-media-with-text').should('exist')

// Wait for fonts to load before proceeding
// Wait for fonts to load before proceeding
cy.waitForFontsToLoad().then(() => {
// Now take Percy snapshot
cy.percySnapshot('FLEXIBLE / Media With Text: Default')
Expand Down
2 changes: 1 addition & 1 deletion src/stories/RichText.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('GLOBAL/ Rich Text', () => {
)
cy.get('.rich-text').should('exist')

// Wait for fonts to load before proceeding
// Wait for fonts to load before proceeding
cy.waitForFontsToLoad().then(() => {
// Now take Percy snapshot
cy.percySnapshot('Global / Rich Text: Default')
Expand Down

0 comments on commit d98a19f

Please sign in to comment.