chore: renames admin url util conventions

This commit is contained in:
James
2022-07-13 12:47:53 -07:00
parent de43e21ebc
commit 8ba25e8602
7 changed files with 31 additions and 34 deletions

View File

@@ -49,7 +49,7 @@ describe('access control', () => {
test('field without read access should not show', async () => { test('field without read access should not show', async () => {
const { id } = await createDoc({ restrictedField: 'restricted' }); 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); await expect(page.locator('input[name="restrictedField"]')).toHaveCount(0);
}); });
@@ -66,7 +66,7 @@ describe('access control', () => {
}); });
test('should not have collection url', async () => { 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('text=Nothing found').click();
await page.locator('a:has-text("Back to Dashboard")').click(); await page.locator('a:has-text("Back to Dashboard")').click();
await expect(page).toHaveURL(url.admin); await expect(page).toHaveURL(url.admin);

View File

@@ -45,17 +45,17 @@ describe('collections', () => {
const collectionLink = page.locator(`nav >> text=${slug}`); const collectionLink = page.locator(`nav >> text=${slug}`);
await collectionLink.click(); await collectionLink.click();
expect(page.url()).toContain(url.collection); expect(page.url()).toContain(url.list);
}); });
test('should navigate to collection - card', async () => { test('should navigate to collection - card', async () => {
await page.goto(url.admin); await page.goto(url.admin);
await page.locator('a:has-text("Posts")').click(); 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 () => { 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(); await page.locator('a:has-text("Dashboard")').click();
expect(page.url()).toContain(url.admin); expect(page.url()).toContain(url.admin);
}); });
@@ -63,9 +63,9 @@ describe('collections', () => {
test('breadcrumbs - from document to collection', async () => { test('breadcrumbs - from document to collection', async () => {
const { id } = await createPost(); const { id } = await createPost();
await page.goto(url.doc(id)); await page.goto(url.edit(id));
await page.locator('nav >> text=Posts').click(); 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 () => { test('should read existing', async () => {
const { id } = await createPost(); 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('#title')).toHaveValue(title);
await expect(page.locator('#description')).toHaveValue(description); await expect(page.locator('#description')).toHaveValue(description);
@@ -95,7 +95,7 @@ describe('collections', () => {
test('should update existing', async () => { test('should update existing', async () => {
const { id } = await createPost(); const { id } = await createPost();
await page.goto(url.doc(id)); await page.goto(url.edit(id));
const newTitle = 'new title'; const newTitle = 'new title';
const newDesc = 'new description'; const newDesc = 'new description';
@@ -111,18 +111,18 @@ describe('collections', () => {
test('should delete existing', async () => { test('should delete existing', async () => {
const { id } = await createPost(); 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("Delete")').click();
await page.locator('button:has-text("Confirm")').click(); await page.locator('button:has-text("Confirm")').click();
await expect(page.locator(`text=Post "${id}" successfully deleted.`)).toBeVisible(); 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 () => { test('should duplicate existing', async () => {
const { id } = await createPost(); const { id } = await createPost();
await page.goto(url.doc(id)); await page.goto(url.edit(id));
await page.locator('button:has-text("Duplicate")').click(); await page.locator('button:has-text("Duplicate")').click();
expect(page.url()).toContain(url.create); expect(page.url()).toContain(url.create);
@@ -135,7 +135,7 @@ describe('collections', () => {
const tableRowLocator = 'table >> tbody >> tr'; const tableRowLocator = 'table >> tbody >> tr';
beforeEach(async () => { beforeEach(async () => {
await page.goto(url.collection); await page.goto(url.list);
}); });
describe('filtering', () => { describe('filtering', () => {

View File

@@ -174,7 +174,7 @@ describe('fields - relationship', () => {
describe('existing relationships', () => { describe('existing relationships', () => {
test('should highlight existing relationship', async () => { 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 fields = page.locator('.render-fields >> .react-select');
const relationOneField = fields.nth(0); const relationOneField = fields.nth(0);
@@ -187,7 +187,7 @@ describe('fields - relationship', () => {
}); });
test('should show untitled ID on restricted relation', async () => { 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 fields = page.locator('.render-fields >> .react-select');
const restrictedRelationField = fields.nth(3); const restrictedRelationField = fields.nth(3);
@@ -203,7 +203,7 @@ describe('fields - relationship', () => {
}); });
test('should show useAsTitle on relation', async () => { 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 fields = page.locator('.render-fields >> .react-select');
const relationWithTitleField = fields.nth(4); const relationWithTitleField = fields.nth(4);

View File

@@ -1,13 +1,11 @@
import { buildConfig } from '../buildConfig'; import { buildConfig } from '../buildConfig';
import { devUser } from '../../credentials'; import { devUser } from '../../credentials';
import { seededDoc } from './shared'; import { textDoc } from './shared';
export const slug = 'docs';
export default buildConfig({ export default buildConfig({
collections: [ collections: [
{ {
slug, slug: 'text-fields',
admin: { admin: {
useAsTitle: 'text', useAsTitle: 'text',
}, },
@@ -30,8 +28,8 @@ export default buildConfig({
}); });
await payload.create({ await payload.create({
collection: slug, collection: 'text-fields',
data: seededDoc, data: textDoc,
}); });
}, },
}); });

View File

@@ -3,8 +3,7 @@ import { expect, test } from '@playwright/test';
import { AdminUrlUtil } from '../../helpers/adminUrlUtil'; import { AdminUrlUtil } from '../../helpers/adminUrlUtil';
import { initPayloadTest } from '../../helpers/configHelpers'; import { initPayloadTest } from '../../helpers/configHelpers';
import { login } from '../helpers'; import { login } from '../helpers';
import { slug } from './config'; import { textDoc } from './shared';
import { seededDoc } from './shared';
const { beforeAll, describe } = test; 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(); const context = await browser.newContext();
page = await context.newPage(); page = await context.newPage();
@@ -30,9 +29,9 @@ describe('fields', () => {
describe('text', () => { describe('text', () => {
test('should display field in list view', async () => { 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'); 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);
}); });
}); });
}); });

View File

@@ -1,3 +1,3 @@
export const seededDoc = { export const textDoc = {
text: 'Seeded document', text: 'Seeded text document',
}; };

View File

@@ -1,17 +1,17 @@
export class AdminUrlUtil { export class AdminUrlUtil {
admin: string; admin: string;
collection: string; list: string;
create: string; create: string;
constructor(serverURL: string, slug: string) { constructor(serverURL: string, slug: string) {
this.admin = `${serverURL}/admin`; this.admin = `${serverURL}/admin`;
this.collection = `${this.admin}/collections/${slug}`; this.list = `${this.admin}/collections/${slug}`;
this.create = `${this.collection}/create`; this.create = `${this.list}/create`;
} }
doc(id: string): string { edit(id: string): string {
return `${this.collection}/${id}`; return `${this.list}/${id}`;
} }
} }