test: refactor all test directories into one
This commit is contained in:
35
test/fields-array/config.ts
Normal file
35
test/fields-array/config.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { buildConfig } from '../buildConfig';
|
||||
|
||||
export const slug = 'fields-array';
|
||||
|
||||
export default buildConfig({
|
||||
collections: [
|
||||
{
|
||||
slug,
|
||||
fields: [
|
||||
{
|
||||
type: 'array',
|
||||
name: 'readOnlyArray',
|
||||
label: 'readOnly Array',
|
||||
admin: {
|
||||
readOnly: true,
|
||||
},
|
||||
defaultValue: [
|
||||
{
|
||||
text: 'defaultValue',
|
||||
},
|
||||
{
|
||||
text: 'defaultValue2',
|
||||
},
|
||||
],
|
||||
fields: [
|
||||
{
|
||||
type: 'text',
|
||||
name: 'text',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
43
test/fields-array/e2e.spec.ts
Normal file
43
test/fields-array/e2e.spec.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import type { Page } from '@playwright/test';
|
||||
import { expect, test } from '@playwright/test';
|
||||
import wait from '../../src/utilities/wait';
|
||||
import { AdminUrlUtil } from '../helpers/adminUrlUtil';
|
||||
import { initPayloadTest } from '../helpers/configHelpers';
|
||||
import { firstRegister } from '../helpers';
|
||||
import { slug } from './config';
|
||||
|
||||
const { beforeAll, describe } = test;
|
||||
|
||||
let url: AdminUrlUtil;
|
||||
|
||||
describe('fields - array', () => {
|
||||
let page: Page;
|
||||
beforeAll(async ({ browser }) => {
|
||||
const { serverURL } = await initPayloadTest({
|
||||
__dirname,
|
||||
init: {
|
||||
local: false,
|
||||
},
|
||||
});
|
||||
url = new AdminUrlUtil(serverURL, slug);
|
||||
|
||||
const context = await browser.newContext();
|
||||
page = await context.newPage();
|
||||
|
||||
await firstRegister({ page, serverURL });
|
||||
});
|
||||
|
||||
test('should be readOnly', async () => {
|
||||
await page.goto(url.create);
|
||||
await wait(2000);
|
||||
const field = page.locator('#readOnlyArray\\.0\\.text');
|
||||
await expect(field).toBeDisabled();
|
||||
});
|
||||
|
||||
test('should have defaultValue', async () => {
|
||||
await page.goto(url.create);
|
||||
await wait(2000);
|
||||
const field = page.locator('#readOnlyArray\\.0\\.text');
|
||||
await expect(field).toHaveValue('defaultValue');
|
||||
});
|
||||
});
|
||||
35
test/fields-array/payload-types.ts
Normal file
35
test/fields-array/payload-types.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
/* tslint:disable */
|
||||
/**
|
||||
* This file was automatically generated by Payload CMS.
|
||||
* DO NOT MODIFY IT BY HAND. Instead, modify your source Payload config,
|
||||
* and re-run `payload generate:types` to regenerate this file.
|
||||
*/
|
||||
|
||||
export interface Config {}
|
||||
/**
|
||||
* This interface was referenced by `Config`'s JSON-Schema
|
||||
* via the `definition` "fields-array".
|
||||
*/
|
||||
export interface FieldsArray {
|
||||
id: string;
|
||||
readOnlyArray?: {
|
||||
text?: string;
|
||||
id?: string;
|
||||
}[];
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
/**
|
||||
* This interface was referenced by `Config`'s JSON-Schema
|
||||
* via the `definition` "users".
|
||||
*/
|
||||
export interface User {
|
||||
id: string;
|
||||
email?: string;
|
||||
resetPasswordToken?: string;
|
||||
resetPasswordExpiration?: string;
|
||||
loginAttempts?: number;
|
||||
lockUntil?: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
Reference in New Issue
Block a user