|
| 1 | +import { test, expect } from '@playwright/test'; |
| 2 | +import { login, uploadLicense, validateDeployLogs } from '../shared'; |
| 3 | + |
| 4 | +const { execSync } = require("child_process"); |
| 5 | + |
| 6 | +test('smoke test', async ({ page }) => { |
| 7 | + test.setTimeout(5 * 60 * 1000); // 5 minutes |
| 8 | + await login(page); |
| 9 | + await uploadLicense(page, expect); |
| 10 | + await expect(page.locator('#app')).toContainText('Install in airgapped environment', { timeout: 15000 }); |
| 11 | + await page.getByText('download App Name from the Internet').click(); |
| 12 | + await expect(page.locator('#app')).toContainText('Installing your license'); |
| 13 | + await expect(page.locator('h3')).toContainText('My Example Config', { timeout: 30000 }); |
| 14 | + await page.locator('#a_bool-group').getByText('a bool field').click(); |
| 15 | + await page.locator('#a_required_text-group').getByRole('textbox').click(); |
| 16 | + await page.locator('#a_required_text-group').getByRole('textbox').fill('my required text field'); |
| 17 | + await expect(page.locator('#version_sequence-group')).toContainText('This version is 0'); |
| 18 | + await page.getByRole('button', { name: 'Continue' }).click(); |
| 19 | + await expect(page.locator('#app')).toContainText('Results', { timeout: 30000 }); |
| 20 | + await expect(page.locator('#app')).toContainText('Sequence is 0'); |
| 21 | + await page.getByRole('button', { name: 'Deploy' }).click(); |
| 22 | + await page.getByRole('button', { name: 'Deploy anyway' }).click(); |
| 23 | + await expect(page.locator('#app')).toContainText('Ready', { timeout: 30000 }); |
| 24 | + await expect(page.locator('#app')).toContainText('Currently deployed version', { timeout: 15000 }); |
| 25 | + await expect(page.locator('#app')).toContainText('Check for update'); |
| 26 | + await expect(page.locator('#app')).toContainText('Configure automatic updates'); |
| 27 | + await expect(page.locator('#app')).toContainText('Redeploy', { timeout: 15000 }); |
| 28 | + await page.getByRole('link', { name: 'Version history' }).click(); |
| 29 | + await expect(page.locator('.currentVersion--wrapper')).toContainText('Sequence 0'); |
| 30 | + await expect(page.locator('#app')).toContainText('Currently deployed version'); |
| 31 | + await expect(page.locator('#app')).toContainText('Check for update'); |
| 32 | + await expect(page.locator('#app')).toContainText('Configure automatic updates'); |
| 33 | + await expect(page.getByRole('button')).toContainText('Redeploy'); |
| 34 | + await page.getByText('Configure automatic updates').click(); |
| 35 | + await expect(page.locator('.ConfigureUpdatesModal')).toContainText('Default'); |
| 36 | + await expect(page.locator('.ConfigureUpdatesModal')).toContainText('Every 4 hours'); |
| 37 | + await expect(page.locator('label')).toContainText('Enable automatic deployment'); |
| 38 | + await page.locator('.replicated-select__control').click(); |
| 39 | + await page.locator('.replicated-select__option').getByText('Weekly', { exact: true }).click(); |
| 40 | + await expect(page.locator('.ConfigureUpdatesModal')).toContainText('Weekly'); |
| 41 | + await expect(page.locator('.ConfigureUpdatesModal')).toContainText('At 12:00 AM, only on Sunday'); |
| 42 | + await page.getByRole('button', { name: 'Update', exact: true }).click(); |
| 43 | + await expect(page.getByText('Automatically check for updates', { exact: true })).not.toBeVisible(); |
| 44 | + await page.locator('span[data-tip="View deploy logs"]').first().click(); |
| 45 | + await validateDeployLogs(page, expect); |
| 46 | + await page.reload(); |
| 47 | + await page.getByRole('link', { name: 'Dashboard' }).click(); |
| 48 | + await expect(page.getByText('App Name')).toBeVisible(); |
| 49 | + await expect(page.locator('.Dashboard--appIcon')).toBeVisible(); |
| 50 | + await expect(page.locator('p').filter({ hasText: 'License' })).toBeVisible(); |
| 51 | + await page.getByText('Configure automatic updates').click(); |
| 52 | + await expect(page.locator('.ConfigureUpdatesModal')).toContainText('Weekly'); |
| 53 | + await expect(page.locator('.ConfigureUpdatesModal')).toContainText('At 12:00 AM, only on Sunday'); |
| 54 | + await expect(page.locator('label')).toContainText('Enable automatic deployment'); |
| 55 | + await page.getByRole('button', { name: 'Cancel' }).click(); |
| 56 | + await page.locator('svg.icons.clickable[data-tip="View release notes"]').click(); |
| 57 | + await expect(page.getByLabel('Release Notes').getByRole('paragraph')).toContainText('release notes - updates'); |
| 58 | + await page.getByRole('button', { name: 'Close' }).click(); |
| 59 | + await page.locator('span[data-tip="View deploy logs"]').click(); |
| 60 | + await validateDeployLogs(page, expect); |
| 61 | + await page.getByRole('link', { name: 'Config', exact: true }).click(); |
| 62 | + await expect(page.locator('h3')).toContainText('My Example Config'); |
| 63 | + await expect(page.locator('#version_sequence-group')).toContainText('This version is 1'); |
| 64 | + await expect(page.getByRole('button', { name: 'Save config' })).toBeVisible(); |
| 65 | + await page.getByRole('link', { name: 'Troubleshoot' }).click(); |
| 66 | + await expect(page.getByRole('button', { name: 'Analyze App Name' })).toBeVisible(); |
| 67 | + await page.getByRole('link', { name: 'License' }).click(); |
| 68 | + await expect(page.locator('#app')).toContainText('Airgap enabled'); |
| 69 | + await expect(page.locator('#app')).toContainText('Snapshots enabled'); |
| 70 | + await expect(page.getByRole('button', { name: 'Sync license' })).toBeVisible(); |
| 71 | + await page.getByRole('link', { name: 'View files' }).click(); |
| 72 | + await page.getByText('upstream', { exact: true }).click(); |
| 73 | + await page.getByRole('listitem', { name: 'config.yaml' }).locator('div').click(); |
| 74 | + await expect(page.locator('.view-lines')).toContainText('apiVersion'); |
| 75 | + await page.getByText('Click here', { exact: true }).click(); |
| 76 | + await expect(page.getByRole('heading')).toContainText('Edit patches for your kots application'); |
| 77 | + await expect(page.getByText('Copy command').first()).toBeVisible(); |
| 78 | + |
| 79 | + let downloadCommand = await page.locator('.react-prism.language-bash').first().textContent(); |
| 80 | + if (!downloadCommand!.includes('download')) { |
| 81 | + throw new Error("Expected the download command to contain the word 'download'"); |
| 82 | + } |
| 83 | + downloadCommand = `${downloadCommand} --overwrite`; |
| 84 | + console.log(downloadCommand, "\n"); |
| 85 | + execSync(downloadCommand, {stdio: 'inherit'}); |
| 86 | + |
| 87 | + await expect(page.getByText('Copy command').last()).toBeVisible(); |
| 88 | + let uploadCommand = await page.locator('.react-prism.language-bash').last().textContent(); |
| 89 | + if (!uploadCommand!.includes('upload')) { |
| 90 | + throw new Error("Expected the upload command to contain the word 'upload'"); |
| 91 | + } |
| 92 | + console.log(uploadCommand, "\n"); |
| 93 | + execSync(uploadCommand, {stdio: 'inherit'}); |
| 94 | + |
| 95 | + await page.getByRole('button', { name: 'Ok, got it!' }).click(); |
| 96 | + await page.getByRole('link', { name: 'Version history' }).click(); |
| 97 | + await expect(page.locator('#app')).toContainText('KOTS Upload'); |
| 98 | + await expect(page.getByText('Running checks', { exact: true }).first()).not.toBeVisible({ timeout: 30000 }); |
| 99 | + await page.getByRole('button', { name: 'Deploy' }).first().click(); |
| 100 | + await page.getByRole('button', { name: 'Deploy this version' }).click(); |
| 101 | + await expect(page.locator('#app')).toContainText('Deploying'); |
| 102 | + await expect(page.locator('#app')).toContainText('Currently deployed version'); |
| 103 | + await expect(page.locator('#app')).toContainText('Application up to date.'); |
| 104 | + await expect(page.locator('.currentVersion--wrapper')).toContainText('Sequence 1'); |
| 105 | + await page.getByRole('link', { name: 'Registry settings' }).click(); |
| 106 | + await page.getByPlaceholder('artifactory.some-big-bank.com').click(); |
| 107 | + await page.getByPlaceholder('artifactory.some-big-bank.com').fill('ttl.sh'); |
| 108 | + await page.getByPlaceholder('username').click(); |
| 109 | + await page.getByPlaceholder('username').fill('admin'); |
| 110 | + await page.getByPlaceholder('password').click(); |
| 111 | + await page.getByPlaceholder('password').fill('admin'); |
| 112 | + await page.getByRole('button', { name: 'Test connection' }).click(); |
| 113 | + await expect(page.locator('form')).toContainText('Success!'); |
| 114 | + await page.getByRole('button', { name: 'Save changes' }).click(); |
| 115 | + await expect(page.getByRole('button', { name: 'Save changes' })).toBeDisabled(); |
| 116 | + await expect(page.locator('.Loader')).toBeVisible(); |
| 117 | + await expect(page.locator('#app')).toContainText('Writing manifest to image destination', { timeout: 30000 }); |
| 118 | + await expect(page.getByRole('button', { name: 'Save changes' })).toBeEnabled({ timeout: 30000 }); |
| 119 | + await expect(page.locator('.Loader')).not.toBeVisible(); |
| 120 | + await page.getByRole('link', { name: 'Version history' }).click(); |
| 121 | + await expect(page.locator('#app')).toContainText('Registry Change'); |
| 122 | + await expect(page.locator('#app')).toContainText('Sequence 2'); |
| 123 | + await page.getByRole('link', { name: 'Registry settings' }).click(); |
| 124 | + await page.getByRole('button', { name: 'Stop using registry' }).click(); |
| 125 | + await page.getByRole('button', { name: 'OK' }).click(); |
| 126 | + await expect(page.locator('.Loader')).toBeVisible(); |
| 127 | + await expect(page.getByRole('button', { name: 'Stop using registry' })).toBeDisabled(); |
| 128 | + await expect(page.getByRole('button', { name: 'Save changes' })).toBeEnabled({ timeout: 30000 }); |
| 129 | + await expect(page.locator('.Loader')).not.toBeVisible(); |
| 130 | + await expect(page.getByPlaceholder('artifactory.some-big-bank.com')).toBeEmpty(); |
| 131 | + await expect(page.getByPlaceholder('username')).toBeEmpty(); |
| 132 | + await expect(page.getByPlaceholder('password')).toBeEmpty(); |
| 133 | + await expect(page.getByPlaceholder('namespace')).toBeEmpty(); |
| 134 | + await page.waitForTimeout(2000); |
| 135 | + await page.getByRole('link', { name: 'Version history' }).click(); |
| 136 | + await expect(page.locator('#app')).toContainText('Sequence 3', { timeout: 10000 }); |
| 137 | + await expect(page.locator('#app')).toContainText('Registry Change'); |
| 138 | + await expect(page.locator('.NavItem').getByText('Application', { exact: true })).toBeVisible(); |
| 139 | + await expect(page.locator('.NavItem').getByText('GitOps', { exact: true })).toBeVisible(); |
| 140 | + await expect(page.locator('.NavItem').getByText('Snapshots', { exact: true })).toBeVisible(); |
| 141 | + await expect(page.locator('div').filter({ hasText: /^Change passwordAdd new applicationLog out$/ }).getByRole('img')).toBeVisible(); |
| 142 | + await page.locator('.NavItem').getByText('Snapshots', { exact: true }).click(); |
| 143 | + await page.getByRole('link', { name: 'Settings & Schedule' }).click(); |
| 144 | + await expect(page.locator('#app')).toContainText('Snapshot settings'); |
| 145 | + await page.getByText('+ Add a new destination').click(); |
| 146 | + await expect(page.getByRole('button', { name: 'Check for Velero' })).toBeVisible(); |
| 147 | + await page.getByRole('button', { name: 'Check for Velero' }).click(); |
| 148 | + await expect(page.getByLabel('Modal')).toContainText('Velero is installed on your cluster'); |
| 149 | + await page.getByRole('button', { name: 'Ok, got it!' }).click(); |
| 150 | + await page.getByRole('link', { name: 'Full Snapshots (Instance)' }).click(); |
| 151 | + await expect(page.locator('#app')).toContainText('No snapshots yet'); |
| 152 | + await page.getByRole('button', { name: 'Start a snapshot' }).click(); |
| 153 | + await expect(page.locator('#app')).toContainText('In Progress'); |
| 154 | + await expect(page.locator('#app')).toContainText('Completed', { timeout: 300000 }); |
| 155 | + await page.getByText('Learn more').click(); |
| 156 | + await page.getByRole('button', { name: 'Ok, got it!' }).click(); |
| 157 | + await expect(page.locator('#app')).toContainText('Full Snapshots (Instance)'); |
| 158 | + await page.getByRole('link', { name: 'Partial Snapshots (Application)' }).click(); |
| 159 | + await page.getByRole('button', { name: 'Start a snapshot' }).click(); |
| 160 | + await expect(page.locator('#app')).toContainText('In Progress'); |
| 161 | + await expect(page.locator('#app')).toContainText('Completed', { timeout: 30000 }); |
| 162 | + await expect(page.getByText('It’s recommend that you use')).toBeVisible(); |
| 163 | + await page.getByText('Learn more').click(); |
| 164 | + await page.getByRole('button', { name: 'Ok, got it!' }).click(); |
| 165 | + await expect(page.locator('#app')).toContainText('Partial snapshots (Application)'); |
| 166 | + await page.getByRole('link', { name: 'Full Snapshots (Instance)', exact: true }).click(); |
| 167 | + await page.locator('.SnapshotRow--wrapper').click(); |
| 168 | + await expect(page.locator('#app')).toContainText('Snapshot timeline'); |
| 169 | + await page.getByText('View logs').click(); |
| 170 | + await expect(page.locator('.view-lines')).toContainText('level=info'); |
| 171 | + await page.getByRole('button', { name: 'Ok, got it!' }).click(); |
| 172 | + await page.getByRole('link', { name: 'Full Snapshots (Instance)', exact: true }).click(); |
| 173 | + await page.locator('svg.icons.clickable[data-tip="Restore from this backup"]').click(); |
| 174 | + await expect(page.getByLabel('Modal')).toContainText('Restore from backup'); |
| 175 | + await expect(page.getByLabel('Modal')).toContainText('Admin console & application'); |
| 176 | + await expect(page.getByLabel('Modal')).toContainText('Application & metadata only'); |
| 177 | + await expect(page.getByLabel('Modal')).toContainText('Only restores the admin console'); |
| 178 | + await page.getByText('Application & metadata only', { exact: true }).click(); |
| 179 | + await page.getByRole('button', { name: 'Cancel' }).click(); |
| 180 | + await page.locator('svg.icons.clickable').last().click(); |
| 181 | + await expect(page.getByLabel('Modal')).toContainText('Delete snapshot'); |
| 182 | + await page.getByRole('button', { name: 'Delete snapshot' }).click(); |
| 183 | + await expect(page.locator('#app')).toContainText('Deleting'); |
| 184 | + await expect(page.locator('#app')).toContainText('No snapshots yet', { timeout: 15000 }); |
| 185 | + await page.getByRole('link', { name: 'Settings & Schedule' }).click(); |
| 186 | + await page.getByRole('button', { name: 'Update storage settings' }).click(); |
| 187 | + await expect(page.locator('form')).toContainText('Settings updated', { timeout: 30000 }); |
| 188 | + await page.getByRole('button', { name: 'Update schedule' }).click(); |
| 189 | + await expect(page.locator('#app')).toContainText('Schedule updated'); |
| 190 | + await page.locator('div').filter({ hasText: /^Change passwordAdd new applicationLog out$/ }).getByRole('img').click(); |
| 191 | + await page.getByText('Log out', { exact: true }).click(); |
| 192 | + await expect(page.getByPlaceholder('password')).toBeVisible(); |
| 193 | + await expect(page.locator('#app')).toContainText('Enter the password to access the App Name admin console.'); |
| 194 | + await expect(page.getByRole('button')).toContainText('Log in'); |
| 195 | +}); |
0 commit comments