Skip to content

Commit

Permalink
Renamed CrawlCustomSettingsFlyoutLogic.actions.includeRobotsTxt to in…
Browse files Browse the repository at this point in the history
…cludeSitemapsInRobotsTxt
  • Loading branch information
Byron Hulcher committed Feb 15, 2022
1 parent 082c135 commit 8d9ca6f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('CrawlCustomSettingsFlyoutLogic', () => {
domainConfigs: [],
domainUrls: [],
entryPointUrls: [],
includeRobotsTxt: true,
includeSitemapsInRobotsTxt: true,
isDataLoading: true,
isFlyoutVisible: false,
isFormSubmitting: false,
Expand Down Expand Up @@ -257,7 +257,7 @@ describe('CrawlCustomSettingsFlyoutLogic', () => {
'https://www.elastic.co/custom-sitemap1.xml',
'https://swiftype.com/custom-sitemap2.xml',
],
includeRobotsTxt: false,
includeSitemapsInRobotsTxt: false,
isDataLoading: false,
isFlyoutVisible: false,
selectedDomainUrls: ['https://www.elastic.co', 'https://swiftype.com'],
Expand All @@ -277,7 +277,7 @@ describe('CrawlCustomSettingsFlyoutLogic', () => {
expect.objectContaining({
customEntryPointUrls: [],
customSitemapUrls: [],
includeRobotsTxt: true,
includeSitemapsInRobotsTxt: true,
isDataLoading: true,
isFlyoutVisible: true,
selectedDomainUrls: [],
Expand All @@ -299,7 +299,7 @@ describe('CrawlCustomSettingsFlyoutLogic', () => {
describe('startCustomCrawl', () => {
it('starts a custom crawl with the user set values', async () => {
mount({
includeRobotsTxt: true,
includeSitemapsInRobotsTxt: true,
maxCrawlDepth: 5,
selectedDomainUrls: ['https://www.elastic.co', 'https://swiftype.com'],
selectedEntryPointUrls: [
Expand Down Expand Up @@ -329,23 +329,23 @@ describe('CrawlCustomSettingsFlyoutLogic', () => {
});
});

describe('toggleIncludeRobotsTxt', () => {
describe('toggleIncludeSitemapsInRobotsTxt', () => {
it('toggles the flag', () => {
mount({
includeRobotsTxt: false,
includeSitemapsInRobotsTxt: false,
});

CrawlCustomSettingsFlyoutLogic.actions.toggleIncludeRobotsTxt();
CrawlCustomSettingsFlyoutLogic.actions.toggleIncludeSitemapsInRobotsTxt();

expect(CrawlCustomSettingsFlyoutLogic.values.includeRobotsTxt).toEqual(true);
expect(CrawlCustomSettingsFlyoutLogic.values.includeSitemapsInRobotsTxt).toEqual(true);

mount({
includeRobotsTxt: true,
includeSitemapsInRobotsTxt: true,
});

CrawlCustomSettingsFlyoutLogic.actions.toggleIncludeRobotsTxt();
CrawlCustomSettingsFlyoutLogic.actions.toggleIncludeSitemapsInRobotsTxt();

expect(CrawlCustomSettingsFlyoutLogic.values.includeRobotsTxt).toEqual(false);
expect(CrawlCustomSettingsFlyoutLogic.values.includeSitemapsInRobotsTxt).toEqual(false);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface CrawlCustomSettingsFlyoutLogicValues {
[key: string]: DomainConfig;
};
entryPointUrls: string[];
includeRobotsTxt: boolean;
includeSitemapsInRobotsTxt: boolean;
isDataLoading: boolean;
isFormSubmitting: boolean;
isFlyoutVisible: boolean;
Expand All @@ -48,7 +48,7 @@ export interface CrawlCustomSettingsFlyoutLogicActions {
onSelectSitemapUrls(sitemapUrls: string[]): { sitemapUrls: string[] };
showFlyout(): void;
startCustomCrawl(): void;
toggleIncludeRobotsTxt(): void;
toggleIncludeSitemapsInRobotsTxt(): void;
}

const filterSeedUrlsByDomainUrls = (seedUrls: string[], domainUrls: string[]): string[] => {
Expand Down Expand Up @@ -78,7 +78,7 @@ export const CrawlCustomSettingsFlyoutLogic = kea<
onSelectMaxCrawlDepth: (maxCrawlDepth) => ({ maxCrawlDepth }),
onSelectSitemapUrls: (sitemapUrls) => ({ sitemapUrls }),
startCustomCrawl: true,
toggleIncludeRobotsTxt: true,
toggleIncludeSitemapsInRobotsTxt: true,
showFlyout: true,
}),
reducers: () => ({
Expand All @@ -102,11 +102,12 @@ export const CrawlCustomSettingsFlyoutLogic = kea<
onRecieveDomainConfigData: (_, { domainConfigs }) => domainConfigs,
},
],
includeRobotsTxt: [
includeSitemapsInRobotsTxt: [
true,
{
showFlyout: () => true,
toggleIncludeRobotsTxt: (includeRobotsTxt) => !includeRobotsTxt,
toggleIncludeSitemapsInRobotsTxt: (includeSitemapsInRobotsTxt) =>
!includeSitemapsInRobotsTxt,
},
],
isDataLoading: [
Expand Down Expand Up @@ -217,7 +218,7 @@ export const CrawlCustomSettingsFlyoutLogic = kea<
max_crawl_depth: values.maxCrawlDepth,
seed_urls: [...values.selectedEntryPointUrls, ...values.customEntryPointUrls],
sitemap_urls: [...values.selectedSitemapUrls, ...values.customSitemapUrls],
sitemap_discovery_disabled: !values.includeRobotsTxt,
sitemap_discovery_disabled: !values.includeSitemapsInRobotsTxt,
});
},
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const MOCK_VALUES = {
'https://swiftype.com/sitemap1.xml',
'https://swiftype.com/sitemap2.xml',
],
includeRobotsTxt: true,
includeSitemapsInRobotsTxt: true,
};

const MOCK_ACTIONS = {
Expand All @@ -45,7 +45,7 @@ const MOCK_ACTIONS = {
onSelectCustomSitemapUrls: jest.fn(),
onSelectEntryPointUrls: jest.fn(),
onSelectSitemapUrls: jest.fn(),
toggleIncludeRobotsTxt: jest.fn(),
toggleIncludeSitemapsInRobotsTxt: jest.fn(),
};

const getAccordionBadge = (wrapper: ShallowWrapper) => {
Expand Down Expand Up @@ -84,7 +84,7 @@ describe('CrawlCustomSettingsFlyoutSeedUrlsPanel', () => {
it('allows the user to toggle whether to include robots.txt sitemaps', () => {
expect(sitemapTab.find(EuiCheckbox).props()).toEqual(
expect.objectContaining({
onChange: MOCK_ACTIONS.toggleIncludeRobotsTxt,
onChange: MOCK_ACTIONS.toggleIncludeSitemapsInRobotsTxt,
checked: true,
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const CrawlCustomSettingsFlyoutSeedUrlsPanel: React.FC = () => {
customEntryPointUrls,
customSitemapUrls,
entryPointUrls,
includeRobotsTxt,
includeSitemapsInRobotsTxt,
selectedDomainUrls,
selectedEntryPointUrls,
selectedSitemapUrls,
Expand All @@ -48,7 +48,7 @@ export const CrawlCustomSettingsFlyoutSeedUrlsPanel: React.FC = () => {
onSelectCustomSitemapUrls,
onSelectEntryPointUrls,
onSelectSitemapUrls,
toggleIncludeRobotsTxt,
toggleIncludeSitemapsInRobotsTxt,
} = useActions(CrawlCustomSettingsFlyoutLogic);

const totalSeedUrls =
Expand Down Expand Up @@ -123,8 +123,8 @@ export const CrawlCustomSettingsFlyoutSeedUrlsPanel: React.FC = () => {
}}
/>
}
checked={includeRobotsTxt}
onChange={toggleIncludeRobotsTxt}
checked={includeSitemapsInRobotsTxt}
onChange={toggleIncludeSitemapsInRobotsTxt}
/>
</EuiPanel>
<SimplifiedSelectable
Expand Down

0 comments on commit 8d9ca6f

Please sign in to comment.