This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
/* global expect */
|
||||
import pgAdmin from 'sources/pgadmin';
|
||||
import SchemaView from '../../pgadmin/static/js/SchemaView';
|
||||
import pgWindow from 'sources/window';
|
||||
@@ -90,8 +91,27 @@ export const getPropertiesView = async (schemaObj, getInitData)=> {
|
||||
});
|
||||
};
|
||||
|
||||
// Count the rows belonging to the data grid itself, ignoring rows of any
|
||||
// grid nested inside an expanded row.
|
||||
const countDatagridRows = (gridEle)=>{
|
||||
const tableEle = gridEle.querySelector('[data-test="data-grid-view"]');
|
||||
return Array.from(
|
||||
tableEle?.querySelectorAll('[data-test="data-table-row"]') ?? []
|
||||
).filter(
|
||||
(rowEle)=>rowEle.closest('[data-test="data-grid-view"]') === tableEle
|
||||
).length;
|
||||
};
|
||||
|
||||
export const addNewDatagridRow = async (user, ctrl)=>{
|
||||
await user.click(ctrl.container.querySelector('[data-test="add-row"] button'));
|
||||
const addBtn = ctrl.container.querySelector('[data-test="add-row"]');
|
||||
expect(addBtn).not.toBeNull();
|
||||
|
||||
const gridEle = addBtn.closest('.DataGridView-grid');
|
||||
expect(gridEle).not.toBeNull();
|
||||
|
||||
const rowCount = countDatagridRows(gridEle);
|
||||
await user.click(addBtn);
|
||||
expect(countDatagridRows(gridEle)).toBe(rowCount + 1);
|
||||
};
|
||||
|
||||
export const genericBeforeEach = ()=> {
|
||||
|
||||
@@ -45,10 +45,13 @@ describe('ForeignKeySchema', ()=>{
|
||||
beforeAll(()=>{
|
||||
jest.spyOn(nodeAjax, 'getNodeAjaxOptions').mockReturnValue(Promise.resolve([]));
|
||||
jest.spyOn(nodeAjax, 'getNodeListByName').mockReturnValue(Promise.resolve([]));
|
||||
schemaObj = getNodeForeignKeySchema({}, {}, {Nodes: {table: {}}});
|
||||
});
|
||||
|
||||
beforeEach(()=>{
|
||||
// A fresh schema per test, as each dialog gets in the product; the
|
||||
// properties view mutates its fields (helpMessage), which would otherwise
|
||||
// leak into the grid cells rendered by later tests.
|
||||
schemaObj = getNodeForeignKeySchema({}, {}, {Nodes: {table: {}}});
|
||||
genericBeforeEach();
|
||||
});
|
||||
|
||||
|
||||
@@ -137,8 +137,11 @@ describe('PartitionsSchema', ()=>{
|
||||
});
|
||||
|
||||
it('create collection', async ()=>{
|
||||
// Let the collection become the top schema, as the table dialog is in
|
||||
// the product, rather than the partition schema being its own top with
|
||||
// no session data.
|
||||
let schemaCollObj = new SchemaInColl(
|
||||
schemaObj,[ 'is_attach', 'partition_name', 'is_default', 'values_from', 'values_to', 'values_in', 'values_modulus', 'values_remainder']
|
||||
new PartitionsSchema(),[ 'is_attach', 'partition_name', 'is_default', 'values_from', 'values_to', 'values_in', 'values_modulus', 'values_remainder']
|
||||
);
|
||||
const {ctrl, user} = await getCreateView(schemaCollObj);
|
||||
/* Make sure you hit every corner */
|
||||
|
||||
@@ -41,7 +41,10 @@ describe('PrimaryKeySchema', ()=>{
|
||||
let schemaObj;
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
beforeAll(()=>{
|
||||
// A fresh schema per test, as each dialog gets in the product; the
|
||||
// properties view mutates its fields (helpMessage), which would otherwise
|
||||
// leak into the grid cells rendered by later tests.
|
||||
beforeEach(()=>{
|
||||
schemaObj = new PrimaryKeySchema({
|
||||
spcname: ()=>Promise.resolve([]),
|
||||
}, {});
|
||||
|
||||
@@ -41,7 +41,10 @@ describe('UniqueConstraintSchema', ()=>{
|
||||
let schemaObj;
|
||||
let getInitData = ()=>Promise.resolve({});
|
||||
|
||||
beforeAll(()=>{
|
||||
// A fresh schema per test, as each dialog gets in the product; the
|
||||
// properties view mutates its fields (helpMessage), which would otherwise
|
||||
// leak into the grid cells rendered by later tests.
|
||||
beforeEach(()=>{
|
||||
schemaObj = new UniqueConstraintSchema({
|
||||
spcname: ()=>Promise.resolve([]),
|
||||
}, {});
|
||||
|
||||
Reference in New Issue
Block a user