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

Index view for Templates & Parts: use grid layout as default #60069

Merged
merged 3 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const defaultConfigPerViewType = {
};

const DEFAULT_VIEW = {
type: LAYOUT_TABLE,
type: LAYOUT_GRID,
search: '',
page: 1,
perPage: 20,
Expand All @@ -87,7 +87,7 @@ const DEFAULT_VIEW = {
// All fields are visible by default, so it's
// better to keep track of the hidden ones.
hiddenFields: [ 'preview' ],
layout: defaultConfigPerViewType[ LAYOUT_TABLE ],
layout: defaultConfigPerViewType[ LAYOUT_GRID ],
filters: [],
};

Expand Down
6 changes: 2 additions & 4 deletions test/e2e/specs/site-editor/hybrid-theme.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test.describe( 'Hybrid theme', () => {
);

await expect(
page.getByRole( 'table' ).getByRole( 'link', { name: 'header' } )
page.getByRole( 'link', { name: 'header' } )
).toBeVisible();
} );

Expand All @@ -29,9 +29,7 @@ test.describe( 'Hybrid theme', () => {
'postType=wp_template_part&path=/wp_template_part/all'
);

const templatePart = page
.getByRole( 'table' )
.getByRole( 'link', { name: 'header' } );
const templatePart = page.getByRole( 'link', { name: 'header' } );

await expect( templatePart ).toBeVisible();
await templatePart.click();
Expand Down
29 changes: 18 additions & 11 deletions test/e2e/specs/site-editor/new-templates-list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ test.describe( 'Templates', () => {
requestUtils.deleteAllTemplates( 'wp_template' ),
] );
} );

test.afterAll( async ( { requestUtils } ) => {
await requestUtils.activateTheme( 'twentytwentyone' );
} );

test.afterEach( async ( { requestUtils } ) => {
await requestUtils.deleteAllTemplates( 'wp_template' );
} );

test( 'Sorting', async ( { admin, page } ) => {
await admin.visitSiteEditor( { path: '/wp_template' } );

// Descending by title.
await page
.getByRole( 'button', { name: 'Template', exact: true } )
.click();
await page
.getByRole( 'menuitemradio', {
name: 'Sort descending',
} )
.click();
await page.getByRole( 'button', { name: 'View options' } ).click();
await page.getByRole( 'menuitem', { name: 'Sort by' } ).click();
await page.getByRole( 'menuitem', { name: 'Template' } ).click();
await page.getByRole( 'menuitemradio', { name: 'descending' } ).click();
const firstTitle = page
.getByRole( 'region', {
name: 'Template',
Expand All @@ -35,12 +35,12 @@ test.describe( 'Templates', () => {
.getByRole( 'link', { includeHidden: true } )
.first();
await expect( firstTitle ).toHaveText( 'Tag Archives' );

// Ascending by title.
await page
.getByRole( 'menuitemradio', { name: 'Sort ascending' } )
.click();
await page.getByRole( 'menuitemradio', { name: 'ascending' } ).click();
await expect( firstTitle ).toHaveText( 'Category Archives' );
} );

test( 'Filtering', async ( { requestUtils, admin, page } ) => {
await requestUtils.createTemplate( 'wp_template', {
slug: 'date',
Expand Down Expand Up @@ -82,10 +82,17 @@ test.describe( 'Templates', () => {
await page.keyboard.press( 'Escape' ); // close the menu.
await expect( titles ).toHaveCount( 2 );
} );

test( 'Field visibility', async ( { admin, page } ) => {
await admin.visitSiteEditor( { path: '/wp_template' } );

await page.getByRole( 'button', { name: 'View options' } ).click();
await page.getByRole( 'menuitem', { name: 'Layout' } ).click();
await page.getByRole( 'menuitemradio', { name: 'Table' } ).click();

await page.getByRole( 'button', { name: 'Description' } ).click();
await page.getByRole( 'menuitem', { name: 'Hide' } ).click();

await expect(
page.getByRole( 'button', { name: 'Description' } )
).toBeHidden();
Expand Down
Loading