Skip to content

Commit

Permalink
Merge branch '10.0-release' into zachw/migration-hocus-states
Browse files Browse the repository at this point in the history
  • Loading branch information
ZachJW34 authored Feb 17, 2022
2 parents dad42cf + 3331c62 commit 901075c
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 24 deletions.
154 changes: 130 additions & 24 deletions packages/app/cypress/e2e/settings.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ describe('App: Settings', () => {

beforeEach(() => {
cy.openProject('todos')
cy.startAppServer('e2e')
})

it('visits settings page', () => {
cy.startAppServer('e2e')
cy.visitApp()
cy.findByText('Settings').click()

Expand All @@ -17,44 +17,150 @@ describe('App: Settings', () => {
cy.findByText('Project Settings').should('be.visible')
})

it('shows the projectId section when there is a projectId', () => {
cy.visitApp()
cy.findByText('Settings').click()
cy.findByText('Project Settings').click()
cy.findByText('Project ID').should('be.visible')
})

it('shows the recordKeys section', () => {
cy.loginUser()

it('shows a button to log in if user is not connected', () => {
cy.startAppServer('e2e')
cy.visitApp()
cy.findByText('Settings').click()
cy.findByText('Project Settings').click()
cy.findByText('Record Key').should('be.visible')
})

it('opens cloud settings when clicking on "Manage Keys"', () => {
cy.loginUser()
cy.intercept('mutation-ExternalLink_OpenExternal', { 'data': { 'openExternal': true } }).as('OpenExternal')
cy.__incorrectlyVisitAppWithIntercept()
cy.findByText('Settings').click()
cy.findByText('Project Settings').click()
cy.findByText('Manage Keys').click()
cy.wait('@OpenExternal')
.its('request.body.variables.url')
.should('equal', 'http:/test.cloud/cloud-project/settings')
cy.get('button').contains('Log In')
})

it('can reconfigure a project', () => {
cy.startAppServer('e2e')
cy.__incorrectlyVisitAppWithIntercept('settings')

cy.intercept('mutation-SettingsContainer_ReconfigureProject', { 'data': { 'reconfigureProject': true } }).as('ReconfigureProject')
cy.findByText('Reconfigure Project').click()
cy.wait('@ReconfigureProject')
})

describe('Project Settings', () => {
it('shows the projectId section when there is a projectId', () => {
cy.startAppServer('e2e')
cy.visitApp()
cy.findByText('Settings').click()
cy.findByText('Project Settings').click()
cy.findByText('Project ID').should('be.visible')
})

it('shows the Record Keys section', () => {
cy.startAppServer('e2e')
cy.loginUser()

cy.visitApp()
cy.findByText('Settings').click()
cy.findByText('Project Settings').click()
cy.findByText('Record Key').should('be.visible')
})

it('obfuscates each record key and has a button to reveal the key', () => {
cy.startAppServer('e2e')
cy.loginUser()

cy.visitApp()
cy.findByText('Settings').click()
cy.findByText('Project Settings').click()
cy.get('[data-cy="record-key"]').should('contain', '***')
cy.get('[aria-label="Record Key Visibility Toggle"]').click()
cy.get('[data-cy="record-key"]').should('contain', '2aaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa')
})

it('shows the Spec Patterns section (default specPattern value)', () => {
cy.scaffoldProject('simple-ct')
cy.openProject('simple-ct')
cy.startAppServer('component')
cy.loginUser()

cy.visitApp()
cy.findByText('Settings').click()
cy.findByText('Project Settings').click()
cy.get('[data-cy="file-match-indicator"]').contains('2 Matches')
cy.get('[data-cy="spec-pattern"]').contains('**/*.cy.{js,jsx,ts,tsx}')
})

it('shows the Spec Patterns section (edited specPattern value)', () => {
cy.startAppServer('e2e')
cy.loginUser()

cy.visitApp()
cy.findByText('Settings').click()
cy.findByText('Project Settings').click()
cy.get('[data-cy="file-match-indicator"]').contains('41 Matches')
cy.get('[data-cy="spec-pattern"]').contains('tests/**/*')
})

it('shows the Experiments section', () => {
cy.startAppServer('e2e')
cy.loginUser()

cy.visitApp()
cy.findByText('Settings').click()
cy.findByText('Project Settings').click()
cy.get('[data-cy="settings-experiments"]').within(() => {
cy.get('[data-cy="experiment-experimentalFetchPolyfill"]')
cy.get('[data-cy="experiment-experimentalInteractiveRunEvents"]')
cy.get('[data-cy="experiment-experimentalSessionSupport"]')
cy.get('[data-cy="experiment-experimentalSourceRewriting"]')
})
})

it('shows the Resolved Configuration section', () => {
cy.startAppServer('e2e')
cy.loginUser()

cy.visitApp()
cy.findByText('Settings').click()
cy.findByText('Project Settings').click()
cy.get('[data-cy="config-code"]').contains('{')
})

it('highlights values set via config file, envFile, env, or CLI in the appropriate color', () => {
cy.startAppServer('e2e')
cy.loginUser()

cy.visitApp()
cy.findByText('Settings').click()
cy.findByText('Project Settings').click()
cy.get('[data-cy="config-legend"]').within(() => {
cy.get('.bg-gray-50').contains('default')
cy.get('.bg-teal-100').contains('config')
cy.get('.bg-yellow-100').contains('env')
cy.get('.bg-red-50').contains('cli')
})

cy.get('[data-cy="config-code"]').within(() => {
cy.get('.bg-teal-100').contains('tests/_fixtures')
cy.get('.bg-teal-100').contains('abc123')
cy.get('.bg-teal-100').contains('specFilePattern')
cy.get('.bg-teal-100').contains('supportFile')
cy.get('.bg-yellow-100').contains('REMOTE_DEBUGGING_PORT')
cy.get('.bg-yellow-100').contains('KONFIG_ENV')
cy.get('.bg-yellow-100').contains('INTERNAL_E2E_TESTING_SELF')
cy.get('.bg-yellow-100').contains('INTERNAL_GRAPHQL_PORT')
cy.get('.bg-red-50').contains('4455')
})
})

// TODO: The Edit button isn't hooked up to do anything when it should trigger the openFileInIDE mutation (https://cypress-io.atlassian.net/browse/UNIFY-1164)
it.skip('opens cypress.config.js file after clicking "Edit" button', () => {
})

it('opens cloud settings when clicking on "Manage Keys"', () => {
cy.startAppServer('e2e')
cy.loginUser()
cy.intercept('mutation-ExternalLink_OpenExternal', { 'data': { 'openExternal': true } }).as('OpenExternal')
cy.__incorrectlyVisitAppWithIntercept('settings')
cy.findByText('Project Settings').click()
cy.findByText('Manage Keys').click()
cy.wait('@OpenExternal')
.its('request.body.variables.url')
.should('equal', 'http:/test.cloud/cloud-project/settings')
})
})

describe('external editor', () => {
beforeEach(() => {
cy.startAppServer('e2e')
cy.withCtx(async (ctx) => {
ctx.coreData.localSettings.availableEditors = [
...ctx.coreData.localSettings.availableEditors,
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/settings/project/CodeBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<code
class="text-size-14px"
:class="{ 'text-gray-500': localConfidential }"
data-cy="record-key"
>
{{ localConfidential ? '*'.repeat(code.length) : code }}
</code>
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/settings/project/SpecPatterns.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<SpecPatterns
v-if="props.gql"
:gql="props.gql"
data-cy="spec-pattern"
/>
</SettingsSection>
</template>
Expand Down

0 comments on commit 901075c

Please sign in to comment.