chore: renames admin url util conventions
This commit is contained in:
@@ -49,7 +49,7 @@ describe('access control', () => {
|
||||
test('field without read access should not show', async () => {
|
||||
const { id } = await createDoc({ restrictedField: 'restricted' });
|
||||
|
||||
await page.goto(url.doc(id));
|
||||
await page.goto(url.edit(id));
|
||||
|
||||
await expect(page.locator('input[name="restrictedField"]')).toHaveCount(0);
|
||||
});
|
||||
@@ -66,7 +66,7 @@ describe('access control', () => {
|
||||
});
|
||||
|
||||
test('should not have collection url', async () => {
|
||||
await page.goto(url.collection);
|
||||
await page.goto(url.list);
|
||||
await page.locator('text=Nothing found').click();
|
||||
await page.locator('a:has-text("Back to Dashboard")').click();
|
||||
await expect(page).toHaveURL(url.admin);
|
||||
|
||||
@@ -45,17 +45,17 @@ describe('collections', () => {
|
||||
const collectionLink = page.locator(`nav >> text=${slug}`);
|
||||
await collectionLink.click();
|
||||
|
||||
expect(page.url()).toContain(url.collection);
|
||||
expect(page.url()).toContain(url.list);
|
||||
});
|
||||
|
||||
test('should navigate to collection - card', async () => {
|
||||
await page.goto(url.admin);
|
||||
await page.locator('a:has-text("Posts")').click();
|
||||
expect(page.url()).toContain(url.collection);
|
||||
expect(page.url()).toContain(url.list);
|
||||
});
|
||||
|
||||
test('breadcrumbs - from card to dashboard', async () => {
|
||||
await page.goto(url.collection);
|
||||
await page.goto(url.list);
|
||||
await page.locator('a:has-text("Dashboard")').click();
|
||||
expect(page.url()).toContain(url.admin);
|
||||
});
|
||||
@@ -63,9 +63,9 @@ describe('collections', () => {
|
||||
test('breadcrumbs - from document to collection', async () => {
|
||||
const { id } = await createPost();
|
||||
|
||||
await page.goto(url.doc(id));
|
||||
await page.goto(url.edit(id));
|
||||
await page.locator('nav >> text=Posts').click();
|
||||
expect(page.url()).toContain(url.collection);
|
||||
expect(page.url()).toContain(url.list);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -86,7 +86,7 @@ describe('collections', () => {
|
||||
test('should read existing', async () => {
|
||||
const { id } = await createPost();
|
||||
|
||||
await page.goto(url.doc(id));
|
||||
await page.goto(url.edit(id));
|
||||
|
||||
await expect(page.locator('#title')).toHaveValue(title);
|
||||
await expect(page.locator('#description')).toHaveValue(description);
|
||||
@@ -95,7 +95,7 @@ describe('collections', () => {
|
||||
test('should update existing', async () => {
|
||||
const { id } = await createPost();
|
||||
|
||||
await page.goto(url.doc(id));
|
||||
await page.goto(url.edit(id));
|
||||
|
||||
const newTitle = 'new title';
|
||||
const newDesc = 'new description';
|
||||
@@ -111,18 +111,18 @@ describe('collections', () => {
|
||||
test('should delete existing', async () => {
|
||||
const { id } = await createPost();
|
||||
|
||||
await page.goto(url.doc(id));
|
||||
await page.goto(url.edit(id));
|
||||
await page.locator('button:has-text("Delete")').click();
|
||||
await page.locator('button:has-text("Confirm")').click();
|
||||
|
||||
await expect(page.locator(`text=Post "${id}" successfully deleted.`)).toBeVisible();
|
||||
expect(page.url()).toContain(url.collection);
|
||||
expect(page.url()).toContain(url.list);
|
||||
});
|
||||
|
||||
test('should duplicate existing', async () => {
|
||||
const { id } = await createPost();
|
||||
|
||||
await page.goto(url.doc(id));
|
||||
await page.goto(url.edit(id));
|
||||
await page.locator('button:has-text("Duplicate")').click();
|
||||
|
||||
expect(page.url()).toContain(url.create);
|
||||
@@ -135,7 +135,7 @@ describe('collections', () => {
|
||||
const tableRowLocator = 'table >> tbody >> tr';
|
||||
|
||||
beforeEach(async () => {
|
||||
await page.goto(url.collection);
|
||||
await page.goto(url.list);
|
||||
});
|
||||
|
||||
describe('filtering', () => {
|
||||
|
||||
@@ -174,7 +174,7 @@ describe('fields - relationship', () => {
|
||||
|
||||
describe('existing relationships', () => {
|
||||
test('should highlight existing relationship', async () => {
|
||||
await page.goto(url.doc(docWithExistingRelations.id));
|
||||
await page.goto(url.edit(docWithExistingRelations.id));
|
||||
|
||||
const fields = page.locator('.render-fields >> .react-select');
|
||||
const relationOneField = fields.nth(0);
|
||||
@@ -187,7 +187,7 @@ describe('fields - relationship', () => {
|
||||
});
|
||||
|
||||
test('should show untitled ID on restricted relation', async () => {
|
||||
await page.goto(url.doc(docWithExistingRelations.id));
|
||||
await page.goto(url.edit(docWithExistingRelations.id));
|
||||
|
||||
const fields = page.locator('.render-fields >> .react-select');
|
||||
const restrictedRelationField = fields.nth(3);
|
||||
@@ -203,7 +203,7 @@ describe('fields - relationship', () => {
|
||||
});
|
||||
|
||||
test('should show useAsTitle on relation', async () => {
|
||||
await page.goto(url.doc(docWithExistingRelations.id));
|
||||
await page.goto(url.edit(docWithExistingRelations.id));
|
||||
|
||||
const fields = page.locator('.render-fields >> .react-select');
|
||||
const relationWithTitleField = fields.nth(4);
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
import { buildConfig } from '../buildConfig';
|
||||
import { devUser } from '../../credentials';
|
||||
import { seededDoc } from './shared';
|
||||
|
||||
export const slug = 'docs';
|
||||
import { textDoc } from './shared';
|
||||
|
||||
export default buildConfig({
|
||||
collections: [
|
||||
{
|
||||
slug,
|
||||
slug: 'text-fields',
|
||||
admin: {
|
||||
useAsTitle: 'text',
|
||||
},
|
||||
@@ -30,8 +28,8 @@ export default buildConfig({
|
||||
});
|
||||
|
||||
await payload.create({
|
||||
collection: slug,
|
||||
data: seededDoc,
|
||||
collection: 'text-fields',
|
||||
data: textDoc,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
@@ -3,8 +3,7 @@ import { expect, test } from '@playwright/test';
|
||||
import { AdminUrlUtil } from '../../helpers/adminUrlUtil';
|
||||
import { initPayloadTest } from '../../helpers/configHelpers';
|
||||
import { login } from '../helpers';
|
||||
import { slug } from './config';
|
||||
import { seededDoc } from './shared';
|
||||
import { textDoc } from './shared';
|
||||
|
||||
const { beforeAll, describe } = test;
|
||||
|
||||
@@ -20,7 +19,7 @@ describe('fields', () => {
|
||||
},
|
||||
});
|
||||
|
||||
url = new AdminUrlUtil(serverURL, slug);
|
||||
url = new AdminUrlUtil(serverURL, 'text-fields');
|
||||
|
||||
const context = await browser.newContext();
|
||||
page = await context.newPage();
|
||||
@@ -30,9 +29,9 @@ describe('fields', () => {
|
||||
|
||||
describe('text', () => {
|
||||
test('should display field in list view', async () => {
|
||||
await page.goto(url.collection);
|
||||
await page.goto(url.list);
|
||||
const textCell = await page.locator('table tr:first-child td:first-child a');
|
||||
await expect(textCell).toHaveText(seededDoc.text);
|
||||
await expect(textCell).toHaveText(textDoc.text);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export const seededDoc = {
|
||||
text: 'Seeded document',
|
||||
export const textDoc = {
|
||||
text: 'Seeded text document',
|
||||
};
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
export class AdminUrlUtil {
|
||||
admin: string;
|
||||
|
||||
collection: string;
|
||||
list: string;
|
||||
|
||||
create: string;
|
||||
|
||||
constructor(serverURL: string, slug: string) {
|
||||
this.admin = `${serverURL}/admin`;
|
||||
this.collection = `${this.admin}/collections/${slug}`;
|
||||
this.create = `${this.collection}/create`;
|
||||
this.list = `${this.admin}/collections/${slug}`;
|
||||
this.create = `${this.list}/create`;
|
||||
}
|
||||
|
||||
doc(id: string): string {
|
||||
return `${this.collection}/${id}`;
|
||||
edit(id: string): string {
|
||||
return `${this.list}/${id}`;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user