hunk.code_window:       shell: bash
         run: yarn config set nmMode hardlinks-local
       - name: yarn install
         uses: nick-fields/retry@v2
         with:
           timeout_minutes: 10
           max_attempts: 3
           retry_on: timeout
           command: yarn install ${{ inputs.extra-flags }}
         env:
           HUSKY: '0'
           PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
  
hunk.labels: keep keep keep keep replace replace replace replace replace replace keep keep keep
hunk.after_edit:       if: ${{ inputs.package-install == 'true' }}
         continue-on-error: true
         shell: bash
         run: yarn install ${{ inputs.extra-flags }}
         env:
           HUSKY: '0'
           PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
           ELECTRON_SKIP_BINARY_DOWNLOAD: '1'
           SENTRYCLI_SKIP_DOWNLOAD: '1'
       - name: yarn install (try again)
         if: ${{ steps.install.outcome == 'failure' }}
         shell: bash
         run: yarn install ${{ inputs.extra-flags }}
  
hunk.file_path: .github/actions/setup-node/action.yml
hunk.type: replace
file: /// <reference types="../global.d.ts" />
  import { ok } from 'node:assert';
  import { beforeEach, test } from 'node:test';
  
  import { Test } from '@nestjs/testing';
  import { PrismaClient } from '@prisma/client';
  
  import { ConfigModule } from '../config';
  import { GqlModule } from '../graphql.module';
  import { AuthModule } from '../modules/auth';
  import { AuthService } from '../modules/auth/service';
  import { PrismaModule } from '../prisma';
  
  let auth: AuthService;
  
  // cleanup database before each test
  beforeEach(async () => {
    const client = new PrismaClient();
    await client.$connect();
    await client.user.deleteMany({});
  });
  
  beforeEach(async () => {
    const module = await Test.createTestingModule({
      imports: [
        ConfigModule.forRoot({
          auth: {
            accessTokenExpiresIn: 1,
            refreshTokenExpiresIn: 1,
            leeway: 1,
          },
        }),
        PrismaModule,
        GqlModule,
        AuthModule,
      ],
    }).compile();
    auth = module.get(AuthService);
  });
  
  test('should be able to register and signIn', async () => {
    await auth.register('Alex Yang', 'alexyang@example.org', '123456');
    await auth.signIn('alexyang@example.org', '123456');
  });
  
  test('should be able to verify', async () => {
    await auth.register('Alex Yang', 'alexyang@example.org', '123456');
    await auth.signIn('alexyang@example.org', '123456');
    const user = {
      id: '1',
      name: 'Alex Yang',
      email: 'alexyang@example.org',
      createdAt: new Date(),
    };
    {
      const token = await auth.sign(user);
      const claim = await auth.verify(token);
      ok(claim.id === '1');
      ok(claim.name === 'Alex Yang');
      ok(claim.email === 'alexyang@example.org');
    }
    {
      const token = await auth.refresh(user);
      const claim = await auth.verify(token);
      ok(claim.id === '1');
      ok(claim.name === 'Alex Yang');
      ok(claim.email === 'alexyang@example.org');
    }
  });
  