Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes failing tests: block_actions.user.name is optional #1916

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- name: Print eslint version
run: ./node_modules/.bin/eslint -v
- run: npm run build
- run: npm test
- run: npm run coverage
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"eslint": "^7.26.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-airbnb-typescript": "^12.3.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-jsdoc": "^30.6.1",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-node": "^11.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/receivers/AwsLambdaReceiver.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import crypto from 'crypto';
import sinon from 'sinon';
import { Logger, LogLevel } from '@slack/logger';
import { assert } from 'chai';
import 'mocha';
import crypto from 'crypto';
import rewiremock from 'rewiremock';
import { WebClientOptions } from '@slack/web-api';
import AwsLambdaReceiver, { AwsHandler } from './AwsLambdaReceiver';
Expand Down
2 changes: 1 addition & 1 deletion src/receivers/AwsLambdaReceiver.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { Logger, ConsoleLogger, LogLevel } from '@slack/logger';
import querystring from 'querystring';
import crypto from 'crypto';
import { Logger, ConsoleLogger, LogLevel } from '@slack/logger';
import tsscmp from 'tsscmp';
import App from '../App';
import { Receiver, ReceiverEvent } from '../types/receiver';
Expand Down
4 changes: 2 additions & 2 deletions src/receivers/ExpressReceiver.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'mocha';
import { Readable } from 'stream';
import { EventEmitter } from 'events';
import sinon, { SinonFakeTimers, SinonSpy } from 'sinon';
import { assert } from 'chai';
import rewiremock from 'rewiremock';
import { Logger, LogLevel } from '@slack/logger';
import { Application, IRouter, Request, Response } from 'express';
import { Readable } from 'stream';
import { EventEmitter } from 'events';
import { Override, mergeOverrides, createFakeLogger } from '../test-helpers';
import { ErrorCode, CodedError, ReceiverInconsistentStateError, AppInitializationError, AuthorizationError } from '../errors';
import { HTTPModuleFunctions as httpFunc } from './HTTPModuleFunctions';
Expand Down
4 changes: 2 additions & 2 deletions src/receivers/ExpressReceiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { createServer, Server, ServerOptions } from 'http';
import type { IncomingMessage, ServerResponse } from 'http';
import { createServer as createHttpsServer, Server as HTTPSServer, ServerOptions as HTTPSServerOptions } from 'https';
import { ListenOptions } from 'net';
import express, { Request, Response, Application, RequestHandler, Router, IRouter } from 'express';
import rawBody from 'raw-body';
import querystring from 'querystring';
import crypto from 'crypto';
import express, { Request, Response, Application, RequestHandler, Router, IRouter } from 'express';
import rawBody from 'raw-body';
import tsscmp from 'tsscmp';
import { Logger, ConsoleLogger, LogLevel } from '@slack/logger';
import { InstallProvider, CallbackOptions, InstallProviderOptions, InstallURLOptions, InstallPathOptions } from '@slack/oauth';
Expand Down
4 changes: 2 additions & 2 deletions src/receivers/HTTPModuleFunctions.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'mocha';
import sinon from 'sinon';
import { assert } from 'chai';
import { IncomingMessage, ServerResponse } from 'http';
import { createHmac } from 'crypto';
import sinon from 'sinon';
import { assert } from 'chai';

import {
ReceiverMultipleAckError,
Expand Down
2 changes: 1 addition & 1 deletion src/receivers/HTTPModuleFunctions.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* eslint-disable import/prefer-default-export */
import { parse as qsParse } from 'querystring';
import type { IncomingMessage, ServerResponse } from 'http';
import rawBody from 'raw-body';
import type { Logger } from '@slack/logger';
import type { IncomingMessage, ServerResponse } from 'http';
import { CodedError, ErrorCode } from '../errors';
import { BufferedIncomingMessage } from './BufferedIncomingMessage';
import { verifySlackRequest } from './verify-request';
Expand Down
4 changes: 2 additions & 2 deletions src/receivers/HTTPReceiver.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'mocha';
import { EventEmitter } from 'events';
import { IncomingMessage, ServerResponse } from 'http';
import sinon, { SinonSpy } from 'sinon';
import { assert } from 'chai';
import rewiremock from 'rewiremock';
import { Logger, LogLevel } from '@slack/logger';
import { EventEmitter } from 'events';
import { InstallProvider } from '@slack/oauth';
import { IncomingMessage, ServerResponse } from 'http';
import { match } from 'path-to-regexp';
import { ParamsDictionary } from 'express-serve-static-core';
import { Override, mergeOverrides } from '../test-helpers';
Expand Down
2 changes: 1 addition & 1 deletion src/receivers/HTTPReceiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import { createServer, Server, ServerOptions, RequestListener, IncomingMessage, ServerResponse } from 'http';
import { createServer as createHttpsServer, Server as HTTPSServer, ServerOptions as HTTPSServerOptions } from 'https';
import { ListenOptions } from 'net';
import { URL } from 'url';
import { Logger, ConsoleLogger, LogLevel } from '@slack/logger';
import { InstallProvider, CallbackOptions, InstallProviderOptions, InstallURLOptions, InstallPathOptions } from '@slack/oauth';
import { URL } from 'url';
import { match } from 'path-to-regexp';
import { ParamsDictionary } from 'express-serve-static-core';
import { ParamsIncomingMessage } from './ParamsIncomingMessage';
Expand Down
2 changes: 1 addition & 1 deletion src/receivers/HTTPResponseAck.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'mocha';
import { IncomingMessage, ServerResponse } from 'http';
import sinon from 'sinon';
import { assert } from 'chai';
import { IncomingMessage, ServerResponse } from 'http';
import { HTTPResponseAck } from './HTTPResponseAck';
import { HTTPModuleFunctions } from './HTTPModuleFunctions';
import { ReceiverMultipleAckError } from '../errors';
Expand Down
2 changes: 1 addition & 1 deletion src/receivers/HTTPResponseAck.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Logger } from '@slack/logger';
import { IncomingMessage, ServerResponse } from 'http';
import { Logger } from '@slack/logger';
import { AckFn } from '../types';
import { ReceiverMultipleAckError } from '../errors';
import { HTTPModuleFunctions as httpFunc, ReceiverUnhandledRequestHandlerArgs } from './HTTPModuleFunctions';
Expand Down
4 changes: 2 additions & 2 deletions src/receivers/SocketModeReceiver.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'mocha';
import { EventEmitter } from 'events';
import { IncomingMessage, ServerResponse } from 'http';
import sinon, { SinonSpy } from 'sinon';
import { assert } from 'chai';
import rewiremock from 'rewiremock';
import { Logger, LogLevel } from '@slack/logger';
import { EventEmitter } from 'events';
import { IncomingMessage, ServerResponse } from 'http';
import { match } from 'path-to-regexp';
import { ParamsDictionary } from 'express-serve-static-core';
import { InstallProvider } from '@slack/oauth';
Expand Down
2 changes: 1 addition & 1 deletion src/receivers/SocketModeReceiver.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { URL } from 'url';
import { SocketModeClient } from '@slack/socket-mode';
import { createServer, ServerResponse, Server } from 'http';
import { SocketModeClient } from '@slack/socket-mode';
import { Logger, ConsoleLogger, LogLevel } from '@slack/logger';
import { InstallProvider, CallbackOptions, InstallProviderOptions, InstallURLOptions, InstallPathOptions } from '@slack/oauth';
import { AppsConnectionsOpenResponse } from '@slack/web-api';
Expand Down
2 changes: 1 addition & 1 deletion src/receivers/http-utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ConsoleLogger } from '@slack/logger';
import { IncomingMessage } from 'http';
import { ConsoleLogger } from '@slack/logger';
import { HTTPModuleFunctions } from './HTTPModuleFunctions';

const logger = new ConsoleLogger();
Expand Down
2 changes: 1 addition & 1 deletion src/receivers/verify-request.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'mocha';
import { assert } from 'chai';
import { createHmac } from 'crypto';
import { assert } from 'chai';
import { isValidSlackRequest, verifySlackRequest } from './verify-request';

describe('Request verification', async () => {
Expand Down
4 changes: 2 additions & 2 deletions src/receivers/verify-request.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Deprecated: this function will be removed in the near future. Use HTTPModuleFunctions instead.
import { ConsoleLogger, Logger } from '@slack/logger';
import { createHmac } from 'crypto';
import tsscmp from 'tsscmp';
import type { IncomingMessage, ServerResponse } from 'http';
import { ConsoleLogger, Logger } from '@slack/logger';
import tsscmp from 'tsscmp';
import { BufferedIncomingMessage } from './BufferedIncomingMessage';
import { HTTPModuleFunctions, RequestVerificationOptions } from './HTTPModuleFunctions';

Expand Down
2 changes: 1 addition & 1 deletion src/types/actions/block-action.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('Interactivity payload types', () => {
type: 'block_actions',
user: {
id: 'W111',
name: 'seratch',
username: 'seratch',
team_id: 'T111',
},
api_app_id: 'A02',
Expand Down
7 changes: 5 additions & 2 deletions src/types/actions/block-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,12 @@ export interface BlockAction<ElementAction extends BasicElementAction = BlockEle
} | null;
user: {
id: string;
name: string;
/**
* name will be present if the block_action originates from the Home tab
*/
name?: string;
username: string;
team_id?: string; // undocumented
team_id?: string;
};
channel?: {
id: string;
Expand Down