Skip to content

Commit

Permalink
fix: Do not use isDashboard in onboarding flow (#12160)
Browse files Browse the repository at this point in the history
* fix: Do not use isDashboard in onboarding flow

* chore: Remove CONSOLE_CONTEXT tests from onboarding

* fix: Update interactive setup test
  • Loading branch information
Mmarzex committed Sep 16, 2023
1 parent 737bc1e commit 1f8d786
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 39 deletions.
9 changes: 2 additions & 7 deletions lib/cli/interactive-setup/dashboard-login.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const { showOnboardingWelcome } = require('./utils');

const loginOrRegisterQuestion = async ({ stepHistory }) =>
promptWithHistory({
message: 'Do you want to login/register to Serverless Dashboard?',
message: 'Register or Login to Serverless Framework',
type: 'confirm',
name: 'shouldLoginOrRegister',
stepHistory,
Expand All @@ -26,12 +26,7 @@ const steps = {

module.exports = {
async isApplicable(context) {
const { isDashboard, configuration, options, serviceDir } = context;

if (!isDashboard) {
context.inapplicabilityReasonCode = 'CONSOLE_CONTEXT';
return false;
}
const { configuration, options, serviceDir } = context;

if (!serviceDir) {
context.inapplicabilityReasonCode = 'NOT_IN_SERVICE_DIRECTORY';
Expand Down
7 changes: 1 addition & 6 deletions lib/cli/interactive-setup/dashboard-set-org.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,7 @@ const steps = {

module.exports = {
async isApplicable(context) {
const { isDashboard, configuration, options, serviceDir } = context;

if (!isDashboard) {
context.inapplicabilityReasonCode = 'CONSOLE_CONTEXT';
return false;
}
const { configuration, options, serviceDir } = context;

if (!serviceDir) {
context.inapplicabilityReasonCode = 'NOT_IN_SERVICE_DIRECTORY';
Expand Down
13 changes: 0 additions & 13 deletions test/unit/lib/cli/interactive-setup/dashboard-login.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,6 @@ describe('test/unit/lib/cli/interactive-setup/dashboard-login.test.js', function
expect(context.inapplicabilityReasonCode).to.equal('NOT_IN_SERVICE_DIRECTORY');
});

it('Should be ineffective, when not in dashboard context', async () => {
const context = {
serviceDir: process.cwd(),
configuration: {},
configurationFilename: 'serverless.yml',
options: {},
initial: {},
inquirer,
};
expect(await step.isApplicable(context)).to.equal(false);
expect(context.inapplicabilityReasonCode).to.equal('CONSOLE_CONTEXT');
});

it('Should be ineffective, when not at AWS service path', async () => {
const context = {
serviceDir: process.cwd(),
Expand Down
13 changes: 0 additions & 13 deletions test/unit/lib/cli/interactive-setup/dashboard-set-org.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,6 @@ describe('test/unit/lib/cli/interactive-setup/dashboard-set-org.test.js', functi
expect(context.inapplicabilityReasonCode).to.equal('NOT_IN_SERVICE_DIRECTORY');
});

it('Should be ineffective, when not in dashboard context', async () => {
const context = {
initial: {},
serviceDir: process.cwd(),
configuration: {},
configurationFilename: 'serverless.yml',
options: {},
isDashboard: false,
};
expect(await step.isApplicable(context)).to.equal(false);
expect(context.inapplicabilityReasonCode).to.equal('CONSOLE_CONTEXT');
});

it('Should be ineffective, when not at AWS service path', async () => {
const context = {
serviceDir: process.cwd(),
Expand Down
4 changes: 4 additions & 0 deletions test/unit/lib/cli/interactive-setup/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ describe('test/unit/lib/cli/interactive-setup/index.test.js', () => {
instructionString: 'What do you want to call this project?',
input: 'interactive-setup-test',
},
{
instructionString: 'Register or Login to Serverless Framework',
input: 'n',
},

// aws-credentials
{
Expand Down

0 comments on commit 1f8d786

Please sign in to comment.