Repository: spotify/backstage
File: plugins/techdocs-node/src/stages/publish/awsS3.test.ts (TypeScript)

Code before:
      expect(await publisher.getReadiness()).toEqual({
        isAvailable: true,
      });
    });

    it('should reject incorrect config', async () => {
      const publisher = await createPublisherFromConfig({
        bucketName: 'errorBucket',
      });
      expect(await publisher.getReadiness()).toEqual({
        isAvailable: false,
      });
    });
  });

  describe('publish', () => {
    it('should publish a directory', async () => {
      const publisher = await createPublisherFromConfig();
      expect(await publisher.publish({ entity, directory })).toMatchObject({
        objects: expect.arrayContaining([
          'default/component/backstage/404.html',
          `default/component/backstage/index.html`,
          `default/component/backstage/assets/main.css`,
        ]),
      });
    }, 30000);

    it('should publish a directory as well when legacy casing is used', async () => {
      const publisher = await createPublisherFromConfig({
        legacyUseCaseSensitiveTripletPaths: true,
      });
      expect(await publisher.publish({ entity, directory })).toMatchObject({
        objects: expect.arrayContaining([
          'default/Component/backstage/404.html',
          `default/Component/backstage/index.html`,
          `default/Component/backstage/assets/main.css`,
        ]),
      });
    }, 30000);

    it('should publish a directory when root path is specified', async () => {
      const publisher = await createPublisherFromConfig({
        bucketRootPath: 'backstage-data/techdocs',
      });
      expect(await publisher.publish({ entity, directory })).toMatchObject({
        objects: expect.arrayContaining([
          'backstage-data/techdocs/default/component/backstage/404.html',
          `backstage-data/techdocs/default/component/backstage/index.html`,
          `backstage-data/techdocs/default/component/backstage/assets/main.css`,
        ]),
      });

Review comment (suggestion):
was this on purpose? 🤔 
```suggestion
    });
```

Code after:
  describe('retry mechanism', () => {
    it('should retry with custom retry strategy', async () => {
      const publisher = await createPublisherFromConfig();
      const customRetryStrategy = jest.fn(error => {
        return error.name === 'NetworkingError';
      });

      s3Mock
        .on(ListObjectsV2Command)
        .rejectsOnce(
          new S3ServiceException({
            name: 'NetworkingError',
            $fault: 'client',
            $metadata: {},
          }),
        )
        .resolvesOnce({ Contents: [] });

      await (publisher as AwsS3Publish).retryOperation(
        async () => {
          const command = new ListObjectsV2Command({ Bucket: 'bucketName' });
          return (publisher as AwsS3Publish).storageClient.send(command);
        },
        'TestOperation',
        3,
        customRetryStrategy,
      );

      expect(customRetryStrategy).toHaveBeenCalled();
    });

    it('should use default retry strategy when no custom strategy provided', async () => {
      const publisher = await createPublisherFromConfig();
      s3Mock
        .on(ListObjectsV2Command)
        .rejectsOnce(
          new S3ServiceException({
            name: 'RequestTimeout',
            $fault: 'client',
            $metadata: {},
          }),
        )
        .resolvesOnce({ Contents: [] });

      await (publisher as AwsS3Publish).retryOperation(
        async () => {
          const command = new ListObjectsV2Command({ Bucket: 'bucketName' });
          return (publisher as AwsS3Publish).storageClient.send(command);
        },
        'TestOperation',
        3,