123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351 |
- import {
- clusterSchemasPayload,
- schemaVersionsPayload,
- } from 'redux/reducers/schemas/__test__/fixtures';
- import * as actions from 'redux/actions';
- import {
- MessageSchemaSourceEnum,
- TopicColumnsToSort,
- TopicMessageSchema,
- } from 'generated-sources';
- import { FailurePayload } from 'redux/interfaces';
- import {
- topicMessagePayload,
- topicMessagesMetaPayload,
- } from 'redux/reducers/topicMessages/__test__/fixtures';
- import { fetchKsqlDbTablesPayload } from 'redux/reducers/ksqlDb/__test__/fixtures';
- import { mockTopicsState } from './fixtures';
- describe('Actions', () => {
- describe('fetchClusterStatsAction', () => {
- it('creates a REQUEST action', () => {
- expect(actions.fetchClusterStatsAction.request()).toEqual({
- type: 'GET_CLUSTER_STATUS__REQUEST',
- });
- });
- it('creates a SUCCESS action', () => {
- expect(
- actions.fetchClusterStatsAction.success({ brokerCount: 1 })
- ).toEqual({
- type: 'GET_CLUSTER_STATUS__SUCCESS',
- payload: {
- brokerCount: 1,
- },
- });
- });
- it('creates a FAILURE action', () => {
- expect(actions.fetchClusterStatsAction.failure()).toEqual({
- type: 'GET_CLUSTER_STATUS__FAILURE',
- });
- });
- });
- describe('fetchSchemasByClusterNameAction', () => {
- it('creates a REQUEST action', () => {
- expect(actions.fetchSchemasByClusterNameAction.request()).toEqual({
- type: 'GET_CLUSTER_SCHEMAS__REQUEST',
- });
- });
- it('creates a SUCCESS action', () => {
- expect(
- actions.fetchSchemasByClusterNameAction.success(clusterSchemasPayload)
- ).toEqual({
- type: 'GET_CLUSTER_SCHEMAS__SUCCESS',
- payload: clusterSchemasPayload,
- });
- });
- it('creates a FAILURE action', () => {
- expect(actions.fetchSchemasByClusterNameAction.failure()).toEqual({
- type: 'GET_CLUSTER_SCHEMAS__FAILURE',
- });
- });
- });
- describe('fetchSchemaVersionsAction', () => {
- it('creates a REQUEST action', () => {
- expect(actions.fetchSchemaVersionsAction.request()).toEqual({
- type: 'GET_SCHEMA_VERSIONS__REQUEST',
- });
- });
- it('creates a SUCCESS action', () => {
- expect(
- actions.fetchSchemaVersionsAction.success(schemaVersionsPayload)
- ).toEqual({
- type: 'GET_SCHEMA_VERSIONS__SUCCESS',
- payload: schemaVersionsPayload,
- });
- });
- it('creates a FAILURE action', () => {
- expect(actions.fetchSchemaVersionsAction.failure()).toEqual({
- type: 'GET_SCHEMA_VERSIONS__FAILURE',
- });
- });
- });
- describe('createSchemaAction', () => {
- it('creates a REQUEST action', () => {
- expect(actions.createSchemaAction.request()).toEqual({
- type: 'POST_SCHEMA__REQUEST',
- });
- });
- it('creates a SUCCESS action', () => {
- expect(
- actions.createSchemaAction.success(schemaVersionsPayload[0])
- ).toEqual({
- type: 'POST_SCHEMA__SUCCESS',
- payload: schemaVersionsPayload[0],
- });
- });
- it('creates a FAILURE action', () => {
- expect(actions.createSchemaAction.failure({})).toEqual({
- type: 'POST_SCHEMA__FAILURE',
- payload: {},
- });
- });
- });
- describe('dismissAlert', () => {
- it('creates a REQUEST action', () => {
- const id = 'alert-id1';
- expect(actions.dismissAlert(id)).toEqual({
- type: 'DISMISS_ALERT',
- payload: id,
- });
- });
- });
- describe('clearMessagesTopicAction', () => {
- it('creates a REQUEST action', () => {
- expect(actions.clearMessagesTopicAction.request()).toEqual({
- type: 'CLEAR_TOPIC_MESSAGES__REQUEST',
- });
- });
- it('creates a SUCCESS action', () => {
- expect(actions.clearMessagesTopicAction.success()).toEqual({
- type: 'CLEAR_TOPIC_MESSAGES__SUCCESS',
- });
- });
- it('creates a FAILURE action', () => {
- expect(actions.clearMessagesTopicAction.failure({})).toEqual({
- type: 'CLEAR_TOPIC_MESSAGES__FAILURE',
- payload: {},
- });
- });
- });
- describe('fetchTopicConsumerGroups', () => {
- it('creates a REQUEST action', () => {
- expect(actions.fetchTopicConsumerGroupsAction.request()).toEqual({
- type: 'GET_TOPIC_CONSUMER_GROUPS__REQUEST',
- });
- });
- it('creates a SUCCESS action', () => {
- expect(
- actions.fetchTopicConsumerGroupsAction.success(mockTopicsState)
- ).toEqual({
- type: 'GET_TOPIC_CONSUMER_GROUPS__SUCCESS',
- payload: mockTopicsState,
- });
- });
- it('creates a FAILURE action', () => {
- expect(actions.fetchTopicConsumerGroupsAction.failure()).toEqual({
- type: 'GET_TOPIC_CONSUMER_GROUPS__FAILURE',
- });
- });
- });
- describe('setTopicsSearchAction', () => {
- it('creartes SET_TOPICS_SEARCH', () => {
- expect(actions.setTopicsSearchAction('test')).toEqual({
- type: 'SET_TOPICS_SEARCH',
- payload: 'test',
- });
- });
- });
- describe('setTopicsOrderByAction', () => {
- it('creartes SET_TOPICS_ORDER_BY', () => {
- expect(actions.setTopicsOrderByAction(TopicColumnsToSort.NAME)).toEqual({
- type: 'SET_TOPICS_ORDER_BY',
- payload: TopicColumnsToSort.NAME,
- });
- });
- });
- describe('deleting consumer group', () => {
- it('creates DELETE_CONSUMER_GROUP__REQUEST', () => {
- expect(actions.deleteConsumerGroupAction.request()).toEqual({
- type: 'DELETE_CONSUMER_GROUP__REQUEST',
- });
- });
- it('creates DELETE_CONSUMER_GROUP__SUCCESS', () => {
- expect(actions.deleteConsumerGroupAction.success('test')).toEqual({
- type: 'DELETE_CONSUMER_GROUP__SUCCESS',
- payload: 'test',
- });
- });
- it('creates DELETE_CONSUMER_GROUP__FAILURE', () => {
- const alert: FailurePayload = {
- subject: ['consumer-group', 'test'].join('-'),
- title: `Consumer Gropup Test`,
- };
- expect(actions.deleteConsumerGroupAction.failure({ alert })).toEqual({
- type: 'DELETE_CONSUMER_GROUP__FAILURE',
- payload: { alert },
- });
- });
- });
- describe('topic messages', () => {
- it('creates ADD_TOPIC_MESSAGE', () => {
- expect(actions.addTopicMessage(topicMessagePayload)).toEqual({
- type: 'ADD_TOPIC_MESSAGE',
- payload: topicMessagePayload,
- });
- });
- it('creates RESET_TOPIC_MESSAGES', () => {
- expect(actions.resetTopicMessages()).toEqual({
- type: 'RESET_TOPIC_MESSAGES',
- });
- });
- it('creates UPDATE_TOPIC_MESSAGES_PHASE', () => {
- expect(actions.updateTopicMessagesPhase('Polling')).toEqual({
- type: 'UPDATE_TOPIC_MESSAGES_PHASE',
- payload: 'Polling',
- });
- });
- it('creates UPDATE_TOPIC_MESSAGES_META', () => {
- expect(actions.updateTopicMessagesMeta(topicMessagesMetaPayload)).toEqual(
- {
- type: 'UPDATE_TOPIC_MESSAGES_META',
- payload: topicMessagesMetaPayload,
- }
- );
- });
- });
- describe('sending messages', () => {
- describe('fetchTopicMessageSchemaAction', () => {
- it('creates GET_TOPIC_SCHEMA__REQUEST', () => {
- expect(actions.fetchTopicMessageSchemaAction.request()).toEqual({
- type: 'GET_TOPIC_SCHEMA__REQUEST',
- });
- });
- it('creates GET_TOPIC_SCHEMA__SUCCESS', () => {
- const messageSchema: TopicMessageSchema = {
- key: {
- name: 'key',
- source: MessageSchemaSourceEnum.SCHEMA_REGISTRY,
- schema: `{
- "$schema": "http://json-schema.org/draft-07/schema#",
- "$id": "http://example.com/myURI.schema.json",
- "title": "TestRecord",
- "type": "object",
- "additionalProperties": false,
- "properties": {
- "f1": {
- "type": "integer"
- },
- "f2": {
- "type": "string"
- },
- "schema": {
- "type": "string"
- }
- }
- }
- `,
- },
- value: {
- name: 'value',
- source: MessageSchemaSourceEnum.SCHEMA_REGISTRY,
- schema: `{
- "$schema": "http://json-schema.org/draft-07/schema#",
- "$id": "http://example.com/myURI1.schema.json",
- "title": "TestRecord",
- "type": "object",
- "additionalProperties": false,
- "properties": {
- "f1": {
- "type": "integer"
- },
- "f2": {
- "type": "string"
- },
- "schema": {
- "type": "string"
- }
- }
- }
- `,
- },
- };
- expect(
- actions.fetchTopicMessageSchemaAction.success({
- topicName: 'test',
- schema: messageSchema,
- })
- ).toEqual({
- type: 'GET_TOPIC_SCHEMA__SUCCESS',
- payload: {
- topicName: 'test',
- schema: messageSchema,
- },
- });
- });
- it('creates GET_TOPIC_SCHEMA__FAILURE', () => {
- const alert: FailurePayload = {
- subject: ['message-chema', 'test'].join('-'),
- title: `Message Schema Test`,
- };
- expect(
- actions.fetchTopicMessageSchemaAction.failure({ alert })
- ).toEqual({
- type: 'GET_TOPIC_SCHEMA__FAILURE',
- payload: { alert },
- });
- });
- });
- });
- });
- describe('ksqlDb', () => {
- it('creates GET_KSQL_DB_TABLES_AND_STREAMS__REQUEST', () => {
- expect(actions.fetchKsqlDbTablesAction.request()).toEqual({
- type: 'GET_KSQL_DB_TABLES_AND_STREAMS__REQUEST',
- });
- });
- it('creates GET_KSQL_DB_TABLES_AND_STREAMS__SUCCESS', () => {
- expect(
- actions.fetchKsqlDbTablesAction.success(fetchKsqlDbTablesPayload)
- ).toEqual({
- type: 'GET_KSQL_DB_TABLES_AND_STREAMS__SUCCESS',
- payload: fetchKsqlDbTablesPayload,
- });
- });
- it('creates GET_KSQL_DB_TABLES_AND_STREAMS__FAILURE', () => {
- expect(actions.fetchKsqlDbTablesAction.failure({})).toEqual({
- type: 'GET_KSQL_DB_TABLES_AND_STREAMS__FAILURE',
- payload: {},
- });
- });
- });
|