Skip to content

Commit

Permalink
fix: devfile.io index route
Browse files Browse the repository at this point in the history
Signed-off-by: Oleksii Orel <[email protected]>
  • Loading branch information
olexii4 committed Mar 6, 2025
1 parent 13063fb commit 09bb1bd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ describe('fetch registry metadata', () => {
await fetchRegistryMetadata(baseUrl, true);

expect(mockFetchData).toHaveBeenCalledWith(
'https://eclipse-che.github.io/che-devfile-registry/7.71.0/index',
'https://eclipse-che.github.io/che-devfile-registry/7.71.0/index/all',
);
expect(mockFetchRemoteData.mock.calls).toEqual([
[`https://eclipse-che.github.io/che-devfile-registry/7.71.0/index`],
[`https://eclipse-che.github.io/che-devfile-registry/7.71.0/index/all`],
[`https://eclipse-che.github.io/che-devfile-registry/7.71.0/devfiles/index.json`],
]);
});
Expand All @@ -117,12 +117,12 @@ describe('fetch registry metadata', () => {
SessionStorageKey.EXTERNAL_REGISTRIES,
);
expect(mockFetchRemoteData).toHaveBeenCalledWith(
'https://eclipse-che.github.io/che-devfile-registry/7.71.0/index',
'https://eclipse-che.github.io/che-devfile-registry/7.71.0/index/all',
);
expect(mockSessionStorageServiceUpdate).toHaveBeenCalledWith(
SessionStorageKey.EXTERNAL_REGISTRIES,
JSON.stringify({
'https://eclipse-che.github.io/che-devfile-registry/7.71.0/index': {
'https://eclipse-che.github.io/che-devfile-registry/7.71.0/index/all': {
metadata: [metadata],
lastFetched: 1555555555555,
},
Expand Down Expand Up @@ -174,7 +174,7 @@ describe('fetch registry metadata', () => {
SessionStorageKey.EXTERNAL_REGISTRIES,
);
expect(mockFetchRemoteData.mock.calls).toEqual([
['https://eclipse-che.github.io/che-devfile-registry/7.71.0/index'],
['https://eclipse-che.github.io/che-devfile-registry/7.71.0/index/all'],
['https://eclipse-che.github.io/che-devfile-registry/7.71.0/devfiles/index.json'],
]);
expect(mockSessionStorageServiceUpdate).not.toHaveBeenCalled();
Expand Down Expand Up @@ -214,13 +214,13 @@ describe('fetch registry metadata', () => {
SessionStorageKey.EXTERNAL_REGISTRIES,
);
expect(mockFetchRemoteData).toHaveBeenCalledWith(
'https://eclipse-che.github.io/che-devfile-registry/7.71.0/index',
'https://eclipse-che.github.io/che-devfile-registry/7.71.0/index/all',
);
expect(console.warn).toHaveBeenCalledTimes(2);
expect(mockSessionStorageServiceUpdate).toHaveBeenCalledWith(
SessionStorageKey.EXTERNAL_REGISTRIES,
JSON.stringify({
'https://eclipse-che.github.io/che-devfile-registry/7.71.0/index': {
'https://eclipse-che.github.io/che-devfile-registry/7.71.0/index/all': {
metadata: [metadata],
lastFetched: 1555555555555,
},
Expand All @@ -244,7 +244,7 @@ describe('fetch registry metadata', () => {
mockFetchRemoteData.mockResolvedValue([metadata]);
mockSessionStorageServiceGet.mockReturnValue(
JSON.stringify({
'https://eclipse-che.github.io/che-devfile-registry/7.71.0/index': {
'https://eclipse-che.github.io/che-devfile-registry/7.71.0/index/all': {
metadata: [metadata],
lastFetched: time,
},
Expand Down Expand Up @@ -276,7 +276,7 @@ describe('fetch registry metadata', () => {
mockFetchRemoteData.mockResolvedValue([metadata]);
mockSessionStorageServiceGet.mockReturnValue(
JSON.stringify({
'https://eclipse-che.github.io/che-devfile-registry/7.71.0/index': {
'https://eclipse-che.github.io/che-devfile-registry/7.71.0/index/all': {
metadata: [metadata],
lastFetched: time,
},
Expand All @@ -289,12 +289,12 @@ describe('fetch registry metadata', () => {
SessionStorageKey.EXTERNAL_REGISTRIES,
);
expect(mockFetchRemoteData).toHaveBeenCalledWith(
'https://eclipse-che.github.io/che-devfile-registry/7.71.0/index',
'https://eclipse-che.github.io/che-devfile-registry/7.71.0/index/all',
);
expect(mockSessionStorageServiceUpdate).toHaveBeenCalledWith(
SessionStorageKey.EXTERNAL_REGISTRIES,
JSON.stringify({
'https://eclipse-che.github.io/che-devfile-registry/7.71.0/index': {
'https://eclipse-che.github.io/che-devfile-registry/7.71.0/index/all': {
metadata: [metadata],
lastFetched: time + elapsedTime,
},
Expand Down Expand Up @@ -325,11 +325,11 @@ describe('fetch registry metadata', () => {
expect(mockSessionStorageServiceGet).toHaveBeenCalledWith(
SessionStorageKey.EXTERNAL_REGISTRIES,
);
expect(mockFetchRemoteData).toHaveBeenCalledWith('https://registry.devfile.io/index');
expect(mockFetchRemoteData).toHaveBeenCalledWith('https://registry.devfile.io/index/all');
expect(mockSessionStorageServiceUpdate).toHaveBeenCalledWith(
SessionStorageKey.EXTERNAL_REGISTRIES,
JSON.stringify({
'https://registry.devfile.io/index': {
'https://registry.devfile.io/index/all': {
metadata: [metadata],
lastFetched: 1555555555555,
},
Expand All @@ -353,7 +353,7 @@ describe('fetch registry metadata', () => {
expect(mockSessionStorageServiceGet).toHaveBeenCalledWith(
SessionStorageKey.EXTERNAL_REGISTRIES,
);
expect(mockFetchRemoteData).toHaveBeenCalledWith('https://registry.devfile.io/index');
expect(mockFetchRemoteData).toHaveBeenCalledWith('https://registry.devfile.io/index/all');
expect(mockSessionStorageServiceUpdate).not.toHaveBeenCalled();
expect(errorMessage).toEqual(
'Failed to fetch devfiles metadata from registry URL: https://registry.devfile.io/, reason: Returned value is not array.',
Expand Down Expand Up @@ -390,12 +390,12 @@ describe('fetch registry metadata', () => {
expect(mockSessionStorageServiceGet).toHaveBeenCalledWith(
SessionStorageKey.EXTERNAL_REGISTRIES,
);
expect(mockFetchRemoteData).toHaveBeenCalledWith('https://registry.devfile.io/index');
expect(mockFetchRemoteData).toHaveBeenCalledWith('https://registry.devfile.io/index/all');
expect(console.warn).toHaveBeenCalledTimes(2);
expect(mockSessionStorageServiceUpdate).toHaveBeenCalledWith(
SessionStorageKey.EXTERNAL_REGISTRIES,
JSON.stringify({
'https://registry.devfile.io/index': {
'https://registry.devfile.io/index/all': {
metadata: [metadata],
lastFetched: 1555555555555,
},
Expand All @@ -419,7 +419,7 @@ describe('fetch registry metadata', () => {
mockFetchRemoteData.mockResolvedValue([metadata]);
mockSessionStorageServiceGet.mockReturnValue(
JSON.stringify({
'https://registry.devfile.io/index': {
'https://registry.devfile.io/index/all': {
metadata: [metadata],
lastFetched: time,
},
Expand Down Expand Up @@ -451,7 +451,7 @@ describe('fetch registry metadata', () => {
mockFetchRemoteData.mockResolvedValue([metadata]);
mockSessionStorageServiceGet.mockReturnValue(
JSON.stringify({
'https://registry.devfile.io/index': {
'https://registry.devfile.io/index/all': {
metadata: [metadata],
lastFetched: time,
},
Expand All @@ -463,11 +463,11 @@ describe('fetch registry metadata', () => {
expect(mockSessionStorageServiceGet).toHaveBeenCalledWith(
SessionStorageKey.EXTERNAL_REGISTRIES,
);
expect(mockFetchRemoteData).toHaveBeenCalledWith('https://registry.devfile.io/index');
expect(mockFetchRemoteData).toHaveBeenCalledWith('https://registry.devfile.io/index/all');
expect(mockSessionStorageServiceUpdate).toHaveBeenCalledWith(
SessionStorageKey.EXTERNAL_REGISTRIES,
JSON.stringify({
'https://registry.devfile.io/index': {
'https://registry.devfile.io/index/all': {
metadata: [metadata],
lastFetched: time + elapsedTime,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export function getRegistryIndexLocations(registryUrl: string, isExternal: boole
registryUrl = registryUrl[registryUrl.length - 1] === '/' ? registryUrl : registryUrl + '/';
const registryIndexLocations: Array<string> = [];
if (isExternal) {
const indexUrl = new URL('index', registryUrl);
const indexUrl = new URL('index/all', registryUrl);
registryIndexLocations.push(indexUrl.href);

const deprecatedIndexUrl = new URL('devfiles/index.json', registryUrl);
Expand Down

0 comments on commit 09bb1bd

Please sign in to comment.