Skip to content

Commit

Permalink
Merge branch 'main' into metrics-automate
Browse files Browse the repository at this point in the history
  • Loading branch information
solaris007 authored Jan 11, 2025
2 parents 0438f36 + 2ae677b commit 2fec3cc
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 758 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## [1.46.8](https://github.com/adobe/spacecat-audit-worker/compare/v1.46.7...v1.46.8) (2025-01-10)


### Bug Fixes

* remove path containing accessible urls ([#575](https://github.com/adobe/spacecat-audit-worker/issues/575)) ([128303e](https://github.com/adobe/spacecat-audit-worker/commit/128303ed706bbe1a19545cca2281d28acce0297b))

## [1.46.7](https://github.com/adobe/spacecat-audit-worker/compare/v1.46.6...v1.46.7) (2025-01-10)


### Bug Fixes

* **deps:** update dependency @adobe/spacecat-shared-data-access to v1.61.19 ([#574](https://github.com/adobe/spacecat-audit-worker/issues/574)) ([870e6e3](https://github.com/adobe/spacecat-audit-worker/commit/870e6e30e8054703f5a9fbf9e34d587d6dd0edf2))

## [1.46.6](https://github.com/adobe/spacecat-audit-worker/compare/v1.46.5...v1.46.6) (2025-01-09)


Expand Down
715 changes: 6 additions & 709 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobe/spacecat-audit-worker",
"version": "1.46.6",
"version": "1.46.8",
"description": "SpaceCat Audit Worker",
"main": "src/index.js",
"type": "module",
Expand Down Expand Up @@ -61,7 +61,7 @@
"@adobe/helix-universal": "5.0.8",
"@adobe/helix-universal-logger": "3.0.23",
"@adobe/spacecat-shared-ahrefs-client": "1.6.2",
"@adobe/spacecat-shared-data-access": "1.61.18",
"@adobe/spacecat-shared-data-access": "2.0.0",
"@adobe/spacecat-shared-google-client": "1.4.3",
"@adobe/spacecat-shared-http-utils": "1.9.3",
"@adobe/spacecat-shared-rum-api-client": "2.18.0",
Expand Down
1 change: 0 additions & 1 deletion src/sitemap/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ export async function findSitemap(inputUrl) {
return {
success: true,
reasons: [{ value: 'Sitemaps found and checked.' }],
paths: extractedPaths,
url: inputUrl,
details: { issues: notOkPagesFromSitemap },
};
Expand Down
2 changes: 1 addition & 1 deletion test/audits/backlinks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

/* eslint-env mocha */
import { Configuration } from '@adobe/spacecat-shared-data-access';
import ConfigurationSchema from '@adobe/spacecat-shared-data-access/src/v2/models/configuration/configuration.schema.js';
import ConfigurationSchema from '@adobe/spacecat-shared-data-access/src/models/configuration/configuration.schema.js';
import { Config } from '@adobe/spacecat-shared-data-access/src/models/site/config.js';
import { expect, use } from 'chai';
import chaiAsPromised from 'chai-as-promised';
Expand Down
3 changes: 1 addition & 2 deletions test/audits/forms.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { expect, use } from 'chai';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
import nock from 'nock';
import { createSite } from '@adobe/spacecat-shared-data-access/src/models/site.js';
import { formsAuditRunner } from '../../src/forms-opportunities/handler.js';
import { MockContextBuilder } from '../shared.js';
import formVitalsData from '../fixtures/formvitalsdata.json' with { type: 'json' };
Expand All @@ -29,7 +28,7 @@ const sandbox = sinon.createSandbox();
const baseURL = 'https://example.com';

describe('Forms Vitals audit', () => {
const site = createSite({ baseURL });
const site = { getBaseURL: () => baseURL };

const context = new MockContextBuilder()
.withSandbox(sandbox)
Expand Down
4 changes: 2 additions & 2 deletions test/audits/internal-links.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { expect, use } from 'chai';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
import nock from 'nock';
import { createSite } from '@adobe/spacecat-shared-data-access/src/models/site.js';

import { internalLinksAuditRunner, convertToOpportunity } from '../../src/internal-links/handler.js';
import { internalLinksData, expectedOpportunity, expectedSuggestions } from '../fixtures/internal-links-data.js';
import { MockContextBuilder } from '../shared.js';
Expand Down Expand Up @@ -50,7 +50,7 @@ const baseURL = 'https://example.com';
const auditUrl = 'www.example.com';

describe('Broken internal links audit', () => {
const site = createSite({ baseURL });
const site = { getBaseURL: () => baseURL };

const context = new MockContextBuilder()
.withSandbox(sandbox)
Expand Down
10 changes: 4 additions & 6 deletions test/audits/site-detection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import sinon from 'sinon';
import sinonChai from 'sinon-chai';
import chaiAsPromised from 'chai-as-promised';
import nock from 'nock';
import { createSite } from '@adobe/spacecat-shared-data-access/src/models/site.js';
import { createSiteCandidate } from '@adobe/spacecat-shared-data-access/src/models/site-candidate.js';
import { readFileSync, readdirSync } from 'fs';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
Expand Down Expand Up @@ -64,11 +62,11 @@ describe('site-detection runner tests', () => {

beforeEach('setup', () => {
sites = [
createSite({ baseURL: 'https://spacecat1.com' }),
createSite({ baseURL: 'https://spacecat2.com' })];
{ getBaseURL: () => 'https://spacecat1.com' },
{ getBaseURL: () => 'https://spacecat2.com' }];
siteCandidates = [
createSiteCandidate({ baseURL: 'https://spacecat3.com' }),
createSiteCandidate({ baseURL: 'https://spacecat4.com' }),
{ getBaseURL: () => 'https://spacecat3.com' },
{ getBaseURL: () => 'https://spacecat4.com' },
];
context.dataAccess.Site.all.resolves(sites);
context.dataAccess.SiteCandidate.all.resolves(siteCandidates);
Expand Down
25 changes: 0 additions & 25 deletions test/audits/sitemap.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@ describe('Sitemap Audit', () => {
issues: {},
},
success: true,
paths: {
[`${url}/sitemap_foo.xml`]: [`${url}/foo`, `${url}/bar`],
[`${url}/sitemap_bar.xml`]: [`${url}/baz`, `${url}/cux`],
},
reasons: [{
value: 'Sitemaps found and checked.',
}],
Expand Down Expand Up @@ -175,10 +171,6 @@ describe('Sitemap Audit', () => {
issues: {},
},
success: true,
paths: {
[`${url}/sitemap_foo.xml`]: [`${url}/foo`, `${url}/bar`],
[`${url}/sitemap_bar.xml`]: [`${url}/baz`, `${url}/cux`],
},
reasons: [{
value: 'Sitemaps found and checked.',
}],
Expand Down Expand Up @@ -225,10 +217,6 @@ describe('Sitemap Audit', () => {
issues: {},
},
success: true,
paths: {
[`${url}/sitemap_foo.txt`]: [`${url}/foo`, `${url}/bar`],
[`${url}/sitemap_bar.txt`]: [`${url}/baz`, `${url}/cux`],
},
reasons: [{
value: 'Sitemaps found and checked.',
}],
Expand Down Expand Up @@ -531,9 +519,6 @@ describe('Sitemap Audit', () => {

const result = await findSitemap(url);
expect(result.success).to.equal(true);
expect(result.paths).to.deep.equal({
[`${url}/sitemap.xml`]: [`${url}/foo`, `${url}/bar`],
});
});

it('should fail when sitemap contents have a different URL than the base domain (regardless of www. or not)', async () => {
Expand Down Expand Up @@ -617,9 +602,6 @@ describe('Sitemap Audit', () => {
info: () => {},
});
expect(result.success).to.equal(true);
expect(result.paths).to.deep.equal({
[`${url}/sitemap.xml`]: [`${url}/foo`, `${url}/bar`],
});
});

it('should return success when sitemap_index.xml is found', async () => {
Expand Down Expand Up @@ -665,10 +647,6 @@ describe('Sitemap Audit', () => {

const result = await findSitemap(url);
expect(result.success).to.equal(true);
expect(result.paths).to.deep.equal({
[`${url}/sitemap_foo.xml`]: [`${url}/foo`, `${url}/bar`],
[`${url}/sitemap_bar.xml`]: [`${url}/baz`, `${url}/cux`],
});
});

it('should return success when sitemap paths have www', async () => {
Expand All @@ -690,9 +668,6 @@ describe('Sitemap Audit', () => {

const result = await findSitemap(`${protocol}://www.${domain}`);
expect(result.success).to.equal(true);
expect(result.paths).to.deep.equal({
[`${url}/sitemap.xml`]: [`${protocol}://www.${domain}/foo`, `${protocol}://www.${domain}/bar`],
});
});

it('should return error when no sitemap is found', async () => {
Expand Down
22 changes: 12 additions & 10 deletions test/common/audit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

/* eslint-env mocha */
import { createConfiguration } from '@adobe/spacecat-shared-data-access/src/models/configuration.js';

import { expect, use } from 'chai';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';
Expand Down Expand Up @@ -71,10 +71,11 @@ describe('Audit tests', () => {
getIsLive: () => true,
getIsError: () => false,
};
const configurationData = {
version: '1.0',
queues: {},
handlers: {
configuration = {
getVersion: () => '1.0',
getQueues: () => {
},
getHandlers: () => ({
dummy: {
enabled: {
sites: ['site-id', 'space.cat', site.getId()],
Expand All @@ -83,10 +84,12 @@ describe('Audit tests', () => {
enabledByDefault: false,
dependencies: [],
},
},
jobs: [],
}),
getJobs: () => [],
isHandlerEnabledForSite: () => true,
disableHandlerForSite: () => true,
disableHandlerForOrg: () => true,
};
configuration = createConfiguration(configurationData);
});

afterEach('clean', () => {
Expand Down Expand Up @@ -202,8 +205,7 @@ describe('Audit tests', () => {
});

it('audit run skips when audit is disabled', async () => {
configuration.disableHandlerForSite('dummy', { getId: () => site.getId(), getOrganizationId: () => org.getId() });
configuration.disableHandlerForOrg('dummy', org);
configuration.isHandlerEnabledForSite = sinon.stub().returns(false);
const queueUrl = 'some-queue-url';
context.env = { AUDIT_RESULTS_QUEUE_URL: queueUrl };
context.dataAccess.Site.findById.withArgs(message.siteId).resolves(site);
Expand Down

0 comments on commit 2fec3cc

Please sign in to comment.