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

Inject defaultCatalog property to chaise-config and remove catalog alias creation step #2497

Merged
merged 2 commits into from
Aug 2, 2024
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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ module.exports = {
'@typescript-eslint/no-unsafe-function-type': 'warn',
'@typescript-eslint/ban-ts-comment': 'warn',
'@typescript-eslint/no-inferrable-types': 'warn',
'@typescript-eslint/no-require-imports': 'warn',
// TODO we should remove the following deprecated rule when we go to version 8:
'@typescript-eslint/ban-types': 'warn',

Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,10 @@ lint: $(SOURCE)
lint-w-warn: $(SOURCE)
@npx eslint src --ext .ts,.tsx

.PHONY: lint-tests
lint-tests:
npx eslint test/e2e --ext .ts,.tsx --quiet

# Rule to create the package.
.PHONY: dist-wo-deps
dist-wo-deps: print-variables run-webpack $(SASS) $(MIN) $(HTML) gitversion
Expand Down
8 changes: 8 additions & 0 deletions test/e2e/setup/playwright.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ export type TestOptions = {
*/
chaiseConfigFilePath?: string,

/**
* if set to to true, we will inject the "defaultCatalog" property
* into the chaise-config.js file.
*
* the id of the catalog created for the chrome project will be used for this.
*/
addDefaultCatalogToChaiseConfig?: boolean,

manualTestConfig?: boolean,

/**
Expand Down
30 changes: 23 additions & 7 deletions test/e2e/setup/playwright.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { FullConfig } from '@playwright/test';
import axios from 'axios';
import { execSync } from 'child_process';
import fs from 'fs';
import path from 'path';

import { TestOptions } from '@isrd-isi-edu/chaise/test/e2e/setup/playwright.model';
import { removeAllCatalogs, setupCatalog } from '@isrd-isi-edu/chaise/test/e2e/utils/catalog-utils';
import { ENTITIES_PATH, PW_PROJECT_NAMES } from '@isrd-isi-edu/chaise/test/e2e/utils/constants';
import { getCatalogID, removeAllCatalogs, setupCatalog } from '@isrd-isi-edu/chaise/test/e2e/utils/catalog-utils';
import { ENTITIES_PATH, PW_PROJECT_NAMES, UPLOAD_FOLDER } from '@isrd-isi-edu/chaise/test/e2e/utils/constants';
import { setCatalogID } from '@isrd-isi-edu/chaise/test/e2e/utils/catalog-utils';

/**
Expand Down Expand Up @@ -80,7 +81,7 @@ export default async function globalSetup(config: FullConfig) {
chaiseConfigFilePath = `test/e2e/specs/${options.mainSpecName}/chaise-config.js`;
}

copyChaiseConfig(chaiseConfigFilePath);
copyChaiseConfig(chaiseConfigFilePath, options.addDefaultCatalogToChaiseConfig);

registerCallbacks(testConfiguration);
}
Expand Down Expand Up @@ -180,9 +181,7 @@ async function createCatalog(testConfiguration: any, projectNames: string[], mai

for (const p of projectNames) {
try {
// add alias to the catalog based on the config and project name
const alias = `${mainSpecName}-${p}`;
const res = await setupCatalog({ catalog: { ...catalog, alias }, schemas });
const res = await setupCatalog({ catalog: { ...catalog }, schemas });
console.log(`catalog with id ${res.catalogId} created for project ${p}`);
setCatalogID(p, res.catalogId);

Expand Down Expand Up @@ -292,7 +291,7 @@ async function getSessionByUserPass(username: string, password: string, authCook
/**
* copy the chaise config into desired location
*/
function copyChaiseConfig(chaiseConfigFilePath?: string) {
function copyChaiseConfig(chaiseConfigFilePath?: string, addDefaultCatalogToChaiseConfig?: boolean) {
let chaiseFilePath = 'chaise-config-sample.js';
if (typeof chaiseConfigFilePath === 'string') {
try {
Expand All @@ -303,6 +302,23 @@ function copyChaiseConfig(chaiseConfigFilePath?: string) {
}
}

if (addDefaultCatalogToChaiseConfig) {
// grab the catalog id
const catId = getCatalogID(PW_PROJECT_NAMES.CHROME);
if (catId === null) {
throw new Error('unable to find catalog id for chrome project while adding defaultCatalog');
}

// grab the content of chaise-config file and add the defaultCatalog to it
let content = fs.readFileSync(chaiseFilePath, 'utf8');
content += `\nchaiseConfig.defaultCatalog = '${catId}'`;

// write the new content into the temporary location
execSync(`mkdir -p ${UPLOAD_FOLDER}`);
chaiseFilePath = path.resolve(UPLOAD_FOLDER, 'chaise-config.js');
fs.writeFileSync(chaiseFilePath, content);
}

const remoteChaiseDirPath = process.env.REMOTE_CHAISE_DIR_PATH;

// The tests will take this path when it is not running on CI and remoteChaseDirPath is not null
Expand Down
1 change: 0 additions & 1 deletion test/e2e/specs/delete-prohibited/chaise-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

var chaiseConfig = {
name: "Delete Prohibited",
defaultCatalog: 'delete-prohibited-chrome',
editRecord: true,
deleteRecord: false,
showFaceting: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export default getConfig({
testName: 'delete-prohibited/navbar',
configFileName: 'navbar/catalog-chaise-config.dev.json',
mainSpecName: 'delete-prohibited',
addDefaultCatalogToChaiseConfig: true
});
1 change: 1 addition & 0 deletions test/e2e/specs/delete-prohibited/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export default getConfig({
testName: 'delete-prohibited',
configFileName: 'parallel-configs/delete-prohibited.dev.json',
mainSpecName: 'delete-prohibited',
addDefaultCatalogToChaiseConfig: true
});
Loading