generated from kubefirst/react-app-template
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: cypress implementation * test change * step through to creating management cluster * add new data fields to ui components * update: make cypress create management cluster test configurable/ wait for provision without fail. * fix: do not destructure props to controlled text field. rendered field does not update accordingly without it. * chore: add optional sub domain field --------- Co-authored-by: CristhianF7 <CristhianF7@gmail.com> Co-authored-by: Jared Edwards <jared@kubefirst.com>
- Loading branch information
1 parent
f4829a6
commit 2fce747
Showing
26 changed files
with
1,595 additions
and
743 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
components/controlledFields/textField/textField.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React, { useState } from 'react'; | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
import { useForm } from 'react-hook-form'; | ||
|
||
import ControlledTextField from '../TextField'; | ||
|
||
const meta: Meta<typeof ControlledTextField> = { | ||
component: ControlledTextField, | ||
}; | ||
|
||
export default meta; | ||
|
||
const ControlledTextFieldWithHooks = () => { | ||
const { control, watch } = useForm({ defaultValues: { text: 'test' } }); | ||
|
||
const watchValue = watch('text'); | ||
|
||
return ( | ||
<ControlledTextField | ||
control={control} | ||
rules={{ required: false }} | ||
label="Test" | ||
name="text" | ||
helperText={watchValue} | ||
/> | ||
); | ||
}; | ||
|
||
export const Default: StoryObj<typeof ControlledTextField> = { | ||
render: () => <ControlledTextFieldWithHooks />, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { defineConfig } from 'cypress'; | ||
import * as dotenv from 'dotenv'; | ||
dotenv.config(); | ||
|
||
export default defineConfig({ | ||
env: { | ||
CONSOLE_BASE_URL: process.env.CONSOLE_BASE_URL, | ||
GITHUB_TOKEN: process.env.GITHUB_TOKEN, | ||
GITLAB_TOKEN: process.env.GITLAB_TOKEN, | ||
GITHUB_USER: process.env.GITHUB_USER, | ||
GITLAB_USER: process.env.GITLAB_USER, | ||
GITLAB_OWNER: process.env.GITLAB_OWNER, | ||
GITHUB_OWNER: process.env.GITHUB_OWNER, | ||
CIVO_TOKEN: process.env.CIVO_TOKEN, | ||
CIVO_CLOUD_REGION: process.env.CIVO_CLOUD_REGION, | ||
DNS_PROVIDER: process.env.DNS_PROVIDER, | ||
DOMAIN_NAME: process.env.DOMAIN_NAME, | ||
ALERTS_EMAIL: process.env.ALERTS_EMAIL, | ||
CLOUDFLARE_TOKEN: process.env.CLOUDFLARE_TOKEN, | ||
CLOUDFLARE_ORIGIN_CA_KEY: process.env.CLOUDFLARE_ORIGIN_CA_KEY, | ||
CLUSTER_NAME: process.env.CLUSTER_NAME, | ||
SUB_DOMAIN: process.env.SUB_DOMAIN, | ||
}, | ||
e2e: { | ||
setupNodeEvents(on, config) { | ||
// implement node event listeners here | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
describe('add a workload cluster', () => { | ||
beforeEach(() => { | ||
cy.openConsole(); | ||
}); | ||
|
||
it('authentication', () => { | ||
cy.get('[data-test-id="add-workload-cluster"]').click(); | ||
|
||
cy.get('.Mui-checked > .PrivateSwitchBase-input').click(); | ||
cy.get('.Mui-focused > .MuiInputBase-input').click(); | ||
cy.get('.sc-8ad53ea0-0:nth-child(2) .MuiInputBase-input').type('development'); | ||
cy.get('.Mui-focused > .MuiInputBase-input').click(); | ||
cy.get('.sc-8ad53ea0-0:nth-child(3) .MuiInputBase-input').type('development'); | ||
cy.get('#\3Ar1\3A').click(); | ||
cy.get('.Mui-disabled').click(); | ||
cy.get('.sc-1d58281b-2').submit(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
const GITLAB_TOKEN = Cypress.env('GITLAB_TOKEN'); | ||
const GITLAB_USER = Cypress.env('GITLAB_USER'); | ||
const GITLAB_OWNER = Cypress.env('GITLAB_OWNER'); | ||
const CIVO_TOKEN = Cypress.env('CIVO_TOKEN'); | ||
const CIVO_CLOUD_REGION = Cypress.env('CIVO_CLOUD_REGION'); | ||
const DNS_PROVIDER = Cypress.env('DNS_PROVIDER'); | ||
const DOMAIN_NAME = Cypress.env('DOMAIN_NAME'); | ||
const ALERTS_EMAIL = Cypress.env('ALERTS_EMAIL'); | ||
const CLOUDFLARE_TOKEN = Cypress.env('CLOUDFLARE_TOKEN'); | ||
const CLOUDFLARE_ORIGIN_CA_KEY = Cypress.env('CLOUDFLARE_ORIGIN_CA_KEY'); | ||
const CLUSTER_NAME = Cypress.env('CLUSTER_NAME'); | ||
const SUB_DOMAIN = Cypress.env('SUB_DOMAIN'); | ||
|
||
describe('create cluster - setup', () => { | ||
beforeEach(() => { | ||
cy.openConsole(); | ||
}); | ||
|
||
it('authentication', () => { | ||
cy.get('[data-test-id="gitlab-button"]').click(); | ||
cy.get('[data-test-id="cloud-section"]').contains('Now select your cloud adventure'); | ||
cy.get('[data-test-id="civo-button"]').click(); | ||
cy.get('[data-test-id="next-button"]').click(); | ||
|
||
cy.get('[data-test-id="form-section"]').contains('Now, let’s get you authenticated'); | ||
cy.get("[name='gitToken']").type(GITLAB_TOKEN); | ||
|
||
cy.get('[data-test-id="gitUser"]').contains(GITLAB_USER); | ||
cy.get("[name='gitOwner']").click(); | ||
// grab popper element and select option that contains GITLAB_OWNER | ||
cy.get('.MuiAutocomplete-popper').then((popper) => { | ||
cy.wrap(popper).contains(GITLAB_OWNER).click(); | ||
}); | ||
|
||
cy.get("[name='civo_auth.token']").type(CIVO_TOKEN); | ||
|
||
cy.get('[data-test-id="next-button"]').click(); | ||
cy.get("[name='alertsEmail']").type(ALERTS_EMAIL); | ||
cy.get("[name='cloudRegion']").click(); // click cloudRegion multiselect to open menu | ||
cy.get('.MuiAutocomplete-popper').then((popper) => { | ||
cy.wrap(popper).contains(CIVO_CLOUD_REGION).click(); | ||
}); | ||
|
||
cy.get("[name='dnsProvider']").click(); // click dnsProvider multiselect to open menu | ||
cy.get('.MuiAutocomplete-popper').then((popper) => { | ||
cy.wrap(popper).contains(DNS_PROVIDER).click(); | ||
}); | ||
|
||
cy.get("[name='cloudflareToken']").type(CLOUDFLARE_TOKEN); | ||
cy.get("[name='cloudflareOriginCaIssuerKey']").type(CLOUDFLARE_ORIGIN_CA_KEY); | ||
|
||
cy.get("[name='domainName']").click(); // click domainName multiselect to open menu | ||
cy.get('.MuiAutocomplete-popper').then((popper) => { | ||
cy.wrap(popper).contains(DOMAIN_NAME).click(); | ||
}); | ||
|
||
if (SUB_DOMAIN) { | ||
cy.get("[name='subDomain']").type(SUB_DOMAIN); | ||
} | ||
|
||
cy.get("[name='clusterName']").type(CLUSTER_NAME); | ||
|
||
cy.get("[name='advancedOptions']").click(); // click advanced options button | ||
|
||
cy.get("[name='gitopsTemplateBranch']").type('civo-gitlab-workload-clusters'); | ||
cy.get('[data-test-id="next-button"]').click(); // create management cluster | ||
// proceed to cluster provision completion page | ||
|
||
cy.wait(2000); // give some time to make sure disabled prop is applied to next button | ||
|
||
// recursive function to check for enabled next button when provisioning management cluster | ||
function waitForEnabledButton() { | ||
cy.get('[data-test-id="next-button"]').then((element) => { | ||
if (!element.prop('disabled')) { | ||
cy.wrap(element).click(); | ||
} else { | ||
cy.wait(10000); | ||
waitForEnabledButton(); | ||
} | ||
}); | ||
} | ||
|
||
waitForEnabledButton(); | ||
|
||
cy.get('[data-test-id="launch-console"]').click(); | ||
}); | ||
}); |
Oops, something went wrong.