Skip to content

Commit

Permalink
Added more tests and updated the Spring stubs (#1)
Browse files Browse the repository at this point in the history
* Added more tests and updated the Spring stubs
  • Loading branch information
nicholasnet authored Oct 20, 2023
1 parent eeed51a commit d857326
Show file tree
Hide file tree
Showing 15 changed files with 111 additions and 43 deletions.
30 changes: 16 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: Integration Test
name: Unit/E2E Test
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
unit:
name: 'Linting, Unit tests and E2E tests'
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
Expand All @@ -26,17 +27,18 @@ jobs:
- name: Run Unit tests
run: npm run test:unit:ci

- name: Install Playwright Browsers
run: npx playwright install --with-deps

- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 14

- name: Run Build
run: npm run build

# - name: Install Playwright Browsers
# run: npx playwright install --with-deps
#
# - name: Run Playwright tests
# run: npx playwright test
#
# - uses: actions/upload-artifact@v3
# if: always()
# with:
# name: playwright-report
# path: playwright-report/
# retention-days: 14
51 changes: 51 additions & 0 deletions e2e/app.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,59 @@
import os from 'os'
import { test, expect } from '@playwright/test'
import * as timers from 'timers'

// See here how to get started:
// https://playwright.dev/docs/intro
test('visits the app root url and show dependency dialog', async ({ page }) => {
const metaKey = os.platform() === 'darwin' ? 'Meta' : 'Control'
// expect(getUA).toBe('taco')
// console.log(isMac)
await page.goto('/')
await expect(page.locator('body')).toHaveCount(1)

// Initially there should not be any selected package item
await expect(page.locator('div[data-selected-package-item="true"]')).toHaveCount(0)

// Make sure dependencies button is shown and clickable
await expect(page.getByRole('button', { name: 'Add Dependencies' })).toHaveCount(1)
await page.getByRole('button', { name: 'Add Dependencies' }).click({ force: true })

// Make sure that items are displayed
await expect(page.locator('div[role="dialog"]')).toHaveCount(1)
await expect(page.locator('div[data-package-item="true"]')).toHaveCount(65)
await expect(page.locator('div[data-package-item-id="lombok"]')).toHaveCount(1)

// Make sure package filter works
await page.locator('input[name="dependencies-input-filter"]').fill('web')
await expect(page.locator('div[data-package-item="true"]')).toHaveCount(4)
await expect(page.locator('div[data-package-item-id="lombok"]')).toHaveCount(0)
await page.locator('div[data-package-item-id="web"]').click()

// Make sure that package selection works
await expect(page.locator('div[data-selected-package-item="true"]')).toHaveCount(1)
await expect(page.locator('div[data-selected-package-item-id="web"]')).toHaveCount(1)

// Make sure that remove package button works
await expect(page.locator('button[title="Remove this package"]')).toHaveCount(1)
page.locator('button[title="Remove this package"]').click()
await expect(page.locator('div[data-selected-package-item="true"]')).toHaveCount(0)

// Make sure that multiple works
await expect(page.getByRole('button', { name: 'Add Dependencies' })).toHaveCount(1)
await page.getByRole('button', { name: 'Add Dependencies' }).click({ force: true })

timers.setTimeout(async () => {
await expect(page.locator('div[data-package-item-id="web"]')).toHaveCount(1)
await page.locator('div[data-package-item-id="web"]').click({ modifiers: [metaKey] })
//await page.keyboard.press(`${metaKey}+Enter`)

await page.locator('div[data-package-item-id="lombok"]').click({ modifiers: [metaKey] })
//await page.keyboard.press(`${metaKey}+Enter`)

await page.locator('input[name="dependencies-input-filter"]').press('Escape')

// Make sure Dependencies dialog is closed and appropriate packages are shown
//await expect(page.locator('div[role="dialog"]')).toHaveCount(0)
await expect(page.locator('div[data-selected-package-item="true"]')).toHaveCount(2)
}, 2000)
})
4 changes: 3 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const springProject = ref<{ active: boolean; valid: boolean; metaData: SpringPro
valid: true,
metaData: {
language: Language.Java,
springBootVersion: SpringBootVersion['3_1_4'] as SpringBootVersion,
springBootVersion: SpringBootVersion['3_1_5'] as SpringBootVersion,
group: defaultGroup,
name: 'demo',
artifact: 'demo',
Expand Down Expand Up @@ -393,6 +393,8 @@ function removePackage(packageId: string) {
<div
v-for="p in selectedPackageInformation"
:key="'package-' + p.id"
data-selected-package-item="true"
:data-selected-package-item-id="p.id"
class="flex items-center justify-between rounded p-2 shadow"
:class="[
p.supported ? 'bg-white dark:bg-primary-dark-700' : 'bg-error-100 dark:bg-error-500'
Expand Down
4 changes: 3 additions & 1 deletion src/components/DependenciesDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ onBeforeUnmount(() => {
</div>
</div>
<div class="flex h-12 flex-grow overflow-auto" style="margin-top: 2px" ref="packagesList">
<div class="relative flex-1">
<div class="relative flex-1" data-dependencies-list="true">
<div v-for="dependency in dependencies" :key="dependency.id">
<template v-if="dependency.packages.length !== 0">
<div
Expand All @@ -241,6 +241,8 @@ onBeforeUnmount(() => {
</div>
<template v-for="packages in dependency.packages" :key="dependency.id + packages.id">
<div
data-package-item="true"
:data-package-item-id="packages.id"
@click="selectPackage(packages.id)"
class="flex cursor-pointer border-b border-primary-200 p-2 transition duration-100 ease-linear dark:border-primary-500"
:class="{
Expand Down
8 changes: 4 additions & 4 deletions src/components/SpringProject.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,17 @@ function validate() {
<div class="space-x-4 flex">
<BaseInput
v-model="springBootVersion"
:label="SpringBootVersion['3_0_11']"
:label="SpringBootVersion['3_0_12']"
name="springBootVersion"
type="radio"
:value="SpringBootVersion['3_0_11']"
:value="SpringBootVersion['3_0_12']"
></BaseInput>
<BaseInput
v-model="springBootVersion"
:label="SpringBootVersion['3_1_4']"
:label="SpringBootVersion['3_1_5']"
name="springBootVersion"
type="radio"
:value="SpringBootVersion['3_1_4']"
:value="SpringBootVersion['3_1_5']"
></BaseInput>
</div>
</div>
Expand Down
17 changes: 14 additions & 3 deletions src/components/__tests__/DependenciesDialog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,28 @@ describe('DependenciesDialog works correctly', () => {
expect(wrapper.exists()).toBe(true)
})

it('filters dependencies based on input', async () => {
it('shows dependencies list', async () => {
const wrapper = mount(DependenciesDialog, {
props: {
projectType: ProjectType.Spring,
projectType: ProjectType.VueJS,
modelValue: new Set<string>(),
'onUpdate:modelValue': (e: string) => wrapper.setProps({ modelValue: e })
},
global: {
stubs: {
teleport: true
}
}
})

const dialog = wrapper.getComponent(Dialog)
await dialog.vm.$nextTick()
expect(dialog.isVisible()).toBe(true)
await (dialog.vm as any).show()

const input = dialog.find('input[name="dependencies-input-filter"]')
expect(input.exists()).toBe(true)

const dependenciesListContainer = dialog.find('div[data-dependencies-list]')
expect(dependenciesListContainer.exists()).toBe(true)
})
})
4 changes: 2 additions & 2 deletions src/components/__tests__/SpringProject.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('SpringProject works correctly', () => {
valid: false,
metaData: {
language: Language.Java,
springBootVersion: SpringBootVersion['3_1_4'] as SpringBootVersion,
springBootVersion: SpringBootVersion['3_1_5'] as SpringBootVersion,
group: 'test',
name: 'demo',
artifact: 'demo',
Expand All @@ -36,7 +36,7 @@ describe('SpringProject works correctly', () => {
valid: false,
metaData: {
language: Language.Java,
springBootVersion: SpringBootVersion['3_1_4'] as SpringBootVersion,
springBootVersion: SpringBootVersion['3_1_5'] as SpringBootVersion,
group: 'test',
name: 'demo',
artifact: 'demo',
Expand Down
4 changes: 2 additions & 2 deletions src/entity/SpringBootVersion.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export enum SpringBootVersion {
'3_0_11' = '3.0.11',
'3_1_4' = '3.1.4'
'3_0_12' = '3.0.12',
'3_1_5' = '3.1.5'
}
4 changes: 2 additions & 2 deletions src/generator/spring/__tests__/SpringProjectGenerator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function getOutput(fileName: string) {
function getMetadata(language: Language.Kotlin | Language.Java = Language.Java): SpringProject {
return {
language: language,
springBootVersion: SpringBootVersion['3_1_4'],
springBootVersion: SpringBootVersion['3_1_5'],
group: 'com.test',
artifact: 'demo',
packageName: 'demo',
Expand Down Expand Up @@ -56,7 +56,7 @@ describe('Can generate build.gradle properly', () => {
description: 'test',
plugin: true,
groupId: 'org.graalvm.buildtools.native',
version: '0.9.24'
version: '0.9.27'
},
{
name: 'Spring Boot DevTools',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
plugins {
id("org.springframework.boot") version "3.1.4"
id("org.springframework.boot") version "3.1.5"
id("io.spring.dependency-management") version "1.1.3"
kotlin("jvm") version "1.8.22"
kotlin("plugin.spring") version "1.8.22"
id("org.graalvm.buildtools.native") version "0.9.24"
id("org.graalvm.buildtools.native") version "0.9.27"
}

group = "com.test"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("org.springframework.boot") version "3.1.4"
id("org.springframework.boot") version "3.1.5"
id("io.spring.dependency-management") version "1.1.3"
kotlin("jvm") version "1.8.22"
kotlin("plugin.spring") version "1.8.22"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
java
id("org.springframework.boot") version "3.1.4"
id("org.springframework.boot") version "3.1.5"
id("io.spring.dependency-management") version "1.1.3"
}

Expand Down
12 changes: 6 additions & 6 deletions src/stores/dependency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ function getPackageInformationMap(dependencies: Dependency[]): Map<string, Packa

export const dependencyStore = defineStore('dependency', () => {
const dependencies = new Map<string, Dependency[]>()
dependencies.set(`${ProjectType.Spring}${SpringBootVersion['3_0_11']}`, spring3_0_11)
dependencies.set(`${ProjectType.Spring}${SpringBootVersion['3_1_4']}`, spring3_1_4)
dependencies.set(`${ProjectType.Spring}${SpringBootVersion['3_0_12']}`, spring3_0_11)
dependencies.set(`${ProjectType.Spring}${SpringBootVersion['3_1_5']}`, spring3_1_4)
dependencies.set(`${ProjectType.VueJS}`, vuejs)

const packagesName = new Map<string, Set<string>>()
packagesName.set(`${ProjectType.Spring}${SpringBootVersion['3_0_11']}`, getPackageNamesMap(spring3_0_11))
packagesName.set(`${ProjectType.Spring}${SpringBootVersion['3_1_4']}`, getPackageNamesMap(spring3_1_4))
packagesName.set(`${ProjectType.Spring}${SpringBootVersion['3_0_12']}`, getPackageNamesMap(spring3_0_11))
packagesName.set(`${ProjectType.Spring}${SpringBootVersion['3_1_5']}`, getPackageNamesMap(spring3_1_4))
packagesName.set(ProjectType.VueJS, getPackageNamesMap(vuejs))

const packageInformation = new Map<string, Map<string, Package>>()
Expand Down Expand Up @@ -84,7 +84,7 @@ export const dependencyStore = defineStore('dependency', () => {

function dependenciesByProjectTypeForSpring(
projectType: ProjectType,
springBootVersion = SpringBootVersion['3_1_4']
springBootVersion = SpringBootVersion['3_1_5']
): Dependency[] {
if (!dependencies.has(projectType + springBootVersion)) {
throw new Error('Unknown project type ' + projectType)
Expand All @@ -93,7 +93,7 @@ export const dependencyStore = defineStore('dependency', () => {
return dependencies.get(projectType + springBootVersion) ?? []
}

function checkPackageSupportForSpring(springBootVersion = SpringBootVersion['3_1_4'], packageId: string): boolean {
function checkPackageSupportForSpring(springBootVersion = SpringBootVersion['3_1_5'], packageId: string): boolean {
if (!packagesName.has(`${ProjectType.Spring}${springBootVersion}`)) {
throw new Error('Unknown or unsupported Spring Boot version ' + springBootVersion)
}
Expand Down
4 changes: 2 additions & 2 deletions src/stores/spring-3_0_11.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const data: Dependency[] = [
'Support for compiling Spring applications to native executables using the GraalVM native-image compiler.',
plugin: true,
groupId: 'org.graalvm.buildtools.native',
version: '0.9.24'
version: '0.9.27'
},
{
name: 'Spring Boot DevTools',
Expand Down Expand Up @@ -527,7 +527,7 @@ const data: Dependency[] = [
'Spotless is a general-purpose formatting plugin. It is completely à la carte, but also includes powerful "batteries-included" if you opt-in.',
parentName: 'Code Formatter',
groupId: 'com.diffplug.spotless',
version: '6.20.0',
version: '6.22.0',
plugin: true
}
]
Expand Down
4 changes: 2 additions & 2 deletions src/stores/spring-3_1_4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const data: Dependency[] = [
'Support for compiling Spring applications to native executables using the GraalVM native-image compiler.',
plugin: true,
groupId: 'org.graalvm.buildtools.native',
version: '0.9.24'
version: '0.9.27'
},
{
name: 'Spring Boot DevTools',
Expand Down Expand Up @@ -534,7 +534,7 @@ const data: Dependency[] = [
'Spotless is a general-purpose formatting plugin. It is completely à la carte, but also includes powerful "batteries-included" if you opt-in.',
parentName: 'Code Formatter',
groupId: 'com.diffplug.spotless',
version: '6.20.0',
version: '6.22.0',
plugin: true
}
]
Expand Down

0 comments on commit d857326

Please sign in to comment.