Skip to content

Commit

Permalink
test: Migrate share.spec.js
Browse files Browse the repository at this point in the history
- bitly calls to shorten url are stubbed
- toggle short url might be a bit flaky
- remove old spec file
  • Loading branch information
TheGreatRefrigerator committed Jan 26, 2023
1 parent bc97b9e commit 2e5957a
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 83 deletions.
50 changes: 50 additions & 0 deletions src/fragments/forms/map-form/components/share/Share.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import Share from './Share.vue'
import I18nBuilder from '@/i18n/i18n-builder'
import store from '@/store/store'

const mockUrl = 'https://mock_url_123.test'

describe('<Share />', () => {
beforeEach(() => {
cy.viewport(600, 562)
cy.mount(Share, {
i18n: I18nBuilder.build(), store: store, propsData: {
url: mockUrl
}
})
})
it('renders, opens and closes modal', () => {
cy.get('.share-container')
cy.get('.share-modal').should('not.exist')
cy.get('.open-share-btn').click()
cy.get('.share-modal').should('be.visible')
cy.get('.share-modal .box-header .close').click()
cy.get('.share-modal').should('not.exist')
})
it('shows share link correctly, iframe code and ', () => {
cy.get('.open-share-btn').click()
cy.get('input[type="text"]').should('have.value', mockUrl)
})
it('shows iframe code correctly', () => {
cy.get('.open-share-btn').click()
const locale = 'en-us'
store.commit('mapSettings', {locale: locale})
let iframeCode = `<iframe style='border:none' width='100%' height='100%' src="${mockUrl}/embed/${locale}"></iframe>`
cy.get('textarea').should('have.value', iframeCode)
})
it('toggles short url', () => {
cy.get('.open-share-btn').click()
cy.intercept('GET', '**/v3/shorten*', (req) => {
req.reply({
'status_code': 200,
'data': {
'url': 'https://bit.ly/3ZHDUoZ',
}
})
})
cy.get('.toggle-short-url').click()
cy.get('input[type="text"]').should('contain.value', 'https://bit.ly/')
cy.get('.toggle-short-url').click()
cy.get('input[type="text"]').should('have.value', mockUrl)
})
})
83 changes: 0 additions & 83 deletions tests/integration/specs/share.spec.js

This file was deleted.

0 comments on commit 2e5957a

Please sign in to comment.