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

Font Library: Add upload font test #60221

Merged
merged 17 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
Binary file added test/e2e/assets/Exo2-Regular.woff
Binary file not shown.
Binary file added test/e2e/assets/Exo2-SemiBoldItalic.woff2
Binary file not shown.
79 changes: 64 additions & 15 deletions test/e2e/specs/site-editor/font-library.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,64 @@ test.describe( 'Font Library', () => {
} );

test( 'should display the "Manage Fonts" icon', async ( { page } ) => {
await page.getByRole( 'button', { name: /styles/i } ).click();
await page.getByRole( 'button', { name: 'Styles' } ).click();
await page
.getByRole( 'button', { name: /typography styles/i } )
.getByRole( 'button', { name: 'Typography Styles' } )
.click();
const manageFontsIcon = page.getByRole( 'button', {
name: /manage fonts/i,
name: 'Manage Fonts',
} );
await expect( manageFontsIcon ).toBeVisible();
} );

test( 'should allow user to upload a local font', async ( {
page,
} ) => {
getdave marked this conversation as resolved.
Show resolved Hide resolved
await page.getByRole( 'button', { name: 'Styles' } ).click();
await page
.getByRole( 'button', { name: 'Typography Styles' } )
.click();
await page
.getByRole( 'button', {
name: 'Manage Fonts',
} )
.click();

// Delete test font family (Exo 2) if it exists
await expect(
page.getByRole( 'tab', { name: 'Upload' } )
).toBeVisible( { timeout: 80000 } );

if (
await page.getByRole( 'button', { name: 'Exo 2' } ).isVisible()
) {
await page.getByRole( 'button', { name: 'Exo 2' } ).click();
await page.getByRole( 'button', { name: 'Delete' } ).click();
await page.getByRole( 'button', { name: 'Delete' } ).click();
await page.getByRole( 'tab', { name: 'Library' } ).click();
}

// Upload local fonts
await page.getByRole( 'tab', { name: 'Upload' } ).click();
const fileChooserPromise = page.waitForEvent( 'filechooser' );
await page.getByRole( 'button', { name: 'Upload Font' } ).click();
const fileChooser = await fileChooserPromise;
await fileChooser.setFiles( [
mikachan marked this conversation as resolved.
Show resolved Hide resolved
'./test/e2e/assets/Exo2-Regular.woff',
'./test/e2e/assets/Exo2-SemiBoldItalic.woff2',
] );

// Check fonts were installed
await expect(
page
.getByLabel( 'Upload' )
.getByText( 'Fonts were installed successfully.' )
).toBeVisible( { timeout: 40000 } );
await page.getByRole( 'tab', { name: 'Library' } ).click();
await expect(
page.getByRole( 'button', { name: 'Exo 2' } )
).toBeVisible();
mikachan marked this conversation as resolved.
Show resolved Hide resolved
} );
} );

test.describe( 'When a theme with bundled fonts is active', () => {
Expand All @@ -37,26 +86,26 @@ test.describe( 'Font Library', () => {
} );

test( 'should display the "Manage Fonts" icon', async ( { page } ) => {
await page.getByRole( 'button', { name: /styles/i } ).click();
await page.getByRole( 'button', { name: 'Styles' } ).click();
await page
.getByRole( 'button', { name: /typography styles/i } )
.getByRole( 'button', { name: 'Typography Styles' } )
.click();
const manageFontsIcon = page.getByRole( 'button', {
name: /manage fonts/i,
name: 'Manage Fonts',
} );
await expect( manageFontsIcon ).toBeVisible();
} );

test( 'should open the "Manage Fonts" modal when clicking the "Manage Fonts" icon', async ( {
page,
} ) => {
await page.getByRole( 'button', { name: /styles/i } ).click();
await page.getByRole( 'button', { name: 'Styles' } ).click();
await page
.getByRole( 'button', { name: /typography styles/i } )
.getByRole( 'button', { name: 'Typography Styles' } )
.click();
await page
.getByRole( 'button', {
name: /manage fonts/i,
name: 'Manage Fonts',
} )
.click();
await expect( page.getByRole( 'dialog' ) ).toBeVisible();
Expand All @@ -68,21 +117,21 @@ test.describe( 'Font Library', () => {
test( 'should show font variant panel when clicking on a font family', async ( {
page,
} ) => {
await page.getByRole( 'button', { name: /styles/i } ).click();
await page.getByRole( 'button', { name: 'Styles' } ).click();
await page
.getByRole( 'button', { name: /typography styles/i } )
.getByRole( 'button', { name: 'Typography Styles' } )
.click();
await page
.getByRole( 'button', {
name: /manage fonts/i,
name: 'Manage Fonts',
} )
.click();
await page.getByRole( 'button', { name: /system font/i } ).click();
await page.getByRole( 'button', { name: 'System Font' } ).click();
await expect(
page.getByRole( 'heading', { name: /system font/i } )
page.getByRole( 'heading', { name: 'System Font' } )
).toBeVisible();
await expect(
page.getByRole( 'checkbox', { name: /system font normal/i } )
page.getByRole( 'checkbox', { name: 'System Font Normal' } )
).toBeVisible();
} );
} );
Expand Down
Loading