dceky 1.0.0-beta-profile.1 → 1.0.0-beta-yuenler.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands/assertDoesNotHaveClass.d.ts +19 -0
- package/lib/commands/assertDoesNotHaveClass.js +17 -0
- package/lib/commands/assertDoesNotHaveClass.js.map +1 -0
- package/lib/commands/assertHasClass.d.ts +19 -0
- package/lib/commands/assertHasClass.js +17 -0
- package/lib/commands/assertHasClass.js.map +1 -0
- package/lib/commands/assertNumElements.d.ts +19 -0
- package/lib/commands/assertNumElements.js +17 -0
- package/lib/commands/assertNumElements.js.map +1 -0
- package/lib/commands/clickWithRetry.d.ts +16 -0
- package/lib/commands/clickWithRetry.js +29 -0
- package/lib/commands/clickWithRetry.js.map +1 -0
- package/lib/commands/getNumElements.d.ts +15 -0
- package/lib/commands/getNumElements.js +19 -0
- package/lib/commands/getNumElements.js.map +1 -0
- package/lib/commands/handleHarvardKey.d.ts +14 -0
- package/lib/commands/handleHarvardKey.js +58 -0
- package/lib/commands/handleHarvardKey.js.map +1 -0
- package/lib/commands/launchAs.d.ts +23 -0
- package/lib/commands/launchAs.js +65 -0
- package/lib/commands/launchAs.js.map +1 -0
- package/lib/commands/launchLTIUsingToken.d.ts +16 -0
- package/lib/commands/launchLTIUsingToken.js +57 -0
- package/lib/commands/launchLTIUsingToken.js.map +1 -0
- package/lib/commands/navigateToHref.d.ts +20 -0
- package/lib/commands/navigateToHref.js +23 -0
- package/lib/commands/navigateToHref.js.map +1 -0
- package/lib/commands/runScript.d.ts +17 -0
- package/lib/commands/runScript.js +25 -0
- package/lib/commands/runScript.js.map +1 -0
- package/lib/commands/typeInto.d.ts +21 -0
- package/lib/commands/typeInto.js +28 -0
- package/lib/commands/typeInto.js.map +1 -0
- package/lib/commands/visitCanvasGETEndpoint.d.ts +20 -0
- package/lib/commands/visitCanvasGETEndpoint.js +26 -0
- package/lib/commands/visitCanvasGETEndpoint.js.map +1 -0
- package/lib/commands/waitForElementVisible.d.ts +15 -0
- package/lib/commands/waitForElementVisible.js +20 -0
- package/lib/commands/waitForElementVisible.js.map +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/init.d.ts +4 -11
- package/lib/init.js +35 -4
- package/lib/init.js.map +1 -1
- package/package.json +4 -20
- package/src/commands/assertDoesNotHaveClass.ts +40 -0
- package/src/commands/assertHasClass.ts +40 -0
- package/src/commands/assertNumElements.ts +37 -0
- package/src/commands/clickWithRetry.ts +51 -0
- package/src/commands/getNumElements.ts +38 -0
- package/src/commands/handleHarvardKey.ts +87 -0
- package/src/commands/launchAs.ts +104 -0
- package/src/commands/launchLTIUsingToken.ts +84 -0
- package/src/commands/navigateToHref.ts +45 -0
- package/src/commands/runScript.ts +42 -0
- package/src/commands/typeInto.ts +57 -0
- package/src/commands/visitCanvasGETEndpoint.ts +48 -0
- package/src/commands/waitForElementVisible.ts +40 -0
- package/src/genConfiguration.ts +11 -0
- package/src/index.ts +2 -7
- package/src/init.ts +26 -2
- package/tsconfig.json +0 -1
- package/docs/GlobalsAndProfiles.md +0 -23
- package/profileChooser/chooseProfile.ts +0 -35
- package/profileChooser/helpers/print.ts +0 -155
- package/profileChooser/helpers/prompt.ts +0 -23
- package/profileChooser/helpers/showChooser.ts +0 -95
- package/profileChooser/types/ChooserOption.ts +0 -11
- package/src/commands/clickSomething.ts +0 -33
- package/src/genConfiguration/helpers/resolveDependents.ts +0 -47
- package/src/genConfiguration/helpers/splitEnv.ts +0 -30
- package/src/genConfiguration/index.ts +0 -83
- package/src/genConfiguration/types/DependentValue.ts +0 -14
- package/src/genConfiguration/types/GlobalsOrProfile.ts +0 -12
- package/src/genConfiguration/types/SplitEnv.ts +0 -18
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import clear from 'clear';
|
|
2
|
-
|
|
3
|
-
// Import shared helpers
|
|
4
|
-
import print from './print';
|
|
5
|
-
import prompt from './prompt';
|
|
6
|
-
|
|
7
|
-
// Import shared types
|
|
8
|
-
import ChooserOption from '../types/ChooserOption';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Show a chooser between many options
|
|
12
|
-
* @author Gabe Abrams
|
|
13
|
-
* @param question the question to ask
|
|
14
|
-
* @param options list of options to choose from
|
|
15
|
-
* @param title main title to show above the choices
|
|
16
|
-
* @param dontClear if true, don't clear the console before
|
|
17
|
-
* @returns chosen option
|
|
18
|
-
*/
|
|
19
|
-
const showChooser = (
|
|
20
|
-
opts: {
|
|
21
|
-
question: string,
|
|
22
|
-
options: ChooserOption[],
|
|
23
|
-
title?: string,
|
|
24
|
-
dontClear?: boolean,
|
|
25
|
-
},
|
|
26
|
-
): {
|
|
27
|
-
description: string,
|
|
28
|
-
tag: string,
|
|
29
|
-
index: number,
|
|
30
|
-
} => {
|
|
31
|
-
const {
|
|
32
|
-
question,
|
|
33
|
-
options,
|
|
34
|
-
title,
|
|
35
|
-
dontClear,
|
|
36
|
-
} = opts;
|
|
37
|
-
|
|
38
|
-
// Print the header
|
|
39
|
-
if (!dontClear) {
|
|
40
|
-
clear();
|
|
41
|
-
}
|
|
42
|
-
if (title) {
|
|
43
|
-
print.title(title);
|
|
44
|
-
console.log('');
|
|
45
|
-
}
|
|
46
|
-
print.subtitle(question);
|
|
47
|
-
|
|
48
|
-
// Make sure all options have tags
|
|
49
|
-
let nextNumber = 1;
|
|
50
|
-
const optionsWithTags = options.map((option) => {
|
|
51
|
-
// Get/generate a tag
|
|
52
|
-
let { tag } = option;
|
|
53
|
-
if (!tag) {
|
|
54
|
-
tag = String(nextNumber);
|
|
55
|
-
nextNumber += 1;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Return complete option
|
|
59
|
-
return {
|
|
60
|
-
...option,
|
|
61
|
-
tag,
|
|
62
|
-
};
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
// Print options
|
|
66
|
-
for (let i = 0; i < optionsWithTags.length; i++) {
|
|
67
|
-
console.log(`${optionsWithTags[i].tag} - ${optionsWithTags[i].description}`);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Ask user to choose
|
|
71
|
-
const responseTag = prompt('> ').trim();
|
|
72
|
-
|
|
73
|
-
// Find the appropriate option
|
|
74
|
-
for (let i = 0; i < optionsWithTags.length; i++) {
|
|
75
|
-
if (responseTag.toLowerCase() === optionsWithTags[i].tag.toLowerCase()) {
|
|
76
|
-
// Found the right option
|
|
77
|
-
return {
|
|
78
|
-
...optionsWithTags[i],
|
|
79
|
-
index: i,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// No tag found
|
|
85
|
-
clear();
|
|
86
|
-
print.title('Invalid Choice');
|
|
87
|
-
console.log('');
|
|
88
|
-
print.enterToContinue();
|
|
89
|
-
return showChooser({
|
|
90
|
-
question,
|
|
91
|
-
options: optionsWithTags,
|
|
92
|
-
});
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
export default showChooser;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/// <reference types="cypress" />
|
|
2
|
-
|
|
3
|
-
/*----------------------------------------*/
|
|
4
|
-
/* ---------------- Type ---------------- */
|
|
5
|
-
/*----------------------------------------*/
|
|
6
|
-
|
|
7
|
-
declare global {
|
|
8
|
-
namespace Cypress {
|
|
9
|
-
interface Chainable {
|
|
10
|
-
/**
|
|
11
|
-
* Custom command to click an element by selector
|
|
12
|
-
* @example cy.clickSomething('.my-button')
|
|
13
|
-
*/
|
|
14
|
-
clickSomething(selector: string): Chainable<Element>;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/*----------------------------------------*/
|
|
20
|
-
/* --------------- Command -------------- */
|
|
21
|
-
/*----------------------------------------*/
|
|
22
|
-
|
|
23
|
-
const clickSomething = () => {
|
|
24
|
-
Cypress.Commands.add('clickSomething', (selector: string) => {
|
|
25
|
-
cy.get(selector).click();
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/*----------------------------------------*/
|
|
30
|
-
/* --------------- Export --------------- */
|
|
31
|
-
/*----------------------------------------*/
|
|
32
|
-
|
|
33
|
-
export default clickSomething;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
// Import shared types
|
|
3
|
-
import type GlobalsOrProfile from '../types/GlobalsOrProfile';
|
|
4
|
-
import type DependentValue from '../types/DependentValue';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Resolve all dependent values using already-merged basics.
|
|
8
|
-
* @author Gardenia Liu
|
|
9
|
-
* @param dependentMaps with dependencies on basics
|
|
10
|
-
* @param basics entries
|
|
11
|
-
* @returns env with all dependent values resolved
|
|
12
|
-
*/
|
|
13
|
-
const resolveDependents = (
|
|
14
|
-
dependentMaps: { [k: string]: DependentValue }[],
|
|
15
|
-
basics: GlobalsOrProfile,
|
|
16
|
-
): GlobalsOrProfile => {
|
|
17
|
-
const resolved: GlobalsOrProfile = {};
|
|
18
|
-
|
|
19
|
-
// Loop through all of the dependency maps
|
|
20
|
-
dependentMaps.forEach((depMap) => {
|
|
21
|
-
// Loop through all entries within dependency map
|
|
22
|
-
Object.entries(depMap).forEach(([k, depVal]) => {
|
|
23
|
-
// Get basic selector the value depends on
|
|
24
|
-
const selector = basics[depVal.dependsOn];
|
|
25
|
-
|
|
26
|
-
// Create table of values selector can be
|
|
27
|
-
const { dependsOn, ...table } = depVal as { [k: string]: unknown };
|
|
28
|
-
|
|
29
|
-
// Get the selector's picked value
|
|
30
|
-
const picked = table[selector];
|
|
31
|
-
|
|
32
|
-
if (picked !== undefined) {
|
|
33
|
-
resolved[k] = picked;
|
|
34
|
-
} else if ('default' in table) {
|
|
35
|
-
resolved[k] = table.default;
|
|
36
|
-
} else {
|
|
37
|
-
// eslint-disable-next-line max-len
|
|
38
|
-
console.warn(`[cypress.config] Could not resolve ${k}, dependsOn=${dependsOn}, selector=${String(selector)}`);
|
|
39
|
-
process.exit(1);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
return resolved;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export default resolveDependents;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// Import shared types
|
|
2
|
-
import type GlobalsOrProfile from '../types/GlobalsOrProfile';
|
|
3
|
-
import type DependentValue from '../types/DependentValue';
|
|
4
|
-
import type SplitEnv from '../types/SplitEnv';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Split one map into basic and dependent values
|
|
8
|
-
* @author Gardenia Liu
|
|
9
|
-
* @param map to split
|
|
10
|
-
* @returns split basic and dependent values map
|
|
11
|
-
*/
|
|
12
|
-
const splitEnv = (map: GlobalsOrProfile): SplitEnv => {
|
|
13
|
-
const basic: GlobalsOrProfile = {};
|
|
14
|
-
const dependent: { [k: string]: DependentValue } = {};
|
|
15
|
-
|
|
16
|
-
Object.entries(map).forEach(([k, v]) => {
|
|
17
|
-
// If entry has dependsOn relationship, add it to dependent dictionary
|
|
18
|
-
if (typeof v === 'object' && 'dependsOn' in v) {
|
|
19
|
-
dependent[k] = v as DependentValue;
|
|
20
|
-
// Otherwise, add it to basic dictionary
|
|
21
|
-
} else {
|
|
22
|
-
basic[k] = v;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
// Returns separated basic and dependent values
|
|
27
|
-
return { basic, dependent };
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export default splitEnv;
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
|
|
3
|
-
// Import external libraries
|
|
4
|
-
import { defineConfig } from 'cypress';
|
|
5
|
-
import deepmerge from 'deepmerge';
|
|
6
|
-
|
|
7
|
-
// Import helpers
|
|
8
|
-
import splitEnv from './helpers/splitEnv';
|
|
9
|
-
import resolveDependents from './helpers/resolveDependents';
|
|
10
|
-
|
|
11
|
-
// Import types
|
|
12
|
-
import type SplitEnv from './types/SplitEnv';
|
|
13
|
-
import type GlobalsOrProfile from './types/GlobalsOrProfile';
|
|
14
|
-
|
|
15
|
-
// Determine project directory
|
|
16
|
-
const CWD = (process.env.INIT_CWD || process.env.PWD);
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Generate Cypress configuration based on global credentials,
|
|
20
|
-
* variables, resources, and profiles
|
|
21
|
-
* @author Gardenia Liu
|
|
22
|
-
* @author Gabe Abrams
|
|
23
|
-
*/
|
|
24
|
-
const genConfiguration = () => {
|
|
25
|
-
// Define paths
|
|
26
|
-
const GLOBALS_PATH = path.join(CWD, '/cypress/globals');
|
|
27
|
-
const PROFILES_PATH = path.join(CWD, '/cypress/profiles');
|
|
28
|
-
|
|
29
|
-
// Import global env var objects
|
|
30
|
-
const GlobalCredentials: GlobalsOrProfile = require(path.join(GLOBALS_PATH, '/GlobalCredentials'));
|
|
31
|
-
const GlobalResources: GlobalsOrProfile = require(path.join(GLOBALS_PATH, '/GlobalResources'));
|
|
32
|
-
const GlobalValues: GlobalsOrProfile = require(path.join(GLOBALS_PATH, '/GlobalValues'));
|
|
33
|
-
|
|
34
|
-
// Determine profile file name (default is stage)
|
|
35
|
-
const profileName = process.env.CYPRESS_PROFILE || 'stage';
|
|
36
|
-
|
|
37
|
-
// Load in chosen profile configuration
|
|
38
|
-
let profileModules: GlobalsOrProfile = {};
|
|
39
|
-
try {
|
|
40
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
41
|
-
const mod = require(path.join(PROFILES_PATH, `/${profileName}.Profile`));
|
|
42
|
-
profileModules = (mod?.default ?? mod ?? {}) as GlobalsOrProfile;
|
|
43
|
-
} catch (e) {
|
|
44
|
-
console.warn(`[cypress.config] Could not load profile '${profileName}.Profile'`, e);
|
|
45
|
-
process.exit(1);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// NOTE: Order matters (later overrides earlier)
|
|
49
|
-
const sources: GlobalsOrProfile[] = [GlobalCredentials, GlobalResources, GlobalValues, profileModules];
|
|
50
|
-
|
|
51
|
-
// Split all sources into basic and dependent
|
|
52
|
-
const splits: SplitEnv[] = sources.map(source => splitEnv(source));
|
|
53
|
-
|
|
54
|
-
// Extract basic and dependent values from splits
|
|
55
|
-
const basicValues = splits.map((s) => s.basic);
|
|
56
|
-
const dependentValues = splits.map((s) => s.dependent);
|
|
57
|
-
|
|
58
|
-
// Merge all of the basics
|
|
59
|
-
const basics: GlobalsOrProfile = deepmerge.all<GlobalsOrProfile>(basicValues);
|
|
60
|
-
|
|
61
|
-
// Resolve dependencies
|
|
62
|
-
const dependents: GlobalsOrProfile = resolveDependents(dependentValues, basics);
|
|
63
|
-
|
|
64
|
-
// Add basics, depends, and profileName into the final env
|
|
65
|
-
const finalEnv: GlobalsOrProfile = {
|
|
66
|
-
...basics,
|
|
67
|
-
...dependents,
|
|
68
|
-
profileName,
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const baseUrl = finalEnv.baseURL;
|
|
72
|
-
|
|
73
|
-
const config = defineConfig({
|
|
74
|
-
e2e: {
|
|
75
|
-
baseUrl,
|
|
76
|
-
env: finalEnv,
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
return config;
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export default genConfiguration;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Value for a dependent entry
|
|
3
|
-
* @author Gardenia Liu
|
|
4
|
-
*/
|
|
5
|
-
type DependentValue = {
|
|
6
|
-
dependsOn: string,
|
|
7
|
-
} & {
|
|
8
|
-
// Environment, global variables, profile values, etc.
|
|
9
|
-
[k: string]: any,
|
|
10
|
-
// Default value if the dependsOn value is not found
|
|
11
|
-
default?: any,
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export default DependentValue;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Object containing global variables, profile values, etc.
|
|
3
|
-
* @author Gardenia Liu
|
|
4
|
-
*/
|
|
5
|
-
type GlobalsOrProfile = {
|
|
6
|
-
// Base URL to prefix all paths with
|
|
7
|
-
baseURL?: string,
|
|
8
|
-
// Environment, global variables, profile values, etc.
|
|
9
|
-
[k: string]: any,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default GlobalsOrProfile;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// Import shared types
|
|
2
|
-
import type GlobalsOrProfile from './GlobalsOrProfile';
|
|
3
|
-
import type DependentValue from './DependentValue';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Env type where basic and dependent entries are separated
|
|
7
|
-
* @author Gardenia Liu
|
|
8
|
-
*/
|
|
9
|
-
type SplitEnv = {
|
|
10
|
-
// Basic entries
|
|
11
|
-
basic: GlobalsOrProfile,
|
|
12
|
-
// Dependent entries
|
|
13
|
-
dependent: {
|
|
14
|
-
[k: string]: DependentValue,
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export default SplitEnv;
|