@@ -178,214 +178,4 @@ describe('CopyButton Component', () => {
178
178
expect ( navigator . clipboard . writeText ) . toHaveBeenCalledWith ( 'test text' ) ;
179
179
expect ( await screen . findByText ( 'Copied!' ) ) . toBeInTheDocument ( ) ;
180
180
} ) ;
181
- } ) ;
182
-
183
-
184
-
185
- // jest.mock('../src/app/onboarding/components/Step', () => jest.fn(() => <div>Step Component</div>));
186
- // jest.mock('../src/app/onboarding/components/NextButton', () => jest.fn(() => <div>Next Button</div>));
187
- // jest.mock('../src/app/components/withAuth', () => (Component) => (props) => <Component {...props} />);
188
- // jest.mock('../src/app/onboarding/components/CodeBox', () => jest.fn(() => <div>CodeBox Component</div>));
189
-
190
- // describe('Onboarding Page', () => {
191
- // const mockOnboardingSteps = [
192
- // {
193
- // stepNumber: 1,
194
- // title: "Install and Configure Next.js Bundle Analyzer",
195
- // description: "NPM install Next.js Bundle Analyzer:",
196
- // code: `npm install @next/bundle-analyzer`,
197
- // language: "terminal",
198
- // api: false,
199
- // },
200
- // {
201
- // stepNumber: "",
202
- // title: "",
203
- // description: "Configure next.config.mjs file:",
204
- // code: `import pkg from '@next/bundle-analyzer';
205
- // const withBundleAnalyzer = pkg({
206
- // enabled: process.env.ANALYZE === 'true',
207
- // });
208
-
209
- // const nextConfig = {};
210
-
211
- // export default withBundleAnalyzer(nextConfig);`,
212
- // language: "next.config.mjs",
213
- // api: false,
214
- // },
215
- // {
216
- // stepNumber: 2,
217
- // title: "Install and configure NextLevelPackage",
218
- // description: "NPM Install NextLevelPackage:",
219
- // code: `npm install nextlevelpackage`,
220
- // language: "terminal",
221
- // api: false,
222
- // },
223
- // {
224
- // stepNumber: "",
225
- // title: "",
226
- // description: "Import NextLevelPackage in layout.js:",
227
- // code: `import NextWebVitals from 'nextlevelpackage';`,
228
- // language: "layout.js",
229
- // api: false,
230
- // },
231
- // {
232
- // stepNumber: "",
233
- // title: "",
234
- // description: "Add NextWebVitals component in RootLayout body:",
235
- // code: `export default function RootLayout({ children }) {
236
- // return (
237
- // <html lang="en">
238
- // <body>
239
- // <NextWebVitals />
240
- // {children}
241
- // </body>
242
- // </html>
243
- // );
244
- // }`,
245
- // language: "layout.js",
246
- // api: false,
247
- // },
248
- // {
249
- // stepNumber: 3,
250
- // title: 'Configure Environment Variables',
251
- // description: 'Add the following line to your .env.local file:',
252
- // code: `NEXT_PUBLIC_API_KEY=<your-api-key>`,
253
- // language: '.env.local',
254
- // api: true,
255
- // },
256
- // {
257
- // stepNumber: 4,
258
- // title: "Add Build Script to package.json",
259
- // description: "Add the following script to your package.json:",
260
- // code: `"scripts": {
261
- // "nextlevelbuild": "node ./node_modules/nextlevelpackage/cli.js"
262
- // }`,
263
- // language: "terminal",
264
- // api: false,
265
- // },
266
- // {
267
- // stepNumber: '',
268
- // title: '',
269
- // description: 'Run this build script instead of \'npm next build\' to track metrics in the dashboard:',
270
- // code: `npm run nextlevelbuild`,
271
- // language: "terminal",
272
- // api: false,
273
- // },
274
- // ];
275
- // const mockProps = {
276
- // searchParams: {
277
- // username: 'testuser',
278
- // },
279
- // };
280
-
281
- // beforeEach(() => {
282
- // Step.mockClear();
283
- // NextButton.mockClear();
284
- // });
285
-
286
- // test('renders onboarding page with steps', () => {
287
- // render(<Onboarding {...mockProps} />);
288
-
289
- // expect(screen.getByText('NextLevel Onboarding Instructions')).toBeInTheDocument();
290
- // expect(Step).toHaveBeenCalledTimes(mockOnboardingSteps.length);
291
- // });
292
-
293
- // test('renders Step components with correct props', () => {
294
- // render(<Onboarding {...mockProps} />);
295
-
296
- // mockOnboardingSteps.forEach((step, index) => {
297
- // expect(Step).toHaveBeenNthCalledWith(
298
- // index + 1,
299
- // expect.objectContaining({
300
- // className: "step",
301
- // stepNumber: step.stepNumber,
302
- // title: step.title,
303
- // description: step.description,
304
- // code: step.code,
305
- // language: step.language,
306
- // api: step.api,
307
- // username: 'testuser',
308
- // }),
309
- // {}
310
- // );
311
- // });
312
- // });
313
-
314
- // test('renders NextButton with correct props', () => {
315
- // render(<Onboarding {...mockProps} />);
316
- // expect(screen.getByText('Next Button')).toBeInTheDocument();
317
- // expect(NextButton).toHaveBeenCalledWith(expect.objectContaining({ username: 'testuser' }), {});
318
- // });
319
- // //fails
320
- // test('fetches API key if step requires it', async () => {
321
- // global.fetch = jest.fn(() =>
322
- // Promise.resolve({
323
- // ok: true,
324
- // json: () => Promise.resolve({ APIkey: 'test-api-key' }),
325
- // })
326
- // );
327
-
328
- // render(<Onboarding {...mockProps} />);
329
- // await waitFor(() => expect(global.fetch).toHaveBeenCalledWith('http://localhost:3000/onboarding/api?username=testuser'));
330
-
331
- // expect(Step).toHaveBeenCalledWith(
332
- // expect.objectContaining({
333
- // username: 'testuser',
334
- // }),
335
- // {}
336
- // );
337
- // });
338
-
339
- // });
340
-
341
- // describe('Step Component', () => {
342
- // const mockStepProps = {
343
- // stepNumber: 1,
344
- // title: 'Test Step',
345
- // description: 'Test Description',
346
- // code: 'test code',
347
- // language: 'test language',
348
- // api: false,
349
- // username: 'testuser',
350
- // };
351
- // //fails
352
- // test('renders Step component', () => {
353
- // render(<Step {...mockStepProps} />);
354
- // expect(screen.getByText('Step Component')).toBeInTheDocument();
355
- // });
356
- // //fails
357
- // test('fetches API key if api is true', async () => {
358
- // global.fetch = jest.fn(() =>
359
- // Promise.resolve({
360
- // ok: true,
361
- // json: () => Promise.resolve({ APIkey: 'test-api-key' }),
362
- // })
363
- // );
364
-
365
- // render(<Step {...mockStepProps} />);
366
-
367
- // await waitFor(() => expect(global.fetch).toHaveBeenCalledWith('http://localhost:3000/onboarding/api?username=testuser'));
368
- // expect(CodeBox).toHaveBeenCalledWith(expect.objectContaining({ fileName: 'API Key', formattedCode: 'test-api-key' }), expect.any(Object));
369
- // });
370
- // });
371
-
372
- // describe('CopyButton Component', () => {
373
- // test('renders CopyButton component', () => {
374
- // render(<CopyButton text="test text" />);
375
- // expect(screen.getByText('Copy')).toBeInTheDocument();
376
- // });
377
-
378
- // test('copies text to clipboard on click', async () => {
379
- // Object.assign(navigator, {
380
- // clipboard: {
381
- // writeText: jest.fn().mockResolvedValue(),
382
- // },
383
- // });
384
-
385
- // render(<CopyButton text="test text" />);
386
- // fireEvent.click(screen.getByText('Copy'));
387
-
388
- // expect(navigator.clipboard.writeText).toHaveBeenCalledWith('test text');
389
- // expect(await screen.findByText('Copied!')).toBeInTheDocument();
390
- // });
391
- // });
181
+ } ) ;
0 commit comments