Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions apps/console/src/__tests__/BrowserSimulation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ const mocks = vi.hoisted(() => {
}
return { data: [] };
}
async findOne(objectName: string, id: string) {
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The findOne method signature should match the DataSource interface exactly. The interface defines id parameter as string | number, but the mock only accepts string. While this works for current tests, it could cause type errors if future tests pass numeric IDs. Consider updating the signature to match the interface.

Suggested change
async findOne(objectName: string, id: string) {
async findOne(objectName: string, id: string | number) {

Copilot uses AI. Check for mistakes.
if (objectName === 'kitchen_sink') {
return { id, name: 'Test Sink', amount: 100 };
}
return null;
}
async getObjectSchema(name: string) {
if (name === 'kitchen_sink') {
return {
Expand Down Expand Up @@ -147,6 +153,14 @@ describe('Console Application Simulation', () => {
});

it('Scenario 4: Object Create Form (All Field Types)', async () => {
// Helper function to check if a label exists in the form
const expectLabelToExist = (label: string) => {
const escaped = label.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const regex = new RegExp(escaped, 'i');
const elements = screen.queryAllByText(regex);
expect(elements.length).toBeGreaterThan(0);
};

renderApp('/kitchen_sink');

// 1. Wait for Object View
Expand All @@ -164,10 +178,10 @@ describe('Console Application Simulation', () => {
});

// 4. Verify Field Inputs
// Wait for at least one field to appear to ensure form is loaded
// Wait for form to finish loading and first field to appear
await waitFor(() => {
expect(screen.getByText(/Text \(Name\)/i)).toBeInTheDocument();
}, { timeout: 5000 });
}, { timeout: 10000 });

const fieldLabels = [
'Text (Name)',
Expand All @@ -178,17 +192,12 @@ describe('Console Application Simulation', () => {
'Boolean (Switch)',
];

// Check each label exists
for (const label of fieldLabels) {
const escaped = label.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const regex = new RegExp(escaped, 'i');
const elements = screen.queryAllByText(regex);
if (elements.length === 0) {
console.log(`Failed to find label: ${label}`);
// console.log(document.body.innerHTML); // Too large, but useful if localized
}
expect(elements.length).toBeGreaterThan(0);
}
// Check all labels exist concurrently using Promise.all for faster execution
await Promise.all(
fieldLabels.map(label =>
waitFor(() => expectLabelToExist(label), { timeout: 5000 })
)
);

// 5. Test specific interaction (e.g. typing in name)
// Note: Shadcn/Form labels might be associated via ID, so getByLabelText is safer usually,
Expand Down
Loading